1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', { value: true });
|
4 |
|
5 | var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
6 | var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
7 | var css = require('@emotion/css');
|
8 | var box = require('@spark-web/box');
|
9 | var field = require('@spark-web/field');
|
10 | var textInput = require('@spark-web/text-input');
|
11 | var react = require('react');
|
12 | var theme = require('@spark-web/theme');
|
13 | var jsxRuntime = require('react/jsx-runtime');
|
14 |
|
15 | function useTextAreaStyles(props) {
|
16 | var theme$1 = theme.useTheme();
|
17 | var _useInputStyles = textInput.useInputStyles(props),
|
18 | _useInputStyles2 = _slicedToArray(_useInputStyles, 2),
|
19 | boxProps = _useInputStyles2[0],
|
20 | inputStyles = _useInputStyles2[1];
|
21 | return [boxProps, _objectSpread(_objectSpread({}, inputStyles), {}, {
|
22 |
|
23 | height: 'auto',
|
24 | minHeight: theme$1.sizing.medium,
|
25 | paddingTop: theme$1.spacing.small,
|
26 | paddingBottom: theme$1.spacing.small,
|
27 | resize: 'vertical'
|
28 | })];
|
29 | }
|
30 |
|
31 | var TextArea = react.forwardRef(function (_ref, forwardedRef) {
|
32 | var data = _ref.data,
|
33 | defaultValue = _ref.defaultValue,
|
34 | name = _ref.name,
|
35 | onBlur = _ref.onBlur,
|
36 | onChange = _ref.onChange,
|
37 | placeholder = _ref.placeholder,
|
38 | required = _ref.required,
|
39 | value = _ref.value;
|
40 | var _useFieldContext = field.useFieldContext(),
|
41 | _useFieldContext2 = _slicedToArray(_useFieldContext, 2),
|
42 | _useFieldContext2$ = _useFieldContext2[0],
|
43 | disabled = _useFieldContext2$.disabled,
|
44 | invalid = _useFieldContext2$.invalid,
|
45 | a11yProps = _useFieldContext2[1];
|
46 | var _useTextAreaStyles = useTextAreaStyles({
|
47 | disabled: disabled,
|
48 | invalid: invalid
|
49 | }),
|
50 | _useTextAreaStyles2 = _slicedToArray(_useTextAreaStyles, 2),
|
51 | boxProps = _useTextAreaStyles2[0],
|
52 | textAreaStyles = _useTextAreaStyles2[1];
|
53 | return jsxRuntime.jsx(textInput.InputContainer, {
|
54 | children: jsxRuntime.jsx(box.Box, _objectSpread(_objectSpread(_objectSpread({}, boxProps), a11yProps), {}, {
|
55 | as: "textarea",
|
56 | className: css.css(textAreaStyles),
|
57 | data: data,
|
58 | defaultValue: defaultValue,
|
59 | disabled: disabled,
|
60 | name: name,
|
61 | onBlur: onBlur,
|
62 | onChange: onChange,
|
63 | placeholder: placeholder,
|
64 | ref: forwardedRef,
|
65 | required: required,
|
66 | rows: 3,
|
67 | value: value
|
68 | }))
|
69 | });
|
70 | });
|
71 | TextArea.displayName = 'TextArea';
|
72 |
|
73 | exports.TextArea = TextArea;
|