@teamturing/react-kit 2.19.27 → 2.19.29

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.
@@ -4,6 +4,7 @@ import Checkbox from '../Checkbox/index.js';
4
4
  import SearchSelectInput from '../SearchSelectInput/index.js';
5
5
  import Select from '../Select/index.js';
6
6
  import TextInput from '../TextInput/index.js';
7
+ import Textarea from '../Textarea/index.js';
7
8
  import View from '../View/index.js';
8
9
  import FormControlCaption from './FormControlCaption.js';
9
10
  import FormControlErrorMessage from './FormControlErrorMessage.js';
@@ -28,7 +29,7 @@ const FormControl = ({
28
29
  successMessage: FormControlSuccessMessage
29
30
  }
30
31
  });
31
- const inputComponentCandidates = [TextInput, Select, SearchSelectInput, Checkbox, ...additionalInputComponentCandidates];
32
+ const inputComponentCandidates = [TextInput, Textarea, Select, SearchSelectInput, Checkbox, ...additionalInputComponentCandidates];
32
33
  const InputComponent = restComponents.find(component => inputComponentCandidates.some(candidate => /*#__PURE__*/isValidElement(component) && component.type === candidate));
33
34
  const isHorizontalLayoutNeeded = /*#__PURE__*/isValidElement(InputComponent) && InputComponent.type === Checkbox;
34
35
  return /*#__PURE__*/jsxRuntimeExports.jsx(FormControlContext.Provider, {
@@ -1,11 +1,15 @@
1
+ import { commaizeNumber } from '../../packages/utils/esm/commaizeNumber.js';
1
2
  import { forcePixelValue } from '../../packages/utils/esm/forcePixelValue.js';
2
3
  import { isFunction } from '../../packages/utils/esm/isFunction.js';
3
- import { forwardRef } from 'react';
4
+ import toArray from '../../node_modules/lodash.toarray/index.js';
5
+ import { forwardRef, useState, useEffect } from 'react';
6
+ import ReactTextareaAutosize from 'react-textarea-autosize';
4
7
  import styled, { css } from 'styled-components';
5
8
  import useProvidedOrCreatedRef from '../../hook/useProvidedOrCreatedRef.js';
6
9
  import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js';
7
10
 
8
11
  const Textarea = /*#__PURE__*/forwardRef(({
12
+ validationStatus,
9
13
  disabled,
10
14
  ...props
11
15
  }, ref) => {
@@ -13,17 +17,35 @@ const Textarea = /*#__PURE__*/forwardRef(({
13
17
  const focusInput = () => {
14
18
  inputRef.current?.focus();
15
19
  };
16
- return /*#__PURE__*/jsxRuntimeExports.jsx(TextareaWrapper, {
20
+ const getTextareaLength = value => {
21
+ return toArray(value).length;
22
+ };
23
+ const [count, setCount] = useState(0);
24
+ const handleChange = e => {
25
+ setCount(getTextareaLength(e.target.value));
26
+ props.onChange?.(e);
27
+ };
28
+ useEffect(() => {
29
+ if (inputRef.current) {
30
+ setCount(getTextareaLength(inputRef.current.value));
31
+ }
32
+ }, [ref]);
33
+ return /*#__PURE__*/jsxRuntimeExports.jsxs(TextareaWrapper, {
17
34
  disabled: disabled,
18
35
  onClick: focusInput,
19
- children: /*#__PURE__*/jsxRuntimeExports.jsx(BaseTextarea, {
36
+ validationStatus: validationStatus,
37
+ children: [/*#__PURE__*/jsxRuntimeExports.jsx(ReactTextareaAutosize, {
38
+ ...props,
20
39
  ref: e => {
21
40
  isFunction(ref) ? ref(e) : null;
22
41
  inputRef.current = e;
23
42
  },
24
43
  disabled: disabled,
25
- ...props
26
- })
44
+ minRows: 7,
45
+ onChange: handleChange
46
+ }), /*#__PURE__*/jsxRuntimeExports.jsxs(TextareaCount, {
47
+ children: [commaizeNumber(count), "\uC790"]
48
+ })]
27
49
  });
28
50
  });
29
51
  const TextareaWrapper = styled.div`
@@ -42,21 +64,9 @@ const TextareaWrapper = styled.div`
42
64
  }) => theme.colors['bg/input']};
43
65
  cursor: text;
44
66
  display: inline-flex;
67
+ flex-direction: column;
45
68
  align-items: center;
46
69
 
47
- padding-top: ${({
48
- theme
49
- }) => forcePixelValue(theme.space['3'])};
50
- padding-right: ${({
51
- theme
52
- }) => forcePixelValue(theme.space['4'])};
53
- padding-bottom: ${({
54
- theme
55
- }) => forcePixelValue(theme.space['3'])};
56
- padding-left: ${({
57
- theme
58
- }) => forcePixelValue(theme.space['4'])};
59
-
60
70
  font-size: ${({
61
71
  theme
62
72
  }) => forcePixelValue(theme.fontSizes.xs)};
@@ -69,13 +79,41 @@ const TextareaWrapper = styled.div`
69
79
  color: ${({
70
80
  theme
71
81
  }) => theme.colors['text/neutral']};
72
- input::placeholder {
82
+ textarea::placeholder {
73
83
  color: ${({
74
84
  theme
75
85
  }) => theme.colors['text/neutral/subtlest']};
76
86
  }
87
+ textarea {
88
+ font-size: inherit;
89
+ font-weight: inherit;
90
+ line-height: inherit;
91
+ font-family: inherit;
92
+ border-radius: inherit;
93
+ color: inherit;
94
+ transition: inherit;
77
95
 
78
- height: 74px;
96
+ border: 0;
97
+ background-color: transparent;
98
+ width: 100%;
99
+ &:focus {
100
+ outline: 0;
101
+ }
102
+ resize: none;
103
+
104
+ padding-top: ${({
105
+ theme
106
+ }) => forcePixelValue(theme.space['3'])};
107
+ padding-right: ${({
108
+ theme
109
+ }) => forcePixelValue(theme.space['4'])};
110
+ padding-bottom: ${({
111
+ theme
112
+ }) => forcePixelValue(theme.space['3'])};
113
+ padding-left: ${({
114
+ theme
115
+ }) => forcePixelValue(theme.space['4'])};
116
+ }
79
117
 
80
118
  &:after {
81
119
  content: '';
@@ -135,24 +173,32 @@ const TextareaWrapper = styled.div`
135
173
  }
136
174
  `};
137
175
  `;
138
- const UnstyledTextarea = styled.textarea`
139
- font-size: inherit;
140
- font-weight: inherit;
141
- line-height: inherit;
142
- font-family: inherit;
143
- border-radius: inherit;
144
- color: inherit;
145
- transition: inherit;
146
-
147
- border: 0;
148
- background-color: transparent;
176
+ const TextareaCount = styled.div`
149
177
  width: 100%;
150
- &:focus {
151
- outline: 0;
152
- }
153
- `;
154
- const BaseTextarea = styled(UnstyledTextarea)`
155
- resize: none;
178
+
179
+ padding-right: ${({
180
+ theme
181
+ }) => forcePixelValue(theme.space[4])};
182
+ padding-bottom: ${({
183
+ theme
184
+ }) => forcePixelValue(theme.space[3])};
185
+ padding-left: ${({
186
+ theme
187
+ }) => forcePixelValue(theme.space[4])};
188
+
189
+ font-size: ${({
190
+ theme
191
+ }) => forcePixelValue(theme.fontSizes.xxs)};
192
+ font-weight: ${({
193
+ theme
194
+ }) => forcePixelValue(theme.fontWeights.medium)};
195
+ line-height: ${({
196
+ theme
197
+ }) => theme.lineHeights[2]};
198
+ color: ${({
199
+ theme
200
+ }) => theme.colors['text/neutral/subtlest']};
201
+ text-align: end;
156
202
  `;
157
203
 
158
204
  export { Textarea as default };