@ta-interaktiv/react-municipality-search 1.2.0 → 1.3.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/CHANGELOG.md +20 -4
- package/dist/index.js +88 -51
- package/dist/index.js.map +1 -1
- package/dist/municipalitySearch.d.ts +7 -1
- package/dist/municipalitySearch.d.ts.map +1 -1
- package/es/index.js +88 -51
- package/es/index.js.map +1 -1
- package/es/municipalitySearch.d.ts +7 -1
- package/es/municipalitySearch.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/municipalitySearch.tsx +110 -46
package/CHANGELOG.md
CHANGED
|
@@ -1,18 +1,34 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
3
|
+
All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
4
|
|
|
6
|
-
# [1.
|
|
5
|
+
# [1.3.0](https://gitlab.com/ta-interaktiv/packages/compare/@ta-interaktiv/react-municipality-search@1.2.2...@ta-interaktiv/react-municipality-search@1.3.0) (2022-04-20)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
7
8
|
|
|
9
|
+
- remove console log ([c3e2566](https://gitlab.com/ta-interaktiv/packages/commit/c3e25662da69d3671aade242e8d700a95c259984))
|
|
8
10
|
|
|
9
11
|
### Features
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
- allow new municipalities data retrieval when the date prop is changed ([62e46d4](https://gitlab.com/ta-interaktiv/packages/commit/62e46d4ad710df131b44d8b1554bf89481bbd2b9))
|
|
14
|
+
|
|
15
|
+
## [1.2.2](https://gitlab.com/ta-interaktiv/packages/compare/@ta-interaktiv/react-municipality-search@1.2.1...@ta-interaktiv/react-municipality-search@1.2.2) (2022-04-19)
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
- correct order in ms ([44dc573](https://gitlab.com/ta-interaktiv/packages/commit/44dc573c1d4dae990ae3984f4cd9ea901a7f40d9))
|
|
20
|
+
|
|
21
|
+
## [1.2.1](https://gitlab.com/ta-interaktiv/packages/compare/@ta-interaktiv/react-municipality-search@1.2.0...@ta-interaktiv/react-municipality-search@1.2.1) (2022-04-14)
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
12
24
|
|
|
25
|
+
- show last selected municipalities ([adff1f9](https://gitlab.com/ta-interaktiv/packages/commit/adff1f9ec251be7ee948697dafbaf00ec3703ac9))
|
|
13
26
|
|
|
27
|
+
# [1.2.0](https://gitlab.com/ta-interaktiv/packages/compare/@ta-interaktiv/react-municipality-search@1.1.3...@ta-interaktiv/react-municipality-search@1.2.0) (2022-02-03)
|
|
14
28
|
|
|
29
|
+
### Features
|
|
15
30
|
|
|
31
|
+
- hideToooltip and resetOnSelect ([f5c1f8f](https://gitlab.com/ta-interaktiv/packages/commit/f5c1f8f9c6d6c86af1b82a995a2d8dcb98a8d87e))
|
|
16
32
|
|
|
17
33
|
## [1.1.3](https://gitlab.com/ta-interaktiv/packages/compare/@ta-interaktiv/react-municipality-search@1.1.2...@ta-interaktiv/react-municipality-search@1.1.3) (2021-09-17)
|
|
18
34
|
|
package/dist/index.js
CHANGED
|
@@ -139,13 +139,13 @@ var MunicipalitySearch = (function (_super) {
|
|
|
139
139
|
results: [],
|
|
140
140
|
value: '',
|
|
141
141
|
error: null,
|
|
142
|
-
municipalities: []
|
|
142
|
+
municipalities: [],
|
|
143
143
|
};
|
|
144
144
|
_this.resetComponent = function () {
|
|
145
145
|
_this.setState({
|
|
146
146
|
isLoading: false,
|
|
147
147
|
results: [],
|
|
148
|
-
value: ''
|
|
148
|
+
value: '',
|
|
149
149
|
});
|
|
150
150
|
};
|
|
151
151
|
_this.filterList = function (searchTerm) {
|
|
@@ -188,7 +188,7 @@ var MunicipalitySearch = (function (_super) {
|
|
|
188
188
|
window.dataLayer.push({
|
|
189
189
|
event: 'Interactions',
|
|
190
190
|
event_action: 'input',
|
|
191
|
-
event_label: "search:for_" + searchTerm + ":results_" + results.length
|
|
191
|
+
event_label: "search:for_" + searchTerm + ":results_" + results.length,
|
|
192
192
|
});
|
|
193
193
|
}
|
|
194
194
|
return _this.removeDuplicates(results, searchTerm);
|
|
@@ -213,7 +213,7 @@ var MunicipalitySearch = (function (_super) {
|
|
|
213
213
|
.fetch(url, {
|
|
214
214
|
method: 'GET',
|
|
215
215
|
mode: 'no-cors',
|
|
216
|
-
credentials: 'include'
|
|
216
|
+
credentials: 'include',
|
|
217
217
|
})
|
|
218
218
|
.then(function (response) {
|
|
219
219
|
console.log(response);
|
|
@@ -222,6 +222,50 @@ var MunicipalitySearch = (function (_super) {
|
|
|
222
222
|
console.log(error);
|
|
223
223
|
});
|
|
224
224
|
};
|
|
225
|
+
_this.pushToLocalStorageArray = function (newMuni) {
|
|
226
|
+
var _a;
|
|
227
|
+
var localStorageItemName = 'selectedMunicipalities_' + _this.props.municipalityData;
|
|
228
|
+
var prevSelectedMunicipalities = (_a = localStorage.getItem(localStorageItemName)) !== null && _a !== void 0 ? _a : JSON.stringify([]);
|
|
229
|
+
var newArray = JSON.parse(prevSelectedMunicipalities);
|
|
230
|
+
var slicedArray = newArray.slice(0, 15);
|
|
231
|
+
slicedArray.unshift(newMuni);
|
|
232
|
+
localStorage.setItem(localStorageItemName, JSON.stringify(__spread(new Map(slicedArray.map(function (muni) { return [
|
|
233
|
+
muni.ORTNAME + muni.GDENR,
|
|
234
|
+
muni,
|
|
235
|
+
]; })).values())));
|
|
236
|
+
};
|
|
237
|
+
_this.getMunicipalitiesData = function () {
|
|
238
|
+
_this.setState({
|
|
239
|
+
isLoading: true,
|
|
240
|
+
});
|
|
241
|
+
return fetch("https://interaktiv.tagesanzeiger.ch/static/gemeindesuche/" + _this.props.municipalityData + ".json")
|
|
242
|
+
.then(function (res) {
|
|
243
|
+
if (!res.ok) {
|
|
244
|
+
throw new MunicipalityDownloadError("Download error: " + res.status + ": " + res.statusText + ".");
|
|
245
|
+
}
|
|
246
|
+
return res.json();
|
|
247
|
+
})
|
|
248
|
+
.then(function (data) {
|
|
249
|
+
_this.setState({
|
|
250
|
+
isLoading: false,
|
|
251
|
+
municipalities: data,
|
|
252
|
+
});
|
|
253
|
+
})
|
|
254
|
+
.catch(function (error) {
|
|
255
|
+
if (error instanceof MunicipalityDownloadError) {
|
|
256
|
+
console.log(error);
|
|
257
|
+
console.info('Make sure that you have the municipality and zip code data for the required year uploaded to the Interaktiv server.');
|
|
258
|
+
console.info('Read more about the data generation in the "data" directory in the project repository for the MunicipalitySearch React component.');
|
|
259
|
+
_this.setState({
|
|
260
|
+
isLoading: false,
|
|
261
|
+
error: 'error.municipalitiesNotDownloaded',
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
throw error;
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
};
|
|
225
269
|
return _this;
|
|
226
270
|
}
|
|
227
271
|
MunicipalitySearch.prototype.removeDuplicates = function (arr, searchTerm) {
|
|
@@ -248,35 +292,22 @@ var MunicipalitySearch = (function (_super) {
|
|
|
248
292
|
.flat();
|
|
249
293
|
return result;
|
|
250
294
|
};
|
|
295
|
+
MunicipalitySearch.prototype.componentDidUpdate = function (prevProps) {
|
|
296
|
+
if (prevProps.municipalityData !== this.props.municipalityData) {
|
|
297
|
+
this.resetComponent();
|
|
298
|
+
this.getMunicipalitiesData();
|
|
299
|
+
}
|
|
300
|
+
};
|
|
251
301
|
MunicipalitySearch.prototype.componentDidMount = function () {
|
|
252
|
-
var
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
_this.setState({
|
|
262
|
-
isLoading: false,
|
|
263
|
-
municipalities: data
|
|
264
|
-
});
|
|
265
|
-
})
|
|
266
|
-
.catch(function (error) {
|
|
267
|
-
if (error instanceof MunicipalityDownloadError) {
|
|
268
|
-
console.log(error);
|
|
269
|
-
console.info('Make sure that you have the municipality and zip code data for the required year uploaded to the Interaktiv server.');
|
|
270
|
-
console.info('Read more about the data generation in the "data" directory in the project repository for the MunicipalitySearch React component.');
|
|
271
|
-
_this.setState({
|
|
272
|
-
isLoading: false,
|
|
273
|
-
error: 'error.municipalitiesNotDownloaded'
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
else {
|
|
277
|
-
throw error;
|
|
278
|
-
}
|
|
279
|
-
});
|
|
302
|
+
var _a;
|
|
303
|
+
var locallyStoredMunicipalitiesArray = localStorage.getItem('selectedMunicipalities_' + this.props.municipalityData);
|
|
304
|
+
if (this.props.showLastSelectedMunicipalities &&
|
|
305
|
+
locallyStoredMunicipalitiesArray) {
|
|
306
|
+
var parsed = JSON.parse(locallyStoredMunicipalitiesArray);
|
|
307
|
+
var muniCount = (_a = this.props.numberOfLastSelectedMunicipalities) !== null && _a !== void 0 ? _a : 1;
|
|
308
|
+
this.setState({ results: parsed.slice(0, muniCount) });
|
|
309
|
+
}
|
|
310
|
+
this.getMunicipalitiesData();
|
|
280
311
|
};
|
|
281
312
|
MunicipalitySearch.prototype.render = function () {
|
|
282
313
|
var _this = this;
|
|
@@ -303,33 +334,39 @@ var MunicipalitySearch = (function (_super) {
|
|
|
303
334
|
React__default.createElement("i", { className: 'search icon' })),
|
|
304
335
|
!this.props.hideTooltip && (React__default.createElement("div", null,
|
|
305
336
|
React__default.createElement("label", { htmlFor: 'search', className: "ui " + (this.state.error ? 'red' : 'basic grey') + " " + labelDirection + " label" }, labelContent())))),
|
|
306
|
-
showResults(results) && (React__default.createElement("div", { className: "results " + styles.results },
|
|
337
|
+
showResults(results) && (React__default.createElement("div", { className: "results " + styles.results }, showResults(results) && (React__default.createElement(renderprops_cjs_js.Transition, { native: true, items: results, keys: function (result) {
|
|
307
338
|
return result.PLZ4 + result.GDENR + result.ORTNAME;
|
|
308
|
-
}, from: { transform: 'translate(0,-20px)', opacity: 0 }, enter: { transform: 'translate(0,0px)', opacity: 1 }, leave: { transform: 'translate(0, 60px)', opacity: 0 }, config: renderprops_cjs_js.config.gentle }, function (result) { return function (props) {
|
|
309
|
-
|
|
310
|
-
if (_this.props.resetOnSelect) {
|
|
311
|
-
_this.resetComponent();
|
|
312
|
-
}
|
|
313
|
-
}, onKeyUp: function (e) {
|
|
314
|
-
if (e.key === 'Enter' || e.key === 'Space') {
|
|
339
|
+
}, from: { transform: 'translate(0,-20px)', opacity: 0 }, enter: { transform: 'translate(0,0px)', opacity: 1 }, leave: { transform: 'translate(0, 60px)', opacity: 0 }, config: renderprops_cjs_js.config.gentle }, function (result) { return function (props) {
|
|
340
|
+
return (React__default.createElement(renderprops_cjs_js.animated.div, { onClick: function () {
|
|
315
341
|
_this.props.onSelectionHandler(result);
|
|
342
|
+
if (_this.props.showLastSelectedMunicipalities) {
|
|
343
|
+
_this.pushToLocalStorageArray(result);
|
|
344
|
+
}
|
|
316
345
|
if (_this.props.resetOnSelect) {
|
|
317
346
|
_this.resetComponent();
|
|
318
347
|
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
"
|
|
328
|
-
|
|
348
|
+
}, onKeyUp: function (e) {
|
|
349
|
+
if (e.key === 'Enter' || e.key === 'Space') {
|
|
350
|
+
_this.props.onSelectionHandler(result);
|
|
351
|
+
if (_this.props.resetOnSelect) {
|
|
352
|
+
_this.resetComponent();
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}, className: "result " + styles.result, style: props, tabIndex: 0 },
|
|
356
|
+
React__default.createElement("div", { className: styles.resultHeader },
|
|
357
|
+
React__default.createElement("span", { className: styles.resultPlz }, result.PLZ4),
|
|
358
|
+
' ',
|
|
359
|
+
result.ORTNAME),
|
|
360
|
+
React__default.createElement("div", { className: styles.resultMeta },
|
|
361
|
+
t('list.municipalityPrefix'),
|
|
362
|
+
" ",
|
|
363
|
+
result.GDENAMK)));
|
|
364
|
+
}; }))))));
|
|
329
365
|
};
|
|
330
366
|
MunicipalitySearch.defaultProps = {
|
|
331
367
|
municipalityData: '2021v3',
|
|
332
|
-
locale: 'de'
|
|
368
|
+
locale: 'de',
|
|
369
|
+
numberOfLastSelectedMunicipalities: 1,
|
|
333
370
|
};
|
|
334
371
|
return MunicipalitySearch;
|
|
335
372
|
}(React.Component));
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../node_modules/tslib/tslib.es6.js","../../../node_modules/style-inject/dist/style-inject.es.js"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation. All rights reserved.\r\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\r\nthis file except in compliance with the License. You may obtain a copy of the\r\nLicense at http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r\nMERCHANTABLITY OR NON-INFRINGEMENT.\r\n\r\nSee the Apache Version 2.0 License for specific language governing permissions\r\nand limitations under the License.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n","function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAGA,IAAI,aAAa,GAAG,SAAS,CAAC,EAAE,CAAC,EAAE;AACnC,IAAI,aAAa,GAAG,MAAM,CAAC,cAAc;AACzC,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,YAAY,KAAK,IAAI,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE,CAAC;AACpF,QAAQ,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACnF,IAAI,OAAO,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC/B,CAAC,CAAC;AAEK,SAAS,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE;AAChC,IAAI,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACxB,IAAI,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,WAAW,GA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WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;AACpD,GAAG;AACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../node_modules/tslib/tslib.es6.js","../../../node_modules/style-inject/dist/style-inject.es.js"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation. All rights reserved.\r\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\r\nthis file except in compliance with the License. You may obtain a copy of the\r\nLicense at http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r\nMERCHANTABLITY OR NON-INFRINGEMENT.\r\n\r\nSee the Apache Version 2.0 License for specific language governing permissions\r\nand limitations under the License.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n","function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAGA,IAAI,aAAa,GAAG,SAAS,CAAC,EAAE,CAAC,EAAE;AACnC,IAAI,aAAa,GAAG,MAAM,CAAC,cAAc;AACzC,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,YAAY,KAAK,IAAI,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE,CAAC;AACpF,QAAQ,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACnF,IAAI,OAAO,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC/B,CAAC,CAAC;AAEK,SAAS,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE;AAChC,IAAI,aAAa,CAAC,CAAC,EAAE,CAAC,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AC,OAAO,GAAG,GAAG,CAAC;AACnC,GAAG,MAAM;AACT,IAAI,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;AACpD,GAAG;AACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -20,6 +20,8 @@ export interface Props {
|
|
|
20
20
|
onSelectionHandler: (municipality: Municipality) => void;
|
|
21
21
|
locale: 'de' | 'fr';
|
|
22
22
|
placeholder?: string;
|
|
23
|
+
showLastSelectedMunicipalities?: boolean;
|
|
24
|
+
numberOfLastSelectedMunicipalities?: number;
|
|
23
25
|
}
|
|
24
26
|
interface State {
|
|
25
27
|
isLoading: boolean;
|
|
@@ -32,6 +34,7 @@ export declare class MunicipalitySearch extends Component<Props, State> {
|
|
|
32
34
|
static defaultProps: {
|
|
33
35
|
municipalityData: string;
|
|
34
36
|
locale: string;
|
|
37
|
+
numberOfLastSelectedMunicipalities: number;
|
|
35
38
|
};
|
|
36
39
|
state: {
|
|
37
40
|
isLoading: boolean;
|
|
@@ -45,7 +48,10 @@ export declare class MunicipalitySearch extends Component<Props, State> {
|
|
|
45
48
|
private removeDuplicates;
|
|
46
49
|
private handleSearchChange;
|
|
47
50
|
private sendToDataPipeline;
|
|
48
|
-
|
|
51
|
+
private pushToLocalStorageArray;
|
|
52
|
+
private getMunicipalitiesData;
|
|
53
|
+
componentDidUpdate(prevProps: Props): void;
|
|
54
|
+
componentDidMount(): void;
|
|
49
55
|
render(): JSX.Element;
|
|
50
56
|
}
|
|
51
57
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"municipalitySearch.d.ts","sourceRoot":"","sources":["src/municipalitySearch.tsx"],"names":[],"mappings":"AACA,OAAc,EAAe,SAAS,EAAE,MAAM,OAAO,CAAA;AACrD,OAAO,8DAA8D,CAAA;AACrE,OAAO,+DAA+D,CAAA;AACtE,OAAO,+DAA+D,CAAA;AAsBtE,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;CAC9B;AAED,MAAM,WAAW,KAAK;IAGpB,gBAAgB,EAAE,MAAM,CAAA;IAGxB,MAAM,CAAC,EAAE,OAAO,CAAA;IAGhB,WAAW,CAAC,EAAE,OAAO,CAAA;IAGrB,aAAa,CAAC,EAAE,OAAO,CAAA;IAGvB,kBAAkB,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,IAAI,CAAA;IAGxD,MAAM,EAAE,IAAI,GAAG,IAAI,CAAA;IAGnB,WAAW,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"municipalitySearch.d.ts","sourceRoot":"","sources":["src/municipalitySearch.tsx"],"names":[],"mappings":"AACA,OAAc,EAAe,SAAS,EAAE,MAAM,OAAO,CAAA;AACrD,OAAO,8DAA8D,CAAA;AACrE,OAAO,+DAA+D,CAAA;AACtE,OAAO,+DAA+D,CAAA;AAsBtE,MAAM,WAAW,Y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D,OAAO,CAAC,kBAAkB,CAgBzB;IAED,OAAO,CAAC,uBAAuB,CAqB9B;IAED,OAAO,CAAC,qBAAqB,CAuC5B;IAEM,kBAAkB,CAAC,SAAS,EAAE,KAAK;IAUnC,iBAAiB;IAqBjB,MAAM;CA0Hd"}
|
package/es/index.js
CHANGED
|
@@ -132,13 +132,13 @@ var MunicipalitySearch = (function (_super) {
|
|
|
132
132
|
results: [],
|
|
133
133
|
value: '',
|
|
134
134
|
error: null,
|
|
135
|
-
municipalities: []
|
|
135
|
+
municipalities: [],
|
|
136
136
|
};
|
|
137
137
|
_this.resetComponent = function () {
|
|
138
138
|
_this.setState({
|
|
139
139
|
isLoading: false,
|
|
140
140
|
results: [],
|
|
141
|
-
value: ''
|
|
141
|
+
value: '',
|
|
142
142
|
});
|
|
143
143
|
};
|
|
144
144
|
_this.filterList = function (searchTerm) {
|
|
@@ -181,7 +181,7 @@ var MunicipalitySearch = (function (_super) {
|
|
|
181
181
|
window.dataLayer.push({
|
|
182
182
|
event: 'Interactions',
|
|
183
183
|
event_action: 'input',
|
|
184
|
-
event_label: "search:for_" + searchTerm + ":results_" + results.length
|
|
184
|
+
event_label: "search:for_" + searchTerm + ":results_" + results.length,
|
|
185
185
|
});
|
|
186
186
|
}
|
|
187
187
|
return _this.removeDuplicates(results, searchTerm);
|
|
@@ -206,7 +206,7 @@ var MunicipalitySearch = (function (_super) {
|
|
|
206
206
|
.fetch(url, {
|
|
207
207
|
method: 'GET',
|
|
208
208
|
mode: 'no-cors',
|
|
209
|
-
credentials: 'include'
|
|
209
|
+
credentials: 'include',
|
|
210
210
|
})
|
|
211
211
|
.then(function (response) {
|
|
212
212
|
console.log(response);
|
|
@@ -215,6 +215,50 @@ var MunicipalitySearch = (function (_super) {
|
|
|
215
215
|
console.log(error);
|
|
216
216
|
});
|
|
217
217
|
};
|
|
218
|
+
_this.pushToLocalStorageArray = function (newMuni) {
|
|
219
|
+
var _a;
|
|
220
|
+
var localStorageItemName = 'selectedMunicipalities_' + _this.props.municipalityData;
|
|
221
|
+
var prevSelectedMunicipalities = (_a = localStorage.getItem(localStorageItemName)) !== null && _a !== void 0 ? _a : JSON.stringify([]);
|
|
222
|
+
var newArray = JSON.parse(prevSelectedMunicipalities);
|
|
223
|
+
var slicedArray = newArray.slice(0, 15);
|
|
224
|
+
slicedArray.unshift(newMuni);
|
|
225
|
+
localStorage.setItem(localStorageItemName, JSON.stringify(__spread(new Map(slicedArray.map(function (muni) { return [
|
|
226
|
+
muni.ORTNAME + muni.GDENR,
|
|
227
|
+
muni,
|
|
228
|
+
]; })).values())));
|
|
229
|
+
};
|
|
230
|
+
_this.getMunicipalitiesData = function () {
|
|
231
|
+
_this.setState({
|
|
232
|
+
isLoading: true,
|
|
233
|
+
});
|
|
234
|
+
return fetch("https://interaktiv.tagesanzeiger.ch/static/gemeindesuche/" + _this.props.municipalityData + ".json")
|
|
235
|
+
.then(function (res) {
|
|
236
|
+
if (!res.ok) {
|
|
237
|
+
throw new MunicipalityDownloadError("Download error: " + res.status + ": " + res.statusText + ".");
|
|
238
|
+
}
|
|
239
|
+
return res.json();
|
|
240
|
+
})
|
|
241
|
+
.then(function (data) {
|
|
242
|
+
_this.setState({
|
|
243
|
+
isLoading: false,
|
|
244
|
+
municipalities: data,
|
|
245
|
+
});
|
|
246
|
+
})
|
|
247
|
+
.catch(function (error) {
|
|
248
|
+
if (error instanceof MunicipalityDownloadError) {
|
|
249
|
+
console.log(error);
|
|
250
|
+
console.info('Make sure that you have the municipality and zip code data for the required year uploaded to the Interaktiv server.');
|
|
251
|
+
console.info('Read more about the data generation in the "data" directory in the project repository for the MunicipalitySearch React component.');
|
|
252
|
+
_this.setState({
|
|
253
|
+
isLoading: false,
|
|
254
|
+
error: 'error.municipalitiesNotDownloaded',
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
throw error;
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
};
|
|
218
262
|
return _this;
|
|
219
263
|
}
|
|
220
264
|
MunicipalitySearch.prototype.removeDuplicates = function (arr, searchTerm) {
|
|
@@ -241,35 +285,22 @@ var MunicipalitySearch = (function (_super) {
|
|
|
241
285
|
.flat();
|
|
242
286
|
return result;
|
|
243
287
|
};
|
|
288
|
+
MunicipalitySearch.prototype.componentDidUpdate = function (prevProps) {
|
|
289
|
+
if (prevProps.municipalityData !== this.props.municipalityData) {
|
|
290
|
+
this.resetComponent();
|
|
291
|
+
this.getMunicipalitiesData();
|
|
292
|
+
}
|
|
293
|
+
};
|
|
244
294
|
MunicipalitySearch.prototype.componentDidMount = function () {
|
|
245
|
-
var
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
_this.setState({
|
|
255
|
-
isLoading: false,
|
|
256
|
-
municipalities: data
|
|
257
|
-
});
|
|
258
|
-
})
|
|
259
|
-
.catch(function (error) {
|
|
260
|
-
if (error instanceof MunicipalityDownloadError) {
|
|
261
|
-
console.log(error);
|
|
262
|
-
console.info('Make sure that you have the municipality and zip code data for the required year uploaded to the Interaktiv server.');
|
|
263
|
-
console.info('Read more about the data generation in the "data" directory in the project repository for the MunicipalitySearch React component.');
|
|
264
|
-
_this.setState({
|
|
265
|
-
isLoading: false,
|
|
266
|
-
error: 'error.municipalitiesNotDownloaded'
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
else {
|
|
270
|
-
throw error;
|
|
271
|
-
}
|
|
272
|
-
});
|
|
295
|
+
var _a;
|
|
296
|
+
var locallyStoredMunicipalitiesArray = localStorage.getItem('selectedMunicipalities_' + this.props.municipalityData);
|
|
297
|
+
if (this.props.showLastSelectedMunicipalities &&
|
|
298
|
+
locallyStoredMunicipalitiesArray) {
|
|
299
|
+
var parsed = JSON.parse(locallyStoredMunicipalitiesArray);
|
|
300
|
+
var muniCount = (_a = this.props.numberOfLastSelectedMunicipalities) !== null && _a !== void 0 ? _a : 1;
|
|
301
|
+
this.setState({ results: parsed.slice(0, muniCount) });
|
|
302
|
+
}
|
|
303
|
+
this.getMunicipalitiesData();
|
|
273
304
|
};
|
|
274
305
|
MunicipalitySearch.prototype.render = function () {
|
|
275
306
|
var _this = this;
|
|
@@ -296,33 +327,39 @@ var MunicipalitySearch = (function (_super) {
|
|
|
296
327
|
React.createElement("i", { className: 'search icon' })),
|
|
297
328
|
!this.props.hideTooltip && (React.createElement("div", null,
|
|
298
329
|
React.createElement("label", { htmlFor: 'search', className: "ui " + (this.state.error ? 'red' : 'basic grey') + " " + labelDirection + " label" }, labelContent())))),
|
|
299
|
-
showResults(results) && (React.createElement("div", { className: "results " + styles.results },
|
|
330
|
+
showResults(results) && (React.createElement("div", { className: "results " + styles.results }, showResults(results) && (React.createElement(Transition, { native: true, items: results, keys: function (result) {
|
|
300
331
|
return result.PLZ4 + result.GDENR + result.ORTNAME;
|
|
301
|
-
}, from: { transform: 'translate(0,-20px)', opacity: 0 }, enter: { transform: 'translate(0,0px)', opacity: 1 }, leave: { transform: 'translate(0, 60px)', opacity: 0 }, config: config.gentle }, function (result) { return function (props) {
|
|
302
|
-
|
|
303
|
-
if (_this.props.resetOnSelect) {
|
|
304
|
-
_this.resetComponent();
|
|
305
|
-
}
|
|
306
|
-
}, onKeyUp: function (e) {
|
|
307
|
-
if (e.key === 'Enter' || e.key === 'Space') {
|
|
332
|
+
}, from: { transform: 'translate(0,-20px)', opacity: 0 }, enter: { transform: 'translate(0,0px)', opacity: 1 }, leave: { transform: 'translate(0, 60px)', opacity: 0 }, config: config.gentle }, function (result) { return function (props) {
|
|
333
|
+
return (React.createElement(animated.div, { onClick: function () {
|
|
308
334
|
_this.props.onSelectionHandler(result);
|
|
335
|
+
if (_this.props.showLastSelectedMunicipalities) {
|
|
336
|
+
_this.pushToLocalStorageArray(result);
|
|
337
|
+
}
|
|
309
338
|
if (_this.props.resetOnSelect) {
|
|
310
339
|
_this.resetComponent();
|
|
311
340
|
}
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
"
|
|
321
|
-
|
|
341
|
+
}, onKeyUp: function (e) {
|
|
342
|
+
if (e.key === 'Enter' || e.key === 'Space') {
|
|
343
|
+
_this.props.onSelectionHandler(result);
|
|
344
|
+
if (_this.props.resetOnSelect) {
|
|
345
|
+
_this.resetComponent();
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}, className: "result " + styles.result, style: props, tabIndex: 0 },
|
|
349
|
+
React.createElement("div", { className: styles.resultHeader },
|
|
350
|
+
React.createElement("span", { className: styles.resultPlz }, result.PLZ4),
|
|
351
|
+
' ',
|
|
352
|
+
result.ORTNAME),
|
|
353
|
+
React.createElement("div", { className: styles.resultMeta },
|
|
354
|
+
t('list.municipalityPrefix'),
|
|
355
|
+
" ",
|
|
356
|
+
result.GDENAMK)));
|
|
357
|
+
}; }))))));
|
|
322
358
|
};
|
|
323
359
|
MunicipalitySearch.defaultProps = {
|
|
324
360
|
municipalityData: '2021v3',
|
|
325
|
-
locale: 'de'
|
|
361
|
+
locale: 'de',
|
|
362
|
+
numberOfLastSelectedMunicipalities: 1,
|
|
326
363
|
};
|
|
327
364
|
return MunicipalitySearch;
|
|
328
365
|
}(Component));
|
package/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../node_modules/tslib/tslib.es6.js","../../../node_modules/style-inject/dist/style-inject.es.js"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation. All rights reserved.\r\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\r\nthis file except in compliance with the License. You may obtain a copy of the\r\nLicense at http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r\nMERCHANTABLITY OR NON-INFRINGEMENT.\r\n\r\nSee the Apache Version 2.0 License for specific language governing permissions\r\nand limitations under the License.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n","function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n"],"names":[],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAGA,IAAI,aAAa,GAAG,SAAS,CAAC,EAAE,CAAC,EAAE;AACnC,IAAI,aAAa,GAAG,MAAM,CAAC,cAAc;AACzC,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,YAAY,KAAK,IAAI,U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;AAC9C,EAAE,KAAK,CAAC,IAAI,GAAG,UAAU,CAAC;AAE1B,EAAE,IAAI,QAAQ,KAAK,KAAK,EAAE;AAC1B,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE;AACzB,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;AAChD,KAAK,MAAM;AACX,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC9B,KAAK;AACL,GAAG,MAAM;AACT,IAAI,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5B,GAAG;AAEH,EAAE,IAAI,KAAK,CAAC,UAAU,EAAE;AACxB,IAAI,KAAK,CAAC,UAAU,CAAC,OAAO,GAAG,GAAG,CAAC;AACnC,GAAG,MAAM;AACT,IAAI,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;AACpD,GAAG;AACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../node_modules/tslib/tslib.es6.js","../../../node_modules/style-inject/dist/style-inject.es.js"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation. All rights reserved.\r\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\r\nthis file except in compliance with the License. You may obtain a copy of the\r\nLicense at http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r\nMERCHANTABLITY OR NON-INFRINGEMENT.\r\n\r\nSee the Apache Version 2.0 License for specific language governing permissions\r\nand limitations under the License.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n","function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n"],"names":[],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAGA,IAAI,aAAa,GAAG,SAAS,CAAC,EAAE,CAAC,EAAE;AACnC,IAAI,aAAa,GAAG,MAAM,CAAC,cAAc;A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IAAI,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;AAC9C,EAAE,KAAK,CAAC,IAAI,GAAG,UAAU,CAAC;AAE1B,EAAE,IAAI,QAAQ,KAAK,KAAK,EAAE;AAC1B,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE;AACzB,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;AAChD,KAAK,MAAM;AACX,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC9B,KAAK;AACL,GAAG,MAAM;AACT,IAAI,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5B,GAAG;AAEH,EAAE,IAAI,KAAK,CAAC,UAAU,EAAE;AACxB,IAAI,KAAK,CAAC,UAAU,CAAC,OAAO,GAAG,GAAG,CAAC;AACnC,GAAG,MAAM;AACT,IAAI,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;AACpD,GAAG;AACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -20,6 +20,8 @@ export interface Props {
|
|
|
20
20
|
onSelectionHandler: (municipality: Municipality) => void;
|
|
21
21
|
locale: 'de' | 'fr';
|
|
22
22
|
placeholder?: string;
|
|
23
|
+
showLastSelectedMunicipalities?: boolean;
|
|
24
|
+
numberOfLastSelectedMunicipalities?: number;
|
|
23
25
|
}
|
|
24
26
|
interface State {
|
|
25
27
|
isLoading: boolean;
|
|
@@ -32,6 +34,7 @@ export declare class MunicipalitySearch extends Component<Props, State> {
|
|
|
32
34
|
static defaultProps: {
|
|
33
35
|
municipalityData: string;
|
|
34
36
|
locale: string;
|
|
37
|
+
numberOfLastSelectedMunicipalities: number;
|
|
35
38
|
};
|
|
36
39
|
state: {
|
|
37
40
|
isLoading: boolean;
|
|
@@ -45,7 +48,10 @@ export declare class MunicipalitySearch extends Component<Props, State> {
|
|
|
45
48
|
private removeDuplicates;
|
|
46
49
|
private handleSearchChange;
|
|
47
50
|
private sendToDataPipeline;
|
|
48
|
-
|
|
51
|
+
private pushToLocalStorageArray;
|
|
52
|
+
private getMunicipalitiesData;
|
|
53
|
+
componentDidUpdate(prevProps: Props): void;
|
|
54
|
+
componentDidMount(): void;
|
|
49
55
|
render(): JSX.Element;
|
|
50
56
|
}
|
|
51
57
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"municipalitySearch.d.ts","sourceRoot":"","sources":["src/municipalitySearch.tsx"],"names":[],"mappings":"AACA,OAAc,EAAe,SAAS,EAAE,MAAM,OAAO,CAAA;AACrD,OAAO,8DAA8D,CAAA;AACrE,OAAO,+DAA+D,CAAA;AACtE,OAAO,+DAA+D,CAAA;AAsBtE,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;CAC9B;AAED,MAAM,WAAW,KAAK;IAGpB,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IAGxC,kCAAkC,CAAC,EAAE,MAAM,CAAA;CAC5C;AAED,UAAU,KAAK;IACb,SAAS,EAAE,OAAO,CAAA;IAClB,OAAO,EAAE,YAAY,EAAE,CAAA;IACvB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EACD,IAAI,GACJ,sBAAsB,GACtB,uBAAuB,GACvB,mCAAmC,CAAA;IACvC,cAAc,EAAE,YAAY,EAAE,CAAA;CAC/B;AAsDD,qBAAa,kBAAmB,SAAQ,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC;IAC7D,OAAc,YAAY;;;;MAIzB;IAEM,KAAK;;;;;;MAMX;IAED,OAAO,CAAC,cAAc,CAMrB;IAED,OAAO,CAAC,UAAU,CA0DjB;IAED,OAAO,CAAC,gBAAgB;IAkCxB,OAAO,CAAC,kBAAkB,CAezB;IAOD,OAAO,CAAC,kBAAkB,CAgBzB;IAED,OAAO,CAAC,uBAAuB,CAqB9B;IAED,OAAO,CAAC,qBAAqB,CAuC5B;IAEM,kBAAkB,CAAC,SAAS,EAAE,KAAK;IAUnC,iBAAiB;IAqBjB,MAAM;CA0Hd"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ta-interaktiv/react-municipality-search",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "React component that allows searching for Swiss municipalities with either ZIP code or place names.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"url": "https://gitlab.com/ta-interaktiv/packages/issues"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
+
"@ta-interaktiv/semantic-ui": "^3.3.3",
|
|
47
48
|
"intl-messageformat": "^2.2.0",
|
|
48
49
|
"react-spring": "^8.0.19"
|
|
49
50
|
},
|
|
@@ -52,5 +53,5 @@
|
|
|
52
53
|
"react": ">=16.0.0",
|
|
53
54
|
"react-dom": ">=16.0.0"
|
|
54
55
|
},
|
|
55
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "1a2b9e052efec5d218999ec99dbaa8a008e0c153"
|
|
56
57
|
}
|
|
@@ -7,7 +7,7 @@ import styles from './styles.module.scss'
|
|
|
7
7
|
import {
|
|
8
8
|
animated,
|
|
9
9
|
config as springConfig,
|
|
10
|
-
Transition
|
|
10
|
+
Transition,
|
|
11
11
|
} from 'react-spring/renderprops.cjs.js'
|
|
12
12
|
import IntlMessageFormat from 'intl-messageformat'
|
|
13
13
|
import de from './locales/de.yml'
|
|
@@ -57,6 +57,12 @@ export interface Props {
|
|
|
57
57
|
|
|
58
58
|
/** Placeholder text */
|
|
59
59
|
placeholder?: string
|
|
60
|
+
|
|
61
|
+
/** Show the last selected municipalities the user clicked on */
|
|
62
|
+
showLastSelectedMunicipalities?: boolean
|
|
63
|
+
|
|
64
|
+
/** How many of the last selected municipalities the user clicked on */
|
|
65
|
+
numberOfLastSelectedMunicipalities?: number
|
|
60
66
|
}
|
|
61
67
|
|
|
62
68
|
interface State {
|
|
@@ -126,7 +132,8 @@ function showResults(results: any[]) {
|
|
|
126
132
|
export class MunicipalitySearch extends Component<Props, State> {
|
|
127
133
|
public static defaultProps = {
|
|
128
134
|
municipalityData: '2021v3',
|
|
129
|
-
locale: 'de'
|
|
135
|
+
locale: 'de',
|
|
136
|
+
numberOfLastSelectedMunicipalities: 1,
|
|
130
137
|
}
|
|
131
138
|
|
|
132
139
|
public state = {
|
|
@@ -134,14 +141,14 @@ export class MunicipalitySearch extends Component<Props, State> {
|
|
|
134
141
|
results: [],
|
|
135
142
|
value: '',
|
|
136
143
|
error: null,
|
|
137
|
-
municipalities: []
|
|
144
|
+
municipalities: [],
|
|
138
145
|
}
|
|
139
146
|
|
|
140
147
|
private resetComponent = () => {
|
|
141
148
|
this.setState({
|
|
142
149
|
isLoading: false,
|
|
143
150
|
results: [],
|
|
144
|
-
value: ''
|
|
151
|
+
value: '',
|
|
145
152
|
})
|
|
146
153
|
}
|
|
147
154
|
|
|
@@ -198,7 +205,7 @@ export class MunicipalitySearch extends Component<Props, State> {
|
|
|
198
205
|
window.dataLayer.push({
|
|
199
206
|
event: 'Interactions',
|
|
200
207
|
event_action: 'input',
|
|
201
|
-
event_label: `search:for_${searchTerm}:results_${results.length}
|
|
208
|
+
event_label: `search:for_${searchTerm}:results_${results.length}`,
|
|
202
209
|
})
|
|
203
210
|
}
|
|
204
211
|
|
|
@@ -210,7 +217,7 @@ export class MunicipalitySearch extends Component<Props, State> {
|
|
|
210
217
|
searchTerm: string
|
|
211
218
|
): Municipality[] {
|
|
212
219
|
const map = new Map()
|
|
213
|
-
arr.forEach(v => {
|
|
220
|
+
arr.forEach((v) => {
|
|
214
221
|
if (this.props.dedupe) {
|
|
215
222
|
map.set(v.ORTNAME + v.GDENR, v)
|
|
216
223
|
} else {
|
|
@@ -269,26 +276,48 @@ export class MunicipalitySearch extends Component<Props, State> {
|
|
|
269
276
|
.fetch(url, {
|
|
270
277
|
method: 'GET',
|
|
271
278
|
mode: 'no-cors',
|
|
272
|
-
credentials: 'include'
|
|
279
|
+
credentials: 'include',
|
|
273
280
|
})
|
|
274
|
-
.then(response => {
|
|
281
|
+
.then((response) => {
|
|
275
282
|
console.log(response)
|
|
276
283
|
})
|
|
277
|
-
.catch(error => {
|
|
284
|
+
.catch((error) => {
|
|
278
285
|
console.log(error)
|
|
279
286
|
})
|
|
280
287
|
}
|
|
281
288
|
|
|
282
|
-
|
|
289
|
+
private pushToLocalStorageArray = (newMuni: Municipality) => {
|
|
290
|
+
const localStorageItemName =
|
|
291
|
+
'selectedMunicipalities_' + this.props.municipalityData
|
|
292
|
+
const prevSelectedMunicipalities =
|
|
293
|
+
localStorage.getItem(localStorageItemName) ?? JSON.stringify([])
|
|
294
|
+
const newArray = JSON.parse(prevSelectedMunicipalities)
|
|
295
|
+
// limit the number of stored municipalities
|
|
296
|
+
const slicedArray = newArray.slice(0, 15)
|
|
297
|
+
slicedArray.unshift(newMuni)
|
|
298
|
+
// deduplicate the array and stringify it for localStorage
|
|
299
|
+
localStorage.setItem(
|
|
300
|
+
localStorageItemName,
|
|
301
|
+
JSON.stringify([
|
|
302
|
+
...new Map(
|
|
303
|
+
slicedArray.map((muni: Municipality) => [
|
|
304
|
+
muni.ORTNAME + muni.GDENR,
|
|
305
|
+
muni,
|
|
306
|
+
])
|
|
307
|
+
).values(),
|
|
308
|
+
])
|
|
309
|
+
)
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
private getMunicipalitiesData = () => {
|
|
313
|
+
this.setState({
|
|
314
|
+
isLoading: true,
|
|
315
|
+
})
|
|
283
316
|
|
|
284
|
-
/** Component mounting */
|
|
285
|
-
public componentDidMount() {
|
|
286
|
-
// Download municipalities list
|
|
287
|
-
// This is a preliminary measure, before we get a proper API
|
|
288
317
|
return fetch(
|
|
289
318
|
`https://interaktiv.tagesanzeiger.ch/static/gemeindesuche/${this.props.municipalityData}.json`
|
|
290
319
|
)
|
|
291
|
-
.then(res => {
|
|
320
|
+
.then((res) => {
|
|
292
321
|
if (!res.ok) {
|
|
293
322
|
throw new MunicipalityDownloadError(
|
|
294
323
|
`Download error: ${res.status}: ${res.statusText}.`
|
|
@@ -296,13 +325,13 @@ export class MunicipalitySearch extends Component<Props, State> {
|
|
|
296
325
|
}
|
|
297
326
|
return res.json()
|
|
298
327
|
})
|
|
299
|
-
.then(data => {
|
|
328
|
+
.then((data) => {
|
|
300
329
|
this.setState({
|
|
301
330
|
isLoading: false,
|
|
302
|
-
municipalities: data
|
|
331
|
+
municipalities: data,
|
|
303
332
|
})
|
|
304
333
|
})
|
|
305
|
-
.catch(error => {
|
|
334
|
+
.catch((error) => {
|
|
306
335
|
if (error instanceof MunicipalityDownloadError) {
|
|
307
336
|
console.log(error)
|
|
308
337
|
console.info(
|
|
@@ -313,7 +342,7 @@ export class MunicipalitySearch extends Component<Props, State> {
|
|
|
313
342
|
)
|
|
314
343
|
this.setState({
|
|
315
344
|
isLoading: false,
|
|
316
|
-
error: 'error.municipalitiesNotDownloaded'
|
|
345
|
+
error: 'error.municipalitiesNotDownloaded',
|
|
317
346
|
})
|
|
318
347
|
} else {
|
|
319
348
|
throw error
|
|
@@ -321,6 +350,37 @@ export class MunicipalitySearch extends Component<Props, State> {
|
|
|
321
350
|
})
|
|
322
351
|
}
|
|
323
352
|
|
|
353
|
+
public componentDidUpdate(prevProps: Props) {
|
|
354
|
+
if (prevProps.municipalityData !== this.props.municipalityData) {
|
|
355
|
+
this.resetComponent()
|
|
356
|
+
this.getMunicipalitiesData()
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// region React Component Lifecycle
|
|
361
|
+
|
|
362
|
+
/** Component mounting */
|
|
363
|
+
public componentDidMount() {
|
|
364
|
+
// set the municipalities from localStorage as results
|
|
365
|
+
const locallyStoredMunicipalitiesArray = localStorage.getItem(
|
|
366
|
+
'selectedMunicipalities_' + this.props.municipalityData
|
|
367
|
+
)
|
|
368
|
+
if (
|
|
369
|
+
this.props.showLastSelectedMunicipalities &&
|
|
370
|
+
locallyStoredMunicipalitiesArray
|
|
371
|
+
) {
|
|
372
|
+
const parsed = JSON.parse(
|
|
373
|
+
locallyStoredMunicipalitiesArray
|
|
374
|
+
) as Municipality[]
|
|
375
|
+
const muniCount = this.props.numberOfLastSelectedMunicipalities ?? 1
|
|
376
|
+
this.setState({ results: parsed.slice(0, muniCount) })
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// Download municipalities list
|
|
380
|
+
// This is a preliminary measure, before we get a proper API
|
|
381
|
+
this.getMunicipalitiesData()
|
|
382
|
+
}
|
|
383
|
+
|
|
324
384
|
public render() {
|
|
325
385
|
const { isLoading, value, results } = this.state
|
|
326
386
|
|
|
@@ -387,7 +447,7 @@ export class MunicipalitySearch extends Component<Props, State> {
|
|
|
387
447
|
</div>
|
|
388
448
|
{showResults(results) && (
|
|
389
449
|
<div className={`results ${styles.results}`}>
|
|
390
|
-
{
|
|
450
|
+
{showResults(results) && (
|
|
391
451
|
<Transition
|
|
392
452
|
native
|
|
393
453
|
items={results}
|
|
@@ -399,37 +459,41 @@ export class MunicipalitySearch extends Component<Props, State> {
|
|
|
399
459
|
leave={{ transform: 'translate(0, 60px)', opacity: 0 }}
|
|
400
460
|
config={springConfig.gentle}
|
|
401
461
|
>
|
|
402
|
-
{result => props =>
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
// this.sendToDataPipeline(result.PLZ4)
|
|
407
|
-
if (this.props.resetOnSelect) {
|
|
408
|
-
this.resetComponent()
|
|
409
|
-
}
|
|
410
|
-
}}
|
|
411
|
-
onKeyUp={e => {
|
|
412
|
-
if (e.key === 'Enter' || e.key === 'Space') {
|
|
462
|
+
{(result) => (props) =>
|
|
463
|
+
(
|
|
464
|
+
<animated.div
|
|
465
|
+
onClick={() => {
|
|
413
466
|
this.props.onSelectionHandler(result)
|
|
414
467
|
// this.sendToDataPipeline(result.PLZ4)
|
|
468
|
+
if (this.props.showLastSelectedMunicipalities) {
|
|
469
|
+
this.pushToLocalStorageArray(result)
|
|
470
|
+
}
|
|
415
471
|
if (this.props.resetOnSelect) {
|
|
416
472
|
this.resetComponent()
|
|
417
473
|
}
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
{
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
474
|
+
}}
|
|
475
|
+
onKeyUp={(e) => {
|
|
476
|
+
if (e.key === 'Enter' || e.key === 'Space') {
|
|
477
|
+
this.props.onSelectionHandler(result)
|
|
478
|
+
// this.sendToDataPipeline(result.PLZ4)
|
|
479
|
+
if (this.props.resetOnSelect) {
|
|
480
|
+
this.resetComponent()
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}}
|
|
484
|
+
className={`result ${styles.result}`}
|
|
485
|
+
style={props}
|
|
486
|
+
tabIndex={0}
|
|
487
|
+
>
|
|
488
|
+
<div className={styles.resultHeader}>
|
|
489
|
+
<span className={styles.resultPlz}>{result.PLZ4}</span>{' '}
|
|
490
|
+
{result.ORTNAME}
|
|
491
|
+
</div>
|
|
492
|
+
<div className={styles.resultMeta}>
|
|
493
|
+
{t('list.municipalityPrefix')} {result.GDENAMK}
|
|
494
|
+
</div>
|
|
495
|
+
</animated.div>
|
|
496
|
+
)}
|
|
433
497
|
</Transition>
|
|
434
498
|
)}
|
|
435
499
|
</div>
|