@nocobase/plugin-map 0.8.1-alpha.3
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/LICENSE +201 -0
- package/client.d.ts +4 -0
- package/client.js +30 -0
- package/lib/client/components/AMap.d.ts +13 -0
- package/lib/client/components/AMap.js +502 -0
- package/lib/client/components/Configuration.d.ts +2 -0
- package/lib/client/components/Configuration.js +167 -0
- package/lib/client/components/Designer.d.ts +2 -0
- package/lib/client/components/Designer.js +308 -0
- package/lib/client/components/Map.d.ts +6 -0
- package/lib/client/components/Map.js +65 -0
- package/lib/client/components/ReadPretty.d.ts +2 -0
- package/lib/client/components/ReadPretty.js +81 -0
- package/lib/client/components/Search.d.ts +6 -0
- package/lib/client/components/Search.js +155 -0
- package/lib/client/constants.d.ts +4 -0
- package/lib/client/constants.js +17 -0
- package/lib/client/fields/circle.d.ts +2 -0
- package/lib/client/fields/circle.js +37 -0
- package/lib/client/fields/index.d.ts +2 -0
- package/lib/client/fields/index.js +22 -0
- package/lib/client/fields/lineString.d.ts +2 -0
- package/lib/client/fields/lineString.js +37 -0
- package/lib/client/fields/point.d.ts +2 -0
- package/lib/client/fields/point.js +37 -0
- package/lib/client/fields/polygon.d.ts +2 -0
- package/lib/client/fields/polygon.js +37 -0
- package/lib/client/fields/schema.d.ts +99 -0
- package/lib/client/fields/schema.js +79 -0
- package/lib/client/hooks/index.d.ts +1 -0
- package/lib/client/hooks/index.js +18 -0
- package/lib/client/hooks/useMapConfiguration.d.ts +2 -0
- package/lib/client/hooks/useMapConfiguration.js +33 -0
- package/lib/client/index.d.ts +3 -0
- package/lib/client/index.js +80 -0
- package/lib/client/initialize.d.ts +4 -0
- package/lib/client/initialize.js +67 -0
- package/lib/client/locales/en-US.d.ts +2 -0
- package/lib/client/locales/en-US.js +9 -0
- package/lib/client/locales/index.d.ts +4 -0
- package/lib/client/locales/index.js +56 -0
- package/lib/client/locales/zh-CN.d.ts +43 -0
- package/lib/client/locales/zh-CN.js +51 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +15 -0
- package/lib/server/actions/index.d.ts +3 -0
- package/lib/server/actions/index.js +66 -0
- package/lib/server/collections/mapConfiguration.d.ts +3 -0
- package/lib/server/collections/mapConfiguration.js +30 -0
- package/lib/server/constants.d.ts +1 -0
- package/lib/server/constants.js +8 -0
- package/lib/server/fields/circle.d.ts +13 -0
- package/lib/server/fields/circle.js +84 -0
- package/lib/server/fields/index.d.ts +4 -0
- package/lib/server/fields/index.js +57 -0
- package/lib/server/fields/lineString.d.ts +13 -0
- package/lib/server/fields/lineString.js +91 -0
- package/lib/server/fields/point.d.ts +13 -0
- package/lib/server/fields/point.js +95 -0
- package/lib/server/fields/polygon.d.ts +13 -0
- package/lib/server/fields/polygon.js +89 -0
- package/lib/server/helpers/index.d.ts +6 -0
- package/lib/server/helpers/index.js +44 -0
- package/lib/server/index.d.ts +1 -0
- package/lib/server/index.js +15 -0
- package/lib/server/plugin.d.ts +11 -0
- package/lib/server/plugin.js +88 -0
- package/package.json +19 -0
- package/server.d.ts +4 -0
- package/server.js +30 -0
- package/src/client/components/AMap.tsx +369 -0
- package/src/client/components/Configuration.tsx +91 -0
- package/src/client/components/Designer.tsx +260 -0
- package/src/client/components/Map.tsx +29 -0
- package/src/client/components/ReadPretty.tsx +34 -0
- package/src/client/components/Search.tsx +93 -0
- package/src/client/constants.ts +6 -0
- package/src/client/fields/circle.ts +23 -0
- package/src/client/fields/index.ts +16 -0
- package/src/client/fields/lineString.ts +23 -0
- package/src/client/fields/point.ts +24 -0
- package/src/client/fields/polygon.ts +23 -0
- package/src/client/fields/schema.ts +57 -0
- package/src/client/hooks/index.ts +1 -0
- package/src/client/hooks/useMapConfiguration.ts +15 -0
- package/src/client/index.tsx +43 -0
- package/src/client/initialize.tsx +33 -0
- package/src/client/locales/en-US.ts +5 -0
- package/src/client/locales/index.ts +22 -0
- package/src/client/locales/zh-CN.ts +45 -0
- package/src/index.ts +1 -0
- package/src/server/__tests__/fields.test.ts +168 -0
- package/src/server/actions/index.ts +46 -0
- package/src/server/collections/mapConfiguration.ts +27 -0
- package/src/server/constants.ts +1 -0
- package/src/server/fields/.gitkeep +0 -0
- package/src/server/fields/circle.ts +50 -0
- package/src/server/fields/index.ts +4 -0
- package/src/server/fields/lineString.ts +56 -0
- package/src/server/fields/point.ts +59 -0
- package/src/server/fields/polygon.ts +56 -0
- package/src/server/helpers/index.ts +25 -0
- package/src/server/index.ts +1 -0
- package/src/server/plugin.ts +46 -0
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function _react() {
|
|
9
|
+
const data = require("@formily/react");
|
|
10
|
+
|
|
11
|
+
_react = function _react() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _client() {
|
|
19
|
+
const data = require("@nocobase/client");
|
|
20
|
+
|
|
21
|
+
_client = function _client() {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function _lodash() {
|
|
29
|
+
const data = _interopRequireDefault(require("lodash"));
|
|
30
|
+
|
|
31
|
+
_lodash = function _lodash() {
|
|
32
|
+
return data;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function _react2() {
|
|
39
|
+
const data = _interopRequireDefault(require("react"));
|
|
40
|
+
|
|
41
|
+
_react2 = function _react2() {
|
|
42
|
+
return data;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return data;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
var _locales = require("../locales");
|
|
49
|
+
|
|
50
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
51
|
+
|
|
52
|
+
const Designer = () => {
|
|
53
|
+
var _collectionField$uiSc, _collectionField$uiSc2, _fieldSchema$xDecora, _fieldSchema$xCompon;
|
|
54
|
+
|
|
55
|
+
const _useCollectionManager = (0, _client().useCollectionManager)(),
|
|
56
|
+
getCollectionJoinField = _useCollectionManager.getCollectionJoinField;
|
|
57
|
+
|
|
58
|
+
const _useCollection = (0, _client().useCollection)(),
|
|
59
|
+
getField = _useCollection.getField;
|
|
60
|
+
|
|
61
|
+
const _useFormBlockContext = (0, _client().useFormBlockContext)(),
|
|
62
|
+
form = _useFormBlockContext.form;
|
|
63
|
+
|
|
64
|
+
const field = (0, _react().useField)();
|
|
65
|
+
const fieldSchema = (0, _react().useFieldSchema)();
|
|
66
|
+
|
|
67
|
+
const _useMapTranslation = (0, _locales.useMapTranslation)(),
|
|
68
|
+
t = _useMapTranslation.t;
|
|
69
|
+
|
|
70
|
+
const _useDesignable = (0, _client().useDesignable)(),
|
|
71
|
+
dn = _useDesignable.dn,
|
|
72
|
+
refresh = _useDesignable.refresh;
|
|
73
|
+
|
|
74
|
+
const collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']);
|
|
75
|
+
const originalTitle = collectionField === null || collectionField === void 0 ? void 0 : (_collectionField$uiSc = collectionField.uiSchema) === null || _collectionField$uiSc === void 0 ? void 0 : _collectionField$uiSc.title;
|
|
76
|
+
const initialValue = {
|
|
77
|
+
title: field.title === originalTitle ? undefined : field.title
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
if (!field.readPretty) {
|
|
81
|
+
initialValue['required'] = field.required;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
let readOnlyMode = 'editable';
|
|
85
|
+
|
|
86
|
+
if (fieldSchema['x-disabled'] === true) {
|
|
87
|
+
readOnlyMode = 'readonly';
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (fieldSchema['x-read-pretty'] === true) {
|
|
91
|
+
readOnlyMode = 'read-pretty';
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return _react2().default.createElement(_client().GeneralSchemaDesigner, null, _react2().default.createElement(_client().SchemaSettings.ModalItem, {
|
|
95
|
+
key: "edit-field-title",
|
|
96
|
+
title: t('Edit field title'),
|
|
97
|
+
schema: {
|
|
98
|
+
type: 'object',
|
|
99
|
+
title: t('Edit field title'),
|
|
100
|
+
properties: {
|
|
101
|
+
title: {
|
|
102
|
+
title: t('Field title'),
|
|
103
|
+
default: field === null || field === void 0 ? void 0 : field.title,
|
|
104
|
+
description: `${t('Original field title: ')}${collectionField === null || collectionField === void 0 ? void 0 : (_collectionField$uiSc2 = collectionField.uiSchema) === null || _collectionField$uiSc2 === void 0 ? void 0 : _collectionField$uiSc2.title}`,
|
|
105
|
+
'x-decorator': 'FormItem',
|
|
106
|
+
'x-component': 'Input',
|
|
107
|
+
'x-component-props': {}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
onSubmit: ({
|
|
112
|
+
title
|
|
113
|
+
}) => {
|
|
114
|
+
if (title) {
|
|
115
|
+
field.title = title;
|
|
116
|
+
fieldSchema.title = title;
|
|
117
|
+
dn.emit('patch', {
|
|
118
|
+
schema: {
|
|
119
|
+
'x-uid': fieldSchema['x-uid'],
|
|
120
|
+
title: fieldSchema.title
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
dn.refresh();
|
|
126
|
+
}
|
|
127
|
+
}), !field.readPretty && _react2().default.createElement(_client().SchemaSettings.ModalItem, {
|
|
128
|
+
key: "edit-description",
|
|
129
|
+
title: t('Edit description'),
|
|
130
|
+
schema: {
|
|
131
|
+
type: 'object',
|
|
132
|
+
title: t('Edit description'),
|
|
133
|
+
properties: {
|
|
134
|
+
description: {
|
|
135
|
+
// title: t('Description'),
|
|
136
|
+
default: field === null || field === void 0 ? void 0 : field.description,
|
|
137
|
+
'x-decorator': 'FormItem',
|
|
138
|
+
'x-component': 'Input.TextArea',
|
|
139
|
+
'x-component-props': {}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
onSubmit: ({
|
|
144
|
+
description
|
|
145
|
+
}) => {
|
|
146
|
+
field.description = description;
|
|
147
|
+
fieldSchema.description = description;
|
|
148
|
+
dn.emit('patch', {
|
|
149
|
+
schema: {
|
|
150
|
+
'x-uid': fieldSchema['x-uid'],
|
|
151
|
+
description: fieldSchema.description
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
dn.refresh();
|
|
155
|
+
}
|
|
156
|
+
}), field.readPretty && _react2().default.createElement(_client().SchemaSettings.ModalItem, {
|
|
157
|
+
key: "edit-tooltip",
|
|
158
|
+
title: t('Edit tooltip'),
|
|
159
|
+
schema: {
|
|
160
|
+
type: 'object',
|
|
161
|
+
title: t('Edit description'),
|
|
162
|
+
properties: {
|
|
163
|
+
tooltip: {
|
|
164
|
+
default: fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xDecora = fieldSchema['x-decorator-props']) === null || _fieldSchema$xDecora === void 0 ? void 0 : _fieldSchema$xDecora.tooltip,
|
|
165
|
+
'x-decorator': 'FormItem',
|
|
166
|
+
'x-component': 'Input.TextArea',
|
|
167
|
+
'x-component-props': {}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
onSubmit: ({
|
|
172
|
+
tooltip
|
|
173
|
+
}) => {
|
|
174
|
+
field.decoratorProps.tooltip = tooltip;
|
|
175
|
+
fieldSchema['x-decorator-props'] = fieldSchema['x-decorator-props'] || {};
|
|
176
|
+
fieldSchema['x-decorator-props']['tooltip'] = tooltip;
|
|
177
|
+
dn.emit('patch', {
|
|
178
|
+
schema: {
|
|
179
|
+
'x-uid': fieldSchema['x-uid'],
|
|
180
|
+
'x-decorator-props': fieldSchema['x-decorator-props']
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
dn.refresh();
|
|
184
|
+
}
|
|
185
|
+
}), !field.readPretty && _react2().default.createElement(_client().SchemaSettings.SwitchItem, {
|
|
186
|
+
key: "required",
|
|
187
|
+
title: t('Required'),
|
|
188
|
+
checked: fieldSchema.required,
|
|
189
|
+
onChange: required => {
|
|
190
|
+
const schema = {
|
|
191
|
+
['x-uid']: fieldSchema['x-uid']
|
|
192
|
+
};
|
|
193
|
+
field.required = required;
|
|
194
|
+
fieldSchema['required'] = required;
|
|
195
|
+
schema['required'] = required;
|
|
196
|
+
dn.emit('patch', {
|
|
197
|
+
schema
|
|
198
|
+
});
|
|
199
|
+
refresh();
|
|
200
|
+
}
|
|
201
|
+
}), form && !(form === null || form === void 0 ? void 0 : form.readPretty) && (fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon === void 0 ? void 0 : _fieldSchema$xCompon['pattern-disable']) != true && _react2().default.createElement(_client().SchemaSettings.SelectItem, {
|
|
202
|
+
key: "pattern",
|
|
203
|
+
title: t('Pattern'),
|
|
204
|
+
options: [{
|
|
205
|
+
label: t('Editable'),
|
|
206
|
+
value: 'editable'
|
|
207
|
+
}, {
|
|
208
|
+
label: t('Readonly'),
|
|
209
|
+
value: 'readonly'
|
|
210
|
+
}, {
|
|
211
|
+
label: t('Easy-reading'),
|
|
212
|
+
value: 'read-pretty'
|
|
213
|
+
}],
|
|
214
|
+
value: readOnlyMode,
|
|
215
|
+
onChange: v => {
|
|
216
|
+
const schema = {
|
|
217
|
+
['x-uid']: fieldSchema['x-uid']
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
switch (v) {
|
|
221
|
+
case 'readonly':
|
|
222
|
+
{
|
|
223
|
+
fieldSchema['x-read-pretty'] = false;
|
|
224
|
+
fieldSchema['x-disabled'] = true;
|
|
225
|
+
schema['x-read-pretty'] = false;
|
|
226
|
+
schema['x-disabled'] = true;
|
|
227
|
+
field.readPretty = false;
|
|
228
|
+
field.disabled = true;
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
case 'read-pretty':
|
|
233
|
+
{
|
|
234
|
+
fieldSchema['x-read-pretty'] = true;
|
|
235
|
+
fieldSchema['x-disabled'] = false;
|
|
236
|
+
schema['x-read-pretty'] = true;
|
|
237
|
+
schema['x-disabled'] = false;
|
|
238
|
+
field.readPretty = true;
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
default:
|
|
243
|
+
{
|
|
244
|
+
fieldSchema['x-read-pretty'] = false;
|
|
245
|
+
fieldSchema['x-disabled'] = false;
|
|
246
|
+
schema['x-read-pretty'] = false;
|
|
247
|
+
schema['x-disabled'] = false;
|
|
248
|
+
field.readPretty = false;
|
|
249
|
+
field.disabled = false;
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
dn.emit('patch', {
|
|
255
|
+
schema
|
|
256
|
+
});
|
|
257
|
+
dn.refresh();
|
|
258
|
+
}
|
|
259
|
+
}), _react2().default.createElement(_client().SchemaSettings.ModalItem, {
|
|
260
|
+
key: "map-zoom",
|
|
261
|
+
title: t('Set default zoom level'),
|
|
262
|
+
schema: {
|
|
263
|
+
type: 'object',
|
|
264
|
+
title: t('Set default zoom level'),
|
|
265
|
+
properties: {
|
|
266
|
+
zoom: {
|
|
267
|
+
title: t('Zoom'),
|
|
268
|
+
default: field.componentProps.zoom || 13,
|
|
269
|
+
description: t('The default zoom level of the map'),
|
|
270
|
+
'x-decorator': 'FormItem',
|
|
271
|
+
'x-component': 'InputNumber',
|
|
272
|
+
'x-component-props': {
|
|
273
|
+
precision: 0
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
onSubmit: ({
|
|
279
|
+
zoom
|
|
280
|
+
}) => {
|
|
281
|
+
if (zoom) {
|
|
282
|
+
_lodash().default.set(fieldSchema, 'x-component-props.zoom', zoom);
|
|
283
|
+
|
|
284
|
+
Object.assign(field.componentProps, fieldSchema['x-component-props']);
|
|
285
|
+
dn.emit('patch', {
|
|
286
|
+
schema: {
|
|
287
|
+
'x-uid': fieldSchema['x-uid'],
|
|
288
|
+
'x-component-props': field.componentProps
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
dn.refresh();
|
|
294
|
+
}
|
|
295
|
+
}), _react2().default.createElement(_client().SchemaSettings.Remove, {
|
|
296
|
+
key: "remove",
|
|
297
|
+
removeParentsIfNoChildren: true,
|
|
298
|
+
confirm: {
|
|
299
|
+
title: t('Delete field')
|
|
300
|
+
},
|
|
301
|
+
breakRemoveOn: {
|
|
302
|
+
'x-component': 'Grid'
|
|
303
|
+
}
|
|
304
|
+
}));
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
var _default = Designer;
|
|
308
|
+
exports.default = _default;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function _react() {
|
|
9
|
+
const data = require("@formily/react");
|
|
10
|
+
|
|
11
|
+
_react = function _react() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _react2() {
|
|
19
|
+
const data = _interopRequireDefault(require("react"));
|
|
20
|
+
|
|
21
|
+
_react2 = function _react2() {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var _AMap = _interopRequireDefault(require("./AMap"));
|
|
29
|
+
|
|
30
|
+
var _ReadPretty = _interopRequireDefault(require("./ReadPretty"));
|
|
31
|
+
|
|
32
|
+
function _css() {
|
|
33
|
+
const data = require("@emotion/css");
|
|
34
|
+
|
|
35
|
+
_css = function _css() {
|
|
36
|
+
return data;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return data;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
var _Designer = _interopRequireDefault(require("./Designer"));
|
|
43
|
+
|
|
44
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
45
|
+
|
|
46
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
47
|
+
|
|
48
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
49
|
+
|
|
50
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
51
|
+
|
|
52
|
+
const InternalMap = (0, _react().connect)(props => {
|
|
53
|
+
return _react2().default.createElement("div", {
|
|
54
|
+
className: (0, _css().css)`
|
|
55
|
+
border: 1px solid transparent;
|
|
56
|
+
.ant-formily-item-error & {
|
|
57
|
+
border: 1px solid #ff4d4f;
|
|
58
|
+
}
|
|
59
|
+
`
|
|
60
|
+
}, props.mapType ? _react2().default.createElement(_AMap.default, _objectSpread({}, props)) : null);
|
|
61
|
+
}, (0, _react().mapReadPretty)(_ReadPretty.default));
|
|
62
|
+
const Map = InternalMap;
|
|
63
|
+
Map.Designer = _Designer.default;
|
|
64
|
+
var _default = Map;
|
|
65
|
+
exports.default = _default;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function _react() {
|
|
9
|
+
const data = require("@formily/react");
|
|
10
|
+
|
|
11
|
+
_react = function _react() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _client() {
|
|
19
|
+
const data = require("@nocobase/client");
|
|
20
|
+
|
|
21
|
+
_client = function _client() {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function _react2() {
|
|
29
|
+
const data = _interopRequireWildcard(require("react"));
|
|
30
|
+
|
|
31
|
+
_react2 = function _react2() {
|
|
32
|
+
return data;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
var _AMap = _interopRequireDefault(require("./AMap"));
|
|
39
|
+
|
|
40
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
41
|
+
|
|
42
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
43
|
+
|
|
44
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
45
|
+
|
|
46
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
47
|
+
|
|
48
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
49
|
+
|
|
50
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
51
|
+
|
|
52
|
+
const ReadPretty = props => {
|
|
53
|
+
var _collectionField$uiSc;
|
|
54
|
+
|
|
55
|
+
const value = props.value,
|
|
56
|
+
readOnly = props.readOnly;
|
|
57
|
+
const fieldSchema = (0, _react().useFieldSchema)();
|
|
58
|
+
|
|
59
|
+
const _useCollection = (0, _client().useCollection)(),
|
|
60
|
+
getField = _useCollection.getField;
|
|
61
|
+
|
|
62
|
+
const collectionField = getField(fieldSchema.name);
|
|
63
|
+
const mapType = props.mapType || (collectionField === null || collectionField === void 0 ? void 0 : (_collectionField$uiSc = collectionField.uiSchema['x-component-props']) === null || _collectionField$uiSc === void 0 ? void 0 : _collectionField$uiSc.mapType);
|
|
64
|
+
const field = (0, _react().useField)();
|
|
65
|
+
(0, _react2().useEffect)(() => {
|
|
66
|
+
if (!field.title) {
|
|
67
|
+
field.title = collectionField.uiSchema.title;
|
|
68
|
+
}
|
|
69
|
+
}, collectionField.title);
|
|
70
|
+
if (!readOnly) return _react2().default.createElement("div", {
|
|
71
|
+
style: {
|
|
72
|
+
whiteSpace: 'pre-wrap'
|
|
73
|
+
}
|
|
74
|
+
}, value === null || value === void 0 ? void 0 : value.map(item => Array.isArray(item) ? `(${item.join(',')})` : item).join(','));
|
|
75
|
+
return mapType === 'amap' ? _react2().default.createElement(_AMap.default, _objectSpread({
|
|
76
|
+
mapType: mapType
|
|
77
|
+
}, props)) : null;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
var _default = ReadPretty;
|
|
81
|
+
exports.default = _default;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function _antd() {
|
|
9
|
+
const data = require("antd");
|
|
10
|
+
|
|
11
|
+
_antd = function _antd() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _css() {
|
|
19
|
+
const data = require("@emotion/css");
|
|
20
|
+
|
|
21
|
+
_css = function _css() {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function _react() {
|
|
29
|
+
const data = _interopRequireWildcard(require("react"));
|
|
30
|
+
|
|
31
|
+
_react = function _react() {
|
|
32
|
+
return data;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function _ahooks() {
|
|
39
|
+
const data = require("ahooks");
|
|
40
|
+
|
|
41
|
+
_ahooks = function _ahooks() {
|
|
42
|
+
return data;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return data;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
var _locales = require("../locales");
|
|
49
|
+
|
|
50
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
51
|
+
|
|
52
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
53
|
+
|
|
54
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
55
|
+
|
|
56
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
57
|
+
|
|
58
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
59
|
+
|
|
60
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
61
|
+
|
|
62
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
63
|
+
|
|
64
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
65
|
+
|
|
66
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
67
|
+
|
|
68
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
69
|
+
|
|
70
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
71
|
+
|
|
72
|
+
const Search = props => {
|
|
73
|
+
const aMap = props.aMap,
|
|
74
|
+
toCenter = props.toCenter;
|
|
75
|
+
|
|
76
|
+
const _useMapTranslation = (0, _locales.useMapTranslation)(),
|
|
77
|
+
t = _useMapTranslation.t;
|
|
78
|
+
|
|
79
|
+
const placeSearch = (0, _react().useRef)();
|
|
80
|
+
|
|
81
|
+
const _useState = (0, _react().useState)([]),
|
|
82
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
83
|
+
options = _useState2[0],
|
|
84
|
+
setOptions = _useState2[1];
|
|
85
|
+
|
|
86
|
+
(0, _react().useEffect)(() => {
|
|
87
|
+
aMap === null || aMap === void 0 ? void 0 : aMap.plugin('AMap.PlaceSearch', () => {
|
|
88
|
+
placeSearch.current = new aMap.PlaceSearch({
|
|
89
|
+
city: '全国',
|
|
90
|
+
pageSize: 30
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}, [aMap]);
|
|
94
|
+
|
|
95
|
+
const _useDebounceFn = (0, _ahooks().useDebounceFn)(keyword => {
|
|
96
|
+
if (!placeSearch.current) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
placeSearch.current.search(keyword || ' ', (status, result) => {
|
|
101
|
+
if (status === 'complete') {
|
|
102
|
+
setOptions(result.poiList.pois.map(item => {
|
|
103
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
104
|
+
label: `${item.name}-${item.address}`,
|
|
105
|
+
value: item.id
|
|
106
|
+
});
|
|
107
|
+
}));
|
|
108
|
+
} else {
|
|
109
|
+
if (status === 'no_data') {
|
|
110
|
+
setOptions([]);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
_antd().message.error(t('Please configure the AMap securityCode or securityHost correctly'));
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}, {
|
|
118
|
+
wait: 300
|
|
119
|
+
}),
|
|
120
|
+
onSearch = _useDebounceFn.run;
|
|
121
|
+
|
|
122
|
+
const onSelect = value => {
|
|
123
|
+
const place = options.find(o => {
|
|
124
|
+
return o.value === value;
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
if (place === null || place === void 0 ? void 0 : place.location) {
|
|
128
|
+
toCenter(place.location);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
return _react().default.createElement("div", {
|
|
133
|
+
className: (0, _css().css)`
|
|
134
|
+
position: absolute;
|
|
135
|
+
top: 10px;
|
|
136
|
+
left: 10px;
|
|
137
|
+
z-index: 10;
|
|
138
|
+
width: calc(100% - 20px);
|
|
139
|
+
`
|
|
140
|
+
}, _react().default.createElement(_antd().Select, {
|
|
141
|
+
showSearch: true,
|
|
142
|
+
allowClear: true,
|
|
143
|
+
style: {
|
|
144
|
+
background: 'rgba(255, 255, 255, 0.8)'
|
|
145
|
+
},
|
|
146
|
+
placeholder: t('Enter keywords to search'),
|
|
147
|
+
filterOption: false,
|
|
148
|
+
onSearch: onSearch,
|
|
149
|
+
onSelect: onSelect,
|
|
150
|
+
options: options
|
|
151
|
+
}));
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
var _default = Search;
|
|
155
|
+
exports.default = _default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MapTypes = void 0;
|
|
7
|
+
|
|
8
|
+
var _locales = require("./locales");
|
|
9
|
+
|
|
10
|
+
const MapTypes = [{
|
|
11
|
+
label: (0, _locales.generateNTemplate)('AMap'),
|
|
12
|
+
value: 'amap'
|
|
13
|
+
}, {
|
|
14
|
+
label: (0, _locales.generateNTemplate)('Google Maps'),
|
|
15
|
+
value: 'google'
|
|
16
|
+
}];
|
|
17
|
+
exports.MapTypes = MapTypes;
|