@pretto/places 0.9.0 → 0.12.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/dist/addressSearch.d.ts
CHANGED
|
@@ -1,26 +1,17 @@
|
|
|
1
|
-
interface AddressSearchResult {
|
|
2
|
-
label: string;
|
|
3
|
-
value: {
|
|
4
|
-
city: string;
|
|
5
|
-
country: string;
|
|
6
|
-
street: string;
|
|
7
|
-
zipcode: string;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
1
|
export interface AddressApiResult {
|
|
11
2
|
properties: {
|
|
12
3
|
label: string;
|
|
4
|
+
name: string;
|
|
13
5
|
postcode: string;
|
|
14
6
|
city: string;
|
|
15
|
-
housenumber
|
|
16
|
-
street
|
|
7
|
+
housenumber?: string;
|
|
8
|
+
street?: string;
|
|
17
9
|
};
|
|
18
10
|
}
|
|
19
11
|
interface Options {
|
|
20
12
|
country: string;
|
|
21
13
|
limit: number;
|
|
22
14
|
}
|
|
23
|
-
declare
|
|
24
|
-
export declare const get: AddressSearch;
|
|
15
|
+
export declare const get: (search: string, options?: Options | undefined, debounceValue?: 300 | undefined) => number;
|
|
25
16
|
export {};
|
|
26
17
|
//# sourceMappingURL=addressSearch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addressSearch.d.ts","sourceRoot":"","sources":["../src/addressSearch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"addressSearch.d.ts","sourceRoot":"","sources":["../src/addressSearch.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE;QACV,KAAK,EAAE,MAAM,CAAA;QACb,IAAI,EAAE,MAAM,CAAA;QACZ,QAAQ,EAAE,MAAM,CAAA;QAChB,IAAI,EAAE,MAAM,CAAA;QACZ,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF;AAED,UAAU,OAAO;IACf,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;CACd;AAuCD,eAAO,MAAM,GAAG,WAAY,MAAM,2EAQjC,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -100,7 +100,7 @@ const responseFormat = (places, country, search, departmentOnly) => {
|
|
|
100
100
|
});
|
|
101
101
|
return flat__default["default"](allPlaces);
|
|
102
102
|
};
|
|
103
|
-
const
|
|
103
|
+
const getData$1 = (search, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
104
104
|
const { country = 'fr', limit = 5, departmentOnly = false } = options || {};
|
|
105
105
|
const isNumber = !isNaN(parseInt(search, 10));
|
|
106
106
|
if (!search || (isNumber && search.length < 2))
|
|
@@ -133,13 +133,22 @@ const get$2 = (search, options) => __awaiter(void 0, void 0, void 0, function* (
|
|
|
133
133
|
return 'An error occurred.';
|
|
134
134
|
}
|
|
135
135
|
});
|
|
136
|
+
let getDelayedData$1;
|
|
137
|
+
const get$2 = (search, options, debounceValue) => {
|
|
138
|
+
clearTimeout(getDelayedData$1);
|
|
139
|
+
getDelayedData$1 = setTimeout(() => {
|
|
140
|
+
getData$1(search, options);
|
|
141
|
+
}, debounceValue);
|
|
142
|
+
return getDelayedData$1;
|
|
143
|
+
};
|
|
136
144
|
|
|
137
145
|
var municipalitySearch = /*#__PURE__*/Object.freeze({
|
|
138
146
|
__proto__: null,
|
|
147
|
+
getData: getData$1,
|
|
139
148
|
get: get$2
|
|
140
149
|
});
|
|
141
150
|
|
|
142
|
-
const
|
|
151
|
+
const getData = (search, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
143
152
|
if (!search)
|
|
144
153
|
return [];
|
|
145
154
|
try {
|
|
@@ -150,16 +159,14 @@ const get$1 = (search, options) => __awaiter(void 0, void 0, void 0, function* (
|
|
|
150
159
|
return Promise.reject(response);
|
|
151
160
|
const result = yield response.json();
|
|
152
161
|
return result.features.reduce((acc, { properties }) => {
|
|
153
|
-
if (!properties.street)
|
|
154
|
-
return acc;
|
|
155
162
|
return [
|
|
156
163
|
...acc,
|
|
157
164
|
{
|
|
158
|
-
label: `${properties.
|
|
165
|
+
label: `${properties.name} (${properties.postcode})`,
|
|
159
166
|
value: {
|
|
160
167
|
city: properties.city,
|
|
161
168
|
country,
|
|
162
|
-
street: `${properties.
|
|
169
|
+
street: `${properties.name}`,
|
|
163
170
|
zipcode: properties.postcode,
|
|
164
171
|
},
|
|
165
172
|
},
|
|
@@ -174,6 +181,14 @@ const get$1 = (search, options) => __awaiter(void 0, void 0, void 0, function* (
|
|
|
174
181
|
return 'An error occurred.';
|
|
175
182
|
}
|
|
176
183
|
});
|
|
184
|
+
let getDelayedData;
|
|
185
|
+
const get$1 = (search, options, debounceValue) => {
|
|
186
|
+
clearTimeout(getDelayedData);
|
|
187
|
+
getDelayedData = setTimeout(() => {
|
|
188
|
+
getData(search, options);
|
|
189
|
+
}, debounceValue);
|
|
190
|
+
return getDelayedData;
|
|
191
|
+
};
|
|
177
192
|
|
|
178
193
|
var addressSearch = /*#__PURE__*/Object.freeze({
|
|
179
194
|
__proto__: null,
|
package/dist/module.js
CHANGED
|
@@ -90,7 +90,7 @@ const responseFormat = (places, country, search, departmentOnly) => {
|
|
|
90
90
|
});
|
|
91
91
|
return flat(allPlaces);
|
|
92
92
|
};
|
|
93
|
-
const
|
|
93
|
+
const getData$1 = (search, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
94
94
|
const { country = 'fr', limit = 5, departmentOnly = false } = options || {};
|
|
95
95
|
const isNumber = !isNaN(parseInt(search, 10));
|
|
96
96
|
if (!search || (isNumber && search.length < 2))
|
|
@@ -123,13 +123,22 @@ const get$2 = (search, options) => __awaiter(void 0, void 0, void 0, function* (
|
|
|
123
123
|
return 'An error occurred.';
|
|
124
124
|
}
|
|
125
125
|
});
|
|
126
|
+
let getDelayedData$1;
|
|
127
|
+
const get$2 = (search, options, debounceValue) => {
|
|
128
|
+
clearTimeout(getDelayedData$1);
|
|
129
|
+
getDelayedData$1 = setTimeout(() => {
|
|
130
|
+
getData$1(search, options);
|
|
131
|
+
}, debounceValue);
|
|
132
|
+
return getDelayedData$1;
|
|
133
|
+
};
|
|
126
134
|
|
|
127
135
|
var municipalitySearch = /*#__PURE__*/Object.freeze({
|
|
128
136
|
__proto__: null,
|
|
137
|
+
getData: getData$1,
|
|
129
138
|
get: get$2
|
|
130
139
|
});
|
|
131
140
|
|
|
132
|
-
const
|
|
141
|
+
const getData = (search, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
133
142
|
if (!search)
|
|
134
143
|
return [];
|
|
135
144
|
try {
|
|
@@ -140,16 +149,14 @@ const get$1 = (search, options) => __awaiter(void 0, void 0, void 0, function* (
|
|
|
140
149
|
return Promise.reject(response);
|
|
141
150
|
const result = yield response.json();
|
|
142
151
|
return result.features.reduce((acc, { properties }) => {
|
|
143
|
-
if (!properties.street)
|
|
144
|
-
return acc;
|
|
145
152
|
return [
|
|
146
153
|
...acc,
|
|
147
154
|
{
|
|
148
|
-
label: `${properties.
|
|
155
|
+
label: `${properties.name} (${properties.postcode})`,
|
|
149
156
|
value: {
|
|
150
157
|
city: properties.city,
|
|
151
158
|
country,
|
|
152
|
-
street: `${properties.
|
|
159
|
+
street: `${properties.name}`,
|
|
153
160
|
zipcode: properties.postcode,
|
|
154
161
|
},
|
|
155
162
|
},
|
|
@@ -164,6 +171,14 @@ const get$1 = (search, options) => __awaiter(void 0, void 0, void 0, function* (
|
|
|
164
171
|
return 'An error occurred.';
|
|
165
172
|
}
|
|
166
173
|
});
|
|
174
|
+
let getDelayedData;
|
|
175
|
+
const get$1 = (search, options, debounceValue) => {
|
|
176
|
+
clearTimeout(getDelayedData);
|
|
177
|
+
getDelayedData = setTimeout(() => {
|
|
178
|
+
getData(search, options);
|
|
179
|
+
}, debounceValue);
|
|
180
|
+
return getDelayedData;
|
|
181
|
+
};
|
|
167
182
|
|
|
168
183
|
var addressSearch = /*#__PURE__*/Object.freeze({
|
|
169
184
|
__proto__: null,
|
|
@@ -20,6 +20,7 @@ interface Options {
|
|
|
20
20
|
departmentOnly?: boolean;
|
|
21
21
|
}
|
|
22
22
|
declare type MunicipalitySearch = (search: string, options?: Options) => Promise<MunicipalitySearchResult[] | string>;
|
|
23
|
-
export declare const
|
|
23
|
+
export declare const getData: MunicipalitySearch;
|
|
24
|
+
export declare const get: (search: string, options?: Options | undefined, debounceValue?: 300 | undefined) => number;
|
|
24
25
|
export {};
|
|
25
26
|
//# sourceMappingURL=municipalitySearch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"municipalitySearch.d.ts","sourceRoot":"","sources":["../src/municipalitySearch.ts"],"names":[],"mappings":"AAKA,UAAU,wBAAwB;IAChC,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,EAAE,MAAM,CAAA;QACf,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;CACF;AAED,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,MAAM,CAAA;IACX,WAAW,CAAC,EAAE;QACZ,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,EAAE,MAAM,CAAA;KACZ,CAAA;IACD,YAAY,EAAE,MAAM,EAAE,CAAA;CACvB;AAED,UAAU,OAAO;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB;AAED,aAAK,kBAAkB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,wBAAwB,EAAE,GAAG,MAAM,CAAC,CAAA;AAmD7G,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"municipalitySearch.d.ts","sourceRoot":"","sources":["../src/municipalitySearch.ts"],"names":[],"mappings":"AAKA,UAAU,wBAAwB;IAChC,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,EAAE,MAAM,CAAA;QACf,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;CACF;AAED,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,MAAM,CAAA;IACX,WAAW,CAAC,EAAE;QACZ,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,EAAE,MAAM,CAAA;KACZ,CAAA;IACD,YAAY,EAAE,MAAM,EAAE,CAAA;CACvB;AAED,UAAU,OAAO;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB;AAED,aAAK,kBAAkB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,wBAAwB,EAAE,GAAG,MAAM,CAAC,CAAA;AAmD7G,eAAO,MAAM,OAAO,EAAE,kBAoCrB,CAAA;AAID,eAAO,MAAM,GAAG,WAAY,MAAM,2EAQjC,CAAA"}
|