@civicactions/cmsds-open-data-components 4.0.19 → 4.0.20-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +59 -34
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1452,12 +1452,23 @@ const $e873081a6e8f024e$var$DatasetSearch = (props)=>{
|
|
|
1452
1452
|
defaultOrder: 'desc'
|
|
1453
1453
|
}, pageTitle: pageTitle = 'Dataset Explorer', categoriesTitle: categoriesTitle = 'Categories', filterTitle: filterTitle = 'Tags', showLargeFileWarning: showLargeFileWarning = false, largeFileThemes: largeFileThemes, introText: introText = '', showDownloadIcon: showDownloadIcon = false, altMobileSearchButton: altMobileSearchButton, dataDictionaryLinks: dataDictionaryLinks = false, showDateDetails: showDateDetails = false, showTopics: showTopics = false, topicSlugFunction: topicSlugFunction, children: children } = props;
|
|
1454
1454
|
const { ACA: ACA } = (0, $hgUW1$useContext)((0, $844981eac9b63865$export$eccc29c8d0ff408));
|
|
1455
|
-
const [searchParams
|
|
1455
|
+
const [searchParams] = (0, $hgUW1$useSearchParams)();
|
|
1456
|
+
const navigate = (0, $hgUW1$useNavigate)();
|
|
1456
1457
|
// Derive all search state from URL params
|
|
1457
|
-
const selectedFacets = (0, $hgUW1$useMemo)(()=>
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1458
|
+
const selectedFacets = (0, $hgUW1$useMemo)(()=>{
|
|
1459
|
+
const parsed = (0, $hgUW1$qs).parse(searchParams.toString());
|
|
1460
|
+
const toArray = (val)=>{
|
|
1461
|
+
if (Array.isArray(val)) return val.filter((v)=>typeof v === 'string');
|
|
1462
|
+
if (typeof val === 'string') return [
|
|
1463
|
+
val
|
|
1464
|
+
];
|
|
1465
|
+
return [];
|
|
1466
|
+
};
|
|
1467
|
+
return {
|
|
1468
|
+
theme: toArray(parsed.theme),
|
|
1469
|
+
keyword: toArray(parsed.keyword)
|
|
1470
|
+
};
|
|
1471
|
+
}, [
|
|
1461
1472
|
searchParams
|
|
1462
1473
|
]);
|
|
1463
1474
|
const page = Number(searchParams.get('page')) || 1;
|
|
@@ -1474,29 +1485,33 @@ const $e873081a6e8f024e$var$DatasetSearch = (props)=>{
|
|
|
1474
1485
|
}, [
|
|
1475
1486
|
fulltext
|
|
1476
1487
|
]);
|
|
1477
|
-
function
|
|
1478
|
-
const
|
|
1488
|
+
function buildNextQueryString(overrides) {
|
|
1489
|
+
const current = (0, $hgUW1$qs).parse(searchParams.toString());
|
|
1490
|
+
const merged = {
|
|
1491
|
+
...current
|
|
1492
|
+
};
|
|
1479
1493
|
Object.entries(overrides).forEach(([key, value])=>{
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1494
|
+
if (value === null) delete merged[key];
|
|
1495
|
+
else merged[key] = value;
|
|
1496
|
+
});
|
|
1497
|
+
return (0, $hgUW1$qs).stringify(merged, {
|
|
1498
|
+
arrayFormat: 'indices',
|
|
1499
|
+
encodeValuesOnly: true
|
|
1486
1500
|
});
|
|
1487
|
-
return next;
|
|
1488
1501
|
}
|
|
1489
1502
|
function updateSelectedFacets(key, value) {
|
|
1490
|
-
const current =
|
|
1503
|
+
const current = selectedFacets[key] || [];
|
|
1491
1504
|
const idx = current.indexOf(value);
|
|
1492
1505
|
const updated = idx > -1 ? current.filter((_, i)=>i !== idx) : [
|
|
1493
1506
|
...current,
|
|
1494
1507
|
value
|
|
1495
1508
|
];
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1509
|
+
navigate({
|
|
1510
|
+
search: buildNextQueryString({
|
|
1511
|
+
[key]: updated.length ? updated : null,
|
|
1512
|
+
page: null
|
|
1513
|
+
})
|
|
1514
|
+
});
|
|
1500
1515
|
}
|
|
1501
1516
|
const setSortOptionsHandler = (value)=>{
|
|
1502
1517
|
let nextSort;
|
|
@@ -1525,11 +1540,15 @@ const $e873081a6e8f024e$var$DatasetSearch = (props)=>{
|
|
|
1525
1540
|
sort: nextSort === defaultSort.defaultSort ? null : nextSort,
|
|
1526
1541
|
sortOrder: nextSortOrder === defaultSort.defaultOrder ? null : nextSortOrder
|
|
1527
1542
|
};
|
|
1528
|
-
|
|
1543
|
+
navigate({
|
|
1544
|
+
search: buildNextQueryString(overrides)
|
|
1545
|
+
});
|
|
1529
1546
|
};
|
|
1530
1547
|
function resetFilters() {
|
|
1531
1548
|
setFilterText('');
|
|
1532
|
-
|
|
1549
|
+
navigate({
|
|
1550
|
+
search: ''
|
|
1551
|
+
});
|
|
1533
1552
|
}
|
|
1534
1553
|
const pageSize = defaultPageSize;
|
|
1535
1554
|
const params = {
|
|
@@ -1626,17 +1645,21 @@ const $e873081a6e8f024e$var$DatasetSearch = (props)=>{
|
|
|
1626
1645
|
if (filterText) {
|
|
1627
1646
|
if ($e873081a6e8f024e$export$1040147c129fdde9(filterText)) {
|
|
1628
1647
|
setInvalidSearch(false);
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1648
|
+
navigate({
|
|
1649
|
+
search: buildNextQueryString({
|
|
1650
|
+
fulltext: filterText,
|
|
1651
|
+
page: null
|
|
1652
|
+
})
|
|
1653
|
+
});
|
|
1633
1654
|
} else setInvalidSearch(true);
|
|
1634
1655
|
} else {
|
|
1635
1656
|
setInvalidSearch(false);
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1657
|
+
navigate({
|
|
1658
|
+
search: buildNextQueryString({
|
|
1659
|
+
fulltext: null,
|
|
1660
|
+
page: null
|
|
1661
|
+
})
|
|
1662
|
+
});
|
|
1640
1663
|
}
|
|
1641
1664
|
},
|
|
1642
1665
|
className: "dkan-dataset-search ds-l-form-row ds-u-padding-bottom--4 ds-u-border-bottom--1",
|
|
@@ -1795,15 +1818,17 @@ const $e873081a6e8f024e$var$DatasetSearch = (props)=>{
|
|
|
1795
1818
|
onPageChange: (evt, page)=>{
|
|
1796
1819
|
evt.preventDefault();
|
|
1797
1820
|
window.scroll(0, 0);
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1821
|
+
navigate({
|
|
1822
|
+
search: buildNextQueryString({
|
|
1823
|
+
page: page > 1 ? String(page) : null
|
|
1824
|
+
})
|
|
1825
|
+
});
|
|
1801
1826
|
},
|
|
1802
1827
|
renderHref: (p)=>{
|
|
1803
|
-
const
|
|
1828
|
+
const nextQs = buildNextQueryString({
|
|
1804
1829
|
page: p > 1 ? String(p) : null
|
|
1805
1830
|
});
|
|
1806
|
-
return `/datasets?${
|
|
1831
|
+
return `/datasets?${nextQs}`;
|
|
1807
1832
|
}
|
|
1808
1833
|
})
|
|
1809
1834
|
]
|