@evenicanpm/portal-table-ui 2.0.1 → 2.1.0
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 +2 -2
- package/src/features/table/components/dashboard/table/bulk-action-button.tsx +10 -4
- package/src/features/table/components/dashboard/table/table-header.tsx +1 -1
- package/src/features/table/components/dashboard/table/table-input.tsx +6 -2
- package/src/features/table/components/dashboard/table/table-row/action-button.tsx +4 -1
- package/src/features/table/components/dashboard/table/table-row/table-row.tsx +2 -9
- package/src/features/table/components/dashboard/table/table.tsx +6 -3
- package/src/features/table/components/dashboard/table-dashboard.tsx +15 -0
- package/src/features/table/types/schemas.ts +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evenicanpm/portal-table-ui",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"@tanstack/react-query": "^5.90.11",
|
|
48
48
|
"date-fns": "^4.1.0"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "8227589295d3d63586f9b26fff8d643b070989b3"
|
|
51
51
|
}
|
|
@@ -25,11 +25,17 @@ export function BulkActionButton({
|
|
|
25
25
|
const { mutate, isPending } = useMutation(mutationOptions);
|
|
26
26
|
|
|
27
27
|
const handleClick = () => {
|
|
28
|
-
mutate(
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
mutate(
|
|
29
|
+
{
|
|
30
|
+
resourceName,
|
|
31
|
+
selectedIds,
|
|
31
32
|
},
|
|
32
|
-
|
|
33
|
+
{
|
|
34
|
+
onSuccess: () => {
|
|
35
|
+
clearSelection();
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
);
|
|
33
39
|
};
|
|
34
40
|
|
|
35
41
|
const Icon = action.icon;
|
|
@@ -78,10 +78,14 @@ const SearchField = React.memo(
|
|
|
78
78
|
onChange={(e) => {
|
|
79
79
|
setSearchTerm(e.target.value);
|
|
80
80
|
}}
|
|
81
|
-
placeholder={
|
|
81
|
+
placeholder={
|
|
82
|
+
selectedColumn?.Label
|
|
83
|
+
? `Search by ${selectedColumn.Label}`
|
|
84
|
+
: "Select a column to search"
|
|
85
|
+
}
|
|
82
86
|
endAdornment={
|
|
83
87
|
<ColumnSelect
|
|
84
|
-
selected={selectedColumn
|
|
88
|
+
selected={selectedColumn?.Data || ""}
|
|
85
89
|
searchCols={searchCols}
|
|
86
90
|
handleChange={(value) => {
|
|
87
91
|
const col = searchCols.find((c) => c.Data === value);
|
|
@@ -14,15 +14,8 @@ type ColumnLogic =
|
|
|
14
14
|
| {
|
|
15
15
|
id: string;
|
|
16
16
|
mask: string | undefined;
|
|
17
|
-
maskFn: unknown;
|
|
18
|
-
cellFn:
|
|
19
|
-
| ((
|
|
20
|
-
value: string | number | string[],
|
|
21
|
-
) => React.ReactElement<
|
|
22
|
-
unknown,
|
|
23
|
-
string | React.JSXElementConstructor<unknown>
|
|
24
|
-
>)
|
|
25
|
-
| ((value: string | number) => string | number);
|
|
17
|
+
maskFn: (value: unknown, mask?: string) => string | number | string[];
|
|
18
|
+
cellFn: (value: string | number | string[]) => React.ReactNode;
|
|
26
19
|
}[]
|
|
27
20
|
| undefined;
|
|
28
21
|
|
|
@@ -152,15 +152,18 @@ export default function DocumentTable({
|
|
|
152
152
|
|
|
153
153
|
// Depends on searchableCols, must be declared after transformer
|
|
154
154
|
const [searchColumn, setSearchColumn] = useState<Column>(
|
|
155
|
-
() => searchableCols?.[0],
|
|
155
|
+
() => searchableCols?.[0] as Column,
|
|
156
156
|
);
|
|
157
157
|
|
|
158
|
+
// always derive a safe usable column
|
|
159
|
+
const effectiveSearchColumn = searchColumn ?? searchableCols?.[0];
|
|
160
|
+
|
|
158
161
|
const { data: fetchedRows, isPending: rowsPending } = useQuery(
|
|
159
162
|
resource.rowsQueryFn({
|
|
160
163
|
page,
|
|
161
164
|
pageSize: pageSize + 1, // Fetch one extra to check if there's a next page
|
|
162
165
|
filters,
|
|
163
|
-
searchColumn:
|
|
166
|
+
searchColumn: effectiveSearchColumn?.Data || "",
|
|
164
167
|
searchTerm,
|
|
165
168
|
}),
|
|
166
169
|
);
|
|
@@ -281,7 +284,7 @@ export default function DocumentTable({
|
|
|
281
284
|
setSearchTerm={setSearchTerm}
|
|
282
285
|
setColumn={setSearchColumn}
|
|
283
286
|
searchCols={searchableCols || []}
|
|
284
|
-
selectedColumn={
|
|
287
|
+
selectedColumn={effectiveSearchColumn}
|
|
285
288
|
/>
|
|
286
289
|
{filterLogic?.map((filter) => (
|
|
287
290
|
<filter.FilterComponent
|
|
@@ -62,6 +62,21 @@ export const TableDashboard = ({ resources, viewConfigQuery }: TableProps) => {
|
|
|
62
62
|
pageSize={pageSize}
|
|
63
63
|
setPageSize={setPageSize}
|
|
64
64
|
/>
|
|
65
|
+
{/* CHILD TABLE */}
|
|
66
|
+
{resource.children?.length ? (
|
|
67
|
+
<Box mt={6}>
|
|
68
|
+
{resource.children.map((child, idx) => (
|
|
69
|
+
<Box key={child.name + String(idx)} mt={4}>
|
|
70
|
+
<Table
|
|
71
|
+
viewConfigQuery={viewConfigQuery}
|
|
72
|
+
resource={child}
|
|
73
|
+
pageSize={pageSize}
|
|
74
|
+
setPageSize={setPageSize}
|
|
75
|
+
/>
|
|
76
|
+
</Box>
|
|
77
|
+
))}
|
|
78
|
+
</Box>
|
|
79
|
+
) : null}
|
|
65
80
|
</TabPanel>
|
|
66
81
|
</Box>
|
|
67
82
|
))}
|