@luomus/laji-form 15.1.52 → 15.1.53

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", null,
405
- React.createElement("strong", { dangerouslySetInnerHTML: { __html: label + requiredHtml } }),
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 undefined;
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 = { located: false };
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.state.moved) {
344
- this.setState({ moved: true });
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.map.map.setView({ lng, lat }, 12);
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.state.moved) {
385
- this.setState({ moved: true });
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.state.moved }, translations.ChooseThisLocation))));
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luomus/laji-form",
3
- "version": "15.1.52",
3
+ "version": "15.1.53",
4
4
  "description": "React module capable of building dynamic forms from Laji form json schemas",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",