diff --git a/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap b/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap index 9be473ee2e1a..dae5ea1476a3 100644 --- a/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap +++ b/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap @@ -9176,6 +9176,85 @@ Map { }, }, }, + "unstable__FluidTextArea" => Object { + "propTypes": Object { + "className": Object { + "type": "string", + }, + "cols": Object { + "type": "number", + }, + "defaultValue": Object { + "args": Array [ + Array [ + Object { + "type": "string", + }, + Object { + "type": "number", + }, + ], + ], + "type": "oneOfType", + }, + "disabled": Object { + "type": "bool", + }, + "enableCounter": Object { + "type": "bool", + }, + "helperText": Object { + "type": "node", + }, + "hideLabel": Object { + "type": "bool", + }, + "id": Object { + "type": "string", + }, + "invalid": Object { + "type": "bool", + }, + "invalidText": Object { + "type": "node", + }, + "labelText": Object { + "isRequired": true, + "type": "node", + }, + "light": Object { + "type": "bool", + }, + "maxCount": Object { + "type": "number", + }, + "onChange": Object { + "type": "func", + }, + "onClick": Object { + "type": "func", + }, + "placeholder": Object { + "type": "string", + }, + "rows": Object { + "type": "number", + }, + "value": Object { + "args": Array [ + Array [ + Object { + "type": "string", + }, + Object { + "type": "number", + }, + ], + ], + "type": "oneOfType", + }, + }, + }, "unstable__FluidTextInput" => Object { "propTypes": Object { "className": Object { diff --git a/packages/react/src/__tests__/index-test.js b/packages/react/src/__tests__/index-test.js index 62077eab9c9a..e6c1a66316c5 100644 --- a/packages/react/src/__tests__/index-test.js +++ b/packages/react/src/__tests__/index-test.js @@ -229,6 +229,7 @@ describe('Carbon Components React', () => { "unstable_Pagination", "unstable_Text", "unstable_TextDirection", + "unstable__FluidTextArea", "unstable__FluidTextInput", "unstable_useContextMenu", "unstable_useFeatureFlag", diff --git a/packages/react/src/components/FluidForm/FluidForm-story.js b/packages/react/src/components/FluidForm/FluidForm-story.js deleted file mode 100644 index 1edd27bc2cb3..000000000000 --- a/packages/react/src/components/FluidForm/FluidForm-story.js +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright IBM Corp. 2016, 2018 - * - * This source code is licensed under the Apache-2.0 license found in the - * LICENSE file in the root directory of this source tree. - */ - -import React from 'react'; -import { action } from '@storybook/addon-actions'; - -import { withKnobs } from '@storybook/addon-knobs'; -import FluidForm from '../FluidForm'; -import TextInput from '../TextInput'; - -const additionalProps = { - className: 'some-class', - onSubmit: (e) => { - e.preventDefault(); - action('FormSubmitted')(e); - }, -}; - -const TextInputProps = { - className: 'some-class', - id: 'test2', - labelText: 'Text Input label', - placeholder: 'Placeholder text', -}; - -const InvalidPasswordProps = { - className: 'some-class', - id: 'test4', - labelText: 'Password', - invalid: true, - invalidText: - 'Your password must be at least 6 characters as well as contain at least one uppercase, one lowercase, and one number.', -}; - -export default { - title: 'Experimental/FluidForm', - component: FluidForm, - decorators: [withKnobs], -}; - -export const Default = () => ( - - - - - -); diff --git a/packages/react/src/components/FluidForm/FluidForm.stories.js b/packages/react/src/components/FluidForm/FluidForm.stories.js new file mode 100644 index 000000000000..14531e560186 --- /dev/null +++ b/packages/react/src/components/FluidForm/FluidForm.stories.js @@ -0,0 +1,84 @@ +/** + * Copyright IBM Corp. 2016, 2018 + * + * This source code is licensed under the Apache-2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + +import React from 'react'; +import { action } from '@storybook/addon-actions'; + +import { withKnobs } from '@storybook/addon-knobs'; +import FluidForm from '.'; +import FluidTextInput from '../FluidTextInput'; +import FluidTextArea from '../FluidTextArea'; +import ModalWrapper from '../ModalWrapper'; + +const additionalProps = { + className: 'some-class', + onSubmit: (e) => { + e.preventDefault(); + action('FormSubmitted')(e); + }, +}; + +const TextInputProps = { + className: 'some-class', + id: 'test2', + labelText: 'Text Input label', + placeholder: 'Placeholder text', +}; + +const TextAreaProps = { + className: 'some-class', + id: 'test3', + labelText: 'Text Area label', + placeholder: 'Placeholder text', +}; + +const InvalidPasswordProps = { + className: 'some-class', + id: 'test4', + labelText: 'Password', + value: '0000', +}; + +export default { + title: 'Experimental/FluidForm', + component: FluidForm, + decorators: [withKnobs], +}; + +export const Default = () => ( + <> + + + + + + +
+ + {}} + size="md"> + + + + + + + +); diff --git a/packages/react/src/components/FluidTextArea/FluidTextArea.Skeleton.js b/packages/react/src/components/FluidTextArea/FluidTextArea.Skeleton.js new file mode 100644 index 000000000000..fbe7186ae1fd --- /dev/null +++ b/packages/react/src/components/FluidTextArea/FluidTextArea.Skeleton.js @@ -0,0 +1,32 @@ +import PropTypes from 'prop-types'; +import React from 'react'; +import classnames from 'classnames'; +import { usePrefix } from '../../internal/usePrefix'; +import { FormContext } from '../FluidForm/FormContext'; + +function FluidTextAreaSkeleton({ className, ...other }) { + const prefix = usePrefix(); + + return ( + +
+ +
+
+ + ); +} + +FluidTextAreaSkeleton.propTypes = { + /** + * Specify an optional className to be applied to the outer FluidForm wrapper + */ + className: PropTypes.string, +}; + +export default FluidTextAreaSkeleton; diff --git a/packages/react/src/components/FluidTextArea/FluidTextArea.js b/packages/react/src/components/FluidTextArea/FluidTextArea.js new file mode 100644 index 000000000000..88c066109360 --- /dev/null +++ b/packages/react/src/components/FluidTextArea/FluidTextArea.js @@ -0,0 +1,123 @@ +/** + * Copyright IBM Corp. 2016, 2018 + * + * This source code is licensed under the Apache-2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + +import PropTypes from 'prop-types'; +import React from 'react'; +import classnames from 'classnames'; +import TextArea from '../TextArea'; +import { usePrefix } from '../../internal/usePrefix'; +import { FormContext } from '../FluidForm/FormContext'; + +function FluidTextArea({ className, ...other }) { + const prefix = usePrefix(); + const classNames = classnames(`${prefix}--text-area--fluid`, className); + + return ( + +