@hzab/form-render-mobile 0.3.2 → 0.4.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.
Files changed (29) hide show
  1. package/lib/index.js +1 -1
  2. package/package.json +1 -1
  3. package/src/components/LocationPicker/Map/AMap/common/loader.ts +2 -2
  4. package/src/components/LocationPicker/Map/AMap/common/utils.ts +15 -4
  5. package/src/components/LocationPicker/Map/AMap/index.jsx +3 -2
  6. package/src/components/LocationPicker/README.md +31 -22
  7. package/src/components/LocationPicker/assets/svg-icon.js +86 -0
  8. package/src/components/LocationPicker/common/utils.ts +2 -9
  9. package/src/components/LocationPicker/components/MapSearch/index.jsx +0 -3
  10. package/src/components/LocationPicker/components/ModalContent/index.less +18 -4
  11. package/src/components/LocationPicker/components/ModalContent/index.tsx +45 -62
  12. package/src/components/LocationPicker/components/Notice/index.tsx +1 -1
  13. package/src/components/LocationPicker/components/ResInfo/index.less +9 -10
  14. package/src/components/LocationPicker/components/ResInfo/index.tsx +20 -18
  15. package/src/components/LocationPicker/index.tsx +24 -72
  16. package/src/components/LocationPicker/servers/index.ts +119 -63
  17. package/src/components/TreeSelect/SelectList/index.tsx +58 -25
  18. package/src/components/TreeSelect/common/data-handler.ts +158 -3
  19. package/src/components/TreeSelect/index.less +1 -0
  20. package/src/components/TreeSelect/index.tsx +8 -1
  21. package/src/index.less +5 -2
  22. package/lib/static/imgs/marker-icon_ab8bbcc8cb.svg +0 -4
  23. package/lib/static/imgs/picker-icon_24d725ef02.svg +0 -5
  24. package/lib/static/imgs/position-icon_5bcb8a742e.svg +0 -6
  25. package/lib/static/imgs/reset-icon_9edad62306.svg +0 -5
  26. package/src/components/LocationPicker/assets/marker-icon.svg +0 -4
  27. package/src/components/LocationPicker/assets/picker-icon.svg +0 -5
  28. package/src/components/LocationPicker/assets/position-icon.svg +0 -6
  29. package/src/components/LocationPicker/assets/reset-icon.svg +0 -5
@@ -1,3 +1,5 @@
1
+ import _ from "lodash";
2
+
1
3
  /**
2
4
  * 获取列表枚举数据
3
5
  * @param list
@@ -14,14 +16,24 @@ export const getDataEnum = function (list, opt?: any) {
14
16
  level,
15
17
  fullPathLabels: [...(parent.fullPathLabels || []), it[label]],
16
18
  fullPathValues: [...(parent.fullPathValues || []), it[value]],
19
+ parentEnum: { ...parent.parentEnum },
17
20
  };
21
+ if (parent[value]) {
22
+ item.parentEnum[parent[value]] = 1;
23
+ }
18
24
  item.fullPathItems = [...(parent.fullPathItems || []), item];
19
25
  delete item[children];
20
26
 
21
27
  dataEnum[it[value]] = item;
22
28
 
23
- if (it[children]) {
24
- getDataEnum(it[children], { ...opt, dataEnum, parent: item });
29
+ const childrenList = it[children];
30
+ if (childrenList) {
31
+ const childrenEnum = {};
32
+ childrenList.forEach((it) => {
33
+ childrenEnum[it[value]] = 1;
34
+ });
35
+ item.childrenEnum = childrenEnum;
36
+ getDataEnum(childrenList, { ...opt, dataEnum, parent: item });
25
37
  }
26
38
  });
27
39
  return dataEnum;
@@ -89,21 +101,32 @@ export const flatActiveTreeData = function (treeData, activeKeys = [], opt?: any
89
101
  const { list = [], fieldNames, parent = {}, level = 1 } = opt || {};
90
102
  const { value = "value", children = "children", label = "label" } = fieldNames || {};
91
103
  treeData?.forEach((it) => {
104
+ const childrenList = it?.[children];
92
105
  const item = {
93
106
  ...it,
94
107
  parent,
95
108
  level,
96
109
  fullPathLabel: [...(parent.fullPathLabel || []), it[label]],
110
+ fullPathValues: [...(parent.fullPathValues || []), it[value]],
111
+ parentEnum: { ...parent.parentEnum },
112
+ childrenLen: childrenList?.length || 0,
97
113
  };
114
+ if (parent[value]) {
115
+ item.parentEnum[parent[value]] = 1;
116
+ }
98
117
  item.fullPathItems = [...(parent.fullPathItems || []), item];
99
118
 
100
119
  if (item.parentId === null || item.parentId === undefined || item.parentId === "") {
101
120
  item.parentId = parent[value];
102
121
  }
103
- const childrenList = it?.[children];
104
122
  delete item[children];
105
123
  list.push(item);
106
124
  if (Array.isArray(childrenList) && childrenList.length > 0) {
125
+ const childrenEnum = {};
126
+ childrenList.forEach((it) => {
127
+ childrenEnum[it[value]] = 1;
128
+ });
129
+ item.childrenEnum = childrenEnum;
107
130
  item.hasChildren = true;
108
131
  activeKeys.includes(it[value]) &&
109
132
  flatActiveTreeData(childrenList, activeKeys, {
@@ -133,3 +156,135 @@ export const getTreeAllExpandKeys = function (treeData, opt?: any) {
133
156
  });
134
157
  return expandKeys;
135
158
  };
159
+
160
+ export const removeAllSelected = function (treeData, selected = [], opt?: any) {
161
+ const { fieldNames } = opt || {};
162
+ const { value = "value", children = "children" } = fieldNames || {};
163
+ treeData?.forEach((it) => {
164
+ const key = it[value];
165
+ const idx = selected.findIndex((k) => k === key);
166
+ idx >= 0 && selected.splice(idx, 1);
167
+ const childList = it[children];
168
+ if (Array.isArray(childList) && childList.length > 0) {
169
+ removeAllSelected(childList, selected, opt);
170
+ }
171
+ });
172
+ return selected;
173
+ };
174
+
175
+ /**
176
+ * 处理选中状态
177
+ * @param treeData
178
+ * @param key
179
+ * @param val
180
+ * @param opt
181
+ * @returns
182
+ * _checked 选中状态
183
+ * _indeterminate 半选状态(只在父子联动中使用)
184
+ */
185
+ export const handleChecked = function (treeData, targetKey, targetVal, opt) {
186
+ const {
187
+ fieldNames,
188
+ /**
189
+ * 是否是父子联动
190
+ */
191
+ treeCheckStrictly,
192
+ selected = [],
193
+ } = opt || {};
194
+ const { value = "value", children = "children" } = fieldNames || {};
195
+ const dataLen = treeData?.length;
196
+ let checkedCount = 0;
197
+ let indeterminate = false;
198
+ for (let i = 0; i < dataLen; i++) {
199
+ const it = treeData[i];
200
+ const key = it[value];
201
+ // 处理禁用、只读状态?
202
+ if (key === targetKey) {
203
+ it._checked = targetVal;
204
+ it._indeterminate = false;
205
+ if (treeCheckStrictly) {
206
+ // 父子联动,处理当前项子项的选中状态,所有子项跟随当前项
207
+ setAllChecked(it[children], targetVal, opt);
208
+ // 结束当前项的处理,当前项及父级的状态由上层遍历处理
209
+ }
210
+ } else {
211
+ const childList = it[children];
212
+ if (Array.isArray(childList) && childList.length > 0) {
213
+ const childRes = handleChecked(childList, targetKey, targetVal, { ...opt, selected });
214
+ if (treeCheckStrictly) {
215
+ // 父子联动,处理父级的选中、半选状态
216
+ it._checked = childRes._checked;
217
+ it._indeterminate = childRes._indeterminate;
218
+ // 子项有半选,则父级也是半选
219
+ if (it._indeterminate && !it._checked) {
220
+ indeterminate = true;
221
+ }
222
+ if (it._checked) {
223
+ it._indeterminate = false;
224
+ removeAllSelected(childList, selected, opt);
225
+ }
226
+ }
227
+ }
228
+ }
229
+
230
+ if (it._checked) {
231
+ // 当前项处理完处理选中状态,checkedCount + 1, key 添加到 selected 数组中
232
+ checkedCount += 1;
233
+ selected.push(key);
234
+ }
235
+ }
236
+
237
+ return {
238
+ treeData,
239
+ checkedCount,
240
+ _checked: dataLen > 0 && checkedCount === dataLen,
241
+ _indeterminate: indeterminate || (checkedCount > 0 && checkedCount < dataLen),
242
+ selected,
243
+ };
244
+ };
245
+
246
+ /**
247
+ * 初始化选中状态
248
+ * @param _treeData
249
+ * @param opt
250
+ * _checked 选中状态
251
+ * _indeterminate 半选状态(只在父子联动中使用)
252
+ */
253
+ export const initChecked = function (_treeData, selected, opt) {
254
+ const treeData = _.cloneDeep(_treeData);
255
+ _.uniq(selected || [])?.forEach((it) => {
256
+ handleChecked(treeData, it, true, opt);
257
+ });
258
+ return treeData;
259
+ };
260
+
261
+ /**
262
+ * 设置所有项的选中状态
263
+ * @param treeData
264
+ * @param targetVal
265
+ * @param opt
266
+ */
267
+ export const setAllChecked = function (treeData, targetVal, opt) {
268
+ const { fieldNames } = opt || {};
269
+ const { children = "children" } = fieldNames || {};
270
+ treeData?.forEach((it) => {
271
+ it._checked = targetVal;
272
+ it._indeterminate = undefined;
273
+ const childList = it[children];
274
+ if (Array.isArray(childList) && childList.length > 0) {
275
+ setAllChecked(childList, targetVal, opt);
276
+ }
277
+ });
278
+ return treeData;
279
+ };
280
+ /**
281
+ * 清除所有的选中状态
282
+ * @param treeData
283
+ * @param opt
284
+ * @returns
285
+ * _checked 选中状态
286
+ * _indeterminate 半选状态
287
+ */
288
+ export const cleanChecked = function (treeData, opt) {
289
+ return setAllChecked(treeData, undefined, opt);
290
+ };
@@ -1,6 +1,7 @@
1
1
  .formily-tree-select {
2
2
  height: 100%;
3
3
  .tree-selected {
4
+ flex: 1;
4
5
  height: 100%;
5
6
  }
6
7
  }
@@ -122,7 +122,14 @@ export const TreeSelect = observer((props: any) => {
122
122
  {showSearch && (
123
123
  <TreeSearch visible={visible} dataSource={dataSource} setTreeData={setTreeData} fieldNames={fieldNames} />
124
124
  )}
125
- <SelectList {...props} visible={visible} treeData={treeData} selected={selected} setSelected={setSelected} />
125
+ <SelectList
126
+ {...props}
127
+ visible={visible}
128
+ dataSource={dataSource}
129
+ treeData={treeData}
130
+ selected={selected}
131
+ setSelected={setSelected}
132
+ />
126
133
  </div>
127
134
  </Popup>
128
135
  </PickerRightOutline>
package/src/index.less CHANGED
@@ -3,10 +3,13 @@
3
3
  .adm-formily-item {
4
4
  font-size: 4vw;
5
5
  .adm-formily-item-label {
6
- line-height: 1.2;
6
+ line-height: 1.5;
7
7
  }
8
8
  .adm-formily-item-error-help {
9
- line-height: 1.2;
9
+ line-height: 1.5;
10
+ }
11
+ .adm-formily-item-control .adm-formily-item-control-content .adm-formily-item-control-content-component {
12
+ line-height: 1.5;
10
13
  }
11
14
  }
12
15
  .adm-list-body {
@@ -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>