@visns-studio/visns-components 2.8.5 → 2.8.7

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.
@@ -226,8 +226,65 @@ const DataGrid = forwardRef(
226
226
  }
227
227
  }, []);
228
228
 
229
- const handleFilterChange = useCallback((d) => {
230
- setFilterValue(d);
229
+ const findUpdatedFilter = (filters, currentValues) => {
230
+ for (const filter of filters) {
231
+ const matchingCurrentValue = currentValues.find(
232
+ (currentValue) => currentValue.name === filter.name
233
+ );
234
+
235
+ if (
236
+ matchingCurrentValue &&
237
+ filter.value !== matchingCurrentValue.value
238
+ ) {
239
+ return {
240
+ key: filter.key || '',
241
+ name: filter.name,
242
+ oldValue: matchingCurrentValue.value,
243
+ newValue: filter.value,
244
+ };
245
+ }
246
+ }
247
+
248
+ return null; // No changes found
249
+ };
250
+
251
+ const handleFilterChange = useCallback((filters, currentValues) => {
252
+ const updatedFilter = findUpdatedFilter(filters, currentValues);
253
+ let updatedFilters = filters;
254
+ let resetMappings = [];
255
+
256
+ filters.forEach((filter) => {
257
+ if (filter.reset?.length > 0) {
258
+ filter.reset.forEach((childId) => {
259
+ resetMappings.push({ childId, parentId: filter.name });
260
+ });
261
+ }
262
+ });
263
+
264
+ filters.forEach((filter, index) => {
265
+ if (
266
+ filter.key &&
267
+ resetMappings.some(
268
+ (mapping) => mapping.childId === filter.key
269
+ )
270
+ ) {
271
+ resetMappings.forEach((mapping) => {
272
+ if (
273
+ updatedFilter &&
274
+ mapping.childId === filter.key &&
275
+ mapping.parentId === updatedFilter.name
276
+ ) {
277
+ updatedFilters[index].value = '';
278
+ gridRef.current.setColumnFilterValue(
279
+ updatedFilters[index].name,
280
+ null
281
+ );
282
+ }
283
+ });
284
+ }
285
+ });
286
+
287
+ setFilterValue(filters);
231
288
  }, []);
232
289
 
233
290
  const handleChangeSearch = (e) => {
@@ -2068,8 +2125,8 @@ const DataGrid = forwardRef(
2068
2125
  headerProps={headerProps}
2069
2126
  idProperty="id"
2070
2127
  minRowHeight={40}
2071
- onFilterValueChange={(filterValue) => {
2072
- handleFilterChange(filterValue);
2128
+ onFilterValueChange={(fv) => {
2129
+ handleFilterChange(fv, filterValue);
2073
2130
  }}
2074
2131
  onLimitChange={setLimit}
2075
2132
  onSelectionChange={handleSelectionChange}
@@ -227,6 +227,7 @@ function Field({
227
227
  'plainrelationarray',
228
228
  'plaintext',
229
229
  'richeditor',
230
+ 'time',
230
231
  ].includes(settings.type)
231
232
  ) {
232
233
  return (
@@ -667,6 +668,7 @@ function Field({
667
668
  'plainrelationarray',
668
669
  'plaintext',
669
670
  'richeditor',
671
+ 'time',
670
672
  'toggle',
671
673
  ].includes(settings.type)
672
674
  ) {
package/package.json CHANGED
@@ -44,7 +44,7 @@
44
44
  "react-dom": "^17.0.1"
45
45
  },
46
46
  "name": "@visns-studio/visns-components",
47
- "version": "2.8.5",
47
+ "version": "2.8.7",
48
48
  "description": "Various packages to assist in the development of our Custom Applications.",
49
49
  "main": "index.js",
50
50
  "scripts": {