next-helios-fe 1.4.2 → 1.4.4

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.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import React, { useState } from "react";
2
+ import React, { useState, useRef } from "react";
3
3
  import { Icon } from "@iconify/react";
4
4
  import { Window, type WindowProps } from "./window";
5
5
 
@@ -29,36 +29,73 @@ export const Wizard: WizardComponent = ({
29
29
  onPreviousClick,
30
30
  onNextClick,
31
31
  }) => {
32
+ const wizardNavigationRef = useRef<HTMLDivElement>(null);
32
33
  const childrenList = React.Children.toArray(children);
33
34
  const windowList = childrenList.filter((child) => {
34
35
  return (child as React.ReactElement).type === Wizard.Window;
35
36
  });
36
37
  const [activeTab, setActiveTab] = useState(0);
37
38
 
39
+ const handleOnPreviousClick = () => {
40
+ if (activeTab - 1 === 0) {
41
+ wizardNavigationRef.current?.scrollTo({
42
+ left: 0,
43
+ behavior: "smooth",
44
+ });
45
+ } else {
46
+ document.getElementById(`wizard-tab-${activeTab - 1}`)?.scrollIntoView({
47
+ behavior: "smooth",
48
+ block: "nearest",
49
+ inline: "center",
50
+ });
51
+ }
52
+ };
53
+
54
+ const handleOnNextClick = () => {
55
+ if (activeTab + 1 === childrenList.length) {
56
+ wizardNavigationRef.current?.scrollTo({
57
+ left: wizardNavigationRef.current.scrollWidth,
58
+ behavior: "smooth",
59
+ });
60
+ } else {
61
+ document.getElementById(`wizard-tab-${activeTab + 1}`)?.scrollIntoView({
62
+ behavior: "smooth",
63
+ block: "nearest",
64
+ inline: "center",
65
+ });
66
+ }
67
+ };
68
+
38
69
  return (
39
70
  <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">
71
+ <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">
72
+ <div
73
+ ref={wizardNavigationRef}
74
+ className="relative flex justify-between overflow-auto [&::-webkit-scrollbar]:hidden"
75
+ >
42
76
  {tabs?.slice(0, childrenList.length)?.map((tab, index) => {
43
77
  return (
44
78
  <div
45
79
  key={index}
46
- className={`group flex flex-col items-center gap-2 max-w-40 max-h-40 ${
80
+ id={`wizard-tab-${index}`}
81
+ className={`group flex flex-col items-center gap-2 min-w-32 max-w-40 px-2 ${
47
82
  activeTab >= index && "is-active"
48
83
  }`}
49
84
  >
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:text-primary"
54
- }`}
55
- disabled={options?.disableNavigationClick}
56
- onClick={() => {
57
- setActiveTab(index);
58
- }}
59
- >
60
- <Icon icon={tab.icon} className="text-2xl" />
61
- </button>
85
+ <div className="rounded-full bg-secondary-bg">
86
+ <button
87
+ 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 ${
88
+ !options?.disableNavigationClick &&
89
+ "hover:border-primary hover:bg-primary-transparent hover:text-primary"
90
+ }`}
91
+ disabled={options?.disableNavigationClick}
92
+ onClick={() => {
93
+ setActiveTab(index);
94
+ }}
95
+ >
96
+ <Icon icon={tab.icon} className="text-2xl" />
97
+ </button>
98
+ </div>
62
99
  <div className="flex flex-col items-center text-center">
63
100
  <h1 className="text-sm font-medium group-[.is-active]:text-primary">
64
101
  {tab.title}
@@ -84,6 +121,7 @@ export const Wizard: WizardComponent = ({
84
121
  disabled={activeTab === 0}
85
122
  onClick={() => {
86
123
  setActiveTab((prev) => prev - 1);
124
+ handleOnPreviousClick();
87
125
  onPreviousClick && onPreviousClick();
88
126
  }}
89
127
  >
@@ -96,6 +134,7 @@ export const Wizard: WizardComponent = ({
96
134
  disabled={activeTab === childrenList.length - 1}
97
135
  onClick={() => {
98
136
  setActiveTab((prev) => prev + 1);
137
+ handleOnNextClick();
99
138
  onNextClick && onNextClick();
100
139
  }}
101
140
  >