@civicactions/cmsds-open-data-components 3.1.3-alpha.4 → 3.1.3-alpha.dd

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,7 +1,7 @@
1
1
  import "./main.css";
2
2
  import {jsxs as $hgUW1$jsxs, jsx as $hgUW1$jsx, Fragment as $hgUW1$Fragment} from "react/jsx-runtime";
3
3
  import $hgUW1$react, {useState as $hgUW1$useState, useRef as $hgUW1$useRef, useEffect as $hgUW1$useEffect} from "react";
4
- import {Button as $hgUW1$Button, Accordion as $hgUW1$Accordion, AccordionItem as $hgUW1$AccordionItem, TextField as $hgUW1$TextField, Spinner as $hgUW1$Spinner, Dropdown as $hgUW1$Dropdown, Alert as $hgUW1$Alert, Pagination as $hgUW1$Pagination, Dialog as $hgUW1$Dialog, AddIcon as $hgUW1$AddIcon, RemoveIcon as $hgUW1$RemoveIcon, Choice as $hgUW1$Choice, Tabs as $hgUW1$Tabs, TabPanel as $hgUW1$TabPanel, Tooltip as $hgUW1$Tooltip, Badge as $hgUW1$Badge, Table as $hgUW1$Table, TableBody as $hgUW1$TableBody, TableRow as $hgUW1$TableRow, TableCell as $hgUW1$TableCell, TableHead as $hgUW1$TableHead} from "@cmsgov/design-system";
4
+ import {Button as $hgUW1$Button, Accordion as $hgUW1$Accordion, AccordionItem as $hgUW1$AccordionItem, TextField as $hgUW1$TextField, Spinner as $hgUW1$Spinner, Dropdown as $hgUW1$Dropdown, Alert as $hgUW1$Alert, Pagination as $hgUW1$Pagination, Dialog as $hgUW1$Dialog, AddIcon as $hgUW1$AddIcon, RemoveIcon as $hgUW1$RemoveIcon, Choice as $hgUW1$Choice, Tabs as $hgUW1$Tabs, TabPanel as $hgUW1$TabPanel, Tooltip as $hgUW1$Tooltip, Badge as $hgUW1$Badge, Table as $hgUW1$Table, TableBody as $hgUW1$TableBody, TableRow as $hgUW1$TableRow, TableCell as $hgUW1$TableCell, TableHead as $hgUW1$TableHead, TooltipIcon as $hgUW1$TooltipIcon} from "@cmsgov/design-system";
5
5
  import $hgUW1$proptypes from "prop-types";
6
6
  import {NavLink as $hgUW1$NavLink, useLocation as $hgUW1$useLocation, useSearchParams as $hgUW1$useSearchParams, Link as $hgUW1$Link, useNavigate as $hgUW1$useNavigate} from "react-router-dom";
7
7
  import $hgUW1$qs from "qs";
@@ -1010,7 +1010,7 @@ const $e873081a6e8f024e$var$DatasetSearch = (props)=>{
1010
1010
  ["page-size"]: pageSize !== 10 ? pageSize : undefined,
1011
1011
  ...additionalParams
1012
1012
  };
1013
- const { data: data, isPending: isPending, error: error } = (0, $hgUW1$useQuery)({
1013
+ const { data: data, isLoading: isLoading, error: error } = (0, $hgUW1$useQuery)({
1014
1014
  queryKey: [
1015
1015
  "datasets",
1016
1016
  params
@@ -1110,7 +1110,7 @@ const $e873081a6e8f024e$var$DatasetSearch = (props)=>{
1110
1110
  }),
1111
1111
  /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
1112
1112
  className: "ds-l-col--12 ds-l-sm-col--8",
1113
- children: isPending ? /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Spinner), {
1113
+ children: isLoading ? /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Spinner), {
1114
1114
  className: "ds-u-valign--middle",
1115
1115
  "aria-valuetext": "Dataset Search loading",
1116
1116
  role: "status"
@@ -1271,24 +1271,24 @@ const $b4aa9c66f2e86959$var$useMetastoreDataset = (datasetId, rootAPIUrl, additi
1271
1271
  const [id, setId] = (0, $hgUW1$useState)(datasetId);
1272
1272
  const [rootUrl, setRootUrl] = (0, $hgUW1$useState)(rootAPIUrl);
1273
1273
  const additionalParamsString = Object.keys(additionalParams).length ? `&${(0, $hgUW1$qs).stringify(additionalParams)}` : "";
1274
- const { data: data, isPending: isPending, error: error } = (0, $hgUW1$useQuery)({
1275
- queryKey: [
1276
- "metastore" + id
1277
- ],
1278
- queryFn: ()=>{
1279
- return fetch(`${rootUrl}/metastore/schemas/dataset/items/${id}?show-reference-ids${additionalParamsString}`).then((res)=>res.json()).then((res)=>{
1280
- return res;
1281
- });
1282
- }
1283
- });
1284
1274
  (0, $hgUW1$useEffect)(()=>{
1285
- if (data && data != dataset) setDataset(data);
1275
+ async function fetchData() {
1276
+ return (0, $hgUW1$axios).get(`${rootUrl}/metastore/schemas/dataset/items/${id}?show-reference-ids${additionalParamsString}`).then((res)=>setDataset(res.data)).catch((error)=>setDataset({
1277
+ title: dataset.title,
1278
+ distribution: dataset.distribution,
1279
+ error: error,
1280
+ description: dataset.description,
1281
+ identifier: dataset.identifier,
1282
+ modified: dataset.modified
1283
+ }));
1284
+ }
1285
+ fetchData();
1286
1286
  }, [
1287
- data
1287
+ id,
1288
+ rootUrl
1288
1289
  ]);
1289
1290
  return {
1290
1291
  dataset: dataset,
1291
- isPending: isPending,
1292
1292
  setId: setId,
1293
1293
  setRootUrl: setRootUrl
1294
1294
  };
@@ -1301,9 +1301,47 @@ var $b4aa9c66f2e86959$export$2e2bcd8739ae039 = $b4aa9c66f2e86959$var$useMetastor
1301
1301
 
1302
1302
 
1303
1303
 
1304
+ async function $0e7628cf73c71646$export$55f990b5477765d6(id, rootUrl, options, additionalParams) {
1305
+ const { keys: keys, limit: limit, offset: offset, conditions: conditions, sort: sort, groupings: groupings, prepareColumns: prepareColumns, properties: properties, setValues: setValues, setCount: setCount, setColumns: setColumns, setLoading: setLoading, setSchema: setSchema } = options;
1306
+ if (!id) // TODO: Throw error
1307
+ return false;
1308
+ if (typeof setLoading === "function") setLoading(true);
1309
+ return await (0, $hgUW1$axios)({
1310
+ method: "GET",
1311
+ url: `${rootUrl}/datastore/query/${id}`,
1312
+ params: {
1313
+ keys: keys,
1314
+ limit: limit,
1315
+ offset: offset,
1316
+ conditions: conditions,
1317
+ sorts: sort,
1318
+ properties: properties,
1319
+ groupings: groupings,
1320
+ ...additionalParams
1321
+ },
1322
+ //paramsSerializer: {
1323
+ // serialize: qs.stringify
1324
+ //},
1325
+ paramsSerializer: (params)=>{
1326
+ return (0, $hgUW1$qs).stringify(params);
1327
+ }
1328
+ }).then((res)=>{
1329
+ const { data: data } = res;
1330
+ const propertyKeys = data.schema[id] && data.schema[id].fields ? Object.keys(data.schema[id].fields) : [];
1331
+ setValues(data.results), setCount(data.count);
1332
+ if (propertyKeys.length) setColumns(prepareColumns ? prepareColumns(propertyKeys) : propertyKeys);
1333
+ setSchema(data.schema);
1334
+ if (typeof setLoading === "function") setLoading(false);
1335
+ return data;
1336
+ });
1337
+ }
1338
+
1339
+
1304
1340
  const $1d3d480a9cfaabe0$var$useDatastore = (resourceId, rootAPIUrl, options, additionalParams = {})=>{
1305
1341
  const keys = options.keys ? options.keys : true;
1306
1342
  const { prepareColumns: prepareColumns } = options;
1343
+ const [manual, setManual] = (0, $hgUW1$useState)(options.manual ? options.manual : false);
1344
+ const [requireConditions, setRequireConditions] = (0, $hgUW1$useState)(options.requireConditions ? options.requireConditions : false);
1307
1345
  const [values, setValues] = (0, $hgUW1$useState)([]);
1308
1346
  const [id, setResource] = (0, $hgUW1$useState)(resourceId);
1309
1347
  const [rootUrl, setRootUrl] = (0, $hgUW1$useState)(rootAPIUrl);
@@ -1311,43 +1349,63 @@ const $1d3d480a9cfaabe0$var$useDatastore = (resourceId, rootAPIUrl, options, add
1311
1349
  const [count, setCount] = (0, $hgUW1$useState)(null);
1312
1350
  const [columns, setColumns] = (0, $hgUW1$useState)([]);
1313
1351
  const [offset, setOffset] = (0, $hgUW1$useState)(options.offset ? options.offset : 0);
1352
+ const [loading, setLoading] = (0, $hgUW1$useState)(false);
1314
1353
  const [conditions, setConditions] = (0, $hgUW1$useState)(options.conditions ? options.conditions : undefined);
1315
1354
  const [sort, setSort] = (0, $hgUW1$useState)(options.sort ? options.sort : undefined);
1316
1355
  const [groupings, setGroupings] = (0, $hgUW1$useState)(options.groupings ? options.groupings : undefined);
1317
1356
  const [schema, setSchema] = (0, $hgUW1$useState)({});
1318
1357
  // const [joins, setJoins] = useState()
1319
1358
  const [properties, setProperties] = (0, $hgUW1$useState)(options.properties ? options.properties : undefined);
1320
- let params = {
1321
- keys: keys,
1322
- limit: limit,
1323
- offset: offset,
1324
- conditions: conditions,
1325
- sorts: sort,
1326
- properties: properties,
1327
- groupings: groupings,
1328
- ...additionalParams
1329
- };
1330
- const additionalParamsString = Object.keys(params).length ? `&${(0, $hgUW1$qs).stringify(params)}` : "";
1331
- const { data: data, isPending: isPending, error: error } = (0, $hgUW1$useQuery)({
1332
- queryKey: [
1333
- "datastore" + id + additionalParamsString
1334
- ],
1335
- queryFn: ()=>{
1336
- return fetch(`${rootUrl}/datastore/query/${id}?${additionalParamsString}`).then((res)=>res.json());
1337
- }
1359
+ const prevLimitRef = (0, $hgUW1$useRef)();
1360
+ const prevOffsetRef = (0, $hgUW1$useRef)();
1361
+ (0, $hgUW1$useEffect)(()=>{
1362
+ prevLimitRef.current = limit;
1363
+ prevOffsetRef.current = offset;
1338
1364
  });
1365
+ const prevLimit = prevLimitRef.current;
1366
+ const prevOffset = prevOffsetRef.current;
1367
+ function fetchData() {
1368
+ let newOffset = prevLimit === limit ? prevOffset !== offset ? offset : 0 : 0;
1369
+ setOffset(newOffset);
1370
+ (0, $0e7628cf73c71646$export$55f990b5477765d6)(id, rootUrl, {
1371
+ keys: keys,
1372
+ limit: limit,
1373
+ offset: newOffset,
1374
+ conditions: conditions,
1375
+ sort: sort,
1376
+ groupings: groupings,
1377
+ prepareColumns: prepareColumns,
1378
+ properties: properties,
1379
+ setValues: setValues,
1380
+ setCount: setCount,
1381
+ setColumns: setColumns,
1382
+ setLoading: setLoading,
1383
+ setSchema: setSchema,
1384
+ setProperties: setProperties
1385
+ }, additionalParams);
1386
+ }
1339
1387
  (0, $hgUW1$useEffect)(()=>{
1340
- if (data) {
1341
- const propertyKeys = data.schema[id] && data.schema[id].fields ? Object.keys(data.schema[id].fields) : [];
1342
- setValues(data.results), setCount(data.count);
1343
- if (propertyKeys.length) setColumns(prepareColumns ? prepareColumns(propertyKeys) : propertyKeys);
1344
- setSchema(data.schema);
1388
+ if (!loading && !manual) {
1389
+ if (!requireConditions) fetchData();
1390
+ else if (requireConditions) {
1391
+ if (conditions && conditions.length) fetchData();
1392
+ else {
1393
+ setCount(null);
1394
+ setValues([]);
1395
+ }
1396
+ }
1345
1397
  }
1346
1398
  }, [
1347
- data
1399
+ id,
1400
+ rootUrl,
1401
+ offset,
1402
+ conditions,
1403
+ sort,
1404
+ limit,
1405
+ requireConditions
1348
1406
  ]);
1349
1407
  return {
1350
- loading: isPending,
1408
+ loading: loading,
1351
1409
  values: values,
1352
1410
  count: count,
1353
1411
  columns: columns,
@@ -1363,7 +1421,10 @@ const $1d3d480a9cfaabe0$var$useDatastore = (resourceId, rootAPIUrl, options, add
1363
1421
  setLimit: setLimit,
1364
1422
  setOffset: setOffset,
1365
1423
  setConditions: setConditions,
1366
- setSort: setSort
1424
+ setSort: setSort,
1425
+ setManual: setManual,
1426
+ setRequireConditions: setRequireConditions,
1427
+ fetchData: fetchData
1367
1428
  };
1368
1429
  };
1369
1430
  var $1d3d480a9cfaabe0$export$2e2bcd8739ae039 = $1d3d480a9cfaabe0$var$useDatastore;
@@ -1613,90 +1674,101 @@ const $6da0396069e23175$export$bc27cf7ecf44639d = {
1613
1674
 
1614
1675
 
1615
1676
 
1616
- const $96d341d082bffec5$var$TruncatedResizeableTHead = ({ table: table, sortElement: sortElement, setAriaLiveFeedback: setAriaLiveFeedback })=>{
1677
+
1678
+
1679
+ const $64a351d3fd8413c3$var$HeaderResizeElement = ({ table: table, header: header, sortElement: sortElement, setAriaLiveFeedback: setAriaLiveFeedback })=>{
1617
1680
  const [columnResizing, setColumnResizing] = (0, $hgUW1$useState)("");
1681
+ return /*#__PURE__*/ (0, $hgUW1$jsxs)("th", {
1682
+ key: header.id,
1683
+ style: {
1684
+ width: header.getSize()
1685
+ },
1686
+ className: "ds-u-border-y--2 ds-u-padding--2 ds-u-border--dark ds-u-font-weight--bold",
1687
+ children: [
1688
+ /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
1689
+ className: "ds-u-display--flex",
1690
+ children: [
1691
+ /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
1692
+ style: {
1693
+ maxWidth: header.getSize() - 16
1694
+ },
1695
+ children: header.isPlaceholder ? null : (0, $hgUW1$flexRender)(header.column.columnDef.header, header.getContext())
1696
+ }),
1697
+ sortElement && /*#__PURE__*/ (0, $hgUW1$jsx)("button", {
1698
+ onClick: header.column.getToggleSortingHandler(),
1699
+ className: header.column.getCanSort() ? `cursor-pointer select-none ds-u-focus-visible ${sortElement(header.column.getIsSorted())}` : "",
1700
+ "aria-label": `${header.column.columnDef.header} sort order`
1701
+ })
1702
+ ]
1703
+ }),
1704
+ /*#__PURE__*/ (0, $hgUW1$jsx)("button", {
1705
+ onMouseDown: header.getResizeHandler(),
1706
+ onTouchStart: header.getResizeHandler(),
1707
+ className: `dc-c-resize-handle ds-u-focus-visible ${header.column.getIsResizing() || header.column.id == columnResizing ? "isResizing" : ""}`,
1708
+ "aria-label": `Resize ${header.column.columnDef.header} column`,
1709
+ onKeyDown: (e)=>{
1710
+ const columnSizingObject = table.getState().columnSizing;
1711
+ switch(e.key){
1712
+ case "Enter":
1713
+ case " ":
1714
+ e.preventDefault();
1715
+ e.stopPropagation();
1716
+ if (columnResizing) {
1717
+ // end resizing
1718
+ setColumnResizing("");
1719
+ setAriaLiveFeedback(`${header.column.columnDef.header} dropped.`);
1720
+ } else {
1721
+ // start resizing
1722
+ setColumnResizing(header.column.id);
1723
+ setAriaLiveFeedback(`${header.column.columnDef.header} grabbed.`);
1724
+ }
1725
+ break;
1726
+ case "Escape":
1727
+ if (columnResizing) {
1728
+ setColumnResizing("");
1729
+ setAriaLiveFeedback(`${header.column.columnDef.header} dropped.`);
1730
+ }
1731
+ break;
1732
+ case "ArrowRight":
1733
+ e.preventDefault();
1734
+ e.stopPropagation();
1735
+ if (columnResizing) {
1736
+ columnSizingObject[header.column.id] = header.getSize() + 10;
1737
+ table.setColumnSizing(columnSizingObject);
1738
+ setAriaLiveFeedback(`${header.column.columnDef.header} has been resized. The new width is ${header.getSize()} pixels.`);
1739
+ }
1740
+ break;
1741
+ case "ArrowLeft":
1742
+ e.preventDefault();
1743
+ e.stopPropagation();
1744
+ if (columnResizing) {
1745
+ columnSizingObject[header.column.id] = header.getSize() - 10;
1746
+ table.setColumnSizing(columnSizingObject);
1747
+ setAriaLiveFeedback(`${header.column.columnDef.header} has been resized. The new width is ${header.getSize()} pixels.`);
1748
+ }
1749
+ break;
1750
+ }
1751
+ },
1752
+ onBlur: ()=>{
1753
+ setColumnResizing("");
1754
+ }
1755
+ })
1756
+ ]
1757
+ });
1758
+ };
1759
+ var $64a351d3fd8413c3$export$2e2bcd8739ae039 = $64a351d3fd8413c3$var$HeaderResizeElement;
1760
+
1761
+
1762
+ const $96d341d082bffec5$var$TruncatedResizeableTHead = ({ table: table, sortElement: sortElement = null, setAriaLiveFeedback: setAriaLiveFeedback })=>{
1618
1763
  return /*#__PURE__*/ (0, $hgUW1$jsx)("thead", {
1619
1764
  className: "dc-thead--truncated dc-thead--resizeable",
1620
1765
  children: table.getHeaderGroups().map((headerGroup)=>/*#__PURE__*/ (0, $hgUW1$jsx)("tr", {
1621
- children: headerGroup.headers.map((header)=>{
1622
- return /*#__PURE__*/ (0, $hgUW1$jsxs)("th", {
1623
- key: header.id,
1624
- style: {
1625
- width: header.getSize()
1626
- },
1627
- title: header.column.columnDef.header,
1628
- className: "ds-u-border-y--2 ds-u-padding--2 ds-u-border--dark ds-u-font-weight--bold dc-c-table-header-cell",
1629
- children: [
1630
- /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
1631
- children: [
1632
- /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
1633
- style: {
1634
- maxWidth: header.getSize() - 16
1635
- },
1636
- children: header.isPlaceholder ? null : (0, $hgUW1$flexRender)(header.column.columnDef.header, header.getContext())
1637
- }),
1638
- /*#__PURE__*/ (0, $hgUW1$jsx)("button", {
1639
- onClick: header.column.getToggleSortingHandler(),
1640
- className: header.column.getCanSort() ? `cursor-pointer select-none ds-u-focus-visible ${sortElement(header.column.getIsSorted())}` : "",
1641
- "aria-label": `${header.column.columnDef.header} sort order`
1642
- })
1643
- ]
1644
- }),
1645
- /*#__PURE__*/ (0, $hgUW1$jsx)("button", {
1646
- onMouseDown: header.getResizeHandler(),
1647
- onTouchStart: header.getResizeHandler(),
1648
- className: `dc-c-resize-handle ds-u-focus-visible ${header.column.getIsResizing() || header.column.id == columnResizing ? "isResizing" : ""}`,
1649
- "aria-label": `Resize ${header.column.columnDef.header} column`,
1650
- onKeyDown: (e)=>{
1651
- const columnSizingObject = table.getState().columnSizing;
1652
- switch(e.key){
1653
- case "Enter":
1654
- case " ":
1655
- e.preventDefault();
1656
- e.stopPropagation();
1657
- if (columnResizing) {
1658
- // end resizing
1659
- setColumnResizing("");
1660
- setAriaLiveFeedback(`${header.column.columnDef.header} dropped.`);
1661
- } else {
1662
- // start resizing
1663
- setColumnResizing(header.column.id);
1664
- setAriaLiveFeedback(`${header.column.columnDef.header} grabbed.`);
1665
- }
1666
- break;
1667
- case "Escape":
1668
- if (columnResizing) {
1669
- setColumnResizing("");
1670
- setAriaLiveFeedback(`${header.column.columnDef.header} dropped.`);
1671
- }
1672
- break;
1673
- case "ArrowRight":
1674
- e.preventDefault();
1675
- e.stopPropagation();
1676
- if (columnResizing) {
1677
- columnSizingObject[header.column.id] = header.getSize() + 10;
1678
- table.setColumnSizing(columnSizingObject);
1679
- setAriaLiveFeedback(`${header.column.columnDef.header} has been resized. The new width is ${header.getSize()} pixels.`);
1680
- }
1681
- break;
1682
- case "ArrowLeft":
1683
- e.preventDefault();
1684
- e.stopPropagation();
1685
- if (columnResizing) {
1686
- columnSizingObject[header.column.id] = header.getSize() - 10;
1687
- table.setColumnSizing(columnSizingObject);
1688
- setAriaLiveFeedback(`${header.column.columnDef.header} has been resized. The new width is ${header.getSize()} pixels.`);
1689
- }
1690
- break;
1691
- }
1692
- },
1693
- onBlur: ()=>{
1694
- setColumnResizing("");
1695
- }
1696
- })
1697
- ]
1698
- });
1699
- })
1766
+ children: headerGroup.headers.map((header)=>/*#__PURE__*/ (0, $hgUW1$jsx)((0, $64a351d3fd8413c3$export$2e2bcd8739ae039), {
1767
+ table: table,
1768
+ header: header,
1769
+ sortElement: sortElement,
1770
+ setAriaLiveFeedback: setAriaLiveFeedback
1771
+ }))
1700
1772
  }, headerGroup.id))
1701
1773
  });
1702
1774
  };
@@ -1717,9 +1789,10 @@ const $23763e27eda0e8d7$var$FixedSizeTHead = ({ table: table, sortElement: sortE
1717
1789
  width: header.getSize()
1718
1790
  },
1719
1791
  title: header.column.columnDef.header,
1720
- className: "ds-u-border-y--2 ds-u-padding--2 ds-u-border--dark ds-u-font-weight--bold dc-c-table-header-cell",
1792
+ className: "ds-u-border-y--2 ds-u-padding--2 ds-u-border--dark ds-u-font-weight--bold",
1721
1793
  children: /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
1722
1794
  onClick: header.column.getToggleSortingHandler(),
1795
+ className: "ds-u-display--flex",
1723
1796
  children: [
1724
1797
  /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
1725
1798
  children: header.isPlaceholder ? null : (0, $hgUW1$flexRender)(header.column.columnDef.header, header.getContext())
@@ -2133,15 +2206,8 @@ var $6380a4a580b24362$export$2e2bcd8739ae039 = $6380a4a580b24362$var$DataTableHe
2133
2206
 
2134
2207
  const $bef7bff2823feea2$var$QueryTitle = ({ conditions: conditions, schema: schema, customColumns: customColumns })=>{
2135
2208
  const { fields: fields } = schema;
2136
- const prependedMessage = /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Fragment), {
2137
- children: "Data filters: "
2138
- });
2139
- if (!conditions || !conditions.length) return /*#__PURE__*/ (0, $hgUW1$jsxs)("p", {
2140
- className: "ds-u-margin-y--0",
2141
- children: [
2142
- prependedMessage,
2143
- " none"
2144
- ]
2209
+ if (!conditions || !conditions.length) return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Fragment), {
2210
+ children: "Add a filter"
2145
2211
  });
2146
2212
  function formatValue(text, property) {
2147
2213
  if (customColumns && customColumns.length > 0) {
@@ -2153,48 +2219,42 @@ const $bef7bff2823feea2$var$QueryTitle = ({ conditions: conditions, schema: sche
2153
2219
  return text;
2154
2220
  } else return text;
2155
2221
  }
2156
- return /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
2222
+ return /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
2157
2223
  className: "dc-querybuilder-title",
2158
- children: [
2159
- /*#__PURE__*/ (0, $hgUW1$jsx)("p", {
2160
- className: "ds-u-margin-y--0",
2161
- children: prependedMessage
2162
- }),
2163
- conditions.map((c)=>{
2164
- const field = fields[c.property];
2165
- const description = field && field.description ? field.description : c.property;
2166
- const operator = (0, $7264a673914aa746$export$5f89a5ae87bc48e1).find((op)=>op.value === c.operator);
2167
- const cleanedText = (0, $7264a673914aa746$export$6b5e57d20078142b)(c.value);
2168
- const formattedText = formatValue(cleanedText, c.property);
2169
- return /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
2170
- className: "ds-u-fill--background ds-u-padding--1 ds-u-margin-y--1 ds-u-display--inline-block ds-u-font-weight--semibold",
2171
- children: [
2172
- /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
2173
- className: "ds-u-font-weight--bold",
2174
- children: description
2175
- }),
2176
- " ",
2177
- /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
2178
- className: "ds-u-font-weight--normal",
2179
- children: operator.label.toUpperCase()
2180
- }),
2181
- " ",
2182
- /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
2183
- className: "ds-u-color--success",
2184
- children: formattedText
2185
- })
2186
- ]
2187
- });
2188
- }).reduce((prev, curr)=>[
2189
- prev,
2190
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Badge), {
2191
- className: "ds-u-margin-x--1",
2192
- variation: "info",
2193
- children: "AND"
2224
+ children: conditions.map((c)=>{
2225
+ const field = fields[c.property];
2226
+ const description = field && field.description ? field.description : c.property;
2227
+ const operator = (0, $7264a673914aa746$export$5f89a5ae87bc48e1).find((op)=>op.value === c.operator);
2228
+ const cleanedText = (0, $7264a673914aa746$export$6b5e57d20078142b)(c.value);
2229
+ const formattedText = formatValue(cleanedText, c.property);
2230
+ return /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
2231
+ className: "ds-u-fill--background ds-u-padding--1 ds-u-margin-y--1 ds-u-display--inline-block ds-u-font-weight--semibold",
2232
+ children: [
2233
+ /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
2234
+ className: "ds-u-font-weight--bold",
2235
+ children: description
2194
2236
  }),
2195
- curr
2196
- ])
2197
- ]
2237
+ " ",
2238
+ /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
2239
+ className: "ds-u-font-weight--normal",
2240
+ children: operator.label.toUpperCase()
2241
+ }),
2242
+ " ",
2243
+ /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
2244
+ className: "ds-u-color--success",
2245
+ children: formattedText
2246
+ })
2247
+ ]
2248
+ });
2249
+ }).reduce((prev, curr)=>[
2250
+ prev,
2251
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Badge), {
2252
+ className: "ds-u-margin-x--1",
2253
+ variation: "info",
2254
+ children: "AND"
2255
+ }),
2256
+ curr
2257
+ ])
2198
2258
  });
2199
2259
  };
2200
2260
  var $bef7bff2823feea2$export$2e2bcd8739ae039 = $bef7bff2823feea2$var$QueryTitle;
@@ -2713,8 +2773,9 @@ const $0958733ee130fc44$var$ResourceInformation = ({ resource: resource })=>{
2713
2773
  var $0958733ee130fc44$export$2e2bcd8739ae039 = $0958733ee130fc44$var$ResourceInformation;
2714
2774
 
2715
2775
 
2716
- function $f764661366bd9e1b$export$ee48b7e0e4eb536e(dist) {
2717
- if (dist && dist.data) {
2776
+
2777
+ const $7357cc0f79f9c514$var$Resource = ({ distributions: distributions, resource: resource, title: title })=>{
2778
+ function getFormatType(dist) {
2718
2779
  if (dist.data.format) return dist.data.format.toLowerCase();
2719
2780
  if (dist.data.mediaType) {
2720
2781
  const mediaType = dist.data.mediaType.split("/");
@@ -2726,13 +2787,8 @@ function $f764661366bd9e1b$export$ee48b7e0e4eb536e(dist) {
2726
2787
  if (mimeType.length && mimeType[1]) return mimeType[1].toLowerCase();
2727
2788
  }
2728
2789
  }
2790
+ return "";
2729
2791
  }
2730
- return "";
2731
- }
2732
-
2733
-
2734
-
2735
- const $7357cc0f79f9c514$var$Resource = ({ distributions: distributions, resource: resource, title: title })=>{
2736
2792
  const sm = (0, $hgUW1$useMediaQuery)({
2737
2793
  minWidth: 0,
2738
2794
  maxWidth: 767
@@ -2744,10 +2800,10 @@ const $7357cc0f79f9c514$var$Resource = ({ distributions: distributions, resource
2744
2800
  className: "ds-l-col--12 ds-u-padding-left--0 ds-text-heading--2xl",
2745
2801
  children: "Resources"
2746
2802
  }),
2747
- distributions.length ? /*#__PURE__*/ (0, $hgUW1$jsx)("ul", {
2803
+ distributions.length && /*#__PURE__*/ (0, $hgUW1$jsx)("ul", {
2748
2804
  className: "ds-c-list ds-c-list--bare dc-c-resource-full-width",
2749
2805
  children: distributions.map((dist)=>{
2750
- const fileFormat = (0, $f764661366bd9e1b$export$ee48b7e0e4eb536e)(dist);
2806
+ const fileFormat = getFormatType(dist);
2751
2807
  return /*#__PURE__*/ (0, $hgUW1$jsxs)("li", {
2752
2808
  className: `ds-u-display--flex ds-u-flex-wrap--wrap ${fileFormat !== "csv" && "ds-u-margin-bottom--2"}`,
2753
2809
  children: [
@@ -2787,8 +2843,6 @@ const $7357cc0f79f9c514$var$Resource = ({ distributions: distributions, resource
2787
2843
  ]
2788
2844
  }, dist.identifier);
2789
2845
  })
2790
- }) : /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2791
- className: "ds-u-margin-top--2"
2792
2846
  })
2793
2847
  ]
2794
2848
  });
@@ -2917,11 +2971,105 @@ var $cf6eaefd6b928de3$export$2e2bcd8739ae039 = $cf6eaefd6b928de3$var$DatasetAPI;
2917
2971
 
2918
2972
 
2919
2973
 
2920
- const $6012b86ffcaf3f71$var$DataDictionary = ({ datasetDictionary: datasetDictionary, title: title, pageSize: pageSize = 20 })=>{
2974
+
2975
+
2976
+
2977
+
2978
+
2979
+
2980
+
2981
+
2982
+
2983
+ const $6765a74df807d015$var$DataDictionaryTable = ({ tableColumns: tableColumns, tableData: tableData, count: count, pageSize: pageSize })=>{
2921
2984
  const [pagination, setPagination] = (0, $hgUW1$useState)({
2922
2985
  pageIndex: 1,
2923
2986
  pageSize: pageSize
2924
2987
  });
2988
+ const [ariaLiveFeedback, setAriaLiveFeedback] = (0, $hgUW1$useState)("");
2989
+ const table = (0, $hgUW1$useReactTable)({
2990
+ data: tableData,
2991
+ columns: tableColumns,
2992
+ columnResizeMode: "onChange",
2993
+ getCoreRowModel: (0, $hgUW1$getCoreRowModel)(),
2994
+ getPaginationRowModel: (0, $hgUW1$getPaginationRowModel)(),
2995
+ onPaginationChange: setPagination,
2996
+ state: {
2997
+ pagination: pagination
2998
+ }
2999
+ });
3000
+ return /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3001
+ children: [
3002
+ /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3003
+ className: "dc-c-datadictionary-table",
3004
+ children: [
3005
+ /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Table), {
3006
+ className: "dc-c-datatable",
3007
+ style: {
3008
+ width: "100%"
3009
+ },
3010
+ children: [
3011
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableHead), {
3012
+ className: "dc-thead--truncated dc-thead--resizeable",
3013
+ children: table.getHeaderGroups().map((headerGroup)=>/*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableRow), {
3014
+ children: headerGroup.headers.map((header)=>{
3015
+ return header.id === "titleResizable" ? /*#__PURE__*/ (0, $hgUW1$jsx)((0, $64a351d3fd8413c3$export$2e2bcd8739ae039), {
3016
+ table: table,
3017
+ header: header,
3018
+ setAriaLiveFeedback: setAriaLiveFeedback
3019
+ }, header.id + "_resize") : /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableCell), {
3020
+ key: header.id,
3021
+ className: "ds-u-border-y--2 ds-u-border--dark ds-u-border-x--0",
3022
+ children: (0, $hgUW1$flexRender)(header.column.columnDef.header, header.getContext())
3023
+ });
3024
+ })
3025
+ }, "header" + headerGroup.id))
3026
+ }),
3027
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableBody), {
3028
+ children: table.getRowModel().rows.map((row, index)=>{
3029
+ return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableRow), {
3030
+ children: row.getVisibleCells().map((cell)=>{
3031
+ return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableCell), {
3032
+ key: cell.id,
3033
+ style: {
3034
+ maxWidth: cell.column.getSize()
3035
+ },
3036
+ children: (0, $hgUW1$flexRender)(cell.column.columnDef.cell, cell.getContext())
3037
+ });
3038
+ })
3039
+ }, index + JSON.stringify(row));
3040
+ })
3041
+ })
3042
+ ]
3043
+ }),
3044
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3045
+ className: "sr-only",
3046
+ "aria-live": "assertive",
3047
+ "aria-atomic": "true",
3048
+ children: ariaLiveFeedback
3049
+ })
3050
+ ]
3051
+ }),
3052
+ count > pageSize ? /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Pagination), {
3053
+ totalPages: Math.ceil(count / pagination.pageSize),
3054
+ currentPage: pagination.pageIndex + 1,
3055
+ onPageChange: (evt, page)=>{
3056
+ evt.preventDefault();
3057
+ setPagination({
3058
+ pageIndex: page - 1,
3059
+ pageSize: pageSize
3060
+ });
3061
+ },
3062
+ renderHref: (page)=>{
3063
+ return "";
3064
+ }
3065
+ }) : ""
3066
+ ]
3067
+ });
3068
+ };
3069
+ var $6765a74df807d015$export$2e2bcd8739ae039 = $6765a74df807d015$var$DataDictionaryTable;
3070
+
3071
+
3072
+ const $a24829b27758fe6c$var$SitewideDataDictionaryTable = ({ datasetDictionary: datasetDictionary, pageSize: pageSize })=>{
2925
3073
  const columnHelper = (0, $hgUW1$createColumnHelper)();
2926
3074
  const tableColumns = [
2927
3075
  columnHelper.accessor("name", {
@@ -2937,67 +3085,117 @@ const $6012b86ffcaf3f71$var$DataDictionary = ({ datasetDictionary: datasetDictio
2937
3085
  header: "Format"
2938
3086
  })
2939
3087
  ];
2940
- const table = (0, $hgUW1$useReactTable)({
2941
- data: datasetDictionary,
2942
- columns: tableColumns,
2943
- getCoreRowModel: (0, $hgUW1$getCoreRowModel)(),
2944
- getPaginationRowModel: (0, $hgUW1$getPaginationRowModel)(),
2945
- onPaginationChange: setPagination,
2946
- state: {
2947
- pagination: pagination
3088
+ return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $6765a74df807d015$export$2e2bcd8739ae039), {
3089
+ tableColumns: tableColumns,
3090
+ tableData: datasetDictionary,
3091
+ count: datasetDictionary.length,
3092
+ pageSize: pageSize
3093
+ });
3094
+ };
3095
+ var $a24829b27758fe6c$export$2e2bcd8739ae039 = $a24829b27758fe6c$var$SitewideDataDictionaryTable;
3096
+
3097
+
3098
+
3099
+
3100
+
3101
+
3102
+
3103
+
3104
+ const $a6e312940f7003ef$var$DatasetDictionaryTable = ({ datasetDictionary: datasetDictionary, pageSize: pageSize })=>{
3105
+ const tableData = datasetDictionary.map((item)=>{
3106
+ return {
3107
+ titleResizable: item.title,
3108
+ description: item.description,
3109
+ type: item.type
3110
+ };
3111
+ });
3112
+ const columnHelper = (0, $hgUW1$createColumnHelper)();
3113
+ const tableColumns = [
3114
+ columnHelper.accessor("titleResizable", {
3115
+ header: ()=>/*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3116
+ className: "dc-c-tooltip-width-override",
3117
+ children: [
3118
+ "Title",
3119
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Tooltip), {
3120
+ title: "Title represents the column headers of the data file (e.g., Change_Type)",
3121
+ // @ts-ignore
3122
+ style: {
3123
+ border: "none",
3124
+ background: "none"
3125
+ },
3126
+ maxWidth: "400px",
3127
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TooltipIcon), {})
3128
+ })
3129
+ ]
3130
+ }),
3131
+ size: 300
3132
+ }),
3133
+ columnHelper.accessor("description", {
3134
+ header: "Description",
3135
+ minSize: 600
3136
+ }),
3137
+ columnHelper.accessor("type", {
3138
+ header: "Type",
3139
+ size: 150,
3140
+ enableResizing: false
3141
+ })
3142
+ ];
3143
+ return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $6765a74df807d015$export$2e2bcd8739ae039), {
3144
+ tableColumns: tableColumns,
3145
+ tableData: tableData,
3146
+ count: datasetDictionary.length,
3147
+ pageSize: pageSize
3148
+ });
3149
+ };
3150
+ var $a6e312940f7003ef$export$2e2bcd8739ae039 = $a6e312940f7003ef$var$DatasetDictionaryTable;
3151
+
3152
+
3153
+
3154
+ const $6012b86ffcaf3f71$var$DataDictionary = ({ datasetDictionaryEndpoint: datasetDictionaryEndpoint, datasetSitewideDictionary: datasetSitewideDictionary, title: title, pageSize: pageSize = 20, additionalParams: additionalParams })=>{
3155
+ const { data: data, isPending: isPending, error: error } = (0, $hgUW1$useQuery)({
3156
+ queryKey: [
3157
+ "dictionary" + datasetDictionaryEndpoint
3158
+ ],
3159
+ queryFn: ()=>{
3160
+ return fetch(`${datasetDictionaryEndpoint}?${(0, $hgUW1$qs).stringify(additionalParams, {
3161
+ arrayFormat: "comma",
3162
+ encode: false
3163
+ })}`).then((res)=>res.json());
2948
3164
  }
2949
3165
  });
3166
+ const datasetDictionary = data && data.data && data.data.fields.length ? data.data.fields : null;
2950
3167
  return /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
2951
3168
  children: [
2952
3169
  /*#__PURE__*/ (0, $hgUW1$jsx)("h2", {
2953
3170
  className: "ds-text-heading--2xl ds-u-margin-y--3",
2954
3171
  children: title
2955
3172
  }),
2956
- /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2957
- className: "ds-u-overflow--auto ds-u-border-x--1",
2958
- children: /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Table), {
2959
- className: "dc-c-datatable",
2960
- children: [
2961
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableHead), {
2962
- children: table.getHeaderGroups().map((headerGroup)=>/*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableRow), {
2963
- children: headerGroup.headers.map((header)=>{
2964
- return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableCell), {
2965
- children: (0, $hgUW1$flexRender)(header.column.columnDef.header, header.getContext())
2966
- });
2967
- })
2968
- }))
2969
- }),
2970
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableBody), {
2971
- children: table.getRowModel().rows.map((row, index)=>{
2972
- const even = (index + 1) % 2 === 0;
2973
- return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableRow), {
2974
- className: `${even ? "dc-c-datatable--even-row" : ""}`,
2975
- children: row.getVisibleCells().map((cell)=>{
2976
- return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableCell), {
2977
- key: cell.id,
2978
- children: (0, $hgUW1$flexRender)(cell.column.columnDef.cell, cell.getContext())
2979
- });
2980
- })
2981
- });
2982
- })
3173
+ datasetDictionary && /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
3174
+ children: [
3175
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3176
+ className: "ds-u-margin-bottom--1 ds-u-display--flex ds-u-justify-content--end",
3177
+ children: /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Button), {
3178
+ className: "ds-l-col--12 ds-l-sm-col--6 ds-l-md-col--4",
3179
+ onClick: ()=>window.open(datasetDictionaryEndpoint),
3180
+ type: "button",
3181
+ children: [
3182
+ /*#__PURE__*/ (0, $hgUW1$jsx)("i", {
3183
+ className: "fa fa-file-download ds-u-color--primary ds-u-padding-right--1"
3184
+ }),
3185
+ " View Dictionary JSON"
3186
+ ]
2983
3187
  })
2984
- ]
2985
- })
2986
- }),
2987
- datasetDictionary.length > pageSize ? /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Pagination), {
2988
- totalPages: Math.ceil(datasetDictionary.length / pagination.pageSize),
2989
- currentPage: pagination.pageIndex + 1,
2990
- onPageChange: (evt, page)=>{
2991
- evt.preventDefault();
2992
- setPagination({
2993
- pageIndex: page - 1,
3188
+ }),
3189
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $a6e312940f7003ef$export$2e2bcd8739ae039), {
3190
+ datasetDictionary: datasetDictionary,
2994
3191
  pageSize: pageSize
2995
- });
2996
- },
2997
- renderHref: (page)=>{
2998
- return "";
2999
- }
3000
- }) : ""
3192
+ })
3193
+ ]
3194
+ }),
3195
+ datasetSitewideDictionary && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $a24829b27758fe6c$export$2e2bcd8739ae039), {
3196
+ datasetDictionary: datasetSitewideDictionary,
3197
+ pageSize: pageSize
3198
+ })
3001
3199
  ]
3002
3200
  });
3003
3201
  };
@@ -3006,18 +3204,20 @@ var $6012b86ffcaf3f71$export$2e2bcd8739ae039 = (0, $61ff88fb3f6ee2c8$export$2e2b
3006
3204
 
3007
3205
 
3008
3206
 
3009
-
3010
- const $a0f13962e513caa1$var$getSiteWideDataDictionary = (rootUrl, dataDictionaryUrl)=>{
3207
+ const $a0f13962e513caa1$var$getDataDictionary = (dataDictionaryUrl, additionalParams)=>{
3011
3208
  const { data: data, isPending: isPending, error: error } = (0, $hgUW1$useQuery)({
3012
3209
  queryKey: [
3013
- "dictionary"
3210
+ "dictionary" + dataDictionaryUrl
3014
3211
  ],
3015
3212
  queryFn: ()=>{
3016
- return fetch(rootUrl + dataDictionaryUrl).then((res)=>res.json());
3213
+ return fetch(`${dataDictionaryUrl}?${(0, $hgUW1$qs).stringify(additionalParams, {
3214
+ arrayFormat: "comma",
3215
+ encode: false
3216
+ })}`).then((res)=>res.json());
3017
3217
  }
3018
3218
  });
3019
3219
  return {
3020
- siteWideDataDictionary: data,
3220
+ dataDictionary: data,
3021
3221
  dataDictionaryLoading: isPending
3022
3222
  };
3023
3223
  };
@@ -3029,7 +3229,7 @@ const $a0f13962e513caa1$var$Dataset = ({ id: id, rootUrl: rootUrl, additionalPar
3029
3229
  } : {
3030
3230
  conditions: []
3031
3231
  };
3032
- const { dataset: dataset, isPending: isPending } = (0, $b4aa9c66f2e86959$export$2e2bcd8739ae039)(id, rootUrl, additionalParams);
3232
+ const { dataset: dataset } = (0, $b4aa9c66f2e86959$export$2e2bcd8739ae039)(id, rootUrl, additionalParams);
3033
3233
  const title = dataset.title ? dataset.title : "";
3034
3234
  const metadataMapping = {
3035
3235
  ...(0, $6da0396069e23175$export$bc27cf7ecf44639d),
@@ -3043,17 +3243,25 @@ const $a0f13962e513caa1$var$Dataset = ({ id: id, rootUrl: rootUrl, additionalPar
3043
3243
  limit: defaultPageSize,
3044
3244
  manual: true
3045
3245
  }, additionalParams);
3046
- const { siteWideDataDictionary: siteWideDataDictionary } = dataDictionaryUrl ? $a0f13962e513caa1$var$getSiteWideDataDictionary(rootUrl, dataDictionaryUrl) : {
3047
- siteWideDataDictionary: null
3048
- };
3246
+ const siteWideDataDictionary = dataDictionaryUrl ? $a0f13962e513caa1$var$getDataDictionary(rootUrl + dataDictionaryUrl, additionalParams).dataDictionary : null;
3049
3247
  // compare schema fields with siteWideDataDictionary to display commonalities for now
3050
3248
  // until dataset level data dictionaries are implemented
3051
- const datasetDictionary = siteWideDataDictionary && resource && resource.schema[distribution.identifier] ? siteWideDataDictionary.data.fields.filter((field)=>{
3249
+ const datasetSitewideDictionary = siteWideDataDictionary && resource && resource.schema[distribution.identifier] ? siteWideDataDictionary.data.fields.filter((field)=>{
3052
3250
  return Object.keys(resource.schema[distribution.identifier].fields).indexOf(field.name) !== -1;
3053
3251
  }) : null;
3054
3252
  (0, $hgUW1$useEffect)(()=>{
3055
- const localFileFormat = (0, $f764661366bd9e1b$export$ee48b7e0e4eb536e)(distribution);
3056
- if (localFileFormat === "csv") resource.setResource(distribution.identifier);
3253
+ if (distribution.identifier) {
3254
+ let localFileFormat = "";
3255
+ if (distribution.data.format) localFileFormat = distribution.data.format.toUpperCase();
3256
+ else if (distribution.data.mediaType) {
3257
+ const mediaType = distribution.data.mediaType.split("/");
3258
+ if (mediaType.length && mediaType[1]) localFileFormat = mediaType[1].toUpperCase();
3259
+ }
3260
+ if (localFileFormat === "CSV") {
3261
+ resource.setResource(distribution.identifier);
3262
+ resource.setManual(false);
3263
+ }
3264
+ }
3057
3265
  }, [
3058
3266
  distribution
3059
3267
  ]);
@@ -3095,17 +3303,6 @@ const $a0f13962e513caa1$var$Dataset = ({ id: id, rootUrl: rootUrl, additionalPar
3095
3303
  })
3096
3304
  ]
3097
3305
  });
3098
- // The below code manages the selected tab in the Design System tab group manually to ensure we can still use the
3099
- // Data Table tab as the default since it no longer exists on initial render (By default, Overview will appear as default)
3100
- const getDefaultTab = ()=>{
3101
- return (0, $f764661366bd9e1b$export$ee48b7e0e4eb536e)(distribution) === "csv" ? "data-table" : "overview";
3102
- };
3103
- const [selectedTab, setSelectedTab] = (0, $hgUW1$useState)(window.location.hash.substring(1) ? window.location.hash.substring(1) : getDefaultTab());
3104
- (0, $hgUW1$useEffect)(()=>{
3105
- setSelectedTab(getDefaultTab());
3106
- }, [
3107
- distribution
3108
- ]);
3109
3306
  return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Fragment), {
3110
3307
  children: dataset.error ? /*#__PURE__*/ (0, $hgUW1$jsx)((0, $026cb986f9fea2b1$export$2e2bcd8739ae039), {
3111
3308
  content: notFoundContent,
@@ -3153,13 +3350,11 @@ const $a0f13962e513caa1$var$Dataset = ({ id: id, rootUrl: rootUrl, additionalPar
3153
3350
  className: "ds-l-row",
3154
3351
  children: /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3155
3352
  className: "ds-l-md-col--12 dc-dataset",
3156
- children: !isPending && /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Tabs), {
3157
- onChange: (selectedId, prevSelectedId)=>{
3158
- setSelectedTab(selectedId);
3159
- },
3160
- selectedId: selectedTab,
3353
+ children: distribution && distribution.data && /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Tabs), {
3354
+ onChange: function noRefCheck() {},
3355
+ defaultSelectedId: window.location.hash.substring(1),
3161
3356
  children: [
3162
- (0, $f764661366bd9e1b$export$ee48b7e0e4eb536e)(distribution) === "csv" && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TabPanel), {
3357
+ distribution.data.format === "csv" && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TabPanel), {
3163
3358
  id: "data-table",
3164
3359
  tab: /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
3165
3360
  className: "ds-u-color--primary",
@@ -3198,7 +3393,7 @@ const $a0f13962e513caa1$var$Dataset = ({ id: id, rootUrl: rootUrl, additionalPar
3198
3393
  metadataMapping: metadataMapping
3199
3394
  })
3200
3395
  }),
3201
- distribution && distribution.data && datasetDictionary && datasetDictionary.length ? /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TabPanel), {
3396
+ distribution.data && distribution.data.describedBy && distribution.data.describedByType === "application/vnd.tableschema+json" || datasetSitewideDictionary && datasetSitewideDictionary.length ? /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TabPanel), {
3202
3397
  id: "data-dictionary",
3203
3398
  tab: /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
3204
3399
  className: "ds-u-color--primary",
@@ -3211,11 +3406,13 @@ const $a0f13962e513caa1$var$Dataset = ({ id: id, rootUrl: rootUrl, additionalPar
3211
3406
  }),
3212
3407
  className: borderlessTabs ? "ds-u-border--0 ds-u-padding-x--0" : "",
3213
3408
  children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $6012b86ffcaf3f71$export$2e2bcd8739ae039), {
3214
- datasetDictionary: datasetDictionary,
3215
- title: "Data Dictionary"
3409
+ datasetSitewideDictionary: datasetSitewideDictionary,
3410
+ datasetDictionaryEndpoint: distribution.data.describedBy,
3411
+ title: "Data Dictionary",
3412
+ additionalParams: additionalParams
3216
3413
  })
3217
3414
  }) : null,
3218
- distribution && distribution.data && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TabPanel), {
3415
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TabPanel), {
3219
3416
  id: "api",
3220
3417
  tab: /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
3221
3418
  className: "ds-u-color--primary",
@@ -5369,7 +5566,10 @@ const $dd6eb2b30d7ad75d$var$FilteredResourceBody = ({ id: id, dataset: dataset,
5369
5566
  manual: true
5370
5567
  }, additionalParams);
5371
5568
  (0, $hgUW1$useEffect)(()=>{
5372
- if (distribution.identifier) resource.setResource(distribution.identifier);
5569
+ if (distribution.identifier) {
5570
+ resource.setResource(distribution.identifier);
5571
+ resource.setManual(false);
5572
+ }
5373
5573
  }, [
5374
5574
  distribution
5375
5575
  ]);