@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,17 +1,23 @@
|
|
|
1
|
+
import { VStack } from "@chakra-ui/react";
|
|
1
2
|
import {
|
|
2
|
-
Meta,
|
|
3
|
-
Story,
|
|
4
3
|
ArgsTable,
|
|
5
4
|
Canvas,
|
|
6
5
|
Description,
|
|
7
|
-
|
|
6
|
+
Meta,
|
|
7
|
+
Story,
|
|
8
|
+
} from "@storybook/addon-docs";
|
|
8
9
|
import { withDesign } from "storybook-addon-designs";
|
|
9
|
-
import { VStack } from "@chakra-ui/react";
|
|
10
10
|
|
|
11
11
|
import TextInput from "./TextInput";
|
|
12
|
-
import { TextInputTypes } from "./TextInputTypes";
|
|
12
|
+
import { TextInputTypes, TextInputVariants } from "./TextInputTypes";
|
|
13
13
|
import { getCategory } from "../../utils/componentCategories";
|
|
14
14
|
import DSProvider from "../../theme/provider";
|
|
15
|
+
import { getStorybookEnumValues } from "../../utils/utils";
|
|
16
|
+
|
|
17
|
+
export const enumValues = getStorybookEnumValues(
|
|
18
|
+
TextInputTypes,
|
|
19
|
+
"TextInputTypes"
|
|
20
|
+
);
|
|
15
21
|
|
|
16
22
|
<Meta
|
|
17
23
|
title={getCategory("TextInput")}
|
|
@@ -20,16 +26,33 @@ import DSProvider from "../../theme/provider";
|
|
|
20
26
|
parameters={{
|
|
21
27
|
design: {
|
|
22
28
|
type: "figma",
|
|
23
|
-
url:
|
|
24
|
-
"https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Master?node-id=11895%3A547",
|
|
29
|
+
url: "https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Master?node-id=11895%3A547",
|
|
25
30
|
},
|
|
26
31
|
jest: ["TextInput.test.tsx"],
|
|
27
32
|
}}
|
|
28
33
|
argTypes={{
|
|
29
|
-
attributes: {
|
|
30
|
-
id: {
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
attributes: { control: false },
|
|
35
|
+
id: { control: false },
|
|
36
|
+
isDisabled: { table: { defaultValue: { summary: false } } },
|
|
37
|
+
isInvalid: { table: { defaultValue: { summary: false } } },
|
|
38
|
+
isRequired: { table: { defaultValue: { summary: false } } },
|
|
39
|
+
key: { table: { disable: true } },
|
|
40
|
+
onChange: { control: false },
|
|
41
|
+
ref: { table: { disable: true } },
|
|
42
|
+
showHelperInvalidText: { table: { defaultValue: { summary: true } } },
|
|
43
|
+
showLabel: { table: { defaultValue: { summary: true } } },
|
|
44
|
+
showOptReqLabel: { table: { defaultValue: { summary: true } } },
|
|
45
|
+
step: { table: { defaultValue: { summary: 1 } } },
|
|
46
|
+
type: {
|
|
47
|
+
control: { type: "select" },
|
|
48
|
+
table: { defaultValue: { summary: "TextInputTypes.text" } },
|
|
49
|
+
options: enumValues.options,
|
|
50
|
+
},
|
|
51
|
+
value: { control: false },
|
|
52
|
+
variantType: {
|
|
53
|
+
control: false,
|
|
54
|
+
table: { defaultValue: { summary: "TextInputVariants.Default" } },
|
|
55
|
+
},
|
|
33
56
|
}}
|
|
34
57
|
/>
|
|
35
58
|
|
|
@@ -38,7 +61,7 @@ import DSProvider from "../../theme/provider";
|
|
|
38
61
|
| Component Version | DS Version |
|
|
39
62
|
| ----------------- | ---------- |
|
|
40
63
|
| Added | `0.22.0` |
|
|
41
|
-
| Latest | `0.25.
|
|
64
|
+
| Latest | `0.25.9` |
|
|
42
65
|
|
|
43
66
|
<Description of={TextInput} />
|
|
44
67
|
|
|
@@ -50,26 +73,36 @@ is left blank, a value will be generated for you.
|
|
|
50
73
|
|
|
51
74
|
<Canvas withToolbar>
|
|
52
75
|
<Story
|
|
53
|
-
name="TextInput"
|
|
76
|
+
name="TextInput with Controls"
|
|
54
77
|
args={{
|
|
78
|
+
additionalStyles: undefined,
|
|
79
|
+
attributes: undefined,
|
|
80
|
+
className: undefined,
|
|
81
|
+
defaultValue: undefined,
|
|
55
82
|
helperText: "Choose wisely.",
|
|
56
|
-
id: "
|
|
83
|
+
id: "textInput-id",
|
|
57
84
|
invalidText: "This is error text :(",
|
|
58
85
|
isDisabled: false,
|
|
59
86
|
isInvalid: false,
|
|
60
87
|
isRequired: true,
|
|
61
88
|
labelText: "What is your favorite color?",
|
|
89
|
+
name: undefined,
|
|
90
|
+
onChange: undefined,
|
|
62
91
|
placeholder: "e.g. blue, green, etc.",
|
|
92
|
+
showHelperInvalidText: true,
|
|
63
93
|
showLabel: true,
|
|
64
94
|
showOptReqLabel: true,
|
|
65
|
-
|
|
95
|
+
step: 1,
|
|
96
|
+
type: "TextInputTypes.text",
|
|
97
|
+
value: undefined,
|
|
98
|
+
variantType: TextInputVariants.Default,
|
|
66
99
|
}}
|
|
67
100
|
>
|
|
68
|
-
{(args) => <TextInput {...args} />}
|
|
101
|
+
{(args) => <TextInput {...args} type={enumValues.getValue(args.type)} />}
|
|
69
102
|
</Story>
|
|
70
103
|
</Canvas>
|
|
71
104
|
|
|
72
|
-
<ArgsTable story="TextInput" />
|
|
105
|
+
<ArgsTable story="TextInput with Controls" />
|
|
73
106
|
|
|
74
107
|
## Labelling Variations
|
|
75
108
|
|
|
@@ -140,6 +173,36 @@ text within the `label` element.
|
|
|
140
173
|
</DSProvider>
|
|
141
174
|
</Canvas>
|
|
142
175
|
|
|
176
|
+
## HTML in Helper Text
|
|
177
|
+
|
|
178
|
+
HTML can be passed into the `helperText` prop as a string or HTML.
|
|
179
|
+
|
|
180
|
+
```jsx
|
|
181
|
+
helperText="Choose <b>wisely!</b>"
|
|
182
|
+
// or
|
|
183
|
+
helperText={<>Choose <b>wisely!</b></>}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
<Canvas>
|
|
187
|
+
<DSProvider>
|
|
188
|
+
<TextInput
|
|
189
|
+
labelText="What is your favorite color?"
|
|
190
|
+
placeholder="i.e. blue, green, etc."
|
|
191
|
+
helperText="Choose <b>wisely!</b>"
|
|
192
|
+
/>
|
|
193
|
+
<br />
|
|
194
|
+
<TextInput
|
|
195
|
+
labelText="What is your favorite color?"
|
|
196
|
+
placeholder="i.e. blue, green, etc."
|
|
197
|
+
helperText={
|
|
198
|
+
<>
|
|
199
|
+
Choose <b>wisely!</b>
|
|
200
|
+
</>
|
|
201
|
+
}
|
|
202
|
+
/>
|
|
203
|
+
</DSProvider>
|
|
204
|
+
</Canvas>
|
|
205
|
+
|
|
143
206
|
## Textarea
|
|
144
207
|
|
|
145
208
|
The TextInput component includes a multiline `textarea` form field. To render a
|
|
@@ -161,6 +224,10 @@ variations described above are available for the `textarea` option.
|
|
|
161
224
|
showOptReqLabel: true,
|
|
162
225
|
type: TextInputTypes.textarea,
|
|
163
226
|
}}
|
|
227
|
+
argTypes={{
|
|
228
|
+
type: { control: false },
|
|
229
|
+
variantType: { control: false },
|
|
230
|
+
}}
|
|
164
231
|
>
|
|
165
232
|
{(args) => <TextInput {...args} />}
|
|
166
233
|
</Story>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { render, screen, fireEvent } from "@testing-library/react";
|
|
3
3
|
import { axe } from "jest-axe";
|
|
4
|
+
import renderer from "react-test-renderer";
|
|
4
5
|
import userEvent from "@testing-library/user-event";
|
|
5
6
|
|
|
6
7
|
import TextInput from "./TextInput";
|
|
@@ -368,3 +369,98 @@ describe("Textarea element type", () => {
|
|
|
368
369
|
expect(screen.getByLabelText(/Custom textarea Label/i)).toBeInTheDocument();
|
|
369
370
|
});
|
|
370
371
|
});
|
|
372
|
+
|
|
373
|
+
describe("UI Snapshots", () => {
|
|
374
|
+
it("renders the text input UI snapshot correctly", () => {
|
|
375
|
+
const required = renderer
|
|
376
|
+
.create(
|
|
377
|
+
<TextInput
|
|
378
|
+
id="myTextInput"
|
|
379
|
+
isRequired
|
|
380
|
+
labelText="Custom Input Label"
|
|
381
|
+
placeholder="Input Placeholder"
|
|
382
|
+
type={TextInputTypes.text}
|
|
383
|
+
/>
|
|
384
|
+
)
|
|
385
|
+
.toJSON();
|
|
386
|
+
const optional = renderer
|
|
387
|
+
.create(
|
|
388
|
+
<TextInput
|
|
389
|
+
id="myTextInput"
|
|
390
|
+
labelText="Custom Input Label"
|
|
391
|
+
placeholder="Input Placeholder"
|
|
392
|
+
type={TextInputTypes.text}
|
|
393
|
+
/>
|
|
394
|
+
)
|
|
395
|
+
.toJSON();
|
|
396
|
+
const hiddenLabelText = renderer
|
|
397
|
+
.create(
|
|
398
|
+
<TextInput
|
|
399
|
+
id="myTextInput"
|
|
400
|
+
isRequired
|
|
401
|
+
labelText="Custom Input Label"
|
|
402
|
+
placeholder="Input Placeholder"
|
|
403
|
+
showLabel={false}
|
|
404
|
+
type={TextInputTypes.text}
|
|
405
|
+
/>
|
|
406
|
+
)
|
|
407
|
+
.toJSON();
|
|
408
|
+
const withHelperText = renderer
|
|
409
|
+
.create(
|
|
410
|
+
<TextInput
|
|
411
|
+
helperText="Custom helper text"
|
|
412
|
+
id="myTextInput"
|
|
413
|
+
isRequired
|
|
414
|
+
labelText="Custom Input Label"
|
|
415
|
+
placeholder="Input Placeholder"
|
|
416
|
+
type={TextInputTypes.text}
|
|
417
|
+
/>
|
|
418
|
+
)
|
|
419
|
+
.toJSON();
|
|
420
|
+
const errorState = renderer
|
|
421
|
+
.create(
|
|
422
|
+
<TextInput
|
|
423
|
+
id="myTextInput"
|
|
424
|
+
isInvalid
|
|
425
|
+
isRequired
|
|
426
|
+
labelText="Custom Input Label"
|
|
427
|
+
placeholder="Input Placeholder"
|
|
428
|
+
type={TextInputTypes.text}
|
|
429
|
+
/>
|
|
430
|
+
)
|
|
431
|
+
.toJSON();
|
|
432
|
+
const disabledState = renderer
|
|
433
|
+
.create(
|
|
434
|
+
<TextInput
|
|
435
|
+
id="myTextInput"
|
|
436
|
+
isDisabled
|
|
437
|
+
isRequired
|
|
438
|
+
labelText="Custom Input Label"
|
|
439
|
+
placeholder="Input Placeholder"
|
|
440
|
+
type={TextInputTypes.text}
|
|
441
|
+
/>
|
|
442
|
+
)
|
|
443
|
+
.toJSON();
|
|
444
|
+
|
|
445
|
+
expect(required).toMatchSnapshot();
|
|
446
|
+
expect(optional).toMatchSnapshot();
|
|
447
|
+
expect(hiddenLabelText).toMatchSnapshot();
|
|
448
|
+
expect(withHelperText).toMatchSnapshot();
|
|
449
|
+
expect(errorState).toMatchSnapshot();
|
|
450
|
+
expect(disabledState).toMatchSnapshot();
|
|
451
|
+
});
|
|
452
|
+
it("renders the textarea UI snapshot correctly", () => {
|
|
453
|
+
const basicTextarea = renderer
|
|
454
|
+
.create(
|
|
455
|
+
<TextInput
|
|
456
|
+
id="myTextarea"
|
|
457
|
+
labelText="Custom textarea Label"
|
|
458
|
+
placeholder="Textarea Placeholder"
|
|
459
|
+
type={TextInputTypes.textarea}
|
|
460
|
+
/>
|
|
461
|
+
)
|
|
462
|
+
.toJSON();
|
|
463
|
+
|
|
464
|
+
expect(basicTextarea).toMatchSnapshot();
|
|
465
|
+
});
|
|
466
|
+
});
|
|
@@ -12,7 +12,9 @@ import {
|
|
|
12
12
|
TextInputVariants,
|
|
13
13
|
} from "./TextInputTypes";
|
|
14
14
|
import Label from "../Label/Label";
|
|
15
|
-
import HelperErrorText
|
|
15
|
+
import HelperErrorText, {
|
|
16
|
+
HelperErrorTextType,
|
|
17
|
+
} from "../HelperErrorText/HelperErrorText";
|
|
16
18
|
import generateUUID from "../../helpers/generateUUID";
|
|
17
19
|
|
|
18
20
|
export interface InputProps {
|
|
@@ -25,11 +27,11 @@ export interface InputProps {
|
|
|
25
27
|
/** The starting value of the input field. */
|
|
26
28
|
defaultValue?: string;
|
|
27
29
|
/** Populates the HelperErrorText for the standard state */
|
|
28
|
-
helperText?:
|
|
30
|
+
helperText?: HelperErrorTextType;
|
|
29
31
|
/** ID that other components can cross reference for accessibility purposes */
|
|
30
32
|
id?: string;
|
|
31
33
|
/** Populates the HelperErrorText for the error state */
|
|
32
|
-
invalidText?:
|
|
34
|
+
invalidText?: HelperErrorTextType;
|
|
33
35
|
/** Adds the `disabled` and `aria-disabled` prop to the input when true */
|
|
34
36
|
isDisabled?: boolean;
|
|
35
37
|
/** Adds errored styling to the input/textarea and helper text elements */
|
|
@@ -63,7 +65,7 @@ export interface InputProps {
|
|
|
63
65
|
type?: TextInputTypes;
|
|
64
66
|
/** Populates the value of the input/textarea elements */
|
|
65
67
|
value?: string;
|
|
66
|
-
/**
|
|
68
|
+
/** FOR INTERNAL DS USE ONLY: the input variant to display. */
|
|
67
69
|
variantType?: TextInputVariants;
|
|
68
70
|
}
|
|
69
71
|
|
|
@@ -111,7 +113,7 @@ const TextInput = React.forwardRef<TextInputRefType, InputProps>(
|
|
|
111
113
|
const finalInvalidText = invalidText
|
|
112
114
|
? invalidText
|
|
113
115
|
: "There is an error related to this field.";
|
|
114
|
-
let footnote:
|
|
116
|
+
let footnote: HelperErrorTextType = isInvalid
|
|
115
117
|
? finalInvalidText
|
|
116
118
|
: helperText;
|
|
117
119
|
let fieldOutput;
|
|
@@ -184,9 +186,11 @@ const TextInput = React.forwardRef<TextInputRefType, InputProps>(
|
|
|
184
186
|
{fieldOutput}
|
|
185
187
|
{footnote && showHelperInvalidText && !isHidden && (
|
|
186
188
|
<Box __css={finalStyles.helper} aria-disabled={isDisabled}>
|
|
187
|
-
<HelperErrorText
|
|
188
|
-
{
|
|
189
|
-
|
|
189
|
+
<HelperErrorText
|
|
190
|
+
id={`${id}-helperText`}
|
|
191
|
+
isInvalid={isInvalid}
|
|
192
|
+
text={footnote}
|
|
193
|
+
/>
|
|
190
194
|
</Box>
|
|
191
195
|
)}
|
|
192
196
|
</Box>
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`UI Snapshots renders the text input UI snapshot correctly 1`] = `
|
|
4
|
+
<div
|
|
5
|
+
className="css-0"
|
|
6
|
+
>
|
|
7
|
+
<label
|
|
8
|
+
className="css-0"
|
|
9
|
+
htmlFor="myTextInput"
|
|
10
|
+
id="myTextInput-label"
|
|
11
|
+
>
|
|
12
|
+
Custom Input Label
|
|
13
|
+
<div
|
|
14
|
+
className="css-0"
|
|
15
|
+
>
|
|
16
|
+
Required
|
|
17
|
+
</div>
|
|
18
|
+
</label>
|
|
19
|
+
<input
|
|
20
|
+
aria-required={true}
|
|
21
|
+
className="chakra-input css-0"
|
|
22
|
+
disabled={false}
|
|
23
|
+
id="myTextInput"
|
|
24
|
+
onBlur={[Function]}
|
|
25
|
+
onFocus={[Function]}
|
|
26
|
+
placeholder="Input Placeholder"
|
|
27
|
+
required={true}
|
|
28
|
+
step={null}
|
|
29
|
+
type="text"
|
|
30
|
+
/>
|
|
31
|
+
</div>
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
exports[`UI Snapshots renders the text input UI snapshot correctly 2`] = `
|
|
35
|
+
<div
|
|
36
|
+
className="css-0"
|
|
37
|
+
>
|
|
38
|
+
<label
|
|
39
|
+
className="css-0"
|
|
40
|
+
htmlFor="myTextInput"
|
|
41
|
+
id="myTextInput-label"
|
|
42
|
+
>
|
|
43
|
+
Custom Input Label
|
|
44
|
+
<div
|
|
45
|
+
className="css-0"
|
|
46
|
+
>
|
|
47
|
+
Optional
|
|
48
|
+
</div>
|
|
49
|
+
</label>
|
|
50
|
+
<input
|
|
51
|
+
className="chakra-input css-0"
|
|
52
|
+
disabled={false}
|
|
53
|
+
id="myTextInput"
|
|
54
|
+
onBlur={[Function]}
|
|
55
|
+
onFocus={[Function]}
|
|
56
|
+
placeholder="Input Placeholder"
|
|
57
|
+
required={false}
|
|
58
|
+
step={null}
|
|
59
|
+
type="text"
|
|
60
|
+
/>
|
|
61
|
+
</div>
|
|
62
|
+
`;
|
|
63
|
+
|
|
64
|
+
exports[`UI Snapshots renders the text input UI snapshot correctly 3`] = `
|
|
65
|
+
<div
|
|
66
|
+
className="css-0"
|
|
67
|
+
>
|
|
68
|
+
<input
|
|
69
|
+
aria-label="Custom Input Label"
|
|
70
|
+
aria-required={true}
|
|
71
|
+
className="chakra-input css-0"
|
|
72
|
+
disabled={false}
|
|
73
|
+
id="myTextInput"
|
|
74
|
+
onBlur={[Function]}
|
|
75
|
+
onFocus={[Function]}
|
|
76
|
+
placeholder="Input Placeholder"
|
|
77
|
+
required={true}
|
|
78
|
+
step={null}
|
|
79
|
+
type="text"
|
|
80
|
+
/>
|
|
81
|
+
</div>
|
|
82
|
+
`;
|
|
83
|
+
|
|
84
|
+
exports[`UI Snapshots renders the text input UI snapshot correctly 4`] = `
|
|
85
|
+
<div
|
|
86
|
+
className="css-0"
|
|
87
|
+
>
|
|
88
|
+
<label
|
|
89
|
+
className="css-0"
|
|
90
|
+
htmlFor="myTextInput"
|
|
91
|
+
id="myTextInput-label"
|
|
92
|
+
>
|
|
93
|
+
Custom Input Label
|
|
94
|
+
<div
|
|
95
|
+
className="css-0"
|
|
96
|
+
>
|
|
97
|
+
Required
|
|
98
|
+
</div>
|
|
99
|
+
</label>
|
|
100
|
+
<input
|
|
101
|
+
aria-describedby="myTextInput-helperText"
|
|
102
|
+
aria-required={true}
|
|
103
|
+
className="chakra-input css-0"
|
|
104
|
+
disabled={false}
|
|
105
|
+
id="myTextInput"
|
|
106
|
+
onBlur={[Function]}
|
|
107
|
+
onFocus={[Function]}
|
|
108
|
+
placeholder="Input Placeholder"
|
|
109
|
+
required={true}
|
|
110
|
+
step={null}
|
|
111
|
+
type="text"
|
|
112
|
+
/>
|
|
113
|
+
<div
|
|
114
|
+
aria-disabled={false}
|
|
115
|
+
className="css-0"
|
|
116
|
+
>
|
|
117
|
+
<div
|
|
118
|
+
aria-atomic={true}
|
|
119
|
+
aria-live="off"
|
|
120
|
+
className=" css-0"
|
|
121
|
+
dangerouslySetInnerHTML={
|
|
122
|
+
Object {
|
|
123
|
+
"__html": "Custom helper text",
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
data-isinvalid={false}
|
|
127
|
+
id="myTextInput-helperText"
|
|
128
|
+
/>
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
131
|
+
`;
|
|
132
|
+
|
|
133
|
+
exports[`UI Snapshots renders the text input UI snapshot correctly 5`] = `
|
|
134
|
+
<div
|
|
135
|
+
className="css-0"
|
|
136
|
+
>
|
|
137
|
+
<label
|
|
138
|
+
className="css-0"
|
|
139
|
+
htmlFor="myTextInput"
|
|
140
|
+
id="myTextInput-label"
|
|
141
|
+
>
|
|
142
|
+
Custom Input Label
|
|
143
|
+
<div
|
|
144
|
+
className="css-0"
|
|
145
|
+
>
|
|
146
|
+
Required
|
|
147
|
+
</div>
|
|
148
|
+
</label>
|
|
149
|
+
<input
|
|
150
|
+
aria-invalid={true}
|
|
151
|
+
aria-required={true}
|
|
152
|
+
className="chakra-input css-0"
|
|
153
|
+
disabled={false}
|
|
154
|
+
id="myTextInput"
|
|
155
|
+
onBlur={[Function]}
|
|
156
|
+
onFocus={[Function]}
|
|
157
|
+
placeholder="Input Placeholder"
|
|
158
|
+
required={true}
|
|
159
|
+
step={null}
|
|
160
|
+
type="text"
|
|
161
|
+
/>
|
|
162
|
+
<div
|
|
163
|
+
aria-disabled={false}
|
|
164
|
+
className="css-0"
|
|
165
|
+
>
|
|
166
|
+
<div
|
|
167
|
+
aria-atomic={true}
|
|
168
|
+
aria-live="polite"
|
|
169
|
+
className=" css-0"
|
|
170
|
+
dangerouslySetInnerHTML={
|
|
171
|
+
Object {
|
|
172
|
+
"__html": "There is an error related to this field.",
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
data-isinvalid={true}
|
|
176
|
+
id="myTextInput-helperText"
|
|
177
|
+
/>
|
|
178
|
+
</div>
|
|
179
|
+
</div>
|
|
180
|
+
`;
|
|
181
|
+
|
|
182
|
+
exports[`UI Snapshots renders the text input UI snapshot correctly 6`] = `
|
|
183
|
+
<div
|
|
184
|
+
className="css-0"
|
|
185
|
+
>
|
|
186
|
+
<label
|
|
187
|
+
className="css-0"
|
|
188
|
+
htmlFor="myTextInput"
|
|
189
|
+
id="myTextInput-label"
|
|
190
|
+
>
|
|
191
|
+
Custom Input Label
|
|
192
|
+
<div
|
|
193
|
+
className="css-0"
|
|
194
|
+
>
|
|
195
|
+
Required
|
|
196
|
+
</div>
|
|
197
|
+
</label>
|
|
198
|
+
<input
|
|
199
|
+
aria-required={true}
|
|
200
|
+
className="chakra-input css-0"
|
|
201
|
+
disabled={true}
|
|
202
|
+
id="myTextInput"
|
|
203
|
+
onBlur={[Function]}
|
|
204
|
+
onFocus={[Function]}
|
|
205
|
+
placeholder="Input Placeholder"
|
|
206
|
+
required={true}
|
|
207
|
+
step={null}
|
|
208
|
+
type="text"
|
|
209
|
+
/>
|
|
210
|
+
</div>
|
|
211
|
+
`;
|
|
212
|
+
|
|
213
|
+
exports[`UI Snapshots renders the textarea UI snapshot correctly 1`] = `
|
|
214
|
+
<div
|
|
215
|
+
className="css-0"
|
|
216
|
+
>
|
|
217
|
+
<label
|
|
218
|
+
className="css-0"
|
|
219
|
+
htmlFor="myTextarea"
|
|
220
|
+
id="myTextarea-label"
|
|
221
|
+
>
|
|
222
|
+
Custom textarea Label
|
|
223
|
+
<div
|
|
224
|
+
className="css-0"
|
|
225
|
+
>
|
|
226
|
+
Optional
|
|
227
|
+
</div>
|
|
228
|
+
</label>
|
|
229
|
+
<textarea
|
|
230
|
+
className="chakra-textarea css-0"
|
|
231
|
+
disabled={false}
|
|
232
|
+
id="myTextarea"
|
|
233
|
+
onBlur={[Function]}
|
|
234
|
+
onFocus={[Function]}
|
|
235
|
+
placeholder="Textarea Placeholder"
|
|
236
|
+
required={false}
|
|
237
|
+
step={null}
|
|
238
|
+
/>
|
|
239
|
+
</div>
|
|
240
|
+
`;
|