next-helios-fe 1.1.3 → 1.1.5
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/modal/index.d.ts +2 -2
- package/dist/components/dialog/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/components/content-container/drawer.tsx +6 -6
- package/src/components/content-container/modal/index.tsx +4 -4
- package/src/components/dialog/index.tsx +5 -5
- package/src/components/form/input/time.tsx +8 -8
- package/src/components/form/other/autocomplete.tsx +9 -9
- package/src/components/form/other/multipleSelect.tsx +7 -7
- package/src/components/form/other/phoneNumber.tsx +7 -7
- package/src/components/form/other/select.tsx +9 -9
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@ export const Drawer: React.FC<DrawerProps> = ({
|
|
|
13
13
|
title,
|
|
14
14
|
subtitle,
|
|
15
15
|
}) => {
|
|
16
|
-
const [
|
|
16
|
+
const [open, setOpen] = useState(false);
|
|
17
17
|
|
|
18
18
|
useEffect(() => {
|
|
19
19
|
document.addEventListener("mousedown", (e) => {
|
|
@@ -21,7 +21,7 @@ export const Drawer: React.FC<DrawerProps> = ({
|
|
|
21
21
|
e.target instanceof HTMLElement &&
|
|
22
22
|
!e.target.closest("#info-screen")
|
|
23
23
|
) {
|
|
24
|
-
|
|
24
|
+
setOpen(false);
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
}, []);
|
|
@@ -29,19 +29,19 @@ export const Drawer: React.FC<DrawerProps> = ({
|
|
|
29
29
|
return (
|
|
30
30
|
<div
|
|
31
31
|
className={`absolute top-0 right-0 h-full z-40 ${
|
|
32
|
-
!
|
|
32
|
+
!open && "pointer-events-none"
|
|
33
33
|
}`}
|
|
34
34
|
>
|
|
35
35
|
<div
|
|
36
36
|
className={`flex h-full duration-300 ${
|
|
37
|
-
|
|
37
|
+
open ? "translate-x-0" : "translate-x-96"
|
|
38
38
|
}`}
|
|
39
39
|
>
|
|
40
40
|
<button
|
|
41
41
|
type="button"
|
|
42
42
|
className="group sticky top-36 h-min rounded-l-md text-white bg-primary p-2 hover:bg-primary-dark pointer-events-auto active:opacity-70 active:duration-300 active:ease-out"
|
|
43
43
|
onClick={() => {
|
|
44
|
-
|
|
44
|
+
setOpen((prev) => !prev);
|
|
45
45
|
}}
|
|
46
46
|
>
|
|
47
47
|
<Icon
|
|
@@ -63,7 +63,7 @@ export const Drawer: React.FC<DrawerProps> = ({
|
|
|
63
63
|
type="button"
|
|
64
64
|
className="flex justify-center items-center rounded-full p-1 text-slate-400 hover:bg-secondary-light"
|
|
65
65
|
onClick={() => {
|
|
66
|
-
|
|
66
|
+
setOpen(false);
|
|
67
67
|
}}
|
|
68
68
|
>
|
|
69
69
|
<Icon icon="pajamas:close" className="text-2xl" />
|
|
@@ -19,8 +19,8 @@ interface ModalProps {
|
|
|
19
19
|
label?: string;
|
|
20
20
|
onClick: () => void;
|
|
21
21
|
};
|
|
22
|
-
|
|
23
|
-
onClose: (
|
|
22
|
+
open: boolean;
|
|
23
|
+
onClose: (open: boolean) => void;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export const Modal: React.FC<ModalProps> = ({
|
|
@@ -29,7 +29,7 @@ export const Modal: React.FC<ModalProps> = ({
|
|
|
29
29
|
title,
|
|
30
30
|
options,
|
|
31
31
|
action,
|
|
32
|
-
|
|
32
|
+
open,
|
|
33
33
|
onClose,
|
|
34
34
|
}) => {
|
|
35
35
|
useEffect(() => {
|
|
@@ -57,7 +57,7 @@ export const Modal: React.FC<ModalProps> = ({
|
|
|
57
57
|
<div
|
|
58
58
|
id={id}
|
|
59
59
|
className={`absolute top-0 left-0 w-dvw h-dvh z-40 bg-black/30 backdrop-blur-sm ${
|
|
60
|
-
!
|
|
60
|
+
!open && "hidden"
|
|
61
61
|
}`}
|
|
62
62
|
>
|
|
63
63
|
<div className="flex justify-center items-center w-full h-full">
|
|
@@ -11,15 +11,15 @@ interface DialogProps {
|
|
|
11
11
|
options?: {
|
|
12
12
|
timeout?: 3000 | 5000 | 7000 | 10000;
|
|
13
13
|
};
|
|
14
|
-
|
|
15
|
-
onClose: (
|
|
14
|
+
open: boolean;
|
|
15
|
+
onClose: (open: boolean) => void;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export const Dialog: React.FC<DialogProps> = ({
|
|
19
19
|
children,
|
|
20
20
|
action,
|
|
21
21
|
options,
|
|
22
|
-
|
|
22
|
+
open,
|
|
23
23
|
onClose,
|
|
24
24
|
}) => {
|
|
25
25
|
const actionVariant =
|
|
@@ -50,12 +50,12 @@ export const Dialog: React.FC<DialogProps> = ({
|
|
|
50
50
|
}, options.timeout);
|
|
51
51
|
return () => clearTimeout(timeout);
|
|
52
52
|
}
|
|
53
|
-
}, [
|
|
53
|
+
}, [open]);
|
|
54
54
|
|
|
55
55
|
return (
|
|
56
56
|
<div
|
|
57
57
|
className={`absolute top-0 left-0 w-dvw h-dvh z-40 ${
|
|
58
|
-
!
|
|
58
|
+
!open && "hidden"
|
|
59
59
|
} ${options?.timeout ? "pointer-events-none" : "bg-black/30"}`}
|
|
60
60
|
>
|
|
61
61
|
<div className="flex justify-center mt-4">
|
|
@@ -13,7 +13,7 @@ export interface TimeProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
|
13
13
|
|
|
14
14
|
export const Time: React.FC<TimeProps> = ({ options, label, ...rest }) => {
|
|
15
15
|
const [tempValue, setTempValue] = useState(dayjs().format("hh:mm a"));
|
|
16
|
-
const [
|
|
16
|
+
const [openDropdown, setOpenDropdown] = useState(false);
|
|
17
17
|
const [position, setPosition] = useState<{
|
|
18
18
|
top: number;
|
|
19
19
|
left: number;
|
|
@@ -115,7 +115,7 @@ export const Time: React.FC<TimeProps> = ({ options, label, ...rest }) => {
|
|
|
115
115
|
!dropdownRef.current.contains(e.target as Node) &&
|
|
116
116
|
!triggerRef.current?.contains(e.target as Node)
|
|
117
117
|
) {
|
|
118
|
-
|
|
118
|
+
setOpenDropdown(false);
|
|
119
119
|
}
|
|
120
120
|
};
|
|
121
121
|
|
|
@@ -147,15 +147,15 @@ export const Time: React.FC<TimeProps> = ({ options, label, ...rest }) => {
|
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
if (
|
|
150
|
+
if (openDropdown) {
|
|
151
151
|
document.getElementById("body")!.style.overflow = "hidden";
|
|
152
152
|
} else {
|
|
153
153
|
document.getElementById("body")!.style.overflow = "auto";
|
|
154
154
|
}
|
|
155
|
-
}, [
|
|
155
|
+
}, [openDropdown]);
|
|
156
156
|
|
|
157
157
|
useEffect(() => {
|
|
158
|
-
if (
|
|
158
|
+
if (openDropdown) {
|
|
159
159
|
const scrollToSelected = (
|
|
160
160
|
ref: React.RefObject<HTMLDivElement>,
|
|
161
161
|
value: string,
|
|
@@ -175,7 +175,7 @@ export const Time: React.FC<TimeProps> = ({ options, label, ...rest }) => {
|
|
|
175
175
|
scrollToSelected(hoursRef, tempValue.split(":")[0], 0);
|
|
176
176
|
scrollToSelected(minutesRef, tempValue.split(":")[1].split(" ")[0], 0);
|
|
177
177
|
}
|
|
178
|
-
}, [
|
|
178
|
+
}, [openDropdown, tempValue]);
|
|
179
179
|
|
|
180
180
|
useEffect(() => {
|
|
181
181
|
if (rest.value) {
|
|
@@ -210,7 +210,7 @@ export const Time: React.FC<TimeProps> = ({ options, label, ...rest }) => {
|
|
|
210
210
|
<div className="relative" ref={triggerRef}>
|
|
211
211
|
<div
|
|
212
212
|
className="relative flex items-center cursor-pointer"
|
|
213
|
-
onClick={() =>
|
|
213
|
+
onClick={() => setOpenDropdown(!openDropdown)}
|
|
214
214
|
>
|
|
215
215
|
<input
|
|
216
216
|
type="text"
|
|
@@ -219,7 +219,7 @@ export const Time: React.FC<TimeProps> = ({ options, label, ...rest }) => {
|
|
|
219
219
|
{...rest}
|
|
220
220
|
/>
|
|
221
221
|
</div>
|
|
222
|
-
{
|
|
222
|
+
{openDropdown &&
|
|
223
223
|
position &&
|
|
224
224
|
createPortal(
|
|
225
225
|
<div
|
|
@@ -26,7 +26,7 @@ export const Autocomplete: React.FC<AutocompleteProps> = ({
|
|
|
26
26
|
...rest
|
|
27
27
|
}) => {
|
|
28
28
|
const [tempValue, setTempValue] = useState("");
|
|
29
|
-
const [
|
|
29
|
+
const [openDropdown, setOpenDropdown] = useState(false);
|
|
30
30
|
const [position, setPosition] = useState<{
|
|
31
31
|
top: number;
|
|
32
32
|
left: number;
|
|
@@ -49,7 +49,7 @@ export const Autocomplete: React.FC<AutocompleteProps> = ({
|
|
|
49
49
|
!dropdownRef.current.contains(e.target as Node) &&
|
|
50
50
|
!triggerRef.current?.contains(e.target as Node)
|
|
51
51
|
) {
|
|
52
|
-
|
|
52
|
+
setOpenDropdown(false);
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
|
|
@@ -81,12 +81,12 @@ export const Autocomplete: React.FC<AutocompleteProps> = ({
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
if (
|
|
84
|
+
if (openDropdown) {
|
|
85
85
|
document.getElementById("body")!.style.overflow = "hidden";
|
|
86
86
|
} else {
|
|
87
87
|
document.getElementById("body")!.style.overflow = "auto";
|
|
88
88
|
}
|
|
89
|
-
}, [
|
|
89
|
+
}, [openDropdown, tempValue]);
|
|
90
90
|
|
|
91
91
|
useEffect(() => {
|
|
92
92
|
if (rest.value) {
|
|
@@ -121,7 +121,7 @@ export const Autocomplete: React.FC<AutocompleteProps> = ({
|
|
|
121
121
|
<div className="relative" ref={triggerRef}>
|
|
122
122
|
<div
|
|
123
123
|
className="relative flex items-center cursor-pointer"
|
|
124
|
-
onClick={() =>
|
|
124
|
+
onClick={() => setOpenDropdown(!openDropdown)}
|
|
125
125
|
>
|
|
126
126
|
<input
|
|
127
127
|
type="text"
|
|
@@ -133,15 +133,15 @@ export const Autocomplete: React.FC<AutocompleteProps> = ({
|
|
|
133
133
|
setTempValue(e.target.value);
|
|
134
134
|
}}
|
|
135
135
|
onClick={() => {
|
|
136
|
-
|
|
136
|
+
setOpenDropdown(true);
|
|
137
137
|
setTempValue("");
|
|
138
138
|
}}
|
|
139
139
|
/>
|
|
140
140
|
<div className="absolute right-4 text-xl text-slate-400 pointer-events-none">
|
|
141
|
-
<Icon icon={`gravity-ui:chevron-${
|
|
141
|
+
<Icon icon={`gravity-ui:chevron-${openDropdown ? "up" : "down"}`} />
|
|
142
142
|
</div>
|
|
143
143
|
</div>
|
|
144
|
-
{
|
|
144
|
+
{openDropdown &&
|
|
145
145
|
position &&
|
|
146
146
|
createPortal(
|
|
147
147
|
<div
|
|
@@ -176,7 +176,7 @@ export const Autocomplete: React.FC<AutocompleteProps> = ({
|
|
|
176
176
|
}`}
|
|
177
177
|
onMouseDown={() => {
|
|
178
178
|
setTempValue(item.label);
|
|
179
|
-
|
|
179
|
+
setOpenDropdown(false);
|
|
180
180
|
}}
|
|
181
181
|
>
|
|
182
182
|
{item.label}
|
|
@@ -41,7 +41,7 @@ export const MultipleSelect: React.FC<MultipleSelectProps> = ({
|
|
|
41
41
|
...rest
|
|
42
42
|
}) => {
|
|
43
43
|
const [tempValue, setTempValue] = useState<string[]>([]);
|
|
44
|
-
const [
|
|
44
|
+
const [openDropdown, setOpenDropdown] = useState(false);
|
|
45
45
|
const [position, setPosition] = useState<{
|
|
46
46
|
top: number;
|
|
47
47
|
left: number;
|
|
@@ -64,7 +64,7 @@ export const MultipleSelect: React.FC<MultipleSelectProps> = ({
|
|
|
64
64
|
!dropdownRef.current.contains(e.target as Node) &&
|
|
65
65
|
!triggerRef.current?.contains(e.target as Node)
|
|
66
66
|
) {
|
|
67
|
-
|
|
67
|
+
setOpenDropdown(false);
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
|
|
@@ -96,12 +96,12 @@ export const MultipleSelect: React.FC<MultipleSelectProps> = ({
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
if (
|
|
99
|
+
if (openDropdown) {
|
|
100
100
|
document.getElementById("body")!.style.overflow = "hidden";
|
|
101
101
|
} else {
|
|
102
102
|
document.getElementById("body")!.style.overflow = "auto";
|
|
103
103
|
}
|
|
104
|
-
}, [
|
|
104
|
+
}, [openDropdown]);
|
|
105
105
|
|
|
106
106
|
useEffect(() => {
|
|
107
107
|
if (value) {
|
|
@@ -135,7 +135,7 @@ export const MultipleSelect: React.FC<MultipleSelectProps> = ({
|
|
|
135
135
|
disabled={rest.disabled}
|
|
136
136
|
onClick={() => {
|
|
137
137
|
onClick && onClick();
|
|
138
|
-
|
|
138
|
+
setOpenDropdown(true);
|
|
139
139
|
}}
|
|
140
140
|
{...rest}
|
|
141
141
|
>
|
|
@@ -166,10 +166,10 @@ export const MultipleSelect: React.FC<MultipleSelectProps> = ({
|
|
|
166
166
|
</div>
|
|
167
167
|
)}
|
|
168
168
|
<div className="text-xl text-slate-400 pointer-events-none">
|
|
169
|
-
<Icon icon={`gravity-ui:chevron-${
|
|
169
|
+
<Icon icon={`gravity-ui:chevron-${openDropdown ? "up" : "down"}`} />
|
|
170
170
|
</div>
|
|
171
171
|
</button>
|
|
172
|
-
{
|
|
172
|
+
{openDropdown &&
|
|
173
173
|
position &&
|
|
174
174
|
createPortal(
|
|
175
175
|
<div
|
|
@@ -1476,7 +1476,7 @@ export const PhoneNumber: React.FC<PhoneNumberProps> = ({
|
|
|
1476
1476
|
const triggerRef = useRef<HTMLDivElement>(null);
|
|
1477
1477
|
const dropdownRef = useRef<HTMLDivElement>(null);
|
|
1478
1478
|
const [tempValue, setTempValue] = useState(["🇮🇩 ID", ""]);
|
|
1479
|
-
const [
|
|
1479
|
+
const [openDropdown, setOpenDropdown] = useState(false);
|
|
1480
1480
|
const [position, setPosition] = useState<{
|
|
1481
1481
|
top: number;
|
|
1482
1482
|
left: number;
|
|
@@ -1497,7 +1497,7 @@ export const PhoneNumber: React.FC<PhoneNumberProps> = ({
|
|
|
1497
1497
|
!dropdownRef.current.contains(e.target as Node) &&
|
|
1498
1498
|
!triggerRef.current?.contains(e.target as Node)
|
|
1499
1499
|
) {
|
|
1500
|
-
|
|
1500
|
+
setOpenDropdown(false);
|
|
1501
1501
|
}
|
|
1502
1502
|
};
|
|
1503
1503
|
|
|
@@ -1529,12 +1529,12 @@ export const PhoneNumber: React.FC<PhoneNumberProps> = ({
|
|
|
1529
1529
|
}
|
|
1530
1530
|
}
|
|
1531
1531
|
|
|
1532
|
-
if (
|
|
1532
|
+
if (openDropdown) {
|
|
1533
1533
|
document.getElementById("body")!.style.overflow = "hidden";
|
|
1534
1534
|
} else {
|
|
1535
1535
|
document.getElementById("body")!.style.overflow = "auto";
|
|
1536
1536
|
}
|
|
1537
|
-
}, [
|
|
1537
|
+
}, [openDropdown]);
|
|
1538
1538
|
|
|
1539
1539
|
useEffect(() => {
|
|
1540
1540
|
if (rest.value) {
|
|
@@ -1605,11 +1605,11 @@ export const PhoneNumber: React.FC<PhoneNumberProps> = ({
|
|
|
1605
1605
|
setTempValue((prev) => [e.target.value, prev[1]]);
|
|
1606
1606
|
}}
|
|
1607
1607
|
onClick={() => {
|
|
1608
|
-
|
|
1608
|
+
setOpenDropdown(true);
|
|
1609
1609
|
setTempValue((prev) => ["", prev[1]]);
|
|
1610
1610
|
}}
|
|
1611
1611
|
/>
|
|
1612
|
-
{
|
|
1612
|
+
{openDropdown &&
|
|
1613
1613
|
position &&
|
|
1614
1614
|
createPortal(
|
|
1615
1615
|
<div
|
|
@@ -1650,7 +1650,7 @@ export const PhoneNumber: React.FC<PhoneNumberProps> = ({
|
|
|
1650
1650
|
`${item.emoji} ${item.code}`,
|
|
1651
1651
|
prev[1],
|
|
1652
1652
|
]);
|
|
1653
|
-
|
|
1653
|
+
setOpenDropdown(false);
|
|
1654
1654
|
}}
|
|
1655
1655
|
>
|
|
1656
1656
|
{`${item.emoji} ${item.code}`}
|
|
@@ -26,7 +26,7 @@ export const Select: React.FC<SelectProps> = ({
|
|
|
26
26
|
...rest
|
|
27
27
|
}) => {
|
|
28
28
|
const [tempValue, setTempValue] = useState("");
|
|
29
|
-
const [
|
|
29
|
+
const [openDropdown, setOpenDropdown] = useState(false);
|
|
30
30
|
const [position, setPosition] = useState<{
|
|
31
31
|
top: number;
|
|
32
32
|
left: number;
|
|
@@ -49,7 +49,7 @@ export const Select: React.FC<SelectProps> = ({
|
|
|
49
49
|
!dropdownRef.current.contains(e.target as Node) &&
|
|
50
50
|
!triggerRef.current?.contains(e.target as Node)
|
|
51
51
|
) {
|
|
52
|
-
|
|
52
|
+
setOpenDropdown(false);
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
|
|
@@ -81,12 +81,12 @@ export const Select: React.FC<SelectProps> = ({
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
if (
|
|
84
|
+
if (openDropdown) {
|
|
85
85
|
document.getElementById("body")!.style.overflow = "hidden";
|
|
86
86
|
} else {
|
|
87
87
|
document.getElementById("body")!.style.overflow = "auto";
|
|
88
88
|
}
|
|
89
|
-
}, [
|
|
89
|
+
}, [openDropdown]);
|
|
90
90
|
|
|
91
91
|
useEffect(() => {
|
|
92
92
|
if (rest.value) {
|
|
@@ -121,7 +121,7 @@ export const Select: React.FC<SelectProps> = ({
|
|
|
121
121
|
<div className="relative" ref={triggerRef}>
|
|
122
122
|
<div
|
|
123
123
|
className="relative flex items-center cursor-pointer"
|
|
124
|
-
onClick={() =>
|
|
124
|
+
onClick={() => setOpenDropdown(!openDropdown)}
|
|
125
125
|
>
|
|
126
126
|
<input
|
|
127
127
|
type="text"
|
|
@@ -129,13 +129,13 @@ export const Select: React.FC<SelectProps> = ({
|
|
|
129
129
|
placeholder={placeholder}
|
|
130
130
|
disabled={rest.disabled}
|
|
131
131
|
value={tempValue}
|
|
132
|
-
onClick={() =>
|
|
132
|
+
onClick={() => setOpenDropdown(true)}
|
|
133
133
|
/>
|
|
134
134
|
<div className="absolute right-4 text-xl text-slate-400 pointer-events-none">
|
|
135
|
-
<Icon icon={`gravity-ui:chevron-${
|
|
135
|
+
<Icon icon={`gravity-ui:chevron-${openDropdown ? "up" : "down"}`} />
|
|
136
136
|
</div>
|
|
137
137
|
</div>
|
|
138
|
-
{
|
|
138
|
+
{openDropdown &&
|
|
139
139
|
position &&
|
|
140
140
|
createPortal(
|
|
141
141
|
<div
|
|
@@ -164,7 +164,7 @@ export const Select: React.FC<SelectProps> = ({
|
|
|
164
164
|
}`}
|
|
165
165
|
onMouseDown={() => {
|
|
166
166
|
setTempValue(item.label);
|
|
167
|
-
|
|
167
|
+
setOpenDropdown(false);
|
|
168
168
|
}}
|
|
169
169
|
>
|
|
170
170
|
{item.label}
|