@uxf/smart-address 1.0.0-beta.109
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/README.md +5 -0
- package/config.d.ts +1 -0
- package/config.js +4 -0
- package/package.json +17 -0
- package/v1/create-address-loader.d.ts +9 -0
- package/v1/create-address-loader.js +14 -0
- package/v1/create-zip-loader.d.ts +6 -0
- package/v1/create-zip-loader.js +11 -0
- package/v1/get-address-extended.d.ts +2 -0
- package/v1/get-address-extended.js +8 -0
- package/v1/get-address.d.ts +2 -0
- package/v1/get-address.js +9 -0
- package/v1/get-city-part.d.ts +2 -0
- package/v1/get-city-part.js +9 -0
- package/v1/get-city.d.ts +2 -0
- package/v1/get-city.js +9 -0
- package/v1/get-momc.d.ts +2 -0
- package/v1/get-momc.js +9 -0
- package/v1/get-mop.d.ts +2 -0
- package/v1/get-mop.js +9 -0
- package/v1/get-street.d.ts +2 -0
- package/v1/get-street.js +9 -0
- package/v1/index.d.ts +14 -0
- package/v1/index.js +29 -0
- package/v1/load-address-options.d.ts +10 -0
- package/v1/load-address-options.js +15 -0
- package/v1/load-zip-options.d.ts +7 -0
- package/v1/load-zip-options.js +14 -0
- package/v1/search-zip.d.ts +2 -0
- package/v1/search-zip.js +12 -0
- package/v1/search.d.ts +9 -0
- package/v1/search.js +22 -0
- package/v1/types.d.ts +89 -0
- package/v1/types.js +2 -0
- package/v1/v1.stories.d.ts +6 -0
- package/v1/v1.stories.js +97 -0
package/README.md
ADDED
package/config.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const smartAddressUrl = "https://www.smart-address.cz/api";
|
package/config.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@uxf/smart-address",
|
|
3
|
+
"version": "1.0.0-beta.109",
|
|
4
|
+
"description": "",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "npm run compile",
|
|
10
|
+
"compile": "tsc -P tsconfig.json",
|
|
11
|
+
"typecheck": "../../node_modules/.bin/tsc --noEmit --skipLibCheck"
|
|
12
|
+
},
|
|
13
|
+
"author": "UX Fans s.r.o",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"dependencies": {},
|
|
16
|
+
"devDependencies": {}
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Location, Option } from "./types";
|
|
2
|
+
declare type Params = {
|
|
3
|
+
level: number;
|
|
4
|
+
limit?: number;
|
|
5
|
+
zip?: number;
|
|
6
|
+
getLabel?: (address: Location) => string;
|
|
7
|
+
};
|
|
8
|
+
export declare const createAddressLoader: (params: Params) => (term: string) => Promise<Option[]>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAddressLoader = void 0;
|
|
4
|
+
const load_address_options_1 = require("./load-address-options");
|
|
5
|
+
const createAddressLoader = (params) => {
|
|
6
|
+
return (term) => (0, load_address_options_1.loadAddressOptions)({
|
|
7
|
+
term,
|
|
8
|
+
level: params.level,
|
|
9
|
+
limit: params.limit,
|
|
10
|
+
zip: params.zip,
|
|
11
|
+
getLabel: params.getLabel,
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
exports.createAddressLoader = createAddressLoader;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createZipLoader = void 0;
|
|
4
|
+
const load_zip_options_1 = require("./load-zip-options");
|
|
5
|
+
const createZipLoader = (params) => {
|
|
6
|
+
return (term) => (0, load_zip_options_1.loadZipOptions)({
|
|
7
|
+
term,
|
|
8
|
+
getLabel: params.getLabel,
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
exports.createZipLoader = createZipLoader;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAddressExtended = void 0;
|
|
4
|
+
const getAddressExtended = async (id) => {
|
|
5
|
+
const response = await fetch("https://www.smart-address.cz/api/v1/address/" + id + "/extended");
|
|
6
|
+
return JSON.parse(await response.text());
|
|
7
|
+
};
|
|
8
|
+
exports.getAddressExtended = getAddressExtended;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAddress = void 0;
|
|
4
|
+
const config_1 = require("../config");
|
|
5
|
+
const getAddress = async (id) => {
|
|
6
|
+
const response = await fetch(config_1.smartAddressUrl + "/v1/address/" + id);
|
|
7
|
+
return JSON.parse(await response.text());
|
|
8
|
+
};
|
|
9
|
+
exports.getAddress = getAddress;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCityPart = void 0;
|
|
4
|
+
const config_1 = require("../config");
|
|
5
|
+
const getCityPart = async (id) => {
|
|
6
|
+
const response = await fetch(config_1.smartAddressUrl + "/v1/address/city-part/" + id);
|
|
7
|
+
return JSON.parse(await response.text());
|
|
8
|
+
};
|
|
9
|
+
exports.getCityPart = getCityPart;
|
package/v1/get-city.d.ts
ADDED
package/v1/get-city.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCity = void 0;
|
|
4
|
+
const config_1 = require("../config");
|
|
5
|
+
const getCity = async (id) => {
|
|
6
|
+
const response = await fetch(config_1.smartAddressUrl + "/v1/address/city/" + id);
|
|
7
|
+
return JSON.parse(await response.text());
|
|
8
|
+
};
|
|
9
|
+
exports.getCity = getCity;
|
package/v1/get-momc.d.ts
ADDED
package/v1/get-momc.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMomc = void 0;
|
|
4
|
+
const config_1 = require("../config");
|
|
5
|
+
const getMomc = async (id) => {
|
|
6
|
+
const response = await fetch(config_1.smartAddressUrl + "/v1/address/momc/" + id);
|
|
7
|
+
return JSON.parse(await response.text());
|
|
8
|
+
};
|
|
9
|
+
exports.getMomc = getMomc;
|
package/v1/get-mop.d.ts
ADDED
package/v1/get-mop.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMop = void 0;
|
|
4
|
+
const config_1 = require("../config");
|
|
5
|
+
const getMop = async (id) => {
|
|
6
|
+
const response = await fetch(config_1.smartAddressUrl + "/v1/address/mop/" + id);
|
|
7
|
+
return JSON.parse(await response.text());
|
|
8
|
+
};
|
|
9
|
+
exports.getMop = getMop;
|
package/v1/get-street.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getStreet = void 0;
|
|
4
|
+
const config_1 = require("../config");
|
|
5
|
+
const getStreet = async (id) => {
|
|
6
|
+
const response = await fetch(config_1.smartAddressUrl + "/v1/address/street/" + id);
|
|
7
|
+
return JSON.parse(await response.text());
|
|
8
|
+
};
|
|
9
|
+
exports.getStreet = getStreet;
|
package/v1/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { search } from "./search";
|
|
2
|
+
export { searchZip } from "./search-zip";
|
|
3
|
+
export { getAddress } from "./get-address";
|
|
4
|
+
export { getAddressExtended } from "./get-address-extended";
|
|
5
|
+
export { getCity } from "./get-city";
|
|
6
|
+
export { getCityPart } from "./get-city-part";
|
|
7
|
+
export { getMomc } from "./get-momc";
|
|
8
|
+
export { getMop } from "./get-mop";
|
|
9
|
+
export { getStreet } from "./get-street";
|
|
10
|
+
export { loadAddressOptions } from "./load-address-options";
|
|
11
|
+
export { loadZipOptions } from "./load-zip-options";
|
|
12
|
+
export { createAddressLoader } from "./create-address-loader";
|
|
13
|
+
export { createZipLoader } from "./create-zip-loader";
|
|
14
|
+
export type { ObjectType, ObjectTypeBasic, BuildingType, BuildingUsageType, ConstructionType, ElevatorType, HeatingType, GasConnectionType, SewerConnectionType, WaterConnectionType, Point, Location, LocationExtended, } from "./types";
|
package/v1/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createZipLoader = exports.createAddressLoader = exports.loadZipOptions = exports.loadAddressOptions = exports.getStreet = exports.getMop = exports.getMomc = exports.getCityPart = exports.getCity = exports.getAddressExtended = exports.getAddress = exports.searchZip = exports.search = void 0;
|
|
4
|
+
var search_1 = require("./search");
|
|
5
|
+
Object.defineProperty(exports, "search", { enumerable: true, get: function () { return search_1.search; } });
|
|
6
|
+
var search_zip_1 = require("./search-zip");
|
|
7
|
+
Object.defineProperty(exports, "searchZip", { enumerable: true, get: function () { return search_zip_1.searchZip; } });
|
|
8
|
+
var get_address_1 = require("./get-address");
|
|
9
|
+
Object.defineProperty(exports, "getAddress", { enumerable: true, get: function () { return get_address_1.getAddress; } });
|
|
10
|
+
var get_address_extended_1 = require("./get-address-extended");
|
|
11
|
+
Object.defineProperty(exports, "getAddressExtended", { enumerable: true, get: function () { return get_address_extended_1.getAddressExtended; } });
|
|
12
|
+
var get_city_1 = require("./get-city");
|
|
13
|
+
Object.defineProperty(exports, "getCity", { enumerable: true, get: function () { return get_city_1.getCity; } });
|
|
14
|
+
var get_city_part_1 = require("./get-city-part");
|
|
15
|
+
Object.defineProperty(exports, "getCityPart", { enumerable: true, get: function () { return get_city_part_1.getCityPart; } });
|
|
16
|
+
var get_momc_1 = require("./get-momc");
|
|
17
|
+
Object.defineProperty(exports, "getMomc", { enumerable: true, get: function () { return get_momc_1.getMomc; } });
|
|
18
|
+
var get_mop_1 = require("./get-mop");
|
|
19
|
+
Object.defineProperty(exports, "getMop", { enumerable: true, get: function () { return get_mop_1.getMop; } });
|
|
20
|
+
var get_street_1 = require("./get-street");
|
|
21
|
+
Object.defineProperty(exports, "getStreet", { enumerable: true, get: function () { return get_street_1.getStreet; } });
|
|
22
|
+
var load_address_options_1 = require("./load-address-options");
|
|
23
|
+
Object.defineProperty(exports, "loadAddressOptions", { enumerable: true, get: function () { return load_address_options_1.loadAddressOptions; } });
|
|
24
|
+
var load_zip_options_1 = require("./load-zip-options");
|
|
25
|
+
Object.defineProperty(exports, "loadZipOptions", { enumerable: true, get: function () { return load_zip_options_1.loadZipOptions; } });
|
|
26
|
+
var create_address_loader_1 = require("./create-address-loader");
|
|
27
|
+
Object.defineProperty(exports, "createAddressLoader", { enumerable: true, get: function () { return create_address_loader_1.createAddressLoader; } });
|
|
28
|
+
var create_zip_loader_1 = require("./create-zip-loader");
|
|
29
|
+
Object.defineProperty(exports, "createZipLoader", { enumerable: true, get: function () { return create_zip_loader_1.createZipLoader; } });
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Location, Option } from "./types";
|
|
2
|
+
declare type Params = {
|
|
3
|
+
term: string;
|
|
4
|
+
level: number;
|
|
5
|
+
limit?: number;
|
|
6
|
+
zip?: number;
|
|
7
|
+
getLabel?: (address: Location) => string;
|
|
8
|
+
};
|
|
9
|
+
export declare const loadAddressOptions: (params: Params) => Promise<Option[]>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadAddressOptions = void 0;
|
|
4
|
+
const search_1 = require("./search");
|
|
5
|
+
const loadAddressOptions = async (params) => {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
const limit = (_a = params.limit) !== null && _a !== void 0 ? _a : 10;
|
|
8
|
+
const getLabel = (_b = params.getLabel) !== null && _b !== void 0 ? _b : ((address) => `${address.ulice}, ${address.obec}`);
|
|
9
|
+
if (params.term.length === 0) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
const response = await (0, search_1.search)({ term: params.term, level: params.level, limit, zip: params.zip });
|
|
13
|
+
return response.map((a) => ({ id: a.id, label: getLabel(a) }));
|
|
14
|
+
};
|
|
15
|
+
exports.loadAddressOptions = loadAddressOptions;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadZipOptions = void 0;
|
|
4
|
+
const search_zip_1 = require("./search-zip");
|
|
5
|
+
const loadZipOptions = async (params) => {
|
|
6
|
+
var _a;
|
|
7
|
+
const getLabel = (_a = params.getLabel) !== null && _a !== void 0 ? _a : ((address) => `${address.psc}`);
|
|
8
|
+
if (params.term.length === 0) {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
const response = await (0, search_zip_1.searchZip)(params.term);
|
|
12
|
+
return response.map((a) => ({ id: a.id, label: getLabel(a) }));
|
|
13
|
+
};
|
|
14
|
+
exports.loadZipOptions = loadZipOptions;
|
package/v1/search-zip.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.searchZip = void 0;
|
|
4
|
+
const config_1 = require("../config");
|
|
5
|
+
const searchZip = async (term) => {
|
|
6
|
+
if (term.length === 0) {
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
9
|
+
const response = await fetch(config_1.smartAddressUrl + "/v1/zip/search?" + new URLSearchParams({ term: term }));
|
|
10
|
+
return JSON.parse(await response.text());
|
|
11
|
+
};
|
|
12
|
+
exports.searchZip = searchZip;
|
package/v1/search.d.ts
ADDED
package/v1/search.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.search = void 0;
|
|
4
|
+
const config_1 = require("../config");
|
|
5
|
+
const search = async (props) => {
|
|
6
|
+
var _a;
|
|
7
|
+
const limit = (_a = props.limit) !== null && _a !== void 0 ? _a : 10;
|
|
8
|
+
if (props.term.length === 0) {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
const params = new URLSearchParams({
|
|
12
|
+
term: props.term,
|
|
13
|
+
level: props.level.toString(),
|
|
14
|
+
limit: limit.toString(),
|
|
15
|
+
});
|
|
16
|
+
if (props.zip) {
|
|
17
|
+
params.append("zip", props.zip.toString());
|
|
18
|
+
}
|
|
19
|
+
const response = await fetch(config_1.smartAddressUrl + "/v1/search?" + params);
|
|
20
|
+
return JSON.parse(await response.text());
|
|
21
|
+
};
|
|
22
|
+
exports.search = search;
|
package/v1/types.d.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export declare type Option = {
|
|
2
|
+
id: number;
|
|
3
|
+
label: string;
|
|
4
|
+
};
|
|
5
|
+
export declare type Point = {
|
|
6
|
+
latitude: string;
|
|
7
|
+
longitude: string;
|
|
8
|
+
};
|
|
9
|
+
export declare type Location = {
|
|
10
|
+
id: number;
|
|
11
|
+
obecKod: number;
|
|
12
|
+
obecNazev: string | null;
|
|
13
|
+
obec: string | null;
|
|
14
|
+
momcKod: number | null;
|
|
15
|
+
momcNazev: string | null;
|
|
16
|
+
mopKod: number | null;
|
|
17
|
+
mopNazev: string | null;
|
|
18
|
+
castObceKod: number | null;
|
|
19
|
+
castObceNazev: string | null;
|
|
20
|
+
uliceKod: number | null;
|
|
21
|
+
uliceNazev: string | null;
|
|
22
|
+
ulice: string | null;
|
|
23
|
+
typSo: string | null;
|
|
24
|
+
cisloDomovni: number | null;
|
|
25
|
+
cisloOrientacni: number | null;
|
|
26
|
+
cisloOrientacniZnak: string | null;
|
|
27
|
+
psc: number | null;
|
|
28
|
+
search: string | null;
|
|
29
|
+
level: number | null;
|
|
30
|
+
gps: Point | null;
|
|
31
|
+
platiOd: string | null;
|
|
32
|
+
aktualizace: string | null;
|
|
33
|
+
okresKod: number | null;
|
|
34
|
+
okresNazev: string | null;
|
|
35
|
+
krajKod: number | null;
|
|
36
|
+
krajNazev: string | null;
|
|
37
|
+
};
|
|
38
|
+
export declare type LocationExtended = {
|
|
39
|
+
id: number;
|
|
40
|
+
distributorElektrinyKod: string | null;
|
|
41
|
+
distributorElektrinyId: number | null;
|
|
42
|
+
distributorPlynuKod: string | null;
|
|
43
|
+
distributorPlynuId: number | null;
|
|
44
|
+
typBudovy: BuildingType | null;
|
|
45
|
+
isknBudovaId: string | null;
|
|
46
|
+
druhKonstrukce: ConstructionType | null;
|
|
47
|
+
pocetBytu: number | null;
|
|
48
|
+
pocetPodlazi: number | null;
|
|
49
|
+
pripojeniKanalizace: SewerConnectionType | null;
|
|
50
|
+
pripojeniPlyn: GasConnectionType | null;
|
|
51
|
+
pripojeniVodovod: WaterConnectionType | null;
|
|
52
|
+
vybaveniVytahem: ElevatorType | null;
|
|
53
|
+
zpusobVytapeni: HeatingType | null;
|
|
54
|
+
zastavenaPlocha: number | null;
|
|
55
|
+
obestavenyProstor: number | null;
|
|
56
|
+
podlahovaPlocha: number | null;
|
|
57
|
+
stavebniObjektKod: string | null;
|
|
58
|
+
parcelaKod: string | null;
|
|
59
|
+
zpusobVyuzitiObjektu: BuildingUsageType | null;
|
|
60
|
+
createdAt: string | null;
|
|
61
|
+
updatedAt: string | null;
|
|
62
|
+
objectType: ObjectType | null;
|
|
63
|
+
objectTypeBasic: ObjectTypeBasic | null;
|
|
64
|
+
objectSize: string | null;
|
|
65
|
+
objectSizeSquare: number | null;
|
|
66
|
+
};
|
|
67
|
+
declare type BasicType = {
|
|
68
|
+
id: number;
|
|
69
|
+
nazev: string | null;
|
|
70
|
+
};
|
|
71
|
+
declare type Type = {
|
|
72
|
+
id: number;
|
|
73
|
+
nazev: string | null;
|
|
74
|
+
popis: string | null;
|
|
75
|
+
zkracenyNazev: string | null;
|
|
76
|
+
zacatekPlatnosti: string | null;
|
|
77
|
+
konecPlatnosti: string | null;
|
|
78
|
+
};
|
|
79
|
+
export declare type ObjectType = BasicType;
|
|
80
|
+
export declare type ObjectTypeBasic = BasicType;
|
|
81
|
+
export declare type BuildingType = Type;
|
|
82
|
+
export declare type ConstructionType = Type;
|
|
83
|
+
export declare type SewerConnectionType = Type;
|
|
84
|
+
export declare type GasConnectionType = Type;
|
|
85
|
+
export declare type WaterConnectionType = Type;
|
|
86
|
+
export declare type ElevatorType = Type;
|
|
87
|
+
export declare type HeatingType = Type;
|
|
88
|
+
export declare type BuildingUsageType = Type;
|
|
89
|
+
export {};
|
package/v1/types.js
ADDED
package/v1/v1.stories.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.Default = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const button_1 = require("@uxf/ui/button");
|
|
29
|
+
const text_input_1 = require("@uxf/ui/text-input");
|
|
30
|
+
const load_address_options_1 = require("./load-address-options");
|
|
31
|
+
const load_zip_options_1 = require("./load-zip-options");
|
|
32
|
+
const combobox_1 = require("@uxf/ui/combobox");
|
|
33
|
+
const create_address_loader_1 = require("./create-address-loader");
|
|
34
|
+
const create_zip_loader_1 = require("./create-zip-loader");
|
|
35
|
+
const get_address_1 = require("./get-address");
|
|
36
|
+
const get_address_extended_1 = require("./get-address-extended");
|
|
37
|
+
const get_city_1 = require("./get-city");
|
|
38
|
+
const get_city_part_1 = require("./get-city-part");
|
|
39
|
+
const get_momc_1 = require("./get-momc");
|
|
40
|
+
const get_mop_1 = require("./get-mop");
|
|
41
|
+
const get_street_1 = require("./get-street");
|
|
42
|
+
exports.default = {
|
|
43
|
+
title: "Smart address/v1",
|
|
44
|
+
};
|
|
45
|
+
function Default() {
|
|
46
|
+
const [addressValue, setAddressValue] = (0, react_1.useState)(null);
|
|
47
|
+
const [zipValue, setZipValue] = (0, react_1.useState)(null);
|
|
48
|
+
const [textValue, setTextValue] = (0, react_1.useState)("");
|
|
49
|
+
const [content, setContent] = (0, react_1.useState)([]);
|
|
50
|
+
const load = (type) => async () => {
|
|
51
|
+
switch (type) {
|
|
52
|
+
case "load-address":
|
|
53
|
+
setContent(await (0, load_address_options_1.loadAddressOptions)({ term: textValue, level: 1 }));
|
|
54
|
+
break;
|
|
55
|
+
case "load-zip":
|
|
56
|
+
setContent(await (0, load_zip_options_1.loadZipOptions)({ term: textValue }));
|
|
57
|
+
break;
|
|
58
|
+
case "get-address":
|
|
59
|
+
setContent(await (0, get_address_1.getAddress)(parseInt(textValue, 10)));
|
|
60
|
+
break;
|
|
61
|
+
case "get-address-extended":
|
|
62
|
+
setContent(await (0, get_address_extended_1.getAddressExtended)(parseInt(textValue, 10)));
|
|
63
|
+
break;
|
|
64
|
+
case "get-city":
|
|
65
|
+
setContent(await (0, get_city_1.getCity)(parseInt(textValue, 10)));
|
|
66
|
+
break;
|
|
67
|
+
case "get-city-part":
|
|
68
|
+
setContent(await (0, get_city_part_1.getCityPart)(parseInt(textValue, 10)));
|
|
69
|
+
break;
|
|
70
|
+
case "get-momc":
|
|
71
|
+
setContent(await (0, get_momc_1.getMomc)(parseInt(textValue, 10)));
|
|
72
|
+
break;
|
|
73
|
+
case "get-mop":
|
|
74
|
+
setContent(await (0, get_mop_1.getMop)(parseInt(textValue, 10)));
|
|
75
|
+
break;
|
|
76
|
+
case "get-street":
|
|
77
|
+
setContent(await (0, get_street_1.getStreet)(parseInt(textValue, 10)));
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
return (react_1.default.createElement("div", { className: "mx-auto max-w-3xl space-y-4 rounded border bg-white p-4" },
|
|
82
|
+
react_1.default.createElement(combobox_1.Combobox, { label: "Address combobox", value: addressValue, onChange: setAddressValue, loadOptions: (0, create_address_loader_1.createAddressLoader)({ level: 1 }) }),
|
|
83
|
+
react_1.default.createElement(combobox_1.Combobox, { label: "Zip combobox", value: zipValue, onChange: setZipValue, loadOptions: (0, create_zip_loader_1.createZipLoader)({}) }),
|
|
84
|
+
react_1.default.createElement(text_input_1.TextInput, { type: "text", value: textValue, onChange: setTextValue, label: "Text input" }),
|
|
85
|
+
react_1.default.createElement("div", { className: "grid grid-cols-2 gap-4" },
|
|
86
|
+
react_1.default.createElement(button_1.Button, { onClick: load("load-address") }, "Load Address Options"),
|
|
87
|
+
react_1.default.createElement(button_1.Button, { onClick: load("load-zip") }, "Load Zip Options"),
|
|
88
|
+
react_1.default.createElement(button_1.Button, { onClick: load("get-address") }, "Get Address"),
|
|
89
|
+
react_1.default.createElement(button_1.Button, { onClick: load("get-address-extended") }, "Get Address Extended"),
|
|
90
|
+
react_1.default.createElement(button_1.Button, { onClick: load("get-city") }, "Get City"),
|
|
91
|
+
react_1.default.createElement(button_1.Button, { onClick: load("get-city-part") }, "Get City Part"),
|
|
92
|
+
react_1.default.createElement(button_1.Button, { onClick: load("get-momc") }, "Get Momc"),
|
|
93
|
+
react_1.default.createElement(button_1.Button, { onClick: load("get-mop") }, "Get Mop"),
|
|
94
|
+
react_1.default.createElement(button_1.Button, { onClick: load("get-street") }, "Get Street")),
|
|
95
|
+
react_1.default.createElement("pre", { className: "bg-gray-100 p-2 text-sm" }, JSON.stringify(content, null, 4))));
|
|
96
|
+
}
|
|
97
|
+
exports.Default = Default;
|