allaw-ui 4.8.4 → 4.8.6
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.
|
@@ -100,30 +100,51 @@ var SearchBar = function (_a) {
|
|
|
100
100
|
}); };
|
|
101
101
|
var handleLocate = function () {
|
|
102
102
|
if (!(navigator === null || navigator === void 0 ? void 0 : navigator.geolocation)) {
|
|
103
|
-
// eslint-disable-next-line no-console
|
|
104
103
|
console.warn("Geolocation not supported by this browser");
|
|
105
104
|
return;
|
|
106
105
|
}
|
|
106
|
+
console.log("Requesting geolocation...");
|
|
107
107
|
navigator.geolocation.getCurrentPosition(function (pos) { return __awaiter(void 0, void 0, void 0, function () {
|
|
108
108
|
var _a, latitude, longitude, resolver, city;
|
|
109
109
|
return __generator(this, function (_b) {
|
|
110
110
|
switch (_b.label) {
|
|
111
111
|
case 0:
|
|
112
|
+
console.log("Geolocation success:", pos.coords);
|
|
112
113
|
_a = pos.coords, latitude = _a.latitude, longitude = _a.longitude;
|
|
113
114
|
resolver = resolveCityFromCoords || defaultResolveCityFromCoords;
|
|
114
115
|
return [4 /*yield*/, resolver(latitude, longitude)];
|
|
115
116
|
case 1:
|
|
116
117
|
city = _b.sent();
|
|
117
118
|
if (city) {
|
|
119
|
+
console.log("City resolved:", city);
|
|
118
120
|
setValue(city);
|
|
119
121
|
onChange === null || onChange === void 0 ? void 0 : onChange(city);
|
|
120
122
|
}
|
|
123
|
+
else {
|
|
124
|
+
console.warn("Could not resolve city from coordinates");
|
|
125
|
+
}
|
|
121
126
|
return [2 /*return*/];
|
|
122
127
|
}
|
|
123
128
|
});
|
|
124
129
|
}); }, function (err) {
|
|
125
|
-
|
|
126
|
-
|
|
130
|
+
console.error("Geolocation error:", err);
|
|
131
|
+
if (err.code === 1) {
|
|
132
|
+
console.error("Permission denied - user must allow location access");
|
|
133
|
+
// Proposer de réessayer
|
|
134
|
+
if (confirm("L'accès à la localisation a été refusé. Voulez-vous réessayer ?")) {
|
|
135
|
+
setTimeout(function () { return handleLocate(); }, 1000);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else if (err.code === 2) {
|
|
139
|
+
console.error("Position unavailable");
|
|
140
|
+
}
|
|
141
|
+
else if (err.code === 3) {
|
|
142
|
+
console.error("Timeout");
|
|
143
|
+
// Réessayer en cas de timeout
|
|
144
|
+
if (confirm("La localisation a pris trop de temps. Voulez-vous réessayer ?")) {
|
|
145
|
+
setTimeout(function () { return handleLocate(); }, 1000);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
127
148
|
}, { enableHighAccuracy: true, timeout: 10000, maximumAge: 0 });
|
|
128
149
|
};
|
|
129
150
|
var wrapperClassName = [
|
|
@@ -146,6 +167,10 @@ var SearchBar = function (_a) {
|
|
|
146
167
|
React.createElement("i", { className: "allaw-icon-x-small" }))),
|
|
147
168
|
endIcon && (React.createElement("button", { className: styles.searchBarIconButton, tabIndex: -1, "aria-label": "Rechercher" },
|
|
148
169
|
React.createElement("i", { className: endIcon }))),
|
|
149
|
-
showLocate && (React.createElement("button", { type: "button", className: styles.searchBarLocateButton, onClick:
|
|
170
|
+
showLocate && (React.createElement("button", { type: "button", className: styles.searchBarLocateButton, onClick: function (e) {
|
|
171
|
+
e.preventDefault();
|
|
172
|
+
e.stopPropagation();
|
|
173
|
+
handleLocate();
|
|
174
|
+
}, "aria-label": "Me localiser", title: "Me localiser" }, "Me localiser"))));
|
|
150
175
|
};
|
|
151
176
|
export default SearchBar;
|