@civicactions/cmsds-open-data-components 4.1.7-alpha.0 → 4.1.7-alpha.1

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
@@ -1,8 +1,8 @@
1
1
  import "./main.css";
2
2
  import {jsx as $hgUW1$jsx, jsxs as $hgUW1$jsxs, Fragment as $hgUW1$Fragment} from "react/jsx-runtime";
3
- import {Accordion as $hgUW1$Accordion, AccordionItem as $hgUW1$AccordionItem, Button as $hgUW1$Button, CloseIconThin as $hgUW1$CloseIconThin, ArrowIcon as $hgUW1$ArrowIcon, Dialog as $hgUW1$Dialog, TextField as $hgUW1$TextField, Spinner as $hgUW1$Spinner, Dropdown as $hgUW1$Dropdown, Alert as $hgUW1$Alert, Pagination as $hgUW1$Pagination, Tooltip as $hgUW1$Tooltip, TooltipIcon as $hgUW1$TooltipIcon, Choice as $hgUW1$Choice, Table as $hgUW1$Table, TableHead as $hgUW1$TableHead, TableRow as $hgUW1$TableRow, TableCell as $hgUW1$TableCell, TableBody as $hgUW1$TableBody, Tabs as $hgUW1$Tabs, TabPanel as $hgUW1$TabPanel, ExternalLinkIcon as $hgUW1$ExternalLinkIcon, Badge as $hgUW1$Badge} from "@cmsgov/design-system";
3
+ import {Accordion as $hgUW1$Accordion, AccordionItem as $hgUW1$AccordionItem, Button as $hgUW1$Button, CloseIconThin as $hgUW1$CloseIconThin, ArrowIcon as $hgUW1$ArrowIcon, Spinner as $hgUW1$Spinner, Alert as $hgUW1$Alert, Dialog as $hgUW1$Dialog, TextField as $hgUW1$TextField, Dropdown as $hgUW1$Dropdown, Pagination as $hgUW1$Pagination, Tooltip as $hgUW1$Tooltip, TooltipIcon as $hgUW1$TooltipIcon, Choice as $hgUW1$Choice, Table as $hgUW1$Table, TableHead as $hgUW1$TableHead, TableRow as $hgUW1$TableRow, TableCell as $hgUW1$TableCell, TableBody as $hgUW1$TableBody, Tabs as $hgUW1$Tabs, TabPanel as $hgUW1$TabPanel, ExternalLinkIcon as $hgUW1$ExternalLinkIcon, Badge as $hgUW1$Badge} from "@cmsgov/design-system";
4
4
  import $hgUW1$react, {createContext as $hgUW1$createContext, useState as $hgUW1$useState, useRef as $hgUW1$useRef, useEffect as $hgUW1$useEffect, useContext as $hgUW1$useContext, useMemo as $hgUW1$useMemo, useCallback as $hgUW1$useCallback} from "react";
5
- import {NavLink as $hgUW1$NavLink, useNavigate as $hgUW1$useNavigate, useSearchParams as $hgUW1$useSearchParams, useLocation as $hgUW1$useLocation, Link as $hgUW1$Link} from "react-router-dom";
5
+ import {NavLink as $hgUW1$NavLink, Link as $hgUW1$Link, useNavigate as $hgUW1$useNavigate, useSearchParams as $hgUW1$useSearchParams, useLocation as $hgUW1$useLocation} from "react-router-dom";
6
6
  import $hgUW1$qs from "qs";
7
7
  import $hgUW1$axios from "axios";
8
8
  import {useQuery as $hgUW1$useQuery, QueryClient as $hgUW1$QueryClient, QueryClientProvider as $hgUW1$QueryClientProvider} from "@tanstack/react-query";
@@ -270,6 +270,199 @@ var $11500a65bd7d9cf1$export$2e2bcd8739ae039 = $11500a65bd7d9cf1$var$HeaderConte
270
270
 
271
271
 
272
272
 
273
+
274
+
275
+
276
+
277
+
278
+ const $61ff88fb3f6ee2c8$var$queryClient = new (0, $hgUW1$QueryClient)({
279
+ defaultOptions: {
280
+ queries: {
281
+ refetchOnWindowFocus: false
282
+ }
283
+ }
284
+ });
285
+ const $61ff88fb3f6ee2c8$var$withQueryProvider = (WrappedComponent)=>(props)=>{
286
+ return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$QueryClientProvider), {
287
+ client: $61ff88fb3f6ee2c8$var$queryClient,
288
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)(WrappedComponent, {
289
+ ...props
290
+ })
291
+ });
292
+ };
293
+ var $61ff88fb3f6ee2c8$export$2e2bcd8739ae039 = $61ff88fb3f6ee2c8$var$withQueryProvider;
294
+
295
+
296
+
297
+
298
+
299
+
300
+
301
+ const $4808982eba3feb88$var$DatasetListSubmenuItem = (props)=>{
302
+ const { title: title, identifier: identifier, linkClasses: linkClasses } = props;
303
+ return /*#__PURE__*/ (0, $hgUW1$jsx)("li", {
304
+ className: "dc-c-list-item",
305
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$NavLink), {
306
+ className: `ds-u-display-flex ds-u-align-items--center ds-u-text-align--left ${linkClasses}`,
307
+ to: `/dataset/${identifier}`,
308
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
309
+ className: "ds-text-heading--md ds-u-margin-left--0",
310
+ children: title
311
+ })
312
+ })
313
+ }, identifier);
314
+ };
315
+ var $4808982eba3feb88$export$2e2bcd8739ae039 = $4808982eba3feb88$var$DatasetListSubmenuItem;
316
+
317
+
318
+
319
+
320
+ function $6d5c0212e738499b$export$34e95918366a058e(params, ACA) {
321
+ if (ACA) params = Object.assign(params, {
322
+ ACA: ACA,
323
+ redirect: false
324
+ });
325
+ return params;
326
+ }
327
+
328
+
329
+
330
+ const $844981eac9b63865$export$eccc29c8d0ff408 = (0, $hgUW1$createContext)({
331
+ ACA: undefined
332
+ });
333
+
334
+
335
+ const $10bc3aae21fc1572$var$DatasetListSubmenu = ({ rootUrl: rootUrl, enablePagination: enablePagination = true, defaultPageSize: defaultPageSize = 4, defaultSort: defaultSort = {
336
+ defaultSort: 'modified',
337
+ defaultOrder: 'desc'
338
+ }, subLinkClasses: subLinkClasses })=>{
339
+ const { ACA: ACA } = (0, $hgUW1$useContext)((0, $844981eac9b63865$export$eccc29c8d0ff408));
340
+ const [currentResultNumbers, setCurrentResultNumbers] = (0, $hgUW1$useState)({
341
+ total: 0,
342
+ startingNumber: 0,
343
+ endingNumber: 0
344
+ });
345
+ const [noResults, setNoResults] = (0, $hgUW1$useState)(false);
346
+ const [totalItems, setTotalItems] = (0, $hgUW1$useState)(0);
347
+ const pageSize = defaultPageSize;
348
+ (0, $hgUW1$useEffect)(()=>{
349
+ if (totalItems <= 0 && currentResultNumbers !== null) setNoResults(true);
350
+ else setNoResults(false);
351
+ }, [
352
+ totalItems,
353
+ pageSize
354
+ ]);
355
+ let params = {
356
+ sort: defaultSort.defaultSort,
357
+ ['sort-order']: defaultSort.defaultOrder,
358
+ ['page-size']: defaultPageSize
359
+ };
360
+ const { data: data, isPending: isPending, error: error } = (0, $hgUW1$useQuery)({
361
+ queryKey: [
362
+ "datasets",
363
+ params
364
+ ],
365
+ queryFn: ()=>{
366
+ return (0, $hgUW1$axios).get(`${rootUrl}/search/?${(0, $hgUW1$qs).stringify((0, $6d5c0212e738499b$export$34e95918366a058e)(params, ACA), {
367
+ arrayFormat: 'comma',
368
+ encode: false
369
+ })}`);
370
+ }
371
+ });
372
+ // Sync totalItems state with API response data
373
+ // Moved to useEffect to prevent state updates during render (which can cause infinite loops)
374
+ (0, $hgUW1$useEffect)(()=>{
375
+ if (data?.data?.total !== undefined && data.data.total !== totalItems) setTotalItems(data.data.total);
376
+ }, [
377
+ data?.data?.total
378
+ ]);
379
+ let submenuItemsCount = 0;
380
+ if (data) {
381
+ let resultsCount = Object.keys(data.data.results).length;
382
+ // For the submenu pager, If there are fewer than 4 dataset items, display the dataset item count, otherwise, show "Viewing 4..".
383
+ submenuItemsCount = resultsCount > defaultPageSize ? defaultPageSize : resultsCount;
384
+ }
385
+ return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Fragment), {
386
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)("section", {
387
+ className: " dkan-c-site-menu--sub-menu",
388
+ children: isPending ? /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Spinner), {
389
+ className: "ds-u-valign--middle",
390
+ "aria-valuetext": "Dataset Search loading",
391
+ role: "status"
392
+ }) : /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
393
+ children: [
394
+ /*#__PURE__*/ (0, $hgUW1$jsxs)("ol", {
395
+ className: "dc-dataset-search-list ds-u-padding--0 ds-u-margin-top--0 ds-u-lg-margin-top--2 ds-u-margin-bottom--2 ds-u-display--block",
396
+ "data-testid": "submenu-results-list",
397
+ children: [
398
+ noResults && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Alert), {
399
+ variation: "error",
400
+ heading: "No results found."
401
+ }),
402
+ data && data.data.results ? Object.keys(data.data.results).map((key)=>{
403
+ return data.data.results[key];
404
+ }).map((item)=>{
405
+ return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $4808982eba3feb88$export$2e2bcd8739ae039), {
406
+ title: item.title,
407
+ identifier: item.identifier,
408
+ linkClasses: subLinkClasses
409
+ }, item.identifier);
410
+ }) : /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Alert), {
411
+ variation: "error",
412
+ heading: "Could not connect to the API."
413
+ })
414
+ ]
415
+ }),
416
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
417
+ className: "ds-u-display--flex ds-u-justify-content--between ds-u-align-items--center ds-u-border-top--1 ds-u-padding-top--3 ds-u-padding-bottom--2 ds-u-margin-x--3 ds-u-lg-margin-x--0",
418
+ children: enablePagination && /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
419
+ children: [
420
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
421
+ className: "",
422
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)("p", {
423
+ className: "ds-u-margin-y--0 ds-u-font-size--sm",
424
+ "aria-hidden": "true",
425
+ children: data && /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
426
+ children: [
427
+ "Viewing ",
428
+ submenuItemsCount,
429
+ " of ",
430
+ data.data.total
431
+ ]
432
+ })
433
+ })
434
+ }),
435
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
436
+ className: "",
437
+ children: data && data.data.total > 0 && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Link), {
438
+ className: "ds-u-padding--0 ds-c-button ds-c-button--ghost dkan-c-header--link",
439
+ to: `../whats-new`,
440
+ children: /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
441
+ className: "ds-text-heading--md",
442
+ children: [
443
+ " ",
444
+ `View all ${data.data.total} entries`,
445
+ " "
446
+ ]
447
+ })
448
+ })
449
+ })
450
+ ]
451
+ })
452
+ })
453
+ ]
454
+ })
455
+ })
456
+ });
457
+ };
458
+ var $10bc3aae21fc1572$export$2e2bcd8739ae039 = (0, $61ff88fb3f6ee2c8$export$2e2bcd8739ae039)($10bc3aae21fc1572$var$DatasetListSubmenu);
459
+
460
+
461
+
462
+
463
+
464
+
465
+
273
466
  const $6d0cf21faac6a2dd$var$SubMenuStaticList = ({ submenuArray: submenuArray, subLinkClasses: subLinkClasses, setIsExpanded: setIsExpanded })=>{
274
467
  // Render a static list of submenu items as listed in the assets/menu.jsx file.
275
468
  let submenuItems = submenuArray.map((s)=>{
@@ -336,9 +529,14 @@ const $669b51f08325b4e3$var$SubMenu = ({ link: link, linkClasses: linkClasses, s
336
529
  subLinkClasses: subLinkClasses,
337
530
  setIsExpanded: setIsExpanded
338
531
  });
339
- else if (/*#__PURE__*/ (0, $hgUW1$react).isValidElement(link.submenu)) submenuBlock = /*#__PURE__*/ (0, $hgUW1$react).cloneElement(link.submenu, {
340
- subLinkClasses: subLinkClasses
341
- });
532
+ else if (/*#__PURE__*/ (0, $hgUW1$react).isValidElement(link.submenu)) {
533
+ const { rootUrl: rootUrl, location: location } = link.submenu.props;
534
+ submenuBlock = /*#__PURE__*/ (0, $hgUW1$jsx)((0, $10bc3aae21fc1572$export$2e2bcd8739ae039), {
535
+ location: location,
536
+ rootUrl: rootUrl,
537
+ subLinkClasses: subLinkClasses
538
+ });
539
+ }
342
540
  }
343
541
  return /*#__PURE__*/ (0, $hgUW1$jsxs)("li", {
344
542
  className: `dkan-c-nav-submenu has-submenu${isExpanded ? ' open' : ''}`,
@@ -381,26 +579,6 @@ var $669b51f08325b4e3$export$2e2bcd8739ae039 = $669b51f08325b4e3$var$SubMenu;
381
579
 
382
580
 
383
581
 
384
- const $61ff88fb3f6ee2c8$var$queryClient = new (0, $hgUW1$QueryClient)({
385
- defaultOptions: {
386
- queries: {
387
- refetchOnWindowFocus: false
388
- }
389
- }
390
- });
391
- const $61ff88fb3f6ee2c8$var$withQueryProvider = (WrappedComponent)=>(props)=>{
392
- return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$QueryClientProvider), {
393
- client: $61ff88fb3f6ee2c8$var$queryClient,
394
- children: /*#__PURE__*/ (0, $hgUW1$jsx)(WrappedComponent, {
395
- ...props
396
- })
397
- });
398
- };
399
- var $61ff88fb3f6ee2c8$export$2e2bcd8739ae039 = $61ff88fb3f6ee2c8$var$withQueryProvider;
400
-
401
-
402
-
403
-
404
582
 
405
583
 
406
584
 
@@ -1190,14 +1368,6 @@ var $5723016a5461c1ca$export$2e2bcd8739ae039 = $5723016a5461c1ca$var$PageHeader;
1190
1368
 
1191
1369
 
1192
1370
 
1193
- function $6d5c0212e738499b$export$34e95918366a058e(params, ACA) {
1194
- if (ACA) params = Object.assign(params, {
1195
- ACA: ACA,
1196
- redirect: false
1197
- });
1198
- return params;
1199
- }
1200
-
1201
1371
 
1202
1372
  function $eff7d34c30f5a0fc$export$959638e8dca60ce6(facets) {
1203
1373
  let facetObj = {};
@@ -1255,11 +1425,6 @@ async function $eff7d34c30f5a0fc$export$2d2256cb46e92ff7(rootUrl, options, ACA)
1255
1425
 
1256
1426
 
1257
1427
 
1258
- const $844981eac9b63865$export$eccc29c8d0ff408 = (0, $hgUW1$createContext)({
1259
- ACA: undefined
1260
- });
1261
-
1262
-
1263
1428
  const $e873081a6e8f024e$export$1040147c129fdde9 = (query)=>{
1264
1429
  return /^[a-zA-Z0-9 ]*$/.test(query.trim());
1265
1430
  };
@@ -3309,7 +3474,18 @@ const $a35cf16d1488f54e$var$DatasetTable = ({ isModal: isModal = false, showCopy
3309
3474
  }, {
3310
3475
  encode: true
3311
3476
  })}&format=csv`;
3312
- if (Object.keys(resource).length && columns.length && resource.schema && Object.keys(distribution).length) return /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
3477
+ const useDatastoreErrorMessages = {
3478
+ 400: {
3479
+ title: 'Data unavailable',
3480
+ message: 'This data is not available for preview at this time. Please try again later.'
3481
+ },
3482
+ 500: {
3483
+ title: 'Something went wrong',
3484
+ message: 'Something went wrong on our end. Please try again later.'
3485
+ }
3486
+ };
3487
+ // Data loaded successfully
3488
+ if (!resource.error && Object.keys(resource).length && columns.length && resource.schema && Object.keys(distribution).length) return /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
3313
3489
  children: [
3314
3490
  /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3315
3491
  className: isModal ? 'dkan-datatable-fullscreen-mode' : '',
@@ -3360,7 +3536,28 @@ const $a35cf16d1488f54e$var$DatasetTable = ({ isModal: isModal = false, showCopy
3360
3536
  })
3361
3537
  ]
3362
3538
  });
3363
- else return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Spinner), {
3539
+ else if (resource.error && !resource.loading) {
3540
+ const resourceErrorStatus = resource.error.status in useDatastoreErrorMessages ? resource.error.status : 500;
3541
+ return /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3542
+ children: [
3543
+ /*#__PURE__*/ (0, $hgUW1$jsx)("h2", {
3544
+ className: "ds-text-heading--lg ds-u-margin--0 ds-u-color--primary",
3545
+ children: useDatastoreErrorMessages[resourceErrorStatus].title
3546
+ }),
3547
+ /*#__PURE__*/ (0, $hgUW1$jsx)("p", {
3548
+ className: "ds-u-padding-bottom--2 ds-u-margin-bottom--7",
3549
+ children: useDatastoreErrorMessages[resourceErrorStatus].message
3550
+ }),
3551
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
3552
+ href: "/",
3553
+ variation: "solid",
3554
+ className: "",
3555
+ children: "Go to home"
3556
+ })
3557
+ ]
3558
+ });
3559
+ // Data loading
3560
+ } else return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Spinner), {
3364
3561
  "aria-valuetext": "Dataset loading",
3365
3562
  role: "status",
3366
3563
  className: "ds-u-margin--3"
@@ -4202,165 +4399,6 @@ var $85f8ff1ff89899c7$export$2e2bcd8739ae039 = $85f8ff1ff89899c7$var$DataTableTo
4202
4399
 
4203
4400
 
4204
4401
 
4205
-
4206
-
4207
-
4208
-
4209
-
4210
- const $4808982eba3feb88$var$DatasetListSubmenuItem = (props)=>{
4211
- const { title: title, identifier: identifier, linkClasses: linkClasses } = props;
4212
- return /*#__PURE__*/ (0, $hgUW1$jsx)("li", {
4213
- className: "dc-c-list-item",
4214
- children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$NavLink), {
4215
- className: `ds-u-display-flex ds-u-align-items--center ds-u-text-align--left ${linkClasses}`,
4216
- to: `/dataset/${identifier}`,
4217
- children: /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
4218
- className: "ds-text-heading--md ds-u-margin-left--0",
4219
- children: title
4220
- })
4221
- })
4222
- }, identifier);
4223
- };
4224
- var $4808982eba3feb88$export$2e2bcd8739ae039 = $4808982eba3feb88$var$DatasetListSubmenuItem;
4225
-
4226
-
4227
-
4228
-
4229
-
4230
-
4231
- const $10bc3aae21fc1572$var$DatasetListSubmenu = ({ rootUrl: rootUrl, enablePagination: enablePagination = true, defaultPageSize: defaultPageSize = 4, defaultSort: defaultSort = {
4232
- defaultSort: 'modified',
4233
- defaultOrder: 'desc'
4234
- }, subLinkClasses: subLinkClasses })=>{
4235
- const { ACA: ACA } = (0, $hgUW1$useContext)((0, $844981eac9b63865$export$eccc29c8d0ff408));
4236
- const [currentResultNumbers, setCurrentResultNumbers] = (0, $hgUW1$useState)({
4237
- total: 0,
4238
- startingNumber: 0,
4239
- endingNumber: 0
4240
- });
4241
- const [noResults, setNoResults] = (0, $hgUW1$useState)(false);
4242
- const [totalItems, setTotalItems] = (0, $hgUW1$useState)(0);
4243
- const pageSize = defaultPageSize;
4244
- (0, $hgUW1$useEffect)(()=>{
4245
- if (totalItems <= 0 && currentResultNumbers !== null) setNoResults(true);
4246
- else setNoResults(false);
4247
- }, [
4248
- totalItems,
4249
- pageSize
4250
- ]);
4251
- let params = {
4252
- sort: defaultSort.defaultSort,
4253
- ['sort-order']: defaultSort.defaultOrder,
4254
- ['page-size']: defaultPageSize
4255
- };
4256
- const { data: data, isPending: isPending, error: error } = (0, $hgUW1$useQuery)({
4257
- queryKey: [
4258
- "datasets",
4259
- params
4260
- ],
4261
- queryFn: ()=>{
4262
- return (0, $hgUW1$axios).get(`${rootUrl}/search/?${(0, $hgUW1$qs).stringify((0, $6d5c0212e738499b$export$34e95918366a058e)(params, ACA), {
4263
- arrayFormat: 'comma',
4264
- encode: false
4265
- })}`);
4266
- }
4267
- });
4268
- // Sync totalItems state with API response data
4269
- // Moved to useEffect to prevent state updates during render (which can cause infinite loops)
4270
- (0, $hgUW1$useEffect)(()=>{
4271
- if (data?.data?.total !== undefined && data.data.total !== totalItems) setTotalItems(data.data.total);
4272
- }, [
4273
- data?.data?.total
4274
- ]);
4275
- let submenuItemsCount = 0;
4276
- if (data) {
4277
- let resultsCount = Object.keys(data.data.results).length;
4278
- // For the submenu pager, If there are fewer than 4 dataset items, display the dataset item count, otherwise, show "Viewing 4..".
4279
- submenuItemsCount = resultsCount > defaultPageSize ? defaultPageSize : resultsCount;
4280
- }
4281
- return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Fragment), {
4282
- children: /*#__PURE__*/ (0, $hgUW1$jsx)("section", {
4283
- className: " dkan-c-site-menu--sub-menu",
4284
- children: isPending ? /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Spinner), {
4285
- className: "ds-u-valign--middle",
4286
- "aria-valuetext": "Dataset Search loading",
4287
- role: "status"
4288
- }) : /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
4289
- children: [
4290
- /*#__PURE__*/ (0, $hgUW1$jsxs)("ol", {
4291
- className: "dc-dataset-search-list ds-u-padding--0 ds-u-margin-top--0 ds-u-lg-margin-top--2 ds-u-margin-bottom--2 ds-u-display--block",
4292
- "data-testid": "submenu-results-list",
4293
- children: [
4294
- noResults && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Alert), {
4295
- variation: "error",
4296
- heading: "No results found."
4297
- }),
4298
- data && data.data.results ? Object.keys(data.data.results).map((key)=>{
4299
- return data.data.results[key];
4300
- }).map((item)=>{
4301
- return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $4808982eba3feb88$export$2e2bcd8739ae039), {
4302
- title: item.title,
4303
- identifier: item.identifier,
4304
- linkClasses: subLinkClasses
4305
- }, item.identifier);
4306
- }) : /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Alert), {
4307
- variation: "error",
4308
- heading: "Could not connect to the API."
4309
- })
4310
- ]
4311
- }),
4312
- /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
4313
- className: "ds-u-display--flex ds-u-justify-content--between ds-u-align-items--center ds-u-border-top--1 ds-u-padding-top--3 ds-u-padding-bottom--2 ds-u-margin-x--3 ds-u-lg-margin-x--0",
4314
- children: enablePagination && /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
4315
- children: [
4316
- /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
4317
- className: "",
4318
- children: /*#__PURE__*/ (0, $hgUW1$jsx)("p", {
4319
- className: "ds-u-margin-y--0 ds-u-font-size--sm",
4320
- "aria-hidden": "true",
4321
- children: data && /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
4322
- children: [
4323
- "Viewing ",
4324
- submenuItemsCount,
4325
- " of ",
4326
- data.data.total
4327
- ]
4328
- })
4329
- })
4330
- }),
4331
- /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
4332
- className: "",
4333
- children: data && data.data.total > 0 && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Link), {
4334
- className: "ds-u-padding--0 ds-c-button ds-c-button--ghost dkan-c-header--link",
4335
- to: `../whats-new`,
4336
- children: /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
4337
- className: "ds-text-heading--md",
4338
- children: [
4339
- " ",
4340
- `View all ${data.data.total} entries`,
4341
- " "
4342
- ]
4343
- })
4344
- })
4345
- })
4346
- ]
4347
- })
4348
- })
4349
- ]
4350
- })
4351
- })
4352
- });
4353
- };
4354
- var $10bc3aae21fc1572$export$2e2bcd8739ae039 = (0, $61ff88fb3f6ee2c8$export$2e2bcd8739ae039)($10bc3aae21fc1572$var$DatasetListSubmenu);
4355
-
4356
-
4357
-
4358
-
4359
-
4360
-
4361
-
4362
-
4363
-
4364
4402
  const $5b656f0283afa250$var$SpanOpenAPIVersion = function(system) {
4365
4403
  return {
4366
4404
  wrapComponents: {
@@ -6028,13 +6066,23 @@ const $1d3d480a9cfaabe0$var$useDatastore = (resourceId, rootAPIUrl, options, add
6028
6066
  }
6029
6067
  // Change whether distribution API or dataset API is used based on option
6030
6068
  const queryID = useDatasetAPI && datasetID ? `${datasetID}/0` : id;
6069
+ async function fetchJson(url) {
6070
+ const res = await fetch(url);
6071
+ const body = await res.json().catch(()=>({}));
6072
+ if (!res.ok) {
6073
+ const err = new Error(body.message || body.error || res.statusText);
6074
+ err.status = res.status;
6075
+ throw err;
6076
+ }
6077
+ return body;
6078
+ }
6031
6079
  const { data: data, isPending: isPending, error: error } = (0, $hgUW1$useQuery)({
6032
6080
  queryKey: [
6033
6081
  "datastore" + id + paramsString
6034
6082
  ],
6035
6083
  queryFn: ()=>{
6036
6084
  setCount(null);
6037
- return fetch(`${rootUrl}/datastore/query/${queryID}?${paramsString}`).then((res)=>res.json());
6085
+ return fetchJson(`${rootUrl}/datastore/query/${queryID}?${paramsString}`);
6038
6086
  },
6039
6087
  enabled: enabled
6040
6088
  });
@@ -6048,7 +6096,7 @@ const $1d3d480a9cfaabe0$var$useDatastore = (resourceId, rootAPIUrl, options, add
6048
6096
  count: true,
6049
6097
  schema: true
6050
6098
  };
6051
- return fetch(`${rootUrl}/datastore/query/${queryID}?${(0, $hgUW1$qs).stringify((0, $6d5c0212e738499b$export$34e95918366a058e)(unfilteredParams, ACA))}`).then((res)=>res.json());
6099
+ return fetchJson(`${rootUrl}/datastore/query/${queryID}?${(0, $hgUW1$qs).stringify((0, $6d5c0212e738499b$export$34e95918366a058e)(unfilteredParams, ACA))}`);
6052
6100
  }
6053
6101
  });
6054
6102
  (0, $hgUW1$useEffect)(()=>{
@@ -6071,6 +6119,7 @@ const $1d3d480a9cfaabe0$var$useDatastore = (resourceId, rootAPIUrl, options, add
6071
6119
  ]);
6072
6120
  return {
6073
6121
  loading: enabled ? isPending : false,
6122
+ error: error,
6074
6123
  values: values,
6075
6124
  count: count,
6076
6125
  columns: columns,