@civicactions/cmsds-open-data-components 3.1.3-alpha.dd4 → 3.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -9,9 +9,9 @@ import $hgUW1$swaggeruireact from "swagger-ui-react";
9
9
  import "swagger-ui-react/swagger-ui.css";
10
10
  import $hgUW1$axios from "axios";
11
11
  import {useQuery as $hgUW1$useQuery, QueryClient as $hgUW1$QueryClient, QueryClientProvider as $hgUW1$QueryClientProvider} from "@tanstack/react-query";
12
- import $hgUW1$dompurify from "dompurify";
13
- import $hgUW1$reacttexttruncate from "react-text-truncate";
14
12
  import {useMediaQuery as $hgUW1$useMediaQuery} from "react-responsive";
13
+ import $hgUW1$dompurify from "dompurify";
14
+ import $hgUW1$lodashtruncate from "lodash.truncate";
15
15
  import {createColumnHelper as $hgUW1$createColumnHelper, useReactTable as $hgUW1$useReactTable, getCoreRowModel as $hgUW1$getCoreRowModel, getSortedRowModel as $hgUW1$getSortedRowModel, flexRender as $hgUW1$flexRender, getPaginationRowModel as $hgUW1$getPaginationRowModel} from "@tanstack/react-table";
16
16
  import $hgUW1$reactdatepicker from "react-datepicker";
17
17
  import "react-datepicker/dist/react-datepicker.css";
@@ -266,8 +266,6 @@ var $61ff88fb3f6ee2c8$export$2e2bcd8739ae039 = $61ff88fb3f6ee2c8$var$withQueryPr
266
266
 
267
267
 
268
268
 
269
-
270
-
271
269
  const $b61856b23f5f58a2$var$LargeFileDialog = (props)=>{
272
270
  const [modalOpen, setModalOpen] = (0, $hgUW1$useState)(false);
273
271
  const { downloadUrl: downloadUrl } = props;
@@ -519,24 +517,23 @@ var $bd76a91923d7e8a7$export$2e2bcd8739ae039 = $bd76a91923d7e8a7$var$Transformed
519
517
 
520
518
 
521
519
 
522
- function $52c6454cae137465$var$prepDescription(description) {
523
- if (!description) return;
524
- if (description.length > 1 && description.substring(0, 1) === "<") {
525
- const elementTagStart = description.indexOf("<");
526
- const elementTagEnd = description.indexOf(">");
527
- const elementTagInner = description.substring(elementTagStart + 1, elementTagEnd);
528
- const elementTagLength = elementTagInner.length;
529
- const isolatedDescriptionStart = description.indexOf(`<${elementTagInner}>`) + (elementTagLength + 2);
530
- const isolatedDescriptionEnd = description.indexOf(`</${elementTagInner}>`);
531
- const isolatedDescription = description.substring(isolatedDescriptionStart, isolatedDescriptionEnd);
532
- return (0, $hgUW1$dompurify).sanitize(isolatedDescription, {
533
- ALLOWED_TAGS: []
534
- });
535
- }
536
- return (0, $hgUW1$dompurify).sanitize(description, {
520
+
521
+
522
+ function $1a2bf34e2a8f6b80$export$59a943b34a82e690(textString, textLength = 240) {
523
+ if (!textString) return "";
524
+ let cleanedText = textString;
525
+ if (cleanedText.split("</p>").length > 1) cleanedText = cleanedText.split("</p>")[0];
526
+ if (cleanedText.split("<br/>").length > 1) cleanedText = cleanedText.split("<br/>")[0];
527
+ cleanedText = (0, $hgUW1$lodashtruncate)(cleanedText, {
528
+ "length": textLength,
529
+ "separator": " "
530
+ });
531
+ return (0, $hgUW1$dompurify).sanitize(cleanedText, {
537
532
  ALLOWED_TAGS: []
538
533
  });
539
534
  }
535
+
536
+
540
537
  const $52c6454cae137465$var$DatasetSearchListItem = (props)=>{
541
538
  const desktop = (0, $hgUW1$useMediaQuery)({
542
539
  minWidth: 1024
@@ -548,12 +545,6 @@ const $52c6454cae137465$var$DatasetSearchListItem = (props)=>{
548
545
  linkContainerClasses = "ds-l-col--auto";
549
546
  linkClasses = "ds-u-display--block ds-u-text-align--left";
550
547
  }
551
- const truncatedDescription = /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$reacttexttruncate), {
552
- line: 3,
553
- element: "p",
554
- truncateText: "\u2026",
555
- text: $52c6454cae137465$var$prepDescription(description)
556
- });
557
548
  return /*#__PURE__*/ (0, $hgUW1$jsx)("li", {
558
549
  className: "dc-c-search-list-item ds-u-padding-top--3",
559
550
  children: /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
@@ -586,7 +577,7 @@ const $52c6454cae137465$var$DatasetSearchListItem = (props)=>{
586
577
  className: "ds-l-row",
587
578
  children: /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
588
579
  className: "ds-l-col--12 ds-l-md-col--12",
589
- children: truncatedDescription
580
+ children: (0, $1a2bf34e2a8f6b80$export$59a943b34a82e690)(description)
590
581
  })
591
582
  }),
592
583
  /*#__PURE__*/ (0, $hgUW1$jsxs)("ul", {
@@ -971,15 +962,19 @@ const $e873081a6e8f024e$var$DatasetSearch = (props)=>{
971
962
  pageSize,
972
963
  page
973
964
  ]);
965
+ (0, $hgUW1$useEffect)(()=>{
966
+ setPage(1);
967
+ }, [
968
+ fulltext,
969
+ selectedFacets
970
+ ]);
974
971
  (0, $hgUW1$useEffect)(()=>{
975
972
  var params = buildSearchParams(true);
976
973
  if (params !== location.search) setSearchParams(params);
977
974
  }, [
978
975
  page,
979
976
  sort,
980
- sortOrder,
981
- fulltext,
982
- selectedFacets
977
+ sortOrder
983
978
  ]);
984
979
  function resetFilters() {
985
980
  setFullText(defaultFulltext);
@@ -1010,7 +1005,7 @@ const $e873081a6e8f024e$var$DatasetSearch = (props)=>{
1010
1005
  ["page-size"]: pageSize !== 10 ? pageSize : undefined,
1011
1006
  ...additionalParams
1012
1007
  };
1013
- const { data: data, isLoading: isLoading, error: error } = (0, $hgUW1$useQuery)({
1008
+ const { data: data, isPending: isPending, error: error } = (0, $hgUW1$useQuery)({
1014
1009
  queryKey: [
1015
1010
  "datasets",
1016
1011
  params
@@ -1110,7 +1105,7 @@ const $e873081a6e8f024e$var$DatasetSearch = (props)=>{
1110
1105
  }),
1111
1106
  /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
1112
1107
  className: "ds-l-col--12 ds-l-sm-col--8",
1113
- children: isLoading ? /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Spinner), {
1108
+ children: isPending ? /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Spinner), {
1114
1109
  className: "ds-u-valign--middle",
1115
1110
  "aria-valuetext": "Dataset Search loading",
1116
1111
  role: "status"
@@ -1259,6 +1254,7 @@ var $e873081a6e8f024e$export$2e2bcd8739ae039 = (0, $61ff88fb3f6ee2c8$export$2e2b
1259
1254
 
1260
1255
 
1261
1256
 
1257
+
1262
1258
  const $b4aa9c66f2e86959$var$useMetastoreDataset = (datasetId, rootAPIUrl, additionalParams = {})=>{
1263
1259
  const [dataset, setDataset] = (0, $hgUW1$useState)({
1264
1260
  title: "",
@@ -1271,24 +1267,31 @@ const $b4aa9c66f2e86959$var$useMetastoreDataset = (datasetId, rootAPIUrl, additi
1271
1267
  const [id, setId] = (0, $hgUW1$useState)(datasetId);
1272
1268
  const [rootUrl, setRootUrl] = (0, $hgUW1$useState)(rootAPIUrl);
1273
1269
  const additionalParamsString = Object.keys(additionalParams).length ? `&${(0, $hgUW1$qs).stringify(additionalParams)}` : "";
1274
- (0, $hgUW1$useEffect)(()=>{
1275
- async function fetchData() {
1276
- return (0, $hgUW1$axios).get(`${rootUrl}/metastore/schemas/dataset/items/${id}?show-reference-ids${additionalParamsString}`).then((res)=>setDataset(res.data)).catch((error)=>setDataset({
1270
+ const { data: data, isPending: isPending } = (0, $hgUW1$useQuery)({
1271
+ queryKey: [
1272
+ "metastore" + id + additionalParamsString
1273
+ ],
1274
+ queryFn: ()=>{
1275
+ return (0, $hgUW1$axios).get(`${rootUrl}/metastore/schemas/dataset/items/${id}?show-reference-ids${additionalParamsString}`).then((res)=>res.data).catch((error)=>{
1276
+ return {
1277
1277
  title: dataset.title,
1278
1278
  distribution: dataset.distribution,
1279
1279
  error: error,
1280
1280
  description: dataset.description,
1281
1281
  identifier: dataset.identifier,
1282
1282
  modified: dataset.modified
1283
- }));
1283
+ };
1284
+ });
1284
1285
  }
1285
- fetchData();
1286
+ });
1287
+ (0, $hgUW1$useEffect)(()=>{
1288
+ if (!isPending && data && data != dataset) setDataset(data);
1286
1289
  }, [
1287
- id,
1288
- rootUrl
1290
+ data
1289
1291
  ]);
1290
1292
  return {
1291
1293
  dataset: dataset,
1294
+ isPending: isPending,
1292
1295
  setId: setId,
1293
1296
  setRootUrl: setRootUrl
1294
1297
  };
@@ -1301,47 +1304,9 @@ var $b4aa9c66f2e86959$export$2e2bcd8739ae039 = $b4aa9c66f2e86959$var$useMetastor
1301
1304
 
1302
1305
 
1303
1306
 
1304
- async function $0e7628cf73c71646$export$55f990b5477765d6(id, rootUrl, options, additionalParams) {
1305
- const { keys: keys, limit: limit, offset: offset, conditions: conditions, sort: sort, groupings: groupings, prepareColumns: prepareColumns, properties: properties, setValues: setValues, setCount: setCount, setColumns: setColumns, setLoading: setLoading, setSchema: setSchema } = options;
1306
- if (!id) // TODO: Throw error
1307
- return false;
1308
- if (typeof setLoading === "function") setLoading(true);
1309
- return await (0, $hgUW1$axios)({
1310
- method: "GET",
1311
- url: `${rootUrl}/datastore/query/${id}`,
1312
- params: {
1313
- keys: keys,
1314
- limit: limit,
1315
- offset: offset,
1316
- conditions: conditions,
1317
- sorts: sort,
1318
- properties: properties,
1319
- groupings: groupings,
1320
- ...additionalParams
1321
- },
1322
- //paramsSerializer: {
1323
- // serialize: qs.stringify
1324
- //},
1325
- paramsSerializer: (params)=>{
1326
- return (0, $hgUW1$qs).stringify(params);
1327
- }
1328
- }).then((res)=>{
1329
- const { data: data } = res;
1330
- const propertyKeys = data.schema[id] && data.schema[id].fields ? Object.keys(data.schema[id].fields) : [];
1331
- setValues(data.results), setCount(data.count);
1332
- if (propertyKeys.length) setColumns(prepareColumns ? prepareColumns(propertyKeys) : propertyKeys);
1333
- setSchema(data.schema);
1334
- if (typeof setLoading === "function") setLoading(false);
1335
- return data;
1336
- });
1337
- }
1338
-
1339
-
1340
1307
  const $1d3d480a9cfaabe0$var$useDatastore = (resourceId, rootAPIUrl, options, additionalParams = {})=>{
1341
1308
  const keys = options.keys ? options.keys : true;
1342
1309
  const { prepareColumns: prepareColumns } = options;
1343
- const [manual, setManual] = (0, $hgUW1$useState)(options.manual ? options.manual : false);
1344
- const [requireConditions, setRequireConditions] = (0, $hgUW1$useState)(options.requireConditions ? options.requireConditions : false);
1345
1310
  const [values, setValues] = (0, $hgUW1$useState)([]);
1346
1311
  const [id, setResource] = (0, $hgUW1$useState)(resourceId);
1347
1312
  const [rootUrl, setRootUrl] = (0, $hgUW1$useState)(rootAPIUrl);
@@ -1349,63 +1314,43 @@ const $1d3d480a9cfaabe0$var$useDatastore = (resourceId, rootAPIUrl, options, add
1349
1314
  const [count, setCount] = (0, $hgUW1$useState)(null);
1350
1315
  const [columns, setColumns] = (0, $hgUW1$useState)([]);
1351
1316
  const [offset, setOffset] = (0, $hgUW1$useState)(options.offset ? options.offset : 0);
1352
- const [loading, setLoading] = (0, $hgUW1$useState)(false);
1353
1317
  const [conditions, setConditions] = (0, $hgUW1$useState)(options.conditions ? options.conditions : undefined);
1354
1318
  const [sort, setSort] = (0, $hgUW1$useState)(options.sort ? options.sort : undefined);
1355
1319
  const [groupings, setGroupings] = (0, $hgUW1$useState)(options.groupings ? options.groupings : undefined);
1356
1320
  const [schema, setSchema] = (0, $hgUW1$useState)({});
1357
1321
  // const [joins, setJoins] = useState()
1358
1322
  const [properties, setProperties] = (0, $hgUW1$useState)(options.properties ? options.properties : undefined);
1359
- const prevLimitRef = (0, $hgUW1$useRef)();
1360
- const prevOffsetRef = (0, $hgUW1$useRef)();
1361
- (0, $hgUW1$useEffect)(()=>{
1362
- prevLimitRef.current = limit;
1363
- prevOffsetRef.current = offset;
1323
+ let params = {
1324
+ keys: keys,
1325
+ limit: limit,
1326
+ offset: offset,
1327
+ conditions: conditions,
1328
+ sorts: sort,
1329
+ properties: properties,
1330
+ groupings: groupings,
1331
+ ...additionalParams
1332
+ };
1333
+ const additionalParamsString = Object.keys(params).length ? `&${(0, $hgUW1$qs).stringify(params)}` : "";
1334
+ const { data: data, isPending: isPending, error: error } = (0, $hgUW1$useQuery)({
1335
+ queryKey: [
1336
+ "datastore" + id + additionalParamsString
1337
+ ],
1338
+ queryFn: ()=>{
1339
+ return fetch(`${rootUrl}/datastore/query/${id}?${additionalParamsString}`).then((res)=>res.json());
1340
+ }
1364
1341
  });
1365
- const prevLimit = prevLimitRef.current;
1366
- const prevOffset = prevOffsetRef.current;
1367
- function fetchData() {
1368
- let newOffset = prevLimit === limit ? prevOffset !== offset ? offset : 0 : 0;
1369
- setOffset(newOffset);
1370
- (0, $0e7628cf73c71646$export$55f990b5477765d6)(id, rootUrl, {
1371
- keys: keys,
1372
- limit: limit,
1373
- offset: newOffset,
1374
- conditions: conditions,
1375
- sort: sort,
1376
- groupings: groupings,
1377
- prepareColumns: prepareColumns,
1378
- properties: properties,
1379
- setValues: setValues,
1380
- setCount: setCount,
1381
- setColumns: setColumns,
1382
- setLoading: setLoading,
1383
- setSchema: setSchema,
1384
- setProperties: setProperties
1385
- }, additionalParams);
1386
- }
1387
1342
  (0, $hgUW1$useEffect)(()=>{
1388
- if (!loading && !manual) {
1389
- if (!requireConditions) fetchData();
1390
- else if (requireConditions) {
1391
- if (conditions && conditions.length) fetchData();
1392
- else {
1393
- setCount(null);
1394
- setValues([]);
1395
- }
1396
- }
1343
+ if (data) {
1344
+ const propertyKeys = data.schema[id] && data.schema[id].fields ? Object.keys(data.schema[id].fields) : [];
1345
+ setValues(data.results), setCount(data.count);
1346
+ if (propertyKeys.length) setColumns(prepareColumns ? prepareColumns(propertyKeys) : propertyKeys);
1347
+ setSchema(data.schema);
1397
1348
  }
1398
1349
  }, [
1399
- id,
1400
- rootUrl,
1401
- offset,
1402
- conditions,
1403
- sort,
1404
- limit,
1405
- requireConditions
1350
+ data
1406
1351
  ]);
1407
1352
  return {
1408
- loading: loading,
1353
+ loading: isPending,
1409
1354
  values: values,
1410
1355
  count: count,
1411
1356
  columns: columns,
@@ -1421,10 +1366,7 @@ const $1d3d480a9cfaabe0$var$useDatastore = (resourceId, rootAPIUrl, options, add
1421
1366
  setLimit: setLimit,
1422
1367
  setOffset: setOffset,
1423
1368
  setConditions: setConditions,
1424
- setSort: setSort,
1425
- setManual: setManual,
1426
- setRequireConditions: setRequireConditions,
1427
- fetchData: fetchData
1369
+ setSort: setSort
1428
1370
  };
1429
1371
  };
1430
1372
  var $1d3d480a9cfaabe0$export$2e2bcd8739ae039 = $1d3d480a9cfaabe0$var$useDatastore;
@@ -2121,7 +2063,7 @@ const $6380a4a580b24362$var$DataTableHeader = ({ resource: resource, downloadURL
2121
2063
  children: [
2122
2064
  /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2123
2065
  className: "ds-l-col--12 ds-l-lg-col--4",
2124
- children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $2ed0091f7e32d1e6$export$2e2bcd8739ae039), {
2066
+ children: !resource.loading && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $2ed0091f7e32d1e6$export$2e2bcd8739ae039), {
2125
2067
  totalRows: intCount,
2126
2068
  limit: limit,
2127
2069
  offset: offset
@@ -2206,8 +2148,15 @@ var $6380a4a580b24362$export$2e2bcd8739ae039 = $6380a4a580b24362$var$DataTableHe
2206
2148
 
2207
2149
  const $bef7bff2823feea2$var$QueryTitle = ({ conditions: conditions, schema: schema, customColumns: customColumns })=>{
2208
2150
  const { fields: fields } = schema;
2209
- if (!conditions || !conditions.length) return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Fragment), {
2210
- children: "Add a filter"
2151
+ const prependedMessage = /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Fragment), {
2152
+ children: "Data filters: "
2153
+ });
2154
+ if (!conditions || !conditions.length) return /*#__PURE__*/ (0, $hgUW1$jsxs)("p", {
2155
+ className: "ds-u-margin-y--0",
2156
+ children: [
2157
+ prependedMessage,
2158
+ " none"
2159
+ ]
2211
2160
  });
2212
2161
  function formatValue(text, property) {
2213
2162
  if (customColumns && customColumns.length > 0) {
@@ -2219,42 +2168,48 @@ const $bef7bff2823feea2$var$QueryTitle = ({ conditions: conditions, schema: sche
2219
2168
  return text;
2220
2169
  } else return text;
2221
2170
  }
2222
- return /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
2171
+ return /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
2223
2172
  className: "dc-querybuilder-title",
2224
- children: conditions.map((c)=>{
2225
- const field = fields[c.property];
2226
- const description = field && field.description ? field.description : c.property;
2227
- const operator = (0, $7264a673914aa746$export$5f89a5ae87bc48e1).find((op)=>op.value === c.operator);
2228
- const cleanedText = (0, $7264a673914aa746$export$6b5e57d20078142b)(c.value);
2229
- const formattedText = formatValue(cleanedText, c.property);
2230
- return /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
2231
- className: "ds-u-fill--background ds-u-padding--1 ds-u-margin-y--1 ds-u-display--inline-block ds-u-font-weight--semibold",
2232
- children: [
2233
- /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
2234
- className: "ds-u-font-weight--bold",
2235
- children: description
2236
- }),
2237
- " ",
2238
- /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
2239
- className: "ds-u-font-weight--normal",
2240
- children: operator.label.toUpperCase()
2173
+ children: [
2174
+ /*#__PURE__*/ (0, $hgUW1$jsx)("p", {
2175
+ className: "ds-u-margin-y--0",
2176
+ children: prependedMessage
2177
+ }),
2178
+ conditions.map((c)=>{
2179
+ const field = fields[c.property];
2180
+ const description = field && field.description ? field.description : c.property;
2181
+ const operator = (0, $7264a673914aa746$export$5f89a5ae87bc48e1).find((op)=>op.value === c.operator);
2182
+ const cleanedText = (0, $7264a673914aa746$export$6b5e57d20078142b)(c.value);
2183
+ const formattedText = formatValue(cleanedText, c.property);
2184
+ return /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
2185
+ className: "ds-u-fill--background ds-u-padding--1 ds-u-margin-y--1 ds-u-display--inline-block ds-u-font-weight--semibold",
2186
+ children: [
2187
+ /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
2188
+ className: "ds-u-font-weight--bold",
2189
+ children: description
2190
+ }),
2191
+ " ",
2192
+ /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
2193
+ className: "ds-u-font-weight--normal",
2194
+ children: operator.label.toUpperCase()
2195
+ }),
2196
+ " ",
2197
+ /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
2198
+ className: "ds-u-color--success",
2199
+ children: formattedText
2200
+ })
2201
+ ]
2202
+ });
2203
+ }).reduce((prev, curr)=>[
2204
+ prev,
2205
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Badge), {
2206
+ className: "ds-u-margin-x--1",
2207
+ variation: "info",
2208
+ children: "AND"
2241
2209
  }),
2242
- " ",
2243
- /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
2244
- className: "ds-u-color--success",
2245
- children: formattedText
2246
- })
2247
- ]
2248
- });
2249
- }).reduce((prev, curr)=>[
2250
- prev,
2251
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Badge), {
2252
- className: "ds-u-margin-x--1",
2253
- variation: "info",
2254
- children: "AND"
2255
- }),
2256
- curr
2257
- ])
2210
+ curr
2211
+ ])
2212
+ ]
2258
2213
  });
2259
2214
  };
2260
2215
  var $bef7bff2823feea2$export$2e2bcd8739ae039 = $bef7bff2823feea2$var$QueryTitle;
@@ -2617,7 +2572,7 @@ const $a35cf16d1488f54e$var$DatasetTable = ({ id: id, distribution: distribution
2617
2572
  loading: resource.loading
2618
2573
  })
2619
2574
  }),
2620
- /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
2575
+ !resource.loading && /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
2621
2576
  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",
2622
2577
  children: [
2623
2578
  /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Pagination), {
@@ -2653,7 +2608,11 @@ const $a35cf16d1488f54e$var$DatasetTable = ({ id: id, distribution: distribution
2653
2608
  })
2654
2609
  ]
2655
2610
  });
2656
- else return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Fragment), {});
2611
+ else return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Spinner), {
2612
+ "aria-valuetext": "Dataset loading",
2613
+ role: "status",
2614
+ className: "ds-u-margin--3"
2615
+ });
2657
2616
  };
2658
2617
  var $a35cf16d1488f54e$export$2e2bcd8739ae039 = $a35cf16d1488f54e$var$DatasetTable;
2659
2618
 
@@ -2725,6 +2684,7 @@ var $5644ebd2c3dbfd7b$export$2e2bcd8739ae039 = $5644ebd2c3dbfd7b$var$DatasetAddi
2725
2684
 
2726
2685
 
2727
2686
 
2687
+
2728
2688
  const $0958733ee130fc44$var$ResourceInformation = ({ resource: resource })=>{
2729
2689
  const { count: count, columns: columns } = resource;
2730
2690
  return /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
@@ -2773,22 +2733,26 @@ const $0958733ee130fc44$var$ResourceInformation = ({ resource: resource })=>{
2773
2733
  var $0958733ee130fc44$export$2e2bcd8739ae039 = $0958733ee130fc44$var$ResourceInformation;
2774
2734
 
2775
2735
 
2776
-
2777
- const $7357cc0f79f9c514$var$Resource = ({ distributions: distributions, resource: resource, title: title })=>{
2778
- function getFormatType(dist) {
2736
+ function $f764661366bd9e1b$export$ee48b7e0e4eb536e(dist) {
2737
+ if (dist && dist.data) {
2779
2738
  if (dist.data.format) return dist.data.format.toLowerCase();
2780
2739
  if (dist.data.mediaType) {
2781
2740
  const mediaType = dist.data.mediaType.split("/");
2782
2741
  if (mediaType.length && mediaType[1]) return mediaType[1].toLowerCase();
2783
2742
  }
2784
- if (dist.data["%Ref:downloadURL"] && dist.data["%Ref:downloadURL"].length && dist.data["%Ref:downloadURL"][0].data) {
2743
+ if (dist.data["%Ref:downloadURL"].length && dist.data["%Ref:downloadURL"][0].data) {
2785
2744
  if (dist.data["%Ref:downloadURL"][0].data.mimeType) {
2786
2745
  const mimeType = dist.data["%Ref:downloadURL"][0].data.mimeType.split("/");
2787
2746
  if (mimeType.length && mimeType[1]) return mimeType[1].toLowerCase();
2788
2747
  }
2789
2748
  }
2790
- return "";
2791
2749
  }
2750
+ return "";
2751
+ }
2752
+
2753
+
2754
+
2755
+ const $7357cc0f79f9c514$var$Resource = ({ distributions: distributions, resource: resource, title: title })=>{
2792
2756
  const sm = (0, $hgUW1$useMediaQuery)({
2793
2757
  minWidth: 0,
2794
2758
  maxWidth: 767
@@ -2800,20 +2764,26 @@ const $7357cc0f79f9c514$var$Resource = ({ distributions: distributions, resource
2800
2764
  className: "ds-l-col--12 ds-u-padding-left--0 ds-text-heading--2xl",
2801
2765
  children: "Resources"
2802
2766
  }),
2803
- distributions.length && /*#__PURE__*/ (0, $hgUW1$jsx)("ul", {
2767
+ distributions.length ? /*#__PURE__*/ (0, $hgUW1$jsx)("ul", {
2804
2768
  className: "ds-c-list ds-c-list--bare dc-c-resource-full-width",
2805
2769
  children: distributions.map((dist)=>{
2806
- const fileFormat = getFormatType(dist);
2770
+ const fileFormat = (0, $f764661366bd9e1b$export$ee48b7e0e4eb536e)(dist);
2807
2771
  return /*#__PURE__*/ (0, $hgUW1$jsxs)("li", {
2808
2772
  className: `ds-u-display--flex ds-u-flex-wrap--wrap ${fileFormat !== "csv" && "ds-u-margin-bottom--2"}`,
2809
2773
  children: [
2810
2774
  /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
2811
- 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",
2775
+ 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",
2812
2776
  children: [
2813
2777
  /*#__PURE__*/ (0, $hgUW1$jsx)("i", {
2814
- className: "fa ds-u-color--primary ds-u-padding-right--1 fa-file-" + (fileFormat == "xlsx" ? "excel" : fileFormat)
2778
+ className: "fa ds-u-color--primary ds-u-padding-right--1 ds-u-font-size--3xl fa-file-" + (fileFormat == "xlsx" ? "excel" : fileFormat)
2815
2779
  }),
2816
- dist.data.title ? dist.data.title : title + " (" + fileFormat.toUpperCase() + ")"
2780
+ /*#__PURE__*/ (0, $hgUW1$jsxs)("p", {
2781
+ className: "ds-u-margin-top--0",
2782
+ children: [
2783
+ dist.data.title ? dist.data.title : title,
2784
+ " (" + fileFormat.toUpperCase() + ")"
2785
+ ]
2786
+ })
2817
2787
  ]
2818
2788
  }),
2819
2789
  /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
@@ -2834,8 +2804,14 @@ const $7357cc0f79f9c514$var$Resource = ({ distributions: distributions, resource
2834
2804
  ]
2835
2805
  })
2836
2806
  }),
2837
- dist.data.description && /*#__PURE__*/ (0, $hgUW1$jsx)("p", {
2838
- children: dist.data.description
2807
+ dist.data.description && /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2808
+ className: "ds-u-measure--wide ds-u-margin-bottom--7",
2809
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)("p", {
2810
+ className: "dc-c-metadata-description ds-u-margin--0",
2811
+ dangerouslySetInnerHTML: {
2812
+ __html: (0, $hgUW1$dompurify).sanitize(dist.data.description)
2813
+ }
2814
+ })
2839
2815
  }),
2840
2816
  fileFormat === "csv" && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $0958733ee130fc44$export$2e2bcd8739ae039), {
2841
2817
  resource: resource
@@ -2843,6 +2819,9 @@ const $7357cc0f79f9c514$var$Resource = ({ distributions: distributions, resource
2843
2819
  ]
2844
2820
  }, dist.identifier);
2845
2821
  })
2822
+ }) : /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
2823
+ className: "ds-u-margin-bottom--2",
2824
+ children: "No resources have been added to this dataset."
2846
2825
  })
2847
2826
  ]
2848
2827
  });
@@ -3205,6 +3184,7 @@ var $6012b86ffcaf3f71$export$2e2bcd8739ae039 = (0, $61ff88fb3f6ee2c8$export$2e2b
3205
3184
 
3206
3185
 
3207
3186
 
3187
+
3208
3188
  const $a0f13962e513caa1$var$getDataDictionary = (dataDictionaryUrl, additionalParams)=>{
3209
3189
  const { data: data, isPending: isPending, error: error } = (0, $hgUW1$useQuery)({
3210
3190
  queryKey: [
@@ -3230,7 +3210,7 @@ const $a0f13962e513caa1$var$Dataset = ({ id: id, rootUrl: rootUrl, additionalPar
3230
3210
  } : {
3231
3211
  conditions: []
3232
3212
  };
3233
- const { dataset: dataset } = (0, $b4aa9c66f2e86959$export$2e2bcd8739ae039)(id, rootUrl, additionalParams);
3213
+ const { dataset: dataset, isPending: isPending } = (0, $b4aa9c66f2e86959$export$2e2bcd8739ae039)(id, rootUrl, additionalParams);
3234
3214
  const title = dataset.title ? dataset.title : "";
3235
3215
  const metadataMapping = {
3236
3216
  ...(0, $6da0396069e23175$export$bc27cf7ecf44639d),
@@ -3251,18 +3231,8 @@ const $a0f13962e513caa1$var$Dataset = ({ id: id, rootUrl: rootUrl, additionalPar
3251
3231
  return Object.keys(resource.schema[distribution.identifier].fields).indexOf(field.name) !== -1;
3252
3232
  }) : null;
3253
3233
  (0, $hgUW1$useEffect)(()=>{
3254
- if (distribution.identifier) {
3255
- let localFileFormat = "";
3256
- if (distribution.data.format) localFileFormat = distribution.data.format.toUpperCase();
3257
- else if (distribution.data.mediaType) {
3258
- const mediaType = distribution.data.mediaType.split("/");
3259
- if (mediaType.length && mediaType[1]) localFileFormat = mediaType[1].toUpperCase();
3260
- }
3261
- if (localFileFormat === "CSV") {
3262
- resource.setResource(distribution.identifier);
3263
- resource.setManual(false);
3264
- }
3265
- }
3234
+ const localFileFormat = (0, $f764661366bd9e1b$export$ee48b7e0e4eb536e)(distribution);
3235
+ if (localFileFormat === "csv") resource.setResource(distribution.identifier);
3266
3236
  }, [
3267
3237
  distribution
3268
3238
  ]);
@@ -3304,6 +3274,17 @@ const $a0f13962e513caa1$var$Dataset = ({ id: id, rootUrl: rootUrl, additionalPar
3304
3274
  })
3305
3275
  ]
3306
3276
  });
3277
+ // The below code manages the selected tab in the Design System tab group manually to ensure we can still use the
3278
+ // Data Table tab as the default since it no longer exists on initial render (By default, Overview will appear as default)
3279
+ const getDefaultTab = ()=>{
3280
+ return (0, $f764661366bd9e1b$export$ee48b7e0e4eb536e)(distribution) === "csv" ? "data-table" : "overview";
3281
+ };
3282
+ const [selectedTab, setSelectedTab] = (0, $hgUW1$useState)(window.location.hash.substring(1) ? window.location.hash.substring(1) : getDefaultTab());
3283
+ (0, $hgUW1$useEffect)(()=>{
3284
+ setSelectedTab(getDefaultTab());
3285
+ }, [
3286
+ distribution
3287
+ ]);
3307
3288
  return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Fragment), {
3308
3289
  children: dataset.error ? /*#__PURE__*/ (0, $hgUW1$jsx)((0, $026cb986f9fea2b1$export$2e2bcd8739ae039), {
3309
3290
  content: notFoundContent,
@@ -3317,7 +3298,7 @@ const $a0f13962e513caa1$var$Dataset = ({ id: id, rootUrl: rootUrl, additionalPar
3317
3298
  /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3318
3299
  className: "ds-l-md-col--9",
3319
3300
  children: /*#__PURE__*/ (0, $hgUW1$jsx)("h1", {
3320
- className: "ds-h1 title-underline",
3301
+ className: "ds-text-heading--3xl",
3321
3302
  children: title
3322
3303
  })
3323
3304
  }),
@@ -3351,11 +3332,13 @@ const $a0f13962e513caa1$var$Dataset = ({ id: id, rootUrl: rootUrl, additionalPar
3351
3332
  className: "ds-l-row",
3352
3333
  children: /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3353
3334
  className: "ds-l-md-col--12 dc-dataset",
3354
- children: distribution && distribution.data && /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Tabs), {
3355
- onChange: function noRefCheck() {},
3356
- defaultSelectedId: window.location.hash.substring(1),
3335
+ children: !isPending && /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Tabs), {
3336
+ onChange: (selectedId, prevSelectedId)=>{
3337
+ setSelectedTab(selectedId);
3338
+ },
3339
+ selectedId: selectedTab,
3357
3340
  children: [
3358
- distribution.data.format === "csv" && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TabPanel), {
3341
+ (0, $f764661366bd9e1b$export$ee48b7e0e4eb536e)(distribution) === "csv" && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TabPanel), {
3359
3342
  id: "data-table",
3360
3343
  tab: /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
3361
3344
  className: "ds-u-color--primary",
@@ -3413,7 +3396,7 @@ const $a0f13962e513caa1$var$Dataset = ({ id: id, rootUrl: rootUrl, additionalPar
3413
3396
  additionalParams: additionalParams
3414
3397
  })
3415
3398
  }) : null,
3416
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TabPanel), {
3399
+ distribution && distribution.data && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TabPanel), {
3417
3400
  id: "api",
3418
3401
  tab: /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
3419
3402
  className: "ds-u-color--primary",
@@ -5567,10 +5550,7 @@ const $dd6eb2b30d7ad75d$var$FilteredResourceBody = ({ id: id, dataset: dataset,
5567
5550
  manual: true
5568
5551
  }, additionalParams);
5569
5552
  (0, $hgUW1$useEffect)(()=>{
5570
- if (distribution.identifier) {
5571
- resource.setResource(distribution.identifier);
5572
- resource.setManual(false);
5573
- }
5553
+ if (distribution.identifier) resource.setResource(distribution.identifier);
5574
5554
  }, [
5575
5555
  distribution
5576
5556
  ]);
@@ -5592,14 +5572,17 @@ const $dd6eb2b30d7ad75d$var$FilteredResourceBody = ({ id: id, dataset: dataset,
5592
5572
  dataset.title
5593
5573
  ]
5594
5574
  }),
5595
- /*#__PURE__*/ (0, $hgUW1$jsx)("h1", {
5596
- className: "ds-title",
5597
- children: customTitle ? customTitle : pageTitle
5575
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
5576
+ className: "ds-l-md-col--9",
5577
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)("h1", {
5578
+ className: "ds-text-heading--3xl",
5579
+ children: customTitle ? customTitle : pageTitle
5580
+ })
5598
5581
  }),
5599
5582
  /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
5600
- className: "ds-l-row",
5601
- children: /*#__PURE__*/ (0, $hgUW1$jsxs)("span", {
5602
- className: "ds-l-col--12 ds-u-color--gray ds-u-margin-y--1 ds-u-text-align--right",
5583
+ className: "ds-l-md-col--12 ds-u-color--gray ds-u-margin-y--1 ds-u-text-align--right",
5584
+ children: /*#__PURE__*/ (0, $hgUW1$jsxs)("p", {
5585
+ className: "ds-u-margin--0",
5603
5586
  children: [
5604
5587
  "Updated ",
5605
5588
  /*#__PURE__*/ (0, $hgUW1$jsx)((0, $bd76a91923d7e8a7$export$2e2bcd8739ae039), {
@@ -5608,11 +5591,17 @@ const $dd6eb2b30d7ad75d$var$FilteredResourceBody = ({ id: id, dataset: dataset,
5608
5591
  ]
5609
5592
  })
5610
5593
  }),
5611
- /*#__PURE__*/ (0, $hgUW1$jsx)("p", {
5612
- className: "ds-u-margin-top--0 dc-c-metadata-description",
5613
- dangerouslySetInnerHTML: {
5614
- __html: (0, $hgUW1$dompurify).sanitize(distribution.data.description)
5615
- }
5594
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
5595
+ className: "ds-l-md-col--9",
5596
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
5597
+ className: "ds-u-measure--wide ds-u-margin-bottom--7",
5598
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)("p", {
5599
+ className: "ds-u-margin-top--0 dc-c-metadata-description",
5600
+ dangerouslySetInnerHTML: {
5601
+ __html: (0, $hgUW1$dompurify).sanitize(distribution.data.description)
5602
+ }
5603
+ })
5604
+ })
5616
5605
  }),
5617
5606
  resource.columns && Object.keys(resource.schema).length && /*#__PURE__*/ (0, $hgUW1$jsx)((0, $3b6ca952e79f0695$export$2e2bcd8739ae039), {
5618
5607
  resource: resource,
@@ -5791,5 +5780,7 @@ var $90fb213ab8eeb2e7$export$2e2bcd8739ae039 = $90fb213ab8eeb2e7$var$useScrollTo
5791
5780
 
5792
5781
 
5793
5782
 
5794
- export {$f57121650539d8c5$export$2e2bcd8739ae039 as NavBar, $c96c4b9ef7203c1f$export$2e2bcd8739ae039 as APIPage, $026cb986f9fea2b1$export$2e2bcd8739ae039 as PageNotFound, $e873081a6e8f024e$export$2e2bcd8739ae039 as DatasetSearch, $a0f13962e513caa1$export$2e2bcd8739ae039 as Dataset, $a35cf16d1488f54e$export$2e2bcd8739ae039 as DatasetTable, $a5a6a06d249c33b8$export$2e2bcd8739ae039 as Header, $a6df0aa147323304$export$2e2bcd8739ae039 as Footer, $669d2782ec2e2250$export$2e2bcd8739ae039 as SpecsAndLimits, $efc410f5f7ac5ef3$export$2e2bcd8739ae039 as useSearchAPI, $1d3d480a9cfaabe0$export$2e2bcd8739ae039 as useDatastore, $aa4450dcbeef3ac0$export$385a5aba38cc3325 as transformTableSortToQuerySort, $59a079354baa335c$export$2e2bcd8739ae039 as Hero, $52c6454cae137465$export$2e2bcd8739ae039 as DatasetSearchListItem, $789279954d8eff7f$export$2e2bcd8739ae039 as ApiDocumentation, $af099c546cb226c7$export$2e2bcd8739ae039 as ResourceHeader, $626282d9a03c51d5$export$2e2bcd8739ae039 as ResourcePreview, $072291d44ce1834a$export$2e2bcd8739ae039 as ResourceFooter, $ec3e23baa005dc03$export$2e2bcd8739ae039 as Breadcrumb, $bd76a91923d7e8a7$export$2e2bcd8739ae039 as TransformedDate, $d98f94c79ddf4e0e$export$2e2bcd8739ae039 as DataTable, $5644ebd2c3dbfd7b$export$eea3a12df15499ca as buildRows, $f61ecf9f84951a61$export$2e2bcd8739ae039 as FilteredResource, $bef7bff2823feea2$export$2e2bcd8739ae039 as QueryTitle, $7264a673914aa746$export$2b9377795161999 as buildOperatorOptions, $7264a673914aa746$export$e284ae5d89467c8f as convertUTCToLocalDate, $7264a673914aa746$export$6b5e57d20078142b as cleanText, $7264a673914aa746$export$8049e8f40a9bdfb8 as buildCustomColHeaders, $eb7821d186b1a389$export$2e2bcd8739ae039 as useAddLoginLink, $90fb213ab8eeb2e7$export$2e2bcd8739ae039 as useScrollToTop, $b4aa9c66f2e86959$export$2e2bcd8739ae039 as useMetastoreDataset, $6da0396069e23175$export$bc27cf7ecf44639d as defaultMetadataMapping, $2ed0091f7e32d1e6$export$2e2bcd8739ae039 as DataTablePageResults};
5783
+
5784
+
5785
+ export {$f57121650539d8c5$export$2e2bcd8739ae039 as NavBar, $c96c4b9ef7203c1f$export$2e2bcd8739ae039 as APIPage, $026cb986f9fea2b1$export$2e2bcd8739ae039 as PageNotFound, $e873081a6e8f024e$export$2e2bcd8739ae039 as DatasetSearch, $a0f13962e513caa1$export$2e2bcd8739ae039 as Dataset, $a35cf16d1488f54e$export$2e2bcd8739ae039 as DatasetTable, $a5a6a06d249c33b8$export$2e2bcd8739ae039 as Header, $a6df0aa147323304$export$2e2bcd8739ae039 as Footer, $669d2782ec2e2250$export$2e2bcd8739ae039 as SpecsAndLimits, $efc410f5f7ac5ef3$export$2e2bcd8739ae039 as useSearchAPI, $1d3d480a9cfaabe0$export$2e2bcd8739ae039 as useDatastore, $aa4450dcbeef3ac0$export$385a5aba38cc3325 as transformTableSortToQuerySort, $59a079354baa335c$export$2e2bcd8739ae039 as Hero, $52c6454cae137465$export$2e2bcd8739ae039 as DatasetSearchListItem, $789279954d8eff7f$export$2e2bcd8739ae039 as ApiDocumentation, $af099c546cb226c7$export$2e2bcd8739ae039 as ResourceHeader, $626282d9a03c51d5$export$2e2bcd8739ae039 as ResourcePreview, $072291d44ce1834a$export$2e2bcd8739ae039 as ResourceFooter, $ec3e23baa005dc03$export$2e2bcd8739ae039 as Breadcrumb, $bd76a91923d7e8a7$export$2e2bcd8739ae039 as TransformedDate, $d98f94c79ddf4e0e$export$2e2bcd8739ae039 as DataTable, $5644ebd2c3dbfd7b$export$eea3a12df15499ca as buildRows, $f61ecf9f84951a61$export$2e2bcd8739ae039 as FilteredResource, $bef7bff2823feea2$export$2e2bcd8739ae039 as QueryTitle, $7264a673914aa746$export$2b9377795161999 as buildOperatorOptions, $7264a673914aa746$export$e284ae5d89467c8f as convertUTCToLocalDate, $7264a673914aa746$export$6b5e57d20078142b as cleanText, $7264a673914aa746$export$8049e8f40a9bdfb8 as buildCustomColHeaders, $eb7821d186b1a389$export$2e2bcd8739ae039 as useAddLoginLink, $90fb213ab8eeb2e7$export$2e2bcd8739ae039 as useScrollToTop, $b4aa9c66f2e86959$export$2e2bcd8739ae039 as useMetastoreDataset, $61ff88fb3f6ee2c8$export$2e2bcd8739ae039 as withQueryProvider, $6da0396069e23175$export$bc27cf7ecf44639d as defaultMetadataMapping, $2ed0091f7e32d1e6$export$2e2bcd8739ae039 as DataTablePageResults, $1a2bf34e2a8f6b80$export$59a943b34a82e690 as truncateText};
5795
5786
  //# sourceMappingURL=main.js.map