next-helios-fe 1.8.86 → 1.8.88
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.
|
3
|
+
"version": "1.8.88",
|
4
4
|
"description": "",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -39,7 +39,7 @@
|
|
39
39
|
"@iconify/react": "^5.0.1",
|
40
40
|
"dayjs": "^1.11.11",
|
41
41
|
"flowbite-react": "^0.10.1",
|
42
|
-
"next": "14.2.4",
|
42
|
+
"next": "^14.2.4",
|
43
43
|
"postcss": "^8",
|
44
44
|
"react": "^18.2.0",
|
45
45
|
"react-dom": "^18.2.0",
|
@@ -1,5 +1,5 @@
|
|
1
1
|
"use client";
|
2
|
-
import React, { useState, useRef } from "react";
|
2
|
+
import React, { useState, useEffect, useRef } from "react";
|
3
3
|
import { Icon } from "@iconify/react";
|
4
4
|
import { Window, type WindowProps } from "./window";
|
5
5
|
|
@@ -48,35 +48,25 @@ export const Wizard: WizardComponent = ({
|
|
48
48
|
});
|
49
49
|
const [activeTab, setActiveTab] = useState(0);
|
50
50
|
|
51
|
-
|
52
|
-
if (activeTab
|
51
|
+
useEffect(() => {
|
52
|
+
if (activeTab === 0) {
|
53
53
|
wizardNavigationRef.current?.scrollTo({
|
54
54
|
left: 0,
|
55
55
|
behavior: "smooth",
|
56
56
|
});
|
57
57
|
} else {
|
58
|
-
document.getElementById(`wizard-tab-${activeTab - 1}`)?.scrollIntoView({
|
59
|
-
behavior: "smooth",
|
60
|
-
block: "nearest",
|
61
|
-
inline: "center",
|
62
|
-
});
|
63
|
-
}
|
64
|
-
};
|
65
|
-
|
66
|
-
const handleOnNextClick = () => {
|
67
|
-
if (activeTab + 1 === childrenList.length) {
|
68
58
|
wizardNavigationRef.current?.scrollTo({
|
69
|
-
left:
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
59
|
+
left: Array.from({ length: activeTab })
|
60
|
+
.map((_, index) => {
|
61
|
+
return (
|
62
|
+
document.getElementById(`wizard-tab-${index}`)?.offsetWidth || 0
|
63
|
+
);
|
64
|
+
})
|
65
|
+
.reduce((acc, cur) => acc + cur, 0),
|
74
66
|
behavior: "smooth",
|
75
|
-
block: "nearest",
|
76
|
-
inline: "center",
|
77
67
|
});
|
78
68
|
}
|
79
|
-
};
|
69
|
+
}, [activeTab]);
|
80
70
|
|
81
71
|
return (
|
82
72
|
<div className="flex flex-col gap-8 h-full overflow-hidden">
|
@@ -210,7 +200,6 @@ export const Wizard: WizardComponent = ({
|
|
210
200
|
}`}
|
211
201
|
disabled={activeTab === 0}
|
212
202
|
onClick={() => {
|
213
|
-
handleOnPreviousClick();
|
214
203
|
onPreviousClick && onPreviousClick();
|
215
204
|
|
216
205
|
if (onChangeTab) {
|
@@ -254,7 +243,6 @@ export const Wizard: WizardComponent = ({
|
|
254
243
|
if (options?.customNextButton?.onClick) {
|
255
244
|
options.customNextButton.onClick();
|
256
245
|
} else {
|
257
|
-
handleOnNextClick();
|
258
246
|
onNextClick && onNextClick();
|
259
247
|
|
260
248
|
if (onChangeTab) {
|
@@ -1,17 +1,19 @@
|
|
1
1
|
"use client";
|
2
|
-
import React, { useState, useEffect } from "react";
|
2
|
+
import React, { useState, useEffect, useRef } from "react";
|
3
3
|
import { Tooltip } from "../../../components";
|
4
4
|
import { Icon } from "@iconify/react";
|
5
5
|
|
6
6
|
export interface TextareaProps
|
7
7
|
extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, "rows"> {
|
8
8
|
rows?: number;
|
9
|
-
maxRows?: number;
|
10
9
|
label?: string;
|
11
10
|
description?: string;
|
12
11
|
options?: {
|
13
12
|
width?: "full" | "fit";
|
14
13
|
height?: "short" | "medium" | "high";
|
14
|
+
autoGrow?: {
|
15
|
+
maxRows: number;
|
16
|
+
};
|
15
17
|
disableResize?: boolean;
|
16
18
|
hideInputDetail?: boolean;
|
17
19
|
};
|
@@ -19,13 +21,13 @@ export interface TextareaProps
|
|
19
21
|
|
20
22
|
export const Textarea: React.FC<TextareaProps> = ({
|
21
23
|
rows,
|
22
|
-
maxRows,
|
23
24
|
options,
|
24
25
|
label,
|
25
26
|
description,
|
26
27
|
...rest
|
27
28
|
}) => {
|
28
|
-
const
|
29
|
+
const mirrorInputRef = useRef<HTMLTextAreaElement>(null);
|
30
|
+
const [tempRows, setTempRows] = useState<number>(1);
|
29
31
|
const width = options?.width === "fit" ? "w-fit" : "w-full";
|
30
32
|
const height =
|
31
33
|
options?.height === "short"
|
@@ -35,36 +37,56 @@ export const Textarea: React.FC<TextareaProps> = ({
|
|
35
37
|
: "py-1.5";
|
36
38
|
|
37
39
|
useEffect(() => {
|
38
|
-
if (
|
39
|
-
if (
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
if (options?.autoGrow) {
|
41
|
+
if (
|
42
|
+
((mirrorInputRef.current?.scrollHeight || 0) -
|
43
|
+
(options?.height === "short"
|
44
|
+
? 4
|
45
|
+
: options?.height === "high"
|
46
|
+
? 8
|
47
|
+
: 12)) /
|
48
|
+
24 <=
|
49
|
+
options?.autoGrow.maxRows
|
50
|
+
) {
|
51
|
+
setTempRows(
|
52
|
+
((mirrorInputRef.current?.scrollHeight || 0) -
|
53
|
+
(options?.height === "short"
|
54
|
+
? 4
|
55
|
+
: options?.height === "high"
|
56
|
+
? 8
|
57
|
+
: 12)) /
|
58
|
+
24
|
59
|
+
);
|
43
60
|
} else {
|
44
|
-
setTempRows(
|
61
|
+
setTempRows(options?.autoGrow.maxRows);
|
45
62
|
}
|
46
63
|
}
|
47
|
-
}, [
|
64
|
+
}, [
|
65
|
+
options?.autoGrow,
|
66
|
+
mirrorInputRef.current?.scrollHeight,
|
67
|
+
rest.value,
|
68
|
+
options?.height,
|
69
|
+
]);
|
48
70
|
|
49
71
|
return (
|
50
|
-
<label className={`flex flex-col gap-2 ${width}`}>
|
72
|
+
<label className={`relative flex flex-col gap-2 ${width}`}>
|
51
73
|
{(label ||
|
52
74
|
(!options?.hideInputDetail && (rest.maxLength || description))) && (
|
53
75
|
<div className="flex items-center gap-2">
|
54
76
|
{label && (
|
55
77
|
<span
|
56
|
-
className={`text-sm
|
78
|
+
className={`select-none text-sm ${
|
57
79
|
rest.required &&
|
58
|
-
"after:
|
80
|
+
"after:ml-1 after:text-danger after:content-['*']"
|
59
81
|
}`}
|
60
82
|
>
|
61
83
|
{label}
|
62
84
|
</span>
|
63
85
|
)}
|
64
86
|
{!options?.hideInputDetail && (
|
65
|
-
<div className="flex-1
|
87
|
+
<div className="flex flex-1 items-center justify-end gap-2">
|
66
88
|
{rest.maxLength && (
|
67
|
-
<span className="text-sm
|
89
|
+
<span className="select-none text-sm">
|
68
90
|
{rest.value ? (rest.value as string).length : 0}/
|
69
91
|
{rest.maxLength}
|
70
92
|
</span>
|
@@ -82,12 +104,20 @@ export const Textarea: React.FC<TextareaProps> = ({
|
|
82
104
|
</div>
|
83
105
|
)}
|
84
106
|
<textarea
|
85
|
-
rows={tempRows}
|
86
|
-
className={`w-full
|
107
|
+
rows={options?.autoGrow ? tempRows : rows || 10}
|
108
|
+
className={`w-full rounded-md border border-default bg-secondary-bg px-4 placeholder:translate-x-0 placeholder:text-silent placeholder:duration-300 focus:border-primary-dark focus:shadow focus:shadow-primary focus:outline-none focus:ring-1 focus:ring-primary focus:placeholder:translate-x-1 disabled:bg-secondary-light disabled:text-disabled ${
|
87
109
|
options?.disableResize && "resize-none"
|
88
110
|
} ${height}`}
|
89
111
|
{...rest}
|
90
112
|
/>
|
113
|
+
<textarea
|
114
|
+
ref={mirrorInputRef}
|
115
|
+
rows={1}
|
116
|
+
className={`absolute w-full rounded-md border border-default bg-secondary-bg px-4 pointer-events-none opacity-0 placeholder:translate-x-0 placeholder:text-silent placeholder:duration-300 focus:border-primary-dark focus:shadow focus:shadow-primary focus:outline-none focus:ring-1 focus:ring-primary focus:placeholder:translate-x-1 disabled:bg-secondary-light disabled:text-disabled ${height}`}
|
117
|
+
readOnly
|
118
|
+
tabIndex={-1}
|
119
|
+
value={rest.value}
|
120
|
+
/>
|
91
121
|
</label>
|
92
122
|
);
|
93
123
|
};
|
@@ -202,7 +202,7 @@ export const Tooltip: React.FC<TooltipProps> = ({
|
|
202
202
|
createPortal(
|
203
203
|
<div
|
204
204
|
ref={tooltipRef}
|
205
|
-
className={`
|
205
|
+
className={`fixed z-50 max-w-dvw max-h-dvh overflow-hidden duration-200 transition-opacity ${
|
206
206
|
visible ? "opacity-100" : "opacity-0 pointer-events-none"
|
207
207
|
} ${options?.enableHover ? "" : "pointer-events-none"}`}
|
208
208
|
style={getTooltipPosition()}
|