rez-table-listing-mui 2.0.11 → 2.0.13

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": "2.0.11",
3
+ "version": "2.0.13",
4
4
  "type": "module",
5
5
  "description": "A rez table listing component built on TanStack Table",
6
6
  "main": "dist/index.js",
@@ -27,6 +27,10 @@ const FormMultiSelect = ({
27
27
  }) => {
28
28
  const options = dropdownData[filter.filter_attribute] || [];
29
29
 
30
+ // 🔑 single source of truth
31
+ const getOptionValue = (item: DropdownOption) =>
32
+ isFlatJson ? item.label : item.value;
33
+
30
34
  return (
31
35
  <Controller
32
36
  name={`${filter?.filter_attribute_name}.value`}
@@ -65,26 +69,30 @@ const FormMultiSelect = ({
65
69
  const filtered = Array.isArray(selected)
66
70
  ? selected.filter(Boolean)
67
71
  : [];
72
+
68
73
  return filtered
69
- .map(
70
- (val) =>
71
- options.find((item) => item.value === val)?.label || val
72
- )
74
+ .map((val) => {
75
+ const match = options.find(
76
+ (item) => getOptionValue(item) === val
77
+ );
78
+ return match?.label || val;
79
+ })
73
80
  .join(", ");
74
81
  }}
75
82
  >
76
- {options?.map((item, idx) => (
77
- <MenuItem
78
- key={idx}
79
- value={isFlatJson ? item.label : item.value}
80
- >
81
- <Checkbox
82
- checked={cleanedValue.includes(item.value)}
83
- sx={{ marginRight: 1 }}
84
- />
85
- {item.label}
86
- </MenuItem>
87
- ))}
83
+ {options.map((item, idx) => {
84
+ const optionValue = getOptionValue(item);
85
+
86
+ return (
87
+ <MenuItem key={idx} value={optionValue}>
88
+ <Checkbox
89
+ checked={cleanedValue.includes(optionValue)}
90
+ sx={{ marginRight: 1 }}
91
+ />
92
+ {item.label}
93
+ </MenuItem>
94
+ );
95
+ })}
88
96
  </Select>
89
97
  </FormControl>
90
98
  );
@@ -38,6 +38,7 @@ const QuickTab = ({
38
38
  tabsApiDataLoading,
39
39
  activeTab,
40
40
  columnTabAttributes,
41
+ isFlatJson,
41
42
  }: SettingsQuickTabProps) => {
42
43
  const {
43
44
  settingsData,
@@ -65,6 +66,10 @@ const QuickTab = ({
65
66
  // // tab?.tab_name?.label?.toLowerCase() == activeTab?.toLowerCase()
66
67
  // );
67
68
  // In case there is no quick tab state from API
69
+ const normalizeTabItem = (item: any) => ({
70
+ label: item.label,
71
+ value: isFlatJson ? item.label : item.value,
72
+ });
68
73
  useEffect(() => {
69
74
  const stateToArray =
70
75
  (quickTabStates && Object.entries(quickTabStates)) || [];
@@ -86,12 +91,14 @@ const QuickTab = ({
86
91
  useEffect(() => {
87
92
  if (currentQuickAttribute === settingsData?.quick_tab?.attribute) return;
88
93
 
94
+ const normalizedTabs = tabsApiData?.map(normalizeTabItem) || [];
95
+
89
96
  if (tabsApiData?.length) {
90
97
  setSettingsData((prev) => ({
91
98
  ...prev,
92
99
  quick_tab: {
93
100
  ...prev?.quick_tab,
94
- hide_list: tabsApiData,
101
+ hide_list: normalizedTabs,
95
102
  show_list: [],
96
103
  },
97
104
  }));
@@ -178,10 +185,14 @@ const QuickTab = ({
178
185
  // Convert show_list/hide_list to FilterValue[] for rendering only
179
186
 
180
187
  const constructHideList = () => {
181
- return tabsApiData?.filter(
182
- (tab) => !showListValues?.find((i) => i.value === tab.value)
188
+ const normalizedTabs = tabsApiData?.map(normalizeTabItem) || [];
189
+
190
+ // remove items already in show_list (value-safe comparison)
191
+ return normalizedTabs?.filter(
192
+ (tab) => !showListValues?.some((i) => i?.value === tab?.value)
183
193
  );
184
194
  };
195
+
185
196
  const showListValues = quickTabStates?.show_list || [];
186
197
  const hideListValues = constructHideList() || [];
187
198
 
@@ -25,6 +25,7 @@ import { useFullscreenPopoverContainer } from "../../libs/hooks/useFullScreen";
25
25
 
26
26
  export function QuickFilterSettings({
27
27
  view = "listing",
28
+ isFlatJson,
28
29
  show,
29
30
  filterSettingStates,
30
31
  onClose,
@@ -146,6 +147,7 @@ export function QuickFilterSettings({
146
147
  tabsApiDataLoading={tabsApiDataLoading}
147
148
  activeTab={activeTab}
148
149
  columnTabAttributes={columnTabAttributes}
150
+ isFlatJson={isFlatJson}
149
151
  />
150
152
  )}
151
153
  </CustomTabPanel>
@@ -3,6 +3,7 @@ import { craftTableFilterSettingsOptionsProps } from "./table-options";
3
3
 
4
4
  export interface QuickFilterModalProps {
5
5
  view?: string;
6
+ isFlatJson: boolean;
6
7
  show?: boolean;
7
8
  filterSettingStates: craftTableFilterSettingsOptionsProps;
8
9
  onClose?: () => void;
@@ -102,6 +103,7 @@ export interface SettingsQuickTabProps {
102
103
  activeTab?: string;
103
104
  columnTabAttributes?: any[];
104
105
  columnTabAttributesLoading?: boolean;
106
+ isFlatJson: boolean;
105
107
  }
106
108
 
107
109
  export interface SettingsDataProps {
@@ -503,6 +503,7 @@ function ListingView() {
503
503
 
504
504
  <QuickFilterSettings
505
505
  view="listing"
506
+ isFlatJson={metaQuery.data?.is_flat_json || false}
506
507
  filterSettingStates={filterSettingStates}
507
508
  onClose={() => setShowListViewSettings(false)}
508
509
  columnsData={metaQuery.data || {}}