next-helios-fe 1.3.6 → 1.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-helios-fe",
3
- "version": "1.3.6",
3
+ "version": "1.4.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -31,6 +31,7 @@ export const Modal: React.FC<ModalProps> = ({
31
31
  useEffect(() => {
32
32
  if (!options?.disableClose) {
33
33
  document.addEventListener("keydown", (e) => {
34
+ e.preventDefault();
34
35
  if (e.key === "Escape") {
35
36
  onClose && onClose();
36
37
  }
@@ -21,10 +21,10 @@ interface TabComponent extends React.FC<TabProps> {
21
21
 
22
22
  export const Tab: TabComponent = ({ children, tabs, options }) => {
23
23
  const childrenList = React.Children.toArray(children);
24
- const [activeTab, setActiveTab] = useState(0);
25
24
  const windowList = childrenList.filter((child) => {
26
25
  return (child as React.ReactElement).type === Tab.Window;
27
26
  });
27
+ const [activeTab, setActiveTab] = useState(0);
28
28
 
29
29
  return (
30
30
  <div
@@ -36,7 +36,7 @@ export const Tab: TabComponent = ({ children, tabs, options }) => {
36
36
  >
37
37
  {options?.variant !== "horizontal" ? (
38
38
  <div className="flex overflow-auto [&::-webkit-scrollbar]:hidden">
39
- {tabs.slice(0, childrenList.length).map((tab, index) => {
39
+ {tabs?.slice(0, childrenList?.length).map((tab, index) => {
40
40
  return (
41
41
  <button
42
42
  key={index}
@@ -0,0 +1,105 @@
1
+ "use client";
2
+ import React, { useState } from "react";
3
+ import { Icon } from "@iconify/react";
4
+ import { Window, type WindowProps } from "./window";
5
+
6
+ interface WizardProps {
7
+ children: React.ReactNode;
8
+ tabs: {
9
+ title: string;
10
+ subTitle: string;
11
+ icon: string;
12
+ }[];
13
+ options?: {
14
+ border?: boolean;
15
+ };
16
+ onPreviousClick?: () => void;
17
+ onNextClick?: () => void;
18
+ }
19
+
20
+ interface WizardComponent extends React.FC<WizardProps> {
21
+ Window: React.FC<WindowProps>;
22
+ }
23
+
24
+ export const Wizard: WizardComponent = ({
25
+ children,
26
+ tabs,
27
+ options,
28
+ onPreviousClick,
29
+ onNextClick,
30
+ }) => {
31
+ const childrenList = React.Children.toArray(children);
32
+ const windowList = childrenList.filter((child) => {
33
+ return (child as React.ReactElement).type === Wizard.Window;
34
+ });
35
+ const [activeTab, setActiveTab] = useState(0);
36
+
37
+ return (
38
+ <div className="flex flex-col gap-8 h-full overflow-hidden">
39
+ <div className="space-x-8 relative before:absolute before:inset-0 before:mt-4 before:-translate-y-px md: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">
40
+ <div className="relative flex justify-between">
41
+ {tabs?.slice(0, childrenList.length)?.map((tab, index) => {
42
+ return (
43
+ <div
44
+ key={index}
45
+ className={`group flex flex-col items-center gap-2 max-w-40 max-h-40 ${
46
+ activeTab >= index && "is-active"
47
+ }`}
48
+ >
49
+ <button
50
+ className="flex justify-center items-center w-12 h-12 shadow border border-white rounded-full bg-secondary-light duration-300 group-[.is-active]:bg-primary group-[.is-active]:text-white"
51
+ onClick={() => {
52
+ setActiveTab(index);
53
+ }}
54
+ >
55
+ <Icon icon={tab.icon} className="text-2xl" />
56
+ </button>
57
+ <div className="flex flex-col items-center text-center">
58
+ <h1 className="text-sm font-medium group-[.is-active]:text-primary">
59
+ {tab.title}
60
+ </h1>
61
+ <p className="text-xs">{tab.subTitle}</p>
62
+ </div>
63
+ </div>
64
+ );
65
+ })}
66
+ </div>
67
+ </div>
68
+ <div
69
+ className={`flex-1 overflow-auto ${
70
+ options?.border && "border rounded-md px-4 py-6"
71
+ }`}
72
+ >
73
+ {windowList[activeTab]}
74
+ </div>
75
+ <div className="flex justify-between">
76
+ <button
77
+ type="button"
78
+ className="flex items-center gap-2 text-primary hover:text-primary-dark disabled:text-slate-400"
79
+ disabled={activeTab === 0}
80
+ onClick={() => {
81
+ setActiveTab((prev) => prev - 1);
82
+ onPreviousClick && onPreviousClick();
83
+ }}
84
+ >
85
+ <Icon icon="gravity-ui:chevron-left" className="text-xl" />
86
+ Previous
87
+ </button>
88
+ <button
89
+ type="button"
90
+ className="flex items-center gap-2 text-primary hover:text-primary-dark disabled:text-slate-400"
91
+ disabled={activeTab === childrenList.length - 1}
92
+ onClick={() => {
93
+ setActiveTab((prev) => prev + 1);
94
+ onNextClick && onNextClick();
95
+ }}
96
+ >
97
+ Next
98
+ <Icon icon="gravity-ui:chevron-right" className="text-xl" />
99
+ </button>
100
+ </div>
101
+ </div>
102
+ );
103
+ };
104
+
105
+ Wizard.Window = Window;
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import React from "react";
3
+
4
+ export interface WindowProps {
5
+ children: React.ReactNode;
6
+ }
7
+
8
+ export const Window: React.FC<WindowProps> = ({ children }) => {
9
+ return children;
10
+ };
@@ -15,7 +15,7 @@ interface DialogProps {
15
15
  timeout?: 3000 | 5000 | 7000 | 10000;
16
16
  };
17
17
  open: boolean;
18
- onClose: (open: boolean) => void;
18
+ onClose: () => void;
19
19
  }
20
20
 
21
21
  export const Dialog: React.FC<DialogProps> = ({
@@ -50,7 +50,7 @@ export const Dialog: React.FC<DialogProps> = ({
50
50
  useEffect(() => {
51
51
  if (options?.timeout) {
52
52
  const timeout = setTimeout(() => {
53
- onClose(false);
53
+ onClose && onClose();
54
54
  }, options.timeout);
55
55
  return () => clearTimeout(timeout);
56
56
  }
@@ -93,7 +93,7 @@ export const Dialog: React.FC<DialogProps> = ({
93
93
  type="button"
94
94
  className="text-primary hover:text-primary-dark hover:underline"
95
95
  onClick={() => {
96
- onClose && onClose(false);
96
+ onClose && onClose();
97
97
  }}
98
98
  >
99
99
  Close
@@ -8,6 +8,7 @@
8
8
  // export { Mfa } from "./security/mfa";
9
9
  // export { Recaptcha } from "./security/recaptcha";
10
10
  export { Tab } from "./content-container/tab";
11
+ export { Wizard } from "./content-container/wizard";
11
12
  export { Dialog } from "./dialog";
12
13
  export { Modal } from "./content-container/modal";
13
14
  export { Drawer } from "./content-container/drawer";