@luomus/laji-form 15.1.102 → 15.1.103

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.
@@ -1,6 +1,6 @@
1
1
  import { Translations } from "./components/LajiForm";
2
2
  import { Lang } from "./types";
3
- import type { paths } from "generated/api";
3
+ import type { paths } from "./generated/api";
4
4
  export declare class LajiApiError extends Error {
5
5
  statusCode: number;
6
6
  constructor(message: string, statusCode: number);
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { ButtonProps as ThemedButtonProps } from "src/themes/theme";
2
+ import { ButtonProps as ThemedButtonProps } from "../../themes/theme";
3
3
  export type ButtonProps = ThemedButtonProps & {
4
4
  tooltip?: string;
5
5
  tooltipPlacement?: string;
@@ -1,5 +1,5 @@
1
1
  import * as PropTypes from "prop-types";
2
- import { FieldProps } from "src/types";
2
+ import { FieldProps } from "../../types";
3
3
  declare const _anyToBoolean: {
4
4
  (props: FieldProps): JSX.Element;
5
5
  propTypes: {
@@ -643,9 +643,9 @@ let LineTransectMapArrayField = class LineTransectMapArrayField extends React.Co
643
643
  formData = syncLineTransectStartEnd(formData);
644
644
  this.props.onChange(addOrDelete ? (0, ArrayField_1.onArrayFieldChange)(formData, this.props) : formData);
645
645
  }
646
- if ("activeIdx" in state) {
647
- this.afterActiveChange(state.activeIdx);
648
- }
646
+ // if ("activeIdx" in state) {
647
+ // this.afterActiveChange(state.activeIdx);
648
+ // }
649
649
  };
650
650
  Object.keys(state).length ? this.setState(state, afterState()) : afterState();
651
651
  };
@@ -672,18 +672,30 @@ let LineTransectMapArrayField = class LineTransectMapArrayField extends React.Co
672
672
  content = `${content}<br/>${translations.LineTransectSegmentNotCounted}`;
673
673
  return content;
674
674
  };
675
- this.focusOnMap = (idx) => {
675
+ this.focusOnMap = (idx, initialCall) => {
676
676
  if (!this.hasLineTransectFeature(this.props)) {
677
677
  setTimeout(() => this.map.zoomToData({ paddingInMeters: 200 }));
678
678
  return;
679
679
  }
680
680
  this.props.formContext.setTimeout(() => {
681
- this.map && this.map.fitBounds(L.featureGroup(this.map._corridorLayers[idx]).getBounds(), { paddingInMeters: 100 });
681
+ if (!this.map) {
682
+ return;
683
+ }
684
+ const bounds = L.featureGroup(this.map._corridorLayers[idx]).getBounds();
685
+ if (initialCall) {
686
+ this.map.fitBounds(bounds, { paddingInMeters: 100 });
687
+ }
688
+ else if (bounds.isValid()) {
689
+ this.map.map.panTo(bounds.getCenter());
690
+ }
682
691
  });
683
692
  };
684
693
  this.state = { showLTTools: false };
685
694
  this.props.onChange(syncLineTransectStartEnd(this.props.formData));
686
695
  }
696
+ componentDidMount() {
697
+ this.focusOnMap(this.state.idx);
698
+ }
687
699
  getOptions() {
688
700
  const { formData, disabled, readonly } = this.props;
689
701
  const { geometryField, placeholderGeometry } = (0, utils_2.getUiOptions)(this.props.uiSchema);
@@ -736,8 +748,8 @@ let LineTransectMapArrayField = class LineTransectMapArrayField extends React.Co
736
748
  }]
737
749
  };
738
750
  }
739
- afterActiveChange(idx) {
740
- this.focusOnMap(idx);
751
+ afterActiveChange(idx, initialCall) {
752
+ this.focusOnMap(idx, initialCall);
741
753
  }
742
754
  hasLineTransectFeature(props) {
743
755
  const { geometryField } = (0, utils_2.getUiOptions)(props.uiSchema);
@@ -1296,8 +1308,8 @@ function _MapArrayField(ComposedComponent) {
1296
1308
  this.afterActiveChange(this.state.activeIdx, !!"initial call");
1297
1309
  }
1298
1310
  }
1299
- afterActiveChange(idx) {
1300
- super.afterActiveChange && super.afterActiveChange(idx);
1311
+ afterActiveChange(idx, initialCall) {
1312
+ super.afterActiveChange && super.afterActiveChange(idx, initialCall);
1301
1313
  this.onLocateOrAddNew();
1302
1314
  }
1303
1315
  componentWillUnmount() {
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { FieldProps, JSONSchemaObject } from "src/types";
2
+ import { FieldProps, JSONSchemaObject } from "../../types";
3
3
  import * as PropTypes from "prop-types";
4
4
  interface State {
5
5
  activeIdx: number[];
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { ByLang, FormContext } from "../../LajiForm";
3
3
  import memoize from "memoizee";
4
- import type { components } from "generated/api.d";
4
+ import type { components } from "../../../generated/api.d";
5
5
  type NamedPlace = components["schemas"]["store-namedPlace"];
6
6
  type Props = {
7
7
  places: NamedPlace[];
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { FieldProps, JSONSchemaArray, JSONSchemaObject } from "../../../types";
3
- import type { components } from "generated/api.d";
3
+ import type { components } from "../../../generated/api.d";
4
4
  type NamedPlace = components["schemas"]["store-namedPlace"];
5
5
  type Props = FieldProps<NamedPlace, JSONSchemaObject | JSONSchemaArray<JSONSchemaObject>>;
6
6
  type State = {
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { FormContext } from "src/components/LajiForm";
3
- import type { components } from "generated/api.d";
3
+ import type { components } from "../../../generated/api.d";
4
4
  type NamedPlace = components["schemas"]["store-namedPlace"];
5
5
  type Props = {
6
6
  onPlaceSelected: (place: NamedPlace) => void;
@@ -1,5 +1,5 @@
1
1
  import * as PropTypes from "prop-types";
2
- import { FieldProps, WidgetProps } from "src/types";
2
+ import { FieldProps, WidgetProps } from "../../types";
3
3
  export declare const AnyToBoolean: (props: FieldProps | (WidgetProps & {
4
4
  widget: true;
5
5
  })) => JSX.Element;