@civicactions/cmsds-open-data-components 4.0.13-alpha.1 → 4.0.13-alpha.3

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/main.js CHANGED
@@ -278,7 +278,16 @@ var $11500a65bd7d9cf1$export$2e2bcd8739ae039 = $11500a65bd7d9cf1$var$HeaderConte
278
278
  const $61ff88fb3f6ee2c8$var$queryClient = new (0, $hgUW1$QueryClient)({
279
279
  defaultOptions: {
280
280
  queries: {
281
- refetchOnWindowFocus: false
281
+ // disable refetch when user returns to tab
282
+ refetchOnWindowFocus: false,
283
+ // Keep unused cache for 10 minutes (default is 5)
284
+ // Helps users navigating back/forward see cached data while refetch happens
285
+ gcTime: 600000,
286
+ // Reduce retries for slow connections
287
+ // Default is 3 with exponential backoff (can take 7+ seconds)
288
+ retry: 1,
289
+ // Fixed retry delay instead of exponential
290
+ retryDelay: 1000
282
291
  }
283
292
  }
284
293
  });
@@ -369,9 +378,15 @@ const $10bc3aae21fc1572$var$DatasetListSubmenu = ({ rootUrl: rootUrl, enablePagi
369
378
  })}`);
370
379
  }
371
380
  });
381
+ // Sync totalItems state with API response data
382
+ // Moved to useEffect to prevent state updates during render (which can cause infinite loops)
383
+ (0, $hgUW1$useEffect)(()=>{
384
+ if (data?.data?.total !== undefined && data.data.total !== totalItems) setTotalItems(data.data.total);
385
+ }, [
386
+ data?.data?.total
387
+ ]);
372
388
  let submenuItemsCount = 0;
373
389
  if (data) {
374
- if (data.data.total && totalItems !== data.data.total) setTotalItems(data.data.total);
375
390
  let resultsCount = Object.keys(data.data.results).length;
376
391
  // For the submenu pager, If there are fewer than 4 dataset items, display the dataset item count, otherwise, show "Viewing 4..".
377
392
  submenuItemsCount = resultsCount > defaultPageSize ? defaultPageSize : resultsCount;
@@ -2957,26 +2972,9 @@ const $eadd6431fddf4b6c$var$FilterItem = ({ id: id, condition: condition, index:
2957
2972
  const [property, setProperty] = (0, $hgUW1$useState)(condition.property);
2958
2973
  const [value, setValue] = (0, $hgUW1$useState)(condition.value);
2959
2974
  const [startDate, setStartDate] = (0, $hgUW1$react).useState($eadd6431fddf4b6c$var$getStartDate(condition, schema, id));
2960
- const [previousType, setPreviousType] = (0, $hgUW1$useState)(schema[id].fields[property]?.mysql_type);
2961
2975
  const xl = (0, $hgUW1$useMediaQuery)({
2962
2976
  minWidth: 1280
2963
2977
  });
2964
- // Reset value when mysql_type changes from date to another type
2965
- (0, $hgUW1$useEffect)(()=>{
2966
- const currentType = schema[id].fields[property]?.mysql_type;
2967
- if (previousType === 'date' && currentType !== 'date') {
2968
- setValue('');
2969
- update(index, 'value', '');
2970
- }
2971
- setPreviousType(currentType);
2972
- }, [
2973
- schema,
2974
- id,
2975
- property,
2976
- previousType,
2977
- index,
2978
- update
2979
- ]);
2980
2978
  (0, $hgUW1$useEffect)(()=>{
2981
2979
  if (property !== condition.property) {
2982
2980
  if (property) update(index, 'property', property);
@@ -4603,7 +4601,13 @@ const $e873081a6e8f024e$var$DatasetSearch = (props)=>{
4603
4601
  })}`);
4604
4602
  }
4605
4603
  });
4606
- if (data && data.data.total && totalItems != data.data.total) setTotalItems(data.data.total);
4604
+ // Sync totalItems state with API response data
4605
+ // Moved to useEffect to prevent state updates during render (which can cause infinite loops)
4606
+ (0, $hgUW1$useEffect)(()=>{
4607
+ if (data?.data?.total !== undefined && data.data.total !== totalItems) setTotalItems(data.data.total);
4608
+ }, [
4609
+ data?.data?.total
4610
+ ]);
4607
4611
  const facets = data && data.data.facets ? (0, $eff7d34c30f5a0fc$export$959638e8dca60ce6)(data ? data.data.facets : []) : {
4608
4612
  theme: null,
4609
4613
  keyword: null
@@ -4959,7 +4963,13 @@ const $550bcc185f420ff5$var$DatasetList = ({ rootUrl: rootUrl, enableSort: enabl
4959
4963
  })}`);
4960
4964
  }
4961
4965
  });
4962
- if (data && data.data.total && totalItems != data.data.total) setTotalItems(data.data.total);
4966
+ // Sync totalItems state with API response data
4967
+ // Moved to useEffect to prevent state updates during render (which can cause infinite loops)
4968
+ (0, $hgUW1$useEffect)(()=>{
4969
+ if (data?.data?.total !== undefined && data.data.total !== totalItems) setTotalItems(data.data.total);
4970
+ }, [
4971
+ data?.data?.total
4972
+ ]);
4963
4973
  (0, $hgUW1$useEffect)(()=>{
4964
4974
  // Update browser URL with current search params
4965
4975
  const params = buildSearchParams(true);