rez-table-listing-mui 1.2.11 → 1.2.12

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": "rez-table-listing-mui",
3
- "version": "1.2.11",
3
+ "version": "1.2.12",
4
4
  "type": "module",
5
5
  "description": "A rez table listing component built on TanStack Table",
6
6
  "main": "dist/index.js",
package/src/App.tsx CHANGED
@@ -26,13 +26,14 @@ import { SettingsDataProps } from "./types/filter-settings";
26
26
  import { FilterMasterStateProps } from "./types/filter";
27
27
  import { ColumnDef } from "@tanstack/react-table";
28
28
  import { ENTITY_TYPE } from "./libs/utils/common";
29
+ import { makeData, Person } from "./libs/utils/make-hierar-data";
29
30
 
30
31
  function App() {
31
32
  // const [mockLoading, setMockLoading] = useState<boolean>(true);
32
33
  // const [jsonData] = useState<any[]>([]);
33
34
  const [columns, setColumns] = useState<any[]>([]);
34
35
  const [searchTerm, setSearchTerm] = useState("");
35
- // const [data, setData] = useState<Person[]>(() => makeData(50, 3, 2));
36
+ const [data, setData] = useState<Person[]>(() => makeData(200, 3, 2));
36
37
 
37
38
  const [selectedTab, setSelectedTab] = useState("All");
38
39
 
@@ -225,6 +226,7 @@ function App() {
225
226
  fontWeight: 500,
226
227
  borderRadius: "4px",
227
228
  padding: "4px",
229
+ width: "fit-content",
228
230
  }}
229
231
  >
230
232
  {statusValue}
@@ -339,6 +341,8 @@ function App() {
339
341
 
340
342
  <TableWrapper
341
343
  data={filteredData}
344
+ // data={data}
345
+ // columns={defaultColumns}
342
346
  columns={columns && columns.length > 0 ? columns : defaultColumns}
343
347
  tableStates={tableStates}
344
348
  featureOptions={{
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  ColumnDef,
3
+ ColumnMeta,
3
4
  getCoreRowModel,
4
5
  getExpandedRowModel,
5
6
  getPaginationRowModel,
@@ -21,6 +22,10 @@ import TableDND from "./table-dnd";
21
22
  import Table from "./table";
22
23
  import { useFullscreenPopoverContainer } from "../libs/hooks/useFullScreen";
23
24
 
25
+ interface CustomColumnMeta<T> extends ColumnMeta<T, unknown> {
26
+ defaultPinned?: "left" | "right" | undefined;
27
+ }
28
+
24
29
  function TableWrapper<T>({
25
30
  data = [],
26
31
  columns = [],
@@ -85,6 +90,17 @@ function TableWrapper<T>({
85
90
  }
86
91
  }, [columns]);
87
92
 
93
+ //For Default Column Pinning to work
94
+ useEffect(() => {
95
+ table.getAllLeafColumns().forEach((col) => {
96
+ const where = (col.columnDef.meta as CustomColumnMeta<T>)
97
+ ?.defaultPinned as "left" | "right" | undefined;
98
+ if (where && !col.getIsPinned()) {
99
+ col.pin(where);
100
+ }
101
+ });
102
+ }, [tableStates?.columnPinning?.left, metaColumns]);
103
+
88
104
  const [columnOrder, setColumnOrder] = useState<string[]>(() =>
89
105
  metaColumns.map((c) => c.id!)
90
106
  );
@@ -108,31 +108,33 @@ const QuickTab = ({
108
108
  );
109
109
 
110
110
  // Update the error state
111
- setSaveButtonError((prev) => {
112
- const otherMessages =
113
- prev?.messages?.filter((message) => message.type !== ERROR_CODE) ||
114
- [];
115
-
116
- return {
117
- ...prev,
118
- hasError: true,
119
- messages: hasQuickTabError
120
- ? [...prev?.messages]
121
- : [...otherMessages, errorMessage],
122
- };
123
- });
111
+
112
+ // Later we can use this to show error message when we will make error logic more simple
113
+ // setSaveButtonError((prev) => {
114
+ // const otherMessages =
115
+ // prev?.messages?.filter((message) => message.type !== ERROR_CODE) ||
116
+ // [];
117
+
118
+ // return {
119
+ // ...prev,
120
+ // hasError: true,
121
+ // messages: hasQuickTabError
122
+ // ? [...prev?.messages]
123
+ // : [...otherMessages, errorMessage],
124
+ // };
125
+ // });
124
126
  } else {
125
127
  const hasOtherMessages = saveButtonError?.messages?.some(
126
128
  (message) => message.type !== ERROR_CODE
127
129
  );
128
130
  // Reset error state if the list is valid
129
- setSaveButtonError((prev) => ({
130
- ...prev,
131
- hasError: hasOtherMessages,
132
- messages:
133
- prev?.messages?.filter((message) => message.type !== ERROR_CODE) ||
134
- [],
135
- }));
131
+ // setSaveButtonError((prev) => ({
132
+ // ...prev,
133
+ // hasError: hasOtherMessages,
134
+ // messages:
135
+ // prev?.messages?.filter((message) => message.type !== ERROR_CODE) ||
136
+ // [],
137
+ // }));
136
138
  }
137
139
  }
138
140
  }, [quickTabStates?.hide_list, quickTabStates?.show_list]);
@@ -149,6 +149,7 @@ export function QuickFilterSettings({
149
149
  <DialogActions>
150
150
  <CustomButton
151
151
  // disabled={saveButtonError?.hasError}
152
+ disabled={saveButtonError?.hasError}
152
153
  onClick={handleSaveSetSettingsData}
153
154
  >
154
155
  Save Quick Filter
@@ -1,4 +1,5 @@
1
1
  import {
2
+ ColumnPinningState,
2
3
  ExpandedState,
3
4
  PaginationState,
4
5
  RowSelectionState,
@@ -49,6 +50,12 @@ export function useCraftTable(paginationPageSize: number = 25) {
49
50
  );
50
51
  }
51
52
 
53
+ // For Default Column Pinning
54
+ const [columnPinning, setColumnPinning] = useState<ColumnPinningState>({
55
+ left: [],
56
+ right: [],
57
+ });
58
+
52
59
  const craftTableOptions: CraftTableOptionsProps = {
53
60
  sorting: sorting,
54
61
  setSorting: setSorting,
@@ -74,6 +81,8 @@ export function useCraftTable(paginationPageSize: number = 25) {
74
81
  setShowTableFilter: setShowTableFilter,
75
82
  showFilterOptions: showFilterOptions,
76
83
  setShowFilterOption: setShowFilterOption,
84
+ columnPinning: columnPinning,
85
+ setColumnPinning: setColumnPinning,
77
86
  };
78
87
 
79
88
  return craftTableOptions;
@@ -58,7 +58,7 @@ export const useDefaultColumns = () => {
58
58
  header: "Last Name",
59
59
  accessorKey: "lastName",
60
60
  size: 100,
61
- meta: { label: "Last Name" },
61
+ meta: { label: "Last Name", defaultPinned: "left" },
62
62
  },
63
63
  {
64
64
  header: "Email Id",
@@ -97,6 +97,7 @@ export const useDefaultColumns = () => {
97
97
  label: "Status",
98
98
  type: "custom",
99
99
  propName: "renderStatus",
100
+ align: "right",
100
101
  },
101
102
  },
102
103
  {
@@ -106,6 +107,7 @@ export const useDefaultColumns = () => {
106
107
  label: "Action",
107
108
  type: "custom",
108
109
  propName: "renderAction",
110
+ align: "right",
109
111
  },
110
112
  },
111
113
  ],
@@ -3,6 +3,7 @@ import {
3
3
  RowSelectionState,
4
4
  SortingState,
5
5
  ExpandedState,
6
+ ColumnPinningState,
6
7
  } from "@tanstack/react-table";
7
8
  import { Dispatch, SetStateAction } from "react";
8
9
  import {
@@ -45,6 +46,8 @@ export interface CraftTableOptionsProps {
45
46
  setShowTableFilter: Dispatch<SetStateAction<boolean>>;
46
47
  showFilterOptions: boolean;
47
48
  setShowFilterOption: Dispatch<SetStateAction<boolean>>;
49
+ columnPinning: ColumnPinningState;
50
+ setColumnPinning: Dispatch<SetStateAction<ColumnPinningState>>;
48
51
  }
49
52
 
50
53
  export interface craftTableFilterSettingsOptionsProps {