@luomus/laji-form 15.1.0 → 15.1.2
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/CHANGELOG.md +0 -4
- package/dist/laji-form.js +1 -1
- package/jsonconfig.json +26 -0
- package/migrate.sh +0 -1
- package/package.json +8 -8
- package/test-export/test-utils.d.ts +100 -54
- package/test-export/test-utils.js +102 -84
- package/xsel -b +9 -0
- package/cypress/fixtures/example.json +0 -5
- package/cypress/screenshots/nafi.cy.ts/NAFI (MHL.6) -- selecting species name with keyboard navigation -- and closes suggestion list (failed).png +0 -0
- package/cypress/screenshots/nafi.cy.ts/NAFI (MHL.6) -- selecting species name with keyboard navigation -- and is marked as suggested (failed).png +0 -0
- package/lib/ApiClient.d.ts +0 -46
- package/lib/ApiClient.js +0 -93
- package/lib/Context.d.ts +0 -8
- package/lib/Context.js +0 -18
- package/lib/ReactContext.d.ts +0 -7
- package/lib/ReactContext.js +0 -5
- package/lib/components/BaseComponent.d.ts +0 -9
- package/lib/components/BaseComponent.js +0 -29
- package/lib/components/LajiForm.d.ts +0 -221
- package/lib/components/LajiForm.js +0 -615
- package/lib/components/VirtualSchemaField.d.ts +0 -42
- package/lib/components/VirtualSchemaField.js +0 -74
- package/lib/components/components.d.ts +0 -119
- package/lib/components/components.js +0 -606
- package/lib/components/fields/AnnotationField.d.ts +0 -34
- package/lib/components/fields/AnnotationField.js +0 -242
- package/lib/components/fields/AnyToBooleanField.d.ts +0 -18
- package/lib/components/fields/AnyToBooleanField.js +0 -20
- package/lib/components/fields/ArrayBulkField.d.ts +0 -23
- package/lib/components/fields/ArrayBulkField.js +0 -82
- package/lib/components/fields/ArrayCombinerField.d.ts +0 -36
- package/lib/components/fields/ArrayCombinerField.js +0 -138
- package/lib/components/fields/ArrayField.d.ts +0 -39
- package/lib/components/fields/ArrayField.js +0 -148
- package/lib/components/fields/AudioArrayField.d.ts +0 -22
- package/lib/components/fields/AudioArrayField.js +0 -100
- package/lib/components/fields/AutoArrayField.d.ts +0 -24
- package/lib/components/fields/AutoArrayField.js +0 -56
- package/lib/components/fields/AutosuggestField.d.ts +0 -69
- package/lib/components/fields/AutosuggestField.js +0 -299
- package/lib/components/fields/CombinedValueDisplayField.d.ts +0 -41
- package/lib/components/fields/CombinedValueDisplayField.js +0 -100
- package/lib/components/fields/ConditionalOnChangeField.d.ts +0 -42
- package/lib/components/fields/ConditionalOnChangeField.js +0 -107
- package/lib/components/fields/ConditionalUiSchemaField.d.ts +0 -123
- package/lib/components/fields/ConditionalUiSchemaField.js +0 -143
- package/lib/components/fields/ContextInjectionField.d.ts +0 -24
- package/lib/components/fields/ContextInjectionField.js +0 -68
- package/lib/components/fields/DataLeakerField.d.ts +0 -40
- package/lib/components/fields/DataLeakerField.js +0 -68
- package/lib/components/fields/DefaultValueArrayField.d.ts +0 -34
- package/lib/components/fields/DefaultValueArrayField.js +0 -59
- package/lib/components/fields/DependentBooleanField.d.ts +0 -38
- package/lib/components/fields/DependentBooleanField.js +0 -87
- package/lib/components/fields/DependentDisableField.d.ts +0 -35
- package/lib/components/fields/DependentDisableField.js +0 -71
- package/lib/components/fields/EnumRangeArrayField.d.ts +0 -27
- package/lib/components/fields/EnumRangeArrayField.js +0 -115
- package/lib/components/fields/ExtraLabelRowField.d.ts +0 -38
- package/lib/components/fields/ExtraLabelRowField.js +0 -100
- package/lib/components/fields/FakePropertyField.d.ts +0 -18
- package/lib/components/fields/FakePropertyField.js +0 -48
- package/lib/components/fields/FilterArrayField.d.ts +0 -73
- package/lib/components/fields/FilterArrayField.js +0 -121
- package/lib/components/fields/FlatField.d.ts +0 -29
- package/lib/components/fields/FlatField.js +0 -171
- package/lib/components/fields/GeocoderField.d.ts +0 -47
- package/lib/components/fields/GeocoderField.js +0 -372
- package/lib/components/fields/GridLayoutField.d.ts +0 -18
- package/lib/components/fields/GridLayoutField.js +0 -32
- package/lib/components/fields/HiddenField.d.ts +0 -10
- package/lib/components/fields/HiddenField.js +0 -11
- package/lib/components/fields/ImageArrayField.d.ts +0 -172
- package/lib/components/fields/ImageArrayField.js +0 -697
- package/lib/components/fields/ImageDisplayField.d.ts +0 -18
- package/lib/components/fields/ImageDisplayField.js +0 -44
- package/lib/components/fields/InitiallyHiddenField.d.ts +0 -21
- package/lib/components/fields/InitiallyHiddenField.js +0 -58
- package/lib/components/fields/InjectDefaultValueField.d.ts +0 -37
- package/lib/components/fields/InjectDefaultValueField.js +0 -68
- package/lib/components/fields/InjectField.d.ts +0 -46
- package/lib/components/fields/InjectField.js +0 -88
- package/lib/components/fields/InputWithDefaultValueButtonField.d.ts +0 -25
- package/lib/components/fields/InputWithDefaultValueButtonField.js +0 -61
- package/lib/components/fields/LocalityField.d.ts +0 -22
- package/lib/components/fields/LocalityField.js +0 -94
- package/lib/components/fields/LocationChooserField.d.ts +0 -27
- package/lib/components/fields/LocationChooserField.js +0 -440
- package/lib/components/fields/MapArrayField.d.ts +0 -78
- package/lib/components/fields/MapArrayField.js +0 -1783
- package/lib/components/fields/MapField.d.ts +0 -48
- package/lib/components/fields/MapField.js +0 -434
- package/lib/components/fields/MultiAnyToBooleanField.d.ts +0 -25
- package/lib/components/fields/MultiAnyToBooleanField.js +0 -100
- package/lib/components/fields/MultiArrayField.d.ts +0 -53
- package/lib/components/fields/MultiArrayField.js +0 -224
- package/lib/components/fields/MultiLanguageField.d.ts +0 -13
- package/lib/components/fields/MultiLanguageField.js +0 -52
- package/lib/components/fields/MultiTagArrayField.d.ts +0 -36
- package/lib/components/fields/MultiTagArrayField.js +0 -142
- package/lib/components/fields/NamedPlaceChooserField.d.ts +0 -29
- package/lib/components/fields/NamedPlaceChooserField.js +0 -380
- package/lib/components/fields/NamedPlaceSaverField.d.ts +0 -29
- package/lib/components/fields/NamedPlaceSaverField.js +0 -237
- package/lib/components/fields/NestField.d.ts +0 -148
- package/lib/components/fields/NestField.js +0 -289
- package/lib/components/fields/ObjectField.d.ts +0 -2
- package/lib/components/fields/ObjectField.js +0 -119
- package/lib/components/fields/PdfArrayField.d.ts +0 -21
- package/lib/components/fields/PdfArrayField.js +0 -40
- package/lib/components/fields/PrefillingArrayField.d.ts +0 -22
- package/lib/components/fields/PrefillingArrayField.js +0 -65
- package/lib/components/fields/SchemaField.d.ts +0 -7
- package/lib/components/fields/SchemaField.js +0 -109
- package/lib/components/fields/ScopeField.d.ts +0 -85
- package/lib/components/fields/ScopeField.js +0 -521
- package/lib/components/fields/SectionArrayField.d.ts +0 -38
- package/lib/components/fields/SectionArrayField.js +0 -618
- package/lib/components/fields/SelectTreeField.d.ts +0 -39
- package/lib/components/fields/SelectTreeField.js +0 -143
- package/lib/components/fields/SingleActiveArrayField.d.ts +0 -49
- package/lib/components/fields/SingleActiveArrayField.js +0 -974
- package/lib/components/fields/SingleItemArrayField.d.ts +0 -15
- package/lib/components/fields/SingleItemArrayField.js +0 -60
- package/lib/components/fields/SortArrayField.d.ts +0 -73
- package/lib/components/fields/SortArrayField.js +0 -351
- package/lib/components/fields/SplitField.d.ts +0 -28
- package/lib/components/fields/SplitField.js +0 -65
- package/lib/components/fields/StringToArrayField.d.ts +0 -24
- package/lib/components/fields/StringToArrayField.js +0 -48
- package/lib/components/fields/SumField.d.ts +0 -35
- package/lib/components/fields/SumField.js +0 -83
- package/lib/components/fields/TableField.d.ts +0 -18
- package/lib/components/fields/TableField.js +0 -136
- package/lib/components/fields/TagArrayField.d.ts +0 -38
- package/lib/components/fields/TagArrayField.js +0 -128
- package/lib/components/fields/ToggleAdditionalArrayFieldsField.d.ts +0 -26
- package/lib/components/fields/ToggleAdditionalArrayFieldsField.js +0 -81
- package/lib/components/fields/UiFieldApplierField.d.ts +0 -30
- package/lib/components/fields/UiFieldApplierField.js +0 -106
- package/lib/components/fields/UiFieldMapperArrayField.d.ts +0 -42
- package/lib/components/fields/UiFieldMapperArrayField.js +0 -121
- package/lib/components/fields/UnitCountShorthandField.d.ts +0 -22
- package/lib/components/fields/UnitCountShorthandField.js +0 -149
- package/lib/components/fields/UnitListShorthandArrayField.d.ts +0 -26
- package/lib/components/fields/UnitListShorthandArrayField.js +0 -108
- package/lib/components/fields/UnitShorthandField.d.ts +0 -32
- package/lib/components/fields/UnitShorthandField.js +0 -220
- package/lib/components/templates/ArrayFieldTemplate.d.ts +0 -85
- package/lib/components/templates/ArrayFieldTemplate.js +0 -417
- package/lib/components/templates/BaseInputTemplate.d.ts +0 -11
- package/lib/components/templates/BaseInputTemplate.js +0 -80
- package/lib/components/templates/DescriptionField.d.ts +0 -1
- package/lib/components/templates/DescriptionField.js +0 -37
- package/lib/components/templates/ErrorListTemplate.d.ts +0 -9
- package/lib/components/templates/ErrorListTemplate.js +0 -95
- package/lib/components/templates/FieldTemplate.d.ts +0 -6
- package/lib/components/templates/FieldTemplate.js +0 -112
- package/lib/components/templates/ObjectFieldTemplate.d.ts +0 -7
- package/lib/components/templates/ObjectFieldTemplate.js +0 -66
- package/lib/components/templates/TitleField.d.ts +0 -9
- package/lib/components/templates/TitleField.js +0 -51
- package/lib/components/widgets/AnyToBooleanWidget.d.ts +0 -20
- package/lib/components/widgets/AnyToBooleanWidget.js +0 -49
- package/lib/components/widgets/AutosuggestWidget.d.ts +0 -66
- package/lib/components/widgets/AutosuggestWidget.js +0 -1127
- package/lib/components/widgets/CheckboxWidget.d.ts +0 -37
- package/lib/components/widgets/CheckboxWidget.js +0 -139
- package/lib/components/widgets/DateTimeWidget.d.ts +0 -62
- package/lib/components/widgets/DateTimeWidget.js +0 -251
- package/lib/components/widgets/DateWidget.d.ts +0 -23
- package/lib/components/widgets/DateWidget.js +0 -41
- package/lib/components/widgets/HiddenWidget.d.ts +0 -15
- package/lib/components/widgets/HiddenWidget.js +0 -19
- package/lib/components/widgets/ImageSelectWidget.d.ts +0 -14
- package/lib/components/widgets/ImageSelectWidget.js +0 -57
- package/lib/components/widgets/InformalTaxonGroupChooserWidget.d.ts +0 -43
- package/lib/components/widgets/InformalTaxonGroupChooserWidget.js +0 -237
- package/lib/components/widgets/InputGroupWidget.d.ts +0 -21
- package/lib/components/widgets/InputGroupWidget.js +0 -36
- package/lib/components/widgets/InputWithDefaultValueButtonWidget.d.ts +0 -21
- package/lib/components/widgets/InputWithDefaultValueButtonWidget.js +0 -47
- package/lib/components/widgets/NumberWidget.d.ts +0 -13
- package/lib/components/widgets/NumberWidget.js +0 -21
- package/lib/components/widgets/PlainTextWidget.d.ts +0 -12
- package/lib/components/widgets/PlainTextWidget.js +0 -24
- package/lib/components/widgets/SelectWidget.d.ts +0 -52
- package/lib/components/widgets/SelectWidget.js +0 -158
- package/lib/components/widgets/SeparatedDateTimeWidget.d.ts +0 -19
- package/lib/components/widgets/SeparatedDateTimeWidget.js +0 -59
- package/lib/components/widgets/TaxonImageWidget.d.ts +0 -13
- package/lib/components/widgets/TaxonImageWidget.js +0 -30
- package/lib/components/widgets/TextSelectWidget.d.ts +0 -25
- package/lib/components/widgets/TextSelectWidget.js +0 -94
- package/lib/components/widgets/TextareaWidget.d.ts +0 -32
- package/lib/components/widgets/TextareaWidget.js +0 -87
- package/lib/components/widgets/TimeWidget.d.ts +0 -11
- package/lib/components/widgets/TimeWidget.js +0 -19
- package/lib/components/widgets/URLWidget.d.ts +0 -14
- package/lib/components/widgets/URLWidget.js +0 -12
- package/lib/components/widgets/UpperCaseWidget.d.ts +0 -13
- package/lib/components/widgets/UpperCaseWidget.js +0 -21
- package/lib/index.d.ts +0 -20
- package/lib/index.js +0 -50
- package/lib/services/blocker-service.d.ts +0 -11
- package/lib/services/blocker-service.js +0 -55
- package/lib/services/custom-event-service.d.ts +0 -17
- package/lib/services/custom-event-service.js +0 -35
- package/lib/services/dom-id-service.d.ts +0 -8
- package/lib/services/dom-id-service.js +0 -30
- package/lib/services/focus-service.d.ts +0 -13
- package/lib/services/focus-service.js +0 -60
- package/lib/services/id-service.d.ts +0 -22
- package/lib/services/id-service.js +0 -130
- package/lib/services/key-handler-service.d.ts +0 -56
- package/lib/services/key-handler-service.js +0 -184
- package/lib/services/root-instance-service.d.ts +0 -25
- package/lib/services/root-instance-service.js +0 -49
- package/lib/services/settings-service.d.ts +0 -34
- package/lib/services/settings-service.js +0 -154
- package/lib/services/singleton-map-service.d.ts +0 -23
- package/lib/services/singleton-map-service.js +0 -44
- package/lib/services/submit-hook-service.d.ts +0 -24
- package/lib/services/submit-hook-service.js +0 -73
- package/lib/styles.d.ts +0 -1
- package/lib/styles.js +0 -4
- package/lib/themes/bs3.d.ts +0 -3
- package/lib/themes/bs3.js +0 -133
- package/lib/themes/bs5.d.ts +0 -3
- package/lib/themes/bs5.js +0 -111
- package/lib/themes/glyphicon-fa-mapping.d.ts +0 -3
- package/lib/themes/glyphicon-fa-mapping.js +0 -271
- package/lib/themes/stub.d.ts +0 -3
- package/lib/themes/stub.js +0 -82
- package/lib/themes/theme.d.ts +0 -233
- package/lib/themes/theme.js +0 -2
- package/lib/translations.json +0 -847
- package/lib/utils.d.ts +0 -171
- package/lib/utils.js +0 -1191
- package/lib/validation.d.ts +0 -7
- package/lib/validation.js +0 -141
- package/llol +0 -10
- package/llol.pdf +0 -10
- package/playwright-report/index.html +0 -62
- package/q +0 -196
- package/rename.sh +0 -24
- package/trip-report.spec.ts +0 -594
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export function findSingleGeometry(geoJSON: any): any;
|
|
2
|
-
export function getCenterAndRadiusFromGeometry(geometry: any): {
|
|
3
|
-
center?: undefined;
|
|
4
|
-
radius?: undefined;
|
|
5
|
-
} | {
|
|
6
|
-
center: any;
|
|
7
|
-
radius: any;
|
|
8
|
-
};
|
|
9
|
-
export default class MapField extends React.Component<any, any, any> {
|
|
10
|
-
static propTypes: {
|
|
11
|
-
uiSchema: PropTypes.Requireable<PropTypes.InferProps<{
|
|
12
|
-
"ui:options": PropTypes.Requireable<PropTypes.InferProps<{
|
|
13
|
-
mapOptions: PropTypes.Requireable<object>;
|
|
14
|
-
height: PropTypes.Requireable<number>;
|
|
15
|
-
emptyHelp: PropTypes.Requireable<string>;
|
|
16
|
-
geometryCollection: any;
|
|
17
|
-
}>>;
|
|
18
|
-
}>>;
|
|
19
|
-
schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
20
|
-
type: PropTypes.Requireable<string>;
|
|
21
|
-
}>>;
|
|
22
|
-
formData: PropTypes.Requireable<object>;
|
|
23
|
-
};
|
|
24
|
-
constructor(props: any);
|
|
25
|
-
onLocateEventHandler: (geometry: any) => void;
|
|
26
|
-
_lastFormData: any;
|
|
27
|
-
_zoomToDataOnNextTick: boolean | undefined;
|
|
28
|
-
geocode: (prevProps: any) => void;
|
|
29
|
-
zoomIfExternalEdit: (props: any) => void;
|
|
30
|
-
setMapRef: (mapComponent: any) => void;
|
|
31
|
-
map: any;
|
|
32
|
-
showMobileEditorMap: () => void;
|
|
33
|
-
getDrawOptions: (props: any) => any;
|
|
34
|
-
getEditWithModalFeatureStyle: () => {
|
|
35
|
-
fillOpacity: number;
|
|
36
|
-
color: string;
|
|
37
|
-
weight: string;
|
|
38
|
-
};
|
|
39
|
-
getGeometry: (props: any) => any;
|
|
40
|
-
onOptionsChanged: (options: any) => void;
|
|
41
|
-
onChange: (events: any) => void;
|
|
42
|
-
onMobileEditorChange: (point: any) => void;
|
|
43
|
-
onHideMobileEditorMap: (options: any) => void;
|
|
44
|
-
onLocate: (latlng: any, radius: any, forceShow: any) => void;
|
|
45
|
-
renderBlocker(): JSX.Element | undefined;
|
|
46
|
-
}
|
|
47
|
-
import * as React from "react";
|
|
48
|
-
import * as PropTypes from "prop-types";
|
|
@@ -1,434 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.getCenterAndRadiusFromGeometry = exports.findSingleGeometry = void 0;
|
|
15
|
-
const React = require("react");
|
|
16
|
-
const react_dom_1 = require("react-dom");
|
|
17
|
-
const PropTypes = require("prop-types");
|
|
18
|
-
const MapArrayField_1 = require("./MapArrayField");
|
|
19
|
-
const components_1 = require("../components");
|
|
20
|
-
const utils_1 = require("../../utils");
|
|
21
|
-
const equals = require("deep-equal");
|
|
22
|
-
const Spinner = require("react-spinner");
|
|
23
|
-
const components_2 = require("../components");
|
|
24
|
-
const utils_2 = require("@luomus/laji-map/lib/utils");
|
|
25
|
-
const utils_3 = require("@rjsf/utils");
|
|
26
|
-
function findSingleGeometry(geoJSON) {
|
|
27
|
-
if (!geoJSON)
|
|
28
|
-
return undefined;
|
|
29
|
-
switch (geoJSON.type) {
|
|
30
|
-
case "FeatureCollection":
|
|
31
|
-
return geoJSON.features.length === 1
|
|
32
|
-
? findSingleGeometry(geoJSON.features[0])
|
|
33
|
-
: undefined;
|
|
34
|
-
case "GeometryCollection":
|
|
35
|
-
return geoJSON.geometries.length === 1
|
|
36
|
-
? findSingleGeometry(geoJSON.geometries[0])
|
|
37
|
-
: undefined;
|
|
38
|
-
case "Feature":
|
|
39
|
-
return findSingleGeometry(geoJSON.geometry);
|
|
40
|
-
case undefined:
|
|
41
|
-
return undefined;
|
|
42
|
-
default:
|
|
43
|
-
return geoJSON && geoJSON.coordinates ? geoJSON : undefined;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.findSingleGeometry = findSingleGeometry;
|
|
47
|
-
function getCenterAndRadiusFromGeometry(geometry) {
|
|
48
|
-
const singleGeometry = findSingleGeometry(geometry);
|
|
49
|
-
if (!singleGeometry) {
|
|
50
|
-
return {};
|
|
51
|
-
}
|
|
52
|
-
let center, radius;
|
|
53
|
-
if (singleGeometry && singleGeometry.type === "Point") {
|
|
54
|
-
center = singleGeometry.coordinates.slice(0).reverse();
|
|
55
|
-
radius = singleGeometry.radius;
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
const bounds = new L.GeoJSON(utils_2.anyToFeatureCollection(geometry)).getBounds();
|
|
59
|
-
center = bounds.getCenter();
|
|
60
|
-
radius = bounds.getSouthWest().distanceTo(bounds.getSouthEast()) / 2;
|
|
61
|
-
}
|
|
62
|
-
return { center, radius };
|
|
63
|
-
}
|
|
64
|
-
exports.getCenterAndRadiusFromGeometry = getCenterAndRadiusFromGeometry;
|
|
65
|
-
class MapField extends React.Component {
|
|
66
|
-
constructor(props) {
|
|
67
|
-
super(props);
|
|
68
|
-
this.onLocateEventHandler = (geometry) => {
|
|
69
|
-
if (geometry) {
|
|
70
|
-
this.onLocate({ lat: geometry.coordinates[1], lng: geometry.coordinates[0] }, 100, !!"force");
|
|
71
|
-
}
|
|
72
|
-
else if (!this.getGeometry(this.props)) {
|
|
73
|
-
this.setState({ locateOn: true });
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
this.geocode = (prevProps) => {
|
|
77
|
-
let { area } = utils_1.getUiOptions(this.props.uiSchema);
|
|
78
|
-
if (area instanceof Array) {
|
|
79
|
-
area = area[0];
|
|
80
|
-
}
|
|
81
|
-
const isEmptyAndWasEmpty = [this.props, prevProps].every(props => {
|
|
82
|
-
const { geoData } = this.getDrawOptions(props);
|
|
83
|
-
return !geoData
|
|
84
|
-
|| (utils_1.isObject(geoData) && Object.keys(geoData).length === 0)
|
|
85
|
-
|| (geoData.type === "GeometryCollection" && geoData.geometries.length === 0)
|
|
86
|
-
|| (geoData.type === "FeatureCollection" && geoData.features.length === 0);
|
|
87
|
-
});
|
|
88
|
-
if (isEmptyAndWasEmpty && area && area.length > 0) {
|
|
89
|
-
this.props.formContext.apiClient.fetch(`/areas/${area}`, undefined, undefined).then((result) => {
|
|
90
|
-
this.map.geocode(result.name, undefined, 8);
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
this.zoomIfExternalEdit = (props) => {
|
|
95
|
-
if (!equals(this._lastFormData, props.formData)) {
|
|
96
|
-
this.map.zoomToData();
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
this.setMapRef = (mapComponent) => {
|
|
100
|
-
if (mapComponent && mapComponent.refs && mapComponent.refs.map) {
|
|
101
|
-
this.map = mapComponent.refs.map.map;
|
|
102
|
-
this.setState({ mapRendered: true });
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
this.showMobileEditorMap = () => {
|
|
106
|
-
this.setState({ mobileEditor: { visible: true, options: (this.state.mobileEditor || {}).options || {} } });
|
|
107
|
-
};
|
|
108
|
-
this.getDrawOptions = (props) => {
|
|
109
|
-
const { uiSchema, disabled, readonly } = props;
|
|
110
|
-
const options = utils_1.getUiOptions(uiSchema);
|
|
111
|
-
const { mapOptions = {}, mobileEditor } = options;
|
|
112
|
-
const drawOptions = Object.assign(Object.assign({}, (mapOptions.draw || {})), { geoData: this.getGeometry(props), onChange: this.onChange, editable: !disabled && !readonly });
|
|
113
|
-
if (mobileEditor) {
|
|
114
|
-
drawOptions.getFeatureStyle = this.getEditWithModalFeatureStyle;
|
|
115
|
-
}
|
|
116
|
-
return drawOptions;
|
|
117
|
-
};
|
|
118
|
-
this.getEditWithModalFeatureStyle = () => ({
|
|
119
|
-
fillOpacity: 0,
|
|
120
|
-
color: "black",
|
|
121
|
-
weight: "2",
|
|
122
|
-
});
|
|
123
|
-
this.getGeometry = (props) => {
|
|
124
|
-
const { formData } = props;
|
|
125
|
-
return formData && Object.keys(formData).length ? formData : undefined;
|
|
126
|
-
};
|
|
127
|
-
this.onOptionsChanged = (options) => {
|
|
128
|
-
this.setState({ mapOptions: Object.assign(Object.assign({}, this.state.mapOptions), options) });
|
|
129
|
-
};
|
|
130
|
-
this.onChange = (events) => {
|
|
131
|
-
const { geometryCollection = true } = utils_1.getUiOptions(this.props.uiSchema);
|
|
132
|
-
let formData;
|
|
133
|
-
events.forEach(e => {
|
|
134
|
-
switch (e.type) {
|
|
135
|
-
case "create":
|
|
136
|
-
formData = geometryCollection ? {
|
|
137
|
-
type: "GeometryCollection",
|
|
138
|
-
geometries: [e.feature.geometry]
|
|
139
|
-
} : e.feature.geometry;
|
|
140
|
-
break;
|
|
141
|
-
case "edit":
|
|
142
|
-
formData = geometryCollection ? {
|
|
143
|
-
type: "GeometryCollection",
|
|
144
|
-
geometries: [e.features[0].geometry]
|
|
145
|
-
} : e.features[0].geometry;
|
|
146
|
-
break;
|
|
147
|
-
case "delete":
|
|
148
|
-
formData = geometryCollection ? {
|
|
149
|
-
type: "GeometryCollection",
|
|
150
|
-
geometries: []
|
|
151
|
-
} : {};
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
this._zoomToDataOnNextTick = true;
|
|
155
|
-
this.props.onChange(formData);
|
|
156
|
-
};
|
|
157
|
-
this.onMobileEditorChange = (point) => {
|
|
158
|
-
const geometry = this.getGeometry(this.props);
|
|
159
|
-
const feature = {
|
|
160
|
-
type: "Feature",
|
|
161
|
-
geometry: point
|
|
162
|
-
};
|
|
163
|
-
if (geometry) {
|
|
164
|
-
this.onChange([{ type: "edit", features: [feature] }]);
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
this.onChange([{ type: "create", feature }]);
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
this.onHideMobileEditorMap = (options) => {
|
|
171
|
-
this.setState({ mobileEditor: { visible: false, options } });
|
|
172
|
-
};
|
|
173
|
-
this.onLocate = (latlng, radius, forceShow) => {
|
|
174
|
-
const { geometryCollection = true, mobileEditor, createOnLocate } = utils_1.getUiOptions(this.props.uiSchema);
|
|
175
|
-
const isEmpty = !this.getGeometry(this.props);
|
|
176
|
-
if (!latlng || !isEmpty) {
|
|
177
|
-
this.setState({ located: true });
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
if (mobileEditor) {
|
|
181
|
-
if (!this.state.located || forceShow) {
|
|
182
|
-
this.setState({
|
|
183
|
-
mobileEditor: {
|
|
184
|
-
visible: true,
|
|
185
|
-
center: latlng,
|
|
186
|
-
radius,
|
|
187
|
-
options: (this.state.mobileEditor || {}).options || {}
|
|
188
|
-
},
|
|
189
|
-
located: true
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
this.setState({ located: true });
|
|
195
|
-
if (createOnLocate) {
|
|
196
|
-
const geometry = { type: "Point", coordinates: [latlng.lng, latlng.lat] };
|
|
197
|
-
this.props.onChange(geometryCollection ? { type: "GeometryCollection", geometries: [geometry] } : geometry);
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
this.state = { located: false };
|
|
201
|
-
this.props.formContext.services.settings.bind(this, props);
|
|
202
|
-
}
|
|
203
|
-
componentDidMount() {
|
|
204
|
-
const { uiSchema } = this.props;
|
|
205
|
-
const { mapOptions = {} } = utils_1.getUiOptions(uiSchema);
|
|
206
|
-
if (mapOptions.singleton) {
|
|
207
|
-
const { map } = this.props.formContext.services.singletonMap;
|
|
208
|
-
if (map && map.getOptions().locate && map.userLocation) {
|
|
209
|
-
this.onLocate(map.userLocation.latlng, map.userLocation.accuracy);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
this.geocode(this.props);
|
|
213
|
-
this.props.formContext.services.customEvents.add(this.props.idSchema.$id, "locate", this.onLocateEventHandler);
|
|
214
|
-
}
|
|
215
|
-
componentWillUnmount() {
|
|
216
|
-
this.props.formContext.services.customEvents.remove(this.props.idSchema.$id, "locate", this.onLocateEventHandler);
|
|
217
|
-
}
|
|
218
|
-
componentDidUpdate(prevProps) {
|
|
219
|
-
this.geocode(prevProps);
|
|
220
|
-
this.zoomIfExternalEdit(this.props);
|
|
221
|
-
this._lastFormData = this.props.formData;
|
|
222
|
-
if (this._zoomToDataOnNextTick) {
|
|
223
|
-
this.map.zoomToData();
|
|
224
|
-
this._zoomToDataOnNextTick = undefined;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
render() {
|
|
228
|
-
const TitleFieldTemplate = utils_3.getTemplate("TitleFieldTemplate", this.props.registry, utils_1.getUiOptions(this.props.uiSchema));
|
|
229
|
-
const { uiSchema, formData } = this.props;
|
|
230
|
-
const { height = 400, emptyHelp, mapOptions = {}, mobileEditor: _mobileEditor, data } = utils_1.getUiOptions(uiSchema);
|
|
231
|
-
const isEmpty = !formData || !formData.geometries || !formData.geometries.length;
|
|
232
|
-
const _mapOptions = Object.assign(Object.assign(Object.assign({ controls: true, clickBeforeZoomAndPan: true }, mapOptions), (this.state.mapOptions || {})), { locate: {
|
|
233
|
-
on: this.state.locateOn || false,
|
|
234
|
-
onLocationFound: this.onLocate
|
|
235
|
-
} });
|
|
236
|
-
const isSingleton = _mapOptions.singleton;
|
|
237
|
-
let singletonHasLocate = false;
|
|
238
|
-
let singletonRendered = false;
|
|
239
|
-
if (isSingleton) {
|
|
240
|
-
const { map } = this.props.formContext.services.singletonMap;
|
|
241
|
-
if (map) {
|
|
242
|
-
singletonRendered = true;
|
|
243
|
-
singletonHasLocate = map.getOptions().locate;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
if (mapOptions.createOnLocate && !this.state.mapOptions && (!singletonRendered || singletonHasLocate)) {
|
|
247
|
-
_mapOptions.locate.on = true;
|
|
248
|
-
}
|
|
249
|
-
if (_mobileEditor) {
|
|
250
|
-
_mapOptions.controls = false;
|
|
251
|
-
_mapOptions.viewLocked = true;
|
|
252
|
-
_mapOptions.customControls = [{
|
|
253
|
-
text: this.props.formContext.translations.ChooseLocation,
|
|
254
|
-
fn: this.showMobileEditorMap,
|
|
255
|
-
iconCls: "glyphicon glyphicon-pencil"
|
|
256
|
-
}];
|
|
257
|
-
}
|
|
258
|
-
const { lang, topOffset, bottomOffset } = this.props.formContext;
|
|
259
|
-
const { mobileEditor } = this.state;
|
|
260
|
-
let mobileEditorOptions = utils_1.isObject(mobileEditor) ? mobileEditor : {};
|
|
261
|
-
const geometry = this.getGeometry(this.props);
|
|
262
|
-
if (geometry) {
|
|
263
|
-
const { center, radius } = getCenterAndRadiusFromGeometry(geometry);
|
|
264
|
-
mobileEditorOptions = {
|
|
265
|
-
center,
|
|
266
|
-
radius
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
if (this.map && this.map.userLocation) {
|
|
270
|
-
mobileEditorOptions.userLocation = this.map.userLocation;
|
|
271
|
-
}
|
|
272
|
-
const extraData = Array.isArray(data) ? data : [data].map((geoData) => ({ geoData }));
|
|
273
|
-
return (React.createElement("div", null,
|
|
274
|
-
React.createElement(TitleFieldTemplate, { title: this.props.schema.title, schema: this.props.schema }),
|
|
275
|
-
React.createElement(components_1.Affix, Object.assign({}, { topOffset, bottomOffset }),
|
|
276
|
-
React.createElement("div", { style: { height } },
|
|
277
|
-
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 })),
|
|
278
|
-
this.map && this.map.container && react_dom_1.createPortal(this.renderBlocker(), this.map.container))),
|
|
279
|
-
this.state.mapRendered && mobileEditor && mobileEditor.visible &&
|
|
280
|
-
React.createElement(MobileEditorMap, Object.assign({}, mobileEditorOptions, { options: mobileEditor.options, onChange: this.onMobileEditorChange, onClose: this.onHideMobileEditorMap, map: this.map, formContext: this.props.formContext }))));
|
|
281
|
-
}
|
|
282
|
-
renderBlocker() {
|
|
283
|
-
const { blockBeforeLocation } = utils_1.getUiOptions(this.props.uiSchema);
|
|
284
|
-
const geometry = this.getGeometry(this.props);
|
|
285
|
-
if (blockBeforeLocation && !this.state.located && !geometry) {
|
|
286
|
-
return (React.createElement(React.Fragment, null,
|
|
287
|
-
React.createElement("div", { className: "blocker" }),
|
|
288
|
-
React.createElement("div", { className: "blocker-content" },
|
|
289
|
-
React.createElement("span", null,
|
|
290
|
-
this.props.formContext.translations.SearchingForLocation,
|
|
291
|
-
"..."),
|
|
292
|
-
React.createElement(Spinner, null))));
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
exports.default = MapField;
|
|
297
|
-
MapField.propTypes = {
|
|
298
|
-
uiSchema: PropTypes.shape({
|
|
299
|
-
"ui:options": PropTypes.shape({
|
|
300
|
-
mapOptions: PropTypes.object,
|
|
301
|
-
height: PropTypes.number,
|
|
302
|
-
emptyHelp: PropTypes.string,
|
|
303
|
-
geometryCollection: PropTypes.boolean,
|
|
304
|
-
})
|
|
305
|
-
}),
|
|
306
|
-
schema: PropTypes.shape({
|
|
307
|
-
type: PropTypes.oneOf(["object"])
|
|
308
|
-
}).isRequired,
|
|
309
|
-
formData: PropTypes.object
|
|
310
|
-
};
|
|
311
|
-
class MobileEditorMap extends React.Component {
|
|
312
|
-
constructor(props) {
|
|
313
|
-
super(props);
|
|
314
|
-
this.DEFAULT_RADIUS_PIXELS = 100;
|
|
315
|
-
this.setMobileEditorMapRef = (mapComponent) => {
|
|
316
|
-
if (mapComponent && mapComponent.refs && mapComponent.refs.map) {
|
|
317
|
-
this.map = mapComponent.refs.map.map;
|
|
318
|
-
}
|
|
319
|
-
this.setState({ mapRendered: true });
|
|
320
|
-
};
|
|
321
|
-
this.setOkButtonRef = (elem) => {
|
|
322
|
-
this.okButtonElem = react_dom_1.findDOMNode(elem);
|
|
323
|
-
};
|
|
324
|
-
this.onChange = () => {
|
|
325
|
-
const { map } = this.map;
|
|
326
|
-
const centerLatLng = map.getCenter();
|
|
327
|
-
const centerPoint = map.latLngToContainerPoint(centerLatLng);
|
|
328
|
-
const leftEdgeAsLatLng = map.containerPointToLatLng({ x: centerPoint.x - this.DEFAULT_RADIUS_PIXELS, y: centerPoint.y });
|
|
329
|
-
const radius = map.getCenter().distanceTo(leftEdgeAsLatLng);
|
|
330
|
-
this.props.onChange({
|
|
331
|
-
type: "Point",
|
|
332
|
-
coordinates: [centerLatLng.lng, centerLatLng.lat],
|
|
333
|
-
radius
|
|
334
|
-
});
|
|
335
|
-
this.onClose();
|
|
336
|
-
};
|
|
337
|
-
this.computePadding = () => {
|
|
338
|
-
// If the rendered element wasn't full screen, we couldn't use these as height/width.
|
|
339
|
-
const height = window.innerHeight;
|
|
340
|
-
const width = window.innerWidth;
|
|
341
|
-
const topToCircleEdgePixels = parseInt(height / 2 - this.DEFAULT_RADIUS_PIXELS);
|
|
342
|
-
const leftToCircleEdgePixels = parseInt(width / 2 - this.DEFAULT_RADIUS_PIXELS);
|
|
343
|
-
const padding = [
|
|
344
|
-
leftToCircleEdgePixels,
|
|
345
|
-
topToCircleEdgePixels
|
|
346
|
-
];
|
|
347
|
-
return padding;
|
|
348
|
-
};
|
|
349
|
-
this.setViewFromCenterAndRadius = (center, radius) => {
|
|
350
|
-
if (center) {
|
|
351
|
-
if (radius) {
|
|
352
|
-
const centerLatLng = L.latLng(center);
|
|
353
|
-
const data = {
|
|
354
|
-
geoData: {
|
|
355
|
-
type: "Point",
|
|
356
|
-
coordinates: [centerLatLng.lng, centerLatLng.lat],
|
|
357
|
-
radius
|
|
358
|
-
},
|
|
359
|
-
getFeatureStyle: this.invisibleStyle
|
|
360
|
-
};
|
|
361
|
-
const zoomToData = {
|
|
362
|
-
padding: this.computePadding()
|
|
363
|
-
};
|
|
364
|
-
return { data, zoomToData };
|
|
365
|
-
}
|
|
366
|
-
return { center };
|
|
367
|
-
}
|
|
368
|
-
return {};
|
|
369
|
-
};
|
|
370
|
-
this.invisibleStyle = () => {
|
|
371
|
-
return {
|
|
372
|
-
opacity: 0,
|
|
373
|
-
fillOpacity: 0
|
|
374
|
-
};
|
|
375
|
-
};
|
|
376
|
-
this.onKeyDown = ({ key }) => {
|
|
377
|
-
if (key === "Escape") {
|
|
378
|
-
this.onClose();
|
|
379
|
-
}
|
|
380
|
-
};
|
|
381
|
-
this.onLocate = (latlng, accuracy) => {
|
|
382
|
-
if (this.props.center || !this.mounted)
|
|
383
|
-
return;
|
|
384
|
-
const options = this.setViewFromCenterAndRadius(latlng, accuracy);
|
|
385
|
-
if (options.data && options.zoomToData) {
|
|
386
|
-
this.setState({ mapOptions: { data: options.data } }, () => {
|
|
387
|
-
this.map.zoomToData(options.zoomToData);
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
else if (options.center) {
|
|
391
|
-
this.map.setCenter(options.center);
|
|
392
|
-
}
|
|
393
|
-
};
|
|
394
|
-
this.onClose = () => {
|
|
395
|
-
this.props.onClose(this.map.getOptions());
|
|
396
|
-
};
|
|
397
|
-
const { center, radius } = this.props;
|
|
398
|
-
this.state = { mapOptions: this.setViewFromCenterAndRadius(center, radius) };
|
|
399
|
-
}
|
|
400
|
-
componentDidMount() {
|
|
401
|
-
this.mounted = true;
|
|
402
|
-
this.okButtonElem.focus();
|
|
403
|
-
}
|
|
404
|
-
componenWillUnmount() {
|
|
405
|
-
this.mounted = false;
|
|
406
|
-
}
|
|
407
|
-
getCircle(radiusPixels) {
|
|
408
|
-
return (React.createElement("svg", { width: "100%", height: "100%", style: { position: "absolute", zIndex: 1000, top: 0, pointerEvents: "none" } },
|
|
409
|
-
React.createElement("defs", null,
|
|
410
|
-
React.createElement("mask", { id: "mask", x: "0", y: "0", width: "100%", height: "100%" },
|
|
411
|
-
React.createElement("rect", { x: "0", y: "0", width: "100%", height: "100%", fill: "#fff" }),
|
|
412
|
-
React.createElement("circle", { cx: "50%", cy: "50%", r: radiusPixels }))),
|
|
413
|
-
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" })));
|
|
415
|
-
}
|
|
416
|
-
render() {
|
|
417
|
-
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
|
|
418
|
-
const { userLocation } = this.props;
|
|
419
|
-
options = Object.assign(Object.assign(Object.assign({}, options), (this.props.options || {})), this.state.mapOptions);
|
|
420
|
-
options.locate = {
|
|
421
|
-
on: true,
|
|
422
|
-
userLocation,
|
|
423
|
-
onLocationFound: this.onLocate,
|
|
424
|
-
panOnFound: false
|
|
425
|
-
};
|
|
426
|
-
const { translations } = this.props.formContext;
|
|
427
|
-
return (React.createElement(components_2.Fullscreen, { onKeyDown: this.onKeyDown, tabIndex: -1, ref: this.setContainerRef, formContext: this.props.formContext },
|
|
428
|
-
React.createElement(MapArrayField_1.MapComponent, Object.assign({}, options, { singleton: true, clickBeforeZoomAndPan: false, viewLocked: false, controls: { draw: false }, ref: this.setMobileEditorMapRef, formContext: this.props.formContext })),
|
|
429
|
-
this.state.mapRendered && react_dom_1.createPortal(this.getCircle(this.DEFAULT_RADIUS_PIXELS), this.map.container),
|
|
430
|
-
React.createElement("div", { className: "floating-buttons-container" },
|
|
431
|
-
React.createElement(components_2.Button, { block: true, onClick: this.onChange, ref: this.setOkButtonRef }, translations.ChooseThisLocation),
|
|
432
|
-
React.createElement(components_2.Button, { block: true, onClick: this.onClose }, translations.Cancel))));
|
|
433
|
-
}
|
|
434
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export default class MultiAnyToBooleanField extends React.Component<any, any, any> {
|
|
2
|
-
static propTypes: {
|
|
3
|
-
uiSchema: PropTypes.Requireable<PropTypes.InferProps<{
|
|
4
|
-
"ui:options": PropTypes.Requireable<PropTypes.InferProps<{
|
|
5
|
-
groups: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
6
|
-
label: PropTypes.Requireable<string>;
|
|
7
|
-
trueValue: PropTypes.Requireable<any>;
|
|
8
|
-
falseValue: PropTypes.Requireable<any>;
|
|
9
|
-
allowUndefined: PropTypes.Requireable<boolean>;
|
|
10
|
-
}> | null | undefined)[]>;
|
|
11
|
-
}>>;
|
|
12
|
-
}>>;
|
|
13
|
-
schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
14
|
-
type: PropTypes.Requireable<string>;
|
|
15
|
-
}>>;
|
|
16
|
-
formData: PropTypes.Requireable<any[]>;
|
|
17
|
-
};
|
|
18
|
-
constructor(props: any);
|
|
19
|
-
getInitialState(props: any): {
|
|
20
|
-
groupsFormData: any[];
|
|
21
|
-
};
|
|
22
|
-
onChange: (index: any) => (value: any) => void;
|
|
23
|
-
}
|
|
24
|
-
import * as React from "react";
|
|
25
|
-
import * as PropTypes from "prop-types";
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
9
|
-
var t = {};
|
|
10
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
11
|
-
t[p] = s[p];
|
|
12
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
13
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
14
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
15
|
-
t[p[i]] = s[p[i]];
|
|
16
|
-
}
|
|
17
|
-
return t;
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
const React = require("react");
|
|
21
|
-
const BaseComponent_1 = require("../BaseComponent");
|
|
22
|
-
const PropTypes = require("prop-types");
|
|
23
|
-
const utils_1 = require("../../utils");
|
|
24
|
-
const AnyToBooleanField_1 = require("./AnyToBooleanField");
|
|
25
|
-
const utils_2 = require("@rjsf/utils");
|
|
26
|
-
let MultiAnyToBooleanField = class MultiAnyToBooleanField extends React.Component {
|
|
27
|
-
constructor(props) {
|
|
28
|
-
super(props);
|
|
29
|
-
this.onChange = (index) => (value) => {
|
|
30
|
-
const groupsFormData = this.state.groupsFormData;
|
|
31
|
-
groupsFormData[index] = value;
|
|
32
|
-
this.setState({ groupsFormData: groupsFormData });
|
|
33
|
-
const formData = groupsFormData.reduce((arr, val) => {
|
|
34
|
-
if (val !== undefined) {
|
|
35
|
-
arr.push(val);
|
|
36
|
-
}
|
|
37
|
-
return arr;
|
|
38
|
-
}, []);
|
|
39
|
-
this.props.onChange(formData);
|
|
40
|
-
};
|
|
41
|
-
this.state = this.getInitialState(props);
|
|
42
|
-
}
|
|
43
|
-
getInitialState(props) {
|
|
44
|
-
let { groups } = utils_1.getUiOptions(props.uiSchema) || [];
|
|
45
|
-
const { formData } = props;
|
|
46
|
-
const trueValues = groups.map(group => group.trueValue);
|
|
47
|
-
const falseValues = groups.map(group => group.falseValue);
|
|
48
|
-
const groupsFormData = [];
|
|
49
|
-
if (formData) {
|
|
50
|
-
formData.forEach(value => {
|
|
51
|
-
if (value === undefined) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
const trueIndex = trueValues.findIndex(trueValue => props.formContext.utils.formDataEquals(value, trueValue, props.idSchema.$id));
|
|
55
|
-
if (trueIndex !== -1) {
|
|
56
|
-
groupsFormData[trueIndex] = value;
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
const falseIndex = falseValues.findIndex(falseValue => props.formContext.utils.formDataEquals(value, falseValue, props.idSchema.$id));
|
|
60
|
-
if (falseIndex !== -1) {
|
|
61
|
-
groupsFormData[falseIndex] = value;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
return { groupsFormData: groupsFormData };
|
|
67
|
-
}
|
|
68
|
-
render() {
|
|
69
|
-
const TitleFieldTemplate = utils_2.getTemplate("TitleFieldTemplate", this.props.registry, utils_1.getUiOptions(this.props.uiSchema));
|
|
70
|
-
let { groups } = utils_1.getUiOptions(this.props.uiSchema) || [];
|
|
71
|
-
return (React.createElement(React.Fragment, null,
|
|
72
|
-
React.createElement(TitleFieldTemplate, { title: this.props.schema.title, schema: this.props.schema, uiSchema: this.props.uiSchema, registry: this.props.registry }),
|
|
73
|
-
React.createElement("div", { className: "checkbox-row" }, groups.map((group, idx) => {
|
|
74
|
-
const { "ui:help": help, "ui:helpHoverable": helpHoverable, helpPlacement } = group, _group = __rest(group, ["ui:help", "ui:helpHoverable", "helpPlacement"]);
|
|
75
|
-
const groupProps = Object.assign(Object.assign({}, this.props), { schema: Object.assign(Object.assign({}, this.props.schema.items), { title: group.label }), uiSchema: Object.assign(Object.assign({}, this.props.uiSchema), { "ui:options": Object.assign({ falseValue: undefined }, _group), "ui:help": help, "ui:helpHoverable": helpHoverable, "ui:helpPlacement": helpPlacement }), formData: this.state.groupsFormData[idx], onChange: this.onChange(idx) });
|
|
76
|
-
return (React.createElement(React.Fragment, { key: idx },
|
|
77
|
-
React.createElement(AnyToBooleanField_1.default, Object.assign({}, groupProps))));
|
|
78
|
-
}))));
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
MultiAnyToBooleanField.propTypes = {
|
|
82
|
-
uiSchema: PropTypes.shape({
|
|
83
|
-
"ui:options": PropTypes.shape({
|
|
84
|
-
groups: PropTypes.arrayOf(PropTypes.shape({
|
|
85
|
-
label: PropTypes.string,
|
|
86
|
-
trueValue: PropTypes.any,
|
|
87
|
-
falseValue: PropTypes.any,
|
|
88
|
-
allowUndefined: PropTypes.bool
|
|
89
|
-
}))
|
|
90
|
-
})
|
|
91
|
-
}),
|
|
92
|
-
schema: PropTypes.shape({
|
|
93
|
-
type: PropTypes.oneOf(["array"])
|
|
94
|
-
}).isRequired,
|
|
95
|
-
formData: PropTypes.array
|
|
96
|
-
};
|
|
97
|
-
MultiAnyToBooleanField = __decorate([
|
|
98
|
-
BaseComponent_1.default
|
|
99
|
-
], MultiAnyToBooleanField);
|
|
100
|
-
exports.default = MultiAnyToBooleanField;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
export default class MultiArrayField extends React.Component<any, any, any> {
|
|
2
|
-
static propTypes: {
|
|
3
|
-
uiSchema: PropTypes.Requireable<PropTypes.InferProps<{
|
|
4
|
-
"ui:options": PropTypes.Requireable<PropTypes.InferProps<{
|
|
5
|
-
rules: PropTypes.Requireable<string | PropTypes.InferProps<{
|
|
6
|
-
container: PropTypes.Requireable<string>;
|
|
7
|
-
field: PropTypes.Validator<string>;
|
|
8
|
-
regexp: PropTypes.Requireable<string>;
|
|
9
|
-
valueIn: PropTypes.Requireable<(string | null | undefined)[]>;
|
|
10
|
-
valueLengthLessThan: PropTypes.Requireable<number>;
|
|
11
|
-
complement: PropTypes.Requireable<boolean>;
|
|
12
|
-
}> | PropTypes.InferProps<{
|
|
13
|
-
idx: PropTypes.Requireable<number>;
|
|
14
|
-
isLast: PropTypes.Requireable<number>;
|
|
15
|
-
complement: PropTypes.Requireable<boolean>;
|
|
16
|
-
}> | (string | PropTypes.InferProps<{
|
|
17
|
-
container: PropTypes.Requireable<string>;
|
|
18
|
-
field: PropTypes.Validator<string>;
|
|
19
|
-
regexp: PropTypes.Requireable<string>;
|
|
20
|
-
valueIn: PropTypes.Requireable<(string | null | undefined)[]>;
|
|
21
|
-
valueLengthLessThan: PropTypes.Requireable<number>;
|
|
22
|
-
complement: PropTypes.Requireable<boolean>;
|
|
23
|
-
}> | PropTypes.InferProps<{
|
|
24
|
-
idx: PropTypes.Requireable<number>;
|
|
25
|
-
isLast: PropTypes.Requireable<number>;
|
|
26
|
-
complement: PropTypes.Requireable<boolean>;
|
|
27
|
-
}> | null | undefined)[]>;
|
|
28
|
-
itemsOperations: PropTypes.Requireable<PropTypes.InferProps<{
|
|
29
|
-
type: PropTypes.Requireable<string>;
|
|
30
|
-
uiSchema: PropTypes.Validator<object>;
|
|
31
|
-
}> | (PropTypes.InferProps<{
|
|
32
|
-
type: PropTypes.Requireable<string>;
|
|
33
|
-
uiSchema: PropTypes.Validator<object>;
|
|
34
|
-
}> | null | undefined)[]>;
|
|
35
|
-
cache: any;
|
|
36
|
-
}>>;
|
|
37
|
-
}>>;
|
|
38
|
-
schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
39
|
-
type: PropTypes.Requireable<string>;
|
|
40
|
-
}>>;
|
|
41
|
-
formData: PropTypes.Requireable<any[]>;
|
|
42
|
-
};
|
|
43
|
-
constructor(props: any);
|
|
44
|
-
constructor(props: any, context: any);
|
|
45
|
-
itemIds: {};
|
|
46
|
-
cache: {}[] | undefined;
|
|
47
|
-
arrayKeyFunctions: any[] | undefined;
|
|
48
|
-
groupItemIds: unknown;
|
|
49
|
-
groupedItems: any;
|
|
50
|
-
onChange: (idx: any) => (formData: any) => void;
|
|
51
|
-
}
|
|
52
|
-
import * as React from "react";
|
|
53
|
-
import * as PropTypes from "prop-types";
|