next-helios-fe 1.0.2 → 1.0.3
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
|
@@ -8,6 +8,7 @@ import { Action, type ActionProps } from "./action";
|
|
|
8
8
|
|
|
9
9
|
interface TableProps {
|
|
10
10
|
title?: string;
|
|
11
|
+
|
|
11
12
|
header: {
|
|
12
13
|
title: string;
|
|
13
14
|
key: string;
|
|
@@ -16,13 +17,14 @@ interface TableProps {
|
|
|
16
17
|
data: any[];
|
|
17
18
|
options?: {
|
|
18
19
|
hideToolbar?: boolean;
|
|
19
|
-
|
|
20
|
+
hideNumberColumn?: boolean;
|
|
20
21
|
checkbox?: boolean;
|
|
21
22
|
height?: "full" | "fit" | "20" | "40" | "80";
|
|
22
23
|
maxRow?: 10 | 20 | 50 | 100;
|
|
23
24
|
border?: boolean;
|
|
24
25
|
};
|
|
25
26
|
actions?: (e: any) => React.ReactNode;
|
|
27
|
+
onAddData?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
interface TableComponentProps extends React.FC<TableProps> {
|
|
@@ -35,6 +37,7 @@ export const Table: TableComponentProps = ({
|
|
|
35
37
|
data,
|
|
36
38
|
options,
|
|
37
39
|
actions,
|
|
40
|
+
onAddData,
|
|
38
41
|
}) => {
|
|
39
42
|
const [search, setSearch] = useState<string>("");
|
|
40
43
|
const [filter, setFilter] = useState<any[]>([]);
|
|
@@ -70,12 +73,10 @@ export const Table: TableComponentProps = ({
|
|
|
70
73
|
return item;
|
|
71
74
|
} else if (
|
|
72
75
|
header.some((headerItem) => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
.includes(search.toLowerCase());
|
|
78
|
-
}
|
|
76
|
+
return item[headerItem.key as keyof typeof item]
|
|
77
|
+
?.toString()
|
|
78
|
+
.toLowerCase()
|
|
79
|
+
.includes(search.toLowerCase());
|
|
79
80
|
})
|
|
80
81
|
) {
|
|
81
82
|
return item;
|
|
@@ -132,22 +133,30 @@ export const Table: TableComponentProps = ({
|
|
|
132
133
|
}`}
|
|
133
134
|
/>
|
|
134
135
|
</button>
|
|
135
|
-
<
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
136
|
+
<div className="relative flex items-center">
|
|
137
|
+
<input
|
|
138
|
+
type="search"
|
|
139
|
+
className="w-full ps-6 pe-0 pt-0 pb-0.5 border-default border-t-0 border-b border-x-0 bg-secondary-bg text-sm font-normal placeholder:duration-300 placeholder:translate-x-0 [&::-webkit-search-cancel-button]:appearance-none focus:placeholder:translate-x-1 placeholder:text-slate-300 focus:outline-none focus:ring-0 focus:border-primary-dark disabled:bg-secondary-light disabled:text-slate-400"
|
|
140
|
+
placeholder="search.."
|
|
141
|
+
value={
|
|
142
|
+
filter.find((filterItem) => filterItem.key === item.key)
|
|
143
|
+
?.value
|
|
144
|
+
}
|
|
145
|
+
onChange={(e) => {
|
|
146
|
+
setFilter(
|
|
147
|
+
filter.map((filterItem) => {
|
|
148
|
+
return filterItem.key === item.key
|
|
149
|
+
? { ...filterItem, value: e.target.value }
|
|
150
|
+
: filterItem;
|
|
151
|
+
})
|
|
152
|
+
);
|
|
153
|
+
}}
|
|
154
|
+
/>
|
|
155
|
+
<Icon
|
|
156
|
+
icon="ic:round-search"
|
|
157
|
+
className="absolute text-sm text-slate-400"
|
|
158
|
+
/>
|
|
159
|
+
</div>
|
|
151
160
|
</div>
|
|
152
161
|
</th>
|
|
153
162
|
);
|
|
@@ -186,7 +195,7 @@ export const Table: TableComponentProps = ({
|
|
|
186
195
|
/>
|
|
187
196
|
</td>
|
|
188
197
|
)}
|
|
189
|
-
{!options?.
|
|
198
|
+
{!options?.hideNumberColumn && (
|
|
190
199
|
<td className="sticky left-0 px-4 py-1 border-b bg-secondary-bg text-center">
|
|
191
200
|
{(page - 1) * maxRow + index + 1}
|
|
192
201
|
</td>
|
|
@@ -229,6 +238,17 @@ export const Table: TableComponentProps = ({
|
|
|
229
238
|
<div className="flex justify-between items-center gap-4 w-full h-fit">
|
|
230
239
|
<span className="text-lg">{title}</span>
|
|
231
240
|
<div className="flex items-center gap-4">
|
|
241
|
+
{onAddData && (
|
|
242
|
+
<button
|
|
243
|
+
type="button"
|
|
244
|
+
className="p-1.5 rounded-full bg-primary text-white hover:bg-primary-dark"
|
|
245
|
+
onClick={(e) => {
|
|
246
|
+
onAddData && onAddData(e);
|
|
247
|
+
}}
|
|
248
|
+
>
|
|
249
|
+
<Icon icon="ic:round-plus" className="text-2xl" />
|
|
250
|
+
</button>
|
|
251
|
+
)}
|
|
232
252
|
<Dropdown
|
|
233
253
|
trigger={
|
|
234
254
|
<button
|
|
@@ -315,8 +335,8 @@ export const Table: TableComponentProps = ({
|
|
|
315
335
|
</div>
|
|
316
336
|
</th>
|
|
317
337
|
)}
|
|
318
|
-
{!options?.
|
|
319
|
-
<th className="sticky left-0 w-min px-4 py-2 bg-secondary-bg font-medium text-center whitespace-nowrap">
|
|
338
|
+
{!options?.hideNumberColumn && (
|
|
339
|
+
<th className="sticky left-0 w-min px-4 py-2 z-10 bg-secondary-bg font-medium text-center whitespace-nowrap">
|
|
320
340
|
<div className="flex flex-col">
|
|
321
341
|
<span>NO.</span>
|
|
322
342
|
<div className="invisible w-0 overflow-hidden">
|