@luomus/laji-form 15.1.52 → 15.1.54
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.
|
@@ -401,8 +401,8 @@ function Label({ label, children, id, required, registry = {}, uiSchema = {} })
|
|
|
401
401
|
}, []);
|
|
402
402
|
const LabelComponent = labelComponent || "label";
|
|
403
403
|
const labelElem = (React.createElement(LabelComponent, { htmlFor: id, "aria-describedby": `${id}--help` },
|
|
404
|
-
React.createElement("div",
|
|
405
|
-
React.createElement("
|
|
404
|
+
React.createElement("div", { style: { whiteSpace: "normal" } },
|
|
405
|
+
React.createElement("span", { dangerouslySetInnerHTML: { __html: label + requiredHtml } }),
|
|
406
406
|
showHelp ? React.createElement(Help, { focusable: true, onFocus: onHelpFocus, onBlur: onHelpBlur, onClick: onHelpClick, id: id }) : null),
|
|
407
407
|
children));
|
|
408
408
|
return help ? React.createElement(React.Fragment, null,
|
|
@@ -33,6 +33,7 @@ export default class MapField extends React.Component<any, any, any> {
|
|
|
33
33
|
getDrawOptions: (props: any) => any;
|
|
34
34
|
getGeometry: (props: any) => any;
|
|
35
35
|
getMobileGeometry: () => any;
|
|
36
|
+
setMoved: (moved: any) => void;
|
|
36
37
|
onOptionsChanged: (options: any) => void;
|
|
37
38
|
onChange: (events: any) => void;
|
|
38
39
|
onMobileEditorChange: (point: any) => void;
|
|
@@ -128,9 +128,15 @@ class MapField extends React.Component {
|
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
130
|
else {
|
|
131
|
-
return
|
|
131
|
+
return {
|
|
132
|
+
type: "Point",
|
|
133
|
+
coordinates: [24.94782264266911, 60.17522413438655]
|
|
134
|
+
};
|
|
132
135
|
}
|
|
133
136
|
};
|
|
137
|
+
this.setMoved = (moved) => {
|
|
138
|
+
this.setState({ moved });
|
|
139
|
+
};
|
|
134
140
|
this.onOptionsChanged = (options) => {
|
|
135
141
|
this.setState({ mapOptions: Object.assign(Object.assign({}, this.state.mapOptions), options) });
|
|
136
142
|
};
|
|
@@ -210,7 +216,10 @@ class MapField extends React.Component {
|
|
|
210
216
|
},
|
|
211
217
|
});
|
|
212
218
|
};
|
|
213
|
-
this.state = {
|
|
219
|
+
this.state = {
|
|
220
|
+
located: false,
|
|
221
|
+
moved: false
|
|
222
|
+
};
|
|
214
223
|
this.props.formContext.services.settings.bind(this, props);
|
|
215
224
|
}
|
|
216
225
|
componentDidMount() {
|
|
@@ -238,6 +247,7 @@ class MapField extends React.Component {
|
|
|
238
247
|
}
|
|
239
248
|
}
|
|
240
249
|
render() {
|
|
250
|
+
var _a;
|
|
241
251
|
const TitleFieldTemplate = utils_3.getTemplate("TitleFieldTemplate", this.props.registry, utils_1.getUiOptions(this.props.uiSchema));
|
|
242
252
|
const { uiSchema, formData } = this.props;
|
|
243
253
|
const { height = 400, emptyHelp, mapOptions = {}, mobileEditor: _mobileEditor, data } = utils_1.getUiOptions(uiSchema);
|
|
@@ -283,7 +293,7 @@ class MapField extends React.Component {
|
|
|
283
293
|
React.createElement(MapArrayField_1.MapComponent, Object.assign({}, _mapOptions, { ref: this.setMapRef, draw: this.getDrawOptions(this.props), data: extraData, lang: lang, zoomToData: { paddingInMeters: 200 }, panel: emptyHelp && isEmpty ? { panelTextContent: emptyHelp } : undefined, formContext: this.props.formContext, onOptionsChanged: this.onOptionsChanged })),
|
|
284
294
|
this.map && this.map.container && react_dom_1.createPortal(this.renderBlocker(), this.map.container))),
|
|
285
295
|
this.state.mapRendered && mobileEditor && mobileEditor.visible &&
|
|
286
|
-
React.createElement(MobileEditorMap, Object.assign({}, mobileEditorOptions, { options: mobileEditor.options, onChange: this.onMobileEditorChange, onClose: this.onHideMobileEditorMap, map: this.map, formContext: this.props.formContext, geometry: this.getMobileGeometry() }))));
|
|
296
|
+
React.createElement(MobileEditorMap, Object.assign({}, mobileEditorOptions, { options: mobileEditor.options, onChange: this.onMobileEditorChange, onClose: this.onHideMobileEditorMap, map: this.map, formContext: this.props.formContext, geometry: this.getMobileGeometry(), moved: this.state.moved, setMoved: this.setMoved, defaultLocation: !this.props.formData && !((_a = this.map) === null || _a === void 0 ? void 0 : _a.userLocation) }))));
|
|
287
297
|
}
|
|
288
298
|
renderBlocker() {
|
|
289
299
|
const { blockBeforeLocation } = utils_1.getUiOptions(this.props.uiSchema);
|
|
@@ -340,8 +350,8 @@ class MobileEditorMap extends React.Component {
|
|
|
340
350
|
this.onClose();
|
|
341
351
|
};
|
|
342
352
|
this.handleMapClick = (e) => {
|
|
343
|
-
if (!this.
|
|
344
|
-
this.
|
|
353
|
+
if (!this.props.moved) {
|
|
354
|
+
this.props.setMoved(true);
|
|
345
355
|
}
|
|
346
356
|
this.setMarkerLatLng(e.latlng);
|
|
347
357
|
};
|
|
@@ -369,8 +379,7 @@ class MobileEditorMap extends React.Component {
|
|
|
369
379
|
};
|
|
370
380
|
const { geometry } = this.props;
|
|
371
381
|
this.state = {
|
|
372
|
-
geometry: [{ geoData: geometry }]
|
|
373
|
-
moved: false
|
|
382
|
+
geometry: [{ geoData: geometry }]
|
|
374
383
|
};
|
|
375
384
|
}
|
|
376
385
|
componentDidMount() {
|
|
@@ -379,10 +388,16 @@ class MobileEditorMap extends React.Component {
|
|
|
379
388
|
if (this.props.geometry) {
|
|
380
389
|
const [lng, lat] = this.props.geometry.coordinates;
|
|
381
390
|
this.setMarkerLatLng({ lng, lat });
|
|
382
|
-
this.
|
|
391
|
+
if (this.props.defaultLocation) {
|
|
392
|
+
this.map.map.setView({ lng, lat }, 4);
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
this.map.map.setView({ lng, lat }, 12);
|
|
396
|
+
this.props.setMoved(true);
|
|
397
|
+
}
|
|
383
398
|
this.marker.on("dragend", () => {
|
|
384
|
-
if (!this.
|
|
385
|
-
this.
|
|
399
|
+
if (!this.props.moved) {
|
|
400
|
+
this.props.setMoved(true);
|
|
386
401
|
}
|
|
387
402
|
});
|
|
388
403
|
}
|
|
@@ -409,6 +424,6 @@ class MobileEditorMap extends React.Component {
|
|
|
409
424
|
return (React.createElement(components_2.Fullscreen, { onKeyDown: this.onKeyDown, tabIndex: -1, ref: this.setContainerRef, formContext: this.props.formContext },
|
|
410
425
|
React.createElement(MapArrayField_1.MapComponent, Object.assign({}, mapComponentProps)),
|
|
411
426
|
React.createElement("div", { className: "floating-buttons-container" },
|
|
412
|
-
React.createElement(components_2.Button, { block: true, onClick: this.onChange, ref: this.setOkButtonRef, disabled: !this.
|
|
427
|
+
React.createElement(components_2.Button, { block: true, onClick: this.onChange, variant: "primary", ref: this.setOkButtonRef, disabled: !this.props.moved }, translations.ChooseThisLocation))));
|
|
413
428
|
}
|
|
414
429
|
}
|
|
@@ -1026,7 +1026,8 @@ class ReactAutosuggest extends React.Component {
|
|
|
1026
1026
|
this.onBlur(e);
|
|
1027
1027
|
};
|
|
1028
1028
|
this.onInputKeyDown = (e) => {
|
|
1029
|
-
|
|
1029
|
+
var _a, _b;
|
|
1030
|
+
let state;
|
|
1030
1031
|
switch (e.key) {
|
|
1031
1032
|
case "ArrowDown":
|
|
1032
1033
|
e.preventDefault();
|
|
@@ -1056,10 +1057,7 @@ class ReactAutosuggest extends React.Component {
|
|
|
1056
1057
|
break;
|
|
1057
1058
|
case "Enter":
|
|
1058
1059
|
e.preventDefault();
|
|
1059
|
-
|
|
1060
|
-
if (suggestion) {
|
|
1061
|
-
this.onSuggestionSelected(suggestion);
|
|
1062
|
-
}
|
|
1060
|
+
this.inputElem.blur();
|
|
1063
1061
|
break;
|
|
1064
1062
|
case "Control":
|
|
1065
1063
|
case "Meta":
|
|
@@ -1070,7 +1068,7 @@ class ReactAutosuggest extends React.Component {
|
|
|
1070
1068
|
default:
|
|
1071
1069
|
this.setState({ touched: true });
|
|
1072
1070
|
}
|
|
1073
|
-
this.props.inputProps
|
|
1071
|
+
(_b = (_a = this.props.inputProps) === null || _a === void 0 ? void 0 : _a.onKeyDown) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
1074
1072
|
};
|
|
1075
1073
|
this.onInputChange = (e) => {
|
|
1076
1074
|
this._onInputChange(e.target.value, "keystroke");
|
|
@@ -1121,13 +1119,14 @@ class ReactAutosuggest extends React.Component {
|
|
|
1121
1119
|
this.renderSuggestions()));
|
|
1122
1120
|
}
|
|
1123
1121
|
onBlur(e) {
|
|
1122
|
+
var _a, _b;
|
|
1124
1123
|
if (e.relatedTarget && e.relatedTarget === react_dom_1.findDOMNode(this.listRef.current)) {
|
|
1125
1124
|
return;
|
|
1126
1125
|
}
|
|
1127
1126
|
const suggestion = (this.props.suggestions || [])[this.state.focusedIdx];
|
|
1128
1127
|
suggestion && this.onSuggestionSelected(this.props.suggestions[this.state.focusedIdx]);
|
|
1129
1128
|
this.setState({ focused: false, focusedIdx: undefined, touched: false });
|
|
1130
|
-
this.props.inputProps
|
|
1129
|
+
(_b = (_a = this.props.inputProps) === null || _a === void 0 ? void 0 : _a.onBlur) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
1131
1130
|
}
|
|
1132
1131
|
renderInput() {
|
|
1133
1132
|
const { inputProps, renderInputComponent = this.renderDefaultInputComponent } = this.props;
|