@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,615 +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
|
-
const React = require("react");
|
|
15
|
-
const react_dom_1 = require("react-dom");
|
|
16
|
-
const PropTypes = require("prop-types");
|
|
17
|
-
const validation_1 = require("../validation");
|
|
18
|
-
const validation_2 = require("../validation");
|
|
19
|
-
const components_1 = require("./components");
|
|
20
|
-
const utils_1 = require("../utils");
|
|
21
|
-
const equals = require("deep-equal");
|
|
22
|
-
const validator_ajv6_1 = require("@rjsf/validator-ajv6");
|
|
23
|
-
const merge = require("deepmerge");
|
|
24
|
-
const ReactContext_1 = require("../ReactContext");
|
|
25
|
-
const stub_1 = require("../themes/stub");
|
|
26
|
-
const core_1 = require("@rjsf/core");
|
|
27
|
-
const ApiClient_1 = require("../ApiClient");
|
|
28
|
-
const Context_1 = require("../Context");
|
|
29
|
-
const translations = require("../translations.json");
|
|
30
|
-
const key_handler_service_1 = require("../services/key-handler-service");
|
|
31
|
-
const settings_service_1 = require("../services/settings-service");
|
|
32
|
-
const focus_service_1 = require("../services/focus-service");
|
|
33
|
-
const blocker_service_1 = require("../services/blocker-service");
|
|
34
|
-
const custom_event_service_1 = require("../services/custom-event-service");
|
|
35
|
-
const submit_hook_service_1 = require("../services/submit-hook-service");
|
|
36
|
-
const dom_id_service_1 = require("../services/dom-id-service");
|
|
37
|
-
const id_service_1 = require("../services/id-service");
|
|
38
|
-
const root_instance_service_1 = require("../services/root-instance-service");
|
|
39
|
-
const singleton_map_service_1 = require("../services/singleton-map-service");
|
|
40
|
-
const fields = importLocalComponents("fields", [
|
|
41
|
-
"SchemaField",
|
|
42
|
-
{ "ArraySchemaField": "SchemaField" },
|
|
43
|
-
"ArrayField",
|
|
44
|
-
"ObjectField",
|
|
45
|
-
"NestField",
|
|
46
|
-
"ArrayBulkField",
|
|
47
|
-
"ArrayBulkField",
|
|
48
|
-
"ScopeField",
|
|
49
|
-
"SelectTreeField",
|
|
50
|
-
"GridLayoutField",
|
|
51
|
-
"TableField",
|
|
52
|
-
"InjectField",
|
|
53
|
-
"InjectDefaultValueField",
|
|
54
|
-
"ArrayCombinerField",
|
|
55
|
-
"DependentBooleanField",
|
|
56
|
-
"DependentDisableField",
|
|
57
|
-
"MapArrayField",
|
|
58
|
-
"AutoArrayField",
|
|
59
|
-
"AutosuggestField",
|
|
60
|
-
"HiddenField",
|
|
61
|
-
"InitiallyHiddenField",
|
|
62
|
-
"ContextInjectionField",
|
|
63
|
-
"ImageArrayField",
|
|
64
|
-
"SplitField",
|
|
65
|
-
"FlatField",
|
|
66
|
-
"SingleActiveArrayField",
|
|
67
|
-
"SingleItemArrayField",
|
|
68
|
-
"UnitShorthandField",
|
|
69
|
-
"CombinedValueDisplayField",
|
|
70
|
-
"UiFieldMapperArrayField",
|
|
71
|
-
"ExtraLabelRowField",
|
|
72
|
-
"SumField",
|
|
73
|
-
"NamedPlaceChooserField",
|
|
74
|
-
"NamedPlaceSaverField",
|
|
75
|
-
"MapField",
|
|
76
|
-
"GeocoderField",
|
|
77
|
-
"TagArrayField",
|
|
78
|
-
"StringToArrayField",
|
|
79
|
-
"ConditionalOnChangeField",
|
|
80
|
-
"ConditionalUiSchemaField",
|
|
81
|
-
"AnnotationField",
|
|
82
|
-
"PrefillingArrayField",
|
|
83
|
-
"AnyToBooleanField",
|
|
84
|
-
"EnumRangeArrayField",
|
|
85
|
-
"UnitListShorthandArrayField",
|
|
86
|
-
"LocationChooserField",
|
|
87
|
-
"DataLeakerField",
|
|
88
|
-
"LocalityField",
|
|
89
|
-
"ImageDisplayField",
|
|
90
|
-
"FakePropertyField",
|
|
91
|
-
"SectionArrayField",
|
|
92
|
-
"MultiArrayField",
|
|
93
|
-
"AudioArrayField",
|
|
94
|
-
"FilterArrayField",
|
|
95
|
-
"MultiAnyToBooleanField",
|
|
96
|
-
"UnitCountShorthandField",
|
|
97
|
-
"ToggleAdditionalArrayFieldsField",
|
|
98
|
-
"DefaultValueArrayField",
|
|
99
|
-
"UiFieldApplierField",
|
|
100
|
-
"MultiLanguageField",
|
|
101
|
-
"SortArrayField",
|
|
102
|
-
"InputWithDefaultValueButtonField",
|
|
103
|
-
"MultiTagArrayField",
|
|
104
|
-
"PdfArrayField",
|
|
105
|
-
{ "InputTransformerField": "ConditionalOnChangeField" },
|
|
106
|
-
{ "ConditionalField": "ConditionalUiSchemaField" },
|
|
107
|
-
{ "UnitRapidField": "UnitShorthandField" },
|
|
108
|
-
{ "AccordionArrayField": "SingleActiveArrayField" } // Alias for backward compatibility.
|
|
109
|
-
]);
|
|
110
|
-
const widgets = importLocalComponents("widgets", [
|
|
111
|
-
"CheckboxWidget",
|
|
112
|
-
"SelectWidget",
|
|
113
|
-
"TextareaWidget",
|
|
114
|
-
"DateTimeWidget",
|
|
115
|
-
"DateWidget",
|
|
116
|
-
"TimeWidget",
|
|
117
|
-
"SeparatedDateTimeWidget",
|
|
118
|
-
"AutosuggestWidget",
|
|
119
|
-
"HiddenWidget",
|
|
120
|
-
"PlainTextWidget",
|
|
121
|
-
"TextSelectWidget",
|
|
122
|
-
"ImageSelectWidget",
|
|
123
|
-
"AnyToBooleanWidget",
|
|
124
|
-
"URLWidget",
|
|
125
|
-
"InformalTaxonGroupChooserWidget",
|
|
126
|
-
"TaxonImageWidget",
|
|
127
|
-
"UpperCaseWidget",
|
|
128
|
-
"NumberWidget",
|
|
129
|
-
"InputGroupWidget",
|
|
130
|
-
"InputWithDefaultValueButtonWidget"
|
|
131
|
-
]);
|
|
132
|
-
const templates = importLocalComponents("templates", [
|
|
133
|
-
"BaseInputTemplate",
|
|
134
|
-
"DescriptionField",
|
|
135
|
-
{ "TitleFieldTemplate": "TitleField" },
|
|
136
|
-
{ "DescriptionFieldTemplate": "DescriptionField" },
|
|
137
|
-
"FieldTemplate",
|
|
138
|
-
"ArrayFieldTemplate",
|
|
139
|
-
"ErrorListTemplate",
|
|
140
|
-
"ObjectFieldTemplate"
|
|
141
|
-
]);
|
|
142
|
-
function importLocalComponents(dir, fieldNames) {
|
|
143
|
-
return fieldNames.reduce((fields, field) => {
|
|
144
|
-
if (typeof field === "string") {
|
|
145
|
-
fields[field] = require(`./${dir}/${field}`).default;
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
const fieldName = Object.keys(field)[0];
|
|
149
|
-
if (typeof field[fieldName] === "string") {
|
|
150
|
-
fields[fieldName] = require(`./${dir}/${field[fieldName]}`).default;
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
fields[fieldName] = field[fieldName];
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
return fields;
|
|
157
|
-
}, {});
|
|
158
|
-
}
|
|
159
|
-
// Each form should have a unique id to keep Context private.
|
|
160
|
-
let id = 0;
|
|
161
|
-
function getNewId() {
|
|
162
|
-
const _id = id;
|
|
163
|
-
id++;
|
|
164
|
-
return _id;
|
|
165
|
-
}
|
|
166
|
-
class LajiForm extends React.Component {
|
|
167
|
-
constructor(props) {
|
|
168
|
-
super(props);
|
|
169
|
-
this.translations = this.constructTranslations();
|
|
170
|
-
this.bgJobRef = React.createRef();
|
|
171
|
-
this.shortcutHelpRef = React.createRef();
|
|
172
|
-
this.propagateSubmit = true;
|
|
173
|
-
this.formRef = React.createRef();
|
|
174
|
-
this.validating = false;
|
|
175
|
-
this.eventListeners = [];
|
|
176
|
-
this.timeouts = [];
|
|
177
|
-
this.onSubmitHooksChange = (submitHooks, callback) => {
|
|
178
|
-
this.setState({ submitHooks }, callback);
|
|
179
|
-
};
|
|
180
|
-
this.getDefaultNotifier = () => {
|
|
181
|
-
if (this.defaultNotifier)
|
|
182
|
-
return this.defaultNotifier;
|
|
183
|
-
this.defaultNotifier = ["success", "info", "warning", "error"].reduce((notifier, method) => {
|
|
184
|
-
notifier[method] = msg => console.warn(`Notification component not specified for LajiForm! Got '${method}'notification: '${msg}'`);
|
|
185
|
-
return notifier;
|
|
186
|
-
}, {});
|
|
187
|
-
return this.defaultNotifier;
|
|
188
|
-
};
|
|
189
|
-
this.onChange = ({ formData }) => {
|
|
190
|
-
this.setState({ formData }, () => {
|
|
191
|
-
if (this.props.onChange) {
|
|
192
|
-
const _formData = this.props.optimizeOnChange
|
|
193
|
-
? formData
|
|
194
|
-
: this.memoizedFormContext.services.ids.removeLajiFormIds(formData);
|
|
195
|
-
this.props.onChange(_formData);
|
|
196
|
-
}
|
|
197
|
-
this.memoizedFormContext.services.ids.setFormData(formData);
|
|
198
|
-
this.memoizedFormContext.services.rootInstance.setFormData(formData);
|
|
199
|
-
!this.validating && this.validate(!!"warnings", !"nonlive");
|
|
200
|
-
});
|
|
201
|
-
};
|
|
202
|
-
this.getFields = (_fields) => (Object.assign(Object.assign({}, fields), (_fields || {})));
|
|
203
|
-
this.getWidgets = (_widgets) => (Object.assign(Object.assign({}, widgets), (_widgets || {})));
|
|
204
|
-
this.getTemplates = (_templates) => (Object.assign(Object.assign({}, templates), (_templates || {})));
|
|
205
|
-
this.getContext = (props, context) => {
|
|
206
|
-
const nextKey = ["theme"].reduce((key, prop) => {
|
|
207
|
-
key[prop] = props[prop];
|
|
208
|
-
return key;
|
|
209
|
-
}, {});
|
|
210
|
-
if (this.contextMemoizeKey && Object.keys(this.contextMemoizeKey).every(k => this.contextMemoizeKey[k] === nextKey[k])) {
|
|
211
|
-
return this.memoizedContext;
|
|
212
|
-
}
|
|
213
|
-
else {
|
|
214
|
-
this.contextMemoizeKey = nextKey;
|
|
215
|
-
this.memoizedContext = {
|
|
216
|
-
theme: props.theme || (context === null || context === void 0 ? void 0 : context.theme) || stub_1.default,
|
|
217
|
-
};
|
|
218
|
-
return this.memoizedContext;
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
this.renderSubmitHooks = () => {
|
|
222
|
-
if (!this.state || !this.state.submitHooks)
|
|
223
|
-
return;
|
|
224
|
-
const jobsAmount = this.state.submitHooks.filter(({ failed }) => !failed).length;
|
|
225
|
-
const runningAmount = this.state.submitHooks.reduce((count, { running }) => running ? count + 1 : count, 0);
|
|
226
|
-
if (!this.state.runningSubmitHooks)
|
|
227
|
-
return null;
|
|
228
|
-
const { ProgressBar } = this.getContext(this.props, this.context).theme;
|
|
229
|
-
return (React.createElement("div", { className: "running-jobs" },
|
|
230
|
-
this.state.formContext.translations.PendingRunningJobs,
|
|
231
|
-
"... (",
|
|
232
|
-
jobsAmount - runningAmount + 1,
|
|
233
|
-
" / ",
|
|
234
|
-
jobsAmount,
|
|
235
|
-
")",
|
|
236
|
-
React.createElement(ProgressBar, { now: 100 / jobsAmount * (jobsAmount - runningAmount) })));
|
|
237
|
-
};
|
|
238
|
-
this.validateAndSubmit = (warnings = true, onlySchema = false) => {
|
|
239
|
-
const { formData } = this.state;
|
|
240
|
-
const { onValidationError, onSubmit } = this.props;
|
|
241
|
-
return this.validate(warnings, true, onlySchema).then((valid) => {
|
|
242
|
-
if (formData !== this.state.formData) {
|
|
243
|
-
this.validateAndSubmit(warnings, onlySchema);
|
|
244
|
-
}
|
|
245
|
-
else if (valid) {
|
|
246
|
-
onSubmit && onSubmit({ formData: this.memoizedFormContext.services.ids.removeLajiFormIds(formData) });
|
|
247
|
-
}
|
|
248
|
-
else {
|
|
249
|
-
onValidationError && onValidationError(this.state.extraErrors);
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
};
|
|
253
|
-
this.validate = (warnings = true, nonlive = true, onlySchema = false) => {
|
|
254
|
-
this.validating = true;
|
|
255
|
-
let live = true;
|
|
256
|
-
if (onlySchema) {
|
|
257
|
-
warnings = false;
|
|
258
|
-
nonlive = false;
|
|
259
|
-
live = false;
|
|
260
|
-
}
|
|
261
|
-
const block = nonlive || onlySchema;
|
|
262
|
-
const { formData } = this.state;
|
|
263
|
-
const { live: liveErrorValidators, rest: errorValidators } = splitLive(this.props.validators, this.props.schema.properties);
|
|
264
|
-
const { live: liveWarningValidators, rest: warningValidators } = splitLive(this.props.warnings, this.props.schema.properties);
|
|
265
|
-
let liveValidations = { errors: liveErrorValidators };
|
|
266
|
-
const validations = {};
|
|
267
|
-
if (!onlySchema && nonlive) {
|
|
268
|
-
validations.errors = errorValidators;
|
|
269
|
-
}
|
|
270
|
-
if (!onlySchema && warnings) {
|
|
271
|
-
liveValidations.warnings = liveWarningValidators;
|
|
272
|
-
if (nonlive) {
|
|
273
|
-
validations.warnings = warningValidators;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
if (!live) {
|
|
277
|
-
liveValidations = {};
|
|
278
|
-
}
|
|
279
|
-
const schemaErrors = nonlive || onlySchema
|
|
280
|
-
? validator_ajv6_1.default.validateFormData(formData, this.props.schema, undefined, ((e) => validation_2.transformErrors(this.state.formContext.translations, e))).errorSchema
|
|
281
|
-
: {};
|
|
282
|
-
block && this.memoizedFormContext.services.blocker.push();
|
|
283
|
-
return new Promise(resolve => Promise.all([validation_1.default(validations, formData), validation_1.default(liveValidations, formData)]).then(([_validations, _liveValidations]) => {
|
|
284
|
-
if (nonlive || onlySchema) {
|
|
285
|
-
this.cachedNonliveValidations = merge(schemaErrors, _validations);
|
|
286
|
-
block && this.memoizedFormContext.services.blocker.pop();
|
|
287
|
-
}
|
|
288
|
-
const merged = merge(_liveValidations, !nonlive
|
|
289
|
-
? (this.cachedNonliveValidations || {})
|
|
290
|
-
: merge(_validations, schemaErrors));
|
|
291
|
-
this.validating = false;
|
|
292
|
-
resolve(!Object.keys(merged).length);
|
|
293
|
-
!equals((this.state.extraErrors || {}), merged) && this.setState({ extraErrors: merged }, this.popErrorListIfNeeded);
|
|
294
|
-
}).catch((e) => {
|
|
295
|
-
block && this.memoizedFormContext.services.blocker.pop();
|
|
296
|
-
throw e;
|
|
297
|
-
}));
|
|
298
|
-
function splitLive(validators = {}, schema, live = {}, rest = {}) {
|
|
299
|
-
Object.keys(validators).forEach(key => {
|
|
300
|
-
if (schema[key]) {
|
|
301
|
-
live[key] = {};
|
|
302
|
-
rest[key] = {};
|
|
303
|
-
splitLive(validators[key], schema[key], live[key], rest[key]);
|
|
304
|
-
if (Object.keys(live[key]).length === 0)
|
|
305
|
-
delete live[key];
|
|
306
|
-
if (Object.keys(rest[key]).length === 0)
|
|
307
|
-
delete rest[key];
|
|
308
|
-
}
|
|
309
|
-
else {
|
|
310
|
-
const container = validators[key].options && validators[key].options._live ? live : rest;
|
|
311
|
-
container[key] = validators[key];
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
return { live, rest };
|
|
315
|
-
}
|
|
316
|
-
};
|
|
317
|
-
this.onSubmit = (onlySchemaValidations) => {
|
|
318
|
-
const _onlySchemaValidations = onlySchemaValidations === "onlySchemaValidations";
|
|
319
|
-
const { uiSchema } = this.props;
|
|
320
|
-
if (uiSchema["ui:disabled"] || uiSchema["ui:readonly"]) {
|
|
321
|
-
return false;
|
|
322
|
-
}
|
|
323
|
-
this.memoizedFormContext.services.blocker.push();
|
|
324
|
-
this.setState({ runningSubmitHooks: true });
|
|
325
|
-
this.memoizedFormContext.services.submitHooks.checkHooks().then(() => {
|
|
326
|
-
this.memoizedFormContext.services.blocker.pop();
|
|
327
|
-
this.setState({ runningSubmitHooks: false });
|
|
328
|
-
this.validateAndSubmit(!_onlySchemaValidations, _onlySchemaValidations);
|
|
329
|
-
}).catch(() => {
|
|
330
|
-
var _a;
|
|
331
|
-
this.setState({ runningSubmitHooks: false });
|
|
332
|
-
this.memoizedFormContext.services.blocker.pop();
|
|
333
|
-
utils_1.highlightElem(react_dom_1.findDOMNode((_a = this.bgJobRef) === null || _a === void 0 ? void 0 : _a.current));
|
|
334
|
-
});
|
|
335
|
-
return undefined;
|
|
336
|
-
};
|
|
337
|
-
this.popErrorListIfNeeded = () => {
|
|
338
|
-
const errorList = this.memoizedFormContext.services.rootInstance.getErrorListInstance();
|
|
339
|
-
let errorListElem;
|
|
340
|
-
try {
|
|
341
|
-
errorListElem = react_dom_1.findDOMNode(errorList);
|
|
342
|
-
}
|
|
343
|
-
catch (e) {
|
|
344
|
-
// Empty
|
|
345
|
-
}
|
|
346
|
-
if (!errorListElem)
|
|
347
|
-
return;
|
|
348
|
-
const wouldScrollTo = utils_1.getScrollPositionForScrollIntoViewIfNeeded(errorListElem, this.props.topOffset, this.props.bottomOffset) || 0;
|
|
349
|
-
const scrollAmount = wouldScrollTo - utils_1.getWindowScrolled();
|
|
350
|
-
if (!errorList.state.poppedTouched && scrollAmount !== 0) {
|
|
351
|
-
errorList.expand();
|
|
352
|
-
}
|
|
353
|
-
utils_1.highlightElem(errorListElem);
|
|
354
|
-
};
|
|
355
|
-
this._onDefaultSubmit = (e) => {
|
|
356
|
-
e.preventDefault();
|
|
357
|
-
this.submit();
|
|
358
|
-
};
|
|
359
|
-
this.submit = () => {
|
|
360
|
-
this.onSubmit();
|
|
361
|
-
};
|
|
362
|
-
this.submitOnlySchemaValidations = () => {
|
|
363
|
-
this.onSubmit("onlySchemaValidations");
|
|
364
|
-
};
|
|
365
|
-
this.getShorcutButtonTooltip = () => {
|
|
366
|
-
const { translations } = this.state.formContext;
|
|
367
|
-
if (this.keyCombo) {
|
|
368
|
-
return utils_1.translate(translations, "ShortcutHelp", { key: utils_1.stringifyKeyCombo(this.keyCombo) });
|
|
369
|
-
}
|
|
370
|
-
return undefined;
|
|
371
|
-
};
|
|
372
|
-
this.toggleHelp = (e) => {
|
|
373
|
-
this.helpVisible ? this.dismissHelp(e) : this.showHelp();
|
|
374
|
-
};
|
|
375
|
-
this.showHelp = () => {
|
|
376
|
-
const node = react_dom_1.findDOMNode(this.shortcutHelpRef.current);
|
|
377
|
-
if (!this.helpVisible) {
|
|
378
|
-
if (node)
|
|
379
|
-
node.className = node.className.replace(" hidden", "");
|
|
380
|
-
this.helpVisible = true;
|
|
381
|
-
}
|
|
382
|
-
};
|
|
383
|
-
this.dismissHelp = (e) => {
|
|
384
|
-
const node = react_dom_1.findDOMNode(this.shortcutHelpRef.current);
|
|
385
|
-
e.preventDefault();
|
|
386
|
-
e.stopPropagation();
|
|
387
|
-
if (this.helpVisible && node) {
|
|
388
|
-
node.className += " hidden";
|
|
389
|
-
}
|
|
390
|
-
this.helpVisible = false;
|
|
391
|
-
this.helpStarted = false;
|
|
392
|
-
document.removeEventListener("keyup", this.dismissHelp);
|
|
393
|
-
window.removeEventListener("blur", this.dismissHelp);
|
|
394
|
-
clearTimeout(this.helpTimeout);
|
|
395
|
-
};
|
|
396
|
-
this.keyFunctions = {
|
|
397
|
-
navigate: (e, { reverse }) => {
|
|
398
|
-
return this.memoizedFormContext.services.focus.focusNextInput(reverse);
|
|
399
|
-
},
|
|
400
|
-
help: (e, { delay }) => {
|
|
401
|
-
if (this.helpStarted)
|
|
402
|
-
return false;
|
|
403
|
-
this.helpStarted = true;
|
|
404
|
-
this.helpTimeout = window.setTimeout(() => {
|
|
405
|
-
this.showHelp();
|
|
406
|
-
}, delay * 1000);
|
|
407
|
-
this.addEventListener(document, "keyup", this.dismissHelp);
|
|
408
|
-
this.addEventListener(window, "blur", this.dismissHelp);
|
|
409
|
-
return false;
|
|
410
|
-
},
|
|
411
|
-
revalidate: () => {
|
|
412
|
-
this.submit();
|
|
413
|
-
}
|
|
414
|
-
};
|
|
415
|
-
this.pushBlockingLoader = () => {
|
|
416
|
-
this.memoizedFormContext.services.blocker.push();
|
|
417
|
-
};
|
|
418
|
-
this.popBlockingLoader = () => {
|
|
419
|
-
this.memoizedFormContext.services.blocker.pop();
|
|
420
|
-
};
|
|
421
|
-
this.onSettingsChange = (settings, global = false) => {
|
|
422
|
-
if (this.props.onSettingsChange)
|
|
423
|
-
this.props.onSettingsChange(settings, global);
|
|
424
|
-
};
|
|
425
|
-
this.addEventListener = (target, name, fn) => {
|
|
426
|
-
target.addEventListener(name, fn);
|
|
427
|
-
this.eventListeners.push([target, name, fn]);
|
|
428
|
-
};
|
|
429
|
-
this.setTimeout = (fn, time = 0) => {
|
|
430
|
-
const timeout = window.setTimeout(fn, time);
|
|
431
|
-
this.timeouts.push(timeout);
|
|
432
|
-
return timeout;
|
|
433
|
-
};
|
|
434
|
-
this.destroy = () => {
|
|
435
|
-
if (this.eventListeners)
|
|
436
|
-
this.eventListeners.forEach(([target, name, fn]) => {
|
|
437
|
-
target.removeEventListener(name, fn);
|
|
438
|
-
});
|
|
439
|
-
if (this.timeouts)
|
|
440
|
-
this.timeouts.forEach((timeout) => {
|
|
441
|
-
clearTimeout(timeout);
|
|
442
|
-
});
|
|
443
|
-
this.eventListeners = [];
|
|
444
|
-
};
|
|
445
|
-
if (props.apiClient) {
|
|
446
|
-
this.apiClient = new ApiClient_1.default(props.apiClient, props.lang, this.translations);
|
|
447
|
-
}
|
|
448
|
-
validation_2.initializeValidation(this.apiClient);
|
|
449
|
-
this._id = getNewId();
|
|
450
|
-
this.getMemoizedFormContext(props); // Initialize form context.
|
|
451
|
-
this.resetShortcuts((props.uiSchema || {})["ui:shortcuts"]);
|
|
452
|
-
this.state = this.getStateFromProps(props);
|
|
453
|
-
}
|
|
454
|
-
UNSAFE_componentWillReceiveProps(props) {
|
|
455
|
-
if (props.apiClient && props.apiClient !== this.apiClient) {
|
|
456
|
-
this.apiClient = new ApiClient_1.default(props.apiClient, props.lang, this.translations);
|
|
457
|
-
}
|
|
458
|
-
if (this.apiClient && "lang" in props && this.props.lang !== props.lang) {
|
|
459
|
-
this.apiClient.setLang(props.lang);
|
|
460
|
-
}
|
|
461
|
-
this.setState(this.getStateFromProps(props));
|
|
462
|
-
}
|
|
463
|
-
getStateFromProps(props) {
|
|
464
|
-
const state = {
|
|
465
|
-
formContext: this.getMemoizedFormContext(props)
|
|
466
|
-
};
|
|
467
|
-
if (((!this.state && props.schema && Object.keys(props.schema).length) || (this.state && !("formData" in this.state))) || ("formData" in props && props.formData !== this.props.formData)) {
|
|
468
|
-
state.formData = state.formContext.services.ids.addLajiFormIds(utils_1.getDefaultFormState(props.schema, props.formData, props.schema))[0];
|
|
469
|
-
}
|
|
470
|
-
else if (this.state && this.formRef.current) {
|
|
471
|
-
state.formData = this.formRef.current.state.formData;
|
|
472
|
-
}
|
|
473
|
-
if (this.state && props.schema !== this.props.schema) {
|
|
474
|
-
state.extraErrors = {};
|
|
475
|
-
}
|
|
476
|
-
this.memoizedFormContext.services.ids.setFormData(state.formData);
|
|
477
|
-
this.memoizedFormContext.services.rootInstance.setFormData(state.formData);
|
|
478
|
-
return state;
|
|
479
|
-
}
|
|
480
|
-
getMemoizedFormContext(props) {
|
|
481
|
-
const nextKey = ["lang", "topOffset", "bottomOffset", "formContext", "settings", "schema", "uiSchemaContext", "lajiGeoServerAddress"].reduce((key, prop) => {
|
|
482
|
-
key[prop] = props[prop];
|
|
483
|
-
return key;
|
|
484
|
-
}, {});
|
|
485
|
-
if (this.contextFormMemoizeKey && Object.keys(this.contextFormMemoizeKey).every(k => this.contextFormMemoizeKey[k] === nextKey[k])) {
|
|
486
|
-
return this.memoizedFormContext;
|
|
487
|
-
}
|
|
488
|
-
else {
|
|
489
|
-
this.contextFormMemoizeKey = nextKey;
|
|
490
|
-
const { services } = this.memoizedFormContext || {};
|
|
491
|
-
this.memoizedFormContext = Object.assign(Object.assign({}, props.formContext), { translations: this.translations[props.lang], lang: props.lang, uiSchemaContext: props.uiSchemaContext || {}, topOffset: props.topOffset || 0, bottomOffset: props.bottomOffset || 0, contextId: this._id, formID: props.id, googleApiKey: props.googleApiKey, notifier: props.notifier || this.getDefaultNotifier(), apiClient: this.apiClient, Label: (props.fields || {}).Label || components_1.Label, mediaMetadata: props.mediaMetadata, setTimeout: this.setTimeout, services: {}, formRef: this.formRef, lajiGeoServerAddress: props.lajiGeoServerAddress, globals: Context_1.default(this._id) });
|
|
492
|
-
this.memoizedFormContext.utils = utils_1.ReactUtils(this.memoizedFormContext);
|
|
493
|
-
if (services) {
|
|
494
|
-
this.memoizedFormContext.services = services;
|
|
495
|
-
services.keyHandler.setFormContext(this.memoizedFormContext);
|
|
496
|
-
services.focus.setFormContext(this.memoizedFormContext);
|
|
497
|
-
services.settings.setSettings(props.settings);
|
|
498
|
-
services.ids.setSchema(props.schema);
|
|
499
|
-
services.rootInstance.setSchema(props.schema);
|
|
500
|
-
}
|
|
501
|
-
else {
|
|
502
|
-
this.memoizedFormContext.services.keyHandler = new key_handler_service_1.default(this.memoizedFormContext);
|
|
503
|
-
this.memoizedFormContext.services.settings = new settings_service_1.default(this.onSettingsChange, props.settings);
|
|
504
|
-
this.memoizedFormContext.services.focus = new focus_service_1.default(this.memoizedFormContext);
|
|
505
|
-
this.memoizedFormContext.services.blocker = new blocker_service_1.default(this.memoizedFormContext);
|
|
506
|
-
this.memoizedFormContext.services.customEvents = new custom_event_service_1.default();
|
|
507
|
-
this.memoizedFormContext.services.submitHooks = new submit_hook_service_1.default(this.onSubmitHooksChange);
|
|
508
|
-
this.memoizedFormContext.services.DOMIds = new dom_id_service_1.default();
|
|
509
|
-
this.memoizedFormContext.services.ids = new id_service_1.default(props.schema, props.formData);
|
|
510
|
-
this.memoizedFormContext.services.rootInstance = new root_instance_service_1.default(props.schema, props.formData, (formData) => this.onChange({ formData }), this.validate, () => this.validateAndSubmit(false));
|
|
511
|
-
this.memoizedFormContext.services.singletonMap = new singleton_map_service_1.default();
|
|
512
|
-
}
|
|
513
|
-
return this.memoizedFormContext;
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
componentDidMount() {
|
|
517
|
-
this.mounted = true;
|
|
518
|
-
this.memoizedFormContext.services.rootInstance.setIsMounted(true);
|
|
519
|
-
this.props.autoFocus && this.memoizedFormContext.utils.focusById("root");
|
|
520
|
-
Object.keys(this.memoizedFormContext.services).forEach(service => {
|
|
521
|
-
var _a, _b;
|
|
522
|
-
(_b = (_a = this.memoizedFormContext.services[service]).initialize) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
523
|
-
});
|
|
524
|
-
if (this.props.componentDidMount)
|
|
525
|
-
this.props.componentDidMount();
|
|
526
|
-
}
|
|
527
|
-
componentWillUnmount() {
|
|
528
|
-
this.mounted = false;
|
|
529
|
-
this.memoizedFormContext.services.rootInstance.setIsMounted(false);
|
|
530
|
-
Object.keys(this.memoizedFormContext.services).forEach(service => {
|
|
531
|
-
var _a, _b;
|
|
532
|
-
(_b = (_a = this.memoizedFormContext.services[service]).destroy) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
533
|
-
});
|
|
534
|
-
}
|
|
535
|
-
componentDidCatch(e, i) {
|
|
536
|
-
this.setState({ error: true });
|
|
537
|
-
if (this.props.onError) {
|
|
538
|
-
this.props.onError(e, i);
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
componentDidUpdate(prevProps) {
|
|
542
|
-
if ((prevProps.uiSchema || {})["ui:shortcuts"] !== (this.props.uiSchema || {})["ui:shortcuts"]) {
|
|
543
|
-
this.resetShortcuts((this.props.uiSchema || {})["ui:shortcuts"]);
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
resetShortcuts(shortcuts = {}) {
|
|
547
|
-
this.memoizedFormContext.services.keyHandler.setShortcuts(shortcuts, this.keyFunctions);
|
|
548
|
-
Object.keys(shortcuts).some(keyCombo => {
|
|
549
|
-
if (shortcuts[keyCombo].fn == "help") {
|
|
550
|
-
this.keyCombo = keyCombo;
|
|
551
|
-
return true;
|
|
552
|
-
}
|
|
553
|
-
return false;
|
|
554
|
-
});
|
|
555
|
-
}
|
|
556
|
-
constructTranslations() {
|
|
557
|
-
return utils_1.constructTranslations(translations);
|
|
558
|
-
}
|
|
559
|
-
render() {
|
|
560
|
-
if (this.state.error)
|
|
561
|
-
return null;
|
|
562
|
-
const { translations } = this.state.formContext;
|
|
563
|
-
const { "ui:shortcuts": shortcuts, "ui:showShortcutsButton": showShortcutsButton = true, "ui:readonly": readonly, "ui:disabled": disabled } = this.props.uiSchema;
|
|
564
|
-
const uiSchema = Object.assign(Object.assign({}, this.props.uiSchema), { "ui:submitButtonOptions": {
|
|
565
|
-
norender: true
|
|
566
|
-
} });
|
|
567
|
-
const { Panel, Table } = this.getContext(this.props, this.context).theme;
|
|
568
|
-
const panelHeader = (React.createElement("h3", null,
|
|
569
|
-
translations.Shortcuts,
|
|
570
|
-
React.createElement("button", { type: "button", className: "close pull-right", onClick: this.dismissHelp }, "\u00D7")));
|
|
571
|
-
return (React.createElement(ReactContext_1.default.Provider, { value: this.getContext(this.props, this.context) },
|
|
572
|
-
React.createElement("div", { className: "laji-form" },
|
|
573
|
-
showShortcutsButton && this.props.showShortcutButton !== false && shortcuts && (React.createElement(components_1.TooltipComponent, { tooltip: this.getShorcutButtonTooltip() },
|
|
574
|
-
React.createElement(components_1.Button, { variant: undefined, onClick: this.toggleHelp }, translations.Shortcuts))),
|
|
575
|
-
React.createElement(components_1.FailedBackgroundJobsPanel, { jobs: this.state.submitHooks, schema: this.props.schema, uiSchema: uiSchema, formContext: this.state.formContext, errorClickHandler: this.memoizedFormContext.services.focus.focus, ref: this.bgJobRef }),
|
|
576
|
-
React.createElement(core_1.default, Object.assign({}, this.props, { formData: this.state.formData, uiSchema: uiSchema, ref: this.formRef, onChange: this.onChange, onSubmit: this.onSubmit, fields: this.getFields(this.props.fields), widgets: this.getWidgets(this.props.widgets), templates: this.getTemplates(this.props.templates), formContext: this.state.formContext, validator: validator_ajv6_1.default, noValidate: true, extraErrors: this.state.extraErrors, noHtml5Validate: true, liveValidate: true, autoComplete: "off", tagName: "div", readonly: readonly, disabled: disabled }), this.props.children),
|
|
577
|
-
(!this.props.children && this.props.renderSubmit !== false) ? (React.createElement(components_1.Button, { id: "submit", onClick: this.submit, disabled: readonly || disabled }, this.props.submitText || translations.Submit)) : null,
|
|
578
|
-
shortcuts &&
|
|
579
|
-
React.createElement(Panel, { ref: this.shortcutHelpRef, className: "shortcut-help laji-form-popped z-depth-3 hidden", style: { top: (this.props.topOffset || 0) + 5, bottom: (this.props.bottomOffset || 0) + 5 }, variant: "info" },
|
|
580
|
-
React.createElement(Panel.Heading, null, panelHeader),
|
|
581
|
-
React.createElement(Table, null,
|
|
582
|
-
React.createElement("tbody", { className: "well" }, Object.keys(shortcuts).map((keyCombo, idx) => {
|
|
583
|
-
const _a = shortcuts[keyCombo], { fn, targetLabel, label } = _a, rest = __rest(_a, ["fn", "targetLabel", "label"]);
|
|
584
|
-
if (["help", "autosuggestToggle"].includes(fn) || fn === "navigateSection" && rest.goOverRow)
|
|
585
|
-
return;
|
|
586
|
-
let translation = "";
|
|
587
|
-
if (translation)
|
|
588
|
-
translation = label;
|
|
589
|
-
else
|
|
590
|
-
translation = translations[[fn, ...Object.keys(rest)].map(utils_1.capitalizeFirstLetter).join("")];
|
|
591
|
-
if (targetLabel)
|
|
592
|
-
translation = `${translation} ${targetLabel}`;
|
|
593
|
-
return (React.createElement("tr", { key: idx },
|
|
594
|
-
React.createElement("td", null, utils_1.stringifyKeyCombo(keyCombo)),
|
|
595
|
-
React.createElement("td", null, translation)));
|
|
596
|
-
})))),
|
|
597
|
-
this.renderSubmitHooks())));
|
|
598
|
-
}
|
|
599
|
-
getSettings(global = false) {
|
|
600
|
-
return this.memoizedFormContext.services.settings.getSettings(global);
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
exports.default = LajiForm;
|
|
604
|
-
LajiForm.contextType = ReactContext_1.default;
|
|
605
|
-
LajiForm.propTypes = {
|
|
606
|
-
uiSchemaContext: PropTypes.object,
|
|
607
|
-
settings: PropTypes.object,
|
|
608
|
-
validators: PropTypes.object,
|
|
609
|
-
warnings: PropTypes.object,
|
|
610
|
-
};
|
|
611
|
-
LajiForm.defaultProps = {
|
|
612
|
-
lang: "en",
|
|
613
|
-
schema: {},
|
|
614
|
-
uiSchema: {}
|
|
615
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { FieldProps } from "./LajiForm";
|
|
3
|
-
export declare function getPropsWithInnerUiSchema(props: FieldProps): FieldProps;
|
|
4
|
-
declare type Constructor<LFC> = new (...args: any[]) => LFC;
|
|
5
|
-
interface LajiFormComponentForVirtualSchemaField extends Omit<React.Component<FieldProps>, "render"> {
|
|
6
|
-
getStateFromProps?(propsWithInnerUiSchema: FieldProps, origProps: FieldProps): any;
|
|
7
|
-
render?(): React.ReactNode;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Virtual SchemaFields are components which are just state transforming machines.
|
|
11
|
-
*/
|
|
12
|
-
export default function VirtualSchemaField<LFC extends Constructor<LajiFormComponentForVirtualSchemaField>>(ComposedComponent: LFC): {
|
|
13
|
-
new (...args: any[]): {
|
|
14
|
-
getUiOptions(): any;
|
|
15
|
-
getStateFromProps: (props: FieldProps) => any;
|
|
16
|
-
render: () => React.ReactNode;
|
|
17
|
-
context: any;
|
|
18
|
-
readonly props: Readonly<FieldProps> & Readonly<{
|
|
19
|
-
children?: React.ReactNode;
|
|
20
|
-
}>;
|
|
21
|
-
state: Readonly<{}>;
|
|
22
|
-
componentDidMount?: (() => void) | undefined;
|
|
23
|
-
setState: <K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<FieldProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined) => void;
|
|
24
|
-
forceUpdate: (callback?: (() => void) | undefined) => void;
|
|
25
|
-
refs: {
|
|
26
|
-
[key: string]: React.ReactInstance;
|
|
27
|
-
};
|
|
28
|
-
shouldComponentUpdate?: ((nextProps: Readonly<FieldProps>, nextState: Readonly<{}>, nextContext: any) => boolean) | undefined;
|
|
29
|
-
componentWillUnmount?: (() => void) | undefined;
|
|
30
|
-
componentDidCatch?: ((error: Error, errorInfo: React.ErrorInfo) => void) | undefined;
|
|
31
|
-
getSnapshotBeforeUpdate?: ((prevProps: Readonly<FieldProps>, prevState: Readonly<{}>) => any) | undefined;
|
|
32
|
-
componentDidUpdate?: ((prevProps: Readonly<FieldProps>, prevState: Readonly<{}>, snapshot?: any) => void) | undefined;
|
|
33
|
-
componentWillMount?: (() => void) | undefined;
|
|
34
|
-
UNSAFE_componentWillMount?: (() => void) | undefined;
|
|
35
|
-
componentWillReceiveProps?: ((nextProps: Readonly<FieldProps>, nextContext: any) => void) | undefined;
|
|
36
|
-
UNSAFE_componentWillReceiveProps?: ((nextProps: Readonly<FieldProps>, nextContext: any) => void) | undefined;
|
|
37
|
-
componentWillUpdate?: ((nextProps: Readonly<FieldProps>, nextState: Readonly<{}>, nextContext: any) => void) | undefined;
|
|
38
|
-
UNSAFE_componentWillUpdate?: ((nextProps: Readonly<FieldProps>, nextState: Readonly<{}>, nextContext: any) => void) | undefined;
|
|
39
|
-
};
|
|
40
|
-
displayName: string;
|
|
41
|
-
} & LFC;
|
|
42
|
-
export {};
|