@digitransit-component/digitransit-component-autosuggest 8.0.9 → 9.0.1
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/README.md +1 -0
- package/lib/index.cjs +2 -2
- package/lib/index.cjs.map +1 -1
- package/lib/index.development.cjs +20 -11
- package/lib/index.js +19 -10
- package/lib/index.js.map +1 -1
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -5533,6 +5533,15 @@ function hasFavourites(searchContext) {
|
|
|
5533
5533
|
if (favouriteLocations?.length > 0) {
|
|
5534
5534
|
return true;
|
|
5535
5535
|
}
|
|
5536
|
+
|
|
5537
|
+
// Prefer the backend-validated signal when available: a stop/station/
|
|
5538
|
+
// bikeStation favourite may look locally available (e.g. a citybike
|
|
5539
|
+
// network whose season config is stale) while no longer being served by
|
|
5540
|
+
// OTP at all, which would otherwise offer a "favourites" suggestion that
|
|
5541
|
+
// opens to an empty list.
|
|
5542
|
+
if (typeof searchContext.getHasOtpLocationFavourites === 'function') {
|
|
5543
|
+
return !!searchContext.getHasOtpLocationFavourites(searchContext.context);
|
|
5544
|
+
}
|
|
5536
5545
|
const favouriteVehicleRentalStations = searchContext.getFavouriteVehicleRentalStations(searchContext.context);
|
|
5537
5546
|
if (favouriteVehicleRentalStations?.length > 0) {
|
|
5538
5547
|
return true;
|
|
@@ -5626,7 +5635,7 @@ function getSearchResults(targets, sources, transportMode, searchContext, filter
|
|
|
5626
5635
|
searchComponents.push(getGeocodingResults(input, searchParams, language, focusPoint, geocodingSources.join(','), URL_PELIAS, minimalRegexp, geocodingLayers));
|
|
5627
5636
|
}
|
|
5628
5637
|
if (allSources || sources.includes('History')) {
|
|
5629
|
-
const locationHistory = getOldSearches(
|
|
5638
|
+
const locationHistory = getOldSearches('endpoint');
|
|
5630
5639
|
const dropLayers = ['bikestation'];
|
|
5631
5640
|
dropLayers.push(...stopLayers);
|
|
5632
5641
|
dropLayers.push(...routeLayers);
|
|
@@ -5650,7 +5659,7 @@ function getSearchResults(targets, sources, transportMode, searchContext, filter
|
|
|
5650
5659
|
}));
|
|
5651
5660
|
}
|
|
5652
5661
|
if (allSources || sources.includes('History')) {
|
|
5653
|
-
const history = getOldSearches(
|
|
5662
|
+
const history = getOldSearches();
|
|
5654
5663
|
const dropLayers = ['bikestation'];
|
|
5655
5664
|
dropLayers.push(...stopLayers);
|
|
5656
5665
|
dropLayers.push(...routeLayers);
|
|
@@ -5709,7 +5718,7 @@ function getSearchResults(targets, sources, transportMode, searchContext, filter
|
|
|
5709
5718
|
}));
|
|
5710
5719
|
}
|
|
5711
5720
|
if (allSources || sources.includes('History')) {
|
|
5712
|
-
const stopHistory = getOldSearches(
|
|
5721
|
+
const stopHistory = getOldSearches().filter(item => {
|
|
5713
5722
|
if (item.properties.gid) {
|
|
5714
5723
|
return item.properties.gid.includes('GTFS:');
|
|
5715
5724
|
}
|
|
@@ -5739,7 +5748,7 @@ function getSearchResults(targets, sources, transportMode, searchContext, filter
|
|
|
5739
5748
|
}
|
|
5740
5749
|
searchComponents.push(getRoutesQuery(input, feedIDs, transportMode, pathOpts).then(result => filterResults ? filterResults(result, mode, 'Routes') : result));
|
|
5741
5750
|
if (allSources || sources.includes('History')) {
|
|
5742
|
-
const routeHistory = getOldSearches(
|
|
5751
|
+
const routeHistory = getOldSearches();
|
|
5743
5752
|
const dropLayers = ['bikestation'];
|
|
5744
5753
|
if (transportMode) {
|
|
5745
5754
|
dropLayers.push(...routeLayers.filter(i => !(i === transportMode)));
|
|
@@ -5768,7 +5777,7 @@ function getSearchResults(targets, sources, transportMode, searchContext, filter
|
|
|
5768
5777
|
}));
|
|
5769
5778
|
}
|
|
5770
5779
|
if (allSources || sources.includes('History')) {
|
|
5771
|
-
const history = getOldSearches(
|
|
5780
|
+
const history = getOldSearches();
|
|
5772
5781
|
const dropLayers = [...stopLayers];
|
|
5773
5782
|
dropLayers.push(...routeLayers);
|
|
5774
5783
|
dropLayers.push(...locationLayers);
|
|
@@ -6391,7 +6400,7 @@ function getSuggestionContent(item, lng, t) {
|
|
|
6391
6400
|
let [name, label] = getNameLabel(item.properties, true);
|
|
6392
6401
|
let suggestionType;
|
|
6393
6402
|
if (item.properties.layer.toLowerCase().includes('bikerental') || item.properties.layer.toLowerCase().includes('bikestation')) {
|
|
6394
|
-
suggestionType = t('
|
|
6403
|
+
suggestionType = t('bikerentalstation', {
|
|
6395
6404
|
lng
|
|
6396
6405
|
});
|
|
6397
6406
|
const stopCode = item.properties.labelId;
|
|
@@ -7301,6 +7310,7 @@ const getNewTargets = ({
|
|
|
7301
7310
|
* getFavouriteRoutesQuery: () => ({}), // Function that returns query for fetching favourite routes.
|
|
7302
7311
|
* getFavouriteVehicleRentalStations: () => ({}), // Function that returns favourite bike rental station.
|
|
7303
7312
|
* getFavouriteVehicleRentalStationsQuery: () => ({}), // Function that returns query for fetching favourite bike rental stations.
|
|
7313
|
+
* getHasOtpLocationFavourites: () => ({}), // Optional. Function that returns whether any OTP-backed favourite is currently available.
|
|
7304
7314
|
* startLocationWatch: () => ({}), // Function that locates users geolocation.
|
|
7305
7315
|
* saveSearch: () => ({}), // Function that saves search to old searches store.
|
|
7306
7316
|
* clearOldSearches: () => ({}), // Function that clears old searches store.
|
|
@@ -7723,14 +7733,13 @@ function DTAutosuggest({
|
|
|
7723
7733
|
});
|
|
7724
7734
|
const mobileClearOldSearches = () => {
|
|
7725
7735
|
const {
|
|
7726
|
-
context,
|
|
7727
7736
|
clearOldSearches,
|
|
7728
7737
|
clearFutureRoutes
|
|
7729
7738
|
} = searchContext;
|
|
7730
|
-
if (
|
|
7731
|
-
clearOldSearches(
|
|
7739
|
+
if (clearOldSearches) {
|
|
7740
|
+
clearOldSearches();
|
|
7732
7741
|
if (clearFutureRoutes) {
|
|
7733
|
-
clearFutureRoutes(
|
|
7742
|
+
clearFutureRoutes();
|
|
7734
7743
|
}
|
|
7735
7744
|
fetchSuggestions(state.value);
|
|
7736
7745
|
}
|