next-helios-fe 1.8.49 → 1.8.50
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,5 +1,5 @@
|
|
1
1
|
"use client";
|
2
|
-
import React, { useState,
|
2
|
+
import React, { useState, useRef } from "react";
|
3
3
|
import { Icon } from "@iconify/react";
|
4
4
|
import { Window, type WindowProps } from "./window";
|
5
5
|
|
@@ -11,9 +11,18 @@ interface WizardProps {
|
|
11
11
|
icon: string;
|
12
12
|
}[];
|
13
13
|
options?: {
|
14
|
+
variant?: "basic" | "modern";
|
14
15
|
border?: boolean;
|
15
16
|
disableNavigationClick?: boolean;
|
16
17
|
hideNavigationOnFirstWindow?: boolean;
|
18
|
+
customNextButton?: {
|
19
|
+
type?: "button" | "submit";
|
20
|
+
label?: string;
|
21
|
+
icon?: string;
|
22
|
+
form?: string;
|
23
|
+
disabled?: boolean;
|
24
|
+
onClick?: () => void;
|
25
|
+
};
|
17
26
|
};
|
18
27
|
onPreviousClick?: () => void;
|
19
28
|
onNextClick?: () => void;
|
@@ -39,15 +48,6 @@ export const Wizard: WizardComponent = ({
|
|
39
48
|
});
|
40
49
|
const [activeTab, setActiveTab] = useState(0);
|
41
50
|
|
42
|
-
useEffect(() => {
|
43
|
-
if (onChangeTab) {
|
44
|
-
onChangeTab({
|
45
|
-
index: activeTab,
|
46
|
-
title: tabs[activeTab].title,
|
47
|
-
});
|
48
|
-
}
|
49
|
-
}, [tabs, activeTab]);
|
50
|
-
|
51
51
|
const handleOnPreviousClick = () => {
|
52
52
|
if (activeTab - 1 === 0) {
|
53
53
|
wizardNavigationRef.current?.scrollTo({
|
@@ -80,53 +80,118 @@ export const Wizard: WizardComponent = ({
|
|
80
80
|
|
81
81
|
return (
|
82
82
|
<div className="flex flex-col gap-8 h-full overflow-hidden">
|
83
|
-
{
|
84
|
-
<div className="
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
83
|
+
{options?.variant === "modern" ? (
|
84
|
+
<div className="flex justify-between items-center gap-8 whitespace-nowrap overflow-x-auto [&::-webkit-scrollbar]:hidden">
|
85
|
+
{tabs?.map((tab, index) => {
|
86
|
+
return (
|
87
|
+
<>
|
88
|
+
<button
|
89
|
+
key={index}
|
90
|
+
type="button"
|
91
|
+
className={`group flex items-center gap-4 ${
|
92
|
+
activeTab > index && "is-hopped"
|
93
|
+
} ${activeTab === index && "is-active"}`}
|
94
|
+
disabled={options?.disableNavigationClick}
|
95
|
+
onClick={() => {
|
96
|
+
setActiveTab(index);
|
97
|
+
|
98
|
+
if (onChangeTab) {
|
99
|
+
onChangeTab({
|
100
|
+
index: index,
|
101
|
+
title: tabs[index].title,
|
102
|
+
});
|
103
|
+
}
|
104
|
+
}}
|
105
|
+
>
|
106
|
+
<div
|
107
|
+
className={`flex justify-center items-center w-10 h-10 shadow border border-white rounded-md bg-secondary-light duration-300 group-[.is-hopped]:border-primary group-[.is-hopped]:bg-primary-transparent group-[.is-hopped]:text-primary group-[.is-active]:bg-primary group-[.is-active]:text-white ${
|
108
|
+
!options?.disableNavigationClick &&
|
109
|
+
"group-hover:border-primary group-hover:bg-primary-transparent group-hover:text-primary"
|
110
|
+
}`}
|
111
|
+
>
|
112
|
+
<Icon
|
113
|
+
icon={tab.icon}
|
114
|
+
className="text-2xl pointer-events-none"
|
115
|
+
/>
|
116
|
+
</div>
|
117
|
+
<div className="flex flex-col items-start">
|
118
|
+
<h1 className="text-sm font-medium group-[.is-hopped]:text-primary group-[.is-active]:text-primary">
|
119
|
+
{tab.title}
|
120
|
+
</h1>
|
121
|
+
<p className="text-xs text-disabled">{tab.subTitle}</p>
|
122
|
+
</div>
|
123
|
+
</button>
|
124
|
+
{index !== tabs.length - 1 && (
|
125
|
+
<div>
|
126
|
+
<Icon
|
127
|
+
icon="gravity-ui:chevron-right"
|
128
|
+
className="text-xl pointer-events-none text-disabled"
|
129
|
+
/>
|
130
|
+
</div>
|
131
|
+
)}
|
132
|
+
</>
|
133
|
+
);
|
134
|
+
})}
|
135
|
+
</div>
|
136
|
+
) : (
|
137
|
+
(!options?.hideNavigationOnFirstWindow || activeTab !== 0) && (
|
138
|
+
<div className="space-x-8 relative before:absolute before:inset-0 before:mt-6 md:before:translate-y-0 before:w-full before:h-0.5 before:bg-gradient-to-r before:from-transparent before:via-primary before:to-transparent">
|
139
|
+
<div
|
140
|
+
ref={wizardNavigationRef}
|
141
|
+
className="relative flex justify-between overflow-x-auto [&::-webkit-scrollbar]:hidden"
|
142
|
+
>
|
143
|
+
{tabs?.map((tab, index) => {
|
144
|
+
{
|
145
|
+
if (!options?.hideNavigationOnFirstWindow || index !== 0) {
|
146
|
+
return (
|
147
|
+
<div
|
148
|
+
key={index}
|
149
|
+
id={`wizard-tab-${index}`}
|
150
|
+
className={`group flex flex-col items-center gap-2 min-w-32 max-w-40 px-2 ${
|
151
|
+
activeTab > index && "is-hopped"
|
152
|
+
} ${activeTab === index && "is-active"}`}
|
153
|
+
>
|
154
|
+
<div className="rounded-full bg-secondary-bg">
|
155
|
+
<button
|
156
|
+
type="button"
|
157
|
+
className={`flex justify-center items-center w-12 h-12 shadow border border-white rounded-full bg-secondary-light duration-300 group-[.is-hopped]:border-primary group-[.is-hopped]:bg-primary-transparent group-[.is-hopped]:text-primary group-[.is-active]:bg-primary group-[.is-active]:text-white ${
|
158
|
+
!options?.disableNavigationClick &&
|
159
|
+
"hover:border-primary hover:bg-primary-transparent hover:text-primary"
|
160
|
+
}`}
|
161
|
+
disabled={options?.disableNavigationClick}
|
162
|
+
onClick={() => {
|
163
|
+
setActiveTab(index);
|
164
|
+
|
165
|
+
if (onChangeTab) {
|
166
|
+
onChangeTab({
|
167
|
+
index: index,
|
168
|
+
title: tabs[index].title,
|
169
|
+
});
|
170
|
+
}
|
171
|
+
}}
|
172
|
+
>
|
173
|
+
<Icon
|
174
|
+
icon={tab.icon}
|
175
|
+
className="text-2xl pointer-events-none"
|
176
|
+
/>
|
177
|
+
</button>
|
178
|
+
</div>
|
179
|
+
<div className="flex flex-col items-center text-center">
|
180
|
+
<h1 className="text-sm font-medium group-[.is-hopped]:text-primary group-[.is-active]:text-primary">
|
181
|
+
{tab.title}
|
182
|
+
</h1>
|
183
|
+
<p className="text-xs text-disabled">
|
184
|
+
{tab.subTitle}
|
185
|
+
</p>
|
186
|
+
</div>
|
122
187
|
</div>
|
123
|
-
|
124
|
-
|
188
|
+
);
|
189
|
+
}
|
125
190
|
}
|
126
|
-
}
|
127
|
-
|
191
|
+
})}
|
192
|
+
</div>
|
128
193
|
</div>
|
129
|
-
|
194
|
+
)
|
130
195
|
)}
|
131
196
|
<div
|
132
197
|
className={`flex-1 overflow-auto ${
|
@@ -138,29 +203,79 @@ export const Wizard: WizardComponent = ({
|
|
138
203
|
<div className="flex justify-between">
|
139
204
|
<button
|
140
205
|
type="button"
|
141
|
-
className=
|
206
|
+
className={`flex items-center gap-2 select-none ${
|
207
|
+
options?.variant === "modern"
|
208
|
+
? "px-3 py-1.5 rounded-md bg-primary shadow-sm shadow-primary text-white hover:bg-primary-dark disabled:bg-secondary-dark disabled:shadow-secondary-dark"
|
209
|
+
: "text-primary hover:text-primary-dark disabled:text-disabled"
|
210
|
+
}`}
|
142
211
|
disabled={activeTab === 0}
|
143
212
|
onClick={() => {
|
144
|
-
setActiveTab((prev) => prev - 1);
|
145
213
|
handleOnPreviousClick();
|
146
214
|
onPreviousClick && onPreviousClick();
|
215
|
+
|
216
|
+
if (onChangeTab) {
|
217
|
+
setActiveTab((prev) => {
|
218
|
+
onChangeTab({
|
219
|
+
index: prev - 1,
|
220
|
+
title: tabs[prev - 1].title,
|
221
|
+
});
|
222
|
+
return prev - 1;
|
223
|
+
});
|
224
|
+
}
|
147
225
|
}}
|
148
226
|
>
|
149
|
-
<Icon
|
227
|
+
<Icon
|
228
|
+
icon={
|
229
|
+
options?.variant === "modern"
|
230
|
+
? "mi:arrow-left"
|
231
|
+
: "gravity-ui:chevron-left"
|
232
|
+
}
|
233
|
+
className="text-xl"
|
234
|
+
/>
|
150
235
|
Previous
|
151
236
|
</button>
|
152
237
|
<button
|
153
|
-
type="button"
|
154
|
-
className=
|
155
|
-
|
238
|
+
type={options?.customNextButton?.type ?? "button"}
|
239
|
+
className={`flex items-center gap-2 select-none ${
|
240
|
+
options?.variant === "modern"
|
241
|
+
? "px-3 py-1.5 rounded-md bg-primary shadow-sm shadow-primary text-white hover:bg-primary-dark disabled:bg-secondary-dark disabled:shadow-secondary-dark"
|
242
|
+
: "text-primary hover:text-primary-dark disabled:text-disabled"
|
243
|
+
}`}
|
244
|
+
form={options?.customNextButton?.form ?? ""}
|
245
|
+
disabled={
|
246
|
+
options?.customNextButton?.disabled ??
|
247
|
+
activeTab === childrenList.length - 1
|
248
|
+
}
|
156
249
|
onClick={() => {
|
157
|
-
|
158
|
-
|
159
|
-
|
250
|
+
if (options?.customNextButton?.onClick) {
|
251
|
+
options.customNextButton.onClick();
|
252
|
+
} else {
|
253
|
+
handleOnNextClick();
|
254
|
+
onNextClick && onNextClick();
|
255
|
+
|
256
|
+
if (onChangeTab) {
|
257
|
+
setActiveTab((prev) => {
|
258
|
+
onChangeTab({
|
259
|
+
index: prev + 1,
|
260
|
+
title: tabs[prev + 1].title,
|
261
|
+
});
|
262
|
+
return prev + 1;
|
263
|
+
});
|
264
|
+
}
|
265
|
+
}
|
160
266
|
}}
|
161
267
|
>
|
162
|
-
Next
|
163
|
-
|
268
|
+
{options?.customNextButton?.label ?? "Next"}
|
269
|
+
{!options?.customNextButton?.label && (
|
270
|
+
<Icon
|
271
|
+
icon={
|
272
|
+
options?.variant === "modern"
|
273
|
+
? "mi:arrow-right"
|
274
|
+
: "gravity-ui:chevron-right"
|
275
|
+
}
|
276
|
+
className="text-xl"
|
277
|
+
/>
|
278
|
+
)}
|
164
279
|
</button>
|
165
280
|
</div>
|
166
281
|
</div>
|