@civicactions/cmsds-open-data-components 4.1.7-alpha.2 → 4.1.7-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
@@ -1450,10 +1450,11 @@ const $e873081a6e8f024e$var$DatasetSearch = (props)=>{
1450
1450
  const { rootUrl: rootUrl, enableSort: enableSort = true, enablePagination: enablePagination = true, defaultPageSize: defaultPageSize = 10, defaultSort: defaultSort = {
1451
1451
  defaultSort: 'modified',
1452
1452
  defaultOrder: 'desc'
1453
- }, pageTitle: pageTitle = 'Dataset Explorer', categoriesTitle: categoriesTitle = 'Categories', filterTitle: filterTitle = 'Tags', showLargeFileWarning: showLargeFileWarning = false, largeFileThemes: largeFileThemes, introText: introText = '', showDownloadIcon: showDownloadIcon = false, altMobileSearchButton: altMobileSearchButton, dataDictionaryLinks: dataDictionaryLinks = false, showDateDetails: showDateDetails = false, updateDateMonthYearOnly: updateDateMonthYearOnly = false, showTopics: showTopics = false, topicSlugFunction: topicSlugFunction, children: children } = props;
1453
+ }, pageTitle: pageTitle = 'Dataset Explorer', categoriesTitle: categoriesTitle = 'Categories', filterTitle: filterTitle = 'Tags', showLargeFileWarning: showLargeFileWarning = false, largeFileThemes: largeFileThemes, introText: introText = '', showDownloadIcon: showDownloadIcon = false, altMobileSearchButton: altMobileSearchButton, dataDictionaryLinks: dataDictionaryLinks = false, showDateDetails: showDateDetails = false, updateDateMonthYearOnly: updateDateMonthYearOnly = false, showTopics: showTopics = false, topicSlugFunction: topicSlugFunction, analytics: analytics = false, onAnalyticsEvent: onAnalyticsEvent = ()=>{}, children: children } = props;
1454
1454
  const { ACA: ACA } = (0, $hgUW1$useContext)((0, $844981eac9b63865$export$eccc29c8d0ff408));
1455
1455
  const [searchParams] = (0, $hgUW1$useSearchParams)();
1456
1456
  const navigate = (0, $hgUW1$useNavigate)();
1457
+ const location = (0, $hgUW1$useLocation)();
1457
1458
  // Derive all search state from URL params
1458
1459
  const selectedFacets = (0, $hgUW1$useMemo)(()=>{
1459
1460
  const parsed = (0, $hgUW1$qs).parse(searchParams.toString());
@@ -1601,6 +1602,12 @@ const $e873081a6e8f024e$var$DatasetSearch = (props)=>{
1601
1602
  noResults,
1602
1603
  currentResultNumbers
1603
1604
  ]);
1605
+ (0, $hgUW1$useEffect)(()=>{
1606
+ if (analytics && location.search) onAnalyticsEvent(location);
1607
+ }, [
1608
+ analytics,
1609
+ location.search
1610
+ ]);
1604
1611
  return /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
1605
1612
  children: [
1606
1613
  /*#__PURE__*/ (0, $hgUW1$jsx)((0, $5723016a5461c1ca$export$2e2bcd8739ae039), {
@@ -2620,12 +2627,13 @@ const $5d9e2ce238d53d29$var$ManageColumns = ({ id: id, columns: columns, default
2620
2627
  ]);
2621
2628
  // keep state in sync
2622
2629
  (0, $hgUW1$useEffect)(()=>{
2623
- if (columnOrder?.length) setCards(columnOrder.map((id)=>columns.find((col)=>col.id === id)) // Get list of cards in order
2624
- .filter(Boolean) // Filter out an possible undefined/non-matches
2625
- .map((column)=>({
2630
+ if (columnOrder?.length) setCards(columnOrder.map((c)=>{
2631
+ const column = columns.filter((col)=>col.id === c)[0];
2632
+ return {
2626
2633
  id: column.id,
2627
2634
  visible: column.getIsVisible()
2628
- })));
2635
+ };
2636
+ }));
2629
2637
  }, [
2630
2638
  columnOrder
2631
2639
  ]);
@@ -2761,12 +2769,13 @@ const $5d9e2ce238d53d29$var$ManageColumns = ({ id: id, columns: columns, default
2761
2769
  onClick: ()=>{
2762
2770
  // reset to default column order and set all cards to visible
2763
2771
  // do not save this to the table state until the "Save" button is clicked
2764
- setCards(defaultColumnOrder.map((id)=>cards.find((c)=>c.id === id)) // Get list of cards in order
2765
- .filter(Boolean) // Filter out an possible undefined/non-matches
2766
- .map((card)=>({
2772
+ setCards(defaultColumnOrder.map((column)=>{
2773
+ const card = cards.filter((c)=>c.id === column)[0];
2774
+ return {
2767
2775
  ...card,
2768
2776
  visible: true
2769
- })));
2777
+ };
2778
+ }));
2770
2779
  },
2771
2780
  children: "Reset Columns"
2772
2781
  })
@@ -3472,18 +3481,7 @@ const $a35cf16d1488f54e$var$DatasetTable = ({ isModal: isModal = false, showCopy
3472
3481
  }, {
3473
3482
  encode: true
3474
3483
  })}&format=csv`;
3475
- const useDatastoreErrorMessages = {
3476
- 400: {
3477
- title: 'Data unavailable',
3478
- message: 'This data is not available for preview at this time. Please try again later.'
3479
- },
3480
- 500: {
3481
- title: 'Something went wrong',
3482
- message: 'Something went wrong on our end. Please try again later.'
3483
- }
3484
- };
3485
- // Data loaded successfully
3486
- if (!resource.error && Object.keys(resource).length && columns.length && resource.schema && Object.keys(distribution).length) return /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
3484
+ if (Object.keys(resource).length && columns.length && resource.schema && Object.keys(distribution).length) return /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
3487
3485
  children: [
3488
3486
  /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3489
3487
  className: isModal ? 'dkan-datatable-fullscreen-mode' : '',
@@ -3534,28 +3532,7 @@ const $a35cf16d1488f54e$var$DatasetTable = ({ isModal: isModal = false, showCopy
3534
3532
  })
3535
3533
  ]
3536
3534
  });
3537
- else if (resource.error && !resource.loading) {
3538
- const resourceErrorStatus = resource.error.status in useDatastoreErrorMessages ? resource.error.status : 500;
3539
- return /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3540
- children: [
3541
- /*#__PURE__*/ (0, $hgUW1$jsx)("h2", {
3542
- className: "ds-text-heading--lg ds-u-margin--0 ds-u-color--primary",
3543
- children: useDatastoreErrorMessages[resourceErrorStatus].title
3544
- }),
3545
- /*#__PURE__*/ (0, $hgUW1$jsx)("p", {
3546
- className: "ds-u-padding-bottom--2 ds-u-margin-bottom--7",
3547
- children: useDatastoreErrorMessages[resourceErrorStatus].message
3548
- }),
3549
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
3550
- href: "/",
3551
- variation: "solid",
3552
- className: "",
3553
- children: "Go to home"
3554
- })
3555
- ]
3556
- });
3557
- // Data loading
3558
- } else return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Spinner), {
3535
+ else return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Spinner), {
3559
3536
  "aria-valuetext": "Dataset loading",
3560
3537
  role: "status",
3561
3538
  className: "ds-u-margin--3"
@@ -6064,23 +6041,13 @@ const $1d3d480a9cfaabe0$var$useDatastore = (resourceId, rootAPIUrl, options, add
6064
6041
  }
6065
6042
  // Change whether distribution API or dataset API is used based on option
6066
6043
  const queryID = useDatasetAPI && datasetID ? `${datasetID}/0` : id;
6067
- async function fetchJson(url) {
6068
- const res = await fetch(url);
6069
- const body = await res.json().catch(()=>({}));
6070
- if (!res.ok) {
6071
- const err = new Error(body.message || body.error || res.statusText);
6072
- err.status = res.status;
6073
- throw err;
6074
- }
6075
- return body;
6076
- }
6077
6044
  const { data: data, isPending: isPending, error: error } = (0, $hgUW1$useQuery)({
6078
6045
  queryKey: [
6079
6046
  "datastore" + id + paramsString
6080
6047
  ],
6081
6048
  queryFn: ()=>{
6082
6049
  setCount(null);
6083
- return fetchJson(`${rootUrl}/datastore/query/${queryID}?${paramsString}`);
6050
+ return fetch(`${rootUrl}/datastore/query/${queryID}?${paramsString}`).then((res)=>res.json());
6084
6051
  },
6085
6052
  enabled: enabled
6086
6053
  });
@@ -6094,7 +6061,7 @@ const $1d3d480a9cfaabe0$var$useDatastore = (resourceId, rootAPIUrl, options, add
6094
6061
  count: true,
6095
6062
  schema: true
6096
6063
  };
6097
- return fetchJson(`${rootUrl}/datastore/query/${queryID}?${(0, $hgUW1$qs).stringify((0, $6d5c0212e738499b$export$34e95918366a058e)(unfilteredParams, ACA))}`);
6064
+ return fetch(`${rootUrl}/datastore/query/${queryID}?${(0, $hgUW1$qs).stringify((0, $6d5c0212e738499b$export$34e95918366a058e)(unfilteredParams, ACA))}`).then((res)=>res.json());
6098
6065
  }
6099
6066
  });
6100
6067
  (0, $hgUW1$useEffect)(()=>{
@@ -6117,7 +6084,6 @@ const $1d3d480a9cfaabe0$var$useDatastore = (resourceId, rootAPIUrl, options, add
6117
6084
  ]);
6118
6085
  return {
6119
6086
  loading: enabled ? isPending : false,
6120
- error: error,
6121
6087
  values: values,
6122
6088
  count: count,
6123
6089
  columns: columns,