next-helios-fe 1.8.83 → 1.8.85

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-helios-fe",
3
- "version": "1.8.83",
3
+ "version": "1.8.85",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,25 +1,31 @@
1
1
  "use client";
2
- import React from "react";
2
+ import React, { useState, useEffect } from "react";
3
3
  import { Tooltip } from "../../../components";
4
4
  import { Icon } from "@iconify/react";
5
5
 
6
6
  export interface TextareaProps
7
- extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
7
+ extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, "rows"> {
8
+ rows?: number;
9
+ maxRows?: number;
8
10
  label?: string;
9
11
  description?: string;
10
12
  options?: {
11
13
  width?: "full" | "fit";
12
14
  height?: "short" | "medium" | "high";
15
+ disableResize?: boolean;
13
16
  hideInputDetail?: boolean;
14
17
  };
15
18
  }
16
19
 
17
20
  export const Textarea: React.FC<TextareaProps> = ({
21
+ rows,
22
+ maxRows,
18
23
  options,
19
24
  label,
20
25
  description,
21
26
  ...rest
22
27
  }) => {
28
+ const [tempRows, setTempRows] = useState<number>(rows || 10);
23
29
  const width = options?.width === "fit" ? "w-fit" : "w-full";
24
30
  const height =
25
31
  options?.height === "short"
@@ -28,6 +34,18 @@ export const Textarea: React.FC<TextareaProps> = ({
28
34
  ? "py-2"
29
35
  : "py-1.5";
30
36
 
37
+ useEffect(() => {
38
+ if (maxRows) {
39
+ if (rest.value && (rest.value as string)?.includes("\n")) {
40
+ if (((rest.value as string).match(/\n/g) || []).length < maxRows) {
41
+ setTempRows(((rest.value as string).match(/\n/g) || []).length + 1);
42
+ }
43
+ } else {
44
+ setTempRows(rows || 10);
45
+ }
46
+ }
47
+ }, [rows, maxRows, rest.value]);
48
+
31
49
  return (
32
50
  <label className={`flex flex-col gap-2 ${width}`}>
33
51
  {(label ||
@@ -64,8 +82,10 @@ export const Textarea: React.FC<TextareaProps> = ({
64
82
  </div>
65
83
  )}
66
84
  <textarea
67
- rows={rest.rows || 10}
68
- className={`w-full px-4 border-default border rounded-md bg-secondary-bg placeholder:duration-300 placeholder:translate-x-0 focus:placeholder:translate-x-1 placeholder:text-silent focus:outline-none focus:ring-1 focus:ring-primary focus:shadow focus:shadow-primary focus:border-primary-dark disabled:bg-secondary-light disabled:text-disabled ${height}`}
85
+ rows={tempRows}
86
+ className={`w-full px-4 border-default border rounded-md bg-secondary-bg placeholder:duration-300 placeholder:translate-x-0 focus:placeholder:translate-x-1 placeholder:text-silent focus:outline-none focus:ring-1 focus:ring-primary focus:shadow focus:shadow-primary focus:border-primary-dark disabled:bg-secondary-light disabled:text-disabled ${
87
+ options?.disableResize && "resize-none"
88
+ } ${height}`}
69
89
  {...rest}
70
90
  />
71
91
  </label>