@versini/ui-textarea 6.1.0 → 6.2.0

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/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { default as React_2 } from 'react';
1
+ import { JSX } from 'react/jsx-runtime';
2
2
 
3
3
  export declare const TEXT_AREA_CLASSNAME = "av-text-area";
4
4
 
@@ -10,20 +10,74 @@ export declare const TEXT_AREA_HELPER_TEXT_CLASSNAME = "av-text-area-helper-text
10
10
 
11
11
  export declare const TEXT_AREA_WRAPPER_CLASSNAME = "av-text-area-wrapper";
12
12
 
13
- export declare const TextArea: React_2.ForwardRefExoticComponent<{
13
+ export declare function TextArea({ id, name, label, error, raw, className, textAreaClassName, mode, focusMode, value, defaultValue, disabled, noBorder, labelId, helperText, helperTextOnFocus, rightElement, leftElement, onChange, onFocus, onBlur, ref, ...extraProps }: TextAreaProps): JSX.Element;
14
+
15
+ declare type TextAreaProps = {
16
+ /**
17
+ * A ref to the textarea element.
18
+ */
19
+ ref?: React.Ref<HTMLTextAreaElement>;
20
+ /**
21
+ * The label of the TextArea.
22
+ */
14
23
  label: string;
24
+ /**
25
+ * The name of the TextArea.
26
+ */
15
27
  name: string;
28
+ /**
29
+ * Whether or not the TextArea is in error state.
30
+ * @default false
31
+ */
16
32
  error?: boolean;
33
+ /**
34
+ * The type of focus for the TextArea. This will change the color
35
+ * of the focus ring around the TextArea.
36
+ */
17
37
  focusMode?: "dark" | "light" | "system" | "alt-system";
38
+ /**
39
+ * Text to add to the bottom of the TextArea.
40
+ */
18
41
  helperText?: string;
42
+ /**
43
+ * Whether or not to show the helper text ONLY when the TextArea is focused.
44
+ * @default false
45
+ */
19
46
  helperTextOnFocus?: boolean;
47
+ /**
48
+ * Id to use for the TextArea label.
49
+ */
20
50
  labelId?: string;
51
+ /**
52
+ * Whether or not the TextArea has a border.
53
+ * @default false
54
+ */
55
+ /**
56
+ * The mode of TextInput. This will change the color of the TextInput.
57
+ */
21
58
  mode?: "dark" | "light" | "system" | "alt-system";
22
59
  noBorder?: boolean;
60
+ /**
61
+ * Whether or not to render the TextArea with styles or not.
62
+ * @default false
63
+ */
23
64
  raw?: boolean;
24
- rightElement?: React_2.ReactElement;
25
- leftElement?: React_2.ReactElement;
65
+ /**
66
+ * This prop allows you to pass in a React element to render on the right
67
+ * side of the TextArea. This is useful for adding icons or actionable
68
+ * elements, such a Button.
69
+ */
70
+ rightElement?: React.ReactElement;
71
+ /**
72
+ * This prop allows you to pass in a React element to render on the left
73
+ * side of the TextArea. This is useful for adding icons or actionable
74
+ * elements, such a Button.
75
+ */
76
+ leftElement?: React.ReactElement;
77
+ /**
78
+ * CSS class(es) to add to the actual textarea element.
79
+ */
26
80
  textAreaClassName?: string;
27
- } & React_2.TextareaHTMLAttributes<HTMLTextAreaElement> & React_2.RefAttributes<HTMLTextAreaElement>>;
81
+ } & React.TextareaHTMLAttributes<HTMLTextAreaElement>;
28
82
 
29
83
  export { }
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- @versini/ui-textarea v6.1.0
2
+ @versini/ui-textarea v6.2.0
3
3
  © 2025 gizmette.com
4
4
  */
5
5
 
@@ -9,7 +9,7 @@ import { useResizeObserver } from "@versini/ui-hooks/use-resize-observer";
9
9
  import { useUncontrolled } from "@versini/ui-hooks/use-uncontrolled";
10
10
  import { useUniqueId } from "@versini/ui-hooks/use-unique-id";
11
11
  import { LiveRegion } from "@versini/ui-liveregion";
12
- import react, { useLayoutEffect, useRef, useState } from "react";
12
+ import { useLayoutEffect, useRef, useState } from "react";
13
13
  import clsx from "clsx";
14
14
 
15
15
  ;// CONCATENATED MODULE: ./src/common/constants.ts
@@ -188,7 +188,7 @@ const adjustLabelAndHelperText = ({ scrollHeight, currentHeight, currentLabelOff
188
188
 
189
189
 
190
190
 
191
- const TextArea = /*#__PURE__*/ react.forwardRef(({ id, name, label, error = false, raw = false, className, textAreaClassName, mode = "system", focusMode = "system", value, defaultValue, disabled = false, noBorder = false, labelId, helperText = "", helperTextOnFocus = false, rightElement, leftElement, onChange, onFocus, onBlur, ...extraProps }, ref)=>{
191
+ function TextArea({ id, name, label, error = false, raw = false, className, textAreaClassName, mode = "system", focusMode = "system", value, defaultValue, disabled = false, noBorder = false, labelId, helperText = "", helperTextOnFocus = false, rightElement, leftElement, onChange, onFocus, onBlur, ref, ...extraProps }) {
192
192
  const textAreaRef = useRef(null);
193
193
  const mergedTextAreaRef = useMergeRefs([
194
194
  ref,
@@ -222,9 +222,9 @@ const TextArea = /*#__PURE__*/ react.forwardRef(({ id, name, label, error = fals
222
222
  leftElement: Boolean(leftElement)
223
223
  });
224
224
  /**
225
- * useUncontrolled hook is used to make the textarea
226
- * both controlled and uncontrolled.
227
- */ const [userInput, setUserInput] = useUncontrolled({
225
+ * useUncontrolled hook is used to make the textarea
226
+ * both controlled and uncontrolled.
227
+ */ const [userInput, setUserInput] = useUncontrolled({
228
228
  value,
229
229
  initialControlledDelay: 20,
230
230
  defaultValue,
@@ -253,44 +253,44 @@ const TextArea = /*#__PURE__*/ react.forwardRef(({ id, name, label, error = fals
253
253
  onBlur && onBlur(e);
254
254
  };
255
255
  /**
256
- * This effect is used to add padding to the rightElement so
257
- * that the input text in the textarea does not overlap with the
258
- * rightElement.
259
- */ /* c8 ignore start - ResizeObserver is tough to test... */ useLayoutEffect(()=>{
256
+ * This effect is used to add padding to the rightElement so
257
+ * that the input text in the textarea does not overlap with the
258
+ * rightElement.
259
+ */ /* c8 ignore start - ResizeObserver is tough to test... */ useLayoutEffect(()=>{
260
260
  if (rect && rect.width) {
261
261
  /**
262
- * - rect.width is the width of the right element (Button, Icon, etc.)
263
- * - The main input field has default left/right paddings of
264
- * 16px (px-4) + 2px border (border-2) = 18px
265
- * - We add 10px to the right padding to give some space between the right
266
- * element and the input field.
267
- */ setTextAreaPaddingRight(rect.width + 18 + 10);
262
+ * - rect.width is the width of the right element (Button, Icon, etc.)
263
+ * - The main input field has default left/right paddings of
264
+ * 16px (px-4) + 2px border (border-2) = 18px
265
+ * - We add 10px to the right padding to give some space between the right
266
+ * element and the input field.
267
+ */ setTextAreaPaddingRight(rect.width + 18 + 10);
268
268
  }
269
269
  }, [
270
270
  rect
271
271
  ]);
272
272
  /* c8 ignore end */ /**
273
- * This effect is used to add padding to the leftElement so
274
- * that the input text in the textarea does not overlap with the
275
- * leftElement.
276
- */ /* c8 ignore start - ResizeObserver is tough to test... */ useLayoutEffect(()=>{
273
+ * This effect is used to add padding to the leftElement so
274
+ * that the input text in the textarea does not overlap with the
275
+ * leftElement.
276
+ */ /* c8 ignore start - ResizeObserver is tough to test... */ useLayoutEffect(()=>{
277
277
  if (lRect && lRect.width) {
278
278
  /**
279
- * - rect.width is the width of the right element (Button, Icon, etc.)
280
- * - The main input field has default left/right paddings of
281
- * 16px (px-4) + 2px border (border-2) = 18px
282
- * - We add 10px to the left padding to give some space between the left
283
- * element and the input field.
284
- */ setTextAreaPaddingLeft(lRect.width + 18 + 10);
279
+ * - rect.width is the width of the right element (Button, Icon, etc.)
280
+ * - The main input field has default left/right paddings of
281
+ * 16px (px-4) + 2px border (border-2) = 18px
282
+ * - We add 10px to the left padding to give some space between the left
283
+ * element and the input field.
284
+ */ setTextAreaPaddingLeft(lRect.width + 18 + 10);
285
285
  }
286
286
  }, [
287
287
  lRect
288
288
  ]);
289
289
  /* c8 ignore end */ /**
290
- * This effect is used to resize the textarea based
291
- * on the content, so that the user can see all the
292
- * content they have typed.
293
- */ useLayoutEffect(()=>{
290
+ * This effect is used to resize the textarea based
291
+ * on the content, so that the user can see all the
292
+ * content they have typed.
293
+ */ useLayoutEffect(()=>{
294
294
  if (raw) {
295
295
  return;
296
296
  }
@@ -304,15 +304,15 @@ const TextArea = /*#__PURE__*/ react.forwardRef(({ id, name, label, error = fals
304
304
  raw
305
305
  ]);
306
306
  /**
307
- * This section is to toggle the transitions.
308
- * This is to prevent the label and helper text from
309
- * animating when the user is typing. The animation is
310
- * re-enabled when there is nothing in the textarea.
311
- *
312
- * The reason for the timeout is to prevent it to be
313
- * re-enabled too soon when the user clears out the
314
- * whole textarea.
315
- */ useLayoutEffect(()=>{
307
+ * This section is to toggle the transitions.
308
+ * This is to prevent the label and helper text from
309
+ * animating when the user is typing. The animation is
310
+ * re-enabled when there is nothing in the textarea.
311
+ *
312
+ * The reason for the timeout is to prevent it to be
313
+ * re-enabled too soon when the user clears out the
314
+ * whole textarea.
315
+ */ useLayoutEffect(()=>{
316
316
  if (raw) {
317
317
  return;
318
318
  }
@@ -324,12 +324,12 @@ const TextArea = /*#__PURE__*/ react.forwardRef(({ id, name, label, error = fals
324
324
  raw
325
325
  ]);
326
326
  /**
327
- * This effect is used to adjust the label and helper text
328
- * when the height of the textarea changes.
329
- * This is done by calculating the difference in
330
- * height and then adjusting the label and helper
331
- * text by that amount.
332
- */ useLayoutEffect(()=>{
327
+ * This effect is used to adjust the label and helper text
328
+ * when the height of the textarea changes.
329
+ * This is done by calculating the difference in
330
+ * height and then adjusting the label and helper
331
+ * text by that amount.
332
+ */ useLayoutEffect(()=>{
333
333
  if (raw) {
334
334
  return;
335
335
  }
@@ -355,10 +355,10 @@ const TextArea = /*#__PURE__*/ react.forwardRef(({ id, name, label, error = fals
355
355
  raw
356
356
  ]);
357
357
  /**
358
- * If there is a left element, we need to translate the label on the x-axis
359
- * to the right so that it does not overlap with the left element.
360
- * NOTE: 12px is the default translate if there are no left elements.
361
- */ if (lRect.width > 0) {
358
+ * If there is a left element, we need to translate the label on the x-axis
359
+ * to the right so that it does not overlap with the left element.
360
+ * NOTE: 12px is the default translate if there are no left elements.
361
+ */ if (lRect.width > 0) {
362
362
  labelRef?.current?.style.setProperty("--tw-translate-x", `${12 + lRect.width + 5}px`);
363
363
  }
364
364
  return /*#__PURE__*/ jsxs("div", {
@@ -436,11 +436,9 @@ const TextArea = /*#__PURE__*/ react.forwardRef(({ id, name, label, error = fals
436
436
  })
437
437
  ]
438
438
  });
439
- });
440
- TextArea.displayName = "TextArea";
439
+ }
441
440
 
442
441
  ;// CONCATENATED MODULE: ./src/components/index.ts
443
- // force new release
444
442
 
445
443
 
446
444
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versini/ui-textarea",
3
- "version": "6.1.0",
3
+ "version": "6.2.0",
4
4
  "license": "MIT",
5
5
  "author": "Arno Versini",
6
6
  "publishConfig": {
@@ -23,7 +23,7 @@
23
23
  "build:js": "rslib build",
24
24
  "build:types": "echo 'Types now built with rslib'",
25
25
  "build": "npm-run-all --serial clean build:check build:js",
26
- "clean": "rimraf dist tmp",
26
+ "clean": "rimraf dist tmp coverage",
27
27
  "dev:js": "rslib build --watch",
28
28
  "dev:types": "echo 'Types now watched with rslib'",
29
29
  "dev": "rslib build --watch",
@@ -38,17 +38,17 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "@testing-library/jest-dom": "6.9.1",
41
- "@versini/ui-types": "8.1.0"
41
+ "@versini/ui-types": "8.2.0"
42
42
  },
43
43
  "dependencies": {
44
44
  "@tailwindcss/typography": "0.5.19",
45
- "@versini/ui-hooks": "6.1.0",
46
- "@versini/ui-liveregion": "3.2.0",
45
+ "@versini/ui-hooks": "6.1.1",
46
+ "@versini/ui-liveregion": "3.2.2",
47
47
  "clsx": "2.1.1",
48
48
  "tailwindcss": "4.1.18"
49
49
  },
50
50
  "sideEffects": [
51
51
  "**/*.css"
52
52
  ],
53
- "gitHead": "b2ee2e328ecadfbedcb26d14afa896a30f0ab54b"
53
+ "gitHead": "5cc3c9aaf61ca3843f16a3d6b322a92f7fb210ca"
54
54
  }