sag_components 2.0.0-beta238 → 2.0.0-beta239
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/dist/index.esm.js +43 -25
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +43 -25
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -40797,25 +40797,48 @@ const TableHeader = ({
|
|
|
40797
40797
|
// Ref for the popup content to measure its dimensions
|
|
40798
40798
|
const popupRef = useRef(null);
|
|
40799
40799
|
|
|
40800
|
-
// Initialize filter selections for
|
|
40800
|
+
// FIXED: Initialize filter selections ONLY for new columns, preserve existing selections
|
|
40801
40801
|
useEffect(() => {
|
|
40802
|
-
|
|
40803
|
-
|
|
40804
|
-
|
|
40805
|
-
|
|
40806
|
-
|
|
40807
|
-
|
|
40808
|
-
|
|
40809
|
-
|
|
40810
|
-
|
|
40811
|
-
|
|
40812
|
-
|
|
40813
|
-
|
|
40814
|
-
|
|
40815
|
-
|
|
40816
|
-
|
|
40802
|
+
setFilterSelections(prevSelections => {
|
|
40803
|
+
const newSelections = {
|
|
40804
|
+
...prevSelections
|
|
40805
|
+
};
|
|
40806
|
+
let hasChanges = false;
|
|
40807
|
+
columns.forEach(column => {
|
|
40808
|
+
// Only initialize if column doesn't exist in state yet
|
|
40809
|
+
if (column.filter && column.filterOptions && !newSelections[column.key]) {
|
|
40810
|
+
const initialState = {};
|
|
40811
|
+
const fullList = [{
|
|
40812
|
+
value: 'All',
|
|
40813
|
+
label: 'Select All'
|
|
40814
|
+
}, ...column.filterOptions];
|
|
40815
|
+
fullList.forEach(item => {
|
|
40816
|
+
initialState[item.value] = true;
|
|
40817
|
+
});
|
|
40818
|
+
newSelections[column.key] = initialState;
|
|
40819
|
+
hasChanges = true;
|
|
40820
|
+
} else if (column.filter && column.filterOptions && newSelections[column.key]) {
|
|
40821
|
+
// Column exists - check if we need to add new options that appeared
|
|
40822
|
+
const currentSelections = newSelections[column.key];
|
|
40823
|
+
const newOptions = column.filterOptions.filter(opt => currentSelections[opt.value] === undefined);
|
|
40824
|
+
|
|
40825
|
+
// Only update if there are genuinely new options
|
|
40826
|
+
if (newOptions.length > 0) {
|
|
40827
|
+
const updatedSelections = {
|
|
40828
|
+
...currentSelections
|
|
40829
|
+
};
|
|
40830
|
+
newOptions.forEach(opt => {
|
|
40831
|
+
updatedSelections[opt.value] = true; // New options start selected
|
|
40832
|
+
});
|
|
40833
|
+
newSelections[column.key] = updatedSelections;
|
|
40834
|
+
hasChanges = true;
|
|
40835
|
+
}
|
|
40836
|
+
}
|
|
40837
|
+
});
|
|
40838
|
+
|
|
40839
|
+
// Only return new object if there were actual changes
|
|
40840
|
+
return hasChanges ? newSelections : prevSelections;
|
|
40817
40841
|
});
|
|
40818
|
-
setFilterSelections(initialFilterSelections);
|
|
40819
40842
|
}, [columns]);
|
|
40820
40843
|
|
|
40821
40844
|
// Helper function to check if filter is in default state (all items selected)
|
|
@@ -41186,26 +41209,21 @@ const TableHeader = ({
|
|
|
41186
41209
|
paramType: "Week",
|
|
41187
41210
|
params: [{
|
|
41188
41211
|
label: 'From',
|
|
41189
|
-
type: 'week'
|
|
41212
|
+
type: 'week'
|
|
41190
41213
|
}, {
|
|
41191
41214
|
label: 'To',
|
|
41192
|
-
type: 'week'
|
|
41215
|
+
type: 'week'
|
|
41193
41216
|
}],
|
|
41194
|
-
radioOptions: ['All weeks', 'Custom Range']
|
|
41195
|
-
// ADDED: Pass initialValues for persistence
|
|
41196
|
-
,
|
|
41217
|
+
radioOptions: ['All weeks', 'Custom Range'],
|
|
41197
41218
|
initialValues: currentFilterState ? {
|
|
41198
41219
|
selectedRadio: currentFilterState.selectedRadio,
|
|
41199
41220
|
fields: currentFilterState.fields
|
|
41200
41221
|
} : null,
|
|
41201
41222
|
onApply: data => {
|
|
41202
|
-
// data contains: { selectedRadio, fields }
|
|
41203
41223
|
setFilterState(prev => ({
|
|
41204
41224
|
...prev,
|
|
41205
41225
|
[key]: data
|
|
41206
41226
|
}));
|
|
41207
|
-
|
|
41208
|
-
// Close the popup after applying
|
|
41209
41227
|
setVisibleFilterPopWrapper(null);
|
|
41210
41228
|
}
|
|
41211
41229
|
});
|