@dt-dds/react-text-area 1.0.0-beta.29 → 1.0.0-beta.30

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @dt-ui/react-text-area
2
2
 
3
+ ## 1.0.0-beta.30
4
+
5
+ ### Minor Changes
6
+
7
+ - feat: update text area
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - Updated dependencies [223664b]
13
+ - @dt-dds/react-label-field@1.0.0-beta.44
14
+ - @dt-dds/react-box@1.0.0-beta.19
15
+
3
16
  ## 1.0.0-beta.29
4
17
 
5
18
  ### Patch Changes
package/README.md CHANGED
@@ -27,6 +27,8 @@ export const App = () => {
27
27
  | `backgroundFill` | `[default, contrast,light]` | `default` | Styles the input with background color |
28
28
  | `enableResize` | `boolean` | `false` | Enables the vertical resizing |
29
29
  | `message` | `string` | - | The message to be displayed below the input field. Useful for hints or to display errors. |
30
+ | `labelVariant` | `[default, floating]` | `default` | Sets the label floating or traditional on top of the input |
31
+ | `hasLabel` | `boolean` | `true` | Show/hide the label |
30
32
 
31
33
  ## Stack
32
34
 
package/dist/index.d.mts CHANGED
@@ -5,6 +5,7 @@ import { ComponentPropsWithoutRef } from 'react';
5
5
 
6
6
  type TextAreaVariant = 'outlined' | 'bottom-line';
7
7
  type TextAreaBackgroundFill = 'default' | 'contrast' | 'light';
8
+ type TextAreaLabelVariant = 'default' | 'floating';
8
9
 
9
10
  interface TextAreaProps extends ComponentPropsWithoutRef<'textarea'>, BaseProps {
10
11
  label: string;
@@ -16,8 +17,10 @@ interface TextAreaProps extends ComponentPropsWithoutRef<'textarea'>, BaseProps
16
17
  backgroundFill?: TextAreaBackgroundFill;
17
18
  hasError?: boolean;
18
19
  message?: string;
20
+ labelVariant?: TextAreaLabelVariant;
21
+ hasLabel?: boolean;
19
22
  }
20
- declare const TextArea: ({ label, dataTestId, name, value, style, variant, backgroundFill, maxLength, enableResize, disabled, required, hasError, message: messageProp, onChange, ...rest }: TextAreaProps) => react_jsx_runtime.JSX.Element;
23
+ declare const TextArea: ({ label, dataTestId, name, value, style, onChange, maxLength, variant, backgroundFill, enableResize, disabled, required, hasError, hasLabel, message: messageProp, labelVariant, placeholder, readOnly, ...rest }: TextAreaProps) => react_jsx_runtime.JSX.Element;
21
24
 
22
25
  declare module '@emotion/react' {
23
26
  interface Theme extends CustomTheme {
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ import { ComponentPropsWithoutRef } from 'react';
5
5
 
6
6
  type TextAreaVariant = 'outlined' | 'bottom-line';
7
7
  type TextAreaBackgroundFill = 'default' | 'contrast' | 'light';
8
+ type TextAreaLabelVariant = 'default' | 'floating';
8
9
 
9
10
  interface TextAreaProps extends ComponentPropsWithoutRef<'textarea'>, BaseProps {
10
11
  label: string;
@@ -16,8 +17,10 @@ interface TextAreaProps extends ComponentPropsWithoutRef<'textarea'>, BaseProps
16
17
  backgroundFill?: TextAreaBackgroundFill;
17
18
  hasError?: boolean;
18
19
  message?: string;
20
+ labelVariant?: TextAreaLabelVariant;
21
+ hasLabel?: boolean;
19
22
  }
20
- declare const TextArea: ({ label, dataTestId, name, value, style, variant, backgroundFill, maxLength, enableResize, disabled, required, hasError, message: messageProp, onChange, ...rest }: TextAreaProps) => react_jsx_runtime.JSX.Element;
23
+ declare const TextArea: ({ label, dataTestId, name, value, style, onChange, maxLength, variant, backgroundFill, enableResize, disabled, required, hasError, hasLabel, message: messageProp, labelVariant, placeholder, readOnly, ...rest }: TextAreaProps) => react_jsx_runtime.JSX.Element;
21
24
 
22
25
  declare module '@emotion/react' {
23
26
  interface Theme extends CustomTheme {
package/dist/index.js CHANGED
@@ -64,9 +64,11 @@ __export(index_exports, {
64
64
  module.exports = __toCommonJS(index_exports);
65
65
 
66
66
  // src/TextArea.tsx
67
+ var import_react_box = require("@dt-dds/react-box");
67
68
  var import_react_label_field = require("@dt-dds/react-label-field");
68
69
  var import_react_typography = require("@dt-dds/react-typography");
69
- var import_react = require("react");
70
+ var import_react = require("@emotion/react");
71
+ var import_react2 = require("react");
70
72
 
71
73
  // src/TextArea.styled.ts
72
74
  var import_styled = __toESM(require("@emotion/styled"));
@@ -79,68 +81,55 @@ var getThemedBackgroundFill = (backgroundFill, theme) => ({
79
81
  })[backgroundFill] || theme.palette.surface.default;
80
82
 
81
83
  // src/TextArea.styled.ts
82
- var TextAreaWrapper = import_styled.default.div`
83
- ${({ theme }) => `
84
- display: flex;
85
- flex-direction: column;
86
- align-items: flex-end;
87
- position: relative;
88
- width: 100%;
89
-
90
- border-style: solid;
91
- border-width: 0;
92
- border-color: ${theme.palette.border.dark};
93
- `}
94
- `;
95
- var TextAreaMessageStyled = import_styled.default.div`
96
- ${({ theme }) => `padding-left: ${theme.spacing.spacing_50}`};
97
- `;
98
- var TextAreaMessages = import_styled.default.div`
99
- display: flex;
100
- flex-direction: row;
101
- flex-wrap: wrap;
102
- justify-content: space-between;
103
- align-items: baseline;
104
- width: 100%;
105
- `;
106
84
  var TextAreaStyled = import_styled.default.textarea`
107
- ${({ theme, enableResize = false, backgroundFill }) => `
108
- ${theme.fontStyles.bodyLgRegular}
85
+ ${({
86
+ theme,
87
+ enableResize,
88
+ backgroundFill,
89
+ variant,
90
+ hasError,
91
+ isFloatingLabel,
92
+ hasLabel
93
+ }) => {
94
+ const borderColor = hasError ? theme.palette.error.default : theme.palette.informative.default;
95
+ return `
96
+ ${theme.fontStyles.bodyMdRegular}
109
97
 
110
98
  background-color: ${getThemedBackgroundFill(backgroundFill, theme)};
111
-
112
- border-style: none;
99
+ min-height: 100px;
113
100
  width: 100%;
114
- color: ${theme.palette.content.dark};
115
- resize: ${enableResize ? "vertical" : "none"};
116
101
  outline: none;
117
- padding-right: 10px;
118
- `}
119
- `;
120
- var ContainerStyled = import_styled.default.div`
121
- ${({ theme, variant, hasError = false, backgroundFill }) => {
122
- const borderColor = hasError ? theme.palette.error.default : theme.palette.primary.default;
123
- return `
124
- background-color: ${getThemedBackgroundFill(backgroundFill, theme)};
125
- position: relative;
126
- padding: 25px 0px 0px 10px;
127
- width: 100%;
102
+ color: ${theme.palette.content.default};
103
+ resize: ${enableResize ? "vertical" : "none"};
104
+ padding: ${isFloatingLabel && hasLabel ? "24px 12px 12px 12px" : "12px"};
105
+ border: 0;
106
+
107
+ ${!isFloatingLabel && hasLabel && "margin-top: 8px"};
128
108
 
129
109
  ${variant === "outlined" ? `border-radius: ${theme.shape.formField};
130
- border: 1px solid ${hasError ? theme.palette.error.default : theme.palette.border.default};
131
- &:focus-within,
132
- &:hover {
110
+ border: 1px solid ${hasError ? theme.palette.error.default : theme.palette.border.medium};
111
+
112
+ &:focus-within,
113
+ &:hover:not([disabled]) {
133
114
  border: 1px solid ${borderColor};
134
115
  }
135
116
  ` : `border-radius: ${theme.shape.formField} ${theme.shape.formField} 0 0;
136
- border-bottom: 1px solid ${hasError ? theme.palette.error.default : theme.palette.border.default};
137
- &:focus-within,
138
- &:hover {
117
+ border-bottom: 1px solid ${hasError ? theme.palette.error.default : theme.palette.border.medium};
118
+
119
+ &:focus-within,
120
+ &:hover:not([disabled]) {
139
121
  border-bottom: 1px solid ${borderColor};
140
122
  }
141
123
  `};
142
124
 
143
- ${variant === "outlined" ? "border-width: 1px" : "border-width: 0 0 1px"};
125
+ &:read-only {
126
+ color: ${theme.palette.content.light};
127
+ }
128
+
129
+ &:disabled {
130
+ cursor: not-allowed;
131
+ color: ${theme.palette.content.light};
132
+ }
144
133
  `;
145
134
  }}
146
135
  `;
@@ -154,40 +143,47 @@ var TextArea = (_a) => {
154
143
  name,
155
144
  value,
156
145
  style,
146
+ onChange,
147
+ maxLength,
157
148
  variant = "outlined",
158
149
  backgroundFill = "default",
159
- maxLength,
160
150
  enableResize = false,
161
151
  disabled = false,
162
152
  required = false,
163
153
  hasError = false,
154
+ hasLabel = true,
164
155
  message: messageProp = "",
165
- onChange = () => {
166
- }
156
+ labelVariant = "default",
157
+ placeholder,
158
+ readOnly
167
159
  } = _b, rest = __objRest(_b, [
168
160
  "label",
169
161
  "dataTestId",
170
162
  "name",
171
163
  "value",
172
164
  "style",
165
+ "onChange",
166
+ "maxLength",
173
167
  "variant",
174
168
  "backgroundFill",
175
- "maxLength",
176
169
  "enableResize",
177
170
  "disabled",
178
171
  "required",
179
172
  "hasError",
173
+ "hasLabel",
180
174
  "message",
181
- "onChange"
175
+ "labelVariant",
176
+ "placeholder",
177
+ "readOnly"
182
178
  ]);
183
- const [chars, setChars] = (0, import_react.useState)(0);
184
- const [activeInput, setActiveInput] = (0, import_react.useState)(false);
185
- const [inputValue, setInputValue] = (0, import_react.useState)("");
186
- const [hasRequiredError, setHasRequiredError] = (0, import_react.useState)(false);
187
- (0, import_react.useEffect)(() => {
179
+ const [chars, setChars] = (0, import_react2.useState)(0);
180
+ const [isActive, setIsActive] = (0, import_react2.useState)(false);
181
+ const [inputValue, setInputValue] = (0, import_react2.useState)("");
182
+ const [hasRequiredError, setHasRequiredError] = (0, import_react2.useState)(false);
183
+ const theme = (0, import_react.useTheme)();
184
+ (0, import_react2.useEffect)(() => {
188
185
  if (!!value) {
189
186
  setInputValue(value);
190
- setActiveInput(true);
191
187
  setChars(value.length);
192
188
  setHasRequiredError(false);
193
189
  } else {
@@ -203,93 +199,107 @@ var TextArea = (_a) => {
203
199
  }
204
200
  };
205
201
  const onFocus = (event) => {
206
- setActiveInput(true);
202
+ setIsActive(true);
207
203
  if (rest.onFocus) {
208
204
  rest.onFocus(event);
209
205
  }
210
206
  };
211
207
  const onBlur = (event) => {
208
+ setIsActive(false);
212
209
  const isEmptyOrOnlySpaces = event.currentTarget.value.trim().length === 0;
213
- if (isEmptyOrOnlySpaces) {
214
- setActiveInput(false);
215
- if (required) {
216
- setHasRequiredError(true);
217
- }
210
+ if (isEmptyOrOnlySpaces && required) {
211
+ setHasRequiredError(true);
218
212
  }
219
213
  if (rest.onBlur) {
220
214
  rest.onBlur(event);
221
215
  }
222
216
  };
223
217
  const testId = dataTestId != null ? dataTestId : `${label.replaceAll(" ", "-").toLocaleLowerCase()}-textarea`;
224
- const messageColor = disabled ? "content.light" : "content.medium";
218
+ const messageColor = disabled || readOnly ? "content.light" : "content.medium";
225
219
  const showError = hasError || hasRequiredError;
226
220
  const message = messageProp;
227
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TextAreaWrapper, { children: [
228
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
221
+ const isFloatingLabel = labelVariant === "floating";
222
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_box.Box, { style: { position: "relative", alignItems: "flex-start" }, children: [
223
+ hasLabel ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
229
224
  import_react_label_field.LabelField,
230
225
  {
231
226
  hasError: showError,
232
227
  htmlFor: testId,
233
- isActive: activeInput,
234
- isDisabled: disabled,
228
+ isActive: isActive && !readOnly ? true : false,
229
+ isDisabled: disabled || readOnly,
230
+ isFloating: isFloatingLabel,
231
+ isInputFilled: !!chars,
235
232
  isRequired: required,
236
233
  style: { zIndex: 1 },
237
234
  children: label
238
235
  }
239
- ),
236
+ ) : null,
240
237
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
241
- ContainerStyled,
242
- {
238
+ TextAreaStyled,
239
+ __spreadValues(__spreadProps(__spreadValues({
243
240
  backgroundFill,
244
- "data-testid": "textarea-container",
241
+ "data-error": showError,
242
+ "data-testid": testId,
243
+ disabled,
244
+ enableResize,
245
245
  hasError: showError,
246
- variant,
247
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
248
- TextAreaStyled,
249
- __spreadProps(__spreadValues({
250
- backgroundFill,
251
- "data-error": showError,
252
- disabled,
253
- enableResize,
254
- id: testId,
255
- maxLength,
256
- name,
257
- style,
258
- value: inputValue
259
- }, rest), {
260
- onBlur,
261
- onChange: handleChange,
262
- onFocus
263
- })
264
- )
265
- }
246
+ hasLabel,
247
+ id: testId,
248
+ isFloatingLabel,
249
+ maxLength,
250
+ name,
251
+ readOnly,
252
+ style,
253
+ value: inputValue,
254
+ variant
255
+ }, rest), {
256
+ onBlur,
257
+ onChange: handleChange,
258
+ onFocus
259
+ }), (!isFloatingLabel || !hasLabel) && {
260
+ placeholder
261
+ })
266
262
  ),
267
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TextAreaMessages, { children: [
268
- message ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TextAreaMessageStyled, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
269
- import_react_typography.Typography,
270
- {
271
- color: showError ? "error.default" : messageColor,
272
- element: "span",
273
- fontStyles: "bodySmRegular",
274
- children: message
275
- }
276
- ) }) : null,
277
- maxLength ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
278
- import_react_typography.Typography,
279
- {
280
- color: "content.medium",
281
- element: "span",
282
- fontStyles: "bodyMdRegular",
283
- id: testId,
284
- style: { marginLeft: "auto" },
285
- children: [
286
- chars,
287
- " / ",
288
- maxLength
289
- ]
290
- }
291
- ) : null
292
- ] })
263
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
264
+ import_react_box.Box,
265
+ {
266
+ style: {
267
+ flexDirection: "row",
268
+ justifyContent: "space-between",
269
+ width: "100%",
270
+ paddingInline: theme.spacing.spacing_40,
271
+ gap: theme.spacing.spacing_30,
272
+ marginTop: 4
273
+ },
274
+ children: [
275
+ message ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
276
+ import_react_typography.Typography,
277
+ {
278
+ color: showError ? "error.default" : messageColor,
279
+ element: "span",
280
+ fontStyles: "bodySmRegular",
281
+ children: message
282
+ }
283
+ ) : null,
284
+ maxLength ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
285
+ import_react_typography.Typography,
286
+ __spreadProps(__spreadValues({
287
+ color: showError ? "error.default" : messageColor,
288
+ dataTestId: "char-counter",
289
+ element: "span",
290
+ fontStyles: "bodySmRegular",
291
+ id: testId
292
+ }, !message && { style: { marginLeft: "auto" } }), {
293
+ children: [
294
+ chars,
295
+ " / ",
296
+ maxLength
297
+ ]
298
+ })
299
+ ) : null
300
+ ]
301
+ }
302
+ )
293
303
  ] });
294
304
  };
295
305
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.mjs CHANGED
@@ -31,8 +31,10 @@ var __objRest = (source, exclude) => {
31
31
  };
32
32
 
33
33
  // src/TextArea.tsx
34
+ import { Box } from "@dt-dds/react-box";
34
35
  import { LabelField } from "@dt-dds/react-label-field";
35
36
  import { Typography } from "@dt-dds/react-typography";
37
+ import { useTheme } from "@emotion/react";
36
38
  import {
37
39
  useEffect,
38
40
  useState
@@ -49,68 +51,55 @@ var getThemedBackgroundFill = (backgroundFill, theme) => ({
49
51
  })[backgroundFill] || theme.palette.surface.default;
50
52
 
51
53
  // src/TextArea.styled.ts
52
- var TextAreaWrapper = styled.div`
53
- ${({ theme }) => `
54
- display: flex;
55
- flex-direction: column;
56
- align-items: flex-end;
57
- position: relative;
58
- width: 100%;
59
-
60
- border-style: solid;
61
- border-width: 0;
62
- border-color: ${theme.palette.border.dark};
63
- `}
64
- `;
65
- var TextAreaMessageStyled = styled.div`
66
- ${({ theme }) => `padding-left: ${theme.spacing.spacing_50}`};
67
- `;
68
- var TextAreaMessages = styled.div`
69
- display: flex;
70
- flex-direction: row;
71
- flex-wrap: wrap;
72
- justify-content: space-between;
73
- align-items: baseline;
74
- width: 100%;
75
- `;
76
54
  var TextAreaStyled = styled.textarea`
77
- ${({ theme, enableResize = false, backgroundFill }) => `
78
- ${theme.fontStyles.bodyLgRegular}
55
+ ${({
56
+ theme,
57
+ enableResize,
58
+ backgroundFill,
59
+ variant,
60
+ hasError,
61
+ isFloatingLabel,
62
+ hasLabel
63
+ }) => {
64
+ const borderColor = hasError ? theme.palette.error.default : theme.palette.informative.default;
65
+ return `
66
+ ${theme.fontStyles.bodyMdRegular}
79
67
 
80
68
  background-color: ${getThemedBackgroundFill(backgroundFill, theme)};
81
-
82
- border-style: none;
69
+ min-height: 100px;
83
70
  width: 100%;
84
- color: ${theme.palette.content.dark};
85
- resize: ${enableResize ? "vertical" : "none"};
86
71
  outline: none;
87
- padding-right: 10px;
88
- `}
89
- `;
90
- var ContainerStyled = styled.div`
91
- ${({ theme, variant, hasError = false, backgroundFill }) => {
92
- const borderColor = hasError ? theme.palette.error.default : theme.palette.primary.default;
93
- return `
94
- background-color: ${getThemedBackgroundFill(backgroundFill, theme)};
95
- position: relative;
96
- padding: 25px 0px 0px 10px;
97
- width: 100%;
72
+ color: ${theme.palette.content.default};
73
+ resize: ${enableResize ? "vertical" : "none"};
74
+ padding: ${isFloatingLabel && hasLabel ? "24px 12px 12px 12px" : "12px"};
75
+ border: 0;
76
+
77
+ ${!isFloatingLabel && hasLabel && "margin-top: 8px"};
98
78
 
99
79
  ${variant === "outlined" ? `border-radius: ${theme.shape.formField};
100
- border: 1px solid ${hasError ? theme.palette.error.default : theme.palette.border.default};
101
- &:focus-within,
102
- &:hover {
80
+ border: 1px solid ${hasError ? theme.palette.error.default : theme.palette.border.medium};
81
+
82
+ &:focus-within,
83
+ &:hover:not([disabled]) {
103
84
  border: 1px solid ${borderColor};
104
85
  }
105
86
  ` : `border-radius: ${theme.shape.formField} ${theme.shape.formField} 0 0;
106
- border-bottom: 1px solid ${hasError ? theme.palette.error.default : theme.palette.border.default};
107
- &:focus-within,
108
- &:hover {
87
+ border-bottom: 1px solid ${hasError ? theme.palette.error.default : theme.palette.border.medium};
88
+
89
+ &:focus-within,
90
+ &:hover:not([disabled]) {
109
91
  border-bottom: 1px solid ${borderColor};
110
92
  }
111
93
  `};
112
94
 
113
- ${variant === "outlined" ? "border-width: 1px" : "border-width: 0 0 1px"};
95
+ &:read-only {
96
+ color: ${theme.palette.content.light};
97
+ }
98
+
99
+ &:disabled {
100
+ cursor: not-allowed;
101
+ color: ${theme.palette.content.light};
102
+ }
114
103
  `;
115
104
  }}
116
105
  `;
@@ -124,40 +113,47 @@ var TextArea = (_a) => {
124
113
  name,
125
114
  value,
126
115
  style,
116
+ onChange,
117
+ maxLength,
127
118
  variant = "outlined",
128
119
  backgroundFill = "default",
129
- maxLength,
130
120
  enableResize = false,
131
121
  disabled = false,
132
122
  required = false,
133
123
  hasError = false,
124
+ hasLabel = true,
134
125
  message: messageProp = "",
135
- onChange = () => {
136
- }
126
+ labelVariant = "default",
127
+ placeholder,
128
+ readOnly
137
129
  } = _b, rest = __objRest(_b, [
138
130
  "label",
139
131
  "dataTestId",
140
132
  "name",
141
133
  "value",
142
134
  "style",
135
+ "onChange",
136
+ "maxLength",
143
137
  "variant",
144
138
  "backgroundFill",
145
- "maxLength",
146
139
  "enableResize",
147
140
  "disabled",
148
141
  "required",
149
142
  "hasError",
143
+ "hasLabel",
150
144
  "message",
151
- "onChange"
145
+ "labelVariant",
146
+ "placeholder",
147
+ "readOnly"
152
148
  ]);
153
149
  const [chars, setChars] = useState(0);
154
- const [activeInput, setActiveInput] = useState(false);
150
+ const [isActive, setIsActive] = useState(false);
155
151
  const [inputValue, setInputValue] = useState("");
156
152
  const [hasRequiredError, setHasRequiredError] = useState(false);
153
+ const theme = useTheme();
157
154
  useEffect(() => {
158
155
  if (!!value) {
159
156
  setInputValue(value);
160
- setActiveInput(true);
161
157
  setChars(value.length);
162
158
  setHasRequiredError(false);
163
159
  } else {
@@ -173,93 +169,107 @@ var TextArea = (_a) => {
173
169
  }
174
170
  };
175
171
  const onFocus = (event) => {
176
- setActiveInput(true);
172
+ setIsActive(true);
177
173
  if (rest.onFocus) {
178
174
  rest.onFocus(event);
179
175
  }
180
176
  };
181
177
  const onBlur = (event) => {
178
+ setIsActive(false);
182
179
  const isEmptyOrOnlySpaces = event.currentTarget.value.trim().length === 0;
183
- if (isEmptyOrOnlySpaces) {
184
- setActiveInput(false);
185
- if (required) {
186
- setHasRequiredError(true);
187
- }
180
+ if (isEmptyOrOnlySpaces && required) {
181
+ setHasRequiredError(true);
188
182
  }
189
183
  if (rest.onBlur) {
190
184
  rest.onBlur(event);
191
185
  }
192
186
  };
193
187
  const testId = dataTestId != null ? dataTestId : `${label.replaceAll(" ", "-").toLocaleLowerCase()}-textarea`;
194
- const messageColor = disabled ? "content.light" : "content.medium";
188
+ const messageColor = disabled || readOnly ? "content.light" : "content.medium";
195
189
  const showError = hasError || hasRequiredError;
196
190
  const message = messageProp;
197
- return /* @__PURE__ */ jsxs(TextAreaWrapper, { children: [
198
- /* @__PURE__ */ jsx(
191
+ const isFloatingLabel = labelVariant === "floating";
192
+ return /* @__PURE__ */ jsxs(Box, { style: { position: "relative", alignItems: "flex-start" }, children: [
193
+ hasLabel ? /* @__PURE__ */ jsx(
199
194
  LabelField,
200
195
  {
201
196
  hasError: showError,
202
197
  htmlFor: testId,
203
- isActive: activeInput,
204
- isDisabled: disabled,
198
+ isActive: isActive && !readOnly ? true : false,
199
+ isDisabled: disabled || readOnly,
200
+ isFloating: isFloatingLabel,
201
+ isInputFilled: !!chars,
205
202
  isRequired: required,
206
203
  style: { zIndex: 1 },
207
204
  children: label
208
205
  }
209
- ),
206
+ ) : null,
210
207
  /* @__PURE__ */ jsx(
211
- ContainerStyled,
212
- {
208
+ TextAreaStyled,
209
+ __spreadValues(__spreadProps(__spreadValues({
213
210
  backgroundFill,
214
- "data-testid": "textarea-container",
211
+ "data-error": showError,
212
+ "data-testid": testId,
213
+ disabled,
214
+ enableResize,
215
215
  hasError: showError,
216
- variant,
217
- children: /* @__PURE__ */ jsx(
218
- TextAreaStyled,
219
- __spreadProps(__spreadValues({
220
- backgroundFill,
221
- "data-error": showError,
222
- disabled,
223
- enableResize,
224
- id: testId,
225
- maxLength,
226
- name,
227
- style,
228
- value: inputValue
229
- }, rest), {
230
- onBlur,
231
- onChange: handleChange,
232
- onFocus
233
- })
234
- )
235
- }
216
+ hasLabel,
217
+ id: testId,
218
+ isFloatingLabel,
219
+ maxLength,
220
+ name,
221
+ readOnly,
222
+ style,
223
+ value: inputValue,
224
+ variant
225
+ }, rest), {
226
+ onBlur,
227
+ onChange: handleChange,
228
+ onFocus
229
+ }), (!isFloatingLabel || !hasLabel) && {
230
+ placeholder
231
+ })
236
232
  ),
237
- /* @__PURE__ */ jsxs(TextAreaMessages, { children: [
238
- message ? /* @__PURE__ */ jsx(TextAreaMessageStyled, { children: /* @__PURE__ */ jsx(
239
- Typography,
240
- {
241
- color: showError ? "error.default" : messageColor,
242
- element: "span",
243
- fontStyles: "bodySmRegular",
244
- children: message
245
- }
246
- ) }) : null,
247
- maxLength ? /* @__PURE__ */ jsxs(
248
- Typography,
249
- {
250
- color: "content.medium",
251
- element: "span",
252
- fontStyles: "bodyMdRegular",
253
- id: testId,
254
- style: { marginLeft: "auto" },
255
- children: [
256
- chars,
257
- " / ",
258
- maxLength
259
- ]
260
- }
261
- ) : null
262
- ] })
233
+ /* @__PURE__ */ jsxs(
234
+ Box,
235
+ {
236
+ style: {
237
+ flexDirection: "row",
238
+ justifyContent: "space-between",
239
+ width: "100%",
240
+ paddingInline: theme.spacing.spacing_40,
241
+ gap: theme.spacing.spacing_30,
242
+ marginTop: 4
243
+ },
244
+ children: [
245
+ message ? /* @__PURE__ */ jsx(
246
+ Typography,
247
+ {
248
+ color: showError ? "error.default" : messageColor,
249
+ element: "span",
250
+ fontStyles: "bodySmRegular",
251
+ children: message
252
+ }
253
+ ) : null,
254
+ maxLength ? /* @__PURE__ */ jsxs(
255
+ Typography,
256
+ __spreadProps(__spreadValues({
257
+ color: showError ? "error.default" : messageColor,
258
+ dataTestId: "char-counter",
259
+ element: "span",
260
+ fontStyles: "bodySmRegular",
261
+ id: testId
262
+ }, !message && { style: { marginLeft: "auto" } }), {
263
+ children: [
264
+ chars,
265
+ " / ",
266
+ maxLength
267
+ ]
268
+ })
269
+ ) : null
270
+ ]
271
+ }
272
+ )
263
273
  ] });
264
274
  };
265
275
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dt-dds/react-text-area",
3
- "version": "1.0.0-beta.29",
3
+ "version": "1.0.0-beta.30",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./dist/index.js"
@@ -20,9 +20,10 @@
20
20
  "test:update:snapshot": "jest -u"
21
21
  },
22
22
  "dependencies": {
23
+ "@dt-dds/react-box": "1.0.0-beta.19",
23
24
  "@dt-dds/react-core": "1.0.0-beta.47",
25
+ "@dt-dds/react-label-field": "1.0.0-beta.44",
24
26
  "@dt-dds/react-typography": "1.0.0-beta.38",
25
- "@dt-dds/react-label-field": "1.0.0-beta.43",
26
27
  "@dt-dds/themes": "1.0.0-beta.7"
27
28
  },
28
29
  "devDependencies": {