@civicactions/cmsds-open-data-components 4.1.7-alpha.3 → 4.1.7-alpha.4
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 +57 -23
- package/dist/main.js.map +1 -1
- package/dist/types.d.ts +20 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1450,11 +1450,10 @@ 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,
|
|
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;
|
|
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)();
|
|
1458
1457
|
// Derive all search state from URL params
|
|
1459
1458
|
const selectedFacets = (0, $hgUW1$useMemo)(()=>{
|
|
1460
1459
|
const parsed = (0, $hgUW1$qs).parse(searchParams.toString());
|
|
@@ -1602,12 +1601,6 @@ const $e873081a6e8f024e$var$DatasetSearch = (props)=>{
|
|
|
1602
1601
|
noResults,
|
|
1603
1602
|
currentResultNumbers
|
|
1604
1603
|
]);
|
|
1605
|
-
(0, $hgUW1$useEffect)(()=>{
|
|
1606
|
-
if (analytics && location.search) onAnalyticsEvent(location);
|
|
1607
|
-
}, [
|
|
1608
|
-
analytics,
|
|
1609
|
-
location.search
|
|
1610
|
-
]);
|
|
1611
1604
|
return /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
|
|
1612
1605
|
children: [
|
|
1613
1606
|
/*#__PURE__*/ (0, $hgUW1$jsx)((0, $5723016a5461c1ca$export$2e2bcd8739ae039), {
|
|
@@ -2627,13 +2620,12 @@ const $5d9e2ce238d53d29$var$ManageColumns = ({ id: id, columns: columns, default
|
|
|
2627
2620
|
]);
|
|
2628
2621
|
// keep state in sync
|
|
2629
2622
|
(0, $hgUW1$useEffect)(()=>{
|
|
2630
|
-
if (columnOrder?.length) setCards(columnOrder.map((
|
|
2631
|
-
|
|
2632
|
-
|
|
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 any possible undefined/non-matches
|
|
2625
|
+
.map((column)=>({
|
|
2633
2626
|
id: column.id,
|
|
2634
2627
|
visible: column.getIsVisible()
|
|
2635
|
-
};
|
|
2636
|
-
}));
|
|
2628
|
+
})));
|
|
2637
2629
|
}, [
|
|
2638
2630
|
columnOrder
|
|
2639
2631
|
]);
|
|
@@ -2769,13 +2761,12 @@ const $5d9e2ce238d53d29$var$ManageColumns = ({ id: id, columns: columns, default
|
|
|
2769
2761
|
onClick: ()=>{
|
|
2770
2762
|
// reset to default column order and set all cards to visible
|
|
2771
2763
|
// do not save this to the table state until the "Save" button is clicked
|
|
2772
|
-
setCards(defaultColumnOrder.map((
|
|
2773
|
-
|
|
2774
|
-
|
|
2764
|
+
setCards(defaultColumnOrder.map((id)=>cards.find((c)=>c.id === id)) // Get list of cards in order
|
|
2765
|
+
.filter(Boolean) // Filter out any possible undefined/non-matches
|
|
2766
|
+
.map((card)=>({
|
|
2775
2767
|
...card,
|
|
2776
2768
|
visible: true
|
|
2777
|
-
};
|
|
2778
|
-
}));
|
|
2769
|
+
})));
|
|
2779
2770
|
},
|
|
2780
2771
|
children: "Reset Columns"
|
|
2781
2772
|
})
|
|
@@ -3467,7 +3458,7 @@ function $a35cf16d1488f54e$export$1147582dfae658c6(columns, schema) {
|
|
|
3467
3458
|
accessor: column
|
|
3468
3459
|
}));
|
|
3469
3460
|
}
|
|
3470
|
-
const $a35cf16d1488f54e$var$DatasetTable = ({ isModal: isModal = false, showCopyLinkButton: showCopyLinkButton = true, showDataTableToolbar: showDataTableToolbar = true, showDownloadFilteredDataButton: showDownloadFilteredDataButton = true, showDownloadFullDataButton: showDownloadFullDataButton = true, showStoredQueryDownloadButton: showStoredQueryDownloadButton = false, showTableResults: showTableResults = true, showFilterDatasetButton: showFilterDatasetButton = true, showManageColumnsButton: showManageColumnsButton = true, showDisplaySettingsButton: showDisplaySettingsButton = true, showFullScreenButton: showFullScreenButton = true, showInfoShareContainer: showInfoShareContainer = true })=>{
|
|
3461
|
+
const $a35cf16d1488f54e$var$DatasetTable = ({ isModal: isModal = false, showCopyLinkButton: showCopyLinkButton = true, showDataTableToolbar: showDataTableToolbar = true, showDownloadFilteredDataButton: showDownloadFilteredDataButton = true, showDownloadFullDataButton: showDownloadFullDataButton = true, showStoredQueryDownloadButton: showStoredQueryDownloadButton = false, showTableResults: showTableResults = true, showFilterDatasetButton: showFilterDatasetButton = true, showManageColumnsButton: showManageColumnsButton = true, showDisplaySettingsButton: showDisplaySettingsButton = true, showFullScreenButton: showFullScreenButton = true, showInfoShareContainer: showInfoShareContainer = true, errorHomeButtonHref: errorHomeButtonHref = '/' })=>{
|
|
3471
3462
|
const { id: id, distribution: distribution, resource: resource, rootUrl: rootUrl, customColumns: customColumns = [], dataDictionaryBanner: dataDictionaryBanner } = (0, $hgUW1$useContext)((0, $43a30d745a7bbc86$export$2e2bcd8739ae039));
|
|
3472
3463
|
const { page: page, setPage: setPage, tableDensity: tableDensity } = (0, $hgUW1$useContext)((0, $ee0d4d4f34048447$export$f814ea079e65d8fe));
|
|
3473
3464
|
const defaultPageSize = 10;
|
|
@@ -3481,7 +3472,18 @@ const $a35cf16d1488f54e$var$DatasetTable = ({ isModal: isModal = false, showCopy
|
|
|
3481
3472
|
}, {
|
|
3482
3473
|
encode: true
|
|
3483
3474
|
})}&format=csv`;
|
|
3484
|
-
|
|
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), {
|
|
3485
3487
|
children: [
|
|
3486
3488
|
/*#__PURE__*/ (0, $hgUW1$jsx)("div", {
|
|
3487
3489
|
className: isModal ? 'dkan-datatable-fullscreen-mode' : '',
|
|
@@ -3532,7 +3534,28 @@ const $a35cf16d1488f54e$var$DatasetTable = ({ isModal: isModal = false, showCopy
|
|
|
3532
3534
|
})
|
|
3533
3535
|
]
|
|
3534
3536
|
});
|
|
3535
|
-
else
|
|
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: errorHomeButtonHref,
|
|
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), {
|
|
3536
3559
|
"aria-valuetext": "Dataset loading",
|
|
3537
3560
|
role: "status",
|
|
3538
3561
|
className: "ds-u-margin--3"
|
|
@@ -6041,13 +6064,23 @@ const $1d3d480a9cfaabe0$var$useDatastore = (resourceId, rootAPIUrl, options, add
|
|
|
6041
6064
|
}
|
|
6042
6065
|
// Change whether distribution API or dataset API is used based on option
|
|
6043
6066
|
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
|
+
}
|
|
6044
6077
|
const { data: data, isPending: isPending, error: error } = (0, $hgUW1$useQuery)({
|
|
6045
6078
|
queryKey: [
|
|
6046
6079
|
"datastore" + id + paramsString
|
|
6047
6080
|
],
|
|
6048
6081
|
queryFn: ()=>{
|
|
6049
6082
|
setCount(null);
|
|
6050
|
-
return
|
|
6083
|
+
return fetchJson(`${rootUrl}/datastore/query/${queryID}?${paramsString}`);
|
|
6051
6084
|
},
|
|
6052
6085
|
enabled: enabled
|
|
6053
6086
|
});
|
|
@@ -6061,7 +6094,7 @@ const $1d3d480a9cfaabe0$var$useDatastore = (resourceId, rootAPIUrl, options, add
|
|
|
6061
6094
|
count: true,
|
|
6062
6095
|
schema: true
|
|
6063
6096
|
};
|
|
6064
|
-
return
|
|
6097
|
+
return fetchJson(`${rootUrl}/datastore/query/${queryID}?${(0, $hgUW1$qs).stringify((0, $6d5c0212e738499b$export$34e95918366a058e)(unfilteredParams, ACA))}`);
|
|
6065
6098
|
}
|
|
6066
6099
|
});
|
|
6067
6100
|
(0, $hgUW1$useEffect)(()=>{
|
|
@@ -6084,6 +6117,7 @@ const $1d3d480a9cfaabe0$var$useDatastore = (resourceId, rootAPIUrl, options, add
|
|
|
6084
6117
|
]);
|
|
6085
6118
|
return {
|
|
6086
6119
|
loading: enabled ? isPending : false,
|
|
6120
|
+
error: error,
|
|
6087
6121
|
values: values,
|
|
6088
6122
|
count: count,
|
|
6089
6123
|
columns: columns,
|