diff --git a/src/components/TextField/TextField.jsx b/src/components/TextField/TextField.jsx index 051d4d90bb..950fcda663 100644 --- a/src/components/TextField/TextField.jsx +++ b/src/components/TextField/TextField.jsx @@ -270,7 +270,7 @@ TextField.propTypes = { secondary: PropTypes.string }), /** TEXT_TYPES is exposed on the component itself */ - type: PropTypes.oneOf([TextField.types.TEXT, TextField.types.PASSWORD, TextField.types.SEARCH]), + type: PropTypes.oneOf([TextField.types.TEXT, TextField.types.PASSWORD, TextField.types.SEARCH, TextField.types.DATE, TextField.types.DATE_TIME]), maxLength: PropTypes.number, trim: PropTypes.bool, /** ARIA role for container landmark */ diff --git a/src/components/TextField/TextFieldConstants.js b/src/components/TextField/TextFieldConstants.js index a62aece7db..2ab8cd3307 100644 --- a/src/components/TextField/TextFieldConstants.js +++ b/src/components/TextField/TextFieldConstants.js @@ -14,5 +14,7 @@ export const getActualSize = size => { export const TEXT_TYPES = { TEXT: "text", PASSWORD: "password", - SEARCH: "search" + SEARCH: "search", + DATE: "date", + DATE_TIME: "datetime-local" }; diff --git a/src/components/TextField/__stories__/TextField.stories.mdx b/src/components/TextField/__stories__/TextField.stories.mdx index fe16851cb4..d49c3ac83c 100644 --- a/src/components/TextField/__stories__/TextField.stories.mdx +++ b/src/components/TextField/__stories__/TextField.stories.mdx @@ -1,5 +1,6 @@ import { ArgsTable, Story, Canvas, Meta } from "@storybook/addon-docs"; import TextField from "../TextField"; +import { TEXT_TYPES } from "../TextFieldConstants"; import { createComponentTemplate, createStoryMetaSettings } from "../../../storybook/functions/create-component-story"; import { Email, CloseSmall, Check } from "../../Icon/Icons"; import { DROPDOWN, SEARCH, COMBOBOX } from "../../../storybook/components/related-components/component-description-map"; @@ -159,5 +160,30 @@ Users can insert text. + +### Input field with date + + +
+ +
+
+
+ +### Input field with datetime + + +
+ +
+
+
+ ## Related components \ No newline at end of file diff --git a/src/components/TextField/__tests__/__snapshots__/textField-snapshot-tests.jest.js.snap b/src/components/TextField/__tests__/__snapshots__/textField-snapshot-tests.jest.js.snap index a13123cbee..d47d99cc21 100644 --- a/src/components/TextField/__tests__/__snapshots__/textField-snapshot-tests.jest.js.snap +++ b/src/components/TextField/__tests__/__snapshots__/textField-snapshot-tests.jest.js.snap @@ -531,6 +531,150 @@ exports[`TextField renders correctly with className 2`] = ` `; +exports[`TextField renders correctly with date type 1`] = ` +
+
+
+ +
+
+
+
+
+`; + +exports[`TextField renders correctly with date-time type 1`] = ` +
+
+
+ +
+
+
+
+
+`; + exports[`TextField renders correctly with icon 1`] = `
{ const tree = renderer.create().toJSON(); expect(tree).toMatchSnapshot(); }); + + it("with date type", () => { + const tree = renderer.create().toJSON(); + expect(tree).toMatchSnapshot(); + }); + + it("with date-time type", () => { + const tree = renderer.create().toJSON(); + expect(tree).toMatchSnapshot(); + }); });