next-helios-fe 1.3.7 → 1.4.1

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.7",
3
+ "version": "1.4.1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -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,110 @@
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
+ disableNavigationClick?: boolean;
16
+ };
17
+ onPreviousClick?: () => void;
18
+ onNextClick?: () => void;
19
+ }
20
+
21
+ interface WizardComponent extends React.FC<WizardProps> {
22
+ Window: React.FC<WindowProps>;
23
+ }
24
+
25
+ export const Wizard: WizardComponent = ({
26
+ children,
27
+ tabs,
28
+ options,
29
+ onPreviousClick,
30
+ onNextClick,
31
+ }) => {
32
+ const childrenList = React.Children.toArray(children);
33
+ const windowList = childrenList.filter((child) => {
34
+ return (child as React.ReactElement).type === Wizard.Window;
35
+ });
36
+ const [activeTab, setActiveTab] = useState(0);
37
+
38
+ return (
39
+ <div className="flex flex-col gap-8 h-full overflow-hidden">
40
+ <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">
41
+ <div className="relative flex justify-between">
42
+ {tabs?.slice(0, childrenList.length)?.map((tab, index) => {
43
+ return (
44
+ <div
45
+ key={index}
46
+ className={`group flex flex-col items-center gap-2 max-w-40 max-h-40 ${
47
+ activeTab >= index && "is-active"
48
+ }`}
49
+ >
50
+ <button
51
+ 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 ${
52
+ !options?.disableNavigationClick &&
53
+ "hover:bg-primary-transparent hover:text-primary"
54
+ }`}
55
+ disabled={options?.disableNavigationClick}
56
+ onClick={() => {
57
+ setActiveTab(index);
58
+ }}
59
+ >
60
+ <Icon icon={tab.icon} className="text-2xl" />
61
+ </button>
62
+ <div className="flex flex-col items-center text-center">
63
+ <h1 className="text-sm font-medium group-[.is-active]:text-primary">
64
+ {tab.title}
65
+ </h1>
66
+ <p className="text-xs">{tab.subTitle}</p>
67
+ </div>
68
+ </div>
69
+ );
70
+ })}
71
+ </div>
72
+ </div>
73
+ <div
74
+ className={`flex-1 overflow-auto ${
75
+ options?.border && "border rounded-md px-4 py-6"
76
+ }`}
77
+ >
78
+ {windowList[activeTab]}
79
+ </div>
80
+ <div className="flex justify-between">
81
+ <button
82
+ type="button"
83
+ className="flex items-center gap-2 text-primary hover:text-primary-dark disabled:text-slate-400"
84
+ disabled={activeTab === 0}
85
+ onClick={() => {
86
+ setActiveTab((prev) => prev - 1);
87
+ onPreviousClick && onPreviousClick();
88
+ }}
89
+ >
90
+ <Icon icon="gravity-ui:chevron-left" className="text-xl" />
91
+ Previous
92
+ </button>
93
+ <button
94
+ type="button"
95
+ className="flex items-center gap-2 text-primary hover:text-primary-dark disabled:text-slate-400"
96
+ disabled={activeTab === childrenList.length - 1}
97
+ onClick={() => {
98
+ setActiveTab((prev) => prev + 1);
99
+ onNextClick && onNextClick();
100
+ }}
101
+ >
102
+ Next
103
+ <Icon icon="gravity-ui:chevron-right" className="text-xl" />
104
+ </button>
105
+ </div>
106
+ </div>
107
+ );
108
+ };
109
+
110
+ 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";
@@ -10,11 +10,11 @@ export interface ItemProps {
10
10
  export const Item: React.FC<ItemProps> = ({ children, icon, isActive }) => {
11
11
  return (
12
12
  <div
13
- className={`relative flex items-center justify-between md:justify-normal md:odd:flex-row-reverse group ${
13
+ className={`group relative flex items-center justify-between md:justify-normal md:odd:flex-row-reverse ${
14
14
  isActive && "is-active"
15
15
  }`}
16
16
  >
17
- <div className="flex items-center justify-center w-8 h-8 rounded-full border border-white bg-slate-300 group-[.is-active]:bg-primary group-[.is-active]:text-white shadow shrink-0 md:order-1 md:group-odd:-translate-x-1/2 md:group-even:translate-x-1/2">
17
+ <div className="flex items-center justify-center w-8 h-8 rounded-full border border-white bg-secondary-light group-[.is-active]:bg-primary group-[.is-active]:text-white shadow shrink-0 md:order-1 md:group-odd:-translate-x-1/2 md:group-even:translate-x-1/2">
18
18
  {icon}
19
19
  </div>
20
20
  <div className="w-[calc(100%-4rem)] md:w-[calc(50%-2rem)]">