next-helios-fe 1.8.107 → 1.8.109
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/dist/components/content-container/tab/index.d.ts +6 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/components/content-container/tab/index.tsx +30 -16
- package/src/components/form/input/date.tsx +1 -1
- package/src/components/form/other/multipleSelect.tsx +22 -9
- package/src/components/form/other/select.tsx +7 -3
package/package.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
"use client";
|
2
|
-
import React, { useState } from "react";
|
2
|
+
import React, { useState, useEffect } from "react";
|
3
3
|
import { Icon } from "@iconify/react";
|
4
4
|
import { Window, type WindowProps } from "./window";
|
5
5
|
|
@@ -15,8 +15,9 @@ interface TabProps {
|
|
15
15
|
disablePadding?: boolean;
|
16
16
|
};
|
17
17
|
cornerComponent?: React.ReactNode;
|
18
|
-
|
19
|
-
|
18
|
+
activeTab?: number;
|
19
|
+
onChangeTab?: (tab: { index: number; title: string }) => void;
|
20
|
+
onCloseTab?: (tab: number) => void;
|
20
21
|
}
|
21
22
|
|
22
23
|
interface TabComponent extends React.FC<TabProps> {
|
@@ -28,6 +29,7 @@ export const Tab: TabComponent = ({
|
|
28
29
|
tabs,
|
29
30
|
options,
|
30
31
|
cornerComponent,
|
32
|
+
activeTab,
|
31
33
|
onChangeTab,
|
32
34
|
onCloseTab,
|
33
35
|
}) => {
|
@@ -35,7 +37,13 @@ export const Tab: TabComponent = ({
|
|
35
37
|
const windowList = childrenList.filter((child) => {
|
36
38
|
return (child as React.ReactElement).type === Tab.Window;
|
37
39
|
});
|
38
|
-
const [
|
40
|
+
const [tempActiveTab, setTempActiveTab] = useState(0);
|
41
|
+
|
42
|
+
useEffect(() => {
|
43
|
+
if (activeTab !== undefined) {
|
44
|
+
setTempActiveTab(activeTab);
|
45
|
+
}
|
46
|
+
}, [activeTab]);
|
39
47
|
|
40
48
|
return (
|
41
49
|
<div
|
@@ -54,7 +62,7 @@ export const Tab: TabComponent = ({
|
|
54
62
|
<button
|
55
63
|
type="button"
|
56
64
|
className={`flex select-none items-center gap-2 whitespace-nowrap border-b-2 pb-1.5 pt-2 duration-300 ${
|
57
|
-
|
65
|
+
tempActiveTab === index
|
58
66
|
? "border-primary text-primary"
|
59
67
|
: "border-transparent hover:border-primary-transparent hover:text-primary"
|
60
68
|
} ${
|
@@ -63,7 +71,9 @@ export const Tab: TabComponent = ({
|
|
63
71
|
: "px-6"
|
64
72
|
}`}
|
65
73
|
onClick={() => {
|
66
|
-
|
74
|
+
if (activeTab === undefined) {
|
75
|
+
setTempActiveTab(index);
|
76
|
+
}
|
67
77
|
|
68
78
|
if (onChangeTab) {
|
69
79
|
onChangeTab({
|
@@ -81,13 +91,15 @@ export const Tab: TabComponent = ({
|
|
81
91
|
type="button"
|
82
92
|
className="absolute right-2 rounded-full p-0.5 hover:text-warning"
|
83
93
|
onClick={() => {
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
? index
|
88
|
-
|
89
|
-
|
90
|
-
|
94
|
+
if (activeTab === undefined) {
|
95
|
+
setTempActiveTab(
|
96
|
+
tempActiveTab === index
|
97
|
+
? index === 0
|
98
|
+
? index
|
99
|
+
: index - 1
|
100
|
+
: tempActiveTab
|
101
|
+
);
|
102
|
+
}
|
91
103
|
|
92
104
|
onCloseTab(index);
|
93
105
|
}}
|
@@ -114,12 +126,14 @@ export const Tab: TabComponent = ({
|
|
114
126
|
key={index}
|
115
127
|
type="button"
|
116
128
|
className={`flex select-none items-center gap-2 whitespace-nowrap border-b-2 border-r-0 px-6 pb-1.5 pt-2 text-left duration-300 lg:border-b-0 lg:border-r-2 ${
|
117
|
-
|
129
|
+
tempActiveTab === index
|
118
130
|
? "border-primary text-primary"
|
119
131
|
: "border-transparent hover:border-primary-transparent hover:text-primary"
|
120
132
|
}`}
|
121
133
|
onClick={() => {
|
122
|
-
|
134
|
+
if (activeTab === undefined) {
|
135
|
+
setTempActiveTab(index);
|
136
|
+
}
|
123
137
|
|
124
138
|
if (onChangeTab) {
|
125
139
|
onChangeTab({
|
@@ -149,7 +163,7 @@ export const Tab: TabComponent = ({
|
|
149
163
|
: ""
|
150
164
|
}`}
|
151
165
|
>
|
152
|
-
{windowList[
|
166
|
+
{windowList[tempActiveTab]}
|
153
167
|
</div>
|
154
168
|
</div>
|
155
169
|
);
|
@@ -115,7 +115,7 @@ export const Date: React.FC<DateProps> = ({
|
|
115
115
|
{!options?.buttonOnly && (
|
116
116
|
<input
|
117
117
|
type="text"
|
118
|
-
className={`w-full ps-4 pe-14 border-default border rounded-md bg-secondary-bg placeholder:duration-300 placeholder:translate-x-0 focus:placeholder:translate-x-1 placeholder:text-silent focus:outline-none focus:ring-1 focus:ring-primary focus:shadow focus:shadow-primary focus:border-primary-dark disabled:bg-secondary-light disabled:text-disabled ${height}`}
|
118
|
+
className={`w-full ps-4 pe-14 border-default border rounded-md bg-secondary-bg cursor-default placeholder:duration-300 placeholder:translate-x-0 focus:placeholder:translate-x-1 placeholder:text-silent focus:outline-none focus:ring-1 focus:ring-primary focus:shadow focus:shadow-primary focus:border-primary-dark disabled:bg-secondary-light disabled:text-disabled ${height}`}
|
119
119
|
disabled={rest.disabled}
|
120
120
|
readOnly
|
121
121
|
value={
|
@@ -62,9 +62,10 @@ export const MultipleSelect: React.FC<MultipleSelectProps> = ({
|
|
62
62
|
onRemove,
|
63
63
|
...rest
|
64
64
|
}) => {
|
65
|
+
const componentRef = useRef<HTMLDivElement>(null);
|
65
66
|
const itemContainerRef = useRef<HTMLDivElement>(null);
|
66
67
|
const inputRef = useRef<HTMLInputElement>(null);
|
67
|
-
const
|
68
|
+
const dropdownTriggerRef = useRef<HTMLButtonElement>(null);
|
68
69
|
const [tempValue, setTempValue] = useState<string[]>([]);
|
69
70
|
const [openDropdown, setOpenDropdown] = useState(false);
|
70
71
|
const [inputHeight, setInputHeight] = useState<number>(0);
|
@@ -78,11 +79,16 @@ export const MultipleSelect: React.FC<MultipleSelectProps> = ({
|
|
78
79
|
: "py-[5px]";
|
79
80
|
|
80
81
|
useEffect(() => {
|
81
|
-
|
82
|
-
if (
|
82
|
+
function handleClickOutside(event: MouseEvent) {
|
83
|
+
if (
|
84
|
+
componentRef.current &&
|
85
|
+
!componentRef.current.contains(event.target as Node)
|
86
|
+
) {
|
83
87
|
setOpenDropdown(false);
|
84
88
|
}
|
85
|
-
}
|
89
|
+
}
|
90
|
+
|
91
|
+
document.addEventListener("mousedown", handleClickOutside);
|
86
92
|
|
87
93
|
const observer = new ResizeObserver((entries) => {
|
88
94
|
for (let entry of entries) {
|
@@ -92,7 +98,10 @@ export const MultipleSelect: React.FC<MultipleSelectProps> = ({
|
|
92
98
|
|
93
99
|
observer.observe(itemContainerRef.current!);
|
94
100
|
|
95
|
-
return () =>
|
101
|
+
return () => {
|
102
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
103
|
+
observer.disconnect();
|
104
|
+
};
|
96
105
|
}, []);
|
97
106
|
|
98
107
|
useEffect(() => {
|
@@ -117,7 +126,7 @@ export const MultipleSelect: React.FC<MultipleSelectProps> = ({
|
|
117
126
|
|
118
127
|
return (
|
119
128
|
<div className="relative">
|
120
|
-
<div className="flex flex-row-reverse items-end">
|
129
|
+
<div ref={componentRef} className="flex flex-row-reverse items-end">
|
121
130
|
<label className={`flex flex-col gap-2 ${width}`}>
|
122
131
|
{(label || description) && (
|
123
132
|
<div className="flex justify-between items-center gap-2">
|
@@ -146,7 +155,7 @@ export const MultipleSelect: React.FC<MultipleSelectProps> = ({
|
|
146
155
|
<input
|
147
156
|
ref={inputRef}
|
148
157
|
type="text"
|
149
|
-
className="w-full ps-4 pe-14 border border-default rounded-md bg-secondary-bg text-transparent cursor-pointer caret-transparent duration-150 placeholder:duration-300 placeholder:text-silent focus:placeholder:translate-x-1 focus:outline-none focus:ring-1 focus:ring-primary focus:shadow focus:shadow-primary focus:border-primary-dark disabled:bg-secondary-light disabled:
|
158
|
+
className="w-full ps-4 pe-14 border border-default rounded-md bg-secondary-bg text-transparent cursor-pointer caret-transparent duration-150 placeholder:duration-300 placeholder:text-silent focus:placeholder:translate-x-1 focus:outline-none focus:ring-1 focus:ring-primary focus:shadow focus:shadow-primary focus:border-primary-dark disabled:bg-secondary-light disabled:cursor-default"
|
150
159
|
style={{
|
151
160
|
height:
|
152
161
|
tempValue.length !== 0
|
@@ -170,7 +179,7 @@ export const MultipleSelect: React.FC<MultipleSelectProps> = ({
|
|
170
179
|
onClick={(e) => {
|
171
180
|
e.preventDefault();
|
172
181
|
setOpenDropdown(true);
|
173
|
-
|
182
|
+
dropdownTriggerRef.current?.click();
|
174
183
|
setDropdownWidth(
|
175
184
|
inputRef?.current?.getBoundingClientRect()?.width || 0
|
176
185
|
);
|
@@ -198,7 +207,7 @@ export const MultipleSelect: React.FC<MultipleSelectProps> = ({
|
|
198
207
|
trigger={
|
199
208
|
<button
|
200
209
|
type="button"
|
201
|
-
ref={
|
210
|
+
ref={dropdownTriggerRef}
|
202
211
|
className="w-0"
|
203
212
|
style={{
|
204
213
|
height:
|
@@ -229,6 +238,8 @@ export const MultipleSelect: React.FC<MultipleSelectProps> = ({
|
|
229
238
|
e.preventDefault();
|
230
239
|
inputRef.current?.focus();
|
231
240
|
setOpenDropdown(false);
|
241
|
+
} else if (e.key === "Tab") {
|
242
|
+
setOpenDropdown(false);
|
232
243
|
}
|
233
244
|
}}
|
234
245
|
>
|
@@ -267,6 +278,8 @@ export const MultipleSelect: React.FC<MultipleSelectProps> = ({
|
|
267
278
|
e.preventDefault();
|
268
279
|
inputRef.current?.focus();
|
269
280
|
setOpenDropdown(false);
|
281
|
+
} else if (e.key === "Tab") {
|
282
|
+
setOpenDropdown(false);
|
270
283
|
}
|
271
284
|
}}
|
272
285
|
>
|
@@ -35,7 +35,7 @@ export const Select: React.FC<SelectProps> = ({
|
|
35
35
|
const [openDropdown, setOpenDropdown] = useState(false);
|
36
36
|
const [dropdownWidth, setDropdownWidth] = useState<number>(0);
|
37
37
|
const inputRef = useRef<HTMLInputElement>(null);
|
38
|
-
const
|
38
|
+
const dropdownTriggerRef = useRef<HTMLButtonElement>(null);
|
39
39
|
const width = options?.width === "fit" ? "w-fit" : "w-full";
|
40
40
|
const height =
|
41
41
|
options?.height === "short"
|
@@ -116,7 +116,7 @@ export const Select: React.FC<SelectProps> = ({
|
|
116
116
|
onClick={(e) => {
|
117
117
|
e.preventDefault();
|
118
118
|
setOpenDropdown(true);
|
119
|
-
|
119
|
+
dropdownTriggerRef.current?.click();
|
120
120
|
setDropdownWidth(
|
121
121
|
inputRef?.current?.getBoundingClientRect()?.width || 0
|
122
122
|
);
|
@@ -146,7 +146,7 @@ export const Select: React.FC<SelectProps> = ({
|
|
146
146
|
trigger={
|
147
147
|
<button
|
148
148
|
type="button"
|
149
|
-
ref={
|
149
|
+
ref={dropdownTriggerRef}
|
150
150
|
className={`w-0 my-0.5 ${height}`}
|
151
151
|
tabIndex={-1}
|
152
152
|
disabled={rest.disabled ?? false}
|
@@ -162,6 +162,8 @@ export const Select: React.FC<SelectProps> = ({
|
|
162
162
|
e.preventDefault();
|
163
163
|
inputRef.current?.focus();
|
164
164
|
setOpenDropdown(false);
|
165
|
+
} else if (e.key === "Tab") {
|
166
|
+
setOpenDropdown(false);
|
165
167
|
}
|
166
168
|
}}
|
167
169
|
>
|
@@ -195,6 +197,8 @@ export const Select: React.FC<SelectProps> = ({
|
|
195
197
|
e.preventDefault();
|
196
198
|
inputRef.current?.focus();
|
197
199
|
setOpenDropdown(false);
|
200
|
+
} else if (e.key === "Tab") {
|
201
|
+
setOpenDropdown(false);
|
198
202
|
}
|
199
203
|
}}
|
200
204
|
>
|