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

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, 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
- 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, Link as $hgUW1$Link, useNavigate as $hgUW1$useNavigate, useSearchParams as $hgUW1$useSearchParams, useLocation as $hgUW1$useLocation} from "react-router-dom";
3
+ import $hgUW1$react, {createContext as $hgUW1$createContext, useState as $hgUW1$useState, useEffect as $hgUW1$useEffect, useRef as $hgUW1$useRef, useContext as $hgUW1$useContext, useMemo as $hgUW1$useMemo, useCallback as $hgUW1$useCallback} from "react";
4
+ 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";
5
+ import {NavLink as $hgUW1$NavLink, useLocation as $hgUW1$useLocation, useNavigate as $hgUW1$useNavigate, useSearchParams as $hgUW1$useSearchParams, Link as $hgUW1$Link} 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";
@@ -24,6 +24,7 @@ import {List as $hgUW1$List, Map as $hgUW1$Map} from "immutable";
24
24
  // Components
25
25
 
26
26
 
27
+
27
28
  function $e49d4387bed21287$export$2e2bcd8739ae039() {
28
29
  return /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
29
30
  className: "ds-u-padding-top--3 ds-u-margin-bottom--2",
@@ -122,7 +123,7 @@ const $a8accc31bf9e0bda$var$CMSTopNav = (props)=>{
122
123
  children: link.label
123
124
  })
124
125
  })
125
- });
126
+ }, link.id);
126
127
  })
127
128
  })
128
129
  })
@@ -272,197 +273,6 @@ var $11500a65bd7d9cf1$export$2e2bcd8739ae039 = $11500a65bd7d9cf1$var$HeaderConte
272
273
 
273
274
 
274
275
 
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
-
466
276
  const $6d0cf21faac6a2dd$var$SubMenuStaticList = ({ submenuArray: submenuArray, subLinkClasses: subLinkClasses, setIsExpanded: setIsExpanded })=>{
467
277
  // Render a static list of submenu items as listed in the assets/menu.jsx file.
468
278
  let submenuItems = submenuArray.map((s)=>{
@@ -479,7 +289,7 @@ const $6d0cf21faac6a2dd$var$SubMenuStaticList = ({ submenuArray: submenuArray, s
479
289
  }) : /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$NavLink), {
480
290
  to: s.url,
481
291
  className: `ds-u-display-flex ds-u-align-items--center ${subLinkClasses}`,
482
- onClick: ()=>setIsExpanded((prev)=>!prev),
292
+ onClick: ()=>setIsExpanded(false),
483
293
  children: [
484
294
  s.icon ?? null,
485
295
  /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
@@ -500,6 +310,12 @@ var $6d0cf21faac6a2dd$export$2e2bcd8739ae039 = $6d0cf21faac6a2dd$var$SubMenuStat
500
310
  const $669b51f08325b4e3$var$SubMenu = ({ link: link, linkClasses: linkClasses, subLinkClasses: subLinkClasses, wrapLabel: wrapLabel = true })=>{
501
311
  const [isExpanded, setIsExpanded] = (0, $hgUW1$useState)(false);
502
312
  const headerContext = (0, $hgUW1$react).useContext((0, $11500a65bd7d9cf1$export$2e2bcd8739ae039));
313
+ const location = (0, $hgUW1$useLocation)();
314
+ (0, $hgUW1$useEffect)(()=>{
315
+ setIsExpanded(false);
316
+ }, [
317
+ location
318
+ ]);
503
319
  const innerHtml = wrapLabel ? /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
504
320
  children: link.label
505
321
  }) : link.label;
@@ -529,14 +345,9 @@ const $669b51f08325b4e3$var$SubMenu = ({ link: link, linkClasses: linkClasses, s
529
345
  subLinkClasses: subLinkClasses,
530
346
  setIsExpanded: setIsExpanded
531
347
  });
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
- }
348
+ else if (/*#__PURE__*/ (0, $hgUW1$react).isValidElement(link.submenu)) submenuBlock = /*#__PURE__*/ (0, $hgUW1$react).cloneElement(link.submenu, {
349
+ subLinkClasses: subLinkClasses
350
+ });
540
351
  }
541
352
  return /*#__PURE__*/ (0, $hgUW1$jsxs)("li", {
542
353
  className: `dkan-c-nav-submenu has-submenu${isExpanded ? ' open' : ''}`,
@@ -579,6 +390,26 @@ var $669b51f08325b4e3$export$2e2bcd8739ae039 = $669b51f08325b4e3$var$SubMenu;
579
390
 
580
391
 
581
392
 
393
+ const $61ff88fb3f6ee2c8$var$queryClient = new (0, $hgUW1$QueryClient)({
394
+ defaultOptions: {
395
+ queries: {
396
+ refetchOnWindowFocus: false
397
+ }
398
+ }
399
+ });
400
+ const $61ff88fb3f6ee2c8$var$withQueryProvider = (WrappedComponent)=>(props)=>{
401
+ return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$QueryClientProvider), {
402
+ client: $61ff88fb3f6ee2c8$var$queryClient,
403
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)(WrappedComponent, {
404
+ ...props
405
+ })
406
+ });
407
+ };
408
+ var $61ff88fb3f6ee2c8$export$2e2bcd8739ae039 = $61ff88fb3f6ee2c8$var$withQueryProvider;
409
+
410
+
411
+
412
+
582
413
 
583
414
 
584
415
 
@@ -1277,6 +1108,7 @@ var $e011250e8a3bd5e5$export$2e2bcd8739ae039 = $e011250e8a3bd5e5$var$SearchFacet
1277
1108
 
1278
1109
 
1279
1110
 
1111
+
1280
1112
  const $3b2d31a9c6cd2284$var$LargeFileInfo = (props)=>/*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
1281
1113
  className: props.className,
1282
1114
  children: [
@@ -1368,6 +1200,14 @@ var $5723016a5461c1ca$export$2e2bcd8739ae039 = $5723016a5461c1ca$var$PageHeader;
1368
1200
 
1369
1201
 
1370
1202
 
1203
+ function $6d5c0212e738499b$export$34e95918366a058e(params, ACA) {
1204
+ if (ACA) params = Object.assign(params, {
1205
+ ACA: ACA,
1206
+ redirect: false
1207
+ });
1208
+ return params;
1209
+ }
1210
+
1371
1211
 
1372
1212
  function $eff7d34c30f5a0fc$export$959638e8dca60ce6(facets) {
1373
1213
  let facetObj = {};
@@ -1425,6 +1265,11 @@ async function $eff7d34c30f5a0fc$export$2d2256cb46e92ff7(rootUrl, options, ACA)
1425
1265
 
1426
1266
 
1427
1267
 
1268
+ const $844981eac9b63865$export$eccc29c8d0ff408 = (0, $hgUW1$createContext)({
1269
+ ACA: undefined
1270
+ });
1271
+
1272
+
1428
1273
  const $e873081a6e8f024e$export$1040147c129fdde9 = (query)=>{
1429
1274
  return /^[a-zA-Z0-9 ]*$/.test(query.trim());
1430
1275
  };
@@ -1450,10 +1295,11 @@ const $e873081a6e8f024e$var$DatasetSearch = (props)=>{
1450
1295
  const { rootUrl: rootUrl, enableSort: enableSort = true, enablePagination: enablePagination = true, defaultPageSize: defaultPageSize = 10, defaultSort: defaultSort = {
1451
1296
  defaultSort: 'modified',
1452
1297
  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;
1298
+ }, 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
1299
  const { ACA: ACA } = (0, $hgUW1$useContext)((0, $844981eac9b63865$export$eccc29c8d0ff408));
1455
1300
  const [searchParams] = (0, $hgUW1$useSearchParams)();
1456
1301
  const navigate = (0, $hgUW1$useNavigate)();
1302
+ const location = (0, $hgUW1$useLocation)();
1457
1303
  // Derive all search state from URL params
1458
1304
  const selectedFacets = (0, $hgUW1$useMemo)(()=>{
1459
1305
  const parsed = (0, $hgUW1$qs).parse(searchParams.toString());
@@ -1601,6 +1447,12 @@ const $e873081a6e8f024e$var$DatasetSearch = (props)=>{
1601
1447
  noResults,
1602
1448
  currentResultNumbers
1603
1449
  ]);
1450
+ (0, $hgUW1$useEffect)(()=>{
1451
+ if (analytics && location.search) onAnalyticsEvent(location);
1452
+ }, [
1453
+ analytics,
1454
+ location.search
1455
+ ]);
1604
1456
  return /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
1605
1457
  children: [
1606
1458
  /*#__PURE__*/ (0, $hgUW1$jsx)((0, $5723016a5461c1ca$export$2e2bcd8739ae039), {
@@ -1846,9 +1698,11 @@ var $e873081a6e8f024e$export$2e2bcd8739ae039 = (0, $61ff88fb3f6ee2c8$export$2e2b
1846
1698
 
1847
1699
 
1848
1700
 
1701
+
1849
1702
  const $fea9297ba4dd394c$var$HeaderSearch = (props)=>{
1850
1703
  const { headingText: headingText = "Dataset Search" } = props;
1851
1704
  const navigate = (0, $hgUW1$useNavigate)();
1705
+ const { isMobile: isMobile } = (0, $hgUW1$useContext)((0, $11500a65bd7d9cf1$export$2e2bcd8739ae039));
1852
1706
  const [modalSearchTerm, setModalSearchTerm] = (0, $hgUW1$useState)('');
1853
1707
  const [modalSearch, setModalSearch] = (0, $hgUW1$useState)(false);
1854
1708
  const [invalidSearch, setInvalidSearch] = (0, $hgUW1$useState)(false);
@@ -1857,8 +1711,10 @@ const $fea9297ba4dd394c$var$HeaderSearch = (props)=>{
1857
1711
  if (window) {
1858
1712
  if ((0, $e873081a6e8f024e$export$1040147c129fdde9)(modalSearchTerm)) {
1859
1713
  setInvalidSearch(false);
1860
- if (window.location.pathname !== '/datasets') navigate(`/datasets?fulltext=${modalSearchTerm}`);
1861
- else {
1714
+ if (window.location.pathname !== '/datasets') {
1715
+ navigate(`/datasets?fulltext=${modalSearchTerm}`);
1716
+ setModalSearch(false);
1717
+ } else {
1862
1718
  window.location.search = `fulltext=${modalSearchTerm}`;
1863
1719
  setModalSearch(false);
1864
1720
  }
@@ -1869,9 +1725,8 @@ const $fea9297ba4dd394c$var$HeaderSearch = (props)=>{
1869
1725
  className: "dkan-c-main-navigation--search",
1870
1726
  children: [
1871
1727
  /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
1872
- variation: "ghost",
1873
- onDark: true,
1874
- className: "ds-u-border--0 dkan-c-header-search--modal-button",
1728
+ variation: isMobile ? undefined : 'ghost',
1729
+ className: "ds-u-lg-border--0 dkan-c-header-search--modal-button",
1875
1730
  onClick: ()=>setModalSearch(true),
1876
1731
  children: /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
1877
1732
  children: "Search"
@@ -1938,7 +1793,6 @@ const $b939b31651e82908$var$HeaderNav = (props)=>{
1938
1793
  children: [
1939
1794
  /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Button), {
1940
1795
  variation: "ghost",
1941
- onDark: true,
1942
1796
  className: "dkan-c-nav-menu--mobile-close-button",
1943
1797
  onClick: ()=>headerContext.setMobileMenuOpen(false),
1944
1798
  children: [
@@ -1968,7 +1822,7 @@ const $b939b31651e82908$var$HeaderNav = (props)=>{
1968
1822
  children: link.label
1969
1823
  })
1970
1824
  })
1971
- });
1825
+ }, link.id);
1972
1826
  })
1973
1827
  })
1974
1828
  }),
@@ -1985,7 +1839,7 @@ const $b939b31651e82908$var$HeaderNav = (props)=>{
1985
1839
  children: link.label
1986
1840
  })
1987
1841
  })
1988
- });
1842
+ }, link.id);
1989
1843
  })
1990
1844
  })
1991
1845
  }),
@@ -2053,6 +1907,7 @@ var $403833a4b442d5df$export$2e2bcd8739ae039 = $403833a4b442d5df$var$MobileMenuB
2053
1907
 
2054
1908
 
2055
1909
 
1910
+
2056
1911
  const $f57121650539d8c5$var$NavBar = (props)=>{
2057
1912
  const { links: links, menuName: menuName, menuId: menuId, menuClasses: menuClasses, linkClasses: linkClasses, subLinkClasses: subLinkClasses, wrapLabel: wrapLabel = false } = props;
2058
1913
  return /*#__PURE__*/ (0, $hgUW1$jsxs)("nav", {
@@ -2620,13 +2475,12 @@ const $5d9e2ce238d53d29$var$ManageColumns = ({ id: id, columns: columns, default
2620
2475
  ]);
2621
2476
  // keep state in sync
2622
2477
  (0, $hgUW1$useEffect)(()=>{
2623
- if (columnOrder?.length) setCards(columnOrder.map((c)=>{
2624
- const column = columns.filter((col)=>col.id === c)[0];
2625
- return {
2478
+ if (columnOrder?.length) setCards(columnOrder.map((id)=>columns.find((col)=>col.id === id)) // Get list of cards in order
2479
+ .filter(Boolean) // Filter out any possible undefined/non-matches
2480
+ .map((column)=>({
2626
2481
  id: column.id,
2627
2482
  visible: column.getIsVisible()
2628
- };
2629
- }));
2483
+ })));
2630
2484
  }, [
2631
2485
  columnOrder
2632
2486
  ]);
@@ -2762,13 +2616,12 @@ const $5d9e2ce238d53d29$var$ManageColumns = ({ id: id, columns: columns, default
2762
2616
  onClick: ()=>{
2763
2617
  // reset to default column order and set all cards to visible
2764
2618
  // do not save this to the table state until the "Save" button is clicked
2765
- setCards(defaultColumnOrder.map((column)=>{
2766
- const card = cards.filter((c)=>c.id === column)[0];
2767
- return {
2619
+ setCards(defaultColumnOrder.map((id)=>cards.find((c)=>c.id === id)) // Get list of cards in order
2620
+ .filter(Boolean) // Filter out any possible undefined/non-matches
2621
+ .map((card)=>({
2768
2622
  ...card,
2769
2623
  visible: true
2770
- };
2771
- }));
2624
+ })));
2772
2625
  },
2773
2626
  children: "Reset Columns"
2774
2627
  })
@@ -3461,7 +3314,7 @@ function $a35cf16d1488f54e$export$1147582dfae658c6(columns, schema) {
3461
3314
  }));
3462
3315
  }
3463
3316
  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 })=>{
3464
- const { id: id, distribution: distribution, resource: resource, rootUrl: rootUrl, customColumns: customColumns = [], dataDictionaryBanner: dataDictionaryBanner } = (0, $hgUW1$useContext)((0, $43a30d745a7bbc86$export$2e2bcd8739ae039));
3317
+ const { id: id, distribution: distribution, resource: resource, rootUrl: rootUrl, customColumns: customColumns = [], dataDictionaryBanner: dataDictionaryBanner, relativeHomeUrlPrepend: relativeHomeUrlPrepend } = (0, $hgUW1$useContext)((0, $43a30d745a7bbc86$export$2e2bcd8739ae039));
3465
3318
  const { page: page, setPage: setPage, tableDensity: tableDensity } = (0, $hgUW1$useContext)((0, $ee0d4d4f34048447$export$f814ea079e65d8fe));
3466
3319
  const defaultPageSize = 10;
3467
3320
  const schema = resource?.schema?.[distribution?.identifier] ?? resource?.schema?.[id];
@@ -3474,7 +3327,18 @@ const $a35cf16d1488f54e$var$DatasetTable = ({ isModal: isModal = false, showCopy
3474
3327
  }, {
3475
3328
  encode: true
3476
3329
  })}&format=csv`;
3477
- if (Object.keys(resource).length && columns.length && resource.schema && Object.keys(distribution).length) return /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
3330
+ const useDatastoreErrorMessages = {
3331
+ 400: {
3332
+ title: 'Data unavailable',
3333
+ message: 'This data is not available for preview at this time. Please try again later.'
3334
+ },
3335
+ 500: {
3336
+ title: 'Something went wrong',
3337
+ message: 'Something went wrong on our end. Please try again later.'
3338
+ }
3339
+ };
3340
+ // Data loaded successfully
3341
+ if (!resource.error && Object.keys(resource).length && columns.length && resource.schema && Object.keys(distribution).length) return /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
3478
3342
  children: [
3479
3343
  /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3480
3344
  className: isModal ? 'dkan-datatable-fullscreen-mode' : '',
@@ -3525,7 +3389,28 @@ const $a35cf16d1488f54e$var$DatasetTable = ({ isModal: isModal = false, showCopy
3525
3389
  })
3526
3390
  ]
3527
3391
  });
3528
- else return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Spinner), {
3392
+ else if (resource.error && !resource.loading) {
3393
+ const resourceErrorStatus = resource.error.status in useDatastoreErrorMessages ? resource.error.status : 500;
3394
+ return /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3395
+ children: [
3396
+ /*#__PURE__*/ (0, $hgUW1$jsx)("h2", {
3397
+ className: "ds-text-heading--lg ds-u-margin--0 ds-u-color--primary",
3398
+ children: useDatastoreErrorMessages[resourceErrorStatus].title
3399
+ }),
3400
+ /*#__PURE__*/ (0, $hgUW1$jsx)("p", {
3401
+ className: "ds-u-padding-bottom--2 ds-u-margin-bottom--7",
3402
+ children: useDatastoreErrorMessages[resourceErrorStatus].message
3403
+ }),
3404
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
3405
+ href: `${relativeHomeUrlPrepend}/`,
3406
+ variation: "solid",
3407
+ className: "",
3408
+ children: "Go to home"
3409
+ })
3410
+ ]
3411
+ });
3412
+ // Data loading
3413
+ } else return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Spinner), {
3529
3414
  "aria-valuetext": "Dataset loading",
3530
3415
  role: "status",
3531
3416
  className: "ds-u-margin--3"
@@ -4367,6 +4252,165 @@ var $85f8ff1ff89899c7$export$2e2bcd8739ae039 = $85f8ff1ff89899c7$var$DataTableTo
4367
4252
 
4368
4253
 
4369
4254
 
4255
+
4256
+
4257
+
4258
+
4259
+
4260
+ const $4808982eba3feb88$var$DatasetListSubmenuItem = (props)=>{
4261
+ const { title: title, identifier: identifier, linkClasses: linkClasses } = props;
4262
+ return /*#__PURE__*/ (0, $hgUW1$jsx)("li", {
4263
+ className: "dc-c-list-item",
4264
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$NavLink), {
4265
+ className: `ds-u-display-flex ds-u-align-items--center ds-u-text-align--left ${linkClasses}`,
4266
+ to: `/dataset/${identifier}`,
4267
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
4268
+ className: "ds-text-heading--md ds-u-margin-left--0",
4269
+ children: title
4270
+ })
4271
+ })
4272
+ }, identifier);
4273
+ };
4274
+ var $4808982eba3feb88$export$2e2bcd8739ae039 = $4808982eba3feb88$var$DatasetListSubmenuItem;
4275
+
4276
+
4277
+
4278
+
4279
+
4280
+
4281
+ const $10bc3aae21fc1572$var$DatasetListSubmenu = ({ rootUrl: rootUrl, enablePagination: enablePagination = true, defaultPageSize: defaultPageSize = 4, defaultSort: defaultSort = {
4282
+ defaultSort: 'modified',
4283
+ defaultOrder: 'desc'
4284
+ }, subLinkClasses: subLinkClasses })=>{
4285
+ const { ACA: ACA } = (0, $hgUW1$useContext)((0, $844981eac9b63865$export$eccc29c8d0ff408));
4286
+ const [currentResultNumbers, setCurrentResultNumbers] = (0, $hgUW1$useState)({
4287
+ total: 0,
4288
+ startingNumber: 0,
4289
+ endingNumber: 0
4290
+ });
4291
+ const [noResults, setNoResults] = (0, $hgUW1$useState)(false);
4292
+ const [totalItems, setTotalItems] = (0, $hgUW1$useState)(0);
4293
+ const pageSize = defaultPageSize;
4294
+ (0, $hgUW1$useEffect)(()=>{
4295
+ if (totalItems <= 0 && currentResultNumbers !== null) setNoResults(true);
4296
+ else setNoResults(false);
4297
+ }, [
4298
+ totalItems,
4299
+ pageSize
4300
+ ]);
4301
+ let params = {
4302
+ sort: defaultSort.defaultSort,
4303
+ ['sort-order']: defaultSort.defaultOrder,
4304
+ ['page-size']: defaultPageSize
4305
+ };
4306
+ const { data: data, isPending: isPending, error: error } = (0, $hgUW1$useQuery)({
4307
+ queryKey: [
4308
+ "datasets",
4309
+ params
4310
+ ],
4311
+ queryFn: ()=>{
4312
+ return (0, $hgUW1$axios).get(`${rootUrl}/search/?${(0, $hgUW1$qs).stringify((0, $6d5c0212e738499b$export$34e95918366a058e)(params, ACA), {
4313
+ arrayFormat: 'comma',
4314
+ encode: false
4315
+ })}`);
4316
+ }
4317
+ });
4318
+ // Sync totalItems state with API response data
4319
+ // Moved to useEffect to prevent state updates during render (which can cause infinite loops)
4320
+ (0, $hgUW1$useEffect)(()=>{
4321
+ if (data?.data?.total !== undefined && data.data.total !== totalItems) setTotalItems(data.data.total);
4322
+ }, [
4323
+ data?.data?.total
4324
+ ]);
4325
+ let submenuItemsCount = 0;
4326
+ if (data) {
4327
+ let resultsCount = Object.keys(data.data.results).length;
4328
+ // For the submenu pager, If there are fewer than 4 dataset items, display the dataset item count, otherwise, show "Viewing 4..".
4329
+ submenuItemsCount = resultsCount > defaultPageSize ? defaultPageSize : resultsCount;
4330
+ }
4331
+ return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Fragment), {
4332
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)("section", {
4333
+ className: " dkan-c-site-menu--sub-menu",
4334
+ children: isPending ? /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Spinner), {
4335
+ className: "ds-u-valign--middle",
4336
+ "aria-valuetext": "Dataset Search loading",
4337
+ role: "status"
4338
+ }) : /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
4339
+ children: [
4340
+ /*#__PURE__*/ (0, $hgUW1$jsxs)("ol", {
4341
+ 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",
4342
+ "data-testid": "submenu-results-list",
4343
+ children: [
4344
+ noResults && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Alert), {
4345
+ variation: "error",
4346
+ heading: "No results found."
4347
+ }),
4348
+ data && data.data.results ? Object.keys(data.data.results).map((key)=>{
4349
+ return data.data.results[key];
4350
+ }).map((item)=>{
4351
+ return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $4808982eba3feb88$export$2e2bcd8739ae039), {
4352
+ title: item.title,
4353
+ identifier: item.identifier,
4354
+ linkClasses: subLinkClasses
4355
+ }, item.identifier);
4356
+ }) : /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Alert), {
4357
+ variation: "error",
4358
+ heading: "Could not connect to the API."
4359
+ })
4360
+ ]
4361
+ }),
4362
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
4363
+ 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",
4364
+ children: enablePagination && /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
4365
+ children: [
4366
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
4367
+ className: "",
4368
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)("p", {
4369
+ className: "ds-u-margin-y--0 ds-u-font-size--sm",
4370
+ "aria-hidden": "true",
4371
+ children: data && /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
4372
+ children: [
4373
+ "Viewing ",
4374
+ submenuItemsCount,
4375
+ " of ",
4376
+ data.data.total
4377
+ ]
4378
+ })
4379
+ })
4380
+ }),
4381
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
4382
+ className: "",
4383
+ children: data && data.data.total > 0 && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Link), {
4384
+ className: "ds-u-padding--0 ds-c-button ds-c-button--ghost dkan-c-header--link",
4385
+ to: `../whats-new`,
4386
+ children: /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
4387
+ className: "ds-text-heading--md",
4388
+ children: [
4389
+ " ",
4390
+ `View all ${data.data.total} entries`,
4391
+ " "
4392
+ ]
4393
+ })
4394
+ })
4395
+ })
4396
+ ]
4397
+ })
4398
+ })
4399
+ ]
4400
+ })
4401
+ })
4402
+ });
4403
+ };
4404
+ var $10bc3aae21fc1572$export$2e2bcd8739ae039 = (0, $61ff88fb3f6ee2c8$export$2e2bcd8739ae039)($10bc3aae21fc1572$var$DatasetListSubmenu);
4405
+
4406
+
4407
+
4408
+
4409
+
4410
+
4411
+
4412
+
4413
+
4370
4414
  const $5b656f0283afa250$var$SpanOpenAPIVersion = function(system) {
4371
4415
  return {
4372
4416
  wrapComponents: {
@@ -4417,6 +4461,7 @@ var $ffd9c403a1c2fc39$export$2e2bcd8739ae039 = $ffd9c403a1c2fc39$var$SpanVersion
4417
4461
 
4418
4462
 
4419
4463
 
4464
+
4420
4465
  const $d42ff6af4a8dee64$var$ApiDocsInfo = ({ url: url, getComponent: getComponent, isDatasetDocs: isDatasetDocs, showRowLimitNotice: showRowLimitNotice, docsURL: docsURL })=>{
4421
4466
  const VersionStamp = getComponent("VersionStamp");
4422
4467
  const OpenAPIVersion = getComponent("OpenAPIVersion");
@@ -5330,24 +5375,24 @@ var $072291d44ce1834a$export$2e2bcd8739ae039 = $072291d44ce1834a$var$ResourceFoo
5330
5375
 
5331
5376
  const $ec3e23baa005dc03$var$Breadcrumb = ({ currentPage: currentPage, pageTrail: pageTrail = [] })=>{
5332
5377
  const pageTrailContent = pageTrail.map((page)=>/*#__PURE__*/ (0, $hgUW1$jsx)("li", {
5333
- class: "dc-c-breadcrumb__list-item",
5378
+ className: "dc-c-breadcrumb__list-item",
5334
5379
  children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Link), {
5335
5380
  to: page.path,
5336
- class: "dc-c-breadcrumb__link",
5381
+ className: "dc-c-breadcrumb__link",
5337
5382
  children: /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
5338
5383
  children: page.title
5339
5384
  })
5340
5385
  })
5341
- }));
5386
+ }, page.path));
5342
5387
  return /*#__PURE__*/ (0, $hgUW1$jsx)("nav", {
5343
- class: "dc-c-breadcrumb ds-u-margin-top--6",
5388
+ className: "dc-c-breadcrumb ds-u-margin-top--6",
5344
5389
  "aria-label": "Breadcrumbs",
5345
5390
  children: /*#__PURE__*/ (0, $hgUW1$jsxs)("ol", {
5346
- class: "dc-c-breadcrumb__list",
5391
+ className: "dc-c-breadcrumb__list",
5347
5392
  children: [
5348
5393
  pageTrailContent,
5349
5394
  currentPage ? /*#__PURE__*/ (0, $hgUW1$jsx)("li", {
5350
- class: "dc-c-breadcrumb__list-item dc-c-current",
5395
+ className: "dc-c-breadcrumb__list-item dc-c-current",
5351
5396
  "aria-current": "page",
5352
5397
  children: /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
5353
5398
  children: currentPage
@@ -6034,13 +6079,23 @@ const $1d3d480a9cfaabe0$var$useDatastore = (resourceId, rootAPIUrl, options, add
6034
6079
  }
6035
6080
  // Change whether distribution API or dataset API is used based on option
6036
6081
  const queryID = useDatasetAPI && datasetID ? `${datasetID}/0` : id;
6082
+ async function fetchJson(url) {
6083
+ const res = await fetch(url);
6084
+ const body = await res.json().catch(()=>({}));
6085
+ if (!res.ok) {
6086
+ const err = new Error(body.message || body.error || res.statusText);
6087
+ err.status = res.status;
6088
+ throw err;
6089
+ }
6090
+ return body;
6091
+ }
6037
6092
  const { data: data, isPending: isPending, error: error } = (0, $hgUW1$useQuery)({
6038
6093
  queryKey: [
6039
6094
  "datastore" + id + paramsString
6040
6095
  ],
6041
6096
  queryFn: ()=>{
6042
6097
  setCount(null);
6043
- return fetch(`${rootUrl}/datastore/query/${queryID}?${paramsString}`).then((res)=>res.json());
6098
+ return fetchJson(`${rootUrl}/datastore/query/${queryID}?${paramsString}`);
6044
6099
  },
6045
6100
  enabled: enabled
6046
6101
  });
@@ -6054,7 +6109,7 @@ const $1d3d480a9cfaabe0$var$useDatastore = (resourceId, rootAPIUrl, options, add
6054
6109
  count: true,
6055
6110
  schema: true
6056
6111
  };
6057
- return fetch(`${rootUrl}/datastore/query/${queryID}?${(0, $hgUW1$qs).stringify((0, $6d5c0212e738499b$export$34e95918366a058e)(unfilteredParams, ACA))}`).then((res)=>res.json());
6112
+ return fetchJson(`${rootUrl}/datastore/query/${queryID}?${(0, $hgUW1$qs).stringify((0, $6d5c0212e738499b$export$34e95918366a058e)(unfilteredParams, ACA))}`);
6058
6113
  }
6059
6114
  });
6060
6115
  (0, $hgUW1$useEffect)(()=>{
@@ -6077,6 +6132,7 @@ const $1d3d480a9cfaabe0$var$useDatastore = (resourceId, rootAPIUrl, options, add
6077
6132
  ]);
6078
6133
  return {
6079
6134
  loading: enabled ? isPending : false,
6135
+ error: error,
6080
6136
  values: values,
6081
6137
  count: count,
6082
6138
  columns: columns,
@@ -7421,7 +7477,8 @@ const $a0f13962e513caa1$var$Dataset = ({ id: id, rootUrl: rootUrl, customColumns
7421
7477
  customColumns: customColumns,
7422
7478
  dataDictionaryBanner: dataDictionaryBanner && displayDataDictionaryTab,
7423
7479
  datasetTableControls: !disableTableControls,
7424
- enableEmptyFilters: enableEmptyFilters
7480
+ enableEmptyFilters: enableEmptyFilters,
7481
+ relativeHomeUrlPrepend: tabHrefPrepend
7425
7482
  },
7426
7483
  children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $39bc4d98030a5599$export$2e2bcd8739ae039), {})
7427
7484
  }) : /*#__PURE__*/ (0, $hgUW1$jsx)("p", {