@hzab/form-render 0.4.2 → 0.5.1
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/lib/index.js +1 -1
- package/package.json +1 -1
- package/src/common/date-utils.ts +18 -0
- package/src/common/formily-utils.ts +13 -0
- package/src/components/DatePicker/index.tsx +74 -60
- package/src/components/LocationPicker/Map/AMap/common/loader.ts +1 -1
- package/src/components/LocationPicker/Map/AMap/common/utils.ts +14 -4
- package/src/components/LocationPicker/Map/AMap/index.jsx +3 -2
- package/src/components/LocationPicker/README.md +29 -21
- package/src/components/LocationPicker/assets/svg-icon.js +86 -0
- package/src/components/LocationPicker/common/utils.ts +2 -22
- package/src/components/LocationPicker/components/MapSearch/index.less +1 -1
- package/src/components/LocationPicker/components/ModalContent/index.less +17 -5
- package/src/components/LocationPicker/components/ModalContent/index.tsx +82 -72
- package/src/components/LocationPicker/components/Notice/index.tsx +1 -6
- package/src/components/LocationPicker/components/ResInfo/index.less +8 -2
- package/src/components/LocationPicker/components/ResInfo/index.tsx +14 -20
- package/src/components/LocationPicker/index.tsx +33 -86
- package/src/components/LocationPicker/servers/index.ts +54 -26
- package/src/components/Text/index.tsx +0 -2
- package/lib/static/imgs/marker-icon_ab8bbcc8cb.svg +0 -4
- package/lib/static/imgs/picker-icon_24d725ef02.svg +0 -5
- package/lib/static/imgs/position-icon_5bcb8a742e.svg +0 -6
- package/lib/static/imgs/reset-icon_9edad62306.svg +0 -5
- package/src/components/LocationPicker/assets/marker-icon.svg +0 -4
- package/src/components/LocationPicker/assets/picker-icon.svg +0 -5
- package/src/components/LocationPicker/assets/position-icon.svg +0 -6
- package/src/components/LocationPicker/assets/reset-icon.svg +0 -5
- package/src/components/LocationPicker/marker-icon.png +0 -0
@@ -1,13 +1,33 @@
|
|
1
|
+
export interface addressErrorI extends Error {
|
2
|
+
result?: string;
|
3
|
+
}
|
4
|
+
|
1
5
|
/**
|
2
6
|
* 根据经纬度获取定义的地址
|
3
7
|
* @param lon
|
4
8
|
* @param lat
|
5
9
|
* @returns
|
6
10
|
*/
|
7
|
-
export function getAddress(lon, lat) {
|
11
|
+
export function getAddress(lon, lat): Promise<string> {
|
12
|
+
return new Promise((resolve, reject) => {
|
13
|
+
getAddressByAMap(lon, lat)
|
14
|
+
.then(resolve)
|
15
|
+
.catch((err) => {
|
16
|
+
if (err.result === "USER_DAILY_QUERY_OVER_LIMIT" || err.result === "A_MAP_IS_NOT_DEFINED") {
|
17
|
+
getAddressByFetch(lon, lat).then(resolve).catch(reject);
|
18
|
+
} else {
|
19
|
+
reject(err);
|
20
|
+
}
|
21
|
+
});
|
22
|
+
});
|
23
|
+
}
|
24
|
+
|
25
|
+
export const getAddressByAMap = function (lon, lat): Promise<string> {
|
8
26
|
return new Promise((resolve, reject) => {
|
9
27
|
if (!window.AMap) {
|
10
|
-
|
28
|
+
const error: addressErrorI = Error("Error getAddress window.AMap is not defined.");
|
29
|
+
error.result = "A_MAP_IS_NOT_DEFINED";
|
30
|
+
reject(error);
|
11
31
|
return;
|
12
32
|
}
|
13
33
|
const geocoder = new window.AMap.Geocoder({});
|
@@ -17,35 +37,43 @@ export function getAddress(lon, lat) {
|
|
17
37
|
resolve(formattedAddress);
|
18
38
|
return formattedAddress;
|
19
39
|
} else if (result === "USER_DAILY_QUERY_OVER_LIMIT") {
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
return;
|
24
|
-
}
|
25
|
-
fetch(
|
26
|
-
`https://restapi.amap.com/v3/geocode/regeo?location=${lon?.toFixed(6)},${lat?.toFixed(6)}&key=${
|
27
|
-
window._AMapLoaderTemp.serverKey
|
28
|
-
}`,
|
29
|
-
{
|
30
|
-
mode: "cors",
|
31
|
-
},
|
32
|
-
)
|
33
|
-
.then((res) => res.json())
|
34
|
-
.then((res) => {
|
35
|
-
if (res.status === "1") {
|
36
|
-
resolve(res.regeocode?.formatted_address);
|
37
|
-
} else {
|
38
|
-
console.warn("Warn getAddress fetch: ", res);
|
39
|
-
reject(new Error(res.info));
|
40
|
-
}
|
41
|
-
})
|
42
|
-
.catch(reject);
|
40
|
+
const error: addressErrorI = new Error("超出使用限制,请联系管理员");
|
41
|
+
error.result = result;
|
42
|
+
reject(error);
|
43
43
|
} else {
|
44
44
|
reject(result);
|
45
45
|
}
|
46
46
|
});
|
47
47
|
});
|
48
|
-
}
|
48
|
+
};
|
49
|
+
|
50
|
+
export const getAddressByFetch = function (lon, lat): Promise<string> {
|
51
|
+
return new Promise((resolve, reject) => {
|
52
|
+
// 超出限制,使用 webServer 进行请求
|
53
|
+
if (!window._AMapLoaderTemp.serverKey) {
|
54
|
+
reject(new Error("请配置 serverKey"));
|
55
|
+
return;
|
56
|
+
}
|
57
|
+
fetch(
|
58
|
+
`https://restapi.amap.com/v3/geocode/regeo?location=${lon?.toFixed(6)},${lat?.toFixed(6)}&key=${
|
59
|
+
window._AMapLoaderTemp.serverKey
|
60
|
+
}`,
|
61
|
+
{
|
62
|
+
mode: "cors",
|
63
|
+
},
|
64
|
+
)
|
65
|
+
.then((res) => res.json())
|
66
|
+
.then((res) => {
|
67
|
+
if (res.status === "1") {
|
68
|
+
resolve(res.regeocode?.formatted_address);
|
69
|
+
} else {
|
70
|
+
console.warn("Warn getAddressByFetch: ", res);
|
71
|
+
reject(new Error(res.info));
|
72
|
+
}
|
73
|
+
})
|
74
|
+
.catch(reject);
|
75
|
+
});
|
76
|
+
};
|
49
77
|
|
50
78
|
/**
|
51
79
|
* 获取搜索提示
|
@@ -1,4 +0,0 @@
|
|
1
|
-
<svg t="1708497164654" class="icon" viewBox="0 0 1024 1024" version="1.1"
|
2
|
-
xmlns="http://www.w3.org/2000/svg" p-id="8489" width="200" height="200">
|
3
|
-
<path d="M512 1024c-205.76-241.472-326.272-411.712-361.664-510.72a384 384 0 1 1 723.072 0.832C837.76 612.928 717.312 782.848 512 1024.064z m0-512a128 128 0 1 0 0-256 128 128 0 0 0 0 256z" fill="#1677ff" p-id="8490"></path>
|
4
|
-
</svg>
|
@@ -1,5 +0,0 @@
|
|
1
|
-
<svg t="1708305242338" class="icon" viewBox="0 0 1088 1024" version="1.1"
|
2
|
-
xmlns="http://www.w3.org/2000/svg" p-id="1494" width="200" height="200">
|
3
|
-
<path d="M812.224 416a288 288 0 1 0-576 0c0 118.144 94.528 272.128 288 456.576 193.472-184.448 288-338.432 288-456.576z m-288 544c-234.688-213.312-352-394.688-352-544a352 352 0 1 1 704 0c0 149.312-117.312 330.688-352 544z" fill="#1677ff" p-id="1495"></path>
|
4
|
-
<path d="M524.224 448a64 64 0 1 0 0-128 64 64 0 0 0 0 128z m0 64a128 128 0 1 1 0-256 128 128 0 0 1 0 256z m345.6 192l102.4 256h-288v-64h-320v64h-288l102.4-256h691.2z m-68.928 0H247.552l-76.8 192h706.944l-76.8-192z" fill="#1677ff" p-id="1496"></path>
|
5
|
-
</svg>
|
@@ -1,6 +0,0 @@
|
|
1
|
-
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
2
|
-
<svg t="1708478996666" class="icon" viewBox="0 0 1024 1024" version="1.1"
|
3
|
-
xmlns="http://www.w3.org/2000/svg" p-id="6897"
|
4
|
-
xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200">
|
5
|
-
<path d="M895.044488 550.176484l-42.200124 0C834.62235 708.540282 709.048353 834.001715 550.718325 852.244194l0 42.258453c0 21.946848-17.790178 39.730886-39.729863 39.730886s-39.729863-17.784038-39.729863-39.730886l0-42.258453C312.926524 834.001715 187.354574 708.540282 169.131537 550.176484l-42.199101 0c-21.940708 0-39.730886-17.786085-39.730886-39.729863 0-21.940708 17.789155-39.726793 39.730886-39.726793l42.257429 0c18.24248-158.335145 143.711076-283.907095 302.068733-302.126039l0-42.200124c0-21.940708 17.789155-39.730886 39.729863-39.730886s39.729863 17.789155 39.729863 39.730886l0 42.258453c158.331052 18.241456 283.904025 143.706983 302.126039 302.06771l42.200124 0c21.940708 0 39.729863 17.786085 39.729863 39.726793C934.774351 532.390399 916.986219 550.176484 895.044488 550.176484zM696.395172 470.719828l76.16161 0c-17.251919-114.39847-107.492176-204.651007-221.838458-221.913159l0 76.236312c0 21.939685-17.790178 39.726793-39.729863 39.726793s-39.729863-17.787108-39.729863-39.726793l0-76.165704c-114.39233 17.256012-204.644867 107.495246-221.910089 221.842551l76.233242 0c21.946848 0 39.729863 17.786085 39.729863 39.726793 0 21.943778-17.781992 39.729863-39.729863 39.729863l-76.162634 0c17.251919 114.39847 107.498316 204.649983 221.839481 221.910089l0-76.234265c0-21.943778 17.789155-39.72577 39.729863-39.72577s39.729863 17.781992 39.729863 39.72577l0 76.234265c114.346281-17.260106 204.586538-107.511619 221.838458-221.910089l-76.16161 0c-21.941732 0-39.729863-17.786085-39.729863-39.729863C656.665309 488.505913 674.453441 470.719828 696.395172 470.719828zM510.988462 550.176484c-21.939685 0-39.729863-17.786085-39.729863-39.729863 0-21.940708 17.789155-39.726793 39.729863-39.726793s39.729863 17.786085 39.729863 39.726793C550.718325 532.390399 532.928147 550.176484 510.988462 550.176484z" fill="#000000" p-id="6898"></path>
|
6
|
-
</svg>
|
@@ -1,5 +0,0 @@
|
|
1
|
-
<svg t="1708485324277" class="icon" viewBox="0 0 1024 1024" version="1.1"
|
2
|
-
xmlns="http://www.w3.org/2000/svg" p-id="7503" width="200" height="200">
|
3
|
-
<path d="M512 682.666667c71.296 0 128-56.789333 128-128s-56.704-128-128-128-128 56.789333-128 128 56.704 128 128 128z" p-id="7504"></path>
|
4
|
-
<path d="M888.192 477.269333a381.44 381.44 0 0 0-57.813333-137.344 386.261333 386.261333 0 0 0-103.68-103.68 381.866667 381.866667 0 0 0-137.344-57.813333 385.194667 385.194667 0 0 0-78.421334-7.68V85.333333L341.333333 213.333333l169.6 128V256.085333c20.650667-0.085333 41.301333 1.877333 61.226667 5.973334a297.002667 297.002667 0 0 1 106.752 44.928 298.88 298.88 0 0 1 80.725333 80.725333A297.258667 297.258667 0 0 1 810.666667 554.666667a300.032 300.032 0 0 1-23.466667 116.266666 303.36 303.36 0 0 1-27.477333 50.688 307.2 307.2 0 0 1-36.608 44.330667 299.861333 299.861333 0 0 1-150.869334 81.365333 304.213333 304.213333 0 0 1-120.405333 0 297.002667 297.002667 0 0 1-106.794667-44.970666 298.752 298.752 0 0 1-80.64-80.64A298.496 298.496 0 0 1 213.333333 554.666667H128a384.853333 384.853333 0 0 0 65.664 214.784 388.096 388.096 0 0 0 103.594667 103.594666A381.866667 381.866667 0 0 0 512 938.666667a387.84 387.84 0 0 0 77.397333-7.808 384.597333 384.597333 0 0 0 137.301334-57.813334 379.136 379.136 0 0 0 56.789333-46.890666 393.728 393.728 0 0 0 46.933333-56.832A381.952 381.952 0 0 0 896 554.666667a387.84 387.84 0 0 0-7.808-77.397334z" p-id="7505"></path>
|
5
|
-
</svg>
|
@@ -1,4 +0,0 @@
|
|
1
|
-
<svg t="1708497164654" class="icon" viewBox="0 0 1024 1024" version="1.1"
|
2
|
-
xmlns="http://www.w3.org/2000/svg" p-id="8489" width="200" height="200">
|
3
|
-
<path d="M512 1024c-205.76-241.472-326.272-411.712-361.664-510.72a384 384 0 1 1 723.072 0.832C837.76 612.928 717.312 782.848 512 1024.064z m0-512a128 128 0 1 0 0-256 128 128 0 0 0 0 256z" fill="#1677ff" p-id="8490"></path>
|
4
|
-
</svg>
|
@@ -1,5 +0,0 @@
|
|
1
|
-
<svg t="1708305242338" class="icon" viewBox="0 0 1088 1024" version="1.1"
|
2
|
-
xmlns="http://www.w3.org/2000/svg" p-id="1494" width="200" height="200">
|
3
|
-
<path d="M812.224 416a288 288 0 1 0-576 0c0 118.144 94.528 272.128 288 456.576 193.472-184.448 288-338.432 288-456.576z m-288 544c-234.688-213.312-352-394.688-352-544a352 352 0 1 1 704 0c0 149.312-117.312 330.688-352 544z" fill="#1677ff" p-id="1495"></path>
|
4
|
-
<path d="M524.224 448a64 64 0 1 0 0-128 64 64 0 0 0 0 128z m0 64a128 128 0 1 1 0-256 128 128 0 0 1 0 256z m345.6 192l102.4 256h-288v-64h-320v64h-288l102.4-256h691.2z m-68.928 0H247.552l-76.8 192h706.944l-76.8-192z" fill="#1677ff" p-id="1496"></path>
|
5
|
-
</svg>
|
@@ -1,6 +0,0 @@
|
|
1
|
-
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
2
|
-
<svg t="1708478996666" class="icon" viewBox="0 0 1024 1024" version="1.1"
|
3
|
-
xmlns="http://www.w3.org/2000/svg" p-id="6897"
|
4
|
-
xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200">
|
5
|
-
<path d="M895.044488 550.176484l-42.200124 0C834.62235 708.540282 709.048353 834.001715 550.718325 852.244194l0 42.258453c0 21.946848-17.790178 39.730886-39.729863 39.730886s-39.729863-17.784038-39.729863-39.730886l0-42.258453C312.926524 834.001715 187.354574 708.540282 169.131537 550.176484l-42.199101 0c-21.940708 0-39.730886-17.786085-39.730886-39.729863 0-21.940708 17.789155-39.726793 39.730886-39.726793l42.257429 0c18.24248-158.335145 143.711076-283.907095 302.068733-302.126039l0-42.200124c0-21.940708 17.789155-39.730886 39.729863-39.730886s39.729863 17.789155 39.729863 39.730886l0 42.258453c158.331052 18.241456 283.904025 143.706983 302.126039 302.06771l42.200124 0c21.940708 0 39.729863 17.786085 39.729863 39.726793C934.774351 532.390399 916.986219 550.176484 895.044488 550.176484zM696.395172 470.719828l76.16161 0c-17.251919-114.39847-107.492176-204.651007-221.838458-221.913159l0 76.236312c0 21.939685-17.790178 39.726793-39.729863 39.726793s-39.729863-17.787108-39.729863-39.726793l0-76.165704c-114.39233 17.256012-204.644867 107.495246-221.910089 221.842551l76.233242 0c21.946848 0 39.729863 17.786085 39.729863 39.726793 0 21.943778-17.781992 39.729863-39.729863 39.729863l-76.162634 0c17.251919 114.39847 107.498316 204.649983 221.839481 221.910089l0-76.234265c0-21.943778 17.789155-39.72577 39.729863-39.72577s39.729863 17.781992 39.729863 39.72577l0 76.234265c114.346281-17.260106 204.586538-107.511619 221.838458-221.910089l-76.16161 0c-21.941732 0-39.729863-17.786085-39.729863-39.729863C656.665309 488.505913 674.453441 470.719828 696.395172 470.719828zM510.988462 550.176484c-21.939685 0-39.729863-17.786085-39.729863-39.729863 0-21.940708 17.789155-39.726793 39.729863-39.726793s39.729863 17.786085 39.729863 39.726793C550.718325 532.390399 532.928147 550.176484 510.988462 550.176484z" fill="#000000" p-id="6898"></path>
|
6
|
-
</svg>
|
@@ -1,5 +0,0 @@
|
|
1
|
-
<svg t="1708485324277" class="icon" viewBox="0 0 1024 1024" version="1.1"
|
2
|
-
xmlns="http://www.w3.org/2000/svg" p-id="7503" width="200" height="200">
|
3
|
-
<path d="M512 682.666667c71.296 0 128-56.789333 128-128s-56.704-128-128-128-128 56.789333-128 128 56.704 128 128 128z" p-id="7504"></path>
|
4
|
-
<path d="M888.192 477.269333a381.44 381.44 0 0 0-57.813333-137.344 386.261333 386.261333 0 0 0-103.68-103.68 381.866667 381.866667 0 0 0-137.344-57.813333 385.194667 385.194667 0 0 0-78.421334-7.68V85.333333L341.333333 213.333333l169.6 128V256.085333c20.650667-0.085333 41.301333 1.877333 61.226667 5.973334a297.002667 297.002667 0 0 1 106.752 44.928 298.88 298.88 0 0 1 80.725333 80.725333A297.258667 297.258667 0 0 1 810.666667 554.666667a300.032 300.032 0 0 1-23.466667 116.266666 303.36 303.36 0 0 1-27.477333 50.688 307.2 307.2 0 0 1-36.608 44.330667 299.861333 299.861333 0 0 1-150.869334 81.365333 304.213333 304.213333 0 0 1-120.405333 0 297.002667 297.002667 0 0 1-106.794667-44.970666 298.752 298.752 0 0 1-80.64-80.64A298.496 298.496 0 0 1 213.333333 554.666667H128a384.853333 384.853333 0 0 0 65.664 214.784 388.096 388.096 0 0 0 103.594667 103.594666A381.866667 381.866667 0 0 0 512 938.666667a387.84 387.84 0 0 0 77.397333-7.808 384.597333 384.597333 0 0 0 137.301334-57.813334 379.136 379.136 0 0 0 56.789333-46.890666 393.728 393.728 0 0 0 46.933333-56.832A381.952 381.952 0 0 0 896 554.666667a387.84 387.84 0 0 0-7.808-77.397334z" p-id="7505"></path>
|
5
|
-
</svg>
|
Binary file
|