@luomus/laji-form 15.1.33 → 15.1.35

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.
@@ -321,6 +321,9 @@ class MobileEditorMap extends React.Component {
321
321
  this.setOkButtonRef = (elem) => {
322
322
  this.okButtonElem = react_dom_1.findDOMNode(elem);
323
323
  };
324
+ this.updateDimensions = () => {
325
+ this.setState({ width: window.innerWidth, height: window.innerHeight });
326
+ };
324
327
  this.onChange = () => {
325
328
  const { map } = this.map;
326
329
  const centerLatLng = map.getCenter();
@@ -395,23 +398,31 @@ class MobileEditorMap extends React.Component {
395
398
  this.props.onClose(this.map.getOptions());
396
399
  };
397
400
  const { center, radius } = this.props;
398
- this.state = { mapOptions: this.setViewFromCenterAndRadius(center, radius) };
401
+ this.state = {
402
+ mapOptions: this.setViewFromCenterAndRadius(center, radius),
403
+ width: window.innerWidth,
404
+ height: window.innerHeight
405
+ };
399
406
  }
400
407
  componentDidMount() {
401
408
  this.mounted = true;
402
409
  this.okButtonElem.focus();
410
+ window.addEventListener("resize", this.updateDimensions);
403
411
  }
404
412
  componenWillUnmount() {
405
413
  this.mounted = false;
414
+ window.removeEventListener("resize", this.updateDimensions);
406
415
  }
407
416
  getCircle(radiusPixels) {
408
- return (React.createElement("svg", { width: "100%", height: "100%", style: { position: "absolute", zIndex: 1000, top: 0, pointerEvents: "none" } },
417
+ return (React.createElement("svg", { width: "100%", height: "100%", style: { position: "absolute", zIndex: 1000, top: 0, left: 0, pointerEvents: "none" } },
409
418
  React.createElement("defs", null,
410
419
  React.createElement("mask", { id: "mask", x: "0", y: "0", width: "100%", height: "100%" },
411
420
  React.createElement("rect", { x: "0", y: "0", width: "100%", height: "100%", fill: "#fff" }),
412
421
  React.createElement("circle", { cx: "50%", cy: "50%", r: radiusPixels }))),
413
422
  React.createElement("rect", { x: "0", y: "0", width: "100%", height: "100%", mask: "url(#mask)", fillOpacity: "0.2" }),
414
- React.createElement("circle", { cx: "50%", cy: "50%", r: radiusPixels, stroke: "black", strokeWidth: "2", fillOpacity: "0" })));
423
+ React.createElement("circle", { cx: "50%", cy: "50%", r: radiusPixels, stroke: "black", strokeWidth: "2", fillOpacity: "0" }),
424
+ React.createElement("line", { x1: this.state.width / 2, y1: this.state.height / 2 - radiusPixels, x2: this.state.width / 2, y2: this.state.height / 2 + radiusPixels, stroke: "black", strokeWidth: "2" }),
425
+ React.createElement("line", { x1: this.state.width / 2 - radiusPixels, y1: this.state.height / 2, x2: this.state.width / 2 + radiusPixels, y2: this.state.height / 2, stroke: "black", strokeWidth: "2" })));
415
426
  }
416
427
  render() {
417
428
  let _a = this.props.map.getOptions(), { rootElem, customControls, draw, data, zoomToData, zoom, center, locate } = _a, options = __rest(_a, ["rootElem", "customControls", "draw", "data", "zoomToData", "zoom", "center", "locate"]); // eslint-disable-line @typescript-eslint/no-unused-vars
@@ -20,10 +20,12 @@ export class Autosuggest extends React.Component<any, any, any> {
20
20
  uiSchema: PropTypes.Requireable<object>;
21
21
  informalTaxonGroups: PropTypes.Requireable<string>;
22
22
  onInformalTaxonGroupSelected: PropTypes.Requireable<(...args: any[]) => any>;
23
+ cache: PropTypes.Requireable<boolean>;
23
24
  };
24
25
  static defaultProps: {
25
26
  allowNonsuggestedValue: boolean;
26
27
  suggestionReceive: string;
28
+ cache: boolean;
27
29
  };
28
30
  constructor(props: any);
29
31
  isValueSuggested: (props: any) => any;
@@ -320,19 +320,19 @@ class FriendsAutosuggestWidget extends React.Component {
320
320
  FriendsAutosuggestWidget.contextType = ReactContext_1.default;
321
321
  class OrganizationAutosuggestWidget extends React.Component {
322
322
  render() {
323
- return (React.createElement(BasicAutosuggestWidget, Object.assign({}, this.props, this.props.options, { nameField: "fullName", validValueRegexp: "MOS.\\d+", Wrapper: OrganizationWrapper })));
323
+ return (React.createElement(BasicAutosuggestWidget, Object.assign({}, this.props, this.props.options, { nameField: "fullName", validValueRegexp: "MOS.\\d+", cache: false, Wrapper: OrganizationWrapper })));
324
324
  }
325
325
  }
326
326
  OrganizationAutosuggestWidget.contextType = ReactContext_1.default;
327
327
  class CollectionAutosuggestWidget extends React.Component {
328
328
  render() {
329
- return (React.createElement(BasicAutosuggestWidget, Object.assign({}, this.props, this.props.options, { nameField: "collectionName", validValueRegexp: "HR.\\d+", Wrapper: CollectionWrapper })));
329
+ return (React.createElement(BasicAutosuggestWidget, Object.assign({}, this.props, this.props.options, { nameField: "collectionName", validValueRegexp: "HR.\\d+", cache: false, Wrapper: CollectionWrapper })));
330
330
  }
331
331
  }
332
332
  CollectionAutosuggestWidget.contextType = ReactContext_1.default;
333
333
  class DatasetAutosuggestWidget extends React.Component {
334
334
  render() {
335
- return (React.createElement(BasicAutosuggestWidget, Object.assign({}, this.props, this.props.options, { nameField: "datasetName", validValueRegexp: "GX.\\d+", Wrapper: DatasetWrapper })));
335
+ return (React.createElement(BasicAutosuggestWidget, Object.assign({}, this.props, this.props.options, { nameField: "datasetName", validValueRegexp: "GX.\\d+", cache: false, Wrapper: DatasetWrapper })));
336
336
  }
337
337
  }
338
338
  DatasetAutosuggestWidget.contextType = ReactContext_1.default;
@@ -348,7 +348,9 @@ class BasicAutosuggestWidget extends React.Component {
348
348
  getSuggestionFromValue(value) {
349
349
  const { autosuggestField, nameField } = this.props;
350
350
  if (this.isValueSuggested(value)) {
351
- return this.props.formContext.apiClient.fetchCached(`/${autosuggestField}/by-id/${value}`).then(result => {
351
+ const apiClient = this.props.formContext.apiClient;
352
+ const fetch = (this.props.cache ? apiClient.fetchCached : apiClient.fetch).bind(apiClient);
353
+ return fetch(`/${autosuggestField}/by-id/${value}`).then(result => {
352
354
  if (result[nameField]) {
353
355
  return {
354
356
  value: result[nameField],
@@ -386,11 +388,13 @@ BasicAutosuggestWidget.propTypes = {
386
388
  uiSchema: PropTypes.object,
387
389
  nameField: PropTypes.string,
388
390
  validValueRegexp: PropTypes.string,
391
+ cache: PropTypes.bool,
389
392
  Wrapper: PropTypes.object
390
393
  };
391
394
  BasicAutosuggestWidget.defaultProps = {
392
395
  nameField: "name",
393
- validValueRegexp: ""
396
+ validValueRegexp: "",
397
+ cache: true
394
398
  };
395
399
  class RangeAutosuggestWidget extends React.Component {
396
400
  render() {
@@ -535,7 +539,8 @@ class Autosuggest extends React.Component {
535
539
  const request = () => {
536
540
  let timestamp = Date.now();
537
541
  this.promiseTimestamp = timestamp;
538
- this.apiClient.fetchCached("/autocomplete/" + autosuggestField, Object.assign({ q: value, includePayload: true, matchType: "exact,partial", includeHidden: false }, query)).then(suggestions => {
542
+ const fetch = (this.props.cache ? this.apiClient.fetchCached : this.apiClient.fetch).bind(this.apiClient);
543
+ fetch("/autocomplete/" + autosuggestField, Object.assign({ q: value, includePayload: true, matchType: "exact,partial", includeHidden: false }, query)).then(suggestions => {
539
544
  if (this.props.prepareSuggestion) {
540
545
  suggestions = suggestions.map(s => this.props.prepareSuggestion(s));
541
546
  }
@@ -776,11 +781,13 @@ Autosuggest.propTypes = {
776
781
  onInputChange: PropTypes.func,
777
782
  uiSchema: PropTypes.object,
778
783
  informalTaxonGroups: PropTypes.string,
779
- onInformalTaxonGroupSelected: PropTypes.func
784
+ onInformalTaxonGroupSelected: PropTypes.func,
785
+ cache: PropTypes.bool
780
786
  };
781
787
  Autosuggest.defaultProps = {
782
788
  allowNonsuggestedValue: true,
783
- suggestionReceive: "key"
789
+ suggestionReceive: "key",
790
+ cache: true
784
791
  };
785
792
  class _TaxonWrapper extends React.Component {
786
793
  constructor(props) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luomus/laji-form",
3
- "version": "15.1.33",
3
+ "version": "15.1.35",
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",