next-helios-fe 1.10.26 → 1.10.28
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
|
@@ -43,46 +43,55 @@ export const Date: React.FC<DateProps> = ({
|
|
|
43
43
|
: "py-1.5";
|
|
44
44
|
|
|
45
45
|
useEffect(() => {
|
|
46
|
-
if (value
|
|
47
|
-
setTempValue(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
if (value) {
|
|
47
|
+
setTempValue(
|
|
48
|
+
value.length === 2
|
|
49
|
+
? [dayjs(value[0]).startOf("day"), dayjs(value[1]).startOf("day")]
|
|
50
|
+
: ([] as any)
|
|
51
|
+
);
|
|
52
|
+
} else if (defaultValue) {
|
|
53
|
+
setTempValue(
|
|
54
|
+
defaultValue.length === 2
|
|
55
|
+
? [
|
|
56
|
+
dayjs(defaultValue[0]).startOf("day"),
|
|
57
|
+
dayjs(defaultValue[1]).startOf("day"),
|
|
58
|
+
]
|
|
59
|
+
: ([] as any)
|
|
60
|
+
);
|
|
56
61
|
}
|
|
57
62
|
}, [value, defaultValue]);
|
|
58
63
|
|
|
59
64
|
const dateRangeLabel = (data: any) => {
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
dayjs(data[1]).format("YYYY-MM-DD") === dayjs().format("YYYY-MM-DD")
|
|
63
|
-
) {
|
|
64
|
-
return "Today";
|
|
65
|
-
} else if (
|
|
66
|
-
dayjs(data[0]).format("YYYY-MM-DD") ===
|
|
67
|
-
dayjs().subtract(1, "days").format("YYYY-MM-DD") &&
|
|
68
|
-
dayjs(data[1]).format("YYYY-MM-DD") ===
|
|
69
|
-
dayjs().subtract(1, "days").format("YYYY-MM-DD")
|
|
70
|
-
) {
|
|
71
|
-
return "Yesterday";
|
|
72
|
-
} else if (
|
|
73
|
-
dayjs(data[0]).format("YYYY-MM-DD") ===
|
|
74
|
-
dayjs().subtract(7, "days").format("YYYY-MM-DD") &&
|
|
75
|
-
dayjs(data[1]).format("YYYY-MM-DD") === dayjs().format("YYYY-MM-DD")
|
|
76
|
-
) {
|
|
77
|
-
return "Last 7 Days";
|
|
78
|
-
} else if (
|
|
79
|
-
dayjs(data[0]).format("YYYY-MM-DD") ===
|
|
80
|
-
dayjs().subtract(1, "months").format("YYYY-MM-DD") &&
|
|
81
|
-
dayjs(data[1]).format("YYYY-MM-DD") === dayjs().format("YYYY-MM-DD")
|
|
82
|
-
) {
|
|
83
|
-
return "Last 30 Days";
|
|
65
|
+
if (data.length === 0) {
|
|
66
|
+
return "";
|
|
84
67
|
} else {
|
|
85
|
-
|
|
68
|
+
if (
|
|
69
|
+
dayjs(data[0]).format("YYYY-MM-DD") === dayjs().format("YYYY-MM-DD") &&
|
|
70
|
+
dayjs(data[1]).format("YYYY-MM-DD") === dayjs().format("YYYY-MM-DD")
|
|
71
|
+
) {
|
|
72
|
+
return "Today";
|
|
73
|
+
} else if (
|
|
74
|
+
dayjs(data[0]).format("YYYY-MM-DD") ===
|
|
75
|
+
dayjs().subtract(1, "days").format("YYYY-MM-DD") &&
|
|
76
|
+
dayjs(data[1]).format("YYYY-MM-DD") ===
|
|
77
|
+
dayjs().subtract(1, "days").format("YYYY-MM-DD")
|
|
78
|
+
) {
|
|
79
|
+
return "Yesterday";
|
|
80
|
+
} else if (
|
|
81
|
+
dayjs(data[0]).format("YYYY-MM-DD") ===
|
|
82
|
+
dayjs().subtract(7, "days").format("YYYY-MM-DD") &&
|
|
83
|
+
dayjs(data[1]).format("YYYY-MM-DD") === dayjs().format("YYYY-MM-DD")
|
|
84
|
+
) {
|
|
85
|
+
return "Last 7 Days";
|
|
86
|
+
} else if (
|
|
87
|
+
dayjs(data[0]).format("YYYY-MM-DD") ===
|
|
88
|
+
dayjs().subtract(1, "months").format("YYYY-MM-DD") &&
|
|
89
|
+
dayjs(data[1]).format("YYYY-MM-DD") === dayjs().format("YYYY-MM-DD")
|
|
90
|
+
) {
|
|
91
|
+
return "Last 30 Days";
|
|
92
|
+
} else {
|
|
93
|
+
return "Custom";
|
|
94
|
+
}
|
|
86
95
|
}
|
|
87
96
|
};
|
|
88
97
|
|
|
@@ -111,44 +120,71 @@ export const Date: React.FC<DateProps> = ({
|
|
|
111
120
|
)}
|
|
112
121
|
</div>
|
|
113
122
|
)}
|
|
114
|
-
<div className="
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
123
|
+
<div className="group flex items-center gap-2">
|
|
124
|
+
<div className="flex-1 relative flex items-center">
|
|
125
|
+
{!options?.buttonOnly && (
|
|
126
|
+
<input
|
|
127
|
+
type="text"
|
|
128
|
+
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}`}
|
|
129
|
+
disabled={rest.disabled}
|
|
130
|
+
readOnly
|
|
131
|
+
value={
|
|
132
|
+
dateRangeLabel(tempValue) === "Custom" ||
|
|
133
|
+
!options?.enableSelectRange
|
|
134
|
+
? `${
|
|
135
|
+
!options?.enableSelectRange
|
|
136
|
+
? ""
|
|
137
|
+
: `${
|
|
138
|
+
dayjs(tempValue[0]).format("MMM YYYY") ===
|
|
139
|
+
dayjs(tempValue[1]).format("MMM YYYY")
|
|
140
|
+
? dayjs(tempValue[0]).format("DD")
|
|
141
|
+
: dayjs(tempValue[0]).format("DD MMM YYYY")
|
|
142
|
+
} - `
|
|
143
|
+
}${dayjs(tempValue[1]).format("DD MMM YYYY")}`
|
|
144
|
+
: dateRangeLabel(tempValue)
|
|
145
|
+
}
|
|
146
|
+
onClick={(e) => {
|
|
147
|
+
dropdownRef.current?.click();
|
|
148
|
+
}}
|
|
149
|
+
/>
|
|
150
|
+
)}
|
|
151
|
+
<button
|
|
152
|
+
type="button"
|
|
153
|
+
className={`rounded-full text-xl hover:bg-secondary-light ${
|
|
154
|
+
options?.buttonOnly
|
|
155
|
+
? "p-2"
|
|
156
|
+
: "absolute right-4 p-1 text-disabled"
|
|
157
|
+
}`}
|
|
158
|
+
tabIndex={-1}
|
|
119
159
|
disabled={rest.disabled}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
160
|
+
onClick={(e) => {
|
|
161
|
+
e.preventDefault();
|
|
162
|
+
dropdownRef.current?.click();
|
|
163
|
+
}}
|
|
164
|
+
>
|
|
165
|
+
<Icon icon="akar-icons:calendar" />
|
|
166
|
+
</button>
|
|
167
|
+
</div>
|
|
168
|
+
{!rest.required && tempValue.length !== 0 && (
|
|
169
|
+
<button
|
|
170
|
+
type="button"
|
|
171
|
+
className="p-1 rounded-full text-xl hover:bg-secondary-light hidden group-hover:block"
|
|
172
|
+
onClick={(e) => {
|
|
173
|
+
e.stopPropagation();
|
|
174
|
+
e.preventDefault();
|
|
175
|
+
setTempValue([]);
|
|
176
|
+
if (rest.onChange) {
|
|
177
|
+
rest.onChange({
|
|
178
|
+
target: {
|
|
179
|
+
value: [],
|
|
180
|
+
} as any,
|
|
181
|
+
} as React.ChangeEvent<HTMLInputElement>);
|
|
182
|
+
}
|
|
183
|
+
}}
|
|
184
|
+
>
|
|
185
|
+
<Icon icon="pajamas:close" />
|
|
186
|
+
</button>
|
|
137
187
|
)}
|
|
138
|
-
<button
|
|
139
|
-
type="button"
|
|
140
|
-
className={`rounded-full text-xl hover:bg-secondary-light ${
|
|
141
|
-
options?.buttonOnly ? "p-2" : "absolute right-4 p-1 text-disabled"
|
|
142
|
-
}`}
|
|
143
|
-
tabIndex={-1}
|
|
144
|
-
disabled={rest.disabled}
|
|
145
|
-
onClick={(e) => {
|
|
146
|
-
e.preventDefault();
|
|
147
|
-
dropdownRef.current?.click();
|
|
148
|
-
}}
|
|
149
|
-
>
|
|
150
|
-
<Icon icon="akar-icons:calendar" />
|
|
151
|
-
</button>
|
|
152
188
|
</div>
|
|
153
189
|
</label>
|
|
154
190
|
<div className="w-0 overflow-hidden">
|
|
@@ -171,7 +171,7 @@ export const ModalSelect: React.FC<ModalSelectProps> = ({
|
|
|
171
171
|
label={label}
|
|
172
172
|
placeholder={placeholder}
|
|
173
173
|
description={description}
|
|
174
|
-
options={options}
|
|
174
|
+
options={{ ...options, disableDropdown: true }}
|
|
175
175
|
disabled={disabled}
|
|
176
176
|
required={required}
|
|
177
177
|
value={tempValue || ""}
|
|
@@ -20,6 +20,7 @@ export interface SelectProps
|
|
|
20
20
|
options?: {
|
|
21
21
|
width?: "full" | "fit";
|
|
22
22
|
height?: "short" | "medium" | "high";
|
|
23
|
+
disableDropdown?: boolean;
|
|
23
24
|
};
|
|
24
25
|
readOnly?: boolean;
|
|
25
26
|
}
|
|
@@ -169,92 +170,94 @@ export const Select: React.FC<SelectProps> = ({
|
|
|
169
170
|
))}
|
|
170
171
|
</select>
|
|
171
172
|
</label>
|
|
172
|
-
|
|
173
|
-
<
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
1
|
|
184
|
-
</button>
|
|
185
|
-
}
|
|
186
|
-
>
|
|
187
|
-
{menus.length === 0 ? (
|
|
188
|
-
<Dropdown.Item
|
|
189
|
-
onKeyDown={(e) => {
|
|
190
|
-
if (e.key === "Escape") {
|
|
191
|
-
e.preventDefault();
|
|
192
|
-
inputRef.current?.focus();
|
|
193
|
-
setOpenDropdown(false);
|
|
194
|
-
} else if (e.key === "Tab") {
|
|
195
|
-
setOpenDropdown(false);
|
|
196
|
-
}
|
|
197
|
-
}}
|
|
198
|
-
>
|
|
199
|
-
<div
|
|
200
|
-
className="flex justify-center"
|
|
201
|
-
style={{ width: dropdownWidth - 43 }}
|
|
173
|
+
{!options?.disableDropdown && (
|
|
174
|
+
<div className="w-0 overflow-hidden">
|
|
175
|
+
<Dropdown
|
|
176
|
+
placement="bottom-start"
|
|
177
|
+
trigger={
|
|
178
|
+
<button
|
|
179
|
+
type="button"
|
|
180
|
+
ref={dropdownTriggerRef}
|
|
181
|
+
className={`w-0 my-0.5 ${height}`}
|
|
182
|
+
tabIndex={-1}
|
|
183
|
+
disabled={rest.disabled ?? readOnly ?? false}
|
|
202
184
|
>
|
|
203
|
-
|
|
204
|
-
</
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
menus.
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
key
|
|
211
|
-
|
|
212
|
-
as={item.variant || "button"}
|
|
213
|
-
disabled={item.disabled ?? false}
|
|
214
|
-
onClick={() => {
|
|
215
|
-
setTempValue(item.value);
|
|
216
|
-
if (rest.onChange) {
|
|
217
|
-
rest.onChange({
|
|
218
|
-
target: { value: item.value } as HTMLSelectElement,
|
|
219
|
-
} as any);
|
|
220
|
-
}
|
|
221
|
-
setOpenDropdown(false);
|
|
185
|
+
1
|
|
186
|
+
</button>
|
|
187
|
+
}
|
|
188
|
+
>
|
|
189
|
+
{menus.length === 0 ? (
|
|
190
|
+
<Dropdown.Item
|
|
191
|
+
onKeyDown={(e) => {
|
|
192
|
+
if (e.key === "Escape") {
|
|
193
|
+
e.preventDefault();
|
|
222
194
|
inputRef.current?.focus();
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}}
|
|
195
|
+
setOpenDropdown(false);
|
|
196
|
+
} else if (e.key === "Tab") {
|
|
197
|
+
setOpenDropdown(false);
|
|
198
|
+
}
|
|
199
|
+
}}
|
|
200
|
+
>
|
|
201
|
+
<div
|
|
202
|
+
className="flex justify-center"
|
|
203
|
+
style={{ width: dropdownWidth - 43 }}
|
|
233
204
|
>
|
|
234
|
-
<
|
|
235
|
-
|
|
236
|
-
|
|
205
|
+
<span>No data found</span>
|
|
206
|
+
</div>
|
|
207
|
+
</Dropdown.Item>
|
|
208
|
+
) : (
|
|
209
|
+
menus.map((item, index) => {
|
|
210
|
+
return (
|
|
211
|
+
<Dropdown.Item
|
|
212
|
+
key={index}
|
|
213
|
+
active={tempValue === item.value ? true : false}
|
|
214
|
+
as={item.variant || "button"}
|
|
215
|
+
disabled={item.disabled ?? false}
|
|
216
|
+
onClick={() => {
|
|
217
|
+
setTempValue(item.value);
|
|
218
|
+
if (rest.onChange) {
|
|
219
|
+
rest.onChange({
|
|
220
|
+
target: { value: item.value } as HTMLSelectElement,
|
|
221
|
+
} as any);
|
|
222
|
+
}
|
|
223
|
+
setOpenDropdown(false);
|
|
224
|
+
inputRef.current?.focus();
|
|
225
|
+
}}
|
|
226
|
+
onKeyDown={(e) => {
|
|
227
|
+
if (e.key === "Escape") {
|
|
228
|
+
e.preventDefault();
|
|
229
|
+
inputRef.current?.focus();
|
|
230
|
+
setOpenDropdown(false);
|
|
231
|
+
} else if (e.key === "Tab") {
|
|
232
|
+
setOpenDropdown(false);
|
|
233
|
+
}
|
|
234
|
+
}}
|
|
237
235
|
>
|
|
238
|
-
<div
|
|
239
|
-
|
|
240
|
-
{
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
236
|
+
<div
|
|
237
|
+
className="flex justify-between items-center gap-4"
|
|
238
|
+
style={{ width: dropdownWidth - 43 }}
|
|
239
|
+
>
|
|
240
|
+
<div className="flex flex-col">
|
|
241
|
+
<span>{item.label}</span>
|
|
242
|
+
{item.subLabel && (
|
|
243
|
+
<span
|
|
244
|
+
className={`text-xs ${
|
|
245
|
+
tempValue === item.value ? "" : "text-disabled"
|
|
246
|
+
}`}
|
|
247
|
+
>
|
|
248
|
+
{item.subLabel}
|
|
249
|
+
</span>
|
|
250
|
+
)}
|
|
251
|
+
</div>
|
|
252
|
+
{labelComponent ? labelComponent(item) : ""}
|
|
249
253
|
</div>
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
</div>
|
|
254
|
+
</Dropdown.Item>
|
|
255
|
+
);
|
|
256
|
+
})
|
|
257
|
+
)}
|
|
258
|
+
</Dropdown>
|
|
259
|
+
</div>
|
|
260
|
+
)}
|
|
258
261
|
</div>
|
|
259
262
|
);
|
|
260
263
|
};
|