@nypl/design-system-react-components 0.25.5 → 0.25.9
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 +91 -1
- package/README.md +1 -1
- package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +1 -0
- package/dist/components/Button/Button.d.ts +6 -6
- package/dist/components/Button/ButtonTypes.d.ts +0 -1
- package/dist/components/Card/Card.d.ts +6 -4
- package/dist/components/Checkbox/Checkbox.d.ts +3 -2
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +3 -2
- package/dist/components/ComponentWrapper/ComponentWrapper.d.ts +8 -2
- package/dist/components/DatePicker/DatePicker.d.ts +3 -2
- package/dist/components/Form/Form.d.ts +2 -2
- package/dist/components/Heading/Heading.d.ts +7 -3
- package/dist/components/Heading/HeadingTypes.d.ts +6 -6
- package/dist/components/HelperErrorText/HelperErrorText.d.ts +5 -2
- package/dist/components/HorizontalRule/HorizontalRule.d.ts +2 -2
- package/dist/components/Icons/Icon.d.ts +4 -4
- package/dist/components/Icons/IconSvgs.d.ts +1 -21
- package/dist/components/Icons/IconTypes.d.ts +1 -23
- package/dist/components/Image/Image.d.ts +11 -3
- package/dist/components/Image/ImageTypes.d.ts +3 -1
- package/dist/components/Link/LinkTypes.d.ts +1 -0
- package/dist/components/Logo/Logo.d.ts +28 -0
- package/dist/components/Logo/LogoSvgs.d.ts +18 -0
- package/dist/components/Logo/LogoTypes.d.ts +30 -0
- package/dist/components/Modal/Modal.d.ts +0 -4
- package/dist/components/Notification/Notification.d.ts +4 -2
- package/dist/components/Placeholder/Placeholder.d.ts +3 -5
- package/dist/components/Radio/Radio.d.ts +6 -5
- package/dist/components/RadioGroup/RadioGroup.d.ts +3 -2
- package/dist/components/SearchBar/SearchBar.d.ts +10 -2
- package/dist/components/Select/Select.d.ts +5 -2
- package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +8 -4
- package/dist/components/Slider/Slider.d.ts +3 -2
- package/dist/components/StatusBadge/StatusBadge.d.ts +2 -1
- package/dist/components/StructuredContent/StructuredContent.d.ts +41 -0
- package/dist/components/StructuredContent/StructuredContentTypes.d.ts +5 -0
- package/dist/components/Table/Table.d.ts +23 -0
- package/dist/components/Template/Template.d.ts +8 -3
- package/dist/components/Text/Text.d.ts +2 -2
- package/dist/components/TextInput/TextInput.d.ts +4 -3
- package/dist/components/Toggle/Toggle.d.ts +48 -0
- package/dist/components/Toggle/ToggleSizes.d.ts +4 -0
- package/dist/components/VideoPlayer/VideoPlayer.d.ts +17 -6
- package/dist/design-system-react-components.cjs.development.js +5989 -5490
- 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 +6057 -5551
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/index.d.ts +11 -4
- package/dist/styles.css +2 -2
- package/dist/theme/components/breadcrumb.d.ts +9 -0
- package/dist/theme/components/button.d.ts +0 -12
- package/dist/theme/components/card.d.ts +14 -2
- package/dist/theme/components/customTable.d.ts +47 -0
- package/dist/theme/components/fieldset.d.ts +2 -2
- package/dist/theme/components/global.d.ts +1 -1
- package/dist/theme/components/heading.d.ts +4 -0
- package/dist/theme/components/label.d.ts +1 -1
- package/dist/theme/components/link.d.ts +14 -1
- package/dist/theme/components/list.d.ts +0 -2
- package/dist/theme/components/logo.d.ts +4 -0
- package/dist/theme/components/notification.d.ts +8 -4
- package/dist/theme/components/searchBar.d.ts +7 -13
- package/dist/theme/components/select.d.ts +1 -0
- package/dist/theme/components/structuredContent.d.ts +33 -0
- package/dist/theme/components/template.d.ts +10 -10
- package/dist/theme/components/textInput.d.ts +2 -0
- package/dist/theme/components/toggle.d.ts +71 -0
- package/dist/theme/foundations/spacing.d.ts +2 -0
- package/dist/utils/utils.d.ts +10 -0
- package/package.json +2 -3
- package/src/__tests__/utils/utils.test.ts +23 -1
- package/src/components/Accordion/Accordion.stories.mdx +15 -14
- package/src/components/Autosuggest/Autosuggest.stories.mdx +2 -1
- package/src/components/Autosuggest/Autosuggest.stories.tsx +24 -48
- package/src/components/Autosuggest/_Autosuggest.scss +2 -6
- package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +50 -14
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +20 -0
- package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +1 -0
- package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +198 -0
- package/src/components/Button/Button.stories.mdx +93 -48
- package/src/components/Button/Button.test.tsx +0 -12
- package/src/components/Button/Button.tsx +7 -8
- package/src/components/Button/ButtonTypes.tsx +0 -1
- package/src/components/Button/__snapshots__/Button.test.tsx.snap +0 -12
- package/src/components/Card/Card.stories.mdx +246 -64
- package/src/components/Card/Card.test.tsx +45 -22
- package/src/components/Card/Card.tsx +26 -13
- package/src/components/Card/__snapshots__/Card.test.tsx.snap +75 -37
- package/src/components/Chakra/Box.stories.mdx +3 -3
- package/src/components/Chakra/Center.stories.mdx +5 -5
- package/src/components/Chakra/Grid.stories.mdx +14 -17
- package/src/components/Chakra/Stack.stories.mdx +2 -2
- package/src/components/Checkbox/Checkbox.stories.mdx +37 -15
- package/src/components/Checkbox/Checkbox.tsx +13 -8
- package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +48 -16
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +14 -10
- package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +6 -3
- package/src/components/ComponentWrapper/ComponentWrapper.test.tsx +151 -0
- package/src/components/ComponentWrapper/ComponentWrapper.tsx +36 -23
- package/src/components/ComponentWrapper/__snapshots__/ComponentWrapper.test.tsx.snap +85 -0
- package/src/components/DatePicker/DatePicker.stories.mdx +63 -18
- package/src/components/DatePicker/DatePicker.test.tsx +8 -6
- package/src/components/DatePicker/DatePicker.tsx +10 -6
- package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +41 -22
- package/src/components/Fieldset/Fieldset.stories.mdx +19 -8
- package/src/components/Form/Form.stories.mdx +49 -41
- package/src/components/Form/Form.tsx +5 -4
- package/src/components/Grid/SimpleGrid.stories.mdx +26 -26
- package/src/components/Heading/Heading.stories.mdx +59 -23
- package/src/components/Heading/Heading.test.tsx +82 -18
- package/src/components/Heading/Heading.tsx +31 -31
- package/src/components/Heading/HeadingTypes.tsx +6 -6
- package/src/components/Heading/__snapshots__/Heading.test.tsx.snap +71 -0
- package/src/components/HelperErrorText/HelperErrorText.stories.mdx +55 -27
- package/src/components/HelperErrorText/HelperErrorText.test.tsx +42 -15
- package/src/components/HelperErrorText/HelperErrorText.tsx +24 -24
- package/src/components/HelperErrorText/__snapshots__/HelperErrorText.test.tsx.snap +41 -4
- package/src/components/Hero/Hero.stories.mdx +72 -53
- package/src/components/HorizontalRule/HorizontalRule.stories.mdx +9 -8
- package/src/components/HorizontalRule/HorizontalRule.tsx +2 -4
- package/src/components/Icons/Icon.stories.mdx +77 -75
- package/src/components/Icons/Icon.tsx +4 -5
- package/src/components/Icons/IconSvgs.tsx +2 -42
- package/src/components/Icons/IconTypes.tsx +1 -24
- package/src/components/Image/Image.stories.mdx +214 -104
- package/src/components/Image/Image.test.tsx +10 -0
- package/src/components/Image/Image.tsx +21 -10
- package/src/components/Image/ImageTypes.ts +2 -0
- package/src/components/Image/__snapshots__/Image.test.tsx.snap +24 -8
- package/src/components/Label/Label.stories.mdx +21 -20
- package/src/components/Link/Link.stories.mdx +103 -53
- package/src/components/Link/Link.test.tsx +108 -7
- package/src/components/Link/Link.tsx +58 -19
- package/src/components/Link/LinkTypes.tsx +1 -0
- package/src/components/Link/__snapshots__/Link.test.tsx.snap +261 -0
- package/src/components/List/List.stories.mdx +36 -24
- package/src/components/Logo/Logo.stories.mdx +220 -0
- package/src/components/Logo/Logo.test.tsx +98 -0
- package/src/components/Logo/Logo.tsx +97 -0
- package/src/components/Logo/LogoSvgs.tsx +34 -0
- package/src/components/Logo/LogoTypes.tsx +32 -0
- package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +71 -0
- package/src/components/Modal/Modal.stories.mdx +20 -5
- package/src/components/Modal/Modal.tsx +2 -8
- package/src/components/Notification/Notification.stories.mdx +96 -40
- package/src/components/Notification/Notification.test.tsx +62 -16
- package/src/components/Notification/Notification.tsx +26 -9
- package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +121 -0
- package/src/components/Pagination/Pagination.stories.mdx +18 -8
- package/src/components/Pagination/Pagination.tsx +1 -1
- package/src/components/Pagination/__snapshots__/Pagination.test.tsx.snap +42 -0
- package/src/components/Placeholder/Placeholder.tsx +7 -14
- package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +74 -46
- package/src/components/Radio/Radio.stories.mdx +39 -19
- package/src/components/Radio/Radio.tsx +13 -9
- package/src/components/RadioGroup/RadioGroup.stories.mdx +50 -16
- package/src/components/RadioGroup/RadioGroup.tsx +15 -11
- package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +6 -3
- package/src/components/SearchBar/SearchBar.Test.tsx +114 -22
- package/src/components/SearchBar/SearchBar.stories.mdx +111 -33
- package/src/components/SearchBar/SearchBar.tsx +57 -33
- package/src/components/Select/Select.stories.mdx +177 -66
- package/src/components/Select/Select.test.tsx +2 -2
- package/src/components/Select/Select.tsx +22 -12
- package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +50 -16
- package/src/components/SkeletonLoader/SkeletonLoader.tsx +8 -4
- package/src/components/Slider/Slider.stories.mdx +74 -23
- package/src/components/Slider/Slider.test.tsx +35 -0
- package/src/components/Slider/Slider.tsx +22 -11
- package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +60 -30
- package/src/components/StatusBadge/StatusBadge.stories.mdx +33 -18
- package/src/components/StatusBadge/StatusBadge.tsx +2 -1
- package/src/components/StructuredContent/StructuredContent.stories.mdx +427 -0
- package/src/components/StructuredContent/StructuredContent.test.tsx +376 -0
- package/src/components/StructuredContent/StructuredContent.tsx +153 -0
- package/src/components/StructuredContent/StructuredContentTypes.tsx +5 -0
- package/src/components/StructuredContent/__snapshots__/StructuredContent.test.tsx.snap +283 -0
- package/src/components/StyleGuide/Bidirectionality.stories.mdx +32 -83
- package/src/components/StyleGuide/Breakpoints.stories.mdx +1 -11
- package/src/components/StyleGuide/Buttons.stories.mdx +3 -18
- package/src/components/StyleGuide/ColorCard.tsx +1 -2
- package/src/components/StyleGuide/Colors.stories.mdx +3 -11
- package/src/components/StyleGuide/DesignTokens.stories.mdx +3 -8
- package/src/components/StyleGuide/Forms.stories.mdx +2 -10
- package/src/components/StyleGuide/Iconography.stories.mdx +8 -34
- package/src/components/StyleGuide/Spacing.stories.mdx +3 -14
- package/src/components/StyleGuide/Typography.stories.mdx +64 -76
- package/src/components/Table/Table.stories.mdx +66 -0
- package/src/components/Table/Table.test.tsx +60 -0
- package/src/components/Table/Table.tsx +116 -0
- package/src/components/Tabs/Tabs.stories.mdx +19 -13
- package/src/components/Tabs/Tabs.test.tsx +1 -1
- package/src/components/Template/Template.stories.mdx +57 -49
- package/src/components/Template/Template.test.tsx +65 -5
- package/src/components/Template/Template.tsx +35 -5
- package/src/components/Template/__snapshots__/Template.test.tsx.snap +76 -0
- package/src/components/Text/Text.stories.mdx +33 -11
- package/src/components/Text/Text.tsx +2 -2
- package/src/components/TextInput/TextInput.stories.mdx +84 -17
- package/src/components/TextInput/TextInput.test.tsx +96 -0
- package/src/components/TextInput/TextInput.tsx +12 -8
- package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +240 -0
- package/src/components/Toggle/Toggle.stories.mdx +200 -0
- package/src/components/Toggle/Toggle.test.tsx +140 -0
- package/src/components/Toggle/Toggle.tsx +123 -0
- package/src/components/Toggle/ToggleSizes.tsx +4 -0
- package/src/components/Toggle/__snapshots__/Toggle.test.tsx.snap +255 -0
- package/src/components/VideoPlayer/VideoPlayer.stories.mdx +96 -25
- package/src/components/VideoPlayer/VideoPlayer.test.tsx +103 -1
- package/src/components/VideoPlayer/VideoPlayer.tsx +72 -22
- package/src/components/VideoPlayer/__snapshots__/VideoPlayer.test.tsx.snap +57 -3
- package/src/docs/Chakra.stories.mdx +5 -8
- package/src/docs/Intro.stories.mdx +2 -2
- package/src/index.ts +13 -4
- package/src/styles/base/_03-base.scss +1 -1
- package/src/styles/base/_place-holder.scss +7 -7
- package/src/styles.scss +1 -5
- package/src/theme/components/breadcrumb.ts +14 -4
- package/src/theme/components/button.ts +5 -12
- package/src/theme/components/card.ts +9 -7
- package/src/theme/components/checkbox.ts +1 -1
- package/src/theme/components/customTable.ts +50 -0
- package/src/theme/components/datePicker.ts +1 -1
- package/src/theme/components/global.ts +7 -7
- package/src/theme/components/heading.ts +13 -11
- package/src/theme/components/helperErrorText.ts +1 -1
- package/src/theme/components/icon.ts +2 -2
- package/src/theme/components/image.ts +9 -1
- package/src/theme/components/link.ts +17 -5
- package/src/theme/components/list.ts +1 -3
- package/src/theme/components/logo.ts +54 -0
- package/src/theme/components/notification.ts +9 -7
- package/src/theme/components/searchBar.ts +7 -13
- package/src/theme/components/select.ts +1 -0
- package/src/theme/components/statusBadge.ts +1 -1
- package/src/theme/components/structuredContent.ts +54 -0
- package/src/theme/components/template.ts +10 -10
- package/src/theme/components/text.ts +6 -6
- package/src/theme/components/textInput.ts +1 -0
- package/src/theme/components/toggle.ts +69 -0
- package/src/theme/components/videoPlayer.ts +0 -2
- package/src/theme/foundations/global.ts +2 -2
- package/src/theme/foundations/spacing.ts +3 -0
- package/src/theme/foundations/typography.ts +84 -12
- package/src/theme/index.ts +8 -0
- package/src/utils/componentCategories.ts +4 -2
- package/src/utils/utils.ts +17 -0
- package/dist/__tests__/utils/bem.test.d.ts +0 -1
- package/dist/components/CardEdition/CardEdition.d.ts +0 -21
- package/dist/components/CardEdition/CardEdition.stories.d.ts +0 -27
- package/dist/components/Input/Input.d.ts +0 -36
- package/dist/components/Input/Input.stories.d.ts +0 -29
- package/dist/components/Input/InputTypes.d.ts +0 -6
- package/dist/components/StyleGuide/UIDocCard.d.ts +0 -11
- package/dist/helpers/CSSVariablesHelper.d.ts +0 -3
- package/dist/helpers/getCSSVariable.d.ts +0 -1
- package/dist/interfaces.d.ts +0 -3
- package/dist/utils/bem.d.ts +0 -1
- package/src/__tests__/utils/bem.test.ts +0 -37
- package/src/components/CardEdition/CardEdition.stories.tsx +0 -122
- package/src/components/CardEdition/CardEdition.test.tsx +0 -395
- package/src/components/CardEdition/CardEdition.tsx +0 -60
- package/src/components/CardEdition/_CardEdition.scss +0 -137
- package/src/components/Input/Input.stories.tsx +0 -133
- package/src/components/Input/Input.test.tsx +0 -266
- package/src/components/Input/Input.tsx +0 -81
- package/src/components/Input/InputTypes.tsx +0 -8
- package/src/components/Input/_Input.scss +0 -78
- package/src/components/StyleGuide/UIDocCard.tsx +0 -36
- package/src/helpers/CSSVariablesHelper.tsx +0 -34
- package/src/helpers/getCSSVariable.tsx +0 -5
- package/src/interfaces.ts +0 -3
- package/src/utils/bem.ts +0 -44
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Meta,
|
|
3
|
-
Story,
|
|
4
2
|
ArgsTable,
|
|
5
3
|
Canvas,
|
|
6
4
|
Description,
|
|
7
|
-
|
|
5
|
+
Meta,
|
|
6
|
+
Story,
|
|
7
|
+
} from "@storybook/addon-docs";
|
|
8
8
|
import { withDesign } from "storybook-addon-designs";
|
|
9
9
|
|
|
10
10
|
import SearchBar from "./SearchBar";
|
|
@@ -19,22 +19,39 @@ import DSProvider from "../../theme/provider";
|
|
|
19
19
|
parameters={{
|
|
20
20
|
design: {
|
|
21
21
|
type: "figma",
|
|
22
|
-
url:
|
|
23
|
-
"https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Master?node-id=11689%3A423",
|
|
22
|
+
url: "https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Master?node-id=11689%3A423",
|
|
24
23
|
},
|
|
25
24
|
jest: ["SearchBar.test.tsx"],
|
|
26
25
|
}}
|
|
27
26
|
argTypes={{
|
|
28
|
-
action: {
|
|
29
|
-
ariaLabel: {
|
|
30
|
-
buttonOnClick: {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
action: { control: false },
|
|
28
|
+
ariaLabel: { control: false },
|
|
29
|
+
buttonOnClick: {
|
|
30
|
+
control: false,
|
|
31
|
+
table: { defaultValue: { summary: "null" } },
|
|
32
|
+
},
|
|
33
|
+
className: { control: false },
|
|
34
|
+
id: { control: false },
|
|
35
|
+
isDisabled: {
|
|
36
|
+
table: { defaultValue: { summary: false } },
|
|
37
|
+
},
|
|
38
|
+
isInvalid: {
|
|
39
|
+
table: { defaultValue: { summary: false } },
|
|
40
|
+
},
|
|
41
|
+
isRequired: {
|
|
42
|
+
table: { defaultValue: { summary: false } },
|
|
43
|
+
},
|
|
44
|
+
method: { control: false },
|
|
45
|
+
onSubmit: { control: false },
|
|
46
|
+
selectProps: { control: false },
|
|
47
|
+
showHelperText: {
|
|
48
|
+
description: "Only used for Storybook",
|
|
49
|
+
},
|
|
50
|
+
showSelect: {
|
|
51
|
+
description: "Only used for Storybook",
|
|
52
|
+
},
|
|
53
|
+
textInputElement: { control: false },
|
|
54
|
+
textInputProps: { control: false },
|
|
38
55
|
}}
|
|
39
56
|
/>
|
|
40
57
|
|
|
@@ -43,7 +60,7 @@ import DSProvider from "../../theme/provider";
|
|
|
43
60
|
| Component Version | DS Version |
|
|
44
61
|
| ----------------- | ---------- |
|
|
45
62
|
| Added | `0.0.4` |
|
|
46
|
-
| Latest | `0.25.
|
|
63
|
+
| Latest | `0.25.9` |
|
|
47
64
|
|
|
48
65
|
<Description of={SearchBar} />
|
|
49
66
|
|
|
@@ -74,20 +91,30 @@ export const optionsGroup = [
|
|
|
74
91
|
|
|
75
92
|
<Canvas withToolbar>
|
|
76
93
|
<Story
|
|
77
|
-
name="
|
|
94
|
+
name="SearchBar with Controls"
|
|
78
95
|
args={{
|
|
79
|
-
|
|
96
|
+
action: undefined,
|
|
97
|
+
buttonOnClick: undefined,
|
|
98
|
+
className: undefined,
|
|
99
|
+
helperText: "Search for items in Animal Crossing New Horizons",
|
|
100
|
+
id: "searchBar-id",
|
|
80
101
|
invalidText: "Could not find the item :(",
|
|
81
102
|
isDisabled: false,
|
|
82
103
|
isInvalid: false,
|
|
83
104
|
isRequired: false,
|
|
105
|
+
labelText: "SearchBar Label",
|
|
106
|
+
method: undefined,
|
|
107
|
+
noBrandButtonType: false,
|
|
108
|
+
onSubmit: () => {},
|
|
109
|
+
selectProps: undefined,
|
|
84
110
|
showHelperText: true,
|
|
85
111
|
showSelect: true,
|
|
112
|
+
textInputElement: undefined,
|
|
113
|
+
textInputProps: undefined,
|
|
86
114
|
}}
|
|
87
115
|
>
|
|
88
116
|
{(args) => (
|
|
89
117
|
<SearchBar
|
|
90
|
-
onSubmit={() => {}}
|
|
91
118
|
{...args}
|
|
92
119
|
selectProps={
|
|
93
120
|
args.showSelect && {
|
|
@@ -101,13 +128,13 @@ export const optionsGroup = [
|
|
|
101
128
|
name: "textInputName",
|
|
102
129
|
placeholder: "Item Search",
|
|
103
130
|
}}
|
|
104
|
-
|
|
131
|
+
helperText={args.showHelperText && args.helperText}
|
|
105
132
|
/>
|
|
106
133
|
)}
|
|
107
134
|
</Story>
|
|
108
135
|
</Canvas>
|
|
109
136
|
|
|
110
|
-
<ArgsTable story="
|
|
137
|
+
<ArgsTable story="SearchBar with Controls" />
|
|
111
138
|
|
|
112
139
|
## Component Props
|
|
113
140
|
|
|
@@ -182,23 +209,54 @@ A `Button` component will automatically be rendered for the `SearchBar`
|
|
|
182
209
|
component. If you want to pass a callback function to the `Button`, use the
|
|
183
210
|
`buttonOnClick` prop.
|
|
184
211
|
|
|
212
|
+
It's also possible to render the `ButtonType.NoBrand` variant style when the
|
|
213
|
+
`noBrandButtonType` prop is set to `true`. The `ButtonType.Primary` variant
|
|
214
|
+
style is used by default.
|
|
215
|
+
|
|
185
216
|
### HelperErrorText Component
|
|
186
217
|
|
|
187
|
-
To render the `HelperErrorText` component, pass a string
|
|
188
|
-
`
|
|
189
|
-
error string in the `invalidText` prop.
|
|
218
|
+
To render the `HelperErrorText` component, pass a string or HTML to the
|
|
219
|
+
`helperText` prop. For the invalid state when `isInvalid` is true, pass the
|
|
220
|
+
error string or HTML in the `invalidText` prop.
|
|
190
221
|
|
|
191
222
|
```
|
|
192
|
-
const
|
|
223
|
+
const helperText = "";
|
|
193
224
|
|
|
194
225
|
// ...
|
|
195
226
|
<SearchBar
|
|
196
227
|
onSubmit={() => {}}
|
|
197
|
-
|
|
228
|
+
helperText="Search for items in <b>Animal Crossing New Horizons</b>."
|
|
198
229
|
// ...
|
|
199
230
|
/>
|
|
200
231
|
```
|
|
201
232
|
|
|
233
|
+
<Canvas>
|
|
234
|
+
<DSProvider>
|
|
235
|
+
<SearchBar
|
|
236
|
+
descriptionText="The helper text below contains HTML in a string."
|
|
237
|
+
helperText="Search for items in <b>Animal Crossing New Horizons</b>."
|
|
238
|
+
onSubmit={() => {}}
|
|
239
|
+
textInputProps={{
|
|
240
|
+
labelText: "Item Search",
|
|
241
|
+
name: "textInputName",
|
|
242
|
+
placeholder: "Item Search",
|
|
243
|
+
}}
|
|
244
|
+
/>
|
|
245
|
+
<br />
|
|
246
|
+
<SearchBar
|
|
247
|
+
descriptionText="The invalid text below contains HTML in a string."
|
|
248
|
+
isInvalid
|
|
249
|
+
invalidText="Could <b>not</b> find the item <b>:(</b>"
|
|
250
|
+
onSubmit={() => {}}
|
|
251
|
+
textInputProps={{
|
|
252
|
+
labelText: "Item Search",
|
|
253
|
+
name: "textInputName",
|
|
254
|
+
placeholder: "Item Search",
|
|
255
|
+
}}
|
|
256
|
+
/>
|
|
257
|
+
</DSProvider>
|
|
258
|
+
</Canvas>
|
|
259
|
+
|
|
202
260
|
## Search Autocomplete
|
|
203
261
|
|
|
204
262
|
While the Design System does not implement an `Autosuggest` or `Autocomplete`
|
|
@@ -226,7 +284,7 @@ precedence.
|
|
|
226
284
|
<SearchBar
|
|
227
285
|
onSubmit={() => {}}
|
|
228
286
|
textInputElement={stories.SearchBarExample()}
|
|
229
|
-
|
|
287
|
+
helperText="Select your home library. Start by typing the name of the library. Try 'ba'."
|
|
230
288
|
{...args}
|
|
231
289
|
/>
|
|
232
290
|
</div>
|
|
@@ -254,7 +312,7 @@ handle the error state yourself.
|
|
|
254
312
|
name: "textInputName",
|
|
255
313
|
placeholder: "Item Search",
|
|
256
314
|
}}
|
|
257
|
-
|
|
315
|
+
helperText="This is the helper text!"
|
|
258
316
|
invalidText="Could not find the item :("
|
|
259
317
|
isInvalid
|
|
260
318
|
/>
|
|
@@ -270,18 +328,38 @@ handle the disabled state yourself.
|
|
|
270
328
|
<Canvas>
|
|
271
329
|
<DSProvider>
|
|
272
330
|
<SearchBar
|
|
273
|
-
|
|
331
|
+
onSubmit={() => {}}
|
|
274
332
|
textInputProps={{
|
|
275
333
|
labelText: "Item Search",
|
|
276
334
|
name: "textInputName",
|
|
277
335
|
placeholder: "Item Search",
|
|
278
336
|
}}
|
|
279
|
-
|
|
337
|
+
helperText="Reason for disabled state."
|
|
280
338
|
isDisabled
|
|
281
339
|
/>
|
|
282
340
|
</DSProvider>
|
|
283
341
|
</Canvas>
|
|
284
342
|
|
|
343
|
+
### With Heading and Description Text
|
|
344
|
+
|
|
345
|
+
Use the `descriptionText` and `headingText` props to render a heading and
|
|
346
|
+
description above the main `SearchBar` form component.
|
|
347
|
+
|
|
348
|
+
<Canvas>
|
|
349
|
+
<DSProvider>
|
|
350
|
+
<SearchBar
|
|
351
|
+
descriptionText="This is the description for this `SearchBar` instance."
|
|
352
|
+
headingText="Heading for this `SearchBar`"
|
|
353
|
+
onSubmit={() => {}}
|
|
354
|
+
textInputProps={{
|
|
355
|
+
labelText: "Item Search",
|
|
356
|
+
name: "textInputName",
|
|
357
|
+
placeholder: "Item Search",
|
|
358
|
+
}}
|
|
359
|
+
/>
|
|
360
|
+
</DSProvider>
|
|
361
|
+
</Canvas>
|
|
362
|
+
|
|
285
363
|
### TextInput and onSubmit Values
|
|
286
364
|
|
|
287
365
|
_NOTE: open the browser console to see the values logged in the example below._
|
|
@@ -312,7 +390,7 @@ function SearchBarValueExample() {
|
|
|
312
390
|
};
|
|
313
391
|
const onSubmit = (event) => {
|
|
314
392
|
event.preventDefault();
|
|
315
|
-
console.log(`onSubmit Select value: ${event.target.
|
|
393
|
+
console.log(`onSubmit Select value: ${event.target.selectName.value}`);
|
|
316
394
|
console.log(`onSubmit TextInput value ${event.target.textInputName.value}`);
|
|
317
395
|
};
|
|
318
396
|
return (
|
|
@@ -329,7 +407,7 @@ function SearchBarValueExample() {
|
|
|
329
407
|
onChange: textInputOnChange,
|
|
330
408
|
placeholder: "Item Search",
|
|
331
409
|
}}
|
|
332
|
-
|
|
410
|
+
helperText="Search for an item"
|
|
333
411
|
invalidText="Could not find the item :("
|
|
334
412
|
/>
|
|
335
413
|
);
|
|
@@ -359,7 +437,7 @@ export function SearchBarValueExample() {
|
|
|
359
437
|
onChange: textInputOnChange,
|
|
360
438
|
placeholder: "Item Search",
|
|
361
439
|
}}
|
|
362
|
-
|
|
440
|
+
helperText="Search for an item"
|
|
363
441
|
invalidText="Could not find the item :("
|
|
364
442
|
/>
|
|
365
443
|
);
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
1
|
import { Box, useMultiStyleConfig } from "@chakra-ui/react";
|
|
2
|
+
import * as React from "react";
|
|
3
3
|
|
|
4
|
-
import generateUUID from "../../helpers/generateUUID";
|
|
5
|
-
import Select from "../Select/Select";
|
|
6
|
-
import TextInput from "../TextInput/TextInput";
|
|
7
|
-
import { TextInputTypes, TextInputVariants } from "../TextInput/TextInputTypes";
|
|
8
4
|
import Button from "../Button/Button";
|
|
9
5
|
import { ButtonTypes } from "../Button/ButtonTypes";
|
|
6
|
+
import ComponentWrapper from "../ComponentWrapper/ComponentWrapper";
|
|
7
|
+
import { HelperErrorTextType } from "../HelperErrorText/HelperErrorText";
|
|
10
8
|
import Icon from "../Icons/Icon";
|
|
11
9
|
import { IconAlign, IconNames, IconSizes } from "../Icons/IconTypes";
|
|
12
|
-
import
|
|
10
|
+
import Select from "../Select/Select";
|
|
13
11
|
import { SelectTypes } from "../Select/SelectTypes";
|
|
12
|
+
import TextInput from "../TextInput/TextInput";
|
|
13
|
+
import { TextInputTypes, TextInputVariants } from "../TextInput/TextInputTypes";
|
|
14
|
+
import generateUUID from "../../helpers/generateUUID";
|
|
14
15
|
|
|
15
16
|
// Internal interfaces that are used only for `SearchBar` props.
|
|
16
17
|
interface SelectProps {
|
|
@@ -37,13 +38,17 @@ export interface SearchBarProps {
|
|
|
37
38
|
buttonOnClick?: (event: React.MouseEvent | React.KeyboardEvent) => void;
|
|
38
39
|
/** A class name for the `form` element. */
|
|
39
40
|
className?: string;
|
|
41
|
+
/** Optional string for the SearchBar's description above the component. */
|
|
42
|
+
descriptionText?: string;
|
|
43
|
+
/** Optional string for the SearchBar's heading text above the component. */
|
|
44
|
+
headingText?: string;
|
|
40
45
|
/** The text to display below the form in a `HelperErrorText` component. */
|
|
41
|
-
|
|
46
|
+
helperText?: HelperErrorTextType;
|
|
42
47
|
/** ID that other components can cross reference for accessibility purposes */
|
|
43
48
|
id?: string;
|
|
44
49
|
/** Optional string to populate the `HelperErrorText` for the error state
|
|
45
50
|
* when `isInvalid` is true. */
|
|
46
|
-
invalidText?:
|
|
51
|
+
invalidText?: HelperErrorTextType;
|
|
47
52
|
/** Sets children form components in the disabled state. */
|
|
48
53
|
isDisabled?: boolean;
|
|
49
54
|
/** Sets children form components in the error state. */
|
|
@@ -54,6 +59,9 @@ export interface SearchBarProps {
|
|
|
54
59
|
labelText: string;
|
|
55
60
|
/** Adds 'method' property to the `form` element. */
|
|
56
61
|
method?: string;
|
|
62
|
+
/** Sets the `Button` variant type to `ButtonTypes.NoBrand` when true;
|
|
63
|
+
* false by default which sets the type to `ButtonTypes.Primary`. */
|
|
64
|
+
noBrandButtonType?: boolean;
|
|
57
65
|
/** Handler function when the form is submitted. */
|
|
58
66
|
onSubmit: (event: React.FormEvent) => void;
|
|
59
67
|
/** Required props to render a `Select` element. */
|
|
@@ -73,7 +81,9 @@ export default function SearchBar(props: SearchBarProps) {
|
|
|
73
81
|
action,
|
|
74
82
|
buttonOnClick = null,
|
|
75
83
|
className,
|
|
76
|
-
|
|
84
|
+
descriptionText,
|
|
85
|
+
headingText,
|
|
86
|
+
helperText,
|
|
77
87
|
id = generateUUID(),
|
|
78
88
|
invalidText,
|
|
79
89
|
isDisabled = false,
|
|
@@ -81,6 +91,7 @@ export default function SearchBar(props: SearchBarProps) {
|
|
|
81
91
|
isRequired = false,
|
|
82
92
|
labelText,
|
|
83
93
|
method,
|
|
94
|
+
noBrandButtonType = false,
|
|
84
95
|
onSubmit,
|
|
85
96
|
selectProps,
|
|
86
97
|
textInputElement,
|
|
@@ -97,8 +108,20 @@ export default function SearchBar(props: SearchBarProps) {
|
|
|
97
108
|
};
|
|
98
109
|
const helperErrorTextID = generateUUID();
|
|
99
110
|
const ariaDescribedby = helperErrorTextID;
|
|
100
|
-
const footnote = isInvalid ? invalidText :
|
|
111
|
+
const footnote = isInvalid ? invalidText : helperText;
|
|
101
112
|
const finalAriaLabel = footnote ? `${labelText} - ${footnote}` : labelText;
|
|
113
|
+
const textInputPlaceholder = `${textInputProps?.placeholder} ${
|
|
114
|
+
isRequired ? "(Required)" : ""
|
|
115
|
+
}`;
|
|
116
|
+
const buttonType = noBrandButtonType
|
|
117
|
+
? ButtonTypes.NoBrand
|
|
118
|
+
: ButtonTypes.Primary;
|
|
119
|
+
const searchBarButtonStyles = {
|
|
120
|
+
borderLeftRadius: "none",
|
|
121
|
+
borderRightRadius: { base: "none", md: "sm" },
|
|
122
|
+
lineHeight: "1.70",
|
|
123
|
+
marginBottom: "auto",
|
|
124
|
+
};
|
|
102
125
|
// Render the `Select` component.
|
|
103
126
|
const selectElem = selectProps && (
|
|
104
127
|
<Select
|
|
@@ -120,7 +143,7 @@ export default function SearchBar(props: SearchBarProps) {
|
|
|
120
143
|
<TextInput
|
|
121
144
|
id={generateUUID()}
|
|
122
145
|
labelText={textInputProps?.labelText}
|
|
123
|
-
placeholder={
|
|
146
|
+
placeholder={textInputPlaceholder}
|
|
124
147
|
onChange={textInputProps?.onChange}
|
|
125
148
|
name={textInputProps?.name}
|
|
126
149
|
type={TextInputTypes.text}
|
|
@@ -136,11 +159,12 @@ export default function SearchBar(props: SearchBarProps) {
|
|
|
136
159
|
// Render the `Button` component.
|
|
137
160
|
const buttonElem = (
|
|
138
161
|
<Button
|
|
162
|
+
additionalStyles={searchBarButtonStyles}
|
|
163
|
+
buttonType={buttonType}
|
|
139
164
|
id={generateUUID()}
|
|
140
|
-
buttonType={ButtonTypes.SearchBar}
|
|
141
|
-
type="submit"
|
|
142
|
-
onClick={buttonOnClick}
|
|
143
165
|
isDisabled={isDisabled}
|
|
166
|
+
onClick={buttonOnClick}
|
|
167
|
+
type="submit"
|
|
144
168
|
>
|
|
145
169
|
<Icon
|
|
146
170
|
name={IconNames.Search}
|
|
@@ -150,35 +174,35 @@ export default function SearchBar(props: SearchBarProps) {
|
|
|
150
174
|
Search
|
|
151
175
|
</Button>
|
|
152
176
|
);
|
|
153
|
-
// Render the `HelperErrorText` component.
|
|
154
|
-
const helperErrorTextElem = footnote && (
|
|
155
|
-
<HelperErrorText id={helperErrorTextID} isInvalid={isInvalid}>
|
|
156
|
-
{footnote}
|
|
157
|
-
</HelperErrorText>
|
|
158
|
-
);
|
|
159
177
|
// If a custom input element was passed, use that instead of the
|
|
160
178
|
// `TextInput` component.
|
|
161
179
|
const textInputElem = textInputElement || textInputNative;
|
|
162
180
|
|
|
163
181
|
return (
|
|
164
|
-
<
|
|
165
|
-
|
|
182
|
+
<ComponentWrapper
|
|
183
|
+
descriptionText={descriptionText}
|
|
184
|
+
headingText={headingText}
|
|
185
|
+
helperText={helperText}
|
|
166
186
|
id={id}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
aria-label={finalAriaLabel}
|
|
170
|
-
aria-describedby={ariaDescribedby}
|
|
171
|
-
onSubmit={onSubmit}
|
|
172
|
-
method={method}
|
|
173
|
-
action={action}
|
|
174
|
-
__css={styles}
|
|
187
|
+
invalidText={invalidText}
|
|
188
|
+
isInvalid={isInvalid}
|
|
175
189
|
>
|
|
176
|
-
<Box
|
|
190
|
+
<Box
|
|
191
|
+
as="form"
|
|
192
|
+
id={`${id}-form`}
|
|
193
|
+
className={className}
|
|
194
|
+
role="search"
|
|
195
|
+
aria-label={finalAriaLabel}
|
|
196
|
+
aria-describedby={ariaDescribedby}
|
|
197
|
+
onSubmit={onSubmit}
|
|
198
|
+
method={method}
|
|
199
|
+
action={action}
|
|
200
|
+
__css={styles}
|
|
201
|
+
>
|
|
177
202
|
{selectElem}
|
|
178
203
|
{textInputElem}
|
|
179
204
|
{buttonElem}
|
|
180
205
|
</Box>
|
|
181
|
-
|
|
182
|
-
</Box>
|
|
206
|
+
</ComponentWrapper>
|
|
183
207
|
);
|
|
184
208
|
}
|