@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evenicanpm/portal-table-ui",
3
- "version": "2.0.1",
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": "bbaff05f6f592114ad7a25caeee531e4fa1b14cf"
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(undefined, {
29
- onSuccess: () => {
30
- clearSelection();
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;
@@ -84,7 +84,7 @@ export default function TableHeader({
84
84
  key={column.Label + String(i)}
85
85
  sx={{
86
86
  whiteSpace: "normal",
87
- wordBreak: "break-word",
87
+ wordBreak: "normal",
88
88
  }}
89
89
  >
90
90
  {column.Label}
@@ -78,10 +78,14 @@ const SearchField = React.memo(
78
78
  onChange={(e) => {
79
79
  setSearchTerm(e.target.value);
80
80
  }}
81
- placeholder={`Seach by ${selectedColumn.Label}`}
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.Data}
88
+ selected={selectedColumn?.Data || ""}
85
89
  searchCols={searchCols}
86
90
  handleChange={(value) => {
87
91
  const col = searchCols.find((c) => c.Data === value);
@@ -22,7 +22,10 @@ export function ActionButton({
22
22
 
23
23
  const handleClick = (e: React.MouseEvent) => {
24
24
  e.stopPropagation();
25
- mutate({ docId });
25
+ mutate({
26
+ docId,
27
+ resourceName: "",
28
+ });
26
29
  };
27
30
 
28
31
  if (action.icon) {
@@ -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: searchColumn?.Data,
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={searchColumn}
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
  ))}
@@ -94,4 +94,7 @@ export interface Resource {
94
94
  // Actions and Bulk Actions
95
95
  actions?: Record<string, UIAction>;
96
96
  bulkActions?: Record<string, UIBulkAction>;
97
+
98
+ // Children resources for nested tables
99
+ children?: Resource[];
97
100
  }