@civicactions/cmsds-open-data-components 3.6.0-rc.1 → 3.6.0-rc.2

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 {jsxs as $hgUW1$jsxs, jsx as $hgUW1$jsx, Fragment as $hgUW1$Fragment} from "react/jsx-runtime";
3
- import $hgUW1$react, {createContext as $hgUW1$createContext, useState as $hgUW1$useState, useRef as $hgUW1$useRef, useEffect as $hgUW1$useEffect, useMemo as $hgUW1$useMemo} from "react";
3
+ import $hgUW1$react, {createContext as $hgUW1$createContext, useState as $hgUW1$useState, useRef as $hgUW1$useRef, useEffect as $hgUW1$useEffect, useMemo as $hgUW1$useMemo, useContext as $hgUW1$useContext, useCallback as $hgUW1$useCallback} from "react";
4
4
  import {NavLink as $hgUW1$NavLink, useNavigate as $hgUW1$useNavigate, useLocation as $hgUW1$useLocation, useSearchParams as $hgUW1$useSearchParams, Link as $hgUW1$Link} from "react-router-dom";
5
- import {Button as $hgUW1$Button, Accordion as $hgUW1$Accordion, AccordionItem as $hgUW1$AccordionItem, 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, 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
+ import {Button as $hgUW1$Button, Accordion as $hgUW1$Accordion, AccordionItem as $hgUW1$AccordionItem, 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, Choice as $hgUW1$Choice, Tabs as $hgUW1$Tabs, TabPanel as $hgUW1$TabPanel, Table as $hgUW1$Table, TableBody as $hgUW1$TableBody, TableRow as $hgUW1$TableRow, TableCell as $hgUW1$TableCell, TableHead as $hgUW1$TableHead, Tooltip as $hgUW1$Tooltip, TooltipIcon as $hgUW1$TooltipIcon, Badge as $hgUW1$Badge} from "@cmsgov/design-system";
6
6
  import {useMediaQuery as $hgUW1$useMediaQuery} from "react-responsive";
7
7
  import $hgUW1$qs from "qs";
8
8
  import $hgUW1$swaggeruireact from "swagger-ui-react";
@@ -12,7 +12,11 @@ import {useQuery as $hgUW1$useQuery, QueryClient as $hgUW1$QueryClient, QueryCli
12
12
  import $hgUW1$dompurify from "dompurify";
13
13
  import $hgUW1$lodashtruncate from "lodash.truncate";
14
14
  import $hgUW1$proptypes from "prop-types";
15
- import {createColumnHelper as $hgUW1$createColumnHelper, useReactTable as $hgUW1$useReactTable, getCoreRowModel as $hgUW1$getCoreRowModel, getSortedRowModel as $hgUW1$getSortedRowModel, flexRender as $hgUW1$flexRender, getFilteredRowModel as $hgUW1$getFilteredRowModel, getPaginationRowModel as $hgUW1$getPaginationRowModel} from "@tanstack/react-table";
15
+ import {createColumnHelper as $hgUW1$createColumnHelper, useReactTable as $hgUW1$useReactTable, getCoreRowModel as $hgUW1$getCoreRowModel, getFilteredRowModel as $hgUW1$getFilteredRowModel, getPaginationRowModel as $hgUW1$getPaginationRowModel, getSortedRowModel as $hgUW1$getSortedRowModel, flexRender as $hgUW1$flexRender} from "@tanstack/react-table";
16
+ import {KeyboardSensor as $hgUW1$KeyboardSensor, PointerSensor as $hgUW1$PointerSensor, useSensors as $hgUW1$useSensors, useSensor as $hgUW1$useSensor, DndContext as $hgUW1$DndContext, closestCenter as $hgUW1$closestCenter} from "@dnd-kit/core";
17
+ import {sortableKeyboardCoordinates as $hgUW1$sortableKeyboardCoordinates, arrayMove as $hgUW1$arrayMove, SortableContext as $hgUW1$SortableContext, verticalListSortingStrategy as $hgUW1$verticalListSortingStrategy, useSortable as $hgUW1$useSortable} from "@dnd-kit/sortable";
18
+ import {restrictToVerticalAxis as $hgUW1$restrictToVerticalAxis} from "@dnd-kit/modifiers";
19
+ import {CSS as $hgUW1$CSS} from "@dnd-kit/utilities";
16
20
  import $hgUW1$reactdatepicker from "react-datepicker";
17
21
  import "react-datepicker/dist/react-datepicker.css";
18
22
  import {usePopper as $hgUW1$usePopper} from "react-popper";
@@ -676,7 +680,7 @@ var $b0968edc60d7d3a4$export$2e2bcd8739ae039 = $b0968edc60d7d3a4$var$SidebarPage
676
680
 
677
681
 
678
682
 
679
- const $c96c4b9ef7203c1f$var$APIPage = ({ hideAuth: hideAuth, additionalParams: additionalParams, rootUrl: rootUrl })=>{
683
+ const $c96c4b9ef7203c1f$var$APIPage = ({ hideAuth: hideAuth = true, additionalParams: additionalParams, rootUrl: rootUrl })=>{
680
684
  const hasACA = additionalParams && additionalParams.ACA ? true : false;
681
685
  let params = {
682
686
  authentication: hideAuth ? false : undefined,
@@ -694,9 +698,6 @@ const $c96c4b9ef7203c1f$var$APIPage = ({ hideAuth: hideAuth, additionalParams: a
694
698
  })
695
699
  });
696
700
  };
697
- $c96c4b9ef7203c1f$var$APIPage.defaultProps = {
698
- hideAuth: true
699
- };
700
701
  var $c96c4b9ef7203c1f$export$2e2bcd8739ae039 = $c96c4b9ef7203c1f$var$APIPage;
701
702
 
702
703
 
@@ -759,7 +760,13 @@ var $026cb986f9fea2b1$export$2e2bcd8739ae039 = $026cb986f9fea2b1$var$PageNotFoun
759
760
 
760
761
 
761
762
 
762
- const $61ff88fb3f6ee2c8$var$queryClient = new (0, $hgUW1$QueryClient)();
763
+ const $61ff88fb3f6ee2c8$var$queryClient = new (0, $hgUW1$QueryClient)({
764
+ defaultOptions: {
765
+ queries: {
766
+ refetchOnWindowFocus: false
767
+ }
768
+ }
769
+ });
763
770
  const $61ff88fb3f6ee2c8$var$withQueryProvider = (WrappedComponent)=>(props)=>{
764
771
  return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$QueryClientProvider), {
765
772
  client: $61ff88fb3f6ee2c8$var$queryClient,
@@ -1009,7 +1016,12 @@ var $b38839fd67928f42$export$2e2bcd8739ae039 = $b38839fd67928f42$var$SearchItemI
1009
1016
 
1010
1017
 
1011
1018
 
1012
- const $bd76a91923d7e8a7$var$TransformedDate = ({ date: date, options: options })=>{
1019
+ const $bd76a91923d7e8a7$var$TransformedDate = ({ date: date, options: options = {
1020
+ year: "numeric",
1021
+ month: "long",
1022
+ day: "numeric",
1023
+ timeZone: "UTC"
1024
+ } })=>{
1013
1025
  const rawDate = new Date(date);
1014
1026
  let modifiedDate = "";
1015
1027
  if (rawDate) modifiedDate = rawDate.toLocaleDateString("en-US", options);
@@ -1017,14 +1029,6 @@ const $bd76a91923d7e8a7$var$TransformedDate = ({ date: date, options: options })
1017
1029
  children: modifiedDate
1018
1030
  });
1019
1031
  };
1020
- $bd76a91923d7e8a7$var$TransformedDate.defaultProps = {
1021
- options: {
1022
- year: "numeric",
1023
- month: "long",
1024
- day: "numeric",
1025
- timeZone: "UTC"
1026
- }
1027
- };
1028
1032
  var $bd76a91923d7e8a7$export$2e2bcd8739ae039 = $bd76a91923d7e8a7$var$TransformedDate;
1029
1033
 
1030
1034
 
@@ -1363,7 +1367,10 @@ async function $eff7d34c30f5a0fc$export$2d2256cb46e92ff7(rootUrl, options, addit
1363
1367
 
1364
1368
 
1365
1369
  const $e873081a6e8f024e$var$DatasetSearch = (props)=>{
1366
- const { rootUrl: rootUrl, surveyLink: surveyLink, additionalParams: additionalParams, enableSort: enableSort, enablePagination: enablePagination = true, defaultPageSize: defaultPageSize = 10, defaultSort: defaultSort, pageTitle: pageTitle, filterTitle: filterTitle, showLargeFileWarning: showLargeFileWarning, largeFileThemes: largeFileThemes, introText: introText, showDownloadIcon: showDownloadIcon, altMobileSearchButton: altMobileSearchButton } = props;
1370
+ const { rootUrl: rootUrl, surveyLink: surveyLink, additionalParams: additionalParams, enableSort: enableSort = true, enablePagination: enablePagination = true, defaultPageSize: defaultPageSize = 10, defaultSort: defaultSort = {
1371
+ defaultSort: "modified",
1372
+ defaultOrder: "desc"
1373
+ }, pageTitle: pageTitle = "Dataset Explorer", filterTitle: filterTitle = "Tags", showLargeFileWarning: showLargeFileWarning = false, largeFileThemes: largeFileThemes, introText: introText = "", showDownloadIcon: showDownloadIcon = false, altMobileSearchButton: altMobileSearchButton } = props;
1367
1374
  const sortOptions = [
1368
1375
  {
1369
1376
  label: "Newest",
@@ -1467,7 +1474,7 @@ const $e873081a6e8f024e$var$DatasetSearch = (props)=>{
1467
1474
  page
1468
1475
  ]);
1469
1476
  (0, $hgUW1$useEffect)(()=>{
1470
- setPage(1);
1477
+ if (page !== 1 && (transformedParams.fulltext !== fulltext || transformedParams.selectedFacets !== selectedFacets)) setPage(1);
1471
1478
  }, [
1472
1479
  fulltext,
1473
1480
  selectedFacets
@@ -1709,40 +1716,6 @@ const $e873081a6e8f024e$var$DatasetSearch = (props)=>{
1709
1716
  ]
1710
1717
  });
1711
1718
  };
1712
- $e873081a6e8f024e$var$DatasetSearch.defaultProps = {
1713
- pageTitle: "Dataset Explorer",
1714
- introText: "",
1715
- fulltextLabel: "Search term",
1716
- fulltextLabelClassName: "ds-u-visibility--screen-reader",
1717
- fulltextPlaceholder: "Search datasets",
1718
- filterTitle: "Tags",
1719
- formClassName: "ds-u-display--flex ds-u-justify-content--between ds-u-margin-bottom--2",
1720
- enableSort: true,
1721
- sortOptions: [
1722
- {
1723
- label: "Newest",
1724
- value: "newest"
1725
- },
1726
- {
1727
- label: "Oldest",
1728
- value: "oldest"
1729
- },
1730
- {
1731
- label: "Title A-Z",
1732
- value: "titleAZ"
1733
- },
1734
- {
1735
- label: "Title Z-A",
1736
- value: "titleZA"
1737
- }
1738
- ],
1739
- defaultSort: {
1740
- defaultSort: "modified",
1741
- defaultOrder: "desc"
1742
- },
1743
- showLargeFileWarning: false,
1744
- showDownloadIcon: false
1745
- };
1746
1719
  var $e873081a6e8f024e$export$2e2bcd8739ae039 = (0, $61ff88fb3f6ee2c8$export$2e2bcd8739ae039)($e873081a6e8f024e$var$DatasetSearch);
1747
1720
 
1748
1721
 
@@ -2128,395 +2101,329 @@ const $6da0396069e23175$export$bc27cf7ecf44639d = {
2128
2101
 
2129
2102
 
2130
2103
 
2131
-
2132
-
2133
-
2134
-
2135
-
2136
- const $64a351d3fd8413c3$var$HeaderResizeElement = ({ table: table, header: header, sortElement: sortElement, setAriaLiveFeedback: setAriaLiveFeedback })=>{
2137
- const [columnResizing, setColumnResizing] = (0, $hgUW1$useState)("");
2138
- return /*#__PURE__*/ (0, $hgUW1$jsxs)("th", {
2139
- key: header.id,
2140
- style: {
2141
- width: header.getSize()
2142
- },
2143
- className: "ds-u-border-y--2 ds-u-padding--2 ds-u-border--dark ds-u-font-weight--bold",
2104
+ function $5644ebd2c3dbfd7b$export$eea3a12df15499ca(metadataMapping, datasetInfo) {
2105
+ const rows = [];
2106
+ Object.keys(metadataMapping).forEach((d)=>{
2107
+ if (!datasetInfo[d]) return null;
2108
+ else rows.push(...metadataMapping[d](datasetInfo[d]));
2109
+ });
2110
+ return rows;
2111
+ }
2112
+ const $5644ebd2c3dbfd7b$var$DatasetAdditionalInformation = ({ datasetInfo: datasetInfo, id: id, metadataMapping: metadataMapping })=>{
2113
+ const rows = $5644ebd2c3dbfd7b$export$eea3a12df15499ca(metadataMapping, datasetInfo);
2114
+ return /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
2115
+ className: "dc-c-additional-info-table ds-u-margin-bottom--6",
2144
2116
  children: [
2145
- /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
2146
- className: "ds-u-display--flex",
2117
+ /*#__PURE__*/ (0, $hgUW1$jsx)("h2", {
2118
+ className: "ds-text-heading--2xl ds-u-margin-y--3",
2119
+ children: "Additional Information"
2120
+ }),
2121
+ /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Table), {
2122
+ compact: true,
2123
+ striped: true,
2147
2124
  children: [
2148
- /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
2149
- style: {
2150
- maxWidth: header.getSize() - 16
2151
- },
2152
- title: header.column.columnDef.header,
2153
- children: header.isPlaceholder ? null : (0, $hgUW1$flexRender)(header.column.columnDef.header, header.getContext())
2125
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableHead), {
2126
+ children: /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$TableRow), {
2127
+ children: [
2128
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableCell), {
2129
+ children: "Field"
2130
+ }),
2131
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableCell), {
2132
+ children: "Value"
2133
+ })
2134
+ ]
2135
+ })
2154
2136
  }),
2155
- sortElement && /*#__PURE__*/ (0, $hgUW1$jsx)("button", {
2156
- onClick: header.column.getToggleSortingHandler(),
2157
- className: header.column.getCanSort() ? `cursor-pointer select-none ds-u-focus-visible ${sortElement(header.column.getIsSorted())}` : "",
2158
- "aria-label": `${header.column.columnDef.header} sort order`
2137
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableBody), {
2138
+ children: rows.map((r)=>/*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$TableRow), {
2139
+ children: [
2140
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableCell), {
2141
+ children: r.label
2142
+ }),
2143
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableCell), {
2144
+ className: "ds-u-word-break-anywhere",
2145
+ children: r.value
2146
+ })
2147
+ ]
2148
+ }, `${r.label}_${id}`))
2159
2149
  })
2160
2150
  ]
2161
- }),
2162
- /*#__PURE__*/ (0, $hgUW1$jsx)("button", {
2163
- onMouseDown: header.getResizeHandler(),
2164
- onTouchStart: header.getResizeHandler(),
2165
- className: `dc-c-resize-handle ds-u-focus-visible ${header.column.getIsResizing() || header.column.id == columnResizing ? "isResizing" : ""}`,
2166
- "aria-label": `Resize ${header.column.columnDef.header} column`,
2167
- onKeyDown: (e)=>{
2168
- const columnSizingObject = table.getState().columnSizing;
2169
- switch(e.key){
2170
- case "Enter":
2171
- case " ":
2172
- e.preventDefault();
2173
- e.stopPropagation();
2174
- if (columnResizing) {
2175
- // end resizing
2176
- setColumnResizing("");
2177
- setAriaLiveFeedback(`${header.column.columnDef.header} dropped.`);
2178
- } else {
2179
- // start resizing
2180
- setColumnResizing(header.column.id);
2181
- setAriaLiveFeedback(`${header.column.columnDef.header} grabbed.`);
2182
- }
2183
- break;
2184
- case "Escape":
2185
- if (columnResizing) {
2186
- setColumnResizing("");
2187
- setAriaLiveFeedback(`${header.column.columnDef.header} dropped.`);
2188
- }
2189
- break;
2190
- case "ArrowRight":
2191
- e.preventDefault();
2192
- e.stopPropagation();
2193
- if (columnResizing) {
2194
- columnSizingObject[header.column.id] = header.getSize() + 10;
2195
- table.setColumnSizing(columnSizingObject);
2196
- setAriaLiveFeedback(`${header.column.columnDef.header} has been resized. The new width is ${header.getSize()} pixels.`);
2197
- }
2198
- break;
2199
- case "ArrowLeft":
2200
- e.preventDefault();
2201
- e.stopPropagation();
2202
- if (columnResizing) {
2203
- columnSizingObject[header.column.id] = header.getSize() - 10;
2204
- table.setColumnSizing(columnSizingObject);
2205
- setAriaLiveFeedback(`${header.column.columnDef.header} has been resized. The new width is ${header.getSize()} pixels.`);
2206
- }
2207
- break;
2208
- }
2209
- },
2210
- onBlur: ()=>{
2211
- setColumnResizing("");
2212
- }
2213
2151
  })
2214
2152
  ]
2215
2153
  });
2216
2154
  };
2217
- var $64a351d3fd8413c3$export$2e2bcd8739ae039 = $64a351d3fd8413c3$var$HeaderResizeElement;
2155
+ var $5644ebd2c3dbfd7b$export$2e2bcd8739ae039 = $5644ebd2c3dbfd7b$var$DatasetAdditionalInformation;
2218
2156
 
2219
2157
 
2220
- const $96d341d082bffec5$var$TruncatedResizeableTHead = ({ table: table, sortElement: sortElement = null, setAriaLiveFeedback: setAriaLiveFeedback })=>{
2221
- return /*#__PURE__*/ (0, $hgUW1$jsx)("thead", {
2222
- className: "dc-thead--truncated dc-thead--resizeable",
2223
- children: table.getHeaderGroups().map((headerGroup)=>/*#__PURE__*/ (0, $hgUW1$jsx)("tr", {
2224
- className: "dc-c-sticky-header",
2225
- children: headerGroup.headers.map((header)=>/*#__PURE__*/ (0, $hgUW1$jsx)((0, $64a351d3fd8413c3$export$2e2bcd8739ae039), {
2226
- table: table,
2227
- header: header,
2228
- sortElement: sortElement,
2229
- setAriaLiveFeedback: setAriaLiveFeedback
2230
- }, header.id + "_dataTableResize"))
2231
- }, headerGroup.id))
2232
- });
2233
- };
2234
- var $96d341d082bffec5$export$2e2bcd8739ae039 = $96d341d082bffec5$var$TruncatedResizeableTHead;
2235
2158
 
2236
2159
 
2237
2160
 
2238
2161
 
2239
2162
 
2240
- const $23763e27eda0e8d7$var$FixedSizeTHead = ({ table: table, sortElement: sortElement })=>{
2241
- return /*#__PURE__*/ (0, $hgUW1$jsx)("thead", {
2242
- className: "dc-thead--fixed-size",
2243
- children: table.getHeaderGroups().map((headerGroup)=>/*#__PURE__*/ (0, $hgUW1$jsx)("tr", {
2244
- children: headerGroup.headers.map((header)=>{
2245
- return /*#__PURE__*/ (0, $hgUW1$jsx)("th", {
2246
- key: header.id,
2247
- style: {
2248
- width: header.getSize()
2249
- },
2250
- title: header.column.columnDef.header,
2251
- className: "ds-u-border-y--2 ds-u-padding--2 ds-u-border--dark ds-u-font-weight--bold",
2163
+
2164
+
2165
+ const $0958733ee130fc44$var$ResourceInformation = ({ resource: resource })=>{
2166
+ const { count: count, columns: columns } = resource;
2167
+ return /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
2168
+ className: "dc-c-resource-info-table ds-l-col--12 ds-u-padding-left--0 ds-u-margin-y--2",
2169
+ children: [
2170
+ /*#__PURE__*/ (0, $hgUW1$jsx)("h3", {
2171
+ className: "ds-u-font-size--base ds-text-heading--xl ds-text-heading--xl",
2172
+ children: "About this Resource"
2173
+ }),
2174
+ /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
2175
+ className: "ds-u-display--flex ds-u-text-align--center ds-u-justify-content--center ds-u-md-justify-content--start",
2176
+ children: [
2177
+ /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
2178
+ className: "ds-u-fill--gray-lightest ds-u-radius ds-u-margin-right--1 ds-u-padding--2",
2179
+ children: [
2180
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2181
+ className: "ds-u-padding-top--05",
2182
+ children: "Rows"
2183
+ }),
2184
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2185
+ className: "ds-u-font-weight--bold",
2186
+ children: count ? count.toLocaleString() : ""
2187
+ })
2188
+ ]
2189
+ }),
2190
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2191
+ className: "ds-u-fill--gray-lightest ds-u-radius ds-u-margin-right--1 ds-u-padding--2",
2252
2192
  children: /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
2253
- onClick: header.column.getToggleSortingHandler(),
2254
- className: "ds-u-display--flex",
2255
2193
  children: [
2256
- /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
2257
- children: header.isPlaceholder ? null : (0, $hgUW1$flexRender)(header.column.columnDef.header, header.getContext())
2194
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2195
+ className: "ds-u-padding-top--05",
2196
+ children: "Columns"
2258
2197
  }),
2259
- /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
2260
- className: header.column.getCanSort() ? `cursor-pointer select-none ${sortElement(header.column.getIsSorted())}` : ""
2198
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2199
+ className: "ds-u-font-weight--bold",
2200
+ children: columns.length.toLocaleString()
2261
2201
  })
2262
2202
  ]
2263
2203
  })
2264
- });
2265
- })
2266
- }, headerGroup.id))
2204
+ })
2205
+ ]
2206
+ })
2207
+ ]
2267
2208
  });
2268
2209
  };
2269
- var $23763e27eda0e8d7$export$2e2bcd8739ae039 = $23763e27eda0e8d7$var$FixedSizeTHead;
2210
+ var $0958733ee130fc44$export$2e2bcd8739ae039 = $0958733ee130fc44$var$ResourceInformation;
2270
2211
 
2271
2212
 
2213
+ function $f764661366bd9e1b$export$ee48b7e0e4eb536e(dist) {
2214
+ if (dist && dist.data) {
2215
+ if (dist.data.format) return dist.data.format.toLowerCase();
2216
+ if (dist.data.mediaType) {
2217
+ const mediaType = dist.data.mediaType.split("/");
2218
+ if (mediaType.length && mediaType[1]) return mediaType[1].toLowerCase();
2219
+ }
2220
+ if (dist.data["%Ref:downloadURL"].length && dist.data["%Ref:downloadURL"][0].data) {
2221
+ if (dist.data["%Ref:downloadURL"][0].data.mimeType) {
2222
+ const mimeType = dist.data["%Ref:downloadURL"][0].data.mimeType.split("/");
2223
+ if (mimeType.length && mimeType[1]) return mimeType[1].toLowerCase();
2224
+ }
2225
+ }
2226
+ }
2227
+ return "";
2228
+ }
2272
2229
 
2273
- const $d98f94c79ddf4e0e$var$DataTable = ({ data: data, columns: columns, setSort: setSort, sortTransform: sortTransform, tablePadding: tablePadding, canResize: canResize, loading: loading = false })=>{
2274
- const [sorting, setSorting] = (0, $hgUW1$react).useState([]);
2275
- const [ariaLiveFeedback, setAriaLiveFeedback] = (0, $hgUW1$useState)("");
2276
- const columnHelper = (0, $hgUW1$createColumnHelper)();
2277
- const table_columns = columns.map((col)=>{
2278
- if (col.cell) return columnHelper.accessor(col.accessor, {
2279
- header: col.header,
2280
- cell: col.cell
2281
- });
2282
- return columnHelper.accessor(col.accessor, {
2283
- header: col.header
2284
- });
2230
+
2231
+
2232
+ const $7357cc0f79f9c514$var$Resource = ({ distributions: distributions, resource: resource, title: title })=>{
2233
+ const sm = (0, $hgUW1$useMediaQuery)({
2234
+ minWidth: 0,
2235
+ maxWidth: 767
2285
2236
  });
2286
- const sortElement = (isSorted, onClickFn)=>{
2287
- if (isSorted === "asc") return "dc-c-sort--asc";
2288
- if (isSorted === "desc") return "dc-c-sort--desc";
2289
- return "dc-c-sort--default";
2290
- };
2291
- const filters = [];
2292
- const table = (0, $hgUW1$useReactTable)({
2293
- data: data,
2294
- columns: table_columns,
2295
- manualSorting: true,
2296
- state: {
2297
- sorting: sorting
2298
- },
2299
- columnResizeMode: "onChange",
2300
- onSortingChange: setSorting,
2301
- getCoreRowModel: (0, $hgUW1$getCoreRowModel)(),
2302
- getSortedRowModel: (0, $hgUW1$getSortedRowModel)(),
2303
- debugTable: false
2237
+ return /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
2238
+ className: "ds-u-display--flex ds-u-flex-wrap--wrap",
2239
+ children: [
2240
+ /*#__PURE__*/ (0, $hgUW1$jsx)("h2", {
2241
+ className: "ds-l-col--12 ds-u-padding-left--0 ds-text-heading--2xl",
2242
+ children: "Resources"
2243
+ }),
2244
+ distributions.length ? /*#__PURE__*/ (0, $hgUW1$jsx)("ul", {
2245
+ className: "ds-c-list ds-c-list--bare dc-c-resource-full-width",
2246
+ children: distributions.map((dist)=>{
2247
+ const fileFormat = (0, $f764661366bd9e1b$export$ee48b7e0e4eb536e)(dist);
2248
+ return /*#__PURE__*/ (0, $hgUW1$jsxs)("li", {
2249
+ className: `ds-u-display--flex ds-u-flex-wrap--wrap ${fileFormat !== "csv" && "ds-u-margin-bottom--2"}`,
2250
+ children: [
2251
+ /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
2252
+ className: "ds-u-font-weight--bold ds-u-font-size--lg ds-l-col--12 ds-l-md-col--6 ds-u-padding-left--0 ds-u-align-items--center ds-u-display--flex",
2253
+ children: [
2254
+ /*#__PURE__*/ (0, $hgUW1$jsx)("i", {
2255
+ className: "fa ds-u-color--primary ds-u-padding-right--1 ds-u-font-size--3xl fa-file-" + (fileFormat == "xlsx" ? "xls" : fileFormat)
2256
+ }),
2257
+ /*#__PURE__*/ (0, $hgUW1$jsxs)("p", {
2258
+ className: "ds-u-margin-top--0",
2259
+ children: [
2260
+ dist.data.title ? dist.data.title : title,
2261
+ " (" + fileFormat.toUpperCase() + ")"
2262
+ ]
2263
+ })
2264
+ ]
2265
+ }),
2266
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2267
+ className: "ds-l-col--12 ds-l-md-col--6 ds-u-text-align--center ds-u-md-text-align--right ds-u-margin-top--2 ds-u-md-margin-top--0",
2268
+ children: /*#__PURE__*/ (0, $hgUW1$jsxs)("a", {
2269
+ href: dist.data.downloadURL,
2270
+ style: {
2271
+ order: sm ? "1" : "0",
2272
+ width: sm ? "100%" : "auto"
2273
+ },
2274
+ "aria-label": `Download ${dist.data.title || title} ${fileFormat}`,
2275
+ className: "ds-c-button",
2276
+ children: [
2277
+ /*#__PURE__*/ (0, $hgUW1$jsx)("i", {
2278
+ className: "fa fa-file-download ds-u-color--primary ds-u-padding-right--1"
2279
+ }),
2280
+ "Download"
2281
+ ]
2282
+ })
2283
+ }),
2284
+ dist.data.description && /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2285
+ className: "ds-u-measure--wide ds-u-margin-bottom--7",
2286
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2287
+ className: "dc-c-metadata-description ds-u-margin--0",
2288
+ dangerouslySetInnerHTML: {
2289
+ __html: (0, $hgUW1$dompurify).sanitize(dist.data.description)
2290
+ }
2291
+ })
2292
+ }),
2293
+ fileFormat === "csv" && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $0958733ee130fc44$export$2e2bcd8739ae039), {
2294
+ resource: resource
2295
+ })
2296
+ ]
2297
+ }, dist.identifier);
2298
+ })
2299
+ }) : /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2300
+ className: "ds-u-margin-bottom--2",
2301
+ children: "No resources have been added to this dataset."
2302
+ })
2303
+ ]
2304
2304
  });
2305
- (0, $hgUW1$react).useEffect(()=>{
2306
- const normalizedSort = sortTransform ? sortTransform(sorting) : filters;
2307
- setSort(normalizedSort);
2308
- }, [
2309
- sorting
2310
- ]);
2305
+ };
2306
+ var $7357cc0f79f9c514$export$2e2bcd8739ae039 = $7357cc0f79f9c514$var$Resource;
2307
+
2308
+
2309
+ const $364dc44850cd8f7f$var$DatasetOverview = ({ dataset: dataset, resource: resource, distributions: distributions, metadataMapping: metadataMapping })=>{
2310
+ const md = (0, $hgUW1$useMediaQuery)({
2311
+ minWidth: 0,
2312
+ maxWidth: 768
2313
+ });
2314
+ const rows = (0, $5644ebd2c3dbfd7b$export$eea3a12df15499ca)(metadataMapping, dataset);
2311
2315
  return /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
2312
2316
  children: [
2317
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $7357cc0f79f9c514$export$2e2bcd8739ae039), {
2318
+ distributions: distributions,
2319
+ resource: resource,
2320
+ title: dataset.title
2321
+ }),
2313
2322
  /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
2314
- className: "dc-c-datatable-wrapper",
2315
- tabIndex: 0,
2323
+ className: "dc-c-additional-info-table ds-u-margin-bottom--6 ds-u-padding-left--0 ds-l-lg-col--7 ds-l-md-col--9 ds-l-col--12",
2316
2324
  children: [
2317
- /*#__PURE__*/ (0, $hgUW1$jsxs)("table", {
2318
- style: {
2319
- width: canResize ? table.getCenterTotalSize() : "100%"
2320
- },
2321
- className: "dc-c-datatable",
2325
+ /*#__PURE__*/ (0, $hgUW1$jsx)("h2", {
2326
+ className: "ds-text-heading--2xl ds-text-heading--2xl",
2327
+ children: "Additional Information"
2328
+ }),
2329
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Table), {
2330
+ compact: true,
2331
+ stackable: true,
2332
+ stackableBreakpoint: "md",
2333
+ warningDisabled: true,
2334
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableBody), {
2335
+ children: rows.map((r)=>/*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$TableRow), {
2336
+ children: [
2337
+ md ? "" : /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableCell), {
2338
+ component: "th",
2339
+ className: "ds-u-font-weight--bold",
2340
+ children: r.label
2341
+ }),
2342
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableCell), {
2343
+ stackedTitle: r.label,
2344
+ children: r.value
2345
+ })
2346
+ ]
2347
+ }, `${r.label}_${dataset.identifier}`))
2348
+ })
2349
+ })
2350
+ ]
2351
+ })
2352
+ ]
2353
+ });
2354
+ };
2355
+ var $364dc44850cd8f7f$export$2e2bcd8739ae039 = $364dc44850cd8f7f$var$DatasetOverview;
2356
+
2357
+
2358
+
2359
+
2360
+
2361
+
2362
+
2363
+
2364
+
2365
+ const $789279954d8eff7f$var$ApiDocumentation = ({ endpoint: endpoint })=>{
2366
+ return /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2367
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$swaggeruireact), {
2368
+ url: endpoint
2369
+ })
2370
+ });
2371
+ };
2372
+ var $789279954d8eff7f$export$2e2bcd8739ae039 = $789279954d8eff7f$var$ApiDocumentation;
2373
+
2374
+
2375
+ const $cf6eaefd6b928de3$var$DatasetAPI = ({ id: id, rootUrl: rootUrl, apiUrl: apiUrl, additionalParams: additionalParams })=>{
2376
+ return /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
2377
+ children: [
2378
+ /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
2379
+ className: "ds-u-display--flex ds-u-flex-wrap--wrap",
2380
+ children: [
2381
+ /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
2382
+ className: "ds-l-col--12 ds-l-md-col--9 ds-u-padding-left--0",
2322
2383
  children: [
2323
- canResize ? /*#__PURE__*/ (0, $hgUW1$jsx)((0, $96d341d082bffec5$export$2e2bcd8739ae039), {
2324
- table: table,
2325
- sortElement: sortElement,
2326
- setAriaLiveFeedback: setAriaLiveFeedback
2327
- }) : /*#__PURE__*/ (0, $hgUW1$jsx)((0, $23763e27eda0e8d7$export$2e2bcd8739ae039), {
2328
- table: table,
2329
- sortElement: sortElement
2384
+ /*#__PURE__*/ (0, $hgUW1$jsx)("h2", {
2385
+ className: "ds-text-heading--2xl",
2386
+ children: "Try the API"
2330
2387
  }),
2331
- loading ? /*#__PURE__*/ (0, $hgUW1$jsx)("tbody", {}) : /*#__PURE__*/ (0, $hgUW1$jsx)("tbody", {
2332
- children: table.getRowModel().rows.map((row, index)=>{
2333
- const even = (index + 1) % 2 === 0;
2334
- return /*#__PURE__*/ (0, $hgUW1$jsx)("tr", {
2335
- className: `${even ? "dc-c-datatable--even-row" : ""}`,
2336
- children: row.getVisibleCells().map((cell)=>{
2337
- let classList = "dc-truncate ds-u-padding-x--1";
2338
- return /*#__PURE__*/ (0, $hgUW1$jsx)("td", {
2339
- key: cell.id,
2340
- style: {
2341
- maxWidth: cell.column.getSize()
2342
- },
2343
- className: `${classList} ${tablePadding}`,
2344
- title: cell.getValue(),
2345
- children: (0, $hgUW1$flexRender)(cell.column.columnDef.cell, cell.getContext())
2346
- });
2347
- })
2348
- }, row.id);
2349
- })
2388
+ /*#__PURE__*/ (0, $hgUW1$jsx)("p", {
2389
+ children: "The Open Data API (ODA) provides programmatic access to this dataset including the ability to filter, query, and aggregate data."
2350
2390
  })
2351
2391
  ]
2352
2392
  }),
2353
2393
  /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2354
- className: "sr-only",
2355
- "aria-live": "assertive",
2356
- "aria-atomic": "true",
2357
- children: ariaLiveFeedback
2394
+ className: "ds-l-col--12 ds-l-md-col--3 ds-u-font-weight--bold ds-u-margin-top--2 ds-u-padding-left--0 ds-u-md-padding-left--2",
2395
+ children: /*#__PURE__*/ (0, $hgUW1$jsxs)("a", {
2396
+ href: apiUrl,
2397
+ children: [
2398
+ "View API",
2399
+ " ",
2400
+ /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
2401
+ style: {
2402
+ whiteSpace: "nowrap"
2403
+ },
2404
+ children: [
2405
+ "specification ",
2406
+ /*#__PURE__*/ (0, $hgUW1$jsx)("i", {
2407
+ className: "fa fa-arrow-right ds-u-font-weight--bold"
2408
+ })
2409
+ ]
2410
+ })
2411
+ ]
2412
+ })
2358
2413
  })
2359
2414
  ]
2360
2415
  }),
2361
- loading && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Spinner), {
2362
- "aria-valuetext": "Dataset loading",
2363
- role: "status",
2364
- className: "ds-u-margin--3"
2365
- }),
2366
- !loading && table.getRowModel().rows.length === 0 && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Alert), {
2367
- variation: "warn",
2368
- children: "No results found for the current filters"
2416
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $789279954d8eff7f$export$2e2bcd8739ae039), {
2417
+ endpoint: `${rootUrl}/metastore/schemas/dataset/items/${id}/docs${additionalParams && additionalParams.ACA ? "?ACA=" + additionalParams.ACA + "&redirect=false" : ""}`
2369
2418
  })
2370
2419
  ]
2371
2420
  });
2372
2421
  };
2373
- var $d98f94c79ddf4e0e$export$2e2bcd8739ae039 = $d98f94c79ddf4e0e$var$DataTable;
2422
+ var $cf6eaefd6b928de3$export$2e2bcd8739ae039 = $cf6eaefd6b928de3$var$DatasetAPI;
2374
2423
 
2375
2424
 
2376
- function $aa4450dcbeef3ac0$export$385a5aba38cc3325(sortArray) {
2377
- let newQuery = [];
2378
- sortArray.forEach((s)=>{
2379
- return newQuery.push({
2380
- property: s.id,
2381
- order: s.desc ? "desc" : "asc"
2382
- });
2383
- });
2384
- return newQuery;
2385
- }
2386
2425
 
2387
2426
 
2388
- // Example custom column headers, where only effective date has an ! at the end
2389
- // [
2390
- // {schema: 'date', cell: ({ value }) => localeDate(value),},
2391
- // {accessor: 'effective_date',cell: ({ value }) => localeDate(value) + '!',},
2392
- // ]
2393
- function $7264a673914aa746$export$8049e8f40a9bdfb8(customHeaders, columns, schema) {
2394
- return columns.map((column)=>{
2395
- const customAccessorIndex = customHeaders.findIndex((header)=>header.accessor === column);
2396
- const customSchemaIndex = customHeaders.findIndex((header)=>header.schema === schema.fields[column].mysql_type);
2397
- let newColumn = {};
2398
- // If specific accessor is passed, this will override a general mysql_type Cell rewrite.
2399
- if (customAccessorIndex > -1) {
2400
- newColumn.header = schema && schema.fields[column].description ? schema.fields[column].description : column;
2401
- newColumn.accessor = column;
2402
- newColumn.cell = customHeaders[customAccessorIndex].cell;
2403
- } else {
2404
- newColumn.header = schema && schema.fields[column].description ? schema.fields[column].description : column;
2405
- newColumn.accessor = column;
2406
- if (customSchemaIndex > -1) newColumn.cell = customHeaders[customSchemaIndex].cell;
2407
- }
2408
- return newColumn;
2409
- });
2410
- }
2411
- function $7264a673914aa746$export$e284ae5d89467c8f(date) {
2412
- if (!date) return date;
2413
- date = new Date(date);
2414
- date = new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
2415
- return date;
2416
- }
2417
- function $7264a673914aa746$export$6b5e57d20078142b(value, operator) {
2418
- let newValue = value;
2419
- if (Array.isArray(newValue)) newValue = newValue.join(",");
2420
- // return newValue.replace(/(^\%+|\%+$)/gm, '');
2421
- return newValue;
2422
- }
2423
- const $7264a673914aa746$export$5f89a5ae87bc48e1 = [
2424
- {
2425
- label: "Is",
2426
- value: "="
2427
- },
2428
- {
2429
- label: "Starts With",
2430
- value: "starts with"
2431
- },
2432
- {
2433
- label: "Contains",
2434
- value: "contains"
2435
- },
2436
- {
2437
- label: "Is Not",
2438
- value: "<>"
2439
- },
2440
- {
2441
- label: "Or",
2442
- value: "in"
2443
- },
2444
- {
2445
- label: "Is",
2446
- value: "="
2447
- },
2448
- {
2449
- label: "Is Not",
2450
- value: "<>"
2451
- },
2452
- {
2453
- label: "Greater Than",
2454
- value: ">"
2455
- },
2456
- {
2457
- label: "Less Than",
2458
- value: "<"
2459
- }
2460
- ];
2461
- function $7264a673914aa746$export$2b9377795161999(type) {
2462
- switch(type){
2463
- case "text":
2464
- case "string":
2465
- return [
2466
- {
2467
- label: "Is",
2468
- value: "="
2469
- },
2470
- {
2471
- label: "Starts With",
2472
- value: "starts with"
2473
- },
2474
- {
2475
- label: "Contains",
2476
- value: "contains"
2477
- },
2478
- {
2479
- label: "Is Not",
2480
- value: "<>"
2481
- },
2482
- {
2483
- label: "Or",
2484
- value: "in"
2485
- }
2486
- ];
2487
- case "date":
2488
- return [
2489
- {
2490
- label: "Is",
2491
- value: "="
2492
- },
2493
- {
2494
- label: "Is Not",
2495
- value: "<>"
2496
- },
2497
- {
2498
- label: "Greater Than",
2499
- value: ">"
2500
- },
2501
- {
2502
- label: "Less Than",
2503
- value: "<"
2504
- }
2505
- ];
2506
- default:
2507
- // These 2 should be safe for all data types
2508
- return [
2509
- {
2510
- label: "Is",
2511
- value: "="
2512
- },
2513
- {
2514
- label: "Is Not",
2515
- value: "<>"
2516
- }
2517
- ];
2518
- }
2519
- }
2520
2427
 
2521
2428
 
2522
2429
 
@@ -2525,406 +2432,307 @@ function $7264a673914aa746$export$2b9377795161999(type) {
2525
2432
 
2526
2433
 
2527
2434
 
2528
- const $2ed0091f7e32d1e6$var$DataTablePageResults = ({ totalRows: totalRows, limit: limit, offset: offset, className: className })=>{
2529
- const numTotalRows = totalRows;
2530
- if (numTotalRows === 0) return /*#__PURE__*/ (0, $hgUW1$jsx)("p", {
2531
- className: className,
2532
- children: `0 - 0 of 0 rows`
2533
- });
2534
- const ofTotal = ()=>{
2535
- if (limit >= numTotalRows) return numTotalRows;
2536
- if (limit + offset >= numTotalRows) return numTotalRows;
2537
- if (offset === 0) return limit;
2538
- return offset + limit;
2539
- };
2540
- const page = offset / limit;
2541
- const startTotal = ()=>page * limit + 1;
2542
- return /*#__PURE__*/ (0, $hgUW1$jsxs)("p", {
2543
- className: className,
2544
- children: [
2545
- "Displaying",
2546
- " ",
2547
- /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
2548
- className: "ds-u-font-weight--bold",
2549
- children: `${startTotal().toLocaleString()} - ${ofTotal().toLocaleString()}`
2550
- }),
2551
- " ",
2552
- "of ",
2553
- /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
2554
- className: "ds-u-font-weight--bold",
2555
- children: `${numTotalRows.toLocaleString()}`
2556
- }),
2557
- " ",
2558
- "results"
2559
- ]
2560
- });
2561
- };
2562
- $2ed0091f7e32d1e6$var$DataTablePageResults.defaultProps = {
2563
- className: "data-table-results"
2564
- };
2565
- $2ed0091f7e32d1e6$var$DataTablePageResults.propTypes = {
2566
- className: (0, $hgUW1$proptypes).string,
2567
- totalRows: (0, $hgUW1$proptypes).number.isRequired,
2568
- limit: (0, $hgUW1$proptypes).number.isRequired,
2569
- offset: (0, $hgUW1$proptypes).number.isRequired
2570
- };
2571
- var $2ed0091f7e32d1e6$export$2e2bcd8739ae039 = $2ed0091f7e32d1e6$var$DataTablePageResults;
2572
2435
 
2573
2436
 
2574
2437
 
2575
2438
 
2576
2439
 
2577
- const $6380a4a580b24362$var$DataTableHeader = ({ resource: resource, downloadURL: downloadURL, unfilteredDownloadURL: unfilteredDownloadURL, jsonUrl: jsonUrl, setPage: setPage })=>{
2578
- const { limit: limit, offset: offset, count: count, conditions: conditions, setLimit: setLimit, setOffset: setOffset } = resource;
2579
- const intCount = count ? count : 0;
2580
- const rowOptions = [
2581
- 10,
2582
- 25,
2583
- 50,
2584
- 100
2585
- ];
2586
- return /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
2587
- className: "ds-u-display--flex ds-u-flex-wrap--wrap ds-u-justify-content--between",
2440
+
2441
+
2442
+ const $64a351d3fd8413c3$var$HeaderResizeElement = ({ table: table, header: header, sortElement: sortElement, setAriaLiveFeedback: setAriaLiveFeedback })=>{
2443
+ const [columnResizing, setColumnResizing] = (0, $hgUW1$useState)("");
2444
+ return /*#__PURE__*/ (0, $hgUW1$jsxs)("th", {
2445
+ key: header.id,
2446
+ style: {
2447
+ width: header.getSize()
2448
+ },
2449
+ className: "ds-u-border-y--2 ds-u-padding--2 ds-u-border--dark ds-u-font-weight--bold",
2588
2450
  children: [
2589
2451
  /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
2590
- className: "dc-c-resource-header--buttons ds-u-display--flex ds-u-flex-wrap--wrap ds-u-justify-content--end ds-l-col--12 ds-u-margin-top--2 ds-u-padding-x--0",
2452
+ className: "ds-u-display--flex",
2591
2453
  children: [
2592
2454
  /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2593
- className: "ds-l-col--12 ds-l-sm-col--auto ds-u-padding-x--0 ds-u-margin-bottom--2",
2594
- children: conditions && conditions.length ? /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Tooltip), {
2595
- onOpen: ()=>{
2596
- navigator.clipboard.writeText(window.location.href);
2597
- },
2598
- className: "ds-c-button ds-u-text-align--center ds-u-display--inline-block ds-l-col--12",
2599
- placement: "bottom",
2600
- dialog: true,
2601
- ariaLabel: "Copy link to filtered data",
2602
- title: "Link copied to clipboard",
2603
- "aria-disabled": !conditions || conditions.length === 0,
2604
- children: /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
2605
- className: "ds-u-font-weight--semibold ds-u-margin-left--1 ds-u-padding--0",
2606
- children: [
2607
- /*#__PURE__*/ (0, $hgUW1$jsx)("i", {
2608
- className: "fas fa-copy"
2609
- }),
2610
- " Copy link to filtered data"
2611
- ]
2612
- })
2613
- }) : /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
2614
- "aria-disabled": true,
2615
- "aria-label": "Copy link to filtered data",
2616
- className: "ds-c-button ds-u-text-align--center ds-u-display--inline-block ds-l-col--12",
2617
- children: /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
2618
- className: "ds-u-font-weight--semibold ds-u-margin-left--1 ds-u-padding--0",
2619
- children: [
2620
- /*#__PURE__*/ (0, $hgUW1$jsx)("i", {
2621
- className: "fas fa-copy"
2622
- }),
2623
- " Copy link to filtered data"
2624
- ]
2625
- })
2455
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
2456
+ title: typeof header.column.columnDef.header === "string" ? header.column.columnDef.header : "",
2457
+ children: header.isPlaceholder ? null : (0, $hgUW1$flexRender)(header.column.columnDef.header, header.getContext())
2626
2458
  })
2627
2459
  }),
2628
- /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
2629
- className: "ds-l-col--12 ds-l-md-col--auto ds-u-padding-x--0 ds-u-display--flex ds-u-flex-wrap--wrap ds-u-justify-content--end",
2630
- children: [
2631
- /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2632
- className: "ds-l-col--12 ds-l-sm-col--auto ds-u-padding-x--0 ds-u-sm-margin-left--2 ds-u-margin-bottom--2",
2633
- children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
2634
- className: "ds-u-text-align--center ds-u-font-weight--normal ds-u-font-size--base ds-u-margin-right--1 ds-u-display--inline-block ds-l-col--12",
2635
- href: downloadURL,
2636
- "aria-disabled": !conditions || conditions.length === 0,
2637
- children: /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
2638
- className: "ds-u-font-weight--semibold ds-u-margin-left--1 ds-u-padding--0",
2639
- children: [
2640
- /*#__PURE__*/ (0, $hgUW1$jsx)("i", {
2641
- className: "fas fa-file-csv"
2642
- }),
2643
- " Download filtered data (CSV)"
2644
- ]
2645
- })
2646
- })
2647
- }),
2648
- /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2649
- className: "ds-l-col--12 ds-l-sm-col--auto ds-u-padding-x--0 ds-u-sm-margin-left--2 ds-u-margin-bottom--2",
2650
- children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
2651
- className: "ds-u-text-align--center ds-u-font-weight--normal ds-u-font-size--base ds-u-margin-right--1 ds-u-display--inline-block ds-l-col--12",
2652
- href: unfilteredDownloadURL,
2653
- children: /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
2654
- className: "ds-u-font-weight--semibold ds-u-margin-left--1 ds-u-padding--0",
2655
- children: [
2656
- /*#__PURE__*/ (0, $hgUW1$jsx)("i", {
2657
- className: "fas fa-file-csv"
2658
- }),
2659
- " Download full dataset (CSV)"
2660
- ]
2661
- })
2662
- })
2663
- })
2664
- ]
2665
- }),
2666
- jsonUrl && /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2667
- className: "ds-l-col--12 ds-l-sm-col--auto ds-u-padding-x--0 ds-u-margin-left--2 ds-u-margin-top--2 ds-u-sm-margin-top--0",
2668
- children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
2669
- className: "ds-u-text-align--center ds-u-font-weight--normal ds-u-font-size--base ds-u-margin-right--1 ds-u-display--inline-block ds-l-col--12",
2670
- href: jsonUrl,
2671
- "aria-label": "Export to .JSON",
2672
- children: /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
2673
- className: "ds-u-font-weight--semibold ds-u-margin-left--1 ds-u-padding--0",
2674
- children: [
2675
- /*#__PURE__*/ (0, $hgUW1$jsx)("i", {
2676
- className: "fas fa-file-code"
2677
- }),
2678
- " Export to JSON"
2679
- ]
2680
- })
2681
- })
2460
+ sortElement && /*#__PURE__*/ (0, $hgUW1$jsx)("button", {
2461
+ onClick: header.column.getToggleSortingHandler(),
2462
+ className: header.column.getCanSort() ? `cursor-pointer select-none ds-u-focus-visible ${sortElement(header.column.getIsSorted())}` : "",
2463
+ "aria-label": `${header.column.columnDef.header} sort order`
2682
2464
  })
2683
2465
  ]
2684
2466
  }),
2685
- /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
2686
- className: "ds-l-col--12 ds-u-display--flex ds-u-align-items--end ds-u-flex-direction--row-reverse ds-u-sm-flex-direction--row ds-u-padding-x--0 ds-u-margin-bottom--2 ds-u-flex-wrap--wrap",
2687
- children: [
2688
- /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2689
- className: "ds-l-col--12 ds-l-sm-col--8 ds-u-padding-x--0",
2690
- children: !resource.loading && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $2ed0091f7e32d1e6$export$2e2bcd8739ae039), {
2691
- totalRows: intCount,
2692
- limit: limit,
2693
- offset: offset
2694
- })
2695
- }),
2696
- /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2697
- className: "ds-l-col--12 ds-l-sm-col--4 ds-u-display--flex ds-u-justify-content--end ds-u-padding-x--0",
2698
- children: /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2699
- children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Dropdown), {
2700
- options: rowOptions.map((row)=>({
2701
- label: row.toString(),
2702
- value: row
2703
- })),
2704
- size: "medium",
2705
- label: "Rows per page:",
2706
- labelClassName: "ds-u-margin-top--0",
2707
- name: "datatable_rows_per_page",
2708
- onChange: (e)=>{
2709
- setLimit(parseInt(e.target.value));
2710
- setPage(1);
2711
- setOffset(0);
2712
- },
2713
- defaultValue: limit.toString()
2714
- })
2715
- })
2716
- })
2717
- ]
2467
+ /*#__PURE__*/ (0, $hgUW1$jsx)("button", {
2468
+ onMouseDown: header.getResizeHandler(),
2469
+ onTouchStart: header.getResizeHandler(),
2470
+ className: `dc-c-resize-handle ds-u-focus-visible ${header.column.getIsResizing() || header.column.id == columnResizing ? "isResizing" : ""}`,
2471
+ "aria-label": `Resize ${header.column.columnDef.header} column`,
2472
+ onKeyDown: (e)=>{
2473
+ const columnSizingObject = table.getState().columnSizing;
2474
+ switch(e.key){
2475
+ case "Enter":
2476
+ case " ":
2477
+ e.preventDefault();
2478
+ e.stopPropagation();
2479
+ if (columnResizing) {
2480
+ // end resizing
2481
+ setColumnResizing("");
2482
+ setAriaLiveFeedback(`${header.column.columnDef.header} dropped.`);
2483
+ } else {
2484
+ // start resizing
2485
+ setColumnResizing(header.column.id);
2486
+ setAriaLiveFeedback(`${header.column.columnDef.header} grabbed.`);
2487
+ }
2488
+ break;
2489
+ case "Escape":
2490
+ if (columnResizing) {
2491
+ setColumnResizing("");
2492
+ setAriaLiveFeedback(`${header.column.columnDef.header} dropped.`);
2493
+ }
2494
+ break;
2495
+ case "ArrowRight":
2496
+ e.preventDefault();
2497
+ e.stopPropagation();
2498
+ if (columnResizing) {
2499
+ columnSizingObject[header.column.id] = header.getSize() + 10;
2500
+ table.setColumnSizing(columnSizingObject);
2501
+ setAriaLiveFeedback(`${header.column.columnDef.header} has been resized. The new width is ${header.getSize()} pixels.`);
2502
+ }
2503
+ break;
2504
+ case "ArrowLeft":
2505
+ e.preventDefault();
2506
+ e.stopPropagation();
2507
+ if (columnResizing) {
2508
+ columnSizingObject[header.column.id] = header.getSize() - 10;
2509
+ table.setColumnSizing(columnSizingObject);
2510
+ setAriaLiveFeedback(`${header.column.columnDef.header} has been resized. The new width is ${header.getSize()} pixels.`);
2511
+ }
2512
+ break;
2513
+ }
2514
+ },
2515
+ onBlur: ()=>{
2516
+ setColumnResizing("");
2517
+ }
2718
2518
  })
2719
2519
  ]
2720
2520
  });
2721
2521
  };
2722
- var $6380a4a580b24362$export$2e2bcd8739ae039 = $6380a4a580b24362$var$DataTableHeader;
2723
-
2724
-
2725
-
2726
-
2727
-
2728
-
2729
-
2730
-
2731
-
2522
+ var $64a351d3fd8413c3$export$2e2bcd8739ae039 = $64a351d3fd8413c3$var$HeaderResizeElement;
2732
2523
 
2733
2524
 
2734
2525
 
2735
- const $bef7bff2823feea2$var$QueryTitle = ({ conditions: conditions, schema: schema, customColumns: customColumns })=>{
2736
- const { fields: fields } = schema;
2737
- const prependedMessage = /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Fragment), {
2738
- children: "Data filters: "
2739
- });
2740
- if (!conditions || !conditions.length) return /*#__PURE__*/ (0, $hgUW1$jsxs)("p", {
2741
- className: "ds-u-margin-y--0",
2742
- children: [
2743
- prependedMessage,
2744
- " none"
2745
- ]
2746
- });
2747
- function formatValue(text, property) {
2748
- if (customColumns && customColumns.length > 0) {
2749
- let newValue = text;
2750
- let customColumn = customColumns.find((c)=>c.accessor === property);
2751
- if (customColumn && customColumn.cell) return customColumn.cell({
2752
- value: text
2753
- });
2754
- return text;
2755
- } else return text;
2756
- }
2757
- return /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
2758
- className: "dc-querybuilder-title",
2759
- children: [
2760
- /*#__PURE__*/ (0, $hgUW1$jsx)("p", {
2761
- className: "ds-u-margin-y--0",
2762
- children: prependedMessage
2763
- }),
2764
- conditions.map((c)=>{
2765
- const field = fields[c.property];
2766
- const description = field && field.description ? field.description : c.property;
2767
- const operator = (0, $7264a673914aa746$export$5f89a5ae87bc48e1).find((op)=>op.value === c.operator);
2768
- const cleanedText = (0, $7264a673914aa746$export$6b5e57d20078142b)(c.value);
2769
- const formattedText = formatValue(cleanedText, c.property);
2770
- return /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
2771
- className: "ds-u-fill--background ds-u-padding--1 ds-u-margin-y--1 ds-u-display--inline-block ds-u-font-weight--semibold",
2772
- children: [
2773
- /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
2774
- className: "ds-u-font-weight--bold",
2775
- children: description
2776
- }),
2777
- " ",
2778
- /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
2779
- className: "ds-u-font-weight--normal",
2780
- children: operator.label.toUpperCase()
2781
- }),
2782
- " ",
2783
- /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
2784
- className: "ds-u-color--success",
2785
- children: formattedText
2786
- })
2787
- ]
2788
- });
2789
- }).reduce((prev, curr)=>[
2790
- prev,
2791
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Badge), {
2792
- className: "ds-u-margin-x--1",
2793
- variation: "info",
2794
- children: "AND"
2795
- }),
2796
- curr
2797
- ])
2798
- ]
2526
+ const $6765a74df807d015$var$DataDictionaryTable = ({ tableColumns: tableColumns, tableData: tableData, pageSize: pageSize, columnFilters: columnFilters })=>{
2527
+ const [sorting, setSorting] = (0, $hgUW1$useState)([]);
2528
+ const [ariaLiveFeedback, setAriaLiveFeedback] = (0, $hgUW1$useState)("");
2529
+ const mobile = (0, $hgUW1$useMediaQuery)({
2530
+ minWidth: 0,
2531
+ maxWidth: 544
2799
2532
  });
2800
- };
2801
- var $bef7bff2823feea2$export$2e2bcd8739ae039 = $bef7bff2823feea2$var$QueryTitle;
2802
-
2803
-
2804
-
2805
-
2806
-
2807
-
2808
-
2809
-
2810
- function $6369abf590ca298f$var$getStartDate(condition, schema, id) {
2811
- if (schema[id].fields[condition.property].mysql_type === "date") {
2812
- const newDate = new Date(condition.value.toString());
2813
- if (newDate instanceof Date && !isNaN(newDate.getTime())) return newDate;
2814
- }
2815
- return new Date();
2816
- }
2817
- const $6369abf590ca298f$var$QueryRow = ({ id: id, condition: condition, index: index, update: update, remove: remove, propertyOptions: propertyOptions, schema: schema })=>{
2818
- const [operator, setOperator] = (0, $hgUW1$useState)(condition.operator);
2819
- const [property, setProperty] = (0, $hgUW1$useState)(condition.property);
2820
- const [value, setValue] = (0, $hgUW1$useState)(condition.value);
2821
- const [startDate, setStartDate] = (0, $hgUW1$react).useState($6369abf590ca298f$var$getStartDate(condition, schema, id));
2822
- (0, $hgUW1$useEffect)(()=>{
2823
- if (property !== condition.property) {
2824
- if (property) update(index, "property", property);
2825
- else update(index, "property", "");
2826
- if (schema[id].fields[condition.property].mysql_type === "date") {
2827
- if (!value) setValue(startDate.toJSON().slice(0, 10));
2533
+ const sortElement = (isSorted)=>{
2534
+ if (isSorted === "asc") return "dc-c-sort--asc";
2535
+ if (isSorted === "desc") return "dc-c-sort--desc";
2536
+ return "dc-c-sort--default";
2537
+ };
2538
+ const table = (0, $hgUW1$useReactTable)({
2539
+ data: tableData,
2540
+ columns: tableColumns,
2541
+ columnResizeMode: "onChange",
2542
+ getCoreRowModel: (0, $hgUW1$getCoreRowModel)(),
2543
+ getFilteredRowModel: (0, $hgUW1$getFilteredRowModel)(),
2544
+ getPaginationRowModel: (0, $hgUW1$getPaginationRowModel)(),
2545
+ getSortedRowModel: (0, $hgUW1$getSortedRowModel)(),
2546
+ onSortingChange: setSorting,
2547
+ initialState: {
2548
+ pagination: {
2549
+ pageSize: pageSize,
2550
+ pageIndex: 0
2828
2551
  }
2552
+ },
2553
+ state: {
2554
+ sorting: sorting,
2555
+ columnFilters: columnFilters
2829
2556
  }
2830
- }, [
2831
- property,
2832
- value,
2833
- startDate,
2834
- schema,
2835
- id,
2836
- condition
2837
- ]);
2838
- (0, $hgUW1$useEffect)(()=>{
2839
- if (operator !== condition.operator) {
2840
- if (operator) update(index, "operator", operator);
2841
- else update(index, "operator", "");
2842
- }
2843
- }, [
2844
- operator
2845
- ]);
2846
- (0, $hgUW1$useEffect)(()=>{
2847
- if (value !== condition.value) {
2848
- if (value) update(index, "value", value);
2849
- else update(index, "value", "");
2557
+ });
2558
+ const sortOptions = [
2559
+ {
2560
+ value: "default",
2561
+ label: "No Sort"
2562
+ },
2563
+ {
2564
+ value: "titleasc",
2565
+ label: "Title A-Z"
2566
+ },
2567
+ {
2568
+ value: "titledesc",
2569
+ label: "Title Z-A"
2570
+ },
2571
+ {
2572
+ value: "typeasc",
2573
+ label: "Type A-Z"
2574
+ },
2575
+ {
2576
+ value: "typedesc",
2577
+ label: "Type Z-A"
2850
2578
  }
2851
- }, [
2852
- value
2853
- ]);
2854
- return /*#__PURE__*/ (0, $hgUW1$jsxs)("fieldset", {
2855
- className: "ds-u-display--flex ds-u-flex-wrap--wrap ds-u-justify-content--between ds-u-align-items--center ds-u-border--0",
2579
+ ];
2580
+ const sortStatesLookup = {
2581
+ default: [],
2582
+ titleasc: [
2583
+ {
2584
+ id: "titleResizable",
2585
+ desc: false
2586
+ }
2587
+ ],
2588
+ titledesc: [
2589
+ {
2590
+ id: "titleResizable",
2591
+ desc: true
2592
+ }
2593
+ ],
2594
+ typeasc: [
2595
+ {
2596
+ id: "type",
2597
+ desc: false
2598
+ }
2599
+ ],
2600
+ typedesc: [
2601
+ {
2602
+ id: "type",
2603
+ desc: true
2604
+ }
2605
+ ]
2606
+ };
2607
+ return /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
2856
2608
  children: [
2857
- /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
2858
- className: "ds-l-col--12 ds-l-md-col--8 ds-u-display--flex ds-u-justify-content--between ds-u-padding-x--0",
2859
- children: [
2860
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Dropdown), {
2861
- options: propertyOptions,
2862
- className: "ds-l-col--8 ds-u-padding-left--0",
2863
- value: property,
2864
- label: "Column Name",
2865
- name: `${condition.key}_property`,
2866
- onChange: (e)=>setProperty(e.target.value)
2609
+ mobile && /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2610
+ className: "ds-u-margin-bottom--3 ds-l-col--12 ds-l-sm-col--6",
2611
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Dropdown), {
2612
+ labelClassName: "ds-u-margin-top--1 ds-u-sm-margin-top--0",
2613
+ options: sortOptions,
2614
+ label: "Sort",
2615
+ value: Object.keys(sortStatesLookup).find((key)=>{
2616
+ return JSON.stringify(sortStatesLookup[key]) == JSON.stringify(sorting);
2867
2617
  }),
2868
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Dropdown), {
2869
- options: (0, $7264a673914aa746$export$2b9377795161999)(schema[id].fields[property].mysql_type),
2870
- className: "ds-l-col--4 ds-u-padding-x--0",
2871
- value: operator,
2872
- label: "Operator",
2873
- name: `${condition.key}_operator`,
2874
- onChange: (e)=>setOperator(e.target.value)
2875
- })
2876
- ]
2618
+ name: "dc-data-dictionary-type",
2619
+ onChange: (e)=>{
2620
+ setSorting(sortStatesLookup[e.target.value]);
2621
+ }
2622
+ })
2877
2623
  }),
2878
2624
  /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
2879
- className: "ds-l-col--12 ds-l-md-col--4 ds-u-padding-x--0 ds-u-md-padding-left--2 ds-u-display--flex ds-u-justify-content--between",
2625
+ className: "dc-c-datadictionary-table",
2880
2626
  children: [
2881
- schema[id].fields[property].mysql_type === "date" ? /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
2627
+ /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Table), {
2628
+ className: "dc-c-datatable",
2629
+ style: {
2630
+ width: "100%"
2631
+ },
2632
+ stackable: true,
2882
2633
  children: [
2883
- /*#__PURE__*/ (0, $hgUW1$jsx)("label", {
2884
- className: "ds-c-label",
2885
- htmlFor: `${condition.key}_date_value`,
2886
- id: `${condition.key}_date_value-label`,
2887
- children: /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
2888
- children: "Value"
2889
- })
2634
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableHead), {
2635
+ className: "dc-thead--truncated dc-thead--resizeable",
2636
+ children: table.getHeaderGroups().map((headerGroup)=>/*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableRow), {
2637
+ children: headerGroup.headers.map((header)=>{
2638
+ return header.id === "titleResizable" ? /*#__PURE__*/ (0, $hgUW1$jsx)((0, $64a351d3fd8413c3$export$2e2bcd8739ae039), {
2639
+ table: table,
2640
+ header: header,
2641
+ setAriaLiveFeedback: setAriaLiveFeedback,
2642
+ sortElement: sortElement
2643
+ }, header.id + "_resize") : /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$TableCell), {
2644
+ key: header.id,
2645
+ className: `ds-u-border-y--2 ds-u-border--dark ds-u-border-x--0`,
2646
+ id: "dataDictionary_" + header.id,
2647
+ children: [
2648
+ (0, $hgUW1$flexRender)(header.column.columnDef.header, header.getContext()),
2649
+ header.id === "type" && /*#__PURE__*/ (0, $hgUW1$jsx)("button", {
2650
+ onClick: header.column.getToggleSortingHandler(),
2651
+ className: header.column.getCanSort() ? `cursor-pointer select-none ds-u-focus-visible ${sortElement(header.column.getIsSorted())}` : "",
2652
+ "aria-label": `${header.column.columnDef.header} sort order`
2653
+ })
2654
+ ]
2655
+ });
2656
+ })
2657
+ }, "header" + headerGroup.id))
2890
2658
  }),
2891
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$reactdatepicker), {
2892
- name: `${condition.key}_date_value`,
2893
- selected: (0, $7264a673914aa746$export$e284ae5d89467c8f)(startDate),
2894
- onChange: (date)=>{
2895
- setStartDate(date);
2896
- setValue(date.toJSON().slice(0, 10));
2897
- },
2898
- showMonthDropdown: true,
2899
- showYearDropdown: true,
2900
- dropdownMode: "select",
2901
- className: "ds-c-field",
2902
- withPortal: true
2659
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableBody), {
2660
+ children: table.getRowModel().rows.map((row, index)=>{
2661
+ return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableRow), {
2662
+ children: row.getVisibleCells().map((cell)=>{
2663
+ return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableCell), {
2664
+ key: cell.id,
2665
+ style: {
2666
+ maxWidth: mobile ? "100%" : cell.column.getSize(),
2667
+ whiteSpace: cell.column.id === "description" ? "pre-wrap" : "normal"
2668
+ },
2669
+ className: `${cell.column.id === "titleResizable" ? "ds-u-word-break" : ""}`,
2670
+ headers: "dataDictionary_" + cell.column.id,
2671
+ stackedTitle: cell.column.id === "titleResizable" ? "Title" : cell.column.columnDef.header,
2672
+ children: (0, $hgUW1$flexRender)(cell.column.columnDef.cell, cell.getContext())
2673
+ });
2674
+ })
2675
+ }, index + JSON.stringify(row));
2676
+ })
2903
2677
  })
2904
2678
  ]
2905
- }) : /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TextField), {
2906
- className: "ds-l-col--11 ds-u-padding-x--0",
2907
- label: "Value",
2908
- name: `${condition.key}_value`,
2909
- value: (0, $7264a673914aa746$export$6b5e57d20078142b)(value, operator),
2910
- onChange: (e)=>setValue(e.target.value)
2911
2679
  }),
2912
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
2913
- variation: "ghost",
2914
- size: "small",
2915
- className: "ds-u-margin-top--6 ds-u-padding-right--0",
2916
- "aria-label": "Delete filter",
2917
- onClick: ()=>remove(index),
2918
- children: /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
2919
- className: "fas fa-trash"
2920
- })
2680
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2681
+ className: "sr-only",
2682
+ "aria-live": "assertive",
2683
+ "aria-atomic": "true",
2684
+ children: ariaLiveFeedback
2685
+ }),
2686
+ table.getRowModel().rows.length === 0 && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Alert), {
2687
+ variation: "warn",
2688
+ children: "No results found for the current filters"
2921
2689
  })
2922
2690
  ]
2923
- })
2691
+ }),
2692
+ table.getRowCount() > pageSize ? /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Pagination), {
2693
+ totalPages: table.getPageCount(),
2694
+ currentPage: table.getState().pagination.pageIndex + 1,
2695
+ onPageChange: (evt, page)=>{
2696
+ evt.preventDefault();
2697
+ table.setPageIndex(page - 1);
2698
+ },
2699
+ renderHref: (page)=>`/page=${page}`
2700
+ }) : ""
2924
2701
  ]
2925
2702
  });
2926
2703
  };
2927
- var $6369abf590ca298f$export$2e2bcd8739ae039 = $6369abf590ca298f$var$QueryRow;
2704
+ var $6765a74df807d015$export$2e2bcd8739ae039 = $6765a74df807d015$var$DataDictionaryTable;
2705
+
2706
+
2707
+ const $a24829b27758fe6c$var$SitewideDataDictionaryTable = ({ datasetDictionary: datasetDictionary, pageSize: pageSize })=>{
2708
+ const columnHelper = (0, $hgUW1$createColumnHelper)();
2709
+ const tableColumns = [
2710
+ columnHelper.accessor("name", {
2711
+ header: "Name"
2712
+ }),
2713
+ columnHelper.accessor("title", {
2714
+ header: "Title"
2715
+ }),
2716
+ columnHelper.accessor("type", {
2717
+ header: "Type"
2718
+ }),
2719
+ columnHelper.accessor("format", {
2720
+ header: "Format"
2721
+ })
2722
+ ];
2723
+ return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $6765a74df807d015$export$2e2bcd8739ae039), {
2724
+ tableColumns: tableColumns,
2725
+ tableData: datasetDictionary,
2726
+ pageSize: pageSize
2727
+ });
2728
+ };
2729
+ var $a24829b27758fe6c$export$2e2bcd8739ae039 = $a24829b27758fe6c$var$SitewideDataDictionaryTable;
2730
+
2731
+
2732
+
2733
+
2734
+
2735
+
2928
2736
 
2929
2737
 
2930
2738
 
@@ -2947,260 +2755,224 @@ const $2eec38d4d0dbf714$var$ClearFiltersButton = ({ disabled: disabled = false,
2947
2755
  var $2eec38d4d0dbf714$export$2e2bcd8739ae039 = $2eec38d4d0dbf714$var$ClearFiltersButton;
2948
2756
 
2949
2757
 
2950
- function $ee4ad47aa483e5b5$var$updateQueryForDatastore(condition) {
2951
- let cond = condition;
2952
- delete cond.key;
2953
- if (cond.operator === "=" || cond.operator === "<>") {
2954
- if (Array.isArray(cond.value)) cond.value = cond.value.join();
2955
- cond.value = cond.value.replace(/(^\%+|\%+$)/gm, "");
2956
- }
2957
- if (cond.operator.toLowerCase() === "like") {
2958
- if (Array.isArray(cond.value)) cond.value = cond.value.join();
2959
- const cleanedValue = cond.value.replace(/(^\%+|\%+$)/gm, "");
2960
- cond.value = `%${cleanedValue}%`;
2961
- }
2962
- if (cond.operator.toLowerCase() === "in") {
2963
- if (!Array.isArray(cond.value)) cond.value = cond.value.split(",");
2964
- }
2965
- if (Array.isArray(cond.value)) cond.value = cond.value.map((v)=>v.trim().replace(/(^\%+|\%+$)/gm, ""));
2966
- return cond;
2967
- }
2968
- const $ee4ad47aa483e5b5$var$QueryBuilder = (props)=>{
2969
- const { resource: resource, id: id, includeSearchParams: includeSearchParams, customColumns: customColumns } = props;
2970
- const { conditions: conditions, schema: schema, setConditions: setConditions } = resource;
2971
- const fields = Object.keys(schema[id].fields);
2972
- const [conditionsCleared, setConditionsCleared] = (0, $hgUW1$useState)(false);
2973
- const [queryConditions, setQueryConditions] = (0, $hgUW1$useState)([]);
2974
- const [titleConditions, setTitleConditions] = (0, $hgUW1$useState)([]); // Add use effect to load conditions on first load if needed
2975
- const [conditionsChanged, setConditionsChanged] = (0, $hgUW1$useState)(false);
2976
- const small = (0, $hgUW1$useMediaQuery)({
2977
- minWidth: 0,
2978
- maxWidth: 544
2979
- });
2980
- const addCondition = (condition)=>{
2981
- if (Array.isArray(condition)) {
2982
- const keyedConditions = condition.map((oc)=>({
2983
- ...oc,
2984
- key: Date.now().toString() + oc.value + oc.property
2985
- }));
2986
- setQueryConditions(keyedConditions);
2987
- } else setQueryConditions([
2988
- ...queryConditions,
2758
+ const $a6e312940f7003ef$var$DatasetDictionaryTable = ({ datasetDictionary: datasetDictionary, pageSize: pageSize })=>{
2759
+ const [titleFilter, setTitleFilter] = (0, $hgUW1$useState)("");
2760
+ const [typeFilter, setTypeFilter] = (0, $hgUW1$useState)("all");
2761
+ const columnFilters = (0, $hgUW1$useMemo)(()=>[
2989
2762
  {
2990
- property: fields[0],
2991
- value: "",
2992
- operator: (0, $7264a673914aa746$export$2b9377795161999)(schema[id].fields[fields[0]].mysql_type)[0].value,
2993
- key: Date.now().toString()
2763
+ id: "titleResizable",
2764
+ value: titleFilter
2765
+ },
2766
+ {
2767
+ id: "type",
2768
+ value: typeFilter === "all" ? "" : typeFilter
2994
2769
  }
2995
- ]);
2996
- };
2997
- (0, $hgUW1$react).useEffect(()=>{
2998
- if (conditions && conditions.length) addCondition(conditions);
2999
- else addCondition(null);
3000
- setTitleConditions(conditions);
3001
- }, []);
3002
- (0, $hgUW1$react).useEffect(()=>{
3003
- if (conditionsCleared) {
3004
- submitConditions(new Event("submit"));
3005
- setConditionsCleared(false);
3006
- }
3007
- }, [
3008
- conditionsCleared
2770
+ ], [
2771
+ titleFilter,
2772
+ typeFilter
3009
2773
  ]);
3010
- const propertyOptions = fields.map((f)=>{
3011
- if (schema[id].fields[f].description) return {
3012
- label: schema[id].fields[f].description,
3013
- value: f
3014
- };
2774
+ const tableData = datasetDictionary.map((item)=>{
3015
2775
  return {
3016
- label: f,
3017
- value: f
2776
+ titleResizable: item.title,
2777
+ description: item.description,
2778
+ type: item.type
3018
2779
  };
3019
2780
  });
3020
- const submitConditions = (e)=>{
3021
- e.preventDefault();
3022
- const submitConditions = queryConditions.filter((oc)=>{
3023
- if (oc.property) return oc;
3024
- return false;
3025
- }).map((oc)=>{
3026
- let cond = Object.assign({}, oc);
3027
- return $ee4ad47aa483e5b5$var$updateQueryForDatastore(cond);
3028
- });
3029
- setConditions(submitConditions);
3030
- setTitleConditions(queryConditions.map((oc)=>Object.assign({}, oc)));
3031
- setConditionsChanged(false);
3032
- if (includeSearchParams) {
3033
- const url = new URL(window.location.href);
3034
- const urlString = (0, $hgUW1$qs).stringify({
3035
- conditions: submitConditions
3036
- }, {
3037
- encodeValuesOnly: true,
3038
- addQueryPrefix: true
3039
- });
3040
- window.history.pushState({}, "", `${url.origin}${url.pathname}${urlString}`);
3041
- }
3042
- };
3043
- const updateCondition = (index, key, value)=>{
3044
- let newConditions = [
3045
- ...queryConditions
3046
- ];
3047
- newConditions[index][key] = value;
3048
- setQueryConditions(newConditions);
3049
- setConditionsChanged(true);
3050
- };
3051
- const removeCondition = (index)=>{
3052
- let newConditions = queryConditions.map((oc)=>Object.assign({}, oc));
3053
- newConditions.splice(index, 1);
3054
- setQueryConditions(newConditions);
3055
- setConditionsChanged(true);
3056
- setConditionsCleared(true);
3057
- };
3058
- return /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3059
- className: "dc-query-builder ds-u-margin-bottom--3",
3060
- children: /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3061
- className: "ds-c-accordion ds-c-accordion--bordered",
3062
- children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$AccordionItem), {
3063
- heading: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $bef7bff2823feea2$export$2e2bcd8739ae039), {
3064
- schema: schema[id],
3065
- conditions: titleConditions,
3066
- customColumns: customColumns
3067
- }),
3068
- defaultOpen: true,
3069
- children: /*#__PURE__*/ (0, $hgUW1$jsxs)("form", {
3070
- onSubmit: (e)=>submitConditions(e),
2781
+ const columnHelper = (0, $hgUW1$createColumnHelper)();
2782
+ const tableColumns = [
2783
+ columnHelper.accessor("titleResizable", {
2784
+ header: ()=>/*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
2785
+ className: "dc-c-tooltip-width-override",
3071
2786
  children: [
3072
- /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3073
- children: queryConditions.map((qf, index)=>/*#__PURE__*/ (0, $hgUW1$jsx)((0, $6369abf590ca298f$export$2e2bcd8739ae039), {
3074
- id: id,
3075
- schema: schema,
3076
- condition: qf,
3077
- index: index,
3078
- propertyOptions: propertyOptions,
3079
- update: updateCondition,
3080
- remove: removeCondition
3081
- }, qf.key))
3082
- }),
3083
- /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3084
- className: "dc-query-bulder--form-buttons ds-u-padding-x--2 ds-u-padding-top--0 ds-u-md-padding-top--2 ds-u-display--flex ds-u-flex-wrap--wrap",
2787
+ "Title",
2788
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Tooltip), {
2789
+ title: "Title represents the column headers of the data file",
2790
+ // @ts-ignore
2791
+ style: {
2792
+ border: "none",
2793
+ background: "none"
2794
+ },
2795
+ maxWidth: "400px",
2796
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TooltipIcon), {})
2797
+ })
2798
+ ]
2799
+ }),
2800
+ size: 300
2801
+ }),
2802
+ columnHelper.accessor("description", {
2803
+ header: "Description",
2804
+ minSize: 600
2805
+ }),
2806
+ columnHelper.accessor("type", {
2807
+ header: "Type",
2808
+ size: 150,
2809
+ enableResizing: false
2810
+ })
2811
+ ];
2812
+ const typeOptions = [
2813
+ {
2814
+ value: "all",
2815
+ label: "All Types"
2816
+ },
2817
+ {
2818
+ value: "string",
2819
+ label: "String"
2820
+ },
2821
+ {
2822
+ value: "date",
2823
+ label: "Date"
2824
+ },
2825
+ {
2826
+ value: "datetime",
2827
+ label: "Datetime"
2828
+ },
2829
+ {
2830
+ value: "year",
2831
+ label: "Year"
2832
+ },
2833
+ {
2834
+ value: "integer",
2835
+ label: "Integer"
2836
+ },
2837
+ {
2838
+ value: "number",
2839
+ label: "Number"
2840
+ },
2841
+ {
2842
+ value: "boolean",
2843
+ label: "Boolean"
2844
+ }
2845
+ ];
2846
+ return /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
2847
+ children: [
2848
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2849
+ className: "dc-query-builder ds-u-margin-bottom--3",
2850
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2851
+ className: "ds-c-accordion ds-c-accordion--bordered",
2852
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$AccordionItem), {
2853
+ heading: "Data Dictionary Filters",
2854
+ defaultOpen: true,
2855
+ children: /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
2856
+ className: "ds-u-display--flex ds-u-flex-wrap--wrap",
3085
2857
  children: [
2858
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TextField), {
2859
+ className: "ds-l-col--12 ds-l-sm-col--6",
2860
+ labelClassName: "ds-u-margin-top--1 ds-u-sm-margin-top--0",
2861
+ label: "Title",
2862
+ value: titleFilter,
2863
+ name: "dc-data-dictionary-title",
2864
+ onChange: (e)=>setTitleFilter(e.target.value)
2865
+ }),
3086
2866
  /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3087
- className: "ds-l-col--12 ds-l-md-col--4 ds-l-md-col--6 ds-u-padding-x--0 ds-u-margin-bottom--2 ds-u-md-margin-bottom--0",
3088
- children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
3089
- variation: "ghost",
3090
- onClick: ()=>addCondition(null),
3091
- className: "ds-u-padding-left--0",
3092
- children: "+ Add filter"
2867
+ className: "ds-l-col--12 ds-l-sm-col--6",
2868
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Dropdown), {
2869
+ labelClassName: "ds-u-margin-top--1 ds-u-sm-margin-top--0",
2870
+ options: typeOptions,
2871
+ label: "Type",
2872
+ value: typeFilter,
2873
+ name: "dc-data-dictionary-type",
2874
+ onChange: (e)=>setTypeFilter(e.target.value)
3093
2875
  })
3094
2876
  }),
3095
- /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3096
- className: "ds-u-display--flex ds-u-justify-content--end ds-l-col--12 ds-l-md-col--6 ds-u-padding-x--0",
3097
- children: [
3098
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
3099
- disabled: !conditionsChanged,
3100
- className: "ds-u-float--right ds-l-md-col--6 ds-u-margin--right--0 ds-u-sm-margin-right--2",
3101
- type: "submit",
3102
- variation: "solid",
3103
- children: "Apply filters"
3104
- }),
3105
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $2eec38d4d0dbf714$export$2e2bcd8739ae039), {
3106
- disabled: queryConditions.length === 0,
2877
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2878
+ className: "ds-u-float--right ds-u-padding-y--2 ds-l-col--12 ds-u-display--flex ds-u-flex-wrap--wrap ds-u-justify-content--end",
2879
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2880
+ className: "ds-u-display--flex ds-u-justify-content--end ds-l-col--12 ds-l-md-col--6 ds-u-padding-x--0",
2881
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $2eec38d4d0dbf714$export$2e2bcd8739ae039), {
3107
2882
  clearFiltersFn: ()=>{
3108
- setQueryConditions([]);
3109
- setTitleConditions([]);
3110
- setConditionsCleared(true);
2883
+ setTitleFilter("");
2884
+ setTypeFilter("all");
3111
2885
  }
3112
2886
  })
3113
- ]
2887
+ })
3114
2888
  })
3115
2889
  ]
3116
2890
  })
3117
- ]
2891
+ })
3118
2892
  })
2893
+ }),
2894
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $6765a74df807d015$export$2e2bcd8739ae039), {
2895
+ tableColumns: tableColumns,
2896
+ tableData: tableData,
2897
+ pageSize: pageSize,
2898
+ columnFilters: columnFilters
3119
2899
  })
3120
- })
2900
+ ]
3121
2901
  });
3122
2902
  };
3123
- $ee4ad47aa483e5b5$var$QueryBuilder.defaultProps = {
3124
- includeSearchParams: true
3125
- };
3126
- var $ee4ad47aa483e5b5$export$2e2bcd8739ae039 = $ee4ad47aa483e5b5$var$QueryBuilder;
2903
+ var $a6e312940f7003ef$export$2e2bcd8739ae039 = $a6e312940f7003ef$var$DatasetDictionaryTable;
3127
2904
 
3128
2905
 
3129
- function $a35cf16d1488f54e$export$1147582dfae658c6(columns, schema) {
3130
- return columns.map((column)=>({
3131
- header: schema && schema.fields[column].description ? schema.fields[column].description : column,
3132
- accessor: column
3133
- }));
3134
- }
3135
- const $a35cf16d1488f54e$var$DatasetTable = ({ id: id, distribution: distribution, resource: resource, rootUrl: rootUrl, customColumns: customColumns = [], jsonUrl: jsonUrl, dataDictionaryBanner: dataDictionaryBanner })=>{
3136
- const defaultPage = 1;
3137
- const defaultPageSize = 10;
3138
- const [page, setPage] = (0, $hgUW1$useState)(defaultPage);
3139
- const customColumnHeaders = (0, $7264a673914aa746$export$8049e8f40a9bdfb8)(customColumns, resource.columns, resource.schema[distribution.identifier]);
3140
- const columns = customColumnHeaders ? customColumnHeaders : $a35cf16d1488f54e$export$1147582dfae658c6(resource.columns, resource.schema[id]);
3141
- const { limit: limit, setLimit: setLimit, setOffset: setOffset } = resource;
3142
- const pageSize = limit ? limit : defaultPageSize;
3143
- const downloadURL = `${rootUrl}/datastore/query/${id}/0/download?${(0, $hgUW1$qs).stringify({
3144
- conditions: resource.conditions
3145
- }, {
3146
- encode: true
3147
- })}&format=csv`;
3148
- if (Object.keys(resource).length && columns.length && resource.schema && Object.keys(distribution).length) return /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
2906
+
2907
+ const $6012b86ffcaf3f71$var$DataDictionary = ({ datasetDictionaryEndpoint: datasetDictionaryEndpoint, datasetSitewideDictionary: datasetSitewideDictionary, title: title, pageSize: pageSize = 20, additionalParams: additionalParams, csvDownload: csvDownload })=>{
2908
+ const { data: data, isPending: isPending, error: error } = (0, $hgUW1$useQuery)({
2909
+ queryKey: [
2910
+ "dictionary" + datasetDictionaryEndpoint
2911
+ ],
2912
+ queryFn: ()=>{
2913
+ return (0, $hgUW1$axios).get(`${datasetDictionaryEndpoint}?${(0, $hgUW1$qs).stringify(additionalParams, {
2914
+ arrayFormat: "comma",
2915
+ encode: false
2916
+ })}`).then((res)=>res.data).catch((error)=>console.error(error));
2917
+ },
2918
+ enabled: datasetDictionaryEndpoint !== undefined
2919
+ });
2920
+ const datasetDictionary = data && data.data && data.data.fields && data.data.fields.length ? data.data.fields : null;
2921
+ return /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
2922
+ "data-testid": "dataset-dictionary-tab",
3149
2923
  children: [
3150
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $ee4ad47aa483e5b5$export$2e2bcd8739ae039), {
3151
- resource: resource,
3152
- id: distribution.identifier,
3153
- customColumns: customColumnHeaders
3154
- }),
3155
- dataDictionaryBanner && /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3156
- children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Alert), {
3157
- children: 'Click on the "Data Dictionary" tab above for full column definitions'
3158
- })
3159
- }),
3160
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $6380a4a580b24362$export$2e2bcd8739ae039), {
3161
- resource: resource,
3162
- downloadURL: downloadURL,
3163
- unfilteredDownloadURL: distribution.data.downloadURL,
3164
- jsonUrl: jsonUrl,
3165
- setPage: setPage
2924
+ /*#__PURE__*/ (0, $hgUW1$jsx)("h2", {
2925
+ className: "ds-text-heading--2xl ds-u-margin-y--3",
2926
+ children: title
3166
2927
  }),
3167
- /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3168
- className: "ds-u-border-x--1 ds-u-border-bottom--1",
3169
- children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $d98f94c79ddf4e0e$export$2e2bcd8739ae039), {
3170
- data: resource.values,
3171
- canResize: true,
3172
- columns: columns,
3173
- setSort: resource.setSort,
3174
- sortTransform: (0, $aa4450dcbeef3ac0$export$385a5aba38cc3325),
3175
- tablePadding: "ds-u-padding-y--2",
3176
- loading: resource.loading
3177
- })
2928
+ datasetDictionary && /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
2929
+ children: [
2930
+ /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
2931
+ className: "ds-u-margin-bottom--1 ds-u-display--flex ds-u-flex-wrap--wrap ds-u-justify-content--end",
2932
+ children: [
2933
+ /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Button), {
2934
+ className: "ds-l-col--12 ds-l-sm-col--6 ds-l-md-col--4",
2935
+ onClick: ()=>window.open(datasetDictionaryEndpoint),
2936
+ type: "button",
2937
+ children: [
2938
+ /*#__PURE__*/ (0, $hgUW1$jsx)("i", {
2939
+ className: "fa fa-file-download ds-u-color--primary ds-u-padding-right--1"
2940
+ }),
2941
+ " View Dictionary JSON"
2942
+ ]
2943
+ }),
2944
+ csvDownload && /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2945
+ className: "ds-l-col--12 ds-l-sm-col--6 ds-l-md-col--4 ds-u-margin-top--2 ds-u-sm-margin-top--0 ds-u-padding--0 ds-u-sm-padding-left--2",
2946
+ children: /*#__PURE__*/ (0, $hgUW1$jsxs)("a", {
2947
+ href: datasetDictionaryEndpoint + "/csv",
2948
+ className: "ds-c-button",
2949
+ style: {
2950
+ width: "100%"
2951
+ },
2952
+ children: [
2953
+ /*#__PURE__*/ (0, $hgUW1$jsx)("i", {
2954
+ className: "fa fa-file-download ds-u-color--primary ds-u-padding-right--1"
2955
+ }),
2956
+ "Download Dictionary CSV"
2957
+ ]
2958
+ })
2959
+ })
2960
+ ]
2961
+ }),
2962
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $a6e312940f7003ef$export$2e2bcd8739ae039), {
2963
+ datasetDictionary: datasetDictionary,
2964
+ pageSize: pageSize
2965
+ })
2966
+ ]
3178
2967
  }),
3179
- !resource.loading && /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3180
- className: "ds-u-display--flex ds-u-flex-wrap--wrap ds-u-justify-content--end ds-u-md-justify-content--between ds-u-margin-top--2 ds-u-align-items--center",
3181
- children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Pagination), {
3182
- totalPages: Math.ceil(resource.count ? resource.count / pageSize : 1),
3183
- currentPage: page,
3184
- onPageChange: (evt, page)=>{
3185
- evt.preventDefault();
3186
- setOffset((page - 1) * limit);
3187
- setPage(page);
3188
- },
3189
- renderHref: (page)=>{
3190
- return "";
3191
- },
3192
- className: "ds-l-col--12 ds-u-padding-x--0"
3193
- })
2968
+ datasetSitewideDictionary && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $a24829b27758fe6c$export$2e2bcd8739ae039), {
2969
+ datasetDictionary: datasetSitewideDictionary,
2970
+ pageSize: pageSize
3194
2971
  })
3195
2972
  ]
3196
2973
  });
3197
- else return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Spinner), {
3198
- "aria-valuetext": "Dataset loading",
3199
- role: "status",
3200
- className: "ds-u-margin--3"
3201
- });
3202
2974
  };
3203
- var $a35cf16d1488f54e$export$2e2bcd8739ae039 = $a35cf16d1488f54e$var$DatasetTable;
2975
+ var $6012b86ffcaf3f71$export$2e2bcd8739ae039 = (0, $61ff88fb3f6ee2c8$export$2e2bcd8739ae039)($6012b86ffcaf3f71$var$DataDictionary);
3204
2976
 
3205
2977
 
3206
2978
 
@@ -3210,58 +2982,64 @@ var $a35cf16d1488f54e$export$2e2bcd8739ae039 = $a35cf16d1488f54e$var$DatasetTabl
3210
2982
 
3211
2983
 
3212
2984
 
3213
- function $5644ebd2c3dbfd7b$export$eea3a12df15499ca(metadataMapping, datasetInfo) {
3214
- const rows = [];
3215
- Object.keys(metadataMapping).forEach((d)=>{
3216
- if (!datasetInfo[d]) return null;
3217
- else rows.push(...metadataMapping[d](datasetInfo[d]));
2985
+
2986
+
2987
+
2988
+
2989
+
2990
+
2991
+
2992
+
2993
+ const $96d341d082bffec5$var$TruncatedResizeableTHead = ({ table: table, sortElement: sortElement = null, setAriaLiveFeedback: setAriaLiveFeedback })=>{
2994
+ return /*#__PURE__*/ (0, $hgUW1$jsx)("thead", {
2995
+ className: "dc-thead--truncated dc-thead--resizeable",
2996
+ children: table.getHeaderGroups().map((headerGroup)=>/*#__PURE__*/ (0, $hgUW1$jsx)("tr", {
2997
+ className: "dc-c-sticky-header",
2998
+ children: headerGroup.headers.map((header)=>/*#__PURE__*/ (0, $hgUW1$jsx)((0, $64a351d3fd8413c3$export$2e2bcd8739ae039), {
2999
+ table: table,
3000
+ header: header,
3001
+ sortElement: sortElement,
3002
+ setAriaLiveFeedback: setAriaLiveFeedback
3003
+ }, header.id + "_dataTableResize"))
3004
+ }, headerGroup.id))
3218
3005
  });
3219
- return rows;
3220
- }
3221
- const $5644ebd2c3dbfd7b$var$DatasetAdditionalInformation = ({ datasetInfo: datasetInfo, id: id, metadataMapping: metadataMapping })=>{
3222
- const rows = $5644ebd2c3dbfd7b$export$eea3a12df15499ca(metadataMapping, datasetInfo);
3223
- return /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3224
- className: "dc-c-additional-info-table ds-u-margin-bottom--6",
3225
- children: [
3226
- /*#__PURE__*/ (0, $hgUW1$jsx)("h2", {
3227
- className: "ds-text-heading--2xl ds-u-margin-y--3",
3228
- children: "Additional Information"
3229
- }),
3230
- /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Table), {
3231
- compact: true,
3232
- striped: true,
3233
- children: [
3234
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableHead), {
3235
- children: /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$TableRow), {
3006
+ };
3007
+ var $96d341d082bffec5$export$2e2bcd8739ae039 = $96d341d082bffec5$var$TruncatedResizeableTHead;
3008
+
3009
+
3010
+
3011
+
3012
+
3013
+ const $23763e27eda0e8d7$var$FixedSizeTHead = ({ table: table, sortElement: sortElement })=>{
3014
+ return /*#__PURE__*/ (0, $hgUW1$jsx)("thead", {
3015
+ className: "dc-thead--fixed-size",
3016
+ children: table.getHeaderGroups().map((headerGroup)=>/*#__PURE__*/ (0, $hgUW1$jsx)("tr", {
3017
+ children: headerGroup.headers.map((header)=>{
3018
+ return /*#__PURE__*/ (0, $hgUW1$jsx)("th", {
3019
+ key: header.id,
3020
+ style: {
3021
+ width: header.getSize()
3022
+ },
3023
+ title: header.column.columnDef.header,
3024
+ className: "ds-u-border-y--2 ds-u-padding--2 ds-u-border--dark ds-u-font-weight--bold",
3025
+ children: /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3026
+ onClick: header.column.getToggleSortingHandler(),
3027
+ className: "ds-u-display--flex",
3236
3028
  children: [
3237
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableCell), {
3238
- children: "Field"
3029
+ /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
3030
+ children: header.isPlaceholder ? null : (0, $hgUW1$flexRender)(header.column.columnDef.header, header.getContext())
3239
3031
  }),
3240
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableCell), {
3241
- children: "Value"
3032
+ /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
3033
+ className: header.column.getCanSort() ? `cursor-pointer select-none ${sortElement(header.column.getIsSorted())}` : ""
3242
3034
  })
3243
3035
  ]
3244
3036
  })
3245
- }),
3246
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableBody), {
3247
- children: rows.map((r)=>/*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$TableRow), {
3248
- children: [
3249
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableCell), {
3250
- children: r.label
3251
- }),
3252
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableCell), {
3253
- className: "ds-u-word-break-anywhere",
3254
- children: r.value
3255
- })
3256
- ]
3257
- }, `${r.label}_${id}`))
3258
- })
3259
- ]
3260
- })
3261
- ]
3037
+ });
3038
+ })
3039
+ }, headerGroup.id))
3262
3040
  });
3263
3041
  };
3264
- var $5644ebd2c3dbfd7b$export$2e2bcd8739ae039 = $5644ebd2c3dbfd7b$var$DatasetAdditionalInformation;
3042
+ var $23763e27eda0e8d7$export$2e2bcd8739ae039 = $23763e27eda0e8d7$var$FixedSizeTHead;
3265
3043
 
3266
3044
 
3267
3045
 
@@ -3271,199 +3049,683 @@ var $5644ebd2c3dbfd7b$export$2e2bcd8739ae039 = $5644ebd2c3dbfd7b$var$DatasetAddi
3271
3049
 
3272
3050
 
3273
3051
 
3274
- const $0958733ee130fc44$var$ResourceInformation = ({ resource: resource })=>{
3275
- const { count: count, columns: columns } = resource;
3276
- return /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3277
- className: "dc-c-resource-info-table ds-l-col--12 ds-u-padding-left--0 ds-u-margin-y--2",
3052
+
3053
+
3054
+
3055
+
3056
+
3057
+
3058
+
3059
+
3060
+ const $5fe94aeb50e0798b$var$Card = ({ id: id, visible: visible, updateVisibility: updateVisibility })=>{
3061
+ const { attributes: attributes, listeners: listeners, setNodeRef: setNodeRef, transform: transform, transition: transition, isDragging: isDragging } = (0, $hgUW1$useSortable)({
3062
+ id: id
3063
+ });
3064
+ const style = {
3065
+ transform: (0, $hgUW1$CSS).Transform.toString(transform),
3066
+ transition: transition,
3067
+ opacity: isDragging ? 0.7 : 1,
3068
+ zIndex: isDragging ? 1 : 0,
3069
+ position: "relative",
3070
+ background: "white",
3071
+ touchAction: "none"
3072
+ };
3073
+ return /*#__PURE__*/ (0, $hgUW1$jsxs)("li", {
3074
+ className: "ds-u-display--flex ds-u-justify-content--between ds-u-border-bottom--1",
3075
+ ref: setNodeRef,
3076
+ style: style,
3077
+ ...listeners,
3078
+ ...attributes,
3079
+ onPointerUp: (e)=>{
3080
+ // Small hack to get around a chrome / webkit rendering bug = force chrome to repaint the checkbox
3081
+ // For whatever reason the way dnd-kit handles events doesn't work well with chrome
3082
+ // Without this code checkboxes can end up visually out of sync with app state until a repaint is forced
3083
+ // this code forces the repaint without user interaction
3084
+ const target = e.target;
3085
+ if (isDragging && target.tagName.toLowerCase() === "label") setTimeout(()=>{
3086
+ target.parentNode.querySelector("input").checked = visible;
3087
+ }, 1);
3088
+ },
3278
3089
  children: [
3279
- /*#__PURE__*/ (0, $hgUW1$jsx)("h3", {
3280
- className: "ds-u-font-size--base ds-text-heading--xl ds-text-heading--xl",
3281
- children: "About this Resource"
3090
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Choice), {
3091
+ type: "checkbox",
3092
+ label: id,
3093
+ name: id + "_visibility",
3094
+ checked: visible,
3095
+ className: "ds-l-col--10 ds-u-margin-top--0 ds-u-margin-y--1 ds-u-padding-x--3",
3096
+ labelClassName: "dc-truncate",
3097
+ value: "",
3098
+ onChange: ()=>{
3099
+ updateVisibility(id, !visible);
3100
+ }
3282
3101
  }),
3283
- /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3284
- className: "ds-u-display--flex ds-u-text-align--center ds-u-justify-content--center ds-u-md-justify-content--start",
3102
+ /*#__PURE__*/ (0, $hgUW1$jsx)("button", {
3103
+ className: `ds-l-col--2 dkan-manage-columns-reorder-button ${isDragging && "grabbed"}`,
3104
+ "aria-label": `Reorder ${id} column`,
3105
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
3106
+ className: "fa fa-sort"
3107
+ })
3108
+ })
3109
+ ]
3110
+ });
3111
+ };
3112
+ var $5fe94aeb50e0798b$export$2e2bcd8739ae039 = $5fe94aeb50e0798b$var$Card;
3113
+
3114
+
3115
+
3116
+
3117
+ class $5d9e2ce238d53d29$var$ExcludeCheckboxKeyboardSensor extends (0, $hgUW1$KeyboardSensor) {
3118
+ // Custom function to exclude checkbox from keyboard dragging
3119
+ static activators = [
3120
+ {
3121
+ eventName: "onKeyDown",
3122
+ handler: ({ nativeEvent: event })=>{
3123
+ // prevent scrolling the list
3124
+ const isCheckbox = [
3125
+ "input",
3126
+ "checkbox"
3127
+ ].indexOf(event.target.tagName.toLowerCase()) !== -1;
3128
+ if (event.key === " " && !isCheckbox) event.preventDefault();
3129
+ // only activate on a space or return press
3130
+ if ([
3131
+ " ",
3132
+ "Enter"
3133
+ ].indexOf(event.key) === -1) return false;
3134
+ if (!isCheckbox) return true;
3135
+ return false;
3136
+ }
3137
+ }
3138
+ ];
3139
+ }
3140
+ class $5d9e2ce238d53d29$var$ExcludeCheckboxPointerSensor extends (0, $hgUW1$PointerSensor) {
3141
+ // Custom function to stop accidental checkbox clicks on pointer activation
3142
+ static activators = [
3143
+ {
3144
+ eventName: "onPointerDown",
3145
+ handler: ({ nativeEvent: event })=>{
3146
+ if (event.target.tagName.toLowerCase() === "input") return false;
3147
+ if (event.target.tagName.toLowerCase() === "label") event.target.blur();
3148
+ return true;
3149
+ }
3150
+ }
3151
+ ];
3152
+ }
3153
+ const $5d9e2ce238d53d29$var$ManageColumns = ({ id: id, columns: columns, defaultColumnOrder: defaultColumnOrder, modalOpen: modalOpen, setModalOpen: setModalOpen })=>{
3154
+ const { columnOrder: columnOrder, setColumnOrder: setColumnOrder, setColumnVisibility: setColumnVisibility } = (0, $hgUW1$useContext)((0, $39bc4d98030a5599$export$a5806b00c0db0089));
3155
+ // maintain card state separately from table state - only sync states when the Save button is pressed
3156
+ const [cards, setCards] = (0, $hgUW1$useState)(columns.map((c)=>{
3157
+ return {
3158
+ id: c.id,
3159
+ visible: c.getIsVisible()
3160
+ };
3161
+ }));
3162
+ const cardOrder = (0, $hgUW1$useMemo)(()=>cards.map(({ id: id })=>id), [
3163
+ cards
3164
+ ]);
3165
+ // keep state in sync
3166
+ (0, $hgUW1$useEffect)(()=>{
3167
+ if (columnOrder.length) setCards(columnOrder.map((c)=>{
3168
+ const column = columns.filter((col)=>col.id === c)[0];
3169
+ return {
3170
+ id: column.id,
3171
+ visible: column.getIsVisible()
3172
+ };
3173
+ }));
3174
+ }, [
3175
+ columnOrder
3176
+ ]);
3177
+ const sensors = (0, $hgUW1$useSensors)((0, $hgUW1$useSensor)($5d9e2ce238d53d29$var$ExcludeCheckboxPointerSensor, {
3178
+ activationConstraint: {
3179
+ distance: 5
3180
+ }
3181
+ }), (0, $hgUW1$useSensor)($5d9e2ce238d53d29$var$ExcludeCheckboxKeyboardSensor, {
3182
+ coordinateGetter: (0, $hgUW1$sortableKeyboardCoordinates)
3183
+ }));
3184
+ const cardHiddenColumns = cards.filter((c)=>c.visible === false).length;
3185
+ const updateVisibility = (0, $hgUW1$useCallback)((id, newVisibility)=>{
3186
+ setCards(cards.map((card)=>{
3187
+ if (card.id === id) return {
3188
+ ...card,
3189
+ visible: newVisibility
3190
+ };
3191
+ return card;
3192
+ }));
3193
+ });
3194
+ function handleDragEnd(e) {
3195
+ const { active: active, over: over } = e;
3196
+ if (active.id !== over.id) {
3197
+ const oldIndex = cardOrder.indexOf(active.id);
3198
+ const newIndex = cardOrder.indexOf(over.id);
3199
+ let newCards = (0, $hgUW1$arrayMove)(cards, oldIndex, newIndex);
3200
+ setCards(newCards);
3201
+ }
3202
+ }
3203
+ const resetCards = ()=>{
3204
+ setCards(columns.map((c)=>{
3205
+ return {
3206
+ id: c.id,
3207
+ visible: c.getIsVisible()
3208
+ };
3209
+ }));
3210
+ };
3211
+ return /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3212
+ className: `ds-c-dialog-wrap${modalOpen ? " open" : ""}`,
3213
+ children: /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Dialog), {
3214
+ heading: "Manage columns",
3215
+ isOpen: modalOpen,
3216
+ onExit: ()=>{
3217
+ setModalOpen(false);
3218
+ resetCards();
3219
+ },
3220
+ className: "dkan-manage-columns-dialog",
3221
+ actions: /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3222
+ className: "ds-u-display--flex ds-u-justify-content--between ds-u-flex-wrap--wrap ds-u-padding-x--3 ds-u-padding-bottom--1 ds-u-sm-padding-bottom--3",
3285
3223
  children: [
3286
3224
  /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3287
- className: "ds-u-fill--gray-lightest ds-u-radius ds-u-margin-right--1 ds-u-padding--2",
3225
+ className: "ds-l-col--12 ds-l-sm-col--auto ds-u-padding-x--0",
3288
3226
  children: [
3289
- /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3290
- className: "ds-u-padding-top--05",
3291
- children: "Rows"
3227
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
3228
+ variation: "solid",
3229
+ className: "ds-l-col--6 ds-l-sm-col--auto",
3230
+ onClick: ()=>{
3231
+ setModalOpen(false);
3232
+ // update table state
3233
+ // Visibility
3234
+ // This code is building a new columnVisibility state object from the card state and doing a single setState on the table
3235
+ // vs doing a setState on every changed column individually
3236
+ const newColumnVisibility = Object.fromEntries(cards.map((c)=>Object.values(c)));
3237
+ setColumnVisibility(newColumnVisibility);
3238
+ // Card order
3239
+ const newCardOrder = cards.map((c)=>{
3240
+ return c.id;
3241
+ });
3242
+ setColumnOrder(newCardOrder);
3243
+ // save to localStorage
3244
+ const localStorageData = {
3245
+ tableColumnOrder: newCardOrder,
3246
+ tableColumnVisibility: newColumnVisibility
3247
+ };
3248
+ localStorage.setItem(id, JSON.stringify(localStorageData));
3249
+ },
3250
+ children: "Save"
3292
3251
  }),
3293
- /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3294
- className: "ds-u-font-weight--bold",
3295
- children: count ? count.toLocaleString() : ""
3252
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
3253
+ variation: "ghost",
3254
+ className: "ds-l-col--6 ds-l-sm-col--auto",
3255
+ onClick: ()=>{
3256
+ setModalOpen(false);
3257
+ resetCards();
3258
+ },
3259
+ children: "Cancel"
3296
3260
  })
3297
3261
  ]
3298
3262
  }),
3299
3263
  /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3300
- className: "ds-u-fill--gray-lightest ds-u-radius ds-u-margin-right--1 ds-u-padding--2",
3301
- children: /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3302
- children: [
3303
- /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3304
- className: "ds-u-padding-top--05",
3305
- children: "Columns"
3306
- }),
3307
- /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3308
- className: "ds-u-font-weight--bold",
3309
- children: columns.length.toLocaleString()
3310
- })
3311
- ]
3264
+ className: "ds-l-col--12 ds-l-sm-col--auto ds-u-padding-x--0 ds-u-padding-top--1 ds-u-sm-padding-y--0",
3265
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
3266
+ variation: "ghost",
3267
+ className: "ds-l-col--6 ds-l-sm-col--auto",
3268
+ onClick: ()=>{
3269
+ // reset to default column order and set all cards to visible
3270
+ // do not save this to the table state until the "Save" button is clicked
3271
+ setCards(defaultColumnOrder.map((column)=>{
3272
+ const card = cards.filter((c)=>c.id === column)[0];
3273
+ return {
3274
+ ...card,
3275
+ visible: true
3276
+ };
3277
+ }));
3278
+ },
3279
+ children: "Reset Columns"
3312
3280
  })
3313
3281
  })
3314
3282
  ]
3315
- })
3316
- ]
3283
+ }),
3284
+ children: [
3285
+ /*#__PURE__*/ (0, $hgUW1$jsx)("p", {
3286
+ id: "reorder-help",
3287
+ className: "ds-u-padding-x--3",
3288
+ children: "Activate the reorder button and use the arrow keys to reorder the list or use your mouse to drag/reorder. Press escape to cancel the reordering."
3289
+ }),
3290
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Choice), {
3291
+ checked: cardHiddenColumns === 0,
3292
+ type: "checkbox",
3293
+ onChange: ()=>{
3294
+ setCards(cards.map((c)=>{
3295
+ return {
3296
+ ...c,
3297
+ visible: cardHiddenColumns !== 0
3298
+ };
3299
+ }));
3300
+ },
3301
+ className: "ds-u-padding-x--3",
3302
+ name: "",
3303
+ value: "",
3304
+ label: "Select all",
3305
+ hint: cardHiddenColumns && cardHiddenColumns + " columns hidden"
3306
+ }),
3307
+ /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3308
+ className: "ds-u-display--flex ds-u-justify-content--between ds-u-font-weight--bold ds-u-padding-y--2 ds-u-padding-x--3 ds-u-border-y--1 ds-u-margin-top--2",
3309
+ children: [
3310
+ /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
3311
+ children: "Display column"
3312
+ }),
3313
+ /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
3314
+ children: "Reorder"
3315
+ })
3316
+ ]
3317
+ }),
3318
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$DndContext), {
3319
+ collisionDetection: (0, $hgUW1$closestCenter),
3320
+ modifiers: [
3321
+ (0, $hgUW1$restrictToVerticalAxis)
3322
+ ],
3323
+ sensors: sensors,
3324
+ onDragEnd: handleDragEnd,
3325
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$SortableContext), {
3326
+ items: cardOrder,
3327
+ strategy: (0, $hgUW1$verticalListSortingStrategy),
3328
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)("ul", {
3329
+ className: "dkan-manage-columns-list",
3330
+ children: cards.map((card)=>{
3331
+ return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $5fe94aeb50e0798b$export$2e2bcd8739ae039), {
3332
+ id: card.id,
3333
+ visible: card.visible,
3334
+ updateVisibility: updateVisibility
3335
+ }, card.id);
3336
+ })
3337
+ })
3338
+ })
3339
+ })
3340
+ ]
3341
+ })
3317
3342
  });
3318
3343
  };
3319
- var $0958733ee130fc44$export$2e2bcd8739ae039 = $0958733ee130fc44$var$ResourceInformation;
3344
+ var $5d9e2ce238d53d29$export$2e2bcd8739ae039 = $5d9e2ce238d53d29$var$ManageColumns;
3320
3345
 
3321
3346
 
3322
- function $f764661366bd9e1b$export$ee48b7e0e4eb536e(dist) {
3323
- if (dist && dist.data) {
3324
- if (dist.data.format) return dist.data.format.toLowerCase();
3325
- if (dist.data.mediaType) {
3326
- const mediaType = dist.data.mediaType.split("/");
3327
- if (mediaType.length && mediaType[1]) return mediaType[1].toLowerCase();
3328
- }
3329
- if (dist.data["%Ref:downloadURL"].length && dist.data["%Ref:downloadURL"][0].data) {
3330
- if (dist.data["%Ref:downloadURL"][0].data.mimeType) {
3331
- const mimeType = dist.data["%Ref:downloadURL"][0].data.mimeType.split("/");
3332
- if (mimeType.length && mimeType[1]) return mimeType[1].toLowerCase();
3333
- }
3334
- }
3335
- }
3336
- return "";
3337
- }
3338
3347
 
3339
3348
 
3340
3349
 
3341
- const $7357cc0f79f9c514$var$Resource = ({ distributions: distributions, resource: resource, title: title })=>{
3342
- const sm = (0, $hgUW1$useMediaQuery)({
3343
- minWidth: 0,
3344
- maxWidth: 767
3350
+
3351
+
3352
+ const $16bd41951b91f02d$var$FullScreenDataTable = ({ modalOpen: modalOpen, setModalOpen: setModalOpen })=>{
3353
+ return /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3354
+ className: `ds-c-dialog-wrap${modalOpen ? " open" : ""}`,
3355
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Dialog), {
3356
+ heading: "Dataset Explorer",
3357
+ isOpen: modalOpen,
3358
+ onExit: ()=>setModalOpen(false),
3359
+ className: "dkan-full-screen-dataset-dialog",
3360
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $a35cf16d1488f54e$export$2e2bcd8739ae039), {
3361
+ isModal: true,
3362
+ closeFullScreenModal: ()=>setModalOpen(false)
3363
+ })
3364
+ })
3345
3365
  });
3346
- return /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3347
- className: "ds-u-display--flex ds-u-flex-wrap--wrap",
3366
+ };
3367
+ var $16bd41951b91f02d$export$2e2bcd8739ae039 = $16bd41951b91f02d$var$FullScreenDataTable;
3368
+
3369
+
3370
+ const $71b4324f265dec16$var$DataTableControls = ({ id: id, columns: columns, defaultColumnOrder: defaultColumnOrder, isModal: isModal, closeFullScreenModal: closeFullScreenModal })=>{
3371
+ const [manageColumnsModalOpen, setManageColumnsModalOpen] = (0, $hgUW1$useState)(false);
3372
+ const [fullScreenModalOpen, setFullScreenModalOpen] = (0, $hgUW1$useState)(false);
3373
+ const hiddenColumns = columns.filter((c)=>c.getIsVisible() === false).length;
3374
+ return /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
3348
3375
  children: [
3349
- /*#__PURE__*/ (0, $hgUW1$jsx)("h2", {
3350
- className: "ds-l-col--12 ds-u-padding-left--0 ds-text-heading--2xl",
3351
- children: "Resources"
3352
- }),
3353
- distributions.length ? /*#__PURE__*/ (0, $hgUW1$jsx)("ul", {
3354
- className: "ds-c-list ds-c-list--bare dc-c-resource-full-width",
3355
- children: distributions.map((dist)=>{
3356
- const fileFormat = (0, $f764661366bd9e1b$export$ee48b7e0e4eb536e)(dist);
3357
- return /*#__PURE__*/ (0, $hgUW1$jsxs)("li", {
3358
- className: `ds-u-display--flex ds-u-flex-wrap--wrap ${fileFormat !== "csv" && "ds-u-margin-bottom--2"}`,
3376
+ /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3377
+ className: "ds-u-border-top--1 ds-u-fill--gray-lightest ds-u-display--flex ds-u-justify-content--between",
3378
+ children: [
3379
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3380
+ children: hiddenColumns > 0 && /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Alert), {
3381
+ variation: "warn",
3382
+ children: [
3383
+ hiddenColumns,
3384
+ " Columns Hidden"
3385
+ ]
3386
+ })
3387
+ }),
3388
+ /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3359
3389
  children: [
3360
- /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3361
- className: "ds-u-font-weight--bold ds-u-font-size--lg ds-l-col--12 ds-l-md-col--6 ds-u-padding-left--0 ds-u-align-items--center ds-u-display--flex",
3390
+ /*#__PURE__*/ (0, $hgUW1$jsxs)("button", {
3391
+ "aria-label": "Manage columns - Opens in a dialog",
3392
+ className: "ds-c-button ds-c-button--ghost ds-u-margin-y--1",
3393
+ onClick: ()=>{
3394
+ setManageColumnsModalOpen(true);
3395
+ },
3362
3396
  children: [
3363
3397
  /*#__PURE__*/ (0, $hgUW1$jsx)("i", {
3364
- className: "fa ds-u-color--primary ds-u-padding-right--1 ds-u-font-size--3xl fa-file-" + (fileFormat == "xlsx" ? "xls" : fileFormat)
3398
+ className: "far fa-cog ds-u-margin-right--1"
3365
3399
  }),
3366
- /*#__PURE__*/ (0, $hgUW1$jsxs)("p", {
3367
- className: "ds-u-margin-top--0",
3368
- children: [
3369
- dist.data.title ? dist.data.title : title,
3370
- " (" + fileFormat.toUpperCase() + ")"
3371
- ]
3372
- })
3400
+ "Manage Columns"
3373
3401
  ]
3374
3402
  }),
3375
- /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3376
- className: "ds-l-col--12 ds-l-md-col--6 ds-u-text-align--center ds-u-md-text-align--right ds-u-margin-top--2 ds-u-md-margin-top--0",
3377
- children: /*#__PURE__*/ (0, $hgUW1$jsxs)("a", {
3378
- href: dist.data.downloadURL,
3379
- style: {
3380
- order: sm ? "1" : "0",
3381
- width: sm ? "100%" : "auto"
3382
- },
3383
- "aria-label": `Download ${dist.data.title || title} ${fileFormat}`,
3384
- className: "ds-c-button",
3385
- children: [
3386
- /*#__PURE__*/ (0, $hgUW1$jsx)("i", {
3387
- className: "fa fa-file-download ds-u-color--primary ds-u-padding-right--1"
3388
- }),
3389
- "Download"
3390
- ]
3391
- })
3392
- }),
3393
- dist.data.description && /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3394
- className: "ds-u-measure--wide ds-u-margin-bottom--7",
3395
- children: /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3396
- className: "dc-c-metadata-description ds-u-margin--0",
3397
- dangerouslySetInnerHTML: {
3398
- __html: (0, $hgUW1$dompurify).sanitize(dist.data.description)
3399
- }
3400
- })
3401
- }),
3402
- fileFormat === "csv" && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $0958733ee130fc44$export$2e2bcd8739ae039), {
3403
- resource: resource
3403
+ /*#__PURE__*/ (0, $hgUW1$jsxs)("button", {
3404
+ "aria-label": isModal ? "Close Full Screen dialog" : "Full Screen mode - Opens in a dialog",
3405
+ className: "ds-c-button ds-c-button--ghost ds-u-margin-y--1",
3406
+ onClick: ()=>{
3407
+ if (isModal) closeFullScreenModal();
3408
+ else setFullScreenModalOpen(true);
3409
+ },
3410
+ children: [
3411
+ /*#__PURE__*/ (0, $hgUW1$jsx)("i", {
3412
+ className: `fa ${isModal ? "fa-compress" : "fa-expand"} ds-u-margin-right--1`
3413
+ }),
3414
+ isModal ? "Exit Full Screen" : "Full Screen"
3415
+ ]
3404
3416
  })
3405
3417
  ]
3406
- }, dist.identifier);
3407
- })
3408
- }) : /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3409
- className: "ds-u-margin-bottom--2",
3410
- children: "No resources have been added to this dataset."
3418
+ })
3419
+ ]
3420
+ }),
3421
+ /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3422
+ children: [
3423
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $5d9e2ce238d53d29$export$2e2bcd8739ae039), {
3424
+ id: id,
3425
+ columns: columns,
3426
+ defaultColumnOrder: defaultColumnOrder,
3427
+ modalOpen: manageColumnsModalOpen,
3428
+ setModalOpen: setManageColumnsModalOpen
3429
+ }),
3430
+ !isModal && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $16bd41951b91f02d$export$2e2bcd8739ae039), {
3431
+ modalOpen: fullScreenModalOpen,
3432
+ setModalOpen: setFullScreenModalOpen
3433
+ })
3434
+ ]
3411
3435
  })
3412
3436
  ]
3413
3437
  });
3414
- };
3415
- var $7357cc0f79f9c514$export$2e2bcd8739ae039 = $7357cc0f79f9c514$var$Resource;
3416
-
3417
-
3418
- const $364dc44850cd8f7f$var$DatasetOverview = ({ dataset: dataset, resource: resource, distributions: distributions, metadataMapping: metadataMapping })=>{
3419
- const md = (0, $hgUW1$useMediaQuery)({
3420
- minWidth: 0,
3421
- maxWidth: 768
3438
+ };
3439
+ var $71b4324f265dec16$export$2e2bcd8739ae039 = $71b4324f265dec16$var$DataTableControls;
3440
+
3441
+
3442
+
3443
+
3444
+ const $d98f94c79ddf4e0e$var$DataTable = ({ columns: columns, sortTransform: sortTransform, tablePadding: tablePadding, canResize: canResize, loading: loading = false, isModal: isModal, closeFullScreenModal: closeFullScreenModal })=>{
3445
+ const { id: id, resource: resource, datasetTableControls: datasetTableControls } = (0, $hgUW1$useContext)((0, $a0f13962e513caa1$export$a7997ae78b143b));
3446
+ const { columnOrder: columnOrder, setColumnOrder: setColumnOrder, columnVisibility: columnVisibility, setColumnVisibility: setColumnVisibility } = (0, $hgUW1$useContext)((0, $39bc4d98030a5599$export$a5806b00c0db0089));
3447
+ const data = resource.values;
3448
+ const [sorting, setSorting] = (0, $hgUW1$useState)([]);
3449
+ const [ariaLiveFeedback, setAriaLiveFeedback] = (0, $hgUW1$useState)("");
3450
+ const dataTableWrapperElement = (0, $hgUW1$useRef)(null);
3451
+ const columnHelper = (0, $hgUW1$createColumnHelper)();
3452
+ const table_columns = columns.map((col)=>{
3453
+ if (col.cell) return columnHelper.accessor(col.accessor, {
3454
+ header: col.header,
3455
+ cell: col.cell
3456
+ });
3457
+ return columnHelper.accessor(col.accessor, {
3458
+ header: col.header
3459
+ });
3460
+ });
3461
+ const [highlightRow, setHighlightRow] = (0, $hgUW1$useState)(null);
3462
+ (0, $hgUW1$useEffect)(()=>{
3463
+ if (!columnOrder.length) setColumnOrder(table_columns.map((c)=>c.accessorKey));
3464
+ }, [
3465
+ columnOrder
3466
+ ]);
3467
+ const sortElement = (isSorted, onClickFn)=>{
3468
+ if (isSorted === "asc") return "dc-c-sort--asc";
3469
+ if (isSorted === "desc") return "dc-c-sort--desc";
3470
+ return "dc-c-sort--default";
3471
+ };
3472
+ const filters = [];
3473
+ const table = (0, $hgUW1$useReactTable)({
3474
+ data: data,
3475
+ columns: table_columns,
3476
+ manualSorting: true,
3477
+ state: {
3478
+ columnOrder: columnOrder,
3479
+ columnVisibility: columnVisibility,
3480
+ sorting: sorting
3481
+ },
3482
+ columnResizeMode: "onChange",
3483
+ onSortingChange: setSorting,
3484
+ onColumnOrderChange: setColumnOrder,
3485
+ onColumnVisibilityChange: setColumnVisibility,
3486
+ getCoreRowModel: (0, $hgUW1$getCoreRowModel)(),
3487
+ getSortedRowModel: (0, $hgUW1$getSortedRowModel)(),
3488
+ debugTable: false
3422
3489
  });
3423
- const rows = (0, $5644ebd2c3dbfd7b$export$eea3a12df15499ca)(metadataMapping, dataset);
3490
+ (0, $hgUW1$useEffect)(()=>{
3491
+ const normalizedSort = sortTransform ? sortTransform(sorting) : filters;
3492
+ resource.setSort(normalizedSort);
3493
+ }, [
3494
+ sorting
3495
+ ]);
3496
+ const defaultColumnOrder = (0, $hgUW1$useMemo)(()=>table_columns.map((column)=>column.accessorKey), []);
3497
+ const tableWrapperWidth = ()=>{
3498
+ if (dataTableWrapperElement.current) return dataTableWrapperElement.current.offsetWidth;
3499
+ return "auto";
3500
+ };
3501
+ (0, $hgUW1$useEffect)(()=>{
3502
+ setHighlightRow(null);
3503
+ }, [
3504
+ data
3505
+ ]);
3424
3506
  return /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
3425
3507
  children: [
3426
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $7357cc0f79f9c514$export$2e2bcd8739ae039), {
3427
- distributions: distributions,
3428
- resource: resource,
3429
- title: dataset.title
3508
+ datasetTableControls && /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3509
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $71b4324f265dec16$export$2e2bcd8739ae039), {
3510
+ id: id,
3511
+ columns: table.getAllLeafColumns(),
3512
+ defaultColumnOrder: defaultColumnOrder,
3513
+ isModal: isModal,
3514
+ closeFullScreenModal: closeFullScreenModal
3515
+ })
3430
3516
  }),
3431
3517
  /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3432
- className: "dc-c-additional-info-table ds-u-margin-bottom--6 ds-u-padding-left--0 ds-l-lg-col--7 ds-l-md-col--9 ds-l-col--12",
3518
+ className: "dc-c-datatable-wrapper",
3519
+ tabIndex: 0,
3520
+ ref: dataTableWrapperElement,
3433
3521
  children: [
3434
- /*#__PURE__*/ (0, $hgUW1$jsx)("h2", {
3435
- className: "ds-text-heading--2xl ds-text-heading--2xl",
3436
- children: "Additional Information"
3437
- }),
3438
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Table), {
3439
- compact: true,
3440
- stackable: true,
3441
- stackableBreakpoint: "md",
3442
- warningDisabled: true,
3443
- children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableBody), {
3444
- children: rows.map((r)=>/*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$TableRow), {
3445
- children: [
3446
- md ? "" : /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableCell), {
3447
- component: "th",
3448
- className: "ds-u-font-weight--bold",
3449
- children: r.label
3450
- }),
3451
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableCell), {
3452
- stackedTitle: r.label,
3453
- children: r.value
3522
+ /*#__PURE__*/ (0, $hgUW1$jsxs)("table", {
3523
+ style: {
3524
+ width: canResize ? table.getCenterTotalSize() : "100%",
3525
+ minWidth: tableWrapperWidth()
3526
+ },
3527
+ className: "dc-c-datatable",
3528
+ children: [
3529
+ canResize ? /*#__PURE__*/ (0, $hgUW1$jsx)((0, $96d341d082bffec5$export$2e2bcd8739ae039), {
3530
+ table: table,
3531
+ sortElement: sortElement,
3532
+ setAriaLiveFeedback: setAriaLiveFeedback
3533
+ }) : /*#__PURE__*/ (0, $hgUW1$jsx)((0, $23763e27eda0e8d7$export$2e2bcd8739ae039), {
3534
+ table: table,
3535
+ sortElement: sortElement
3536
+ }),
3537
+ loading ? /*#__PURE__*/ (0, $hgUW1$jsx)("tbody", {}) : /*#__PURE__*/ (0, $hgUW1$jsx)("tbody", {
3538
+ children: table.getRowModel().rows.map((row, index)=>{
3539
+ const even = (index + 1) % 2 === 0;
3540
+ const highlight = highlightRow === row.id;
3541
+ return /*#__PURE__*/ (0, $hgUW1$jsx)("tr", {
3542
+ className: `${highlight ? "dc-c-datatable--highlight-row" : even && "dc-c-datatable--even-row"}`,
3543
+ onClick: ()=>setHighlightRow(row.id),
3544
+ children: row.getVisibleCells().map((cell)=>{
3545
+ let classList = "dc-truncate ds-u-padding-x--1";
3546
+ return /*#__PURE__*/ (0, $hgUW1$jsx)("td", {
3547
+ key: cell.id,
3548
+ style: {
3549
+ maxWidth: cell.column.getSize()
3550
+ },
3551
+ className: `${classList} ${tablePadding}`,
3552
+ title: cell.getValue(),
3553
+ children: (0, $hgUW1$flexRender)(cell.column.columnDef.cell, cell.getContext())
3554
+ });
3454
3555
  })
3455
- ]
3456
- }, `${r.label}_${dataset.identifier}`))
3457
- })
3556
+ }, row.id);
3557
+ })
3558
+ })
3559
+ ]
3560
+ }),
3561
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3562
+ className: "sr-only",
3563
+ "aria-live": "assertive",
3564
+ "aria-atomic": "true",
3565
+ children: ariaLiveFeedback
3458
3566
  })
3459
3567
  ]
3568
+ }),
3569
+ loading && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Spinner), {
3570
+ "aria-valuetext": "Dataset loading",
3571
+ role: "status",
3572
+ className: "ds-u-margin--3"
3573
+ }),
3574
+ !loading && table.getRowModel().rows.length === 0 && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Alert), {
3575
+ variation: "warn",
3576
+ children: "No results found for the current filters"
3460
3577
  })
3461
3578
  ]
3462
3579
  });
3463
3580
  };
3464
- var $364dc44850cd8f7f$export$2e2bcd8739ae039 = $364dc44850cd8f7f$var$DatasetOverview;
3581
+ var $d98f94c79ddf4e0e$export$2e2bcd8739ae039 = $d98f94c79ddf4e0e$var$DataTable;
3582
+
3583
+
3584
+ function $aa4450dcbeef3ac0$export$385a5aba38cc3325(sortArray) {
3585
+ let newQuery = [];
3586
+ sortArray.forEach((s)=>{
3587
+ return newQuery.push({
3588
+ property: s.id,
3589
+ order: s.desc ? "desc" : "asc"
3590
+ });
3591
+ });
3592
+ return newQuery;
3593
+ }
3465
3594
 
3466
3595
 
3596
+ // Example custom column headers, where only effective date has an ! at the end
3597
+ // [
3598
+ // {schema: 'date', cell: ({ value }) => localeDate(value),},
3599
+ // {accessor: 'effective_date',cell: ({ value }) => localeDate(value) + '!',},
3600
+ // ]
3601
+ function $7264a673914aa746$export$8049e8f40a9bdfb8(customHeaders, columns, schema) {
3602
+ return columns.map((column)=>{
3603
+ const customAccessorIndex = customHeaders.findIndex((header)=>header.accessor === column);
3604
+ const customSchemaIndex = customHeaders.findIndex((header)=>header.schema === schema.fields[column].mysql_type);
3605
+ let newColumn = {};
3606
+ // If specific accessor is passed, this will override a general mysql_type Cell rewrite.
3607
+ if (customAccessorIndex > -1) {
3608
+ newColumn.header = schema && schema.fields[column].description ? schema.fields[column].description : column;
3609
+ newColumn.accessor = column;
3610
+ newColumn.cell = customHeaders[customAccessorIndex].cell;
3611
+ } else {
3612
+ newColumn.header = schema && schema.fields[column].description ? schema.fields[column].description : column;
3613
+ newColumn.accessor = column;
3614
+ if (customSchemaIndex > -1) newColumn.cell = customHeaders[customSchemaIndex].cell;
3615
+ }
3616
+ return newColumn;
3617
+ });
3618
+ }
3619
+ function $7264a673914aa746$export$e284ae5d89467c8f(date) {
3620
+ if (!date) return date;
3621
+ date = new Date(date);
3622
+ date = new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
3623
+ return date;
3624
+ }
3625
+ function $7264a673914aa746$export$6b5e57d20078142b(value, operator) {
3626
+ let newValue = value;
3627
+ if (Array.isArray(newValue)) newValue = newValue.join(",");
3628
+ // return newValue.replace(/(^\%+|\%+$)/gm, '');
3629
+ return newValue;
3630
+ }
3631
+ const $7264a673914aa746$export$5f89a5ae87bc48e1 = [
3632
+ {
3633
+ label: "Is",
3634
+ value: "="
3635
+ },
3636
+ {
3637
+ label: "Starts With",
3638
+ value: "starts with"
3639
+ },
3640
+ {
3641
+ label: "Contains",
3642
+ value: "contains"
3643
+ },
3644
+ {
3645
+ label: "Is Not",
3646
+ value: "<>"
3647
+ },
3648
+ {
3649
+ label: "Or",
3650
+ value: "in"
3651
+ },
3652
+ {
3653
+ label: "Is",
3654
+ value: "="
3655
+ },
3656
+ {
3657
+ label: "Is Not",
3658
+ value: "<>"
3659
+ },
3660
+ {
3661
+ label: "Greater Than",
3662
+ value: ">"
3663
+ },
3664
+ {
3665
+ label: "Less Than",
3666
+ value: "<"
3667
+ }
3668
+ ];
3669
+ function $7264a673914aa746$export$2b9377795161999(type) {
3670
+ switch(type){
3671
+ case "text":
3672
+ case "string":
3673
+ return [
3674
+ {
3675
+ label: "Is",
3676
+ value: "="
3677
+ },
3678
+ {
3679
+ label: "Starts With",
3680
+ value: "starts with"
3681
+ },
3682
+ {
3683
+ label: "Contains",
3684
+ value: "contains"
3685
+ },
3686
+ {
3687
+ label: "Is Not",
3688
+ value: "<>"
3689
+ },
3690
+ {
3691
+ label: "Or",
3692
+ value: "in"
3693
+ }
3694
+ ];
3695
+ case "date":
3696
+ return [
3697
+ {
3698
+ label: "Is",
3699
+ value: "="
3700
+ },
3701
+ {
3702
+ label: "Is Not",
3703
+ value: "<>"
3704
+ },
3705
+ {
3706
+ label: "Greater Than",
3707
+ value: ">"
3708
+ },
3709
+ {
3710
+ label: "Less Than",
3711
+ value: "<"
3712
+ }
3713
+ ];
3714
+ default:
3715
+ // These 2 should be safe for all data types
3716
+ return [
3717
+ {
3718
+ label: "Is",
3719
+ value: "="
3720
+ },
3721
+ {
3722
+ label: "Is Not",
3723
+ value: "<>"
3724
+ }
3725
+ ];
3726
+ }
3727
+ }
3728
+
3467
3729
 
3468
3730
 
3469
3731
 
@@ -3471,64 +3733,183 @@ var $364dc44850cd8f7f$export$2e2bcd8739ae039 = $364dc44850cd8f7f$var$DatasetOver
3471
3733
 
3472
3734
 
3473
3735
 
3474
- const $789279954d8eff7f$var$ApiDocumentation = ({ endpoint: endpoint })=>{
3475
- return /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3476
- children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$swaggeruireact), {
3477
- url: endpoint
3478
- })
3736
+ const $2ed0091f7e32d1e6$var$DataTablePageResults = ({ totalRows: totalRows, limit: limit, offset: offset, className: className = "data-table-results" })=>{
3737
+ const numTotalRows = totalRows;
3738
+ if (numTotalRows === 0) return /*#__PURE__*/ (0, $hgUW1$jsx)("p", {
3739
+ className: className,
3740
+ children: `0 - 0 of 0 rows`
3741
+ });
3742
+ const ofTotal = ()=>{
3743
+ if (limit >= numTotalRows) return numTotalRows;
3744
+ if (limit + offset >= numTotalRows) return numTotalRows;
3745
+ if (offset === 0) return limit;
3746
+ return offset + limit;
3747
+ };
3748
+ const page = offset / limit;
3749
+ const startTotal = ()=>page * limit + 1;
3750
+ return /*#__PURE__*/ (0, $hgUW1$jsxs)("p", {
3751
+ className: className,
3752
+ children: [
3753
+ "Displaying",
3754
+ " ",
3755
+ /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
3756
+ className: "ds-u-font-weight--bold",
3757
+ children: `${startTotal().toLocaleString()} - ${ofTotal().toLocaleString()}`
3758
+ }),
3759
+ " ",
3760
+ "of ",
3761
+ /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
3762
+ className: "ds-u-font-weight--bold",
3763
+ children: `${numTotalRows.toLocaleString()}`
3764
+ }),
3765
+ " ",
3766
+ "results"
3767
+ ]
3479
3768
  });
3480
3769
  };
3481
- var $789279954d8eff7f$export$2e2bcd8739ae039 = $789279954d8eff7f$var$ApiDocumentation;
3770
+ $2ed0091f7e32d1e6$var$DataTablePageResults.propTypes = {
3771
+ className: (0, $hgUW1$proptypes).string,
3772
+ totalRows: (0, $hgUW1$proptypes).number.isRequired,
3773
+ limit: (0, $hgUW1$proptypes).number.isRequired,
3774
+ offset: (0, $hgUW1$proptypes).number.isRequired
3775
+ };
3776
+ var $2ed0091f7e32d1e6$export$2e2bcd8739ae039 = $2ed0091f7e32d1e6$var$DataTablePageResults;
3482
3777
 
3483
3778
 
3484
- const $cf6eaefd6b928de3$var$DatasetAPI = ({ id: id, rootUrl: rootUrl, apiUrl: apiUrl, additionalParams: additionalParams })=>{
3485
- return /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
3779
+
3780
+
3781
+
3782
+ const $6380a4a580b24362$var$DataTableHeader = ({ resource: resource, downloadURL: downloadURL, unfilteredDownloadURL: unfilteredDownloadURL, setPage: setPage })=>{
3783
+ const { limit: limit, offset: offset, count: count, conditions: conditions, setLimit: setLimit, setOffset: setOffset } = resource;
3784
+ const intCount = count ? count : 0;
3785
+ const rowOptions = [
3786
+ 10,
3787
+ 25,
3788
+ 50,
3789
+ 100
3790
+ ];
3791
+ return /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3792
+ className: "ds-u-display--flex ds-u-flex-wrap--wrap ds-u-justify-content--between",
3486
3793
  children: [
3487
3794
  /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3488
- className: "ds-u-display--flex ds-u-flex-wrap--wrap",
3795
+ className: "dc-c-resource-header--buttons ds-u-display--flex ds-u-flex-wrap--wrap ds-u-justify-content--end ds-l-col--12 ds-u-margin-top--2 ds-u-padding-x--0",
3489
3796
  children: [
3797
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3798
+ className: "ds-l-col--12 ds-l-sm-col--auto ds-u-padding-x--0 ds-u-margin-bottom--2",
3799
+ children: conditions && conditions.length ? /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Tooltip), {
3800
+ onOpen: ()=>{
3801
+ navigator.clipboard.writeText(window.location.href);
3802
+ },
3803
+ className: "ds-c-button ds-u-text-align--center ds-u-display--inline-block ds-l-col--12",
3804
+ placement: "bottom",
3805
+ dialog: true,
3806
+ ariaLabel: "Copy link to filtered data",
3807
+ title: "Link copied to clipboard",
3808
+ "aria-disabled": !conditions || conditions.length === 0,
3809
+ children: /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
3810
+ className: "ds-u-font-weight--semibold ds-u-margin-left--1 ds-u-padding--0",
3811
+ children: [
3812
+ /*#__PURE__*/ (0, $hgUW1$jsx)("i", {
3813
+ className: "fas fa-copy"
3814
+ }),
3815
+ " Copy link to filtered data"
3816
+ ]
3817
+ })
3818
+ }) : /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
3819
+ "aria-disabled": true,
3820
+ "aria-label": "Copy link to filtered data",
3821
+ className: "ds-c-button ds-u-text-align--center ds-u-display--inline-block ds-l-col--12",
3822
+ children: /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
3823
+ className: "ds-u-font-weight--semibold ds-u-margin-left--1 ds-u-padding--0",
3824
+ children: [
3825
+ /*#__PURE__*/ (0, $hgUW1$jsx)("i", {
3826
+ className: "fas fa-copy"
3827
+ }),
3828
+ " Copy link to filtered data"
3829
+ ]
3830
+ })
3831
+ })
3832
+ }),
3490
3833
  /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3491
- className: "ds-l-col--12 ds-l-md-col--9 ds-u-padding-left--0",
3834
+ className: "ds-l-col--12 ds-l-md-col--auto ds-u-padding-x--0 ds-u-display--flex ds-u-flex-wrap--wrap ds-u-justify-content--end",
3492
3835
  children: [
3493
- /*#__PURE__*/ (0, $hgUW1$jsx)("h2", {
3494
- className: "ds-text-heading--2xl",
3495
- children: "Try the API"
3836
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3837
+ className: "ds-l-col--12 ds-l-sm-col--auto ds-u-padding-x--0 ds-u-sm-margin-left--2 ds-u-margin-bottom--2",
3838
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
3839
+ className: "ds-u-text-align--center ds-u-font-weight--normal ds-u-font-size--base ds-u-margin-right--1 ds-u-display--inline-block ds-l-col--12",
3840
+ href: downloadURL,
3841
+ "aria-disabled": !conditions || conditions.length === 0,
3842
+ children: /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
3843
+ className: "ds-u-font-weight--semibold ds-u-margin-left--1 ds-u-padding--0",
3844
+ children: [
3845
+ /*#__PURE__*/ (0, $hgUW1$jsx)("i", {
3846
+ className: "fas fa-file-csv"
3847
+ }),
3848
+ " Download filtered data (CSV)"
3849
+ ]
3850
+ })
3851
+ })
3496
3852
  }),
3497
- /*#__PURE__*/ (0, $hgUW1$jsx)("p", {
3498
- children: "The Open Data API (ODA) provides programmatic access to this dataset including the ability to filter, query, and aggregate data."
3853
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3854
+ className: "ds-l-col--12 ds-l-sm-col--auto ds-u-padding-x--0 ds-u-sm-margin-left--2 ds-u-margin-bottom--2",
3855
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
3856
+ className: "ds-u-text-align--center ds-u-font-weight--normal ds-u-font-size--base ds-u-margin-right--1 ds-u-display--inline-block ds-l-col--12",
3857
+ href: unfilteredDownloadURL,
3858
+ children: /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
3859
+ className: "ds-u-font-weight--semibold ds-u-margin-left--1 ds-u-padding--0",
3860
+ children: [
3861
+ /*#__PURE__*/ (0, $hgUW1$jsx)("i", {
3862
+ className: "fas fa-file-csv"
3863
+ }),
3864
+ " Download full dataset (CSV)"
3865
+ ]
3866
+ })
3867
+ })
3499
3868
  })
3500
3869
  ]
3870
+ })
3871
+ ]
3872
+ }),
3873
+ /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3874
+ className: "ds-l-col--12 ds-u-display--flex ds-u-align-items--end ds-u-flex-direction--row-reverse ds-u-sm-flex-direction--row ds-u-padding-x--0 ds-u-margin-bottom--2 ds-u-flex-wrap--wrap",
3875
+ children: [
3876
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3877
+ className: "ds-l-col--12 ds-l-sm-col--8 ds-u-padding-x--0",
3878
+ children: !resource.loading && resource.count !== null && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $2ed0091f7e32d1e6$export$2e2bcd8739ae039), {
3879
+ totalRows: intCount,
3880
+ limit: limit,
3881
+ offset: offset
3882
+ })
3501
3883
  }),
3502
3884
  /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3503
- className: "ds-l-col--12 ds-l-md-col--3 ds-u-font-weight--bold ds-u-margin-top--2 ds-u-padding-left--0 ds-u-md-padding-left--2",
3504
- children: /*#__PURE__*/ (0, $hgUW1$jsxs)("a", {
3505
- href: apiUrl,
3506
- children: [
3507
- "View API",
3508
- " ",
3509
- /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
3510
- style: {
3511
- whiteSpace: "nowrap"
3512
- },
3513
- children: [
3514
- "specification ",
3515
- /*#__PURE__*/ (0, $hgUW1$jsx)("i", {
3516
- className: "fa fa-arrow-right ds-u-font-weight--bold"
3517
- })
3518
- ]
3519
- })
3520
- ]
3885
+ className: "ds-l-col--12 ds-l-sm-col--4 ds-u-display--flex ds-u-justify-content--end ds-u-padding-x--0",
3886
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3887
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Dropdown), {
3888
+ options: rowOptions.map((row)=>({
3889
+ label: row.toString(),
3890
+ value: row
3891
+ })),
3892
+ size: "medium",
3893
+ label: "Rows per page:",
3894
+ labelClassName: "ds-u-margin-top--0",
3895
+ name: "datatable_rows_per_page",
3896
+ onChange: (e)=>{
3897
+ setLimit(parseInt(e.target.value));
3898
+ setPage(1);
3899
+ setOffset(0);
3900
+ },
3901
+ value: limit.toString(),
3902
+ defaultValue: limit.toString()
3903
+ })
3521
3904
  })
3522
3905
  })
3523
3906
  ]
3524
- }),
3525
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $789279954d8eff7f$export$2e2bcd8739ae039), {
3526
- endpoint: `${rootUrl}/metastore/schemas/dataset/items/${id}/docs${additionalParams && additionalParams.ACA ? "?ACA=" + additionalParams.ACA + "&redirect=false" : ""}`
3527
3907
  })
3528
3908
  ]
3529
3909
  });
3530
3910
  };
3531
- var $cf6eaefd6b928de3$export$2e2bcd8739ae039 = $cf6eaefd6b928de3$var$DatasetAPI;
3911
+ var $6380a4a580b24362$export$2e2bcd8739ae039 = $6380a4a580b24362$var$DataTableHeader;
3912
+
3532
3913
 
3533
3914
 
3534
3915
 
@@ -3539,6 +3920,74 @@ var $cf6eaefd6b928de3$export$2e2bcd8739ae039 = $cf6eaefd6b928de3$var$DatasetAPI;
3539
3920
 
3540
3921
 
3541
3922
 
3923
+ const $bef7bff2823feea2$var$QueryTitle = ({ conditions: conditions, schema: schema, customColumns: customColumns })=>{
3924
+ const { fields: fields } = schema;
3925
+ const prependedMessage = /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Fragment), {
3926
+ children: "Data filters: "
3927
+ });
3928
+ if (!conditions || !conditions.length) return /*#__PURE__*/ (0, $hgUW1$jsxs)("p", {
3929
+ className: "ds-u-margin-y--0",
3930
+ children: [
3931
+ prependedMessage,
3932
+ " none"
3933
+ ]
3934
+ });
3935
+ function formatValue(text, property) {
3936
+ if (customColumns && customColumns.length > 0) {
3937
+ let newValue = text;
3938
+ let customColumn = customColumns.find((c)=>c.accessor === property);
3939
+ if (customColumn && customColumn.cell) return customColumn.cell({
3940
+ value: text
3941
+ });
3942
+ return text;
3943
+ } else return text;
3944
+ }
3945
+ return /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
3946
+ className: "dc-querybuilder-title",
3947
+ children: [
3948
+ /*#__PURE__*/ (0, $hgUW1$jsx)("p", {
3949
+ className: "ds-u-margin-y--0",
3950
+ children: prependedMessage
3951
+ }),
3952
+ conditions.map((c)=>{
3953
+ const field = fields[c.property];
3954
+ const description = field && field.description ? field.description : c.property;
3955
+ const operator = (0, $7264a673914aa746$export$5f89a5ae87bc48e1).find((op)=>op.value === c.operator);
3956
+ const cleanedText = (0, $7264a673914aa746$export$6b5e57d20078142b)(c.value);
3957
+ const formattedText = formatValue(cleanedText, c.property);
3958
+ return /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
3959
+ className: "ds-u-fill--background ds-u-padding--1 ds-u-margin-y--1 ds-u-display--inline-block ds-u-font-weight--semibold",
3960
+ children: [
3961
+ /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
3962
+ className: "ds-u-font-weight--bold",
3963
+ children: description
3964
+ }),
3965
+ " ",
3966
+ /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
3967
+ className: "ds-u-font-weight--normal",
3968
+ children: operator.label.toUpperCase()
3969
+ }),
3970
+ " ",
3971
+ /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
3972
+ className: "ds-u-color--success",
3973
+ children: formattedText
3974
+ })
3975
+ ]
3976
+ });
3977
+ }).reduce((prev, curr)=>[
3978
+ prev,
3979
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Badge), {
3980
+ className: "ds-u-margin-x--1",
3981
+ variation: "info",
3982
+ children: "AND"
3983
+ }),
3984
+ curr
3985
+ ])
3986
+ ]
3987
+ });
3988
+ };
3989
+ var $bef7bff2823feea2$export$2e2bcd8739ae039 = $bef7bff2823feea2$var$QueryTitle;
3990
+
3542
3991
 
3543
3992
 
3544
3993
 
@@ -3547,443 +3996,423 @@ var $cf6eaefd6b928de3$export$2e2bcd8739ae039 = $cf6eaefd6b928de3$var$DatasetAPI;
3547
3996
 
3548
3997
 
3549
3998
 
3550
- const $6765a74df807d015$var$DataDictionaryTable = ({ tableColumns: tableColumns, tableData: tableData, pageSize: pageSize, columnFilters: columnFilters })=>{
3551
- const [sorting, setSorting] = (0, $hgUW1$useState)([]);
3552
- const [ariaLiveFeedback, setAriaLiveFeedback] = (0, $hgUW1$useState)("");
3553
- const mobile = (0, $hgUW1$useMediaQuery)({
3554
- minWidth: 0,
3555
- maxWidth: 544
3999
+ function $6369abf590ca298f$var$getStartDate(condition, schema, id) {
4000
+ if (schema[id].fields[condition.property].mysql_type === "date") {
4001
+ const newDate = new Date(condition.value.toString());
4002
+ if (newDate instanceof Date && !isNaN(newDate.getTime())) return newDate;
4003
+ }
4004
+ return new Date();
4005
+ }
4006
+ const $6369abf590ca298f$var$QueryRow = ({ id: id, condition: condition, index: index, update: update, remove: remove, propertyOptions: propertyOptions, schema: schema })=>{
4007
+ const [operator, setOperator] = (0, $hgUW1$useState)(condition.operator);
4008
+ const [property, setProperty] = (0, $hgUW1$useState)(condition.property);
4009
+ const [value, setValue] = (0, $hgUW1$useState)(condition.value);
4010
+ const [startDate, setStartDate] = (0, $hgUW1$react).useState($6369abf590ca298f$var$getStartDate(condition, schema, id));
4011
+ const xl = (0, $hgUW1$useMediaQuery)({
4012
+ minWidth: 1280
3556
4013
  });
3557
- const sortElement = (isSorted)=>{
3558
- if (isSorted === "asc") return "dc-c-sort--asc";
3559
- if (isSorted === "desc") return "dc-c-sort--desc";
3560
- return "dc-c-sort--default";
3561
- };
3562
- const table = (0, $hgUW1$useReactTable)({
3563
- data: tableData,
3564
- columns: tableColumns,
3565
- columnResizeMode: "onChange",
3566
- getCoreRowModel: (0, $hgUW1$getCoreRowModel)(),
3567
- getFilteredRowModel: (0, $hgUW1$getFilteredRowModel)(),
3568
- getPaginationRowModel: (0, $hgUW1$getPaginationRowModel)(),
3569
- getSortedRowModel: (0, $hgUW1$getSortedRowModel)(),
3570
- onSortingChange: setSorting,
3571
- initialState: {
3572
- pagination: {
3573
- pageSize: pageSize,
3574
- pageIndex: 0
4014
+ (0, $hgUW1$useEffect)(()=>{
4015
+ if (property !== condition.property) {
4016
+ if (property) update(index, "property", property);
4017
+ else update(index, "property", "");
4018
+ if (schema[id].fields[condition.property].mysql_type === "date") {
4019
+ if (!value) setValue(startDate.toJSON().slice(0, 10));
3575
4020
  }
3576
- },
3577
- state: {
3578
- sorting: sorting,
3579
- columnFilters: columnFilters
3580
4021
  }
3581
- });
3582
- const sortOptions = [
3583
- {
3584
- value: "default",
3585
- label: "No Sort"
3586
- },
3587
- {
3588
- value: "titleasc",
3589
- label: "Title A-Z"
3590
- },
3591
- {
3592
- value: "titledesc",
3593
- label: "Title Z-A"
3594
- },
3595
- {
3596
- value: "typeasc",
3597
- label: "Type A-Z"
3598
- },
3599
- {
3600
- value: "typedesc",
3601
- label: "Type Z-A"
4022
+ }, [
4023
+ property,
4024
+ value,
4025
+ startDate,
4026
+ schema,
4027
+ id,
4028
+ condition
4029
+ ]);
4030
+ (0, $hgUW1$useEffect)(()=>{
4031
+ if (operator !== condition.operator) {
4032
+ if (operator) update(index, "operator", operator);
4033
+ else update(index, "operator", "");
3602
4034
  }
3603
- ];
3604
- const sortStatesLookup = {
3605
- default: [],
3606
- titleasc: [
3607
- {
3608
- id: "titleResizable",
3609
- desc: false
3610
- }
3611
- ],
3612
- titledesc: [
3613
- {
3614
- id: "titleResizable",
3615
- desc: true
3616
- }
3617
- ],
3618
- typeasc: [
3619
- {
3620
- id: "type",
3621
- desc: false
3622
- }
3623
- ],
3624
- typedesc: [
3625
- {
3626
- id: "type",
3627
- desc: true
3628
- }
3629
- ]
3630
- };
3631
- return /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
4035
+ }, [
4036
+ operator
4037
+ ]);
4038
+ (0, $hgUW1$useEffect)(()=>{
4039
+ if (value !== condition.value) {
4040
+ if (value) update(index, "value", value);
4041
+ else update(index, "value", "");
4042
+ }
4043
+ }, [
4044
+ value
4045
+ ]);
4046
+ return /*#__PURE__*/ (0, $hgUW1$jsxs)("fieldset", {
4047
+ className: "ds-u-display--flex ds-u-flex-wrap--wrap ds-u-justify-content--between ds-u-align-items--center ds-u-border--0",
3632
4048
  children: [
3633
- mobile && /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3634
- className: "ds-u-margin-bottom--3 ds-l-col--12 ds-l-sm-col--6",
3635
- children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Dropdown), {
3636
- labelClassName: "ds-u-margin-top--1 ds-u-sm-margin-top--0",
3637
- options: sortOptions,
3638
- label: "Sort",
3639
- value: Object.keys(sortStatesLookup).find((key)=>{
3640
- return JSON.stringify(sortStatesLookup[key]) == JSON.stringify(sorting);
4049
+ /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
4050
+ className: "ds-l-col--12 ds-l-md-col--8 ds-u-display--flex ds-u-justify-content--between ds-u-padding-x--0",
4051
+ children: [
4052
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Dropdown), {
4053
+ options: propertyOptions,
4054
+ className: "ds-l-col--8 ds-u-padding-left--0",
4055
+ value: property,
4056
+ label: "Column Name",
4057
+ name: `${condition.key}_property`,
4058
+ onChange: (e)=>setProperty(e.target.value)
3641
4059
  }),
3642
- name: "dc-data-dictionary-type",
3643
- onChange: (e)=>{
3644
- setSorting(sortStatesLookup[e.target.value]);
3645
- }
3646
- })
4060
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Dropdown), {
4061
+ options: (0, $7264a673914aa746$export$2b9377795161999)(schema[id].fields[property].mysql_type),
4062
+ className: "ds-l-col--4 ds-u-padding-x--0",
4063
+ value: operator,
4064
+ label: "Operator",
4065
+ name: `${condition.key}_operator`,
4066
+ onChange: (e)=>setOperator(e.target.value)
4067
+ })
4068
+ ]
3647
4069
  }),
3648
4070
  /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3649
- className: "dc-c-datadictionary-table",
4071
+ className: "ds-l-col--12 ds-l-md-col--4 ds-u-padding-x--0 ds-u-md-padding-left--2 ds-u-display--flex ds-u-justify-content--between",
3650
4072
  children: [
3651
- /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Table), {
3652
- className: "dc-c-datatable",
3653
- style: {
3654
- width: "100%"
3655
- },
3656
- stackable: true,
4073
+ schema[id].fields[property].mysql_type === "date" ? /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3657
4074
  children: [
3658
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableHead), {
3659
- className: "dc-thead--truncated dc-thead--resizeable",
3660
- children: table.getHeaderGroups().map((headerGroup)=>/*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableRow), {
3661
- children: headerGroup.headers.map((header)=>{
3662
- return header.id === "titleResizable" ? /*#__PURE__*/ (0, $hgUW1$jsx)((0, $64a351d3fd8413c3$export$2e2bcd8739ae039), {
3663
- table: table,
3664
- header: header,
3665
- setAriaLiveFeedback: setAriaLiveFeedback,
3666
- sortElement: sortElement
3667
- }, header.id + "_resize") : /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$TableCell), {
3668
- key: header.id,
3669
- className: `ds-u-border-y--2 ds-u-border--dark ds-u-border-x--0`,
3670
- id: "dataDictionary_" + header.id,
3671
- children: [
3672
- (0, $hgUW1$flexRender)(header.column.columnDef.header, header.getContext()),
3673
- header.id === "type" && /*#__PURE__*/ (0, $hgUW1$jsx)("button", {
3674
- onClick: header.column.getToggleSortingHandler(),
3675
- className: header.column.getCanSort() ? `cursor-pointer select-none ds-u-focus-visible ${sortElement(header.column.getIsSorted())}` : "",
3676
- "aria-label": `${header.column.columnDef.header} sort order`
3677
- })
3678
- ]
3679
- });
3680
- })
3681
- }, "header" + headerGroup.id))
3682
- }),
3683
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableBody), {
3684
- children: table.getRowModel().rows.map((row, index)=>{
3685
- return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableRow), {
3686
- children: row.getVisibleCells().map((cell)=>{
3687
- return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableCell), {
3688
- key: cell.id,
3689
- style: {
3690
- maxWidth: mobile ? "100%" : cell.column.getSize(),
3691
- whiteSpace: cell.column.id === "description" ? "pre-wrap" : "normal"
3692
- },
3693
- className: `${cell.column.id === "titleResizable" ? "ds-u-word-break" : ""}`,
3694
- headers: "dataDictionary_" + cell.column.id,
3695
- stackedTitle: cell.column.id === "titleResizable" ? "Title" : cell.column.columnDef.header,
3696
- children: (0, $hgUW1$flexRender)(cell.column.columnDef.cell, cell.getContext())
3697
- });
3698
- })
3699
- }, index + JSON.stringify(row));
4075
+ /*#__PURE__*/ (0, $hgUW1$jsx)("label", {
4076
+ className: "ds-c-label",
4077
+ htmlFor: `${condition.key}_date_value`,
4078
+ id: `${condition.key}_date_value-label`,
4079
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
4080
+ children: "Value"
3700
4081
  })
4082
+ }),
4083
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$reactdatepicker), {
4084
+ name: `${condition.key}_date_value`,
4085
+ selected: (0, $7264a673914aa746$export$e284ae5d89467c8f)(startDate),
4086
+ onChange: (date)=>{
4087
+ setStartDate(date);
4088
+ setValue(date.toJSON().slice(0, 10));
4089
+ },
4090
+ showMonthDropdown: true,
4091
+ showYearDropdown: true,
4092
+ dropdownMode: "select",
4093
+ className: "ds-c-field",
4094
+ withPortal: true
3701
4095
  })
3702
4096
  ]
4097
+ }) : /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TextField), {
4098
+ className: "ds-l-col--11 ds-u-padding-x--0",
4099
+ label: "Value",
4100
+ name: `${condition.key}_value`,
4101
+ value: (0, $7264a673914aa746$export$6b5e57d20078142b)(value, operator),
4102
+ onChange: (e)=>setValue(e.target.value)
3703
4103
  }),
3704
- /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3705
- className: "sr-only",
3706
- "aria-live": "assertive",
3707
- "aria-atomic": "true",
3708
- children: ariaLiveFeedback
3709
- }),
3710
- table.getRowModel().rows.length === 0 && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Alert), {
3711
- variation: "warn",
3712
- children: "No results found for the current filters"
4104
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
4105
+ variation: "ghost",
4106
+ size: "small",
4107
+ className: "ds-u-margin-top--6 ds-u-padding-right--0",
4108
+ "aria-label": "Delete filter",
4109
+ onClick: ()=>remove(index),
4110
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
4111
+ className: "fas fa-trash"
4112
+ })
3713
4113
  })
3714
4114
  ]
3715
- }),
3716
- table.getRowCount() > pageSize ? /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Pagination), {
3717
- totalPages: table.getPageCount(),
3718
- currentPage: table.getState().pagination.pageIndex + 1,
3719
- onPageChange: (evt, page)=>{
3720
- evt.preventDefault();
3721
- table.setPageIndex(page - 1);
3722
- },
3723
- renderHref: (page)=>{
3724
- return "";
3725
- }
3726
- }) : ""
4115
+ })
3727
4116
  ]
3728
4117
  });
3729
4118
  };
3730
- var $6765a74df807d015$export$2e2bcd8739ae039 = $6765a74df807d015$var$DataDictionaryTable;
3731
-
3732
-
3733
- const $a24829b27758fe6c$var$SitewideDataDictionaryTable = ({ datasetDictionary: datasetDictionary, pageSize: pageSize })=>{
3734
- const columnHelper = (0, $hgUW1$createColumnHelper)();
3735
- const tableColumns = [
3736
- columnHelper.accessor("name", {
3737
- header: "Name"
3738
- }),
3739
- columnHelper.accessor("title", {
3740
- header: "Title"
3741
- }),
3742
- columnHelper.accessor("type", {
3743
- header: "Type"
3744
- }),
3745
- columnHelper.accessor("format", {
3746
- header: "Format"
3747
- })
3748
- ];
3749
- return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $6765a74df807d015$export$2e2bcd8739ae039), {
3750
- tableColumns: tableColumns,
3751
- tableData: datasetDictionary,
3752
- pageSize: pageSize
3753
- });
3754
- };
3755
- var $a24829b27758fe6c$export$2e2bcd8739ae039 = $a24829b27758fe6c$var$SitewideDataDictionaryTable;
3756
-
3757
-
3758
-
3759
-
3760
-
3761
-
4119
+ var $6369abf590ca298f$export$2e2bcd8739ae039 = $6369abf590ca298f$var$QueryRow;
3762
4120
 
3763
4121
 
3764
4122
 
3765
- const $a6e312940f7003ef$var$DatasetDictionaryTable = ({ datasetDictionary: datasetDictionary, pageSize: pageSize })=>{
3766
- const [titleFilter, setTitleFilter] = (0, $hgUW1$useState)("");
3767
- const [typeFilter, setTypeFilter] = (0, $hgUW1$useState)("all");
3768
- const columnFilters = (0, $hgUW1$useMemo)(()=>[
4123
+ function $ee4ad47aa483e5b5$var$updateQueryForDatastore(condition) {
4124
+ let cond = condition;
4125
+ delete cond.key;
4126
+ if (cond.operator === "=" || cond.operator === "<>") {
4127
+ if (Array.isArray(cond.value)) cond.value = cond.value.join();
4128
+ cond.value = cond.value.replace(/(^\%+|\%+$)/gm, "");
4129
+ }
4130
+ if (cond.operator.toLowerCase() === "like") {
4131
+ if (Array.isArray(cond.value)) cond.value = cond.value.join();
4132
+ const cleanedValue = cond.value.replace(/(^\%+|\%+$)/gm, "");
4133
+ cond.value = `%${cleanedValue}%`;
4134
+ }
4135
+ if (cond.operator.toLowerCase() === "in") {
4136
+ if (!Array.isArray(cond.value)) cond.value = cond.value.split(",");
4137
+ }
4138
+ if (Array.isArray(cond.value)) cond.value = cond.value.map((v)=>v.trim().replace(/(^\%+|\%+$)/gm, ""));
4139
+ return cond;
4140
+ }
4141
+ const $ee4ad47aa483e5b5$var$QueryBuilder = ({ resource: resource, id: id, includeSearchParams: includeSearchParams = true, customColumns: customColumns, isModal: isModal = false })=>{
4142
+ const { conditions: conditions, schema: schema, setConditions: setConditions } = resource;
4143
+ const fields = Object.keys(schema[id].fields);
4144
+ const [queryConditions, setQueryConditions] = (0, $hgUW1$useState)([]);
4145
+ const [titleConditions, setTitleConditions] = (0, $hgUW1$useState)([]); // Add use effect to load conditions on first load if needed
4146
+ const [conditionsChanged, setConditionsChanged] = (0, $hgUW1$useState)(false);
4147
+ const syncConditions = ()=>{
4148
+ if (conditions && conditions.length) {
4149
+ const keyedConditions = conditions.map((oc)=>({
4150
+ ...oc,
4151
+ key: Date.now().toString() + oc.value + oc.property
4152
+ }));
4153
+ setQueryConditions(keyedConditions);
4154
+ } else setQueryConditions([
3769
4155
  {
3770
- id: "titleResizable",
3771
- value: titleFilter
3772
- },
4156
+ property: fields[0],
4157
+ value: "",
4158
+ operator: (0, $7264a673914aa746$export$2b9377795161999)(schema[id].fields[fields[0]].mysql_type)[0].value,
4159
+ key: Date.now().toString()
4160
+ }
4161
+ ]);
4162
+ };
4163
+ const addCondition = (condition)=>{
4164
+ if (Array.isArray(condition)) {
4165
+ const keyedConditions = condition.map((oc)=>({
4166
+ ...oc,
4167
+ key: Date.now().toString() + oc.value + oc.property
4168
+ }));
4169
+ setQueryConditions(keyedConditions);
4170
+ } else setQueryConditions([
4171
+ ...queryConditions,
3773
4172
  {
3774
- id: "type",
3775
- value: typeFilter === "all" ? "" : typeFilter
4173
+ property: fields[0],
4174
+ value: "",
4175
+ operator: (0, $7264a673914aa746$export$2b9377795161999)(schema[id].fields[fields[0]].mysql_type)[0].value,
4176
+ key: Date.now().toString()
3776
4177
  }
3777
- ], [
3778
- titleFilter,
3779
- typeFilter
4178
+ ]);
4179
+ };
4180
+ // Sync the UI with the actual data conditions whenever those change
4181
+ (0, $hgUW1$react).useEffect(()=>{
4182
+ syncConditions();
4183
+ setTitleConditions(conditions);
4184
+ }, [
4185
+ conditions
3780
4186
  ]);
3781
- const tableData = datasetDictionary.map((item)=>{
4187
+ const propertyOptions = fields.map((f)=>{
4188
+ if (schema[id].fields[f].description) return {
4189
+ label: schema[id].fields[f].description,
4190
+ value: f
4191
+ };
3782
4192
  return {
3783
- titleResizable: item.title,
3784
- description: item.description,
3785
- type: item.type
4193
+ label: f,
4194
+ value: f
3786
4195
  };
3787
4196
  });
3788
- const columnHelper = (0, $hgUW1$createColumnHelper)();
3789
- const tableColumns = [
3790
- columnHelper.accessor("titleResizable", {
3791
- header: ()=>/*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3792
- className: "dc-c-tooltip-width-override",
3793
- children: [
3794
- "Title",
3795
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Tooltip), {
3796
- title: "Title represents the column headers of the data file",
3797
- // @ts-ignore
3798
- style: {
3799
- border: "none",
3800
- background: "none"
3801
- },
3802
- maxWidth: "400px",
3803
- children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TooltipIcon), {})
3804
- })
3805
- ]
3806
- }),
3807
- size: 300
3808
- }),
3809
- columnHelper.accessor("description", {
3810
- header: "Description",
3811
- minSize: 600
3812
- }),
3813
- columnHelper.accessor("type", {
3814
- header: "Type",
3815
- size: 150,
3816
- enableResizing: false
3817
- })
3818
- ];
3819
- const typeOptions = [
3820
- {
3821
- value: "all",
3822
- label: "All Types"
3823
- },
3824
- {
3825
- value: "string",
3826
- label: "String"
3827
- },
3828
- {
3829
- value: "date",
3830
- label: "Date"
3831
- },
3832
- {
3833
- value: "datetime",
3834
- label: "Datetime"
3835
- },
3836
- {
3837
- value: "year",
3838
- label: "Year"
3839
- },
3840
- {
3841
- value: "integer",
3842
- label: "Integer"
3843
- },
3844
- {
3845
- value: "number",
3846
- label: "Number"
3847
- },
3848
- {
3849
- value: "boolean",
3850
- label: "Boolean"
4197
+ const updateBrowserURL = (newConditions)=>{
4198
+ if (includeSearchParams) {
4199
+ const url = new URL(window.location.href);
4200
+ const urlString = (0, $hgUW1$qs).stringify({
4201
+ conditions: newConditions
4202
+ }, {
4203
+ encodeValuesOnly: true,
4204
+ addQueryPrefix: true
4205
+ });
4206
+ window.history.pushState({}, "", `${url.origin}${url.pathname}${urlString}`);
3851
4207
  }
3852
- ];
3853
- return /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
3854
- children: [
3855
- /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3856
- className: "dc-query-builder ds-u-margin-bottom--3",
3857
- children: /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3858
- className: "ds-c-accordion ds-c-accordion--bordered",
3859
- children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$AccordionItem), {
3860
- heading: "Data Dictionary Filters",
3861
- defaultOpen: true,
3862
- children: /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3863
- className: "ds-u-display--flex ds-u-flex-wrap--wrap",
4208
+ };
4209
+ const submitConditions = (e)=>{
4210
+ // only update the data conditions when "Apply filters" is pressed
4211
+ e.preventDefault();
4212
+ const submitConditions = queryConditions.filter((oc)=>{
4213
+ if (oc.property) return oc;
4214
+ return false;
4215
+ }).map((oc)=>{
4216
+ let cond = Object.assign({}, oc);
4217
+ return $ee4ad47aa483e5b5$var$updateQueryForDatastore(cond);
4218
+ });
4219
+ setConditions(submitConditions);
4220
+ setConditionsChanged(false);
4221
+ updateBrowserURL(submitConditions);
4222
+ };
4223
+ const updateCondition = (index, key, value)=>{
4224
+ let newConditions = [
4225
+ ...queryConditions
4226
+ ];
4227
+ newConditions[index][key] = value;
4228
+ setQueryConditions(newConditions);
4229
+ setConditionsChanged(true);
4230
+ };
4231
+ const removeCondition = (index)=>{
4232
+ // just removes the condition from the UI - "Apply Filters" must be clicked to change the data model
4233
+ let newConditions = queryConditions.map((oc)=>Object.assign({}, oc));
4234
+ newConditions.splice(index, 1);
4235
+ setQueryConditions(newConditions);
4236
+ setConditionsChanged(true);
4237
+ };
4238
+ return /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
4239
+ className: "dc-query-builder ds-u-margin-bottom--3",
4240
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
4241
+ className: "ds-c-accordion ds-c-accordion--bordered",
4242
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$AccordionItem), {
4243
+ heading: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $bef7bff2823feea2$export$2e2bcd8739ae039), {
4244
+ schema: schema[id],
4245
+ conditions: titleConditions,
4246
+ customColumns: customColumns
4247
+ }),
4248
+ defaultOpen: !isModal,
4249
+ children: /*#__PURE__*/ (0, $hgUW1$jsxs)("form", {
4250
+ onSubmit: (e)=>submitConditions(e),
4251
+ children: [
4252
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
4253
+ children: queryConditions.map((qf, index)=>/*#__PURE__*/ (0, $hgUW1$jsx)((0, $6369abf590ca298f$export$2e2bcd8739ae039), {
4254
+ id: id,
4255
+ schema: schema,
4256
+ condition: qf,
4257
+ index: index,
4258
+ propertyOptions: propertyOptions,
4259
+ update: updateCondition,
4260
+ remove: removeCondition
4261
+ }, qf.key))
4262
+ }),
4263
+ /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
4264
+ className: "dc-query-bulder--form-buttons ds-u-padding-x--2 ds-u-padding-top--0 ds-u-md-padding-top--2 ds-u-display--flex ds-u-flex-wrap--wrap",
3864
4265
  children: [
3865
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TextField), {
3866
- className: "ds-l-col--12 ds-l-sm-col--6",
3867
- labelClassName: "ds-u-margin-top--1 ds-u-sm-margin-top--0",
3868
- label: "Title",
3869
- value: titleFilter,
3870
- name: "dc-data-dictionary-title",
3871
- onChange: (e)=>setTitleFilter(e.target.value)
3872
- }),
3873
4266
  /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3874
- className: "ds-l-col--12 ds-l-sm-col--6",
3875
- children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Dropdown), {
3876
- labelClassName: "ds-u-margin-top--1 ds-u-sm-margin-top--0",
3877
- options: typeOptions,
3878
- label: "Type",
3879
- value: typeFilter,
3880
- name: "dc-data-dictionary-type",
3881
- onChange: (e)=>setTypeFilter(e.target.value)
4267
+ className: "ds-l-col--12 ds-l-md-col--4 ds-l-md-col--6 ds-u-padding-x--0 ds-u-margin-bottom--2 ds-u-md-margin-bottom--0",
4268
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
4269
+ variation: "ghost",
4270
+ onClick: ()=>addCondition(null),
4271
+ className: "ds-u-padding-left--0",
4272
+ children: "+ Add filter"
3882
4273
  })
3883
4274
  }),
3884
- /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3885
- className: "ds-u-float--right ds-u-padding-y--2 ds-l-col--12 ds-u-display--flex ds-u-flex-wrap--wrap ds-u-justify-content--end",
3886
- children: /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3887
- className: "ds-u-display--flex ds-u-justify-content--end ds-l-col--12 ds-l-md-col--6 ds-u-padding-x--0",
3888
- children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $2eec38d4d0dbf714$export$2e2bcd8739ae039), {
4275
+ /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
4276
+ className: "ds-u-display--flex ds-u-justify-content--end ds-l-col--12 ds-l-md-col--6 ds-u-padding-x--0",
4277
+ children: [
4278
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
4279
+ disabled: !conditionsChanged,
4280
+ className: "ds-u-float--right ds-l-md-col--6 ds-u-margin--right--0 ds-u-sm-margin-right--2",
4281
+ type: "submit",
4282
+ variation: "solid",
4283
+ children: "Apply filters"
4284
+ }),
4285
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $2eec38d4d0dbf714$export$2e2bcd8739ae039), {
4286
+ disabled: queryConditions.length === 0,
3889
4287
  clearFiltersFn: ()=>{
3890
- setTitleFilter("");
3891
- setTypeFilter("all");
4288
+ setConditions([]);
4289
+ updateBrowserURL([]);
3892
4290
  }
3893
4291
  })
3894
- })
4292
+ ]
3895
4293
  })
3896
4294
  ]
3897
4295
  })
3898
- })
4296
+ ]
3899
4297
  })
3900
- }),
3901
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $6765a74df807d015$export$2e2bcd8739ae039), {
3902
- tableColumns: tableColumns,
3903
- tableData: tableData,
3904
- pageSize: pageSize,
3905
- columnFilters: columnFilters
3906
4298
  })
3907
- ]
4299
+ })
3908
4300
  });
3909
4301
  };
3910
- var $a6e312940f7003ef$export$2e2bcd8739ae039 = $a6e312940f7003ef$var$DatasetDictionaryTable;
4302
+ var $ee4ad47aa483e5b5$export$2e2bcd8739ae039 = $ee4ad47aa483e5b5$var$QueryBuilder;
3911
4303
 
3912
4304
 
3913
4305
 
3914
- const $6012b86ffcaf3f71$var$DataDictionary = ({ datasetDictionaryEndpoint: datasetDictionaryEndpoint, datasetSitewideDictionary: datasetSitewideDictionary, title: title, pageSize: pageSize = 20, additionalParams: additionalParams, csvDownload: csvDownload })=>{
3915
- const { data: data, isPending: isPending, error: error } = (0, $hgUW1$useQuery)({
3916
- queryKey: [
3917
- "dictionary" + datasetDictionaryEndpoint
3918
- ],
3919
- queryFn: ()=>{
3920
- return (0, $hgUW1$axios).get(`${datasetDictionaryEndpoint}?${(0, $hgUW1$qs).stringify(additionalParams, {
3921
- arrayFormat: "comma",
3922
- encode: false
3923
- })}`).then((res)=>res.data).catch((error)=>console.error(error));
3924
- },
3925
- enabled: datasetDictionaryEndpoint !== undefined
3926
- });
3927
- const datasetDictionary = data && data.data && data.data.fields && data.data.fields.length ? data.data.fields : null;
3928
- return /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
4306
+
4307
+ function $a35cf16d1488f54e$export$1147582dfae658c6(columns, schema) {
4308
+ return columns.map((column)=>({
4309
+ header: schema && schema.fields[column].description ? schema.fields[column].description : column,
4310
+ accessor: column
4311
+ }));
4312
+ }
4313
+ const $a35cf16d1488f54e$var$DatasetTable = ({ isModal: isModal = false, closeFullScreenModal: closeFullScreenModal })=>{
4314
+ const { id: id, distribution: distribution, resource: resource, rootUrl: rootUrl, customColumns: customColumns = [], dataDictionaryBanner: dataDictionaryBanner } = (0, $hgUW1$useContext)((0, $a0f13962e513caa1$export$a7997ae78b143b));
4315
+ const { page: page, setPage: setPage } = (0, $hgUW1$useContext)((0, $39bc4d98030a5599$export$a5806b00c0db0089));
4316
+ const defaultPageSize = 10;
4317
+ const customColumnHeaders = (0, $7264a673914aa746$export$8049e8f40a9bdfb8)(customColumns, resource.columns, resource.schema[distribution.identifier]);
4318
+ const columns = customColumnHeaders ? customColumnHeaders : $a35cf16d1488f54e$export$1147582dfae658c6(resource.columns, resource.schema[id]);
4319
+ const { limit: limit, setOffset: setOffset } = resource;
4320
+ const pageSize = limit ? limit : defaultPageSize;
4321
+ const downloadURL = `${rootUrl}/datastore/query/${id}/0/download?${(0, $hgUW1$qs).stringify({
4322
+ conditions: resource.conditions
4323
+ }, {
4324
+ encode: true
4325
+ })}&format=csv`;
4326
+ if (Object.keys(resource).length && columns.length && resource.schema && Object.keys(distribution).length) return /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
3929
4327
  children: [
3930
- /*#__PURE__*/ (0, $hgUW1$jsx)("h2", {
3931
- className: "ds-text-heading--2xl ds-u-margin-y--3",
3932
- children: title
4328
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $ee4ad47aa483e5b5$export$2e2bcd8739ae039), {
4329
+ resource: resource,
4330
+ id: distribution.identifier,
4331
+ customColumns: customColumnHeaders,
4332
+ isModal: isModal
3933
4333
  }),
3934
- datasetDictionary && /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
3935
- children: [
3936
- /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3937
- className: "ds-u-margin-bottom--1 ds-u-display--flex ds-u-flex-wrap--wrap ds-u-justify-content--end",
3938
- children: [
3939
- /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Button), {
3940
- className: "ds-l-col--12 ds-l-sm-col--6 ds-l-md-col--4",
3941
- onClick: ()=>window.open(datasetDictionaryEndpoint),
3942
- type: "button",
3943
- children: [
3944
- /*#__PURE__*/ (0, $hgUW1$jsx)("i", {
3945
- className: "fa fa-file-download ds-u-color--primary ds-u-padding-right--1"
3946
- }),
3947
- " View Dictionary JSON"
3948
- ]
3949
- }),
3950
- csvDownload && /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3951
- className: "ds-l-col--12 ds-l-sm-col--6 ds-l-md-col--4 ds-u-margin-top--2 ds-u-sm-margin-top--0 ds-u-padding--0 ds-u-sm-padding-left--2",
3952
- children: /*#__PURE__*/ (0, $hgUW1$jsxs)("a", {
3953
- href: datasetDictionaryEndpoint + "/csv",
3954
- className: "ds-c-button",
3955
- style: {
3956
- width: "100%"
3957
- },
3958
- children: [
3959
- /*#__PURE__*/ (0, $hgUW1$jsx)("i", {
3960
- className: "fa fa-file-download ds-u-color--primary ds-u-padding-right--1"
3961
- }),
3962
- "Download Dictionary CSV"
3963
- ]
3964
- })
3965
- })
3966
- ]
3967
- }),
3968
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $a6e312940f7003ef$export$2e2bcd8739ae039), {
3969
- datasetDictionary: datasetDictionary,
3970
- pageSize: pageSize
3971
- })
3972
- ]
4334
+ dataDictionaryBanner && !isModal && /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
4335
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Alert), {
4336
+ children: 'Click on the "Data Dictionary" tab above for full column definitions'
4337
+ })
3973
4338
  }),
3974
- datasetSitewideDictionary && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $a24829b27758fe6c$export$2e2bcd8739ae039), {
3975
- datasetDictionary: datasetSitewideDictionary,
3976
- pageSize: pageSize
4339
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $6380a4a580b24362$export$2e2bcd8739ae039), {
4340
+ resource: resource,
4341
+ downloadURL: downloadURL,
4342
+ unfilteredDownloadURL: distribution.data.downloadURL,
4343
+ setPage: setPage
4344
+ }),
4345
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
4346
+ className: `ds-u-border-x--1 ds-u-border-bottom--1 ${isModal && "dkan-datatable-fullscreen-mode"}`,
4347
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $d98f94c79ddf4e0e$export$2e2bcd8739ae039), {
4348
+ canResize: true,
4349
+ columns: columns,
4350
+ sortTransform: (0, $aa4450dcbeef3ac0$export$385a5aba38cc3325),
4351
+ tablePadding: "ds-u-padding-y--2",
4352
+ loading: resource.loading,
4353
+ isModal: isModal,
4354
+ closeFullScreenModal: closeFullScreenModal
4355
+ })
4356
+ }),
4357
+ !resource.loading && resource.count !== null && /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
4358
+ className: "ds-u-display--flex ds-u-flex-wrap--wrap ds-u-justify-content--end ds-u-md-justify-content--between ds-u-margin-top--2 ds-u-align-items--center",
4359
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Pagination), {
4360
+ totalPages: Math.ceil(resource.count ? resource.count / pageSize : 1),
4361
+ currentPage: Number(page),
4362
+ onPageChange: (evt, page)=>{
4363
+ evt.preventDefault();
4364
+ setOffset((page - 1) * limit);
4365
+ setPage(page);
4366
+ },
4367
+ renderHref: (p)=>`?page=${p}`,
4368
+ className: "ds-l-col--12 ds-u-padding-x--0"
4369
+ })
3977
4370
  })
3978
4371
  ]
3979
4372
  });
4373
+ else return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Spinner), {
4374
+ "aria-valuetext": "Dataset loading",
4375
+ role: "status",
4376
+ className: "ds-u-margin--3"
4377
+ });
3980
4378
  };
3981
- var $6012b86ffcaf3f71$export$2e2bcd8739ae039 = (0, $61ff88fb3f6ee2c8$export$2e2bcd8739ae039)($6012b86ffcaf3f71$var$DataDictionary);
4379
+ var $a35cf16d1488f54e$export$2e2bcd8739ae039 = $a35cf16d1488f54e$var$DatasetTable;
3982
4380
 
3983
4381
 
3984
4382
 
4383
+ const $39bc4d98030a5599$export$a5806b00c0db0089 = /*#__PURE__*/ (0, $hgUW1$createContext)({});
4384
+ const $39bc4d98030a5599$var$DataTableStateWrapper = ()=>{
4385
+ const { id: id, datasetTableControls: datasetTableControls } = (0, $hgUW1$useContext)((0, $a0f13962e513caa1$export$a7997ae78b143b));
4386
+ // a wrapper component to keep column state synced between full screen and regular modes
4387
+ const localStorageData = id ? JSON.parse(localStorage.getItem(id)) : null;
4388
+ const defaultPage = 1;
4389
+ const [page, setPage] = (0, $hgUW1$useState)(defaultPage);
4390
+ const [columnOrder, setColumnOrder] = (0, $hgUW1$useState)(()=>{
4391
+ if (datasetTableControls && localStorageData) return localStorageData.tableColumnOrder;
4392
+ else return [];
4393
+ });
4394
+ const [columnVisibility, setColumnVisibility] = (0, $hgUW1$useState)(()=>{
4395
+ if (datasetTableControls && localStorageData) return localStorageData.tableColumnVisibility;
4396
+ else return {};
4397
+ });
4398
+ return /*#__PURE__*/ (0, $hgUW1$jsx)($39bc4d98030a5599$export$a5806b00c0db0089.Provider, {
4399
+ value: {
4400
+ columnOrder: columnOrder,
4401
+ setColumnOrder: setColumnOrder,
4402
+ columnVisibility: columnVisibility,
4403
+ setColumnVisibility: setColumnVisibility,
4404
+ page: page,
4405
+ setPage: setPage
4406
+ },
4407
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $a35cf16d1488f54e$export$2e2bcd8739ae039), {})
4408
+ });
4409
+ };
4410
+ var $39bc4d98030a5599$export$2e2bcd8739ae039 = $39bc4d98030a5599$var$DataTableStateWrapper;
3985
4411
 
3986
4412
 
4413
+ const $a0f13962e513caa1$export$a7997ae78b143b = /*#__PURE__*/ (0, $hgUW1$createContext)({
4414
+ id: null
4415
+ });
3987
4416
  const $a0f13962e513caa1$var$getDataDictionary = (dataDictionaryUrl, additionalParams)=>{
3988
4417
  const { data: data, isPending: isPending, error: error } = (0, $hgUW1$useQuery)({
3989
4418
  queryKey: [
@@ -4001,7 +4430,7 @@ const $a0f13962e513caa1$var$getDataDictionary = (dataDictionaryUrl, additionalPa
4001
4430
  dataDictionaryLoading: isPending
4002
4431
  };
4003
4432
  };
4004
- const $a0f13962e513caa1$var$Dataset = ({ id: id, rootUrl: rootUrl, additionalParams: additionalParams, customColumns: customColumns, setDatasetTitle: setDatasetTitle, customMetadataMapping: customMetadataMapping, apiPageUrl: apiPageUrl = "/api", dataDictionaryUrl: dataDictionaryUrl, borderlessTabs: borderlessTabs = false, defaultPageSize: defaultPageSize = 25, dataDictionaryCSV: dataDictionaryCSV = false, dataDictionaryBanner: dataDictionaryBanner = false })=>{
4433
+ const $a0f13962e513caa1$var$Dataset = ({ id: id, rootUrl: rootUrl, additionalParams: additionalParams, customColumns: customColumns, setDatasetTitle: setDatasetTitle, customMetadataMapping: customMetadataMapping, apiPageUrl: apiPageUrl = "/api", dataDictionaryUrl: dataDictionaryUrl, borderlessTabs: borderlessTabs = false, defaultPageSize: defaultPageSize = 25, dataDictionaryCSV: dataDictionaryCSV = false, dataDictionaryBanner: dataDictionaryBanner = false, disableTableControls: disableTableControls = false })=>{
4005
4434
  const options = location.search ? {
4006
4435
  ...(0, $hgUW1$qs).parse(location.search, {
4007
4436
  ignoreQueryPrefix: true
@@ -4104,7 +4533,7 @@ const $a0f13962e513caa1$var$Dataset = ({ id: id, rootUrl: rootUrl, additionalPar
4104
4533
  })
4105
4534
  }),
4106
4535
  /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
4107
- className: "ds-l-md-col--12 ds-u-color--gray ds-u-margin-y--1 ds-u-text-align--right",
4536
+ className: "ds-l-md-col--12 ds-u-margin-y--1 ds-u-text-align--right",
4108
4537
  children: /*#__PURE__*/ (0, $hgUW1$jsxs)("p", {
4109
4538
  className: "ds-u-margin--0",
4110
4539
  children: [
@@ -4151,13 +4580,17 @@ const $a0f13962e513caa1$var$Dataset = ({ id: id, rootUrl: rootUrl, additionalPar
4151
4580
  ]
4152
4581
  }),
4153
4582
  className: borderlessTabs ? "ds-u-border--0 ds-u-padding-x--0" : "",
4154
- children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $a35cf16d1488f54e$export$2e2bcd8739ae039), {
4155
- id: id,
4156
- distribution: distribution,
4157
- resource: resource,
4158
- rootUrl: rootUrl,
4159
- customColumns: customColumns,
4160
- dataDictionaryBanner: dataDictionaryBanner && displayDataDictionaryTab
4583
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)($a0f13962e513caa1$export$a7997ae78b143b.Provider, {
4584
+ value: {
4585
+ id: id,
4586
+ resource: resource,
4587
+ distribution: distribution,
4588
+ rootUrl: rootUrl,
4589
+ customColumns: customColumns,
4590
+ dataDictionaryBanner: dataDictionaryBanner && displayDataDictionaryTab,
4591
+ datasetTableControls: !disableTableControls
4592
+ },
4593
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $39bc4d98030a5599$export$2e2bcd8739ae039), {})
4161
4594
  })
4162
4595
  }),
4163
4596
  /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TabPanel), {
@@ -4179,7 +4612,7 @@ const $a0f13962e513caa1$var$Dataset = ({ id: id, rootUrl: rootUrl, additionalPar
4179
4612
  metadataMapping: metadataMapping
4180
4613
  })
4181
4614
  }),
4182
- displayDataDictionaryTab && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TabPanel), {
4615
+ /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$TabPanel), {
4183
4616
  id: "data-dictionary",
4184
4617
  tab: /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
4185
4618
  className: "ds-u-color--primary",
@@ -4191,13 +4624,18 @@ const $a0f13962e513caa1$var$Dataset = ({ id: id, rootUrl: rootUrl, additionalPar
4191
4624
  ]
4192
4625
  }),
4193
4626
  className: borderlessTabs ? "ds-u-border--0 ds-u-padding-x--0" : "",
4194
- children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $6012b86ffcaf3f71$export$2e2bcd8739ae039), {
4195
- datasetSitewideDictionary: datasetSitewideDictionary,
4196
- datasetDictionaryEndpoint: distribution.data.describedBy,
4197
- title: "Data Dictionary",
4198
- additionalParams: additionalParams,
4199
- csvDownload: dataDictionaryCSV
4200
- })
4627
+ children: [
4628
+ displayDataDictionaryTab && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $6012b86ffcaf3f71$export$2e2bcd8739ae039), {
4629
+ datasetSitewideDictionary: datasetSitewideDictionary,
4630
+ datasetDictionaryEndpoint: distribution.data.describedBy,
4631
+ title: "Data Dictionary",
4632
+ additionalParams: additionalParams,
4633
+ csvDownload: dataDictionaryCSV
4634
+ }),
4635
+ !displayDataDictionaryTab && /*#__PURE__*/ (0, $hgUW1$jsx)("p", {
4636
+ children: "There is no Data Dictionary associated with this dataset."
4637
+ })
4638
+ ]
4201
4639
  }),
4202
4640
  distribution && distribution.data && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TabPanel), {
4203
4641
  id: "api",
@@ -4351,8 +4789,7 @@ var $b9af6ce5e2c06331$export$2e2bcd8739ae039 = $b9af6ce5e2c06331$var$Header;
4351
4789
 
4352
4790
 
4353
4791
 
4354
-
4355
- const $24918217e48ac525$var$NavLink = ({ link: link, className: className, wrapLabel: wrapLabel, clickHandler: clickHandler })=>{
4792
+ const $24918217e48ac525$var$NavLink = ({ link: link, className: className = null, wrapLabel: wrapLabel = false, clickHandler: clickHandler })=>{
4356
4793
  const innerHtml = wrapLabel ? /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
4357
4794
  children: link.label
4358
4795
  }) : link.label;
@@ -4364,25 +4801,20 @@ const $24918217e48ac525$var$NavLink = ({ link: link, className: className, wrapL
4364
4801
  });
4365
4802
  // }
4366
4803
  };
4367
- $24918217e48ac525$var$NavLink.defaultProps = {
4368
- wrapLabel: false,
4369
- className: null
4370
- };
4371
- $24918217e48ac525$var$NavLink.propTypes = {
4372
- link: (0, $hgUW1$proptypes).shape({
4373
- url: (0, $hgUW1$proptypes).string,
4374
- label: (0, $hgUW1$proptypes).string,
4375
- nonReactLink: (0, $hgUW1$proptypes).bool
4376
- }).isRequired,
4377
- className: (0, $hgUW1$proptypes).string,
4378
- /**
4379
- * Will wrap the link label in a span for help with styling.
4380
- */ wrapLabel: (0, $hgUW1$proptypes).bool
4381
- };
4382
4804
  var $24918217e48ac525$export$2e2bcd8739ae039 = $24918217e48ac525$var$NavLink;
4383
4805
 
4384
4806
 
4385
- const $a6df0aa147323304$var$Footer = ({ links: links, showEmail: showEmail, emailTitle: emailTitle, emailBody: emailBody, emailLink: emailLink, emailButton: emailButton, socialMediaLinks: socialMediaLinks, hhsLogo: hhsLogo, cmsLogo: cmsLogo, trademarkContent: trademarkContent })=>{
4807
+ const $a6df0aa147323304$var$Footer = ({ links: links, showEmail: showEmail = true, emailTitle: emailTitle = "Get Email Updates", emailBody: emailBody = "Sign up to get the latest information from CMS by choosing the topics and frequency of emails that are best for you.", emailLink: emailLink = "", emailButton: emailButton = "Sign up for email updates", socialMediaLinks: socialMediaLinks = null, hhsLogo: hhsLogo, cmsLogo: cmsLogo, trademarkContent: trademarkContent = /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
4808
+ children: [
4809
+ /*#__PURE__*/ (0, $hgUW1$jsx)("p", {
4810
+ children: "A federal government website managed and paid for by the U.S. Centers for Medicare & Medicaid Services."
4811
+ }),
4812
+ /*#__PURE__*/ (0, $hgUW1$jsx)("p", {
4813
+ className: "ds-u-padding-bottom--2",
4814
+ children: "7500 Security Boulevard, Baltimore, MD 21244"
4815
+ })
4816
+ ]
4817
+ }) })=>{
4386
4818
  const { footerOpenDataToolLinks: footerOpenDataToolLinks, footerAdditionalResourcesLinks: footerAdditionalResourcesLinks, footerUtilityLinks: footerUtilityLinks } = links;
4387
4819
  return /*#__PURE__*/ (0, $hgUW1$jsxs)("footer", {
4388
4820
  className: "dc-c-footer",
@@ -4768,25 +5200,6 @@ const $a6df0aa147323304$var$Footer = ({ links: links, showEmail: showEmail, emai
4768
5200
  ]
4769
5201
  });
4770
5202
  };
4771
- $a6df0aa147323304$var$Footer.defaultProps = {
4772
- showEmail: true,
4773
- emailTitle: "Get Email Updates",
4774
- emailBody: "Sign up to get the latest information from CMS by choosing the topics and frequency of emails that are best for you.",
4775
- emailLink: "",
4776
- emailButton: "Sign up for email updates",
4777
- socialMediaLinks: null,
4778
- trademarkContent: /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
4779
- children: [
4780
- /*#__PURE__*/ (0, $hgUW1$jsx)("p", {
4781
- children: "A federal government website managed and paid for by the U.S. Centers for Medicare & Medicaid Services."
4782
- }),
4783
- /*#__PURE__*/ (0, $hgUW1$jsx)("p", {
4784
- className: "ds-u-padding-bottom--2",
4785
- children: "7500 Security Boulevard, Baltimore, MD 21244"
4786
- })
4787
- ]
4788
- })
4789
- };
4790
5203
  $a6df0aa147323304$var$Footer.propTypes = {
4791
5204
  showEmail: (0, $hgUW1$proptypes).bool,
4792
5205
  emailTitle: (0, $hgUW1$proptypes).string,
@@ -4956,7 +5369,7 @@ const $c7bf75f7e8a68780$export$7850f4d545d994c6 = [
4956
5369
 
4957
5370
 
4958
5371
  const $669d2782ec2e2250$var$SpecsAndLimits = (props)=>{
4959
- const { documentationList: documentationList, children: children } = props;
5372
+ const { documentationList: documentationList = (0, $c7bf75f7e8a68780$export$7850f4d545d994c6), children: children } = props;
4960
5373
  const defaultContent = /*#__PURE__*/ (0, $hgUW1$jsx)("p", {
4961
5374
  children: "Some datasets are extremely large and may be difficult to download and/or cause computer performance issues. The Centers for Medicare and Medicaid Services (CMS) recommends using WinZip, WinRAR, or 7-Zip for file decompression."
4962
5375
  });
@@ -5008,12 +5421,6 @@ const $669d2782ec2e2250$var$SpecsAndLimits = (props)=>{
5008
5421
  })
5009
5422
  });
5010
5423
  };
5011
- $669d2782ec2e2250$var$SpecsAndLimits.defaultProps = {
5012
- documentationList: (0, $c7bf75f7e8a68780$export$7850f4d545d994c6),
5013
- content: /*#__PURE__*/ (0, $hgUW1$jsx)("p", {
5014
- children: "Some datasets are extremely large and may be difficult to download and/or cause computer performance issues. The Centers for Medicare and Medicaid Services (CMS) recommends using WinZip, WinRAR, or 7-Zip for file decompression."
5015
- })
5016
- };
5017
5424
  var $669d2782ec2e2250$export$2e2bcd8739ae039 = $669d2782ec2e2250$var$SpecsAndLimits;
5018
5425
 
5019
5426
 
@@ -5122,7 +5529,7 @@ var $efc410f5f7ac5ef3$export$2e2bcd8739ae039 = $efc410f5f7ac5ef3$var$useSearchAP
5122
5529
 
5123
5530
 
5124
5531
 
5125
- const $59a079354baa335c$var$Hero = ({ title: title, description: description, searchUrl: searchUrl, searchKey: searchKey, textfieldLabel: textfieldLabel, searchButtonText: searchButtonText })=>{
5532
+ const $59a079354baa335c$var$Hero = ({ title: title, description: description, searchUrl: searchUrl = "datasets", searchKey: searchKey = "fulltext", textfieldLabel: textfieldLabel = "Search for a dataset", searchButtonText: searchButtonText = "Search" })=>{
5126
5533
  const navigate = (0, $hgUW1$useNavigate)();
5127
5534
  const [searchValue, setSearchValue] = (0, $hgUW1$react).useState("");
5128
5535
  function submitHero(e) {
@@ -5196,12 +5603,6 @@ const $59a079354baa335c$var$Hero = ({ title: title, description: description, se
5196
5603
  })
5197
5604
  });
5198
5605
  };
5199
- $59a079354baa335c$var$Hero.defaultProps = {
5200
- searchKey: "fulltext",
5201
- searchUrl: "datasets",
5202
- textfieldLabel: "Search for a dataset",
5203
- searchButtonText: "Search"
5204
- };
5205
5606
  var $59a079354baa335c$export$2e2bcd8739ae039 = $59a079354baa335c$var$Hero;
5206
5607
 
5207
5608
 
@@ -5253,22 +5654,13 @@ var $1e012d1e3b534af0$export$2e2bcd8739ae039 = $1e012d1e3b534af0$var$DataTableDe
5253
5654
 
5254
5655
 
5255
5656
 
5256
- const $e71aee394fdad8bd$var$ManageColumns = ()=>{
5257
- const [modalOpen, setModalOpen] = (0, $hgUW1$useState)(false);
5258
- return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
5259
- onClick: ()=>setModalOpen(!modalOpen),
5260
- children: "Manage Columns"
5261
- });
5262
- };
5263
- var $e71aee394fdad8bd$export$2e2bcd8739ae039 = $e71aee394fdad8bd$var$ManageColumns;
5264
-
5265
-
5266
5657
 
5267
-
5268
-
5269
-
5270
- const $7848c69a021266f7$var$DataTableRowChanger = (props)=>{
5271
- const { limit: limit, rowOptions: rowOptions, setLimit: setLimit } = props;
5658
+ const $7848c69a021266f7$var$DataTableRowChanger = ({ limit: limit, rowOptions: rowOptions = [
5659
+ 10,
5660
+ 25,
5661
+ 50,
5662
+ 100
5663
+ ], setLimit: setLimit })=>{
5272
5664
  const rowOptionsFormatted = rowOptions.map((row)=>({
5273
5665
  label: row.toString(),
5274
5666
  value: row.toString()
@@ -5285,14 +5677,6 @@ const $7848c69a021266f7$var$DataTableRowChanger = (props)=>{
5285
5677
  })
5286
5678
  });
5287
5679
  };
5288
- $7848c69a021266f7$var$DataTableRowChanger.defaultProps = {
5289
- rowOptions: [
5290
- 10,
5291
- 25,
5292
- 50,
5293
- 100
5294
- ]
5295
- };
5296
5680
  $7848c69a021266f7$var$DataTableRowChanger.propTypes = {
5297
5681
  rowOptions: (0, $hgUW1$proptypes).arrayOf((0, $hgUW1$proptypes).number),
5298
5682
  setLimit: (0, $hgUW1$proptypes).func.isRequired,
@@ -5518,6 +5902,7 @@ var $af099c546cb226c7$export$2e2bcd8739ae039 = $af099c546cb226c7$var$ResourceHea
5518
5902
 
5519
5903
 
5520
5904
 
5905
+
5521
5906
  function $626282d9a03c51d5$export$1147582dfae658c6(columns, schema) {
5522
5907
  return columns.map((column)=>({
5523
5908
  header: schema && schema.fields[column].description ? schema.fields[column].description : column,
@@ -5535,49 +5920,21 @@ function $626282d9a03c51d5$var$DefaultColumnFilter({ column: { Header: Header, a
5535
5920
  value: filterValue || ""
5536
5921
  });
5537
5922
  }
5538
- const $626282d9a03c51d5$var$ResourcePreview = ({ tablePadding: tablePadding, id: id, options: options, resource: resource, defaultSort: defaultSort, customColumns: customColumns, canResize: canResize })=>{
5923
+ const $626282d9a03c51d5$var$ResourcePreview = ({ tablePadding: tablePadding, id: id, canResize: canResize = true })=>{
5924
+ const { resource: resource, customColumns: customColumns } = (0, $hgUW1$useContext)((0, $a0f13962e513caa1$export$a7997ae78b143b));
5539
5925
  return /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
5540
5926
  id: "resource-preview",
5541
5927
  className: "ds-u-overflow--auto ds-u-border-x--1 ds-u-border-bottom--1",
5542
5928
  children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $d98f94c79ddf4e0e$export$2e2bcd8739ae039), {
5543
- data: resource.values,
5544
5929
  canResize: canResize,
5545
- sortDefaults: defaultSort,
5546
5930
  columns: customColumns ? customColumns : $626282d9a03c51d5$export$1147582dfae658c6(resource.columns, resource.schema[id]),
5547
- setSort: resource.setSort,
5548
5931
  sortTransform: (0, $aa4450dcbeef3ac0$export$385a5aba38cc3325),
5549
5932
  tablePadding: tablePadding,
5550
5933
  className: "dc-c-datatable",
5551
- customColumnFilter: $626282d9a03c51d5$var$DefaultColumnFilter,
5552
- options: options,
5553
- CustomLoadingComponent: /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
5554
- className: "ds-u-display--flex ds-u-padding--3",
5555
- children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Spinner), {
5556
- className: "ds-u-valign--middle",
5557
- role: "status",
5558
- "aria-valuetext": "Datatable loading"
5559
- })
5560
- }),
5561
- CustomNoResults: /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
5562
- className: "ds-u-display--flex ds-u-padding--3",
5563
- children: /*#__PURE__*/ (0, $hgUW1$jsx)("p", {
5564
- children: "No results returned."
5565
- })
5566
- })
5934
+ customColumnFilter: $626282d9a03c51d5$var$DefaultColumnFilter
5567
5935
  })
5568
5936
  });
5569
5937
  };
5570
- $626282d9a03c51d5$var$ResourcePreview.defaultProps = {
5571
- options: {
5572
- layout: "flex",
5573
- columnFilter: false,
5574
- columnSort: true,
5575
- columnResize: true
5576
- },
5577
- truncateCellHeader: true,
5578
- defaultSort: [],
5579
- canResize: true
5580
- };
5581
5938
  var $626282d9a03c51d5$export$2e2bcd8739ae039 = $626282d9a03c51d5$var$ResourcePreview;
5582
5939
 
5583
5940
 
@@ -5811,7 +6168,7 @@ function $3b6ca952e79f0695$var$updateQueryForDatastore(condition) {
5811
6168
  if (Array.isArray(cond.value)) cond.value = cond.value.map((v)=>v.trim().replace(/(^\%+|\%+$)/gm, ""));
5812
6169
  return cond;
5813
6170
  }
5814
- const $3b6ca952e79f0695$var$QueryBuilder = ({ resource: resource, id: id, includeSearchParams: includeSearchParams, customColumns: customColumns })=>{
6171
+ const $3b6ca952e79f0695$var$QueryBuilder = ({ resource: resource, id: id, includeSearchParams: includeSearchParams = true, customColumns: customColumns })=>{
5815
6172
  const { conditions: conditions, schema: schema, setConditions: setConditions } = resource;
5816
6173
  const fields = Object.keys(schema[id].fields);
5817
6174
  const [queryConditions, setQueryConditions] = (0, $hgUW1$useState)([]);
@@ -5932,9 +6289,6 @@ const $3b6ca952e79f0695$var$QueryBuilder = ({ resource: resource, id: id, includ
5932
6289
  })
5933
6290
  });
5934
6291
  };
5935
- $3b6ca952e79f0695$var$QueryBuilder.defaultProps = {
5936
- includeSearchParams: true
5937
- };
5938
6292
  var $3b6ca952e79f0695$export$2e2bcd8739ae039 = $3b6ca952e79f0695$var$QueryBuilder;
5939
6293
 
5940
6294
 
@@ -5961,15 +6315,14 @@ var $de780c924c98fa31$export$2e2bcd8739ae039 = $de780c924c98fa31$var$FilteredRes
5961
6315
 
5962
6316
 
5963
6317
 
6318
+
6319
+
5964
6320
  const $dd6eb2b30d7ad75d$var$FilteredResourceBody = ({ id: id, dataset: dataset, distIndex: distIndex, location: location, additionalParams: additionalParams, customColumns: customColumns, columnSettings: columnSettings, columnWidths: columnWidths, customTitle: customTitle, rootUrl: rootUrl })=>{
5965
- const navigate = (0, $hgUW1$useNavigate)();
5966
6321
  const [tablePadding, setTablePadding] = (0, $hgUW1$react).useState("ds-u-padding-y--1");
5967
6322
  let apiDocs = (0, $hgUW1$useRef)();
5968
- const [filtersOpen, setFiltersOpen] = (0, $hgUW1$react).useState(false);
5969
6323
  let distribution = {};
5970
6324
  let distribution_array = dataset.distribution ? dataset.distribution : [];
5971
6325
  if (distribution_array.length) distribution = distribution_array.find((dist)=>dist.identifier === distribution_array[distIndex].identifier);
5972
- let buttonRef = null;
5973
6326
  const options = location.search ? {
5974
6327
  ...(0, $hgUW1$qs).parse(location.search, {
5975
6328
  ignoreQueryPrefix: true
@@ -5977,7 +6330,6 @@ const $dd6eb2b30d7ad75d$var$FilteredResourceBody = ({ id: id, dataset: dataset,
5977
6330
  } : {
5978
6331
  conditions: []
5979
6332
  };
5980
- let conditions = options.conditions.length ? options.conditions : [];
5981
6333
  const resource = (0, $1d3d480a9cfaabe0$export$2e2bcd8739ae039)("", rootUrl, {
5982
6334
  ...options,
5983
6335
  limit: 25
@@ -6036,7 +6388,7 @@ const $dd6eb2b30d7ad75d$var$FilteredResourceBody = ({ id: id, dataset: dataset,
6036
6388
  dataset: dataset
6037
6389
  })
6038
6390
  }),
6039
- resource.columns && Object.keys(resource.schema).length && /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
6391
+ Object.keys(resource).length && resource.columns && Object.keys(resource.schema).length && /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
6040
6392
  className: "ds-l-md-col--12",
6041
6393
  children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $3b6ca952e79f0695$export$2e2bcd8739ae039), {
6042
6394
  resource: resource,
@@ -6044,36 +6396,49 @@ const $dd6eb2b30d7ad75d$var$FilteredResourceBody = ({ id: id, dataset: dataset,
6044
6396
  customColumns: customColumns
6045
6397
  })
6046
6398
  }),
6047
- resource.columns && Object.keys(resource.schema).length ? /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
6048
- className: "ds-l-md-col--12",
6049
- children: [
6050
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $af099c546cb226c7$export$2e2bcd8739ae039), {
6051
- includeDensity: true,
6052
- setTablePadding: setTablePadding,
6053
- distribution: distribution,
6054
- resource: resource,
6055
- downloadUrl: downloadUrl,
6056
- tablePadding: tablePadding,
6057
- includeDownload: true
6058
- }),
6059
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $626282d9a03c51d5$export$2e2bcd8739ae039), {
6060
- id: distribution.identifier,
6061
- tablePadding: tablePadding,
6062
- resource: resource,
6063
- customColumns: (0, $7264a673914aa746$export$8049e8f40a9bdfb8)(customColumns, resource.columns, resource.schema[distribution_array[distIndex].identifier]),
6064
- columnSettings: columnSettings,
6065
- options: {
6066
- layout: "flex",
6067
- columnFilter: false,
6068
- columnSort: true,
6069
- columnResize: true
6070
- },
6071
- columnWidths: columnWidths
6072
- }),
6073
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $072291d44ce1834a$export$2e2bcd8739ae039), {
6074
- resource: resource
6075
- })
6076
- ]
6399
+ Object.keys(resource).length && resource.columns && Object.keys(resource.schema).length ? /*#__PURE__*/ (0, $hgUW1$jsx)((0, $a0f13962e513caa1$export$a7997ae78b143b).Provider, {
6400
+ value: {
6401
+ id: id,
6402
+ resource: resource,
6403
+ distribution: distribution,
6404
+ rootUrl: rootUrl,
6405
+ customColumns: (0, $7264a673914aa746$export$8049e8f40a9bdfb8)(customColumns, resource.columns, resource.schema[distribution_array[distIndex].identifier])
6406
+ },
6407
+ children: /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
6408
+ className: "ds-l-md-col--12",
6409
+ children: [
6410
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $af099c546cb226c7$export$2e2bcd8739ae039), {
6411
+ includeDensity: true,
6412
+ setTablePadding: setTablePadding,
6413
+ distribution: distribution,
6414
+ resource: resource,
6415
+ downloadUrl: downloadUrl,
6416
+ tablePadding: tablePadding,
6417
+ includeDownload: true
6418
+ }),
6419
+ /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $39bc4d98030a5599$export$a5806b00c0db0089).Provider, {
6420
+ value: {
6421
+ columnOrder: [],
6422
+ setColumnOrder: ()=>{},
6423
+ columnVisibility: {},
6424
+ setColumnVisibility: ()=>{},
6425
+ page: 1,
6426
+ setPage: ()=>{}
6427
+ },
6428
+ children: [
6429
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $626282d9a03c51d5$export$2e2bcd8739ae039), {
6430
+ id: distribution.identifier,
6431
+ tablePadding: tablePadding,
6432
+ columnSettings: columnSettings,
6433
+ columnWidths: columnWidths
6434
+ }),
6435
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $072291d44ce1834a$export$2e2bcd8739ae039), {
6436
+ resource: resource
6437
+ })
6438
+ ]
6439
+ })
6440
+ ]
6441
+ })
6077
6442
  }) : /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Spinner), {
6078
6443
  role: "status",
6079
6444
  "aria-valuetext": "Resource loading"
@@ -6098,9 +6463,6 @@ const $dd6eb2b30d7ad75d$var$FilteredResourceBody = ({ id: id, dataset: dataset,
6098
6463
  })
6099
6464
  });
6100
6465
  };
6101
- $dd6eb2b30d7ad75d$var$FilteredResourceBody.defaultProps = {
6102
- apiDocPage: "/api"
6103
- };
6104
6466
  var $dd6eb2b30d7ad75d$export$2e2bcd8739ae039 = $dd6eb2b30d7ad75d$var$FilteredResourceBody;
6105
6467
 
6106
6468