allaw-ui 4.8.7 → 4.8.9

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.
@@ -12,6 +12,7 @@ export interface SearchBarProps {
12
12
  style?: "classic" | "form";
13
13
  disableAutofill?: boolean;
14
14
  showLocate?: boolean;
15
+ minChar?: number;
15
16
  resolveCityFromCoords?: (lat: number, lon: number) => Promise<string | undefined>;
16
17
  }
17
18
  declare const SearchBar: React.FC<SearchBarProps>;
@@ -51,7 +51,7 @@ import "../../../styles/global.css";
51
51
  import "../../../styles/icons.css";
52
52
  import TinyInfo from "../typography/TinyInfo";
53
53
  var SearchBar = function (_a) {
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
+ 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, minChar = _a.minChar, resolveCityFromCoords = _a.resolveCityFromCoords;
55
55
  var _j = useState(controlledValue), value = _j[0], setValue = _j[1];
56
56
  var _k = useState(null), locationError = _k[0], setLocationError = _k[1];
57
57
  var handleChange = function (event) {
@@ -137,10 +137,13 @@ var SearchBar = function (_a) {
137
137
  }
138
138
  }, { enableHighAccuracy: true, timeout: 10000, maximumAge: 0 });
139
139
  };
140
+ var currentValue = controlledValue || value;
141
+ var hasMinChar = minChar && minChar > 0 && currentValue.length >= minChar;
140
142
  var wrapperClassName = [
141
143
  styles.searchBar,
142
144
  styleProp === "form" ? styles.styleForm : "",
143
145
  size === "big" ? styles.sizeBig : "",
146
+ hasMinChar ? styles.minCharReached : "",
144
147
  ]
145
148
  .filter(Boolean)
146
149
  .join(" ");
@@ -162,7 +165,9 @@ var SearchBar = function (_a) {
162
165
  e.preventDefault();
163
166
  e.stopPropagation();
164
167
  handleLocate();
165
- }, "aria-label": "Me localiser", title: "Me localiser" }, "Me localiser"))),
168
+ }, "aria-label": "Me localiser", title: "Me localiser" },
169
+ React.createElement("span", { className: styles.searchBarLocateText }, "Me localiser"),
170
+ React.createElement("i", { className: "allaw-icon-map-pin ".concat(styles.searchBarLocateIcon) })))),
166
171
  locationError && (React.createElement("div", { className: styles.searchBarError },
167
172
  React.createElement(TinyInfo, { variant: "medium12", color: "actions-error", text: locationError, align: "left" })))));
168
173
  };
@@ -16,6 +16,7 @@ declare namespace _default {
16
16
  let startIcon: undefined;
17
17
  let showLocate: boolean;
18
18
  let locateIcon: string;
19
+ let minChar: undefined;
19
20
  }
20
21
  export namespace argTypes {
21
22
  export namespace placeholder {
@@ -90,6 +91,18 @@ declare namespace _default {
90
91
  export { description_3 as description };
91
92
  }
92
93
  export { showClear_1 as showClear };
94
+ export namespace minChar_1 {
95
+ export namespace control_9 {
96
+ let type_7: string;
97
+ export { type_7 as type };
98
+ export let min: number;
99
+ export let max: number;
100
+ }
101
+ export { control_9 as control };
102
+ let description_4: string;
103
+ export { description_4 as description };
104
+ }
105
+ export { minChar_1 as minChar };
93
106
  export namespace onChange_1 {
94
107
  let action_1: string;
95
108
  export { action_1 as action };
@@ -115,4 +128,6 @@ export const FormStyle: any;
115
128
  export const WithStartIcon: any;
116
129
  export const BigFormStartIconNoEnd: any;
117
130
  export const WithLocate: any;
131
+ export const WithMinChar: any;
132
+ export const ResponsiveLocate: any;
118
133
  import SearchBar from "./SearchBar";
@@ -21,7 +21,7 @@ export default {
21
21
  component: SearchBar,
22
22
  tags: ["autodocs"],
23
23
  excludeStories: /.*Data$/,
24
- args: __assign(__assign({}, ActionsData), { endIcon: "allaw-icon-search", showClear: false, size: "normal", style: "classic", startIcon: undefined, showLocate: false, locateIcon: "allaw-icon-map-pin" }),
24
+ args: __assign(__assign({}, ActionsData), { endIcon: "allaw-icon-search", showClear: false, size: "normal", style: "classic", startIcon: undefined, showLocate: false, locateIcon: "allaw-icon-map-pin", minChar: undefined }),
25
25
  argTypes: {
26
26
  placeholder: {
27
27
  control: {
@@ -68,6 +68,10 @@ export default {
68
68
  control: "boolean",
69
69
  description: "Affiche une croix pour effacer le champ si true.",
70
70
  },
71
+ minChar: {
72
+ control: { type: "number", min: 0, max: 20 },
73
+ description: "Nombre minimum de caractères pour changer la couleur de bordure en vert (#29a36a).",
74
+ },
71
75
  onChange: { action: "changed" },
72
76
  },
73
77
  parameters: {
@@ -153,3 +157,28 @@ WithLocate.args = {
153
157
  showLocate: true,
154
158
  locateIcon: "allaw-icon-map-pin",
155
159
  };
160
+ export var WithMinChar = Template.bind({});
161
+ WithMinChar.args = {
162
+ placeholder: "Saisissez au moins 6 caractères",
163
+ endIcon: "allaw-icon-search",
164
+ showClear: true,
165
+ size: "normal",
166
+ style: "form",
167
+ minChar: 6,
168
+ };
169
+ export var ResponsiveLocate = Template.bind({});
170
+ ResponsiveLocate.args = {
171
+ placeholder: "Ville (redimensionnez la fenêtre)",
172
+ startIcon: "allaw-icon-map-pin",
173
+ showClear: true,
174
+ size: "normal",
175
+ style: "form",
176
+ showLocate: true,
177
+ };
178
+ ResponsiveLocate.parameters = {
179
+ docs: {
180
+ description: {
181
+ story: "Le bouton 'Me localiser' devient une icône en dessous de 480px de largeur. Redimensionnez votre navigateur pour voir l'effet.",
182
+ },
183
+ },
184
+ };
@@ -110,6 +110,37 @@
110
110
  font-size: 13px;
111
111
  }
112
112
 
113
+ .searchBarLocateText {
114
+ display: inline;
115
+ }
116
+
117
+ .searchBarLocateIcon {
118
+ display: none;
119
+ font-size: 14px;
120
+ }
121
+
122
+ /* Responsive behavior for mobile */
123
+ @media (max-width: 479px) {
124
+ .searchBarLocateText {
125
+ display: none;
126
+ }
127
+
128
+ .searchBarLocateIcon {
129
+ display: inline;
130
+ }
131
+
132
+ .searchBarLocateButton {
133
+ padding: 0;
134
+ width: 28px;
135
+ min-width: 28px;
136
+ }
137
+
138
+ .sizeBig .searchBarLocateButton {
139
+ width: 32px;
140
+ min-width: 32px;
141
+ }
142
+ }
143
+
113
144
  .searchBarClearButton {
114
145
  display: flex;
115
146
  align-items: center;
@@ -145,10 +176,23 @@
145
176
  }
146
177
 
147
178
  .styleForm:focus-within {
148
- border-color: #728ea7;
179
+ border-color: #25beeb;
149
180
  }
150
181
 
151
182
  .searchBarError {
152
183
  margin-top: 8px;
153
184
  margin-left: 14px;
154
185
  }
186
+
187
+ /* MinChar variant */
188
+ .minCharReached {
189
+ border-color: #29a36a !important;
190
+ }
191
+
192
+ .minCharReached:hover {
193
+ border-color: #29a36a !important;
194
+ }
195
+
196
+ .minCharReached:focus-within {
197
+ border-color: #29a36a !important;
198
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "allaw-ui",
3
- "version": "4.8.7",
3
+ "version": "4.8.9",
4
4
  "description": "Composants UI pour l'application Allaw",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",