@luomus/laji-form 14.3.6
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 +215 -0
- package/LICENSE +21 -0
- package/README.md +180 -0
- package/cypress/fixtures/example.json +5 -0
- closes suggestion list (failed).png +0 -0
- is marked as suggested (failed).png +0 -0
- package/dist/images/finnish-flag.png +0 -0
- package/dist/images/handled.png +0 -0
- package/dist/images/heard.png +0 -0
- package/dist/images/indirect.png +0 -0
- package/dist/images/media.png +0 -0
- package/dist/images/seen.png +0 -0
- package/dist/images/specimen.png +0 -0
- package/dist/laji-form.js +2 -0
- package/dist/laji-form.js.LICENSE.txt +92 -0
- package/dist/styles.css +3771 -0
- package/lib/ApiClient.d.ts +46 -0
- package/lib/ApiClient.js +93 -0
- package/lib/Context.d.ts +8 -0
- package/lib/Context.js +18 -0
- package/lib/ReactContext.d.ts +7 -0
- package/lib/ReactContext.js +5 -0
- package/lib/components/BaseComponent.d.ts +9 -0
- package/lib/components/BaseComponent.js +29 -0
- package/lib/components/LajiForm.d.ts +221 -0
- package/lib/components/LajiForm.js +614 -0
- package/lib/components/VirtualSchemaField.d.ts +42 -0
- package/lib/components/VirtualSchemaField.js +74 -0
- package/lib/components/components.d.ts +119 -0
- package/lib/components/components.js +606 -0
- package/lib/components/fields/AnnotationField.d.ts +34 -0
- package/lib/components/fields/AnnotationField.js +242 -0
- package/lib/components/fields/AnyToBooleanField.d.ts +18 -0
- package/lib/components/fields/AnyToBooleanField.js +20 -0
- package/lib/components/fields/ArrayBulkField.d.ts +23 -0
- package/lib/components/fields/ArrayBulkField.js +82 -0
- package/lib/components/fields/ArrayCombinerField.d.ts +36 -0
- package/lib/components/fields/ArrayCombinerField.js +138 -0
- package/lib/components/fields/ArrayField.d.ts +39 -0
- package/lib/components/fields/ArrayField.js +148 -0
- package/lib/components/fields/AudioArrayField.d.ts +22 -0
- package/lib/components/fields/AudioArrayField.js +100 -0
- package/lib/components/fields/AutoArrayField.d.ts +24 -0
- package/lib/components/fields/AutoArrayField.js +56 -0
- package/lib/components/fields/AutosuggestField.d.ts +69 -0
- package/lib/components/fields/AutosuggestField.js +299 -0
- package/lib/components/fields/CombinedValueDisplayField.d.ts +41 -0
- package/lib/components/fields/CombinedValueDisplayField.js +100 -0
- package/lib/components/fields/ConditionalOnChangeField.d.ts +42 -0
- package/lib/components/fields/ConditionalOnChangeField.js +107 -0
- package/lib/components/fields/ConditionalUiSchemaField.d.ts +123 -0
- package/lib/components/fields/ConditionalUiSchemaField.js +143 -0
- package/lib/components/fields/ContextInjectionField.d.ts +24 -0
- package/lib/components/fields/ContextInjectionField.js +68 -0
- package/lib/components/fields/DataLeakerField.d.ts +40 -0
- package/lib/components/fields/DataLeakerField.js +68 -0
- package/lib/components/fields/DefaultValueArrayField.d.ts +34 -0
- package/lib/components/fields/DefaultValueArrayField.js +59 -0
- package/lib/components/fields/DependentBooleanField.d.ts +38 -0
- package/lib/components/fields/DependentBooleanField.js +87 -0
- package/lib/components/fields/DependentDisableField.d.ts +35 -0
- package/lib/components/fields/DependentDisableField.js +71 -0
- package/lib/components/fields/EnumRangeArrayField.d.ts +27 -0
- package/lib/components/fields/EnumRangeArrayField.js +115 -0
- package/lib/components/fields/ExtraLabelRowField.d.ts +38 -0
- package/lib/components/fields/ExtraLabelRowField.js +100 -0
- package/lib/components/fields/FakePropertyField.d.ts +18 -0
- package/lib/components/fields/FakePropertyField.js +48 -0
- package/lib/components/fields/FilterArrayField.d.ts +73 -0
- package/lib/components/fields/FilterArrayField.js +121 -0
- package/lib/components/fields/FlatField.d.ts +29 -0
- package/lib/components/fields/FlatField.js +171 -0
- package/lib/components/fields/GeocoderField.d.ts +47 -0
- package/lib/components/fields/GeocoderField.js +372 -0
- package/lib/components/fields/GridLayoutField.d.ts +18 -0
- package/lib/components/fields/GridLayoutField.js +32 -0
- package/lib/components/fields/HiddenField.d.ts +10 -0
- package/lib/components/fields/HiddenField.js +11 -0
- package/lib/components/fields/ImageArrayField.d.ts +153 -0
- package/lib/components/fields/ImageArrayField.js +696 -0
- package/lib/components/fields/ImageDisplayField.d.ts +18 -0
- package/lib/components/fields/ImageDisplayField.js +44 -0
- package/lib/components/fields/InitiallyHiddenField.d.ts +21 -0
- package/lib/components/fields/InitiallyHiddenField.js +58 -0
- package/lib/components/fields/InjectDefaultValueField.d.ts +37 -0
- package/lib/components/fields/InjectDefaultValueField.js +68 -0
- package/lib/components/fields/InjectField.d.ts +46 -0
- package/lib/components/fields/InjectField.js +88 -0
- package/lib/components/fields/InputWithDefaultValueButtonField.d.ts +25 -0
- package/lib/components/fields/InputWithDefaultValueButtonField.js +61 -0
- package/lib/components/fields/LocalityField.d.ts +22 -0
- package/lib/components/fields/LocalityField.js +94 -0
- package/lib/components/fields/LocationChooserField.d.ts +27 -0
- package/lib/components/fields/LocationChooserField.js +440 -0
- package/lib/components/fields/MapArrayField.d.ts +78 -0
- package/lib/components/fields/MapArrayField.js +1783 -0
- package/lib/components/fields/MapField.d.ts +48 -0
- package/lib/components/fields/MapField.js +434 -0
- package/lib/components/fields/MultiAnyToBooleanField.d.ts +25 -0
- package/lib/components/fields/MultiAnyToBooleanField.js +100 -0
- package/lib/components/fields/MultiArrayField.d.ts +53 -0
- package/lib/components/fields/MultiArrayField.js +224 -0
- package/lib/components/fields/MultiLanguageField.d.ts +13 -0
- package/lib/components/fields/MultiLanguageField.js +52 -0
- package/lib/components/fields/MultiTagArrayField.d.ts +36 -0
- package/lib/components/fields/MultiTagArrayField.js +142 -0
- package/lib/components/fields/NamedPlaceChooserField.d.ts +29 -0
- package/lib/components/fields/NamedPlaceChooserField.js +380 -0
- package/lib/components/fields/NamedPlaceSaverField.d.ts +29 -0
- package/lib/components/fields/NamedPlaceSaverField.js +237 -0
- package/lib/components/fields/NestField.d.ts +148 -0
- package/lib/components/fields/NestField.js +289 -0
- package/lib/components/fields/ObjectField.d.ts +2 -0
- package/lib/components/fields/ObjectField.js +119 -0
- package/lib/components/fields/PrefillingArrayField.d.ts +22 -0
- package/lib/components/fields/PrefillingArrayField.js +65 -0
- package/lib/components/fields/SchemaField.d.ts +7 -0
- package/lib/components/fields/SchemaField.js +109 -0
- package/lib/components/fields/ScopeField.d.ts +85 -0
- package/lib/components/fields/ScopeField.js +521 -0
- package/lib/components/fields/SectionArrayField.d.ts +38 -0
- package/lib/components/fields/SectionArrayField.js +614 -0
- package/lib/components/fields/SelectTreeField.d.ts +39 -0
- package/lib/components/fields/SelectTreeField.js +143 -0
- package/lib/components/fields/SingleActiveArrayField.d.ts +49 -0
- package/lib/components/fields/SingleActiveArrayField.js +974 -0
- package/lib/components/fields/SingleItemArrayField.d.ts +15 -0
- package/lib/components/fields/SingleItemArrayField.js +60 -0
- package/lib/components/fields/SortArrayField.d.ts +73 -0
- package/lib/components/fields/SortArrayField.js +351 -0
- package/lib/components/fields/SplitField.d.ts +28 -0
- package/lib/components/fields/SplitField.js +65 -0
- package/lib/components/fields/StringToArrayField.d.ts +24 -0
- package/lib/components/fields/StringToArrayField.js +48 -0
- package/lib/components/fields/SumField.d.ts +35 -0
- package/lib/components/fields/SumField.js +83 -0
- package/lib/components/fields/TableField.d.ts +18 -0
- package/lib/components/fields/TableField.js +136 -0
- package/lib/components/fields/TagArrayField.d.ts +38 -0
- package/lib/components/fields/TagArrayField.js +128 -0
- package/lib/components/fields/ToggleAdditionalArrayFieldsField.d.ts +26 -0
- package/lib/components/fields/ToggleAdditionalArrayFieldsField.js +81 -0
- package/lib/components/fields/UiFieldApplierField.d.ts +30 -0
- package/lib/components/fields/UiFieldApplierField.js +106 -0
- package/lib/components/fields/UiFieldMapperArrayField.d.ts +42 -0
- package/lib/components/fields/UiFieldMapperArrayField.js +121 -0
- package/lib/components/fields/UnitCountShorthandField.d.ts +22 -0
- package/lib/components/fields/UnitCountShorthandField.js +149 -0
- package/lib/components/fields/UnitListShorthandArrayField.d.ts +26 -0
- package/lib/components/fields/UnitListShorthandArrayField.js +108 -0
- package/lib/components/fields/UnitShorthandField.d.ts +32 -0
- package/lib/components/fields/UnitShorthandField.js +220 -0
- package/lib/components/templates/ArrayFieldTemplate.d.ts +85 -0
- package/lib/components/templates/ArrayFieldTemplate.js +416 -0
- package/lib/components/templates/BaseInputTemplate.d.ts +11 -0
- package/lib/components/templates/BaseInputTemplate.js +80 -0
- package/lib/components/templates/DescriptionField.d.ts +1 -0
- package/lib/components/templates/DescriptionField.js +37 -0
- package/lib/components/templates/ErrorListTemplate.d.ts +9 -0
- package/lib/components/templates/ErrorListTemplate.js +95 -0
- package/lib/components/templates/FieldTemplate.d.ts +6 -0
- package/lib/components/templates/FieldTemplate.js +112 -0
- package/lib/components/templates/ObjectFieldTemplate.d.ts +7 -0
- package/lib/components/templates/ObjectFieldTemplate.js +66 -0
- package/lib/components/templates/TitleField.d.ts +9 -0
- package/lib/components/templates/TitleField.js +51 -0
- package/lib/components/widgets/AnyToBooleanWidget.d.ts +20 -0
- package/lib/components/widgets/AnyToBooleanWidget.js +49 -0
- package/lib/components/widgets/AutosuggestWidget.d.ts +66 -0
- package/lib/components/widgets/AutosuggestWidget.js +1127 -0
- package/lib/components/widgets/CheckboxWidget.d.ts +37 -0
- package/lib/components/widgets/CheckboxWidget.js +139 -0
- package/lib/components/widgets/DateTimeWidget.d.ts +62 -0
- package/lib/components/widgets/DateTimeWidget.js +251 -0
- package/lib/components/widgets/DateWidget.d.ts +23 -0
- package/lib/components/widgets/DateWidget.js +41 -0
- package/lib/components/widgets/HiddenWidget.d.ts +15 -0
- package/lib/components/widgets/HiddenWidget.js +19 -0
- package/lib/components/widgets/ImageSelectWidget.d.ts +14 -0
- package/lib/components/widgets/ImageSelectWidget.js +57 -0
- package/lib/components/widgets/InformalTaxonGroupChooserWidget.d.ts +43 -0
- package/lib/components/widgets/InformalTaxonGroupChooserWidget.js +237 -0
- package/lib/components/widgets/InputGroupWidget.d.ts +21 -0
- package/lib/components/widgets/InputGroupWidget.js +36 -0
- package/lib/components/widgets/InputWithDefaultValueButtonWidget.d.ts +21 -0
- package/lib/components/widgets/InputWithDefaultValueButtonWidget.js +47 -0
- package/lib/components/widgets/NumberWidget.d.ts +13 -0
- package/lib/components/widgets/NumberWidget.js +21 -0
- package/lib/components/widgets/PlainTextWidget.d.ts +12 -0
- package/lib/components/widgets/PlainTextWidget.js +24 -0
- package/lib/components/widgets/SelectWidget.d.ts +52 -0
- package/lib/components/widgets/SelectWidget.js +158 -0
- package/lib/components/widgets/SeparatedDateTimeWidget.d.ts +19 -0
- package/lib/components/widgets/SeparatedDateTimeWidget.js +59 -0
- package/lib/components/widgets/TaxonImageWidget.d.ts +13 -0
- package/lib/components/widgets/TaxonImageWidget.js +30 -0
- package/lib/components/widgets/TextSelectWidget.d.ts +25 -0
- package/lib/components/widgets/TextSelectWidget.js +94 -0
- package/lib/components/widgets/TextareaWidget.d.ts +32 -0
- package/lib/components/widgets/TextareaWidget.js +87 -0
- package/lib/components/widgets/TimeWidget.d.ts +11 -0
- package/lib/components/widgets/TimeWidget.js +19 -0
- package/lib/components/widgets/URLWidget.d.ts +14 -0
- package/lib/components/widgets/URLWidget.js +12 -0
- package/lib/components/widgets/UpperCaseWidget.d.ts +13 -0
- package/lib/components/widgets/UpperCaseWidget.js +21 -0
- package/lib/index.d.ts +20 -0
- package/lib/index.js +50 -0
- package/lib/services/blocker-service.d.ts +11 -0
- package/lib/services/blocker-service.js +55 -0
- package/lib/services/custom-event-service.d.ts +17 -0
- package/lib/services/custom-event-service.js +35 -0
- package/lib/services/dom-id-service.d.ts +8 -0
- package/lib/services/dom-id-service.js +30 -0
- package/lib/services/focus-service.d.ts +13 -0
- package/lib/services/focus-service.js +60 -0
- package/lib/services/id-service.d.ts +22 -0
- package/lib/services/id-service.js +130 -0
- package/lib/services/key-handler-service.d.ts +56 -0
- package/lib/services/key-handler-service.js +184 -0
- package/lib/services/root-instance-service.d.ts +25 -0
- package/lib/services/root-instance-service.js +49 -0
- package/lib/services/settings-service.d.ts +34 -0
- package/lib/services/settings-service.js +154 -0
- package/lib/services/singleton-map-service.d.ts +23 -0
- package/lib/services/singleton-map-service.js +44 -0
- package/lib/services/submit-hook-service.d.ts +24 -0
- package/lib/services/submit-hook-service.js +73 -0
- package/lib/styles.d.ts +1 -0
- package/lib/styles.js +4 -0
- package/lib/themes/bs3.d.ts +3 -0
- package/lib/themes/bs3.js +133 -0
- package/lib/themes/bs5.d.ts +3 -0
- package/lib/themes/bs5.js +111 -0
- package/lib/themes/glyphicon-fa-mapping.d.ts +3 -0
- package/lib/themes/glyphicon-fa-mapping.js +271 -0
- package/lib/themes/stub.d.ts +3 -0
- package/lib/themes/stub.js +82 -0
- package/lib/themes/theme.d.ts +233 -0
- package/lib/themes/theme.js +2 -0
- package/lib/translations.json +842 -0
- package/lib/utils.d.ts +167 -0
- package/lib/utils.js +1191 -0
- package/lib/validation.d.ts +7 -0
- package/lib/validation.js +141 -0
- package/llol +10 -0
- package/llol.pdf +10 -0
- package/package.json +99 -0
- package/q +196 -0
- package/test-export/array-spec.d.ts +1 -0
- package/test-export/array-spec.js +204 -0
- package/test-export/bird-point-count-spec.d.ts +1 -0
- package/test-export/bird-point-count-spec.js +62 -0
- package/test-export/collection-contest-form-spec.d.ts +1 -0
- package/test-export/collection-contest-form-spec.js +38 -0
- package/test-export/dataset-form-spec.d.ts +1 -0
- package/test-export/dataset-form-spec.js +50 -0
- package/test-export/date-time-widget-spec.d.ts +1 -0
- package/test-export/date-time-widget-spec.js +188 -0
- package/test-export/geocoder-spec.d.ts +1 -0
- package/test-export/geocoder-spec.js +135 -0
- package/test-export/image-array-spec.d.ts +1 -0
- package/test-export/image-array-spec.js +94 -0
- package/test-export/inject-field-spec.d.ts +1 -0
- package/test-export/inject-field-spec.js +148 -0
- package/test-export/internal-uuids-spec.d.ts +1 -0
- package/test-export/internal-uuids-spec.js +157 -0
- package/test-export/invasive-species-eradication-np-spec.d.ts +1 -0
- package/test-export/invasive-species-eradication-np-spec.js +18 -0
- package/test-export/invasive-species-eradication-spec.d.ts +1 -0
- package/test-export/invasive-species-eradication-spec.js +25 -0
- package/test-export/line-transect-spec.d.ts +1 -0
- package/test-export/line-transect-spec.js +121 -0
- package/test-export/mobile-form-spec.d.ts +1 -0
- package/test-export/mobile-form-spec.js +84 -0
- package/test-export/nafi-spec.d.ts +1 -0
- package/test-export/nafi-spec.js +85 -0
- package/test-export/select-widget-spec.d.ts +1 -0
- package/test-export/select-widget-spec.js +68 -0
- package/test-export/single-item-array-field-spec.d.ts +1 -0
- package/test-export/single-item-array-field-spec.js +92 -0
- package/test-export/syke-butterfly-spec.d.ts +1 -0
- package/test-export/syke-butterfly-spec.js +163 -0
- package/test-export/test-utils.d.ts +184 -0
- package/test-export/test-utils.js +354 -0
- package/test-export/transaction-form-spec.d.ts +1 -0
- package/test-export/transaction-form-spec.js +63 -0
- package/test-export/trip-report-autosuggest-spec.d.ts +1 -0
- package/test-export/trip-report-autosuggest-spec.js +272 -0
- package/test-export/trip-report-spec.d.ts +1 -0
- package/test-export/trip-report-spec.js +456 -0
- package/test-export/unit-list-shorthand-array-field-spec.d.ts +1 -0
- package/test-export/unit-list-shorthand-array-field-spec.js +71 -0
- package/test-export/validation-spec.d.ts +1 -0
- package/test-export/validation-spec.js +336 -0
- package/test-export/water-bird-spec.d.ts +1 -0
- package/test-export/water-bird-spec.js +30 -0
- package/test-export/wbc-spec.d.ts +1 -0
- package/test-export/wbc-spec.js +82 -0
- package/tsconfig.json +25 -0
- package/tsconfig.lib.json +11 -0
- package/tsconfig.test.json +10 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export default class ImageDisplayField extends React.Component<any, any, any> {
|
|
2
|
+
static propTypes: {
|
|
3
|
+
uiSchema: PropTypes.Requireable<PropTypes.InferProps<{
|
|
4
|
+
"ui:options": PropTypes.Requireable<PropTypes.InferProps<{
|
|
5
|
+
urls: PropTypes.Requireable<string | (string | null | undefined)[]>;
|
|
6
|
+
buttons: PropTypes.Requireable<(string | null | undefined)[]>;
|
|
7
|
+
}>>;
|
|
8
|
+
}>>;
|
|
9
|
+
schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
10
|
+
type: PropTypes.Requireable<string>;
|
|
11
|
+
}>>;
|
|
12
|
+
formData: PropTypes.Requireable<object>;
|
|
13
|
+
};
|
|
14
|
+
constructor(props: any);
|
|
15
|
+
constructor(props: any, context: any);
|
|
16
|
+
}
|
|
17
|
+
import * as React from "react";
|
|
18
|
+
import * as PropTypes from "prop-types";
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const React = require("react");
|
|
10
|
+
const PropTypes = require("prop-types");
|
|
11
|
+
const BaseComponent_1 = require("../BaseComponent");
|
|
12
|
+
const utils_1 = require("../../utils");
|
|
13
|
+
const immutability_helper_1 = require("immutability-helper");
|
|
14
|
+
// TODO should work as widget also
|
|
15
|
+
let ImageDisplayField = class ImageDisplayField extends React.Component {
|
|
16
|
+
render() {
|
|
17
|
+
const { SchemaField } = this.props.registry.fields;
|
|
18
|
+
let uiSchema = utils_1.getInnerUiSchema(this.props.uiSchema);
|
|
19
|
+
const { urls = [], buttons = [] } = utils_1.getUiOptions(this.props.uiSchema);
|
|
20
|
+
uiSchema = immutability_helper_1.default(uiSchema, { "ui:options": { buttons: { $set: [...buttons,
|
|
21
|
+
{ position: "left", render: () => React.createElement("div", { className: "laji-form-medias", key: "image-display" }, (Array.isArray(urls) ? urls : [urls]).map(url => React.createElement("div", { className: "media-container", key: url },
|
|
22
|
+
React.createElement("img", { src: url }))))
|
|
23
|
+
}
|
|
24
|
+
] } } });
|
|
25
|
+
return (React.createElement(React.Fragment, null,
|
|
26
|
+
React.createElement(SchemaField, Object.assign({}, this.props, { uiSchema: uiSchema }))));
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
ImageDisplayField.propTypes = {
|
|
30
|
+
uiSchema: PropTypes.shape({
|
|
31
|
+
"ui:options": PropTypes.shape({
|
|
32
|
+
urls: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
|
|
33
|
+
buttons: PropTypes.arrayOf(PropTypes.string),
|
|
34
|
+
}),
|
|
35
|
+
}),
|
|
36
|
+
schema: PropTypes.shape({
|
|
37
|
+
type: PropTypes.oneOf(["array", "object"])
|
|
38
|
+
}).isRequired,
|
|
39
|
+
formData: PropTypes.oneOfType([PropTypes.array, PropTypes.object])
|
|
40
|
+
};
|
|
41
|
+
ImageDisplayField = __decorate([
|
|
42
|
+
BaseComponent_1.default
|
|
43
|
+
], ImageDisplayField);
|
|
44
|
+
exports.default = ImageDisplayField;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export default class InitiallyHiddenField extends React.Component<any, any, any> {
|
|
2
|
+
static contextType: React.Context<import("../../ReactContext").ContextProps>;
|
|
3
|
+
static propTypes: {
|
|
4
|
+
uiSchema: PropTypes.Validator<PropTypes.InferProps<{
|
|
5
|
+
"ui:options": PropTypes.Requireable<PropTypes.InferProps<{
|
|
6
|
+
uiSchema: PropTypes.Requireable<object>;
|
|
7
|
+
}>>;
|
|
8
|
+
}>>;
|
|
9
|
+
schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
10
|
+
type: PropTypes.Requireable<string>;
|
|
11
|
+
}>>;
|
|
12
|
+
formData: PropTypes.Validator<object>;
|
|
13
|
+
};
|
|
14
|
+
constructor(props: any);
|
|
15
|
+
getStateFromProps(props: any): {
|
|
16
|
+
uiSchema: any;
|
|
17
|
+
};
|
|
18
|
+
toggleVisibility: () => void;
|
|
19
|
+
}
|
|
20
|
+
import * as React from "react";
|
|
21
|
+
import * as PropTypes from "prop-types";
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const React = require("react");
|
|
10
|
+
const PropTypes = require("prop-types");
|
|
11
|
+
const utils_1 = require("../../utils");
|
|
12
|
+
const components_1 = require("../components");
|
|
13
|
+
const BaseComponent_1 = require("../BaseComponent");
|
|
14
|
+
const ReactContext_1 = require("../../ReactContext");
|
|
15
|
+
let InitiallyHiddenField = class InitiallyHiddenField extends React.Component {
|
|
16
|
+
constructor(props) {
|
|
17
|
+
super(props);
|
|
18
|
+
this.toggleVisibility = () => {
|
|
19
|
+
this.setState({ visible: !this.state.visible });
|
|
20
|
+
};
|
|
21
|
+
this.state = Object.assign({ visible: false }, this.getStateFromProps(props));
|
|
22
|
+
}
|
|
23
|
+
getStateFromProps(props) {
|
|
24
|
+
return { uiSchema: utils_1.getInnerUiSchema(props.uiSchema) };
|
|
25
|
+
}
|
|
26
|
+
render() {
|
|
27
|
+
let shouldShow = this.state.visible;
|
|
28
|
+
const SchemaField = this.props.registry.fields.SchemaField;
|
|
29
|
+
const { Row, Col, Collapse } = this.context.theme;
|
|
30
|
+
return (React.createElement("div", null,
|
|
31
|
+
React.createElement(Collapse, { in: !shouldShow },
|
|
32
|
+
React.createElement(Row, null,
|
|
33
|
+
React.createElement(Col, { xs: 2, xsOffset: 10 },
|
|
34
|
+
React.createElement(components_1.Button, { className: "button-right", onClick: this.toggleVisibility },
|
|
35
|
+
this.props.schema.title || this.props.name,
|
|
36
|
+
" ",
|
|
37
|
+
React.createElement("span", { className: "caret" }))))),
|
|
38
|
+
React.createElement(Collapse, { in: shouldShow },
|
|
39
|
+
React.createElement("div", null,
|
|
40
|
+
React.createElement(SchemaField, Object.assign({}, this.props, this.state))))));
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
InitiallyHiddenField.contextType = ReactContext_1.default;
|
|
44
|
+
InitiallyHiddenField.propTypes = {
|
|
45
|
+
uiSchema: PropTypes.shape({
|
|
46
|
+
"ui:options": PropTypes.shape({
|
|
47
|
+
uiSchema: PropTypes.object
|
|
48
|
+
})
|
|
49
|
+
}).isRequired,
|
|
50
|
+
schema: PropTypes.shape({
|
|
51
|
+
type: PropTypes.oneOf(["object", "array"])
|
|
52
|
+
}).isRequired,
|
|
53
|
+
formData: PropTypes.oneOfType([PropTypes.object, PropTypes.array]).isRequired
|
|
54
|
+
};
|
|
55
|
+
InitiallyHiddenField = __decorate([
|
|
56
|
+
BaseComponent_1.default
|
|
57
|
+
], InitiallyHiddenField);
|
|
58
|
+
exports.default = InitiallyHiddenField;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Injects given fields value as default value to target field.
|
|
3
|
+
* uiSchema = { "ui:options": {
|
|
4
|
+
* "injections": [
|
|
5
|
+
* {
|
|
6
|
+
* "fields": [field1, field2...], (fields to inject from source field)
|
|
7
|
+
* "target": fieldName (target field where default value is injected)
|
|
8
|
+
* "source": fieldName (source field where default value is injected from. Must be object field)
|
|
9
|
+
* }
|
|
10
|
+
* ...
|
|
11
|
+
* ]
|
|
12
|
+
* }}
|
|
13
|
+
*/
|
|
14
|
+
export default class InjectDefaultValueField extends React.Component<any, any, any> {
|
|
15
|
+
static propTypes: {
|
|
16
|
+
uiSchema: PropTypes.Validator<PropTypes.InferProps<{
|
|
17
|
+
"ui:options": PropTypes.Validator<PropTypes.InferProps<{
|
|
18
|
+
fields: PropTypes.Validator<(string | null | undefined)[]>;
|
|
19
|
+
target: PropTypes.Validator<string>;
|
|
20
|
+
source: PropTypes.Validator<string>;
|
|
21
|
+
}>>;
|
|
22
|
+
}>>;
|
|
23
|
+
schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
24
|
+
type: PropTypes.Requireable<string>;
|
|
25
|
+
}>>;
|
|
26
|
+
formData: PropTypes.Validator<object>;
|
|
27
|
+
};
|
|
28
|
+
static getName(): string;
|
|
29
|
+
constructor(props: any);
|
|
30
|
+
constructor(props: any, context: any);
|
|
31
|
+
getStateFromProps(): {
|
|
32
|
+
onChange: (formData: any) => void;
|
|
33
|
+
};
|
|
34
|
+
onChange: (formData: any) => void;
|
|
35
|
+
}
|
|
36
|
+
import * as React from "react";
|
|
37
|
+
import * as PropTypes from "prop-types";
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const React = require("react");
|
|
10
|
+
const PropTypes = require("prop-types");
|
|
11
|
+
const immutability_helper_1 = require("immutability-helper");
|
|
12
|
+
const VirtualSchemaField_1 = require("../VirtualSchemaField");
|
|
13
|
+
/**
|
|
14
|
+
* Injects given fields value as default value to target field.
|
|
15
|
+
* uiSchema = { "ui:options": {
|
|
16
|
+
* "injections": [
|
|
17
|
+
* {
|
|
18
|
+
* "fields": [field1, field2...], (fields to inject from source field)
|
|
19
|
+
* "target": fieldName (target field where default value is injected)
|
|
20
|
+
* "source": fieldName (source field where default value is injected from. Must be object field)
|
|
21
|
+
* }
|
|
22
|
+
* ...
|
|
23
|
+
* ]
|
|
24
|
+
* }}
|
|
25
|
+
*/
|
|
26
|
+
let InjectDefaultValueField = class InjectDefaultValueField extends React.Component {
|
|
27
|
+
constructor() {
|
|
28
|
+
super(...arguments);
|
|
29
|
+
this.onChange = (formData) => {
|
|
30
|
+
let { schema } = this.props;
|
|
31
|
+
const options = this.getUiOptions();
|
|
32
|
+
const { fields, target } = options;
|
|
33
|
+
let source = options.source ? formData[options.source] : formData;
|
|
34
|
+
fields.forEach(field => {
|
|
35
|
+
if (schema.properties[target].type === "array") {
|
|
36
|
+
if (formData && formData[target])
|
|
37
|
+
formData[target].forEach((item, i) => {
|
|
38
|
+
if (item[field] === this.props.formData[options.source][field]) {
|
|
39
|
+
formData = immutability_helper_1.default(formData, { [target]: { $splice: [[i, 1, immutability_helper_1.default(item, { $merge: { [field]: source[field] } })]] } });
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
this.props.onChange(formData);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
static getName() { return "InjectDefaultValueField"; }
|
|
48
|
+
getStateFromProps() {
|
|
49
|
+
return { onChange: this.onChange };
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
InjectDefaultValueField.propTypes = {
|
|
53
|
+
uiSchema: PropTypes.shape({
|
|
54
|
+
"ui:options": PropTypes.shape({
|
|
55
|
+
fields: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
56
|
+
target: PropTypes.string.isRequired,
|
|
57
|
+
source: PropTypes.string.isRequired
|
|
58
|
+
}).isRequired
|
|
59
|
+
}).isRequired,
|
|
60
|
+
schema: PropTypes.shape({
|
|
61
|
+
type: PropTypes.oneOf(["object", "array"])
|
|
62
|
+
}).isRequired,
|
|
63
|
+
formData: PropTypes.oneOfType([PropTypes.object, PropTypes.array]).isRequired
|
|
64
|
+
};
|
|
65
|
+
InjectDefaultValueField = __decorate([
|
|
66
|
+
VirtualSchemaField_1.default
|
|
67
|
+
], InjectDefaultValueField);
|
|
68
|
+
exports.default = InjectDefaultValueField;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inject a schema object property to nested schema.
|
|
3
|
+
* uiSchema = { "ui:options": {
|
|
4
|
+
* "injections": [
|
|
5
|
+
* {
|
|
6
|
+
* "fields": [field1, field2...],
|
|
7
|
+
* "target": fieldName
|
|
8
|
+
* }
|
|
9
|
+
* ...
|
|
10
|
+
* ]
|
|
11
|
+
* }}
|
|
12
|
+
*/
|
|
13
|
+
export default class InjectField extends React.Component<any, any, any> {
|
|
14
|
+
static propTypes: {
|
|
15
|
+
uiSchema: PropTypes.Validator<PropTypes.InferProps<{
|
|
16
|
+
"ui:options": PropTypes.Validator<PropTypes.InferProps<{
|
|
17
|
+
injections: PropTypes.Validator<PropTypes.InferProps<{
|
|
18
|
+
fields: PropTypes.Validator<(string | null | undefined)[]>;
|
|
19
|
+
target: PropTypes.Validator<string>;
|
|
20
|
+
}> | (PropTypes.InferProps<{
|
|
21
|
+
fields: PropTypes.Validator<(string | null | undefined)[]>;
|
|
22
|
+
target: PropTypes.Validator<string>;
|
|
23
|
+
}> | null | undefined)[]>;
|
|
24
|
+
}>>;
|
|
25
|
+
uiSchema: PropTypes.Requireable<object>;
|
|
26
|
+
}>>;
|
|
27
|
+
schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
28
|
+
type: PropTypes.Requireable<string>;
|
|
29
|
+
}>>;
|
|
30
|
+
formData: PropTypes.Validator<object>;
|
|
31
|
+
};
|
|
32
|
+
static getName(): string;
|
|
33
|
+
constructor(props: any);
|
|
34
|
+
constructor(props: any, context: any);
|
|
35
|
+
getStateFromProps(props: any): {
|
|
36
|
+
schema: any;
|
|
37
|
+
uiSchema: any;
|
|
38
|
+
idSchema: any;
|
|
39
|
+
formData: any;
|
|
40
|
+
errorSchema: any;
|
|
41
|
+
onChange: (formData: any) => void;
|
|
42
|
+
};
|
|
43
|
+
onChange: (formData: any) => void;
|
|
44
|
+
}
|
|
45
|
+
import * as React from "react";
|
|
46
|
+
import * as PropTypes from "prop-types";
|
|
@@ -0,0 +1,88 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const React = require("react");
|
|
10
|
+
const PropTypes = require("prop-types");
|
|
11
|
+
const utils_1 = require("../../utils");
|
|
12
|
+
const VirtualSchemaField_1 = require("../VirtualSchemaField");
|
|
13
|
+
const injectionPropType = PropTypes.shape({
|
|
14
|
+
fields: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
15
|
+
target: PropTypes.string.isRequired
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* Inject a schema object property to nested schema.
|
|
19
|
+
* uiSchema = { "ui:options": {
|
|
20
|
+
* "injections": [
|
|
21
|
+
* {
|
|
22
|
+
* "fields": [field1, field2...],
|
|
23
|
+
* "target": fieldName
|
|
24
|
+
* }
|
|
25
|
+
* ...
|
|
26
|
+
* ]
|
|
27
|
+
* }}
|
|
28
|
+
*/
|
|
29
|
+
let InjectField = class InjectField extends React.Component {
|
|
30
|
+
constructor() {
|
|
31
|
+
super(...arguments);
|
|
32
|
+
this.onChange = (formData) => {
|
|
33
|
+
const options = this.getUiOptions();
|
|
34
|
+
(Array.isArray(options.injections) ? options.injections.slice(0).reverse() : [options.injections]).forEach((injection) => {
|
|
35
|
+
let { fields, target } = injection;
|
|
36
|
+
target = utils_1.toJSONPointer(target);
|
|
37
|
+
formData = fields.reduce((formData, fieldPointer) => {
|
|
38
|
+
fieldPointer = utils_1.toJSONPointer(fieldPointer);
|
|
39
|
+
const fieldName = fieldPointer.split("/").pop();
|
|
40
|
+
formData = utils_1.updateFormDataWithJSONPointer(Object.assign(Object.assign({}, this.props), { formData }), utils_1.parseJSONPointer(formData, `${target}/${fieldName}`), fieldPointer);
|
|
41
|
+
formData = utils_1.immutableDelete(formData, `${target}/${fieldName}`);
|
|
42
|
+
return formData;
|
|
43
|
+
}, formData);
|
|
44
|
+
});
|
|
45
|
+
this.props.onChange(formData);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
static getName() { return "InjectField"; }
|
|
49
|
+
getStateFromProps(props) {
|
|
50
|
+
const options = utils_1.getUiOptions(props.uiSchema);
|
|
51
|
+
const { injections } = options;
|
|
52
|
+
let { schema, uiSchema, idSchema, formData, errorSchema } = props;
|
|
53
|
+
(Array.isArray(injections) ? injections : [injections]).forEach((injection) => {
|
|
54
|
+
let { fields, target } = injection;
|
|
55
|
+
target = utils_1.toJSONPointer(target);
|
|
56
|
+
const origSchema = schema;
|
|
57
|
+
fields.forEach((fieldPath) => {
|
|
58
|
+
fieldPath = utils_1.toJSONPointer(fieldPath);
|
|
59
|
+
const fieldName = fieldPath.split("/").pop();
|
|
60
|
+
schema = utils_1.updateSafelyWithJSONPointer(schema, utils_1.parseJSONPointer(origSchema, utils_1.schemaJSONPointer(origSchema, fieldPath)), `${utils_1.schemaJSONPointer(origSchema, target)}/properties/${fieldName}`);
|
|
61
|
+
schema = utils_1.immutableDelete(schema, utils_1.schemaJSONPointer(origSchema, fieldPath));
|
|
62
|
+
uiSchema = utils_1.updateSafelyWithJSONPointer(uiSchema, utils_1.parseJSONPointer(uiSchema, utils_1.uiSchemaJSONPointer(origSchema, fieldPath)), `${utils_1.uiSchemaJSONPointer(origSchema, target)}/${fieldName}`);
|
|
63
|
+
uiSchema = utils_1.immutableDelete(uiSchema, utils_1.uiSchemaJSONPointer(origSchema, fieldPath));
|
|
64
|
+
const [_formData, _idSchema, _errorSchema] = [formData, idSchema, errorSchema].map(prop => utils_1.immutableDelete(utils_1.updateSafelyWithJSONPointer(prop, utils_1.parseJSONPointer(prop, fieldPath), `${target}/${fieldName}`), fieldPath));
|
|
65
|
+
formData = _formData;
|
|
66
|
+
errorSchema = _errorSchema;
|
|
67
|
+
idSchema = _idSchema;
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
return { schema, uiSchema, idSchema, formData, errorSchema, onChange: this.onChange };
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
InjectField.propTypes = {
|
|
74
|
+
uiSchema: PropTypes.shape({
|
|
75
|
+
"ui:options": PropTypes.shape({
|
|
76
|
+
injections: PropTypes.oneOfType([PropTypes.arrayOf(injectionPropType), injectionPropType]).isRequired,
|
|
77
|
+
}).isRequired,
|
|
78
|
+
uiSchema: PropTypes.object
|
|
79
|
+
}).isRequired,
|
|
80
|
+
schema: PropTypes.shape({
|
|
81
|
+
type: PropTypes.oneOf(["object"])
|
|
82
|
+
}).isRequired,
|
|
83
|
+
formData: PropTypes.object.isRequired
|
|
84
|
+
};
|
|
85
|
+
InjectField = __decorate([
|
|
86
|
+
VirtualSchemaField_1.default
|
|
87
|
+
], InjectField);
|
|
88
|
+
exports.default = InjectField;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export default class InputWithDefaultValueButtonField extends React.Component<any, any, any> {
|
|
2
|
+
static propTypes: {
|
|
3
|
+
uiSchema: PropTypes.Validator<PropTypes.InferProps<{
|
|
4
|
+
"ui:options": PropTypes.Validator<PropTypes.InferProps<{
|
|
5
|
+
buttonLabel: PropTypes.Validator<string>;
|
|
6
|
+
buttonField: PropTypes.Validator<string>;
|
|
7
|
+
valueFields: PropTypes.Requireable<PropTypes.InferProps<{
|
|
8
|
+
field: PropTypes.Validator<string>;
|
|
9
|
+
contextFieldForDefaultValue: PropTypes.Validator<string>;
|
|
10
|
+
}>[]>;
|
|
11
|
+
}>>;
|
|
12
|
+
}>>;
|
|
13
|
+
schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
14
|
+
type: PropTypes.Requireable<string>;
|
|
15
|
+
}>>;
|
|
16
|
+
formData: PropTypes.Validator<object>;
|
|
17
|
+
};
|
|
18
|
+
static getName(): string;
|
|
19
|
+
constructor(props: any);
|
|
20
|
+
constructor(props: any, context: any);
|
|
21
|
+
getStateFromProps(props: any): any;
|
|
22
|
+
onClick: () => void;
|
|
23
|
+
}
|
|
24
|
+
import * as React from "react";
|
|
25
|
+
import * as PropTypes from "prop-types";
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const React = require("react");
|
|
10
|
+
const PropTypes = require("prop-types");
|
|
11
|
+
const VirtualSchemaField_1 = require("../VirtualSchemaField");
|
|
12
|
+
const utils_1 = require("../../utils");
|
|
13
|
+
let InputWithDefaultValueButtonField = class InputWithDefaultValueButtonField extends React.Component {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.onClick = () => {
|
|
17
|
+
let { uiSchema, formData } = this.props;
|
|
18
|
+
const uiSchemaContext = this.props.formContext.uiSchemaContext || {};
|
|
19
|
+
const { valueFields } = utils_1.getUiOptions(uiSchema);
|
|
20
|
+
valueFields.forEach(({ field, contextFieldForDefaultValue }) => {
|
|
21
|
+
formData = utils_1.updateSafelyWithJSONPointer(formData, uiSchemaContext[contextFieldForDefaultValue], field);
|
|
22
|
+
});
|
|
23
|
+
this.props.onChange(formData);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
static getName() { return "InputWithDefaultValueButtonField"; }
|
|
27
|
+
getStateFromProps(props) {
|
|
28
|
+
let { schema, uiSchema } = props;
|
|
29
|
+
const { buttonField, buttonLabel } = utils_1.getUiOptions(uiSchema);
|
|
30
|
+
const innerUiSchema = utils_1.getInnerUiSchema(uiSchema);
|
|
31
|
+
const _uiSchemaJSONPointer = utils_1.uiSchemaJSONPointer(schema, buttonField);
|
|
32
|
+
uiSchema = utils_1.updateSafelyWithJSONPointer(innerUiSchema, {
|
|
33
|
+
"ui:widget": "InputWithDefaultValueButtonWidget",
|
|
34
|
+
"ui:options": {
|
|
35
|
+
buttonLabel,
|
|
36
|
+
onClick: this.onClick
|
|
37
|
+
},
|
|
38
|
+
}, _uiSchemaJSONPointer);
|
|
39
|
+
return Object.assign(Object.assign({}, props), { uiSchema });
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
InputWithDefaultValueButtonField.propTypes = {
|
|
43
|
+
uiSchema: PropTypes.shape({
|
|
44
|
+
"ui:options": PropTypes.shape({
|
|
45
|
+
buttonLabel: PropTypes.string.isRequired,
|
|
46
|
+
buttonField: PropTypes.string.isRequired,
|
|
47
|
+
valueFields: PropTypes.arrayOf(PropTypes.shape({
|
|
48
|
+
field: PropTypes.string.isRequired,
|
|
49
|
+
contextFieldForDefaultValue: PropTypes.string.isRequired
|
|
50
|
+
}).isRequired)
|
|
51
|
+
}).isRequired
|
|
52
|
+
}).isRequired,
|
|
53
|
+
schema: PropTypes.shape({
|
|
54
|
+
type: PropTypes.oneOf(["object"])
|
|
55
|
+
}).isRequired,
|
|
56
|
+
formData: PropTypes.oneOfType([PropTypes.object]).isRequired
|
|
57
|
+
};
|
|
58
|
+
InputWithDefaultValueButtonField = __decorate([
|
|
59
|
+
VirtualSchemaField_1.default
|
|
60
|
+
], InputWithDefaultValueButtonField);
|
|
61
|
+
exports.default = InputWithDefaultValueButtonField;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export default class LocalityField extends React.Component<any, any, any> {
|
|
2
|
+
static contextType: React.Context<import("../../ReactContext").ContextProps>;
|
|
3
|
+
static propTypes: {
|
|
4
|
+
uiSchema: PropTypes.Requireable<object>;
|
|
5
|
+
schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
6
|
+
type: PropTypes.Requireable<string>;
|
|
7
|
+
}>>;
|
|
8
|
+
formData: PropTypes.Validator<object>;
|
|
9
|
+
};
|
|
10
|
+
constructor(props: any);
|
|
11
|
+
showEditor: () => void;
|
|
12
|
+
hideEditor: () => void;
|
|
13
|
+
setFormRef: (elem: any) => void;
|
|
14
|
+
lajiForm: any;
|
|
15
|
+
renderModal: () => JSX.Element;
|
|
16
|
+
onSubmitClick: (e: any) => void;
|
|
17
|
+
onSubmit: ({ formData }: {
|
|
18
|
+
formData: any;
|
|
19
|
+
}) => void;
|
|
20
|
+
}
|
|
21
|
+
import * as React from "react";
|
|
22
|
+
import * as PropTypes from "prop-types";
|
|
@@ -0,0 +1,94 @@
|
|
|
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 PropTypes = require("prop-types");
|
|
22
|
+
const utils_1 = require("../../utils");
|
|
23
|
+
const BaseComponent_1 = require("../BaseComponent");
|
|
24
|
+
const components_1 = require("../components");
|
|
25
|
+
const LajiForm_1 = require("../LajiForm");
|
|
26
|
+
const MapField_1 = require("./MapField");
|
|
27
|
+
const ReactContext_1 = require("../../ReactContext");
|
|
28
|
+
let LocalityField = class LocalityField extends React.Component {
|
|
29
|
+
constructor(props) {
|
|
30
|
+
super(props);
|
|
31
|
+
this.showEditor = () => {
|
|
32
|
+
this.setState({ modal: true });
|
|
33
|
+
};
|
|
34
|
+
this.hideEditor = () => {
|
|
35
|
+
this.setState({ modal: false });
|
|
36
|
+
};
|
|
37
|
+
this.setFormRef = (elem) => {
|
|
38
|
+
this.lajiForm = elem;
|
|
39
|
+
};
|
|
40
|
+
this.renderModal = () => {
|
|
41
|
+
const _a = this.props, { onChange } = _a, props = __rest(_a, ["onChange"]); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
42
|
+
const { Modal } = this.context.theme;
|
|
43
|
+
return (React.createElement(Modal, { dialogClassName: "laji-form image-modal", show: true, onHide: this.hideEditor },
|
|
44
|
+
React.createElement(Modal.Header, { closeButton: true }),
|
|
45
|
+
React.createElement(Modal.Body, null,
|
|
46
|
+
React.createElement(LajiForm_1.default, Object.assign({ ref: this.setFormRef }, props, { uiSchema: utils_1.getInnerUiSchema(this.props.uiSchema), onSubmit: this.onSubmit, lang: this.props.formContext.lang, showShortcutButton: false, renderSubmit: false, validators: {}, warnings: {}, apiClient: this.props.formContext.apiClient.apiClient, uiSchemaContext: this.props.formContext.uiSchemaContext })),
|
|
47
|
+
React.createElement(components_1.Button, { block: true, onClick: this.onSubmitClick }, "OK"),
|
|
48
|
+
React.createElement(components_1.Button, { block: true, onClick: this.hideEditor }, this.props.formContext.translations.Cancel))));
|
|
49
|
+
};
|
|
50
|
+
this.onSubmitClick = (e) => {
|
|
51
|
+
this.lajiForm._onDefaultSubmit(e);
|
|
52
|
+
};
|
|
53
|
+
this.onSubmit = ({ formData }) => {
|
|
54
|
+
this.props.onChange(formData);
|
|
55
|
+
this.hideEditor();
|
|
56
|
+
};
|
|
57
|
+
this.state = {};
|
|
58
|
+
}
|
|
59
|
+
render() {
|
|
60
|
+
const { radius: _radius, geometry } = utils_1.getUiOptions(this.props.uiSchema);
|
|
61
|
+
const fields = Object.keys(this.props.schema.properties);
|
|
62
|
+
const values = fields.filter(s => !utils_1.isEmptyString(this.props.formData[s])).map(f => this.props.formData[f]);
|
|
63
|
+
const radius = typeof _radius === "number"
|
|
64
|
+
? _radius
|
|
65
|
+
: geometry
|
|
66
|
+
? MapField_1.getCenterAndRadiusFromGeometry(geometry).radius
|
|
67
|
+
: undefined;
|
|
68
|
+
if (typeof radius === "number") {
|
|
69
|
+
values.push(`(${this.props.formContext.translations.accuracy}: ${parseInt(radius)}m)`);
|
|
70
|
+
}
|
|
71
|
+
const { Panel, Row, Col } = this.context.theme;
|
|
72
|
+
return (React.createElement(Row, null,
|
|
73
|
+
React.createElement(Col, { xs: 12 },
|
|
74
|
+
React.createElement(Panel, { className: utils_1.getUiOptions(this.props.uiSchema).panelClassName },
|
|
75
|
+
React.createElement(Panel.Body, null,
|
|
76
|
+
values.map((v, i) => (React.createElement("span", { key: i },
|
|
77
|
+
v,
|
|
78
|
+
i < values.length - 1 ? ", " : ""))),
|
|
79
|
+
React.createElement(components_1.GlyphButton, { onClick: this.showEditor, glyph: "pencil", variant: "default", className: "pull-right" })))),
|
|
80
|
+
this.state.modal && this.renderModal()));
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
LocalityField.contextType = ReactContext_1.default;
|
|
84
|
+
LocalityField.propTypes = {
|
|
85
|
+
uiSchema: PropTypes.object,
|
|
86
|
+
schema: PropTypes.shape({
|
|
87
|
+
type: PropTypes.oneOf(["object"])
|
|
88
|
+
}).isRequired,
|
|
89
|
+
formData: PropTypes.object.isRequired
|
|
90
|
+
};
|
|
91
|
+
LocalityField = __decorate([
|
|
92
|
+
BaseComponent_1.default
|
|
93
|
+
], LocalityField);
|
|
94
|
+
exports.default = LocalityField;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export default class LocationChooserField extends React.Component<any, any, any> {
|
|
2
|
+
static propTypes: {
|
|
3
|
+
uiSchema: PropTypes.Validator<PropTypes.InferProps<{
|
|
4
|
+
"ui:options": PropTypes.Requireable<PropTypes.InferProps<{
|
|
5
|
+
uiSchema: PropTypes.Requireable<object>;
|
|
6
|
+
taxonField: PropTypes.Requireable<string>;
|
|
7
|
+
geometryField: PropTypes.Requireable<string>;
|
|
8
|
+
strategy: PropTypes.Requireable<string>;
|
|
9
|
+
mapOptions: PropTypes.Requireable<object>;
|
|
10
|
+
maxShapes: PropTypes.Requireable<number>;
|
|
11
|
+
preselectMarker: PropTypes.Requireable<boolean>;
|
|
12
|
+
color: PropTypes.Requireable<string>;
|
|
13
|
+
}>>;
|
|
14
|
+
}>>;
|
|
15
|
+
schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
16
|
+
type: PropTypes.Requireable<string>;
|
|
17
|
+
}>>;
|
|
18
|
+
formData: PropTypes.Validator<object>;
|
|
19
|
+
};
|
|
20
|
+
constructor(props: any);
|
|
21
|
+
constructor(props: any, context: any);
|
|
22
|
+
getStateFromProps(props: any): {
|
|
23
|
+
uiSchema: any;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
import * as React from "react";
|
|
27
|
+
import * as PropTypes from "prop-types";
|