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

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,19 @@ 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
+ // Prevent refetch when user returns to tab
282
+ refetchOnWindowFocus: false,
283
+ // Keep data fresh for 2 minutes before marking stale
284
+ // Reduces unnecessary refetches, especially on slow connections
285
+ staleTime: 120000,
286
+ // Keep unused cache for 10 minutes (default is 5)
287
+ // Helps users navigating back/forward
288
+ gcTime: 600000,
289
+ // Reduce retries for slow connections
290
+ // Default is 3 with exponential backoff (can take 7+ seconds)
291
+ retry: 1,
292
+ // Fixed retry delay instead of exponential
293
+ retryDelay: 1000
282
294
  }
283
295
  }
284
296
  });
@@ -369,9 +381,15 @@ const $10bc3aae21fc1572$var$DatasetListSubmenu = ({ rootUrl: rootUrl, enablePagi
369
381
  })}`);
370
382
  }
371
383
  });
384
+ // Sync totalItems state with API response data
385
+ // Moved to useEffect to prevent state updates during render (which can cause infinite loops)
386
+ (0, $hgUW1$useEffect)(()=>{
387
+ if (data?.data?.total !== undefined && data.data.total !== totalItems) setTotalItems(data.data.total);
388
+ }, [
389
+ data?.data?.total
390
+ ]);
372
391
  let submenuItemsCount = 0;
373
392
  if (data) {
374
- if (data.data.total && totalItems !== data.data.total) setTotalItems(data.data.total);
375
393
  let resultsCount = Object.keys(data.data.results).length;
376
394
  // For the submenu pager, If there are fewer than 4 dataset items, display the dataset item count, otherwise, show "Viewing 4..".
377
395
  submenuItemsCount = resultsCount > defaultPageSize ? defaultPageSize : resultsCount;
@@ -2957,26 +2975,9 @@ const $eadd6431fddf4b6c$var$FilterItem = ({ id: id, condition: condition, index:
2957
2975
  const [property, setProperty] = (0, $hgUW1$useState)(condition.property);
2958
2976
  const [value, setValue] = (0, $hgUW1$useState)(condition.value);
2959
2977
  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
2978
  const xl = (0, $hgUW1$useMediaQuery)({
2962
2979
  minWidth: 1280
2963
2980
  });
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
2981
  (0, $hgUW1$useEffect)(()=>{
2981
2982
  if (property !== condition.property) {
2982
2983
  if (property) update(index, 'property', property);
@@ -4603,7 +4604,13 @@ const $e873081a6e8f024e$var$DatasetSearch = (props)=>{
4603
4604
  })}`);
4604
4605
  }
4605
4606
  });
4606
- if (data && data.data.total && totalItems != data.data.total) setTotalItems(data.data.total);
4607
+ // Sync totalItems state with API response data
4608
+ // Moved to useEffect to prevent state updates during render (which can cause infinite loops)
4609
+ (0, $hgUW1$useEffect)(()=>{
4610
+ if (data?.data?.total !== undefined && data.data.total !== totalItems) setTotalItems(data.data.total);
4611
+ }, [
4612
+ data?.data?.total
4613
+ ]);
4607
4614
  const facets = data && data.data.facets ? (0, $eff7d34c30f5a0fc$export$959638e8dca60ce6)(data ? data.data.facets : []) : {
4608
4615
  theme: null,
4609
4616
  keyword: null
@@ -4959,7 +4966,13 @@ const $550bcc185f420ff5$var$DatasetList = ({ rootUrl: rootUrl, enableSort: enabl
4959
4966
  })}`);
4960
4967
  }
4961
4968
  });
4962
- if (data && data.data.total && totalItems != data.data.total) setTotalItems(data.data.total);
4969
+ // Sync totalItems state with API response data
4970
+ // Moved to useEffect to prevent state updates during render (which can cause infinite loops)
4971
+ (0, $hgUW1$useEffect)(()=>{
4972
+ if (data?.data?.total !== undefined && data.data.total !== totalItems) setTotalItems(data.data.total);
4973
+ }, [
4974
+ data?.data?.total
4975
+ ]);
4963
4976
  (0, $hgUW1$useEffect)(()=>{
4964
4977
  // Update browser URL with current search params
4965
4978
  const params = buildSearchParams(true);