rez-table-listing-mui 1.3.9 → 1.3.10

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.3.9",
3
+ "version": "1.3.10",
4
4
  "type": "module",
5
5
  "description": "A rez table listing component built on TanStack Table",
6
6
  "main": "dist/index.js",
@@ -5,7 +5,6 @@ import {
5
5
  FilterComponentOptions,
6
6
  FilterDrawerProps,
7
7
  FilterMasterStateProps,
8
- TabType,
9
8
  } from "../../types/filter";
10
9
  import ConfirmModal, { InputField } from "../common/confirm-modal";
11
10
  import CustomTabPanel from "./components/tabs/custom-tab-panel";
@@ -89,10 +88,10 @@ export function TableFilter({
89
88
  }, [editModeFromTabOptions]);
90
89
 
91
90
  // Map tabs to type
92
- const tabMapping: TabType[] = [];
93
- if (showMainFilter) tabMapping.push("main");
94
- if (showSavedFilter) tabMapping.push("saved");
95
- if (showAttributesFilter) tabMapping.push("attributes");
91
+ const tabMapping: TabItem[] = [];
92
+ if (showMainFilter) tabMapping.push({ label: "Filter" });
93
+ if (showSavedFilter) tabMapping.push({ label: "Saved Filter" });
94
+ if (showAttributesFilter) tabMapping.push({ label: "Attributes" });
96
95
 
97
96
  const clearAttributeRadio = () => {
98
97
  const newFilterMaster = {
@@ -114,23 +113,16 @@ export function TableFilter({
114
113
  type: "text",
115
114
  };
116
115
 
117
- //FOR TABS
118
- const tabItems: TabItem[] = [
119
- { label: "Filter" },
120
- { label: "Saved Filter" },
121
- { label: "Attributes" },
122
- ];
123
-
124
116
  const handleTabChange = (_: React.SyntheticEvent, newValue: number) => {
125
- const tabType = tabMapping[newValue];
117
+ const tabType = tabMapping[newValue]?.label;
126
118
 
127
- if (tabType === "attributes" && tabMapping[tabValue] === "main") {
119
+ if (tabType === "Attributes" && tabMapping[tabValue]?.label === "Filter") {
128
120
  clearAttributeRadio();
129
121
  }
130
122
 
131
123
  setTabValue(newValue);
132
124
 
133
- if (tabType === "main") {
125
+ if (tabType === "Filter") {
134
126
  setEditMode(false);
135
127
 
136
128
  setFilterMaster(
@@ -145,17 +137,17 @@ export function TableFilter({
145
137
 
146
138
  setFilters([]);
147
139
 
148
- if (tabType === "saved") setEditMode(false);
140
+ if (tabType?.label === "Saved Filter") setEditMode(false);
149
141
 
150
142
  const patches: Partial<FilterMasterStateProps> = {};
151
143
 
152
- if (tabType === "saved") {
144
+ if (tabType?.label === "Saved Filter") {
153
145
  patches.saved_filters = {
154
146
  selectedId: "",
155
147
  selectedName: "",
156
148
  selectedCode: "",
157
149
  };
158
- } else if (tabType === "attributes") {
150
+ } else if (tabType?.label === "Attributes") {
159
151
  patches.attributes = { radio: [], selected: "" };
160
152
  }
161
153
 
@@ -214,7 +206,7 @@ export function TableFilter({
214
206
  <CustomTabs
215
207
  value={tabValue}
216
208
  onChange={handleTabChange}
217
- tabItems={tabItems}
209
+ tabItems={tabMapping}
218
210
  activeFilterIndex={filterMaster?.activeFilterTabIndex ?? 0}
219
211
  handleCrossClick={handleTabCrossClick}
220
212
  />
@@ -233,7 +225,7 @@ export function TableFilter({
233
225
  {showMainFilter && (
234
226
  <CustomTabPanel
235
227
  value={tabValue}
236
- index={tabMapping.indexOf("main")}
228
+ index={tabMapping.findIndex((tab) => tab.label === "Filter")}
237
229
  sx={{ p: "1.5rem 0.75rem" }}
238
230
  >
239
231
  <MainFilter
@@ -247,7 +239,7 @@ export function TableFilter({
247
239
  {showSavedFilter && (
248
240
  <CustomTabPanel
249
241
  value={tabValue}
250
- index={tabMapping.indexOf("saved")}
242
+ index={tabMapping.findIndex((tab) => tab.label === "Saved Filter")}
251
243
  sx={{ p: "1.5rem 0.75rem" }}
252
244
  >
253
245
  <SavedFilter
@@ -262,7 +254,7 @@ export function TableFilter({
262
254
  {showAttributesFilter && (
263
255
  <CustomTabPanel
264
256
  value={tabValue}
265
- index={tabMapping.indexOf("attributes")}
257
+ index={tabMapping.findIndex((tab) => tab.label === "Attributes")}
266
258
  sx={{ p: "1.5rem 0.75rem" }}
267
259
  >
268
260
  <AttributesFilter
@@ -101,7 +101,7 @@ type RecordFilterComponentProps = {
101
101
  delete: ModalConfig;
102
102
  };
103
103
 
104
- export type TabType = "main" | "saved" | "attributes";
104
+ type TabType = "main" | "saved" | "attributes";
105
105
 
106
106
  interface FilterComponentTabOptions {
107
107
  mainFilter?: FilterComponentOptionsMainFilterOptions;