@nypl/design-system-react-components 0.26.0 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -0
- package/dist/components/Accordion/Accordion.d.ts +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +1 -5
- package/dist/components/Button/Button.d.ts +2 -10
- package/dist/components/ButtonGroup/ButtonGroup.d.ts +22 -0
- package/dist/components/Card/Card.d.ts +2 -2
- package/dist/components/Checkbox/Checkbox.d.ts +10 -8
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +1 -1
- package/dist/components/DatePicker/DatePicker.d.ts +1 -1
- package/dist/components/Form/Form.d.ts +2 -2
- package/dist/components/Grid/SimpleGrid.d.ts +6 -3
- package/dist/components/Heading/Heading.d.ts +2 -5
- package/dist/components/HelperErrorText/HelperErrorText.d.ts +1 -5
- package/dist/components/Hero/Hero.d.ts +13 -9
- package/dist/components/Icons/Icon.d.ts +6 -5
- package/dist/components/Icons/IconSvgs.d.ts +21 -21
- package/dist/components/Image/Image.d.ts +8 -5
- package/dist/components/Link/Link.d.ts +1 -9
- package/dist/components/List/List.d.ts +7 -11
- package/dist/components/Logo/Logo.d.ts +2 -5
- package/dist/components/Logo/LogoSvgs.d.ts +39 -39
- package/dist/components/Modal/Modal.d.ts +28 -8
- package/dist/components/Notification/Notification.d.ts +1 -1
- package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +2 -1
- package/dist/components/RadioGroup/RadioGroup.d.ts +1 -1
- package/dist/components/SearchBar/SearchBar.d.ts +3 -2
- package/dist/components/Select/Select.d.ts +2 -5
- package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +4 -4
- package/dist/components/SkipNavigation/SkipNavigation.d.ts +17 -0
- package/dist/components/StatusBadge/StatusBadge.d.ts +2 -3
- package/dist/components/StructuredContent/StructuredContent.d.ts +2 -2
- package/dist/components/Table/Table.d.ts +1 -1
- package/dist/components/Template/Template.d.ts +2 -0
- package/dist/components/Text/Text.d.ts +1 -1
- package/dist/components/TextInput/TextInput.d.ts +21 -9
- package/dist/components/Toggle/Toggle.d.ts +1 -5
- package/dist/components/VideoPlayer/VideoPlayer.d.ts +2 -1
- package/dist/design-system-react-components.cjs.development.js +977 -1213
- package/dist/design-system-react-components.cjs.development.js.map +1 -1
- package/dist/design-system-react-components.cjs.production.min.js +1 -1
- package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
- package/dist/design-system-react-components.esm.js +976 -1276
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/helpers/types.d.ts +1 -0
- package/dist/index.d.ts +27 -48
- package/dist/styles.css +1 -1
- package/dist/theme/components/buttonGroup.d.ts +11 -0
- package/dist/theme/components/card.d.ts +104 -8
- package/dist/theme/components/componentWrapper.d.ts +4 -3
- package/dist/theme/components/customTable.d.ts +11 -14
- package/dist/theme/components/fieldset.d.ts +4 -3
- package/dist/theme/components/helperErrorText.d.ts +4 -3
- package/dist/theme/components/hero.d.ts +1 -1
- package/dist/theme/components/horizontalRule.d.ts +4 -3
- package/dist/theme/components/icon.d.ts +47743 -1
- package/dist/theme/components/image.d.ts +563 -10
- package/dist/theme/components/label.d.ts +4 -3
- package/dist/theme/components/list.d.ts +6 -7
- package/dist/theme/components/logo.d.ts +474 -1
- package/dist/theme/components/notification.d.ts +20 -16
- package/dist/theme/components/progressIndicator.d.ts +6 -4
- package/dist/theme/components/select.d.ts +4 -10
- package/dist/theme/components/skeletonLoader.d.ts +14 -10
- package/dist/theme/components/skipNavigation.d.ts +22 -0
- package/dist/theme/components/slider.d.ts +7 -6
- package/dist/theme/components/structuredContent.d.ts +10 -9
- package/dist/theme/components/text.d.ts +7 -1
- package/dist/theme/components/toggle.d.ts +6 -4
- package/dist/theme/provider.d.ts +2 -4
- package/dist/utils/componentCategories.d.ts +1 -1
- package/dist/utils/interfaces.d.ts +5 -0
- package/dist/utils/utils.d.ts +2 -18
- package/package.json +15 -16
- package/src/__tests__/setup.ts +3 -3
- package/src/__tests__/utils/utils.test.ts +1 -23
- package/src/components/AccessibilityGuide/SkipNavigation.stories.mdx +22 -14
- package/src/components/Accordion/Accordion.stories.mdx +43 -44
- package/src/components/Accordion/Accordion.test.tsx +5 -13
- package/src/components/Accordion/Accordion.tsx +14 -18
- package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +6 -6
- package/src/components/Autosuggest/Autosuggest.stories.mdx +1 -1
- package/src/components/Autosuggest/Autosuggest.stories.tsx +23 -25
- package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +21 -37
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +4 -17
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +18 -21
- package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +1 -100
- package/src/components/Button/Button.stories.mdx +89 -126
- package/src/components/Button/Button.test.tsx +16 -30
- package/src/components/Button/Button.tsx +14 -20
- package/src/components/ButtonGroup/ButtonGroup.stories.mdx +147 -0
- package/src/components/ButtonGroup/ButtonGroup.test.tsx +141 -0
- package/src/components/ButtonGroup/ButtonGroup.tsx +99 -0
- package/src/components/ButtonGroup/__snapshots__/ButtonGroup.test.tsx.snap +117 -0
- package/src/components/Card/Card.stories.mdx +143 -177
- package/src/components/Card/Card.test.tsx +36 -97
- package/src/components/Card/Card.tsx +78 -74
- package/src/components/Card/__snapshots__/Card.test.tsx.snap +1 -1
- package/src/components/Chakra/Box.stories.mdx +2 -6
- package/src/components/Chakra/Center.stories.mdx +5 -23
- package/src/components/Chakra/Flex.stories.mdx +4 -6
- package/src/components/Chakra/Stack.stories.mdx +9 -10
- package/src/components/Checkbox/Checkbox.stories.mdx +1 -1
- package/src/components/Checkbox/Checkbox.test.tsx +2 -2
- package/src/components/Checkbox/Checkbox.tsx +20 -13
- package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +9 -9
- package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +6 -17
- package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +1 -7
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +33 -29
- package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +24 -35
- package/src/components/ComponentWrapper/ComponentWrapper.tsx +3 -10
- package/src/components/DatePicker/DatePicker.stories.mdx +23 -37
- package/src/components/DatePicker/DatePicker.test.tsx +21 -19
- package/src/components/DatePicker/DatePicker.tsx +57 -49
- package/src/components/Form/Form.stories.mdx +46 -31
- package/src/components/Form/Form.test.tsx +1 -18
- package/src/components/Form/Form.tsx +7 -7
- package/src/components/Grid/SimpleGrid.stories.mdx +73 -49
- package/src/components/Grid/SimpleGrid.test.tsx +7 -9
- package/src/components/Grid/SimpleGrid.tsx +14 -11
- package/src/components/Heading/Heading.stories.mdx +27 -72
- package/src/components/Heading/Heading.test.tsx +18 -44
- package/src/components/Heading/Heading.tsx +7 -10
- package/src/components/HelperErrorText/HelperErrorText.stories.mdx +1 -3
- package/src/components/HelperErrorText/HelperErrorText.tsx +1 -5
- package/src/components/Hero/Hero.stories.mdx +219 -216
- package/src/components/Hero/Hero.test.tsx +107 -223
- package/src/components/Hero/Hero.tsx +63 -61
- package/src/components/Icons/Icon.stories.mdx +172 -118
- package/src/components/Icons/Icon.test.tsx +8 -16
- package/src/components/Icons/Icon.tsx +75 -29
- package/src/components/Icons/IconSvgs.tsx +42 -42
- package/src/components/Image/Image.stories.mdx +45 -132
- package/src/components/Image/Image.test.tsx +16 -31
- package/src/components/Image/Image.tsx +28 -12
- package/src/components/Link/Link.stories.mdx +30 -94
- package/src/components/Link/Link.test.tsx +25 -75
- package/src/components/Link/Link.tsx +43 -56
- package/src/components/Link/__snapshots__/Link.test.tsx.snap +1 -2
- package/src/components/List/List.stories.mdx +20 -31
- package/src/components/List/List.test.tsx +24 -43
- package/src/components/List/List.tsx +25 -36
- package/src/components/Logo/Logo.stories.mdx +94 -50
- package/src/components/Logo/Logo.test.tsx +10 -19
- package/src/components/Logo/Logo.tsx +50 -17
- package/src/components/Logo/LogoSvgs.tsx +78 -78
- package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +4 -4
- package/src/components/Modal/Modal.stories.mdx +245 -139
- package/src/components/Modal/Modal.test.tsx +147 -10
- package/src/components/Modal/Modal.tsx +140 -20
- package/src/components/Modal/__snapshots__/Modal.test.tsx.snap +25 -0
- package/src/components/Notification/Notification.stories.mdx +10 -28
- package/src/components/Notification/Notification.test.tsx +9 -12
- package/src/components/Notification/Notification.tsx +34 -37
- package/src/components/Pagination/Pagination.stories.mdx +3 -4
- package/src/components/Pagination/Pagination.tsx +15 -10
- package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +27 -53
- package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +9 -10
- package/src/components/ProgressIndicator/ProgressIndicator.tsx +17 -21
- package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +0 -10
- package/src/components/Radio/Radio.stories.mdx +1 -1
- package/src/components/Radio/Radio.tsx +9 -6
- package/src/components/RadioGroup/RadioGroup.stories.mdx +15 -16
- package/src/components/RadioGroup/RadioGroup.test.tsx +2 -8
- package/src/components/RadioGroup/RadioGroup.tsx +28 -24
- package/src/components/SearchBar/SearchBar.stories.mdx +1 -1
- package/src/components/SearchBar/SearchBar.test.tsx +1 -1
- package/src/components/SearchBar/SearchBar.tsx +14 -22
- package/src/components/SearchBar/__snapshots__/SearchBar.test.tsx.snap +1 -13
- package/src/components/Select/Select.stories.mdx +10 -25
- package/src/components/Select/Select.test.tsx +6 -7
- package/src/components/Select/Select.tsx +28 -35
- package/src/components/Select/__snapshots__/Select.test.tsx.snap +24 -24
- package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +17 -56
- package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +7 -21
- package/src/components/SkeletonLoader/SkeletonLoader.tsx +9 -8
- package/src/components/SkeletonLoader/__snapshots__/SkeletonLoader.test.tsx.snap +33 -33
- package/src/components/SkipNavigation/SkipNavigation.stories.mdx +90 -0
- package/src/components/SkipNavigation/SkipNavigation.test.tsx +63 -0
- package/src/components/SkipNavigation/SkipNavigation.tsx +51 -0
- package/src/components/SkipNavigation/__snapshots__/SkipNavigation.test.tsx.snap +130 -0
- package/src/components/Slider/Slider.stories.mdx +19 -53
- package/src/components/Slider/Slider.test.tsx +2 -2
- package/src/components/Slider/Slider.tsx +10 -12
- package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +2 -9
- package/src/components/StatusBadge/StatusBadge.stories.mdx +6 -21
- package/src/components/StatusBadge/StatusBadge.test.tsx +2 -3
- package/src/components/StatusBadge/StatusBadge.tsx +3 -10
- package/src/components/StructuredContent/StructuredContent.stories.mdx +30 -58
- package/src/components/StructuredContent/StructuredContent.test.tsx +42 -44
- package/src/components/StructuredContent/StructuredContent.tsx +9 -18
- package/src/components/StyleGuide/Bidirectionality.stories.mdx +9 -23
- package/src/components/StyleGuide/Buttons.stories.mdx +62 -62
- package/src/components/StyleGuide/ColorCard.tsx +2 -4
- package/src/components/StyleGuide/Colors.stories.mdx +7 -8
- package/src/components/StyleGuide/DesignTokens.stories.mdx +5 -7
- package/src/components/StyleGuide/Forms.stories.mdx +0 -1
- package/src/components/StyleGuide/Iconography.stories.mdx +59 -77
- package/src/components/StyleGuide/Spacing.stories.mdx +0 -1
- package/src/components/StyleGuide/Typography.stories.mdx +15 -18
- package/src/components/Table/Table.stories.mdx +85 -1
- package/src/components/Table/Table.test.tsx +57 -1
- package/src/components/Table/Table.tsx +7 -4
- package/src/components/Table/__snapshots__/Table.test.tsx.snap +121 -0
- package/src/components/Tabs/Tabs.stories.mdx +1 -1
- package/src/components/Tabs/Tabs.test.tsx +2 -2
- package/src/components/Tabs/Tabs.tsx +26 -27
- package/src/components/Template/Template.stories.mdx +49 -54
- package/src/components/Template/Template.tsx +9 -3
- package/src/components/Text/Text.stories.mdx +5 -11
- package/src/components/Text/Text.test.tsx +3 -6
- package/src/components/Text/Text.tsx +3 -5
- package/src/components/TextInput/TextInput.stories.mdx +10 -22
- package/src/components/TextInput/TextInput.test.tsx +32 -62
- package/src/components/TextInput/TextInput.tsx +61 -30
- package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +1 -0
- package/src/components/Toggle/Toggle.stories.mdx +5 -16
- package/src/components/Toggle/Toggle.test.tsx +2 -3
- package/src/components/Toggle/Toggle.tsx +9 -10
- package/src/components/VideoPlayer/VideoPlayer.stories.mdx +13 -29
- package/src/components/VideoPlayer/VideoPlayer.test.tsx +18 -23
- package/src/components/VideoPlayer/VideoPlayer.tsx +13 -10
- package/src/docs/Chakra.stories.mdx +14 -11
- package/src/docs/Welcome.stories.mdx +23 -43
- package/src/helpers/types.ts +1 -0
- package/src/hooks/tests/useNYPLTheme.test.tsx +1 -1
- package/src/hooks/useNYPLTheme.stories.mdx +3 -6
- package/src/index.ts +52 -46
- package/src/styles.scss +0 -1
- package/src/theme/components/buttonGroup.ts +10 -0
- package/src/theme/components/card.ts +50 -15
- package/src/theme/components/componentWrapper.ts +5 -1
- package/src/theme/components/customTable.ts +8 -2
- package/src/theme/components/fieldset.ts +5 -1
- package/src/theme/components/helperErrorText.ts +5 -1
- package/src/theme/components/hero.ts +2 -2
- package/src/theme/components/horizontalRule.ts +5 -1
- package/src/theme/components/icon.ts +7 -1
- package/src/theme/components/image.ts +14 -3
- package/src/theme/components/label.ts +5 -1
- package/src/theme/components/list.ts +8 -2
- package/src/theme/components/logo.ts +5 -1
- package/src/theme/components/notification.ts +38 -14
- package/src/theme/components/progressIndicator.ts +10 -5
- package/src/theme/components/select.ts +5 -6
- package/src/theme/components/skeletonLoader.ts +8 -2
- package/src/theme/components/skipNavigation.ts +26 -0
- package/src/theme/components/slider.ts +13 -1
- package/src/theme/components/structuredContent.ts +11 -1
- package/src/theme/components/text.ts +12 -5
- package/src/theme/components/toggle.ts +9 -3
- package/src/theme/index.ts +4 -0
- package/src/theme/provider.tsx +1 -1
- package/src/utils/componentCategories.ts +13 -5
- package/src/utils/interfaces.ts +5 -0
- package/src/utils/utils.ts +2 -32
- package/dist/components/Accordion/AccordionTypes.d.ts +0 -5
- package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +0 -8
- package/dist/components/Button/ButtonTypes.d.ts +0 -8
- package/dist/components/DatePicker/DatePickerTypes.d.ts +0 -5
- package/dist/components/Form/FormTypes.d.ts +0 -2
- package/dist/components/Grid/GridTypes.d.ts +0 -9
- package/dist/components/Heading/HeadingTypes.d.ts +0 -14
- package/dist/components/Hero/HeroTypes.d.ts +0 -12
- package/dist/components/Icons/IconTypes.d.ts +0 -77
- package/dist/components/Image/ImageTypes.d.ts +0 -22
- package/dist/components/Link/LinkTypes.d.ts +0 -8
- package/dist/components/List/ListTypes.d.ts +0 -5
- package/dist/components/Logo/LogoTypes.d.ts +0 -54
- package/dist/components/Notification/NotificationTypes.d.ts +0 -5
- package/dist/components/ProgressIndicator/ProgressIndicatorTypes.d.ts +0 -8
- package/dist/components/Select/SelectTypes.d.ts +0 -8
- package/dist/components/SkeletonLoader/SkeletonLoaderTypes.d.ts +0 -5
- package/dist/components/StatusBadge/StatusBadgeTypes.d.ts +0 -5
- package/dist/components/StructuredContent/StructuredContentTypes.d.ts +0 -5
- package/dist/components/Text/TextTypes.d.ts +0 -6
- package/dist/components/TextInput/TextInputTypes.d.ts +0 -25
- package/dist/components/Toggle/ToggleTypes.d.ts +0 -4
- package/dist/components/VideoPlayer/VideoPlayerTypes.d.ts +0 -9
- package/dist/helpers/enums.d.ts +0 -4
- package/dist/utils/siteSections.d.ts +0 -2
- package/src/components/Accordion/AccordionTypes.tsx +0 -5
- package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +0 -8
- package/src/components/Button/ButtonTypes.tsx +0 -8
- package/src/components/DatePicker/DatePickerTypes.tsx +0 -5
- package/src/components/Form/FormTypes.tsx +0 -3
- package/src/components/Grid/GridTypes.tsx +0 -9
- package/src/components/Heading/HeadingTypes.tsx +0 -15
- package/src/components/Hero/HeroTypes.tsx +0 -20
- package/src/components/Icons/IconTypes.tsx +0 -83
- package/src/components/Image/ImageTypes.ts +0 -24
- package/src/components/Link/LinkTypes.tsx +0 -8
- package/src/components/List/ListTypes.tsx +0 -5
- package/src/components/Logo/LogoTypes.tsx +0 -56
- package/src/components/Modal/_Modal.scss +0 -18
- package/src/components/Notification/NotificationTypes.tsx +0 -5
- package/src/components/ProgressIndicator/ProgressIndicatorTypes.ts +0 -8
- package/src/components/Select/SelectTypes.tsx +0 -10
- package/src/components/SkeletonLoader/SkeletonLoaderTypes.tsx +0 -5
- package/src/components/StatusBadge/StatusBadgeTypes.tsx +0 -5
- package/src/components/StructuredContent/StructuredContentTypes.tsx +0 -5
- package/src/components/Text/TextTypes.tsx +0 -6
- package/src/components/TextInput/TextInputTypes.tsx +0 -48
- package/src/components/Toggle/ToggleTypes.tsx +0 -4
- package/src/components/VideoPlayer/VideoPlayerTypes.tsx +0 -10
- package/src/helpers/enums.ts +0 -4
- package/src/utils/siteSections.ts +0 -10
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Text as ChakraText, chakra, useStyleConfig } from "@chakra-ui/react";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
import { getVariant } from "../../utils/utils";
|
|
4
|
+
export type TextSizes = "default" | "caption" | "tag" | "mini";
|
|
6
5
|
|
|
7
6
|
export interface TextProps {
|
|
8
7
|
/** Additional class name to render in the `Text` component. */
|
|
@@ -24,12 +23,11 @@ export const Text = chakra((props: React.PropsWithChildren<TextProps>) => {
|
|
|
24
23
|
isBold,
|
|
25
24
|
isItalic,
|
|
26
25
|
noSpace,
|
|
27
|
-
size =
|
|
26
|
+
size = "default",
|
|
28
27
|
...rest
|
|
29
28
|
} = props;
|
|
30
|
-
const variant = getVariant(size, TextSizes, TextSizes.Default);
|
|
31
29
|
const styles = useStyleConfig("Text", {
|
|
32
|
-
variant,
|
|
30
|
+
variant: size,
|
|
33
31
|
isBold,
|
|
34
32
|
isItalic,
|
|
35
33
|
noSpace,
|
|
@@ -9,15 +9,8 @@ import {
|
|
|
9
9
|
import { withDesign } from "storybook-addon-designs";
|
|
10
10
|
|
|
11
11
|
import TextInput from "./TextInput";
|
|
12
|
-
import { TextInputTypes, TextInputVariants } from "./TextInputTypes";
|
|
13
12
|
import { getCategory } from "../../utils/componentCategories";
|
|
14
13
|
import DSProvider from "../../theme/provider";
|
|
15
|
-
import { getStorybookEnumValues } from "../../utils/utils";
|
|
16
|
-
|
|
17
|
-
export const enumValues = getStorybookEnumValues(
|
|
18
|
-
TextInputTypes,
|
|
19
|
-
"TextInputTypes"
|
|
20
|
-
);
|
|
21
14
|
|
|
22
15
|
<Meta
|
|
23
16
|
title={getCategory("TextInput")}
|
|
@@ -31,7 +24,6 @@ export const enumValues = getStorybookEnumValues(
|
|
|
31
24
|
jest: ["TextInput.test.tsx"],
|
|
32
25
|
}}
|
|
33
26
|
argTypes={{
|
|
34
|
-
attributes: { control: false },
|
|
35
27
|
id: { control: false },
|
|
36
28
|
isDisabled: { table: { defaultValue: { summary: false } } },
|
|
37
29
|
isInvalid: { table: { defaultValue: { summary: false } } },
|
|
@@ -45,12 +37,10 @@ export const enumValues = getStorybookEnumValues(
|
|
|
45
37
|
step: { table: { defaultValue: { summary: 1 } } },
|
|
46
38
|
textInputType: {
|
|
47
39
|
control: false,
|
|
48
|
-
table: { defaultValue: { summary: "
|
|
40
|
+
table: { defaultValue: { summary: "default" } },
|
|
49
41
|
},
|
|
50
42
|
type: {
|
|
51
|
-
|
|
52
|
-
table: { defaultValue: { summary: "TextInputTypes.text" } },
|
|
53
|
-
options: enumValues.options,
|
|
43
|
+
table: { defaultValue: { summary: "text" } },
|
|
54
44
|
},
|
|
55
45
|
value: { control: false },
|
|
56
46
|
}}
|
|
@@ -61,7 +51,7 @@ export const enumValues = getStorybookEnumValues(
|
|
|
61
51
|
| Component Version | DS Version |
|
|
62
52
|
| ----------------- | ---------- |
|
|
63
53
|
| Added | `0.22.0` |
|
|
64
|
-
| Latest | `0.
|
|
54
|
+
| Latest | `0.28.0` |
|
|
65
55
|
|
|
66
56
|
## Table of Contents
|
|
67
57
|
|
|
@@ -88,8 +78,6 @@ is left blank, a value will be generated for you.
|
|
|
88
78
|
<Story
|
|
89
79
|
name="TextInput with Controls"
|
|
90
80
|
args={{
|
|
91
|
-
additionalStyles: undefined,
|
|
92
|
-
attributes: undefined,
|
|
93
81
|
className: undefined,
|
|
94
82
|
defaultValue: undefined,
|
|
95
83
|
helperText: "Choose wisely.",
|
|
@@ -106,12 +94,12 @@ is left blank, a value will be generated for you.
|
|
|
106
94
|
showLabel: true,
|
|
107
95
|
showRequiredLabel: true,
|
|
108
96
|
step: 1,
|
|
109
|
-
type: "
|
|
97
|
+
type: "text",
|
|
110
98
|
value: undefined,
|
|
111
|
-
textInputType:
|
|
99
|
+
textInputType: "default",
|
|
112
100
|
}}
|
|
113
101
|
>
|
|
114
|
-
{(args) => <TextInput {...args}
|
|
102
|
+
{(args) => <TextInput {...args} />}
|
|
115
103
|
</Story>
|
|
116
104
|
</Canvas>
|
|
117
105
|
|
|
@@ -129,7 +117,7 @@ Internally, a `Label` is associated with the `<input>` element. When `showLabel`
|
|
|
129
117
|
is set to false, the `<input>` element's `aria-label` attribute is set to the
|
|
130
118
|
required `labelText` value.
|
|
131
119
|
|
|
132
|
-
When the `type` prop is set to `
|
|
120
|
+
When the `type` prop is set to `"textarea"`, the `<textarea>` element
|
|
133
121
|
is rendered instead of the `<input>` element. This element follows all the same
|
|
134
122
|
accessibility rules described above.
|
|
135
123
|
|
|
@@ -251,8 +239,8 @@ helperText={<>Choose <b>wisely!</b></>}
|
|
|
251
239
|
## Textarea
|
|
252
240
|
|
|
253
241
|
The TextInput component includes a multiline `textarea` form field. To render a
|
|
254
|
-
`textarea` element, pass `
|
|
255
|
-
|
|
242
|
+
`textarea` element, pass `"textarea"` for the `type` prop. All the variations
|
|
243
|
+
described above are available for the `textarea` option.
|
|
256
244
|
|
|
257
245
|
<Canvas withToolbar>
|
|
258
246
|
<Story
|
|
@@ -268,7 +256,7 @@ All the variations described above are available for the `textarea` option.
|
|
|
268
256
|
placeholder: "Essay question...",
|
|
269
257
|
showLabel: true,
|
|
270
258
|
showRequiredLabel: true,
|
|
271
|
-
type:
|
|
259
|
+
type: "textarea",
|
|
272
260
|
}}
|
|
273
261
|
argTypes={{
|
|
274
262
|
type: { control: false },
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { render,
|
|
2
|
+
import { render, RenderResult, screen } from "@testing-library/react";
|
|
3
3
|
import { axe } from "jest-axe";
|
|
4
4
|
import renderer from "react-test-renderer";
|
|
5
5
|
import userEvent from "@testing-library/user-event";
|
|
6
6
|
|
|
7
7
|
import TextInput from "./TextInput";
|
|
8
|
-
import { TextInputTypes } from "./TextInputTypes";
|
|
9
8
|
|
|
10
9
|
describe("TextInput Accessibility", () => {
|
|
11
10
|
it("passes axe accessibility test for the input element", async () => {
|
|
@@ -16,7 +15,7 @@ describe("TextInput Accessibility", () => {
|
|
|
16
15
|
labelText="Custom input label"
|
|
17
16
|
onChange={jest.fn()}
|
|
18
17
|
placeholder="Input Placeholder"
|
|
19
|
-
type=
|
|
18
|
+
type="text"
|
|
20
19
|
/>
|
|
21
20
|
);
|
|
22
21
|
expect(await axe(container)).toHaveNoViolations();
|
|
@@ -30,7 +29,7 @@ describe("TextInput Accessibility", () => {
|
|
|
30
29
|
labelText="Custom textarea label"
|
|
31
30
|
onChange={jest.fn()}
|
|
32
31
|
placeholder="Input Placeholder"
|
|
33
|
-
type=
|
|
32
|
+
type="textarea"
|
|
34
33
|
/>
|
|
35
34
|
);
|
|
36
35
|
expect(await axe(container)).toHaveNoViolations();
|
|
@@ -38,22 +37,19 @@ describe("TextInput Accessibility", () => {
|
|
|
38
37
|
});
|
|
39
38
|
|
|
40
39
|
describe("TextInput", () => {
|
|
41
|
-
let
|
|
42
|
-
let
|
|
43
|
-
let focusHandler;
|
|
40
|
+
let changeHandler: jest.MockedFunction<() => void>;
|
|
41
|
+
let utils: RenderResult;
|
|
44
42
|
|
|
45
43
|
beforeEach(() => {
|
|
46
|
-
focusHandler = jest.fn();
|
|
47
44
|
changeHandler = jest.fn();
|
|
48
45
|
utils = render(
|
|
49
46
|
<TextInput
|
|
50
|
-
attributes={{ onFocus: focusHandler }}
|
|
51
47
|
id="myTextInput"
|
|
52
48
|
isRequired
|
|
53
49
|
labelText="Custom Input Label"
|
|
54
50
|
onChange={changeHandler}
|
|
55
51
|
placeholder="Input Placeholder"
|
|
56
|
-
type=
|
|
52
|
+
type="text"
|
|
57
53
|
/>
|
|
58
54
|
);
|
|
59
55
|
});
|
|
@@ -74,14 +70,13 @@ describe("TextInput", () => {
|
|
|
74
70
|
it("does not render '(Required)' along with the label text", () => {
|
|
75
71
|
utils.rerender(
|
|
76
72
|
<TextInput
|
|
77
|
-
attributes={{ onFocus: focusHandler }}
|
|
78
73
|
id="myTextInput"
|
|
79
74
|
isRequired
|
|
80
75
|
labelText="Custom Input Label"
|
|
81
76
|
onChange={changeHandler}
|
|
82
77
|
placeholder="Input Placeholder"
|
|
83
78
|
showRequiredLabel={false}
|
|
84
|
-
type=
|
|
79
|
+
type="text"
|
|
85
80
|
/>
|
|
86
81
|
);
|
|
87
82
|
|
|
@@ -108,12 +103,6 @@ describe("TextInput", () => {
|
|
|
108
103
|
);
|
|
109
104
|
});
|
|
110
105
|
|
|
111
|
-
it("allows user to pass in additional attributes", () => {
|
|
112
|
-
expect(focusHandler).toHaveBeenCalledTimes(0);
|
|
113
|
-
fireEvent.focus(screen.getByLabelText(/Custom Input Label/i));
|
|
114
|
-
expect(focusHandler).toHaveBeenCalledTimes(1);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
106
|
it("changing the value calls the onChange handler", () => {
|
|
118
107
|
expect(changeHandler).toHaveBeenCalledTimes(0);
|
|
119
108
|
userEvent.type(screen.getByLabelText(/Custom Input Label/i), "Hello");
|
|
@@ -144,7 +133,7 @@ describe("Renders TextInput with auto-generated ID, hidden label and visible hel
|
|
|
144
133
|
labelText="Custom Input Label"
|
|
145
134
|
placeholder="Input Placeholder"
|
|
146
135
|
showLabel={false}
|
|
147
|
-
type=
|
|
136
|
+
type="text"
|
|
148
137
|
/>
|
|
149
138
|
);
|
|
150
139
|
});
|
|
@@ -170,9 +159,10 @@ describe("Renders TextInput with auto-generated ID, hidden label and visible hel
|
|
|
170
159
|
});
|
|
171
160
|
|
|
172
161
|
describe("TextInput shows error state", () => {
|
|
173
|
-
let
|
|
162
|
+
let utils: RenderResult;
|
|
163
|
+
|
|
174
164
|
beforeEach(() => {
|
|
175
|
-
|
|
165
|
+
utils = render(
|
|
176
166
|
<TextInput
|
|
177
167
|
helperText="Custom Helper Text"
|
|
178
168
|
id="myTextInputError"
|
|
@@ -180,11 +170,9 @@ describe("TextInput shows error state", () => {
|
|
|
180
170
|
isInvalid
|
|
181
171
|
labelText="Custom Input Label"
|
|
182
172
|
placeholder="Input Placeholder"
|
|
183
|
-
type=
|
|
173
|
+
type="text"
|
|
184
174
|
/>
|
|
185
175
|
);
|
|
186
|
-
|
|
187
|
-
rerender = utils.rerender;
|
|
188
176
|
});
|
|
189
177
|
|
|
190
178
|
it("renders Input component", () => {
|
|
@@ -201,7 +189,7 @@ describe("TextInput shows error state", () => {
|
|
|
201
189
|
});
|
|
202
190
|
|
|
203
191
|
it("does not render the invalid text when 'showHelperInvalidText' is set to false", () => {
|
|
204
|
-
rerender(
|
|
192
|
+
utils.rerender(
|
|
205
193
|
<TextInput
|
|
206
194
|
helperText="Custom Helper Text"
|
|
207
195
|
id="myTextInputError"
|
|
@@ -210,7 +198,7 @@ describe("TextInput shows error state", () => {
|
|
|
210
198
|
labelText="Custom Input Label"
|
|
211
199
|
placeholder="Input Placeholder"
|
|
212
200
|
showHelperInvalidText={false}
|
|
213
|
-
type=
|
|
201
|
+
type="text"
|
|
214
202
|
/>
|
|
215
203
|
);
|
|
216
204
|
expect(screen.queryByText("Custom Helper Text")).not.toBeInTheDocument();
|
|
@@ -224,22 +212,17 @@ describe("TextInput shows error state", () => {
|
|
|
224
212
|
});
|
|
225
213
|
});
|
|
226
214
|
|
|
227
|
-
describe("Renders HTML attributes passed
|
|
215
|
+
describe("Renders HTML attributes passed", () => {
|
|
228
216
|
const onChangeSpy = jest.fn();
|
|
229
|
-
const onBlurSpy = jest.fn();
|
|
230
217
|
beforeEach(() => {
|
|
231
218
|
render(
|
|
232
219
|
<TextInput
|
|
233
|
-
attributes={{
|
|
234
|
-
onChange: onChangeSpy,
|
|
235
|
-
onBlur: onBlurSpy,
|
|
236
|
-
maxLength: 10,
|
|
237
|
-
tabIndex: 0,
|
|
238
|
-
}}
|
|
239
220
|
id="inputID-attributes"
|
|
240
221
|
labelText="Input Label"
|
|
222
|
+
maxLength={10}
|
|
223
|
+
onChange={onChangeSpy}
|
|
241
224
|
placeholder="Input Placeholder"
|
|
242
|
-
type=
|
|
225
|
+
type="text"
|
|
243
226
|
/>
|
|
244
227
|
);
|
|
245
228
|
});
|
|
@@ -251,24 +234,11 @@ describe("Renders HTML attributes passed through the `attributes` prop", () => {
|
|
|
251
234
|
);
|
|
252
235
|
});
|
|
253
236
|
|
|
254
|
-
it("has a tabIndex", () => {
|
|
255
|
-
expect(screen.getByLabelText(/Input Label/i)).toHaveAttribute(
|
|
256
|
-
"tabIndex",
|
|
257
|
-
"0"
|
|
258
|
-
);
|
|
259
|
-
});
|
|
260
|
-
|
|
261
237
|
it("calls the onChange function", () => {
|
|
262
238
|
expect(onChangeSpy).toHaveBeenCalledTimes(0);
|
|
263
239
|
userEvent.type(screen.getByLabelText(/Input Label/i), "Hello");
|
|
264
240
|
expect(onChangeSpy).toHaveBeenCalledTimes(5);
|
|
265
241
|
});
|
|
266
|
-
|
|
267
|
-
it("calls the onBlur function", () => {
|
|
268
|
-
expect(onBlurSpy).toHaveBeenCalledTimes(0);
|
|
269
|
-
fireEvent.blur(screen.getByLabelText(/Input Label/i));
|
|
270
|
-
expect(onBlurSpy).toHaveBeenCalledTimes(1);
|
|
271
|
-
});
|
|
272
242
|
});
|
|
273
243
|
|
|
274
244
|
// TODO:
|
|
@@ -280,7 +250,7 @@ describe("Renders HTML attributes passed through the `attributes` prop", () => {
|
|
|
280
250
|
// id="inputID-attributes"
|
|
281
251
|
// labelText="Input Label"
|
|
282
252
|
// placeholder={"Input Placeholder"}
|
|
283
|
-
// type=
|
|
253
|
+
// type="text"
|
|
284
254
|
// ref={ref}
|
|
285
255
|
// />
|
|
286
256
|
// );
|
|
@@ -294,7 +264,7 @@ describe("Renders HTML attributes passed through the `attributes` prop", () => {
|
|
|
294
264
|
// id="inputID-attributes"
|
|
295
265
|
// labelText="Input Label"
|
|
296
266
|
// placeholder={"Input Placeholder"}
|
|
297
|
-
// type=
|
|
267
|
+
// type="textarea"
|
|
298
268
|
// ref={ref}
|
|
299
269
|
// />
|
|
300
270
|
// );
|
|
@@ -308,7 +278,7 @@ describe("Hidden input", () => {
|
|
|
308
278
|
<TextInput
|
|
309
279
|
id="inputID-hidden"
|
|
310
280
|
labelText="Hidden Input Label"
|
|
311
|
-
type=
|
|
281
|
+
type="hidden"
|
|
312
282
|
value="hidden"
|
|
313
283
|
/>
|
|
314
284
|
);
|
|
@@ -328,7 +298,7 @@ describe("Hidden input", () => {
|
|
|
328
298
|
helperText="Helper Text"
|
|
329
299
|
id="inputID-hidden"
|
|
330
300
|
labelText="Hidden Input Label"
|
|
331
|
-
type=
|
|
301
|
+
type="hidden"
|
|
332
302
|
value="hidden"
|
|
333
303
|
/>
|
|
334
304
|
);
|
|
@@ -345,7 +315,7 @@ describe("Textarea element type", () => {
|
|
|
345
315
|
id="myTextarea"
|
|
346
316
|
labelText="Custom textarea Label"
|
|
347
317
|
placeholder="Textarea Placeholder"
|
|
348
|
-
type=
|
|
318
|
+
type="textarea"
|
|
349
319
|
/>
|
|
350
320
|
);
|
|
351
321
|
});
|
|
@@ -368,7 +338,7 @@ describe("UI Snapshots", () => {
|
|
|
368
338
|
isRequired
|
|
369
339
|
labelText="Custom Input Label"
|
|
370
340
|
placeholder="Input Placeholder"
|
|
371
|
-
type=
|
|
341
|
+
type="text"
|
|
372
342
|
/>
|
|
373
343
|
)
|
|
374
344
|
.toJSON();
|
|
@@ -378,7 +348,7 @@ describe("UI Snapshots", () => {
|
|
|
378
348
|
id="myTextInput"
|
|
379
349
|
labelText="Custom Input Label"
|
|
380
350
|
placeholder="Input Placeholder"
|
|
381
|
-
type=
|
|
351
|
+
type="text"
|
|
382
352
|
/>
|
|
383
353
|
)
|
|
384
354
|
.toJSON();
|
|
@@ -390,7 +360,7 @@ describe("UI Snapshots", () => {
|
|
|
390
360
|
labelText="Custom Input Label"
|
|
391
361
|
placeholder="Input Placeholder"
|
|
392
362
|
showLabel={false}
|
|
393
|
-
type=
|
|
363
|
+
type="text"
|
|
394
364
|
/>
|
|
395
365
|
)
|
|
396
366
|
.toJSON();
|
|
@@ -402,7 +372,7 @@ describe("UI Snapshots", () => {
|
|
|
402
372
|
isRequired
|
|
403
373
|
labelText="Custom Input Label"
|
|
404
374
|
placeholder="Input Placeholder"
|
|
405
|
-
type=
|
|
375
|
+
type="text"
|
|
406
376
|
/>
|
|
407
377
|
)
|
|
408
378
|
.toJSON();
|
|
@@ -414,7 +384,7 @@ describe("UI Snapshots", () => {
|
|
|
414
384
|
isRequired
|
|
415
385
|
labelText="Custom Input Label"
|
|
416
386
|
placeholder="Input Placeholder"
|
|
417
|
-
type=
|
|
387
|
+
type="text"
|
|
418
388
|
/>
|
|
419
389
|
)
|
|
420
390
|
.toJSON();
|
|
@@ -426,7 +396,7 @@ describe("UI Snapshots", () => {
|
|
|
426
396
|
isRequired
|
|
427
397
|
labelText="Custom Input Label"
|
|
428
398
|
placeholder="Input Placeholder"
|
|
429
|
-
type=
|
|
399
|
+
type="text"
|
|
430
400
|
/>
|
|
431
401
|
)
|
|
432
402
|
.toJSON();
|
|
@@ -436,7 +406,7 @@ describe("UI Snapshots", () => {
|
|
|
436
406
|
id="chakra"
|
|
437
407
|
labelText="Custom Input Label"
|
|
438
408
|
placeholder="Input Placeholder"
|
|
439
|
-
type=
|
|
409
|
+
type="text"
|
|
440
410
|
p="20px"
|
|
441
411
|
color="ui.error.primary"
|
|
442
412
|
/>
|
|
@@ -448,7 +418,7 @@ describe("UI Snapshots", () => {
|
|
|
448
418
|
id="props"
|
|
449
419
|
labelText="Custom Input Label"
|
|
450
420
|
placeholder="Input Placeholder"
|
|
451
|
-
type=
|
|
421
|
+
type="text"
|
|
452
422
|
data-testid="props"
|
|
453
423
|
/>
|
|
454
424
|
)
|
|
@@ -471,7 +441,7 @@ describe("UI Snapshots", () => {
|
|
|
471
441
|
id="myTextarea"
|
|
472
442
|
labelText="Custom textarea Label"
|
|
473
443
|
placeholder="Textarea Placeholder"
|
|
474
|
-
type=
|
|
444
|
+
type="textarea"
|
|
475
445
|
/>
|
|
476
446
|
)
|
|
477
447
|
.toJSON();
|
|
@@ -7,21 +7,37 @@ import {
|
|
|
7
7
|
} from "@chakra-ui/react";
|
|
8
8
|
import * as React from "react";
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
TextInputTypes,
|
|
12
|
-
TextInputFormats,
|
|
13
|
-
TextInputVariants,
|
|
14
|
-
} from "./TextInputTypes";
|
|
15
10
|
import Label from "../Label/Label";
|
|
16
11
|
import HelperErrorText, {
|
|
17
12
|
HelperErrorTextType,
|
|
18
13
|
} from "../HelperErrorText/HelperErrorText";
|
|
19
14
|
|
|
15
|
+
// HTML Input types as defined by MDN: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input
|
|
16
|
+
export type TextInputTypes =
|
|
17
|
+
| "email"
|
|
18
|
+
| "hidden"
|
|
19
|
+
| "number"
|
|
20
|
+
| "password"
|
|
21
|
+
| "text"
|
|
22
|
+
| "textarea"
|
|
23
|
+
| "tel"
|
|
24
|
+
| "url";
|
|
25
|
+
|
|
26
|
+
// Only used internally.
|
|
27
|
+
export const TextInputFormats = {
|
|
28
|
+
email: "jdoe@domain.com",
|
|
29
|
+
hidden: "",
|
|
30
|
+
password: "",
|
|
31
|
+
text: "",
|
|
32
|
+
tel: "(123) 123-1234",
|
|
33
|
+
textarea: "",
|
|
34
|
+
url: "https://domain.com",
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// Only used internally in `TextInput` and `SearchBar`.
|
|
38
|
+
export type TextInputVariants = "default" | "searchBar" | "searchBarSelect";
|
|
39
|
+
|
|
20
40
|
export interface InputProps {
|
|
21
|
-
/** Optionally pass in additional Chakra-based styles. */
|
|
22
|
-
additionalStyles?: { [key: string]: any };
|
|
23
|
-
/** Additional attributes to pass to the `<input>` or `<textarea>` element */
|
|
24
|
-
attributes?: { [key: string]: any };
|
|
25
41
|
/** A class name for the TextInput parent div. */
|
|
26
42
|
className?: string;
|
|
27
43
|
/** The starting value of the input field. */
|
|
@@ -41,6 +57,12 @@ export interface InputProps {
|
|
|
41
57
|
/** Provides text for a `Label` component if `showLabel` is set to true;
|
|
42
58
|
* populates an `aria-label` attribute if `showLabel` is set to false. */
|
|
43
59
|
labelText: string;
|
|
60
|
+
/** The max number for a `number` TextInput type. */
|
|
61
|
+
max?: number;
|
|
62
|
+
/** The max length of the input field. */
|
|
63
|
+
maxLength?: number;
|
|
64
|
+
/** The min number for a `number` TextInput type. */
|
|
65
|
+
min?: number;
|
|
44
66
|
/** Used to reference the input element in forms. */
|
|
45
67
|
name?: string;
|
|
46
68
|
/** The action to perform on the `input`/`textarea`'s onChange function */
|
|
@@ -49,6 +71,10 @@ export interface InputProps {
|
|
|
49
71
|
| React.ChangeEvent<HTMLInputElement>
|
|
50
72
|
| React.ChangeEvent<HTMLTextAreaElement>
|
|
51
73
|
) => void;
|
|
74
|
+
/** The action to perform on the `input`/`textarea`'s onClick function */
|
|
75
|
+
onClick?: (event: React.MouseEvent<HTMLInputElement, MouseEvent>) => void;
|
|
76
|
+
/** The action to perform on the `input`/`textarea`'s onFocus function */
|
|
77
|
+
onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
52
78
|
/** Populates the placeholder for the input/textarea elements */
|
|
53
79
|
placeholder?: string;
|
|
54
80
|
/** Offers the ability to hide the helper/invalid text. */
|
|
@@ -84,8 +110,6 @@ export const TextInput = chakra(
|
|
|
84
110
|
React.forwardRef<TextInputRefType, InputProps>(
|
|
85
111
|
(props, ref: React.Ref<TextInputRefType>) => {
|
|
86
112
|
const {
|
|
87
|
-
additionalStyles = {},
|
|
88
|
-
attributes = {},
|
|
89
113
|
className,
|
|
90
114
|
defaultValue,
|
|
91
115
|
helperText,
|
|
@@ -95,30 +119,35 @@ export const TextInput = chakra(
|
|
|
95
119
|
isInvalid = false,
|
|
96
120
|
isRequired = false,
|
|
97
121
|
labelText,
|
|
122
|
+
max,
|
|
123
|
+
maxLength,
|
|
124
|
+
min,
|
|
98
125
|
name,
|
|
99
126
|
onChange,
|
|
127
|
+
onClick,
|
|
128
|
+
onFocus,
|
|
100
129
|
placeholder,
|
|
101
130
|
showHelperInvalidText = true,
|
|
102
131
|
showLabel = true,
|
|
103
132
|
showRequiredLabel = true,
|
|
104
133
|
step = 1,
|
|
105
|
-
textInputType =
|
|
106
|
-
type =
|
|
134
|
+
textInputType = "default",
|
|
135
|
+
type = "text",
|
|
107
136
|
value,
|
|
108
137
|
...rest
|
|
109
138
|
} = props;
|
|
110
139
|
const styles = useMultiStyleConfig("TextInput", {
|
|
111
140
|
variant: textInputType,
|
|
112
141
|
});
|
|
113
|
-
const
|
|
114
|
-
const
|
|
115
|
-
const isHidden = type === TextInputTypes.hidden;
|
|
142
|
+
const isTextArea = type === "textarea";
|
|
143
|
+
const isHidden = type === "hidden";
|
|
116
144
|
const finalInvalidText = invalidText
|
|
117
145
|
? invalidText
|
|
118
146
|
: "There is an error related to this field.";
|
|
119
147
|
let footnote: HelperErrorTextType = isInvalid
|
|
120
148
|
? finalInvalidText
|
|
121
149
|
: helperText;
|
|
150
|
+
let ariaAttributes = {};
|
|
122
151
|
let fieldOutput;
|
|
123
152
|
let options;
|
|
124
153
|
|
|
@@ -129,18 +158,14 @@ export const TextInput = chakra(
|
|
|
129
158
|
}
|
|
130
159
|
|
|
131
160
|
if (!showLabel) {
|
|
132
|
-
|
|
161
|
+
ariaAttributes["aria-label"] =
|
|
133
162
|
labelText && footnote ? `${labelText} - ${footnote}` : labelText;
|
|
134
163
|
} else if (helperText) {
|
|
135
|
-
|
|
164
|
+
ariaAttributes["aria-describedby"] = `${id}-helperText`;
|
|
136
165
|
}
|
|
137
166
|
|
|
138
|
-
if (
|
|
139
|
-
|
|
140
|
-
type === TextInputTypes.url ||
|
|
141
|
-
type === TextInputTypes.email
|
|
142
|
-
) {
|
|
143
|
-
const example = TextInputFormats[type];
|
|
167
|
+
if (type === "tel" || type === "url" || type === "email") {
|
|
168
|
+
const example = TextInputFormats[type] || "";
|
|
144
169
|
footnote = (
|
|
145
170
|
<>
|
|
146
171
|
Ex: {example}
|
|
@@ -160,29 +185,35 @@ export const TextInput = chakra(
|
|
|
160
185
|
isDisabled,
|
|
161
186
|
isRequired,
|
|
162
187
|
isInvalid,
|
|
163
|
-
|
|
188
|
+
max,
|
|
189
|
+
maxLength,
|
|
190
|
+
min,
|
|
164
191
|
name,
|
|
165
192
|
onChange,
|
|
193
|
+
onClick,
|
|
194
|
+
onFocus,
|
|
195
|
+
placeholder,
|
|
166
196
|
ref,
|
|
167
197
|
// The `step` attribute is useful for the number type.
|
|
168
|
-
step: type ===
|
|
169
|
-
...
|
|
198
|
+
step: type === "number" ? step : null,
|
|
199
|
+
...ariaAttributes,
|
|
200
|
+
...rest,
|
|
170
201
|
};
|
|
171
202
|
// For `input` and `textarea`, all attributes are the same but `input`
|
|
172
203
|
// also needs `type` and `value` to render correctly.
|
|
173
204
|
if (!isTextArea) {
|
|
174
205
|
options = { type, value, ...options } as any;
|
|
175
|
-
fieldOutput = <ChakraInput {...options} __css={
|
|
206
|
+
fieldOutput = <ChakraInput {...options} __css={styles.input} />;
|
|
176
207
|
} else {
|
|
177
208
|
fieldOutput = (
|
|
178
|
-
<ChakraTextarea {...options} __css={
|
|
209
|
+
<ChakraTextarea {...options} __css={styles.textarea}>
|
|
179
210
|
{value}
|
|
180
211
|
</ChakraTextarea>
|
|
181
212
|
);
|
|
182
213
|
}
|
|
183
214
|
|
|
184
215
|
return (
|
|
185
|
-
<Box __css={
|
|
216
|
+
<Box __css={styles} className={className} {...rest}>
|
|
186
217
|
{labelText && showLabel && !isHidden && (
|
|
187
218
|
<Label
|
|
188
219
|
htmlFor={id}
|