next-helios-fe 1.8.121 → 1.8.122
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/index.js +1 -1
- package/package.json +1 -1
- package/src/components/table/index.tsx +57 -38
package/package.json
CHANGED
@@ -117,6 +117,8 @@ export const Table: TableComponentProps = ({
|
|
117
117
|
column: "",
|
118
118
|
order: "",
|
119
119
|
});
|
120
|
+
const [isReadyForDynamicValue, setIsReadyForDynamicValue] =
|
121
|
+
useState<boolean>(false);
|
120
122
|
|
121
123
|
const height =
|
122
124
|
options?.height === "fit"
|
@@ -148,36 +150,43 @@ export const Table: TableComponentProps = ({
|
|
148
150
|
})
|
149
151
|
);
|
150
152
|
|
151
|
-
|
153
|
+
if (data.length !== 0) {
|
154
|
+
const tempCategoryFilter: any = {};
|
152
155
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
156
|
+
header
|
157
|
+
?.filter((item) => item.type === "category")
|
158
|
+
?.map((item) => {
|
159
|
+
const tempDataByCategory: string[] = [];
|
157
160
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
161
|
+
data
|
162
|
+
.map((dataItem) => dataItem[item.key as keyof typeof dataItem])
|
163
|
+
.sort((a, b) =>
|
164
|
+
(a === undefined
|
165
|
+
? "undefined"
|
166
|
+
: a === null
|
167
|
+
? "null"
|
168
|
+
: a.toString()
|
169
|
+
).localeCompare(
|
170
|
+
b === undefined
|
171
|
+
? "undefined"
|
172
|
+
: b === null
|
173
|
+
? "null"
|
174
|
+
: b.toString()
|
175
|
+
)
|
168
176
|
)
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
}
|
175
|
-
});
|
177
|
+
.filter((value, index, self) => self.indexOf(value) === index)
|
178
|
+
.map((value) => {
|
179
|
+
if (!tempDataByCategory.includes(value)) {
|
180
|
+
tempDataByCategory.push(value);
|
181
|
+
}
|
182
|
+
});
|
176
183
|
|
177
|
-
|
178
|
-
|
184
|
+
tempCategoryFilter[item.key] = tempDataByCategory;
|
185
|
+
});
|
179
186
|
|
180
|
-
|
187
|
+
setCategoryFilter(tempCategoryFilter);
|
188
|
+
setIsReadyForDynamicValue(true);
|
189
|
+
}
|
181
190
|
}, [data]);
|
182
191
|
|
183
192
|
useEffect(() => {
|
@@ -299,17 +308,27 @@ export const Table: TableComponentProps = ({
|
|
299
308
|
|
300
309
|
useEffect(() => {
|
301
310
|
if (getDynamicTableValue) {
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
+
if (isReadyForDynamicValue) {
|
312
|
+
getDynamicTableValue({
|
313
|
+
search,
|
314
|
+
page,
|
315
|
+
dataOffset: (page - 1) * maxRow,
|
316
|
+
maxRow,
|
317
|
+
filter,
|
318
|
+
categoryFilter,
|
319
|
+
sortBy,
|
320
|
+
});
|
321
|
+
}
|
311
322
|
}
|
312
|
-
}, [
|
323
|
+
}, [
|
324
|
+
isReadyForDynamicValue,
|
325
|
+
search,
|
326
|
+
page,
|
327
|
+
maxRow,
|
328
|
+
filter,
|
329
|
+
categoryFilter,
|
330
|
+
sortBy,
|
331
|
+
]);
|
313
332
|
|
314
333
|
const headerArr = header
|
315
334
|
?.filter((item) => !excludedColumn?.includes(item.key))
|
@@ -396,7 +415,7 @@ export const Table: TableComponentProps = ({
|
|
396
415
|
onClick={() => {
|
397
416
|
const tempCategoryFilter = { ...categoryFilter };
|
398
417
|
|
399
|
-
if (categoryFilter[item.key]
|
418
|
+
if (categoryFilter[item.key]?.includes(value)) {
|
400
419
|
tempCategoryFilter[item.key] = categoryFilter[
|
401
420
|
item.key
|
402
421
|
].filter(
|
@@ -424,7 +443,7 @@ export const Table: TableComponentProps = ({
|
|
424
443
|
: value?.toString()
|
425
444
|
}
|
426
445
|
checked={
|
427
|
-
categoryFilter[item.key]
|
446
|
+
categoryFilter[item.key]?.includes(value) ??
|
428
447
|
false
|
429
448
|
}
|
430
449
|
readOnly
|
@@ -568,7 +587,7 @@ export const Table: TableComponentProps = ({
|
|
568
587
|
return (
|
569
588
|
<td
|
570
589
|
key={headerItem.key}
|
571
|
-
className="max-w-60 bg-secondary-bg px-4 py-1.5"
|
590
|
+
className="min-w-32 max-w-60 bg-secondary-bg px-4 py-1.5"
|
572
591
|
>
|
573
592
|
<Tooltip
|
574
593
|
content={item[headerItem.key as keyof typeof item] || "-"}
|