forked from Workday/canvas-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTextArea.tsx
47 lines (44 loc) · 1.71 KB
/
TextArea.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import React from 'react';
import {createContainer, ExtractProps} from '@workday/canvas-kit-react/common';
import {FormField, formFieldStencil} from '@workday/canvas-kit-react/form-field';
import {mergeStyles} from '@workday/canvas-kit-react/layout';
import {TextAreaField} from './TextAreaField';
import {useTextInputModel} from '@workday/canvas-kit-preview-react/text-input';
/**
* @deprecated ⚠️ `TextAreaProps` in Preview has been deprecated and will be removed in a future major version. Please use [`FormField`](https://workday.github.io/canvas-kit/?path=/story/preview-inputs-form-field--basic) in Preview instead.
*/
export interface TextAreaProps extends ExtractProps<typeof FormField, never> {
/**
* Children of the Text Input. Should contain a `<TextArea.Field>`, a `<TextArea.Label>` and an optional `<TextArea.Hint>`
*/
children: React.ReactNode;
}
/**
* @stencil formFieldStencil
* @deprecated ⚠️ `TextArea` in Preview has been deprecated and will be removed in a future major version. Please use [`FormField` in Preview](https://workday.github.io/canvas-kit/?path=/story/preview-inputs-form-field--basic) instead.
*/
export const TextArea = createContainer('div')({
displayName: 'TextArea',
modelHook: useTextInputModel,
subComponents: {
Field: TextAreaField,
Label: FormField.Label,
Hint: FormField.Hint,
},
})<TextAreaProps>(({children, grow, orientation, ...elemProps}, Element, model) => {
return (
<Element
{...mergeStyles(
elemProps,
formFieldStencil({
grow,
orientation: orientation,
error: model.state.error,
required: model.state.isRequired,
})
)}
>
{children}
</Element>
);
});