next-helios-fe 1.8.82 → 1.8.84
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/components/chip/index.d.ts +1 -0
- package/dist/components/form/other/textarea.d.ts +4 -1
- package/dist/components/table/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/components/chip/index.tsx +34 -4
- package/src/components/form/other/textarea.tsx +22 -4
- package/src/components/table/index.tsx +2 -12
package/package.json
CHANGED
@@ -10,9 +10,15 @@ interface ChipProps {
|
|
10
10
|
bordered?: boolean;
|
11
11
|
borderRadius?: "basic" | "full";
|
12
12
|
};
|
13
|
+
onRemove?: () => void;
|
13
14
|
}
|
14
15
|
|
15
|
-
export const Chip: React.FC<ChipProps> = ({
|
16
|
+
export const Chip: React.FC<ChipProps> = ({
|
17
|
+
label,
|
18
|
+
icon,
|
19
|
+
options,
|
20
|
+
onRemove,
|
21
|
+
}) => {
|
16
22
|
const variant =
|
17
23
|
options?.bordered !== true
|
18
24
|
? options?.variant === "secondary"
|
@@ -35,13 +41,37 @@ export const Chip: React.FC<ChipProps> = ({ label, icon, options }) => {
|
|
35
41
|
: "border border-primary text-primary";
|
36
42
|
const borderRadius =
|
37
43
|
options?.borderRadius === "full" ? "rounded-full" : "rounded-md";
|
44
|
+
const removeButton =
|
45
|
+
options?.variant === "secondary"
|
46
|
+
? "text-secondary hover:text-secondary-dark"
|
47
|
+
: options?.variant === "success"
|
48
|
+
? "text-success hover:text-success-dark"
|
49
|
+
: options?.variant === "warning"
|
50
|
+
? "text-warning hover:text-warning-dark"
|
51
|
+
: options?.variant === "danger"
|
52
|
+
? "text-danger hover:text-danger-dark"
|
53
|
+
: "text-primary hover:text-primary-dark";
|
38
54
|
|
39
55
|
return (
|
40
56
|
<div
|
41
|
-
className={`flex items-center gap-
|
57
|
+
className={`flex items-center gap-3 w-fit px-3 py-1 font-medium select-none ${variant} ${borderRadius}`}
|
42
58
|
>
|
43
|
-
|
44
|
-
|
59
|
+
<div className="flex items-center gap-1.5">
|
60
|
+
{icon && <Icon icon={icon} className="text-lg" />}
|
61
|
+
<span className="text-sm">{label}</span>
|
62
|
+
</div>
|
63
|
+
{onRemove && (
|
64
|
+
<div
|
65
|
+
className={`cursor-pointer active:opacity-70 active:duration-300 active:ease-out disabled:active:opacity-100 ${removeButton}`}
|
66
|
+
onClick={() => {
|
67
|
+
if (onRemove) {
|
68
|
+
onRemove();
|
69
|
+
}
|
70
|
+
}}
|
71
|
+
>
|
72
|
+
<Icon icon="pajamas:close" />
|
73
|
+
</div>
|
74
|
+
)}
|
45
75
|
</div>
|
46
76
|
);
|
47
77
|
};
|
@@ -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,16 @@ export const Textarea: React.FC<TextareaProps> = ({
|
|
28
34
|
? "py-2"
|
29
35
|
: "py-1.5";
|
30
36
|
|
37
|
+
useEffect(() => {
|
38
|
+
if (maxRows && rest.value && (rest.value as string)?.includes("\n")) {
|
39
|
+
if (((rest.value as string).match(/\n/g) || []).length < maxRows) {
|
40
|
+
setTempRows(((rest.value as string).match(/\n/g) || []).length + 1);
|
41
|
+
}
|
42
|
+
} else {
|
43
|
+
setTempRows(1);
|
44
|
+
}
|
45
|
+
}, [maxRows, rest.value]);
|
46
|
+
|
31
47
|
return (
|
32
48
|
<label className={`flex flex-col gap-2 ${width}`}>
|
33
49
|
{(label ||
|
@@ -64,8 +80,10 @@ export const Textarea: React.FC<TextareaProps> = ({
|
|
64
80
|
</div>
|
65
81
|
)}
|
66
82
|
<textarea
|
67
|
-
rows={
|
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 ${
|
83
|
+
rows={tempRows}
|
84
|
+
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 ${
|
85
|
+
options?.disableResize && "resize-none"
|
86
|
+
} ${height}`}
|
69
87
|
{...rest}
|
70
88
|
/>
|
71
89
|
</label>
|
@@ -46,7 +46,7 @@ interface TableProps {
|
|
46
46
|
};
|
47
47
|
customTool?: {
|
48
48
|
icon: string;
|
49
|
-
tooltip
|
49
|
+
tooltip: string;
|
50
50
|
variant: "primary" | "secondary" | "success" | "warning" | "danger";
|
51
51
|
show?: boolean;
|
52
52
|
onClick: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
@@ -548,7 +548,7 @@ export const Table: TableComponentProps = ({
|
|
548
548
|
: "bg-primary hover:bg-primary-dark";
|
549
549
|
|
550
550
|
if (item.show !== false) {
|
551
|
-
return
|
551
|
+
return (
|
552
552
|
<Tooltip
|
553
553
|
key={index}
|
554
554
|
content={item.tooltip || "custom tool"}
|
@@ -563,16 +563,6 @@ export const Table: TableComponentProps = ({
|
|
563
563
|
<Icon icon={item.icon} className="text-2xl" />
|
564
564
|
</button>
|
565
565
|
</Tooltip>
|
566
|
-
) : (
|
567
|
-
<button
|
568
|
-
type="button"
|
569
|
-
className={`rounded-full p-1.5 text-white ${variant}`}
|
570
|
-
onClick={(e) => {
|
571
|
-
item.onClick && item.onClick(e);
|
572
|
-
}}
|
573
|
-
>
|
574
|
-
<Icon icon={item.icon} className="text-2xl" />
|
575
|
-
</button>
|
576
566
|
);
|
577
567
|
}
|
578
568
|
})}
|