@hzab/form-render 1.6.17 → 1.6.19

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.
Files changed (60) hide show
  1. package/CHANGELOG.md +291 -283
  2. package/README.md +239 -239
  3. package/package.json +57 -57
  4. package/src/common/formily-utils.ts +125 -125
  5. package/src/common/schema-handler.ts +253 -253
  6. package/src/common/schema-merge.ts +68 -68
  7. package/src/components/ArrayBase/index.tsx +349 -349
  8. package/src/components/ArrayBase/style.less +90 -90
  9. package/src/components/ArrayBase/style.ts +2 -2
  10. package/src/components/ArrayCards/index.tsx +149 -149
  11. package/src/components/ArrayCards/style.less +14 -14
  12. package/src/components/ArrayCards/style.ts +4 -4
  13. package/src/components/ArrayTable/index.tsx +411 -411
  14. package/src/components/ArrayTable/style.less +52 -52
  15. package/src/components/ArrayTable/style.ts +7 -7
  16. package/src/components/DatePicker/index.tsx +108 -108
  17. package/src/components/LocationListPicker/assets/icon.js +1 -1
  18. package/src/components/LocationListPicker/components/AddrList/index.less +55 -55
  19. package/src/components/LocationListPicker/components/AddrList/index.tsx +75 -75
  20. package/src/components/LocationListPicker/components/Popup/address.schema.json +21 -21
  21. package/src/components/LocationListPicker/components/Popup/index.less +22 -22
  22. package/src/components/LocationListPicker/components/Popup/index.tsx +92 -92
  23. package/src/components/LocationListPicker/index.less +34 -34
  24. package/src/components/LocationListPicker/index.tsx +521 -520
  25. package/src/components/LocationPicker/Map/AMap/common/loader.ts +58 -58
  26. package/src/components/LocationPicker/Map/AMap/common/utils.ts +431 -431
  27. package/src/components/LocationPicker/Map/AMap/index.jsx +51 -51
  28. package/src/components/LocationPicker/README.md +44 -44
  29. package/src/components/LocationPicker/common/utils.ts +30 -30
  30. package/src/components/LocationPicker/components/ModalContent/index.tsx +387 -387
  31. package/src/components/LocationPicker/components/PickerInfo/index.tsx +109 -109
  32. package/src/components/LocationPicker/components/ResInfo/index.less +38 -38
  33. package/src/components/LocationPicker/components/ResInfo/index.tsx +65 -65
  34. package/src/components/LocationPicker/index.tsx +197 -197
  35. package/src/components/PersonnelSelect/index.less +21 -21
  36. package/src/components/PersonnelSelect/index.module.less +33 -33
  37. package/src/components/PersonnelSelect/index.tsx +305 -300
  38. package/src/components/PersonnelSelect/type.ts +92 -92
  39. package/src/components/RichEditor/index.less +38 -38
  40. package/src/components/RichEditor/index.tsx +238 -238
  41. package/src/components/TreeCheckbox/components/CheckboxTable/index.tsx +55 -55
  42. package/src/components/TreeCheckbox/components/TabsRender/index.tsx +58 -58
  43. package/src/components/TreeCheckbox/index.less +12 -12
  44. package/src/components/TreeCheckbox/index.tsx +63 -63
  45. package/src/components/Upload/README.md +64 -64
  46. package/src/components/Upload/common/OfflineUpload.ts +339 -339
  47. package/src/components/Upload/common/customRequest.ts +81 -81
  48. package/src/components/Upload/common/fileName.ts +142 -142
  49. package/src/components/Upload/common/handleIOFileList.ts +393 -393
  50. package/src/components/Upload/common/nanoid.ts +7 -7
  51. package/src/components/Upload/common/ossUpload.js +159 -159
  52. package/src/components/Upload/common/utils.js +194 -194
  53. package/src/components/Upload/components/ItemList/index.tsx +52 -52
  54. package/src/components/Upload/components/PreviewModal/previewRender.tsx +80 -80
  55. package/src/components/Upload/index.tsx +17 -17
  56. package/src/components/Upload/uploader-input.jsx +187 -187
  57. package/src/components/Upload/uploader.jsx +316 -316
  58. package/src/components/UserSelect/index.tsx +123 -123
  59. package/src/components/index.tsx +17 -17
  60. package/src/index.tsx +198 -198
@@ -1,197 +1,197 @@
1
- import { useEffect, useRef, useState } from "react";
2
- import { Modal } from "antd";
3
- import { observer } from "@formily/react";
4
-
5
- import ResInfo from "./components/ResInfo";
6
- import ModalContent from "./components/ModalContent";
7
-
8
- import { getCurrentPosition } from "../../common/location-utils";
9
-
10
- import { getPropsValue } from "./common/utils";
11
- import { getAddress } from "./servers";
12
-
13
- import "./index.less";
14
-
15
- export const LocationPicker = observer(function (props: any) {
16
- const {
17
- /**
18
- * 地图显示类型:
19
- * 弹窗 dialog
20
- * 直接显示 show
21
- */
22
- mode = "dialog",
23
- element = "Polypoint",
24
- /**
25
- * 选择器和地图的布局
26
- * 水平 hor
27
- * 垂直 ver
28
- */
29
- layout = "ver",
30
- // 是否允许搜索
31
- hasSearch = true,
32
- /**
33
- * 打开地图时是否根据经纬度自动修正已填的地址
34
- */
35
- isAutoFixAddr = false,
36
- lonKey = "longitude",
37
- latKey = "latitude",
38
- addrKey = "address",
39
- pointsKey = "points",
40
- value,
41
- // 搜索框是否自动搜索
42
- isAutoSearch = true,
43
- modalConf = {},
44
- icons = {},
45
- getCurPositionConf,
46
- } = props;
47
-
48
- const [loading, setLoading] = useState(false);
49
- const [defaultLocation, setDefaultLocation] = useState({
50
- lon: "",
51
- lat: "",
52
- addr: "",
53
- points: [],
54
- });
55
- const [visible, setVisible] = useState(mode === "show");
56
- // 解决 弹窗关闭之后 visible 无法传入 ModalContent 的问题
57
- const [visibleKey, setVisibleKey] = useState(0);
58
- const pickInfoRef = useRef(defaultLocation);
59
- const modalContentRef = useRef();
60
-
61
- useEffect(() => {
62
- const propsVal = getPropsValue(value, {
63
- lonKey,
64
- latKey,
65
- addrKey,
66
- pointsKey,
67
- });
68
- setPickInfo(propsVal)
69
- if (!propsVal.lon || !propsVal.lat) {
70
- setLoading(true);
71
- // 如果没有传入的经纬度,获取当前实际的经纬度数据
72
- // 获取当前经纬度
73
- getCurrentPosition(getCurPositionConf)
74
- .then(async (res) => {
75
- const { coords = {} } = res;
76
- const lon = coords.longitude;
77
- const lat = coords.latitude;
78
- const addr: string = await getAddress(lon, lat).then((addr) => {
79
- return addr;
80
- });
81
- pickInfoRef.current = {
82
- lon,
83
- lat,
84
- addr,
85
- points: [],
86
- };
87
- setDefaultLocation(pickInfoRef.current);
88
- setLoading(false);
89
- })
90
- .catch((e) => {
91
- console.warn("Error LocationPicker getCurrentPosition e: ", e);
92
- setLoading(false);
93
- });
94
- } else {
95
- setLoading(false);
96
- }
97
- }, []);
98
-
99
- function onShow() {
100
- setVisible(true);
101
- setVisibleKey(Date.now());
102
- }
103
-
104
- function onClose() {
105
- setVisible(false);
106
- setVisibleKey(Date.now());
107
- }
108
-
109
- function onChange(res = pickInfoRef.current) {
110
- const info = res || pickInfoRef.current;
111
- const _res = {
112
- [lonKey]: info.lon,
113
- [latKey]: info.lat,
114
- [addrKey]: info.addr,
115
- [pointsKey]: info.points,
116
- };
117
- props.onChange && props.onChange(_res);
118
- }
119
-
120
- async function onOk() {
121
- // 多边形时确定直接保存修改,无需双击结束
122
- if (element !== "Polypoint") {
123
- // @ts-ignore
124
- await modalContentRef.current?.editDone();
125
- }
126
- onChange();
127
- onClose();
128
- }
129
-
130
- function setResInfo(res) {
131
- setPickInfo(res);
132
- onChange(res);
133
- }
134
-
135
- function setPickInfo(res) {
136
- pickInfoRef.current = res;
137
- }
138
-
139
- const isHor = layout === "hor" || layout === "hor-reverse";
140
- const _props = {
141
- ...props,
142
- /**
143
- * 地图显示类型:
144
- * 弹窗 dialog
145
- * 直接显示 show
146
- */
147
- mode: mode ?? "dialog",
148
- element: element ?? "Polypoint",
149
- layout: layout ?? "ver",
150
- // 是否允许搜索
151
- hasSearch: hasSearch ?? true,
152
- /**
153
- * 打开地图时是否根据经纬度自动修正已填的地址
154
- */
155
- isAutoFixAddr: isAutoFixAddr ?? false,
156
- lonKey: lonKey ?? "longitude",
157
- latKey: latKey ?? "latitude",
158
- addrKey: addrKey ?? "address",
159
- pointsKey: pointsKey ?? "points",
160
- // 搜索框是否自动搜索
161
- isAutoSearch: isAutoSearch ?? true,
162
- visible,
163
- visibleKey,
164
- defaultLocation,
165
- loading,
166
- setLoading,
167
- };
168
-
169
- function onDialogInit(params) {
170
- modalContentRef.current = params;
171
- }
172
-
173
- return (
174
- <div className="location-picker">
175
- {mode === "show" && <ModalContent {..._props} setPickInfo={setResInfo} init={onDialogInit} />}
176
- {mode === "dialog" && (
177
- <>
178
- {/* 弹窗 */}
179
- {/* 有弹窗时,显示表单选中的结果 */}
180
- <ResInfo {..._props} onShow={onShow} pickerIcon={icons.pickerIcon} />
181
- <Modal
182
- className="location-picker-modal"
183
- title="地图选点"
184
- onCancel={onClose}
185
- onOk={onOk}
186
- visible={visible}
187
- width={modalConf?.width || isHor ? "1024px" : "720px"}
188
- >
189
- <ModalContent {..._props} setPickInfo={setPickInfo} init={onDialogInit} />
190
- </Modal>
191
- </>
192
- )}
193
- </div>
194
- );
195
- });
196
-
197
- export default LocationPicker;
1
+ import { useEffect, useRef, useState } from "react";
2
+ import { Modal } from "antd";
3
+ import { observer } from "@formily/react";
4
+
5
+ import ResInfo from "./components/ResInfo";
6
+ import ModalContent from "./components/ModalContent";
7
+
8
+ import { getCurrentPosition } from "../../common/location-utils";
9
+
10
+ import { getPropsValue } from "./common/utils";
11
+ import { getAddress } from "./servers";
12
+
13
+ import "./index.less";
14
+
15
+ export const LocationPicker = observer(function (props: any) {
16
+ const {
17
+ /**
18
+ * 地图显示类型:
19
+ * 弹窗 dialog
20
+ * 直接显示 show
21
+ */
22
+ mode = "dialog",
23
+ element = "Polypoint",
24
+ /**
25
+ * 选择器和地图的布局
26
+ * 水平 hor
27
+ * 垂直 ver
28
+ */
29
+ layout = "ver",
30
+ // 是否允许搜索
31
+ hasSearch = true,
32
+ /**
33
+ * 打开地图时是否根据经纬度自动修正已填的地址
34
+ */
35
+ isAutoFixAddr = false,
36
+ lonKey = "longitude",
37
+ latKey = "latitude",
38
+ addrKey = "address",
39
+ pointsKey = "points",
40
+ value,
41
+ // 搜索框是否自动搜索
42
+ isAutoSearch = true,
43
+ modalConf = {},
44
+ icons = {},
45
+ getCurPositionConf,
46
+ } = props;
47
+
48
+ const [loading, setLoading] = useState(false);
49
+ const [defaultLocation, setDefaultLocation] = useState({
50
+ lon: "",
51
+ lat: "",
52
+ addr: "",
53
+ points: [],
54
+ });
55
+ const [visible, setVisible] = useState(mode === "show");
56
+ // 解决 弹窗关闭之后 visible 无法传入 ModalContent 的问题
57
+ const [visibleKey, setVisibleKey] = useState(0);
58
+ const pickInfoRef = useRef(defaultLocation);
59
+ const modalContentRef = useRef();
60
+
61
+ useEffect(() => {
62
+ const propsVal = getPropsValue(value, {
63
+ lonKey,
64
+ latKey,
65
+ addrKey,
66
+ pointsKey,
67
+ });
68
+ setPickInfo(propsVal)
69
+ if (!propsVal.lon || !propsVal.lat) {
70
+ setLoading(true);
71
+ // 如果没有传入的经纬度,获取当前实际的经纬度数据
72
+ // 获取当前经纬度
73
+ getCurrentPosition(getCurPositionConf)
74
+ .then(async (res) => {
75
+ const { coords = {} } = res;
76
+ const lon = coords.longitude;
77
+ const lat = coords.latitude;
78
+ const addr: string = await getAddress(lon, lat).then((addr) => {
79
+ return addr;
80
+ });
81
+ pickInfoRef.current = {
82
+ lon,
83
+ lat,
84
+ addr,
85
+ points: [],
86
+ };
87
+ setDefaultLocation(pickInfoRef.current);
88
+ setLoading(false);
89
+ })
90
+ .catch((e) => {
91
+ console.warn("Error LocationPicker getCurrentPosition e: ", e);
92
+ setLoading(false);
93
+ });
94
+ } else {
95
+ setLoading(false);
96
+ }
97
+ }, []);
98
+
99
+ function onShow() {
100
+ setVisible(true);
101
+ setVisibleKey(Date.now());
102
+ }
103
+
104
+ function onClose() {
105
+ setVisible(false);
106
+ setVisibleKey(Date.now());
107
+ }
108
+
109
+ function onChange(res = pickInfoRef.current) {
110
+ const info = res || pickInfoRef.current;
111
+ const _res = {
112
+ [lonKey]: info.lon,
113
+ [latKey]: info.lat,
114
+ [addrKey]: info.addr,
115
+ [pointsKey]: info.points,
116
+ };
117
+ props.onChange && props.onChange(_res);
118
+ }
119
+
120
+ async function onOk() {
121
+ // 多边形时确定直接保存修改,无需双击结束
122
+ if (element !== "Polypoint") {
123
+ // @ts-ignore
124
+ await modalContentRef.current?.editDone();
125
+ }
126
+ onChange();
127
+ onClose();
128
+ }
129
+
130
+ function setResInfo(res) {
131
+ setPickInfo(res);
132
+ onChange(res);
133
+ }
134
+
135
+ function setPickInfo(res) {
136
+ pickInfoRef.current = res;
137
+ }
138
+
139
+ const isHor = layout === "hor" || layout === "hor-reverse";
140
+ const _props = {
141
+ ...props,
142
+ /**
143
+ * 地图显示类型:
144
+ * 弹窗 dialog
145
+ * 直接显示 show
146
+ */
147
+ mode: mode ?? "dialog",
148
+ element: element ?? "Polypoint",
149
+ layout: layout ?? "ver",
150
+ // 是否允许搜索
151
+ hasSearch: hasSearch ?? true,
152
+ /**
153
+ * 打开地图时是否根据经纬度自动修正已填的地址
154
+ */
155
+ isAutoFixAddr: isAutoFixAddr ?? false,
156
+ lonKey: lonKey ?? "longitude",
157
+ latKey: latKey ?? "latitude",
158
+ addrKey: addrKey ?? "address",
159
+ pointsKey: pointsKey ?? "points",
160
+ // 搜索框是否自动搜索
161
+ isAutoSearch: isAutoSearch ?? true,
162
+ visible,
163
+ visibleKey,
164
+ defaultLocation,
165
+ loading,
166
+ setLoading,
167
+ };
168
+
169
+ function onDialogInit(params) {
170
+ modalContentRef.current = params;
171
+ }
172
+
173
+ return (
174
+ <div className="location-picker">
175
+ {mode === "show" && <ModalContent {..._props} setPickInfo={setResInfo} init={onDialogInit} />}
176
+ {mode === "dialog" && (
177
+ <>
178
+ {/* 弹窗 */}
179
+ {/* 有弹窗时,显示表单选中的结果 */}
180
+ <ResInfo {..._props} onShow={onShow} pickerIcon={icons.pickerIcon} />
181
+ <Modal
182
+ className="location-picker-modal"
183
+ title="地图选点"
184
+ onCancel={onClose}
185
+ onOk={onOk}
186
+ visible={visible}
187
+ width={modalConf?.width || isHor ? "1024px" : "720px"}
188
+ >
189
+ <ModalContent {..._props} setPickInfo={setPickInfo} init={onDialogInit} />
190
+ </Modal>
191
+ </>
192
+ )}
193
+ </div>
194
+ );
195
+ });
196
+
197
+ export default LocationPicker;
@@ -1,21 +1,21 @@
1
- .abt-user-item {
2
- display: flex;
3
- align-items: center;
4
- padding: 0 16px;
5
-
6
-
7
-
8
- .abt-user-item-info {
9
- list-style: none;
10
- flex: 1;
11
- display: flex;
12
- flex-direction: column;
13
- padding-left: 16px;
14
-
15
- .abt-user-item-info__item {
16
- & > span:last-of-type {
17
- color: #666;
18
- }
19
- }
20
- }
21
- }
1
+ .abt-user-item {
2
+ display: flex;
3
+ align-items: center;
4
+ padding: 0 16px;
5
+
6
+
7
+
8
+ .abt-user-item-info {
9
+ list-style: none;
10
+ flex: 1;
11
+ display: flex;
12
+ flex-direction: column;
13
+ padding-left: 16px;
14
+
15
+ .abt-user-item-info__item {
16
+ & > span:last-of-type {
17
+ color: #666;
18
+ }
19
+ }
20
+ }
21
+ }
@@ -1,33 +1,33 @@
1
- .user-select {
2
-
3
- &-option {
4
- :global {
5
- .ant-select-item-option-content {
6
- display: flex;
7
- }
8
- }
9
-
10
-
11
- &__avatar {
12
- margin-right: 10px;
13
- }
14
-
15
- .user-item {
16
- display: flex;
17
- flex-direction: column;
18
-
19
- &-name {
20
- margin-bottom: 4px;
21
- color: #000000d9;
22
- font-size: 14px;
23
- display: flex;
24
- align-items: center;
25
- }
26
-
27
- &__idCard {
28
- color: #00000073;
29
- font-size: 14px;
30
- }
31
- }
32
- }
33
- }
1
+ .user-select {
2
+
3
+ &-option {
4
+ :global {
5
+ .ant-select-item-option-content {
6
+ display: flex;
7
+ }
8
+ }
9
+
10
+
11
+ &__avatar {
12
+ margin-right: 10px;
13
+ }
14
+
15
+ .user-item {
16
+ display: flex;
17
+ flex-direction: column;
18
+
19
+ &-name {
20
+ margin-bottom: 4px;
21
+ color: #000000d9;
22
+ font-size: 14px;
23
+ display: flex;
24
+ align-items: center;
25
+ }
26
+
27
+ &__idCard {
28
+ color: #00000073;
29
+ font-size: 14px;
30
+ }
31
+ }
32
+ }
33
+ }