allaw-ui 4.8.5 → 4.8.7

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.
@@ -49,9 +49,11 @@ import React, { useState } from "react";
49
49
  import styles from "./searchBar.module.css";
50
50
  import "../../../styles/global.css";
51
51
  import "../../../styles/icons.css";
52
+ import TinyInfo from "../typography/TinyInfo";
52
53
  var SearchBar = function (_a) {
53
54
  var _b = _a.placeholder, placeholder = _b === void 0 ? "Faites une recherche" : _b, endIcon = _a.endIcon, startIcon = _a.startIcon, _c = _a.value, controlledValue = _c === void 0 ? "" : _c, onChange = _a.onChange, _d = _a.showClear, showClear = _d === void 0 ? false : _d, _e = _a.size, size = _e === void 0 ? "normal" : _e, _f = _a.style, styleProp = _f === void 0 ? "classic" : _f, _g = _a.disableAutofill, disableAutofill = _g === void 0 ? false : _g, _h = _a.showLocate, showLocate = _h === void 0 ? false : _h, resolveCityFromCoords = _a.resolveCityFromCoords;
54
55
  var _j = useState(controlledValue), value = _j[0], setValue = _j[1];
56
+ var _k = useState(null), locationError = _k[0], setLocationError = _k[1];
55
57
  var handleChange = function (event) {
56
58
  var newValue = event.target.value;
57
59
  setValue(newValue);
@@ -91,8 +93,6 @@ var SearchBar = function (_a) {
91
93
  undefined)];
92
94
  case 3:
93
95
  error_1 = _a.sent();
94
- // eslint-disable-next-line no-console
95
- console.warn("reverse geocoding failed", error_1);
96
96
  return [2 /*return*/, undefined];
97
97
  case 4: return [2 /*return*/];
98
98
  }
@@ -100,42 +100,40 @@ var SearchBar = function (_a) {
100
100
  }); };
101
101
  var handleLocate = function () {
102
102
  if (!(navigator === null || navigator === void 0 ? void 0 : navigator.geolocation)) {
103
- console.warn("Geolocation not supported by this browser");
103
+ setLocationError("La géolocalisation n'est pas supportée par ce navigateur. Saisissez votre ville pour continuer.");
104
104
  return;
105
105
  }
106
- console.log("Requesting geolocation...");
106
+ setLocationError(null);
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);
113
112
  _a = pos.coords, latitude = _a.latitude, longitude = _a.longitude;
114
113
  resolver = resolveCityFromCoords || defaultResolveCityFromCoords;
115
114
  return [4 /*yield*/, resolver(latitude, longitude)];
116
115
  case 1:
117
116
  city = _b.sent();
118
117
  if (city) {
119
- console.log("City resolved:", city);
120
118
  setValue(city);
121
119
  onChange === null || onChange === void 0 ? void 0 : onChange(city);
120
+ setLocationError(null);
122
121
  }
123
122
  else {
124
- console.warn("Could not resolve city from coordinates");
123
+ setLocationError("Impossible de déterminer votre ville. Saisissez-la manuellement pour continuer.");
125
124
  }
126
125
  return [2 /*return*/];
127
126
  }
128
127
  });
129
128
  }); }, function (err) {
130
- console.error("Geolocation error:", err);
131
129
  if (err.code === 1) {
132
- console.error("Permission denied - user must allow location access");
130
+ setLocationError("Accès à la localisation refusé. Saisissez votre ville pour continuer.");
133
131
  }
134
132
  else if (err.code === 2) {
135
- console.error("Position unavailable");
133
+ setLocationError("Position indisponible. Saisissez votre ville pour continuer.");
136
134
  }
137
135
  else if (err.code === 3) {
138
- console.error("Timeout");
136
+ setLocationError("La localisation a pris trop de temps. Saisissez votre ville pour continuer.");
139
137
  }
140
138
  }, { enableHighAccuracy: true, timeout: 10000, maximumAge: 0 });
141
139
  };
@@ -146,19 +144,26 @@ var SearchBar = function (_a) {
146
144
  ]
147
145
  .filter(Boolean)
148
146
  .join(" ");
149
- return (React.createElement("div", { className: wrapperClassName },
150
- startIcon && (React.createElement("span", { className: styles.searchBarStartIcon, "aria-hidden": "true" },
151
- React.createElement("i", { className: startIcon }))),
152
- React.createElement("input", __assign({ type: "text", placeholder: placeholder, className: styles.searchBarPlaceholder, value: controlledValue || value, onChange: handleChange }, (disableAutofill && {
153
- autoComplete: "off",
154
- "data-form-type": "other",
155
- "data-lpignore": "true",
156
- "data-1p-ignore": true,
157
- }))),
158
- showClear && (controlledValue || value) && (React.createElement("button", { type: "button", className: styles.searchBarClearButton, onClick: handleClear, "aria-label": "Effacer la recherche" },
159
- React.createElement("i", { className: "allaw-icon-x-small" }))),
160
- endIcon && (React.createElement("button", { className: styles.searchBarIconButton, tabIndex: -1, "aria-label": "Rechercher" },
161
- React.createElement("i", { className: endIcon }))),
162
- showLocate && (React.createElement("button", { type: "button", className: styles.searchBarLocateButton, onClick: handleLocate, "aria-label": "Me localiser", title: "Me localiser" }, "Me localiser"))));
147
+ return (React.createElement("div", null,
148
+ React.createElement("div", { className: wrapperClassName },
149
+ startIcon && (React.createElement("span", { className: styles.searchBarStartIcon, "aria-hidden": "true" },
150
+ React.createElement("i", { className: startIcon }))),
151
+ React.createElement("input", __assign({ type: "text", placeholder: placeholder, className: styles.searchBarPlaceholder, value: controlledValue || value, onChange: handleChange }, (disableAutofill && {
152
+ autoComplete: "off",
153
+ "data-form-type": "other",
154
+ "data-lpignore": "true",
155
+ "data-1p-ignore": true,
156
+ }))),
157
+ showClear && (controlledValue || value) && (React.createElement("button", { type: "button", className: styles.searchBarClearButton, onClick: handleClear, "aria-label": "Effacer la recherche" },
158
+ React.createElement("i", { className: "allaw-icon-x-small" }))),
159
+ endIcon && (React.createElement("button", { className: styles.searchBarIconButton, tabIndex: -1, "aria-label": "Rechercher" },
160
+ React.createElement("i", { className: endIcon }))),
161
+ showLocate && (React.createElement("button", { type: "button", className: styles.searchBarLocateButton, onClick: function (e) {
162
+ e.preventDefault();
163
+ e.stopPropagation();
164
+ handleLocate();
165
+ }, "aria-label": "Me localiser", title: "Me localiser" }, "Me localiser"))),
166
+ locationError && (React.createElement("div", { className: styles.searchBarError },
167
+ React.createElement(TinyInfo, { variant: "medium12", color: "actions-error", text: locationError, align: "left" })))));
163
168
  };
164
169
  export default SearchBar;
@@ -102,7 +102,7 @@
102
102
  }
103
103
 
104
104
  .searchBarLocateButton:hover {
105
- filter: brightness(0.9);
105
+ background: #1ea8d4;
106
106
  }
107
107
 
108
108
  .sizeBig .searchBarLocateButton {
@@ -147,3 +147,8 @@
147
147
  .styleForm:focus-within {
148
148
  border-color: #728ea7;
149
149
  }
150
+
151
+ .searchBarError {
152
+ margin-top: 8px;
153
+ margin-left: 14px;
154
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "allaw-ui",
3
- "version": "4.8.5",
3
+ "version": "4.8.7",
4
4
  "description": "Composants UI pour l'application Allaw",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",