next-helios-fe 1.1.14 → 1.1.16
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/table/index.d.ts +22 -3
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/components/table/index.tsx +75 -50
package/package.json
CHANGED
|
@@ -18,7 +18,27 @@ interface TableProps {
|
|
|
18
18
|
[key: string]: any;
|
|
19
19
|
}[];
|
|
20
20
|
options?: {
|
|
21
|
-
|
|
21
|
+
toolbar?: {
|
|
22
|
+
addData?: {
|
|
23
|
+
show?: boolean;
|
|
24
|
+
onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
25
|
+
};
|
|
26
|
+
search?: {
|
|
27
|
+
show?: boolean;
|
|
28
|
+
};
|
|
29
|
+
filter?: {
|
|
30
|
+
show?: boolean;
|
|
31
|
+
};
|
|
32
|
+
export?: {
|
|
33
|
+
show?: boolean;
|
|
34
|
+
};
|
|
35
|
+
columnSearch?: {
|
|
36
|
+
show?: boolean;
|
|
37
|
+
};
|
|
38
|
+
pagination?: {
|
|
39
|
+
show?: boolean;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
22
42
|
hideNumberColumn?: boolean;
|
|
23
43
|
enableBorder?: boolean;
|
|
24
44
|
maxRow?: 10 | 20 | 50 | 100;
|
|
@@ -36,8 +56,7 @@ interface TableProps {
|
|
|
36
56
|
}[]
|
|
37
57
|
) => void;
|
|
38
58
|
};
|
|
39
|
-
|
|
40
|
-
onAddData?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
59
|
+
actionColumn?: (e: any) => React.ReactNode;
|
|
41
60
|
}
|
|
42
61
|
|
|
43
62
|
interface TableComponentProps extends React.FC<TableProps> {
|
|
@@ -50,8 +69,7 @@ export const Table: TableComponentProps = ({
|
|
|
50
69
|
data,
|
|
51
70
|
options,
|
|
52
71
|
checkbox,
|
|
53
|
-
|
|
54
|
-
onAddData,
|
|
72
|
+
actionColumn,
|
|
55
73
|
}) => {
|
|
56
74
|
const [search, setSearch] = useState<string>("");
|
|
57
75
|
const [filter, setFilter] = useState<any[]>([]);
|
|
@@ -164,30 +182,32 @@ export const Table: TableComponentProps = ({
|
|
|
164
182
|
}`}
|
|
165
183
|
/>
|
|
166
184
|
</button>
|
|
167
|
-
|
|
168
|
-
<
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
185
|
+
{options?.toolbar?.columnSearch?.show !== false && (
|
|
186
|
+
<div className="relative flex items-center">
|
|
187
|
+
<input
|
|
188
|
+
type="search"
|
|
189
|
+
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"
|
|
190
|
+
placeholder="search.."
|
|
191
|
+
value={
|
|
192
|
+
filter.find((filterItem) => filterItem.key === item.key)
|
|
193
|
+
?.value
|
|
194
|
+
}
|
|
195
|
+
onChange={(e) => {
|
|
196
|
+
setFilter(
|
|
197
|
+
filter.map((filterItem) => {
|
|
198
|
+
return filterItem.key === item.key
|
|
199
|
+
? { ...filterItem, value: e.target.value }
|
|
200
|
+
: filterItem;
|
|
201
|
+
})
|
|
202
|
+
);
|
|
203
|
+
}}
|
|
204
|
+
/>
|
|
205
|
+
<Icon
|
|
206
|
+
icon="ic:round-search"
|
|
207
|
+
className="absolute text-sm text-slate-400"
|
|
208
|
+
/>
|
|
209
|
+
</div>
|
|
210
|
+
)}
|
|
191
211
|
</div>
|
|
192
212
|
</th>
|
|
193
213
|
);
|
|
@@ -260,9 +280,9 @@ export const Table: TableComponentProps = ({
|
|
|
260
280
|
);
|
|
261
281
|
}
|
|
262
282
|
})}
|
|
263
|
-
{
|
|
283
|
+
{actionColumn && (
|
|
264
284
|
<td className="px-4 py-1 border-b bg-secondary-bg text-center">
|
|
265
|
-
{
|
|
285
|
+
{actionColumn(item)}
|
|
266
286
|
</td>
|
|
267
287
|
)}
|
|
268
288
|
</tr>
|
|
@@ -271,21 +291,22 @@ export const Table: TableComponentProps = ({
|
|
|
271
291
|
|
|
272
292
|
return (
|
|
273
293
|
<div className="flex flex-col gap-6 h-full">
|
|
274
|
-
|
|
275
|
-
<
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
onClick
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
294
|
+
<div className="flex justify-between items-center gap-4 w-full h-fit">
|
|
295
|
+
<span className="text-lg">{title}</span>
|
|
296
|
+
<div className="flex items-center gap-4">
|
|
297
|
+
{options?.toolbar?.addData?.show !== false && (
|
|
298
|
+
<button
|
|
299
|
+
type="button"
|
|
300
|
+
className="p-1.5 rounded-full bg-primary text-white hover:bg-primary-dark"
|
|
301
|
+
onClick={(e) => {
|
|
302
|
+
options?.toolbar?.addData?.onClick &&
|
|
303
|
+
options?.toolbar?.addData?.onClick(e);
|
|
304
|
+
}}
|
|
305
|
+
>
|
|
306
|
+
<Icon icon="ic:round-plus" className="text-2xl" />
|
|
307
|
+
</button>
|
|
308
|
+
)}
|
|
309
|
+
{options?.toolbar?.filter?.show !== false && (
|
|
289
310
|
<Dropdown
|
|
290
311
|
trigger={
|
|
291
312
|
<button
|
|
@@ -319,6 +340,8 @@ export const Table: TableComponentProps = ({
|
|
|
319
340
|
);
|
|
320
341
|
})}
|
|
321
342
|
</Dropdown>
|
|
343
|
+
)}
|
|
344
|
+
{options?.toolbar?.search?.show !== false && (
|
|
322
345
|
<Form.Search
|
|
323
346
|
options={{ width: "fit" }}
|
|
324
347
|
placeholder="search.."
|
|
@@ -327,6 +350,8 @@ export const Table: TableComponentProps = ({
|
|
|
327
350
|
setSearch(e.target.value);
|
|
328
351
|
}}
|
|
329
352
|
/>
|
|
353
|
+
)}
|
|
354
|
+
{options?.toolbar?.export?.show !== false && (
|
|
330
355
|
<Button
|
|
331
356
|
type="button"
|
|
332
357
|
options={{ variant: "primary", width: "fit" }}
|
|
@@ -339,9 +364,9 @@ export const Table: TableComponentProps = ({
|
|
|
339
364
|
>
|
|
340
365
|
Export
|
|
341
366
|
</Button>
|
|
342
|
-
|
|
367
|
+
)}
|
|
343
368
|
</div>
|
|
344
|
-
|
|
369
|
+
</div>
|
|
345
370
|
<div
|
|
346
371
|
className={`overflow-auto ${height} ${
|
|
347
372
|
options?.enableBorder && "border rounded-md"
|
|
@@ -387,7 +412,7 @@ export const Table: TableComponentProps = ({
|
|
|
387
412
|
</th>
|
|
388
413
|
)}
|
|
389
414
|
{headerArr}
|
|
390
|
-
{
|
|
415
|
+
{actionColumn && (
|
|
391
416
|
<th className="w-min px-4 py-2 bg-secondary-bg font-medium text-center">
|
|
392
417
|
<div className="flex flex-col">
|
|
393
418
|
<span>Actions</span>
|
|
@@ -405,7 +430,7 @@ export const Table: TableComponentProps = ({
|
|
|
405
430
|
<tbody>{dataArr}</tbody>
|
|
406
431
|
</table>
|
|
407
432
|
</div>
|
|
408
|
-
{
|
|
433
|
+
{options?.toolbar?.pagination?.show !== false && (
|
|
409
434
|
<div className="flex justify-between items-end gap-2 w-full h-fit">
|
|
410
435
|
<div className="!text-sm">
|
|
411
436
|
<Form.Select
|