@luomus/laji-form 15.0.0 → 15.1.1
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/dist/styles.css +81 -90
- package/jsonconfig.json +26 -0
- package/migrate.sh +0 -1
- package/package.json +8 -8
- 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 +150 -176
- package/test-export/test-utils.js +218 -210
- 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.test.json +1 -1
- 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.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
- /package/{lib/styles.d.ts → test-export/array-spec.d.ts} +0 -0
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
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
|
-
const functionPropType = PropTypes.shape({
|
|
14
|
-
"ui:field": PropTypes.string.isRequired,
|
|
15
|
-
"ui:options": PropTypes.object
|
|
16
|
-
});
|
|
17
|
-
let UiFieldApplierField = class UiFieldApplierField extends React.Component {
|
|
18
|
-
constructor(props) {
|
|
19
|
-
super(props);
|
|
20
|
-
this.getFunctions = () => {
|
|
21
|
-
let { functions } = this.getUiOptions();
|
|
22
|
-
if (!Array.isArray(functions)) {
|
|
23
|
-
functions = [functions];
|
|
24
|
-
}
|
|
25
|
-
return functions;
|
|
26
|
-
};
|
|
27
|
-
this.onChange = (formData) => {
|
|
28
|
-
const { field } = this.getUiOptions();
|
|
29
|
-
this.onChangeFormData = formData;
|
|
30
|
-
this.functions[this.functions.length - 1].fn.onChange(utils_1.parseJSONPointer(formData, field));
|
|
31
|
-
};
|
|
32
|
-
this.functions = [];
|
|
33
|
-
}
|
|
34
|
-
static getName() { return "UiFieldApplierField"; }
|
|
35
|
-
getStateFromProps(props) {
|
|
36
|
-
if (this.functions.length !== this.getFunctions().length) {
|
|
37
|
-
this.functions = this.functions.slice(0, this.getFunctions().length);
|
|
38
|
-
}
|
|
39
|
-
let { field } = this.getUiOptions();
|
|
40
|
-
const state = this.getFunctions().reduce((props, options, idx) => {
|
|
41
|
-
let { "ui:field": uiField, "ui:options": uiOptions } = options;
|
|
42
|
-
const uiSchemaForField = utils_1.parseJSONPointer(props.uiSchema, utils_1.uiSchemaJSONPointer(props.schema, field));
|
|
43
|
-
const propsForField = {
|
|
44
|
-
schema: utils_1.parseJSONPointer(props.schema, utils_1.schemaJSONPointer(props.schema, field)),
|
|
45
|
-
uiSchema: Object.assign(Object.assign({}, uiSchemaForField), { "ui:options": Object.assign(Object.assign({}, utils_1.getUiOptions(uiSchemaForField)), uiOptions) }),
|
|
46
|
-
formData: utils_1.parseJSONPointer(props.formData, field, !!"safe"),
|
|
47
|
-
idSchema: utils_1.parseJSONPointer(props.idSchema, field),
|
|
48
|
-
errorSchema: utils_1.parseJSONPointer(props.errorSchema, field, !!"safe") || {},
|
|
49
|
-
registry: props.registry,
|
|
50
|
-
formContext: props.formContext,
|
|
51
|
-
onChange: this.functions[idx] && this.functions[idx].uiField === uiField
|
|
52
|
-
? this.functions[idx].fn.props.onChange
|
|
53
|
-
: (formData) => {
|
|
54
|
-
idx === 0
|
|
55
|
-
? this.combinedOnChange(formData)
|
|
56
|
-
: this.functions[idx - 1].fn.onChange(formData);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
let fn, state;
|
|
60
|
-
if (this.functions[idx] && this.functions[idx].uiField === uiField) {
|
|
61
|
-
fn = this.functions[idx].fn;
|
|
62
|
-
state = fn.getStateFromProps(propsForField);
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
fn = new props.registry.fields[uiField](propsForField);
|
|
66
|
-
this.functions[idx] = { uiField, fn };
|
|
67
|
-
state = fn.state || {};
|
|
68
|
-
}
|
|
69
|
-
let computedProps = {};
|
|
70
|
-
if ("schema" in state) {
|
|
71
|
-
computedProps.schema = utils_1.updateSafelyWithJSONPointer(props.schema, state.schema, utils_1.schemaJSONPointer(props.schema, field));
|
|
72
|
-
}
|
|
73
|
-
if ("uiSchema" in state) {
|
|
74
|
-
computedProps.uiSchema = utils_1.updateSafelyWithJSONPointer(props.uiSchema, state.uiSchema, utils_1.uiSchemaJSONPointer(props.schema, field));
|
|
75
|
-
}
|
|
76
|
-
["formData", "idSchema", "errorSchema"].forEach(prop => {
|
|
77
|
-
if (prop in state) {
|
|
78
|
-
computedProps[prop] = utils_1.updateSafelyWithJSONPointer(props[prop] || {}, state[prop], field);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
return Object.assign(Object.assign({}, props), computedProps);
|
|
82
|
-
}, props);
|
|
83
|
-
state.onChange = this.onChange;
|
|
84
|
-
return state;
|
|
85
|
-
}
|
|
86
|
-
combinedOnChange(formData) {
|
|
87
|
-
const { field } = this.getUiOptions();
|
|
88
|
-
this.props.onChange(utils_1.updateSafelyWithJSONPointer(this.onChangeFormData, formData, field));
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
UiFieldApplierField.propTypes = {
|
|
92
|
-
schema: PropTypes.shape({
|
|
93
|
-
type: PropTypes.oneOf(["object"])
|
|
94
|
-
}).isRequired,
|
|
95
|
-
uiSchema: PropTypes.shape({
|
|
96
|
-
"ui:options": PropTypes.shape({
|
|
97
|
-
field: PropTypes.string,
|
|
98
|
-
functions: PropTypes.oneOfType([functionPropType, PropTypes.arrayOf(functionPropType)])
|
|
99
|
-
})
|
|
100
|
-
}),
|
|
101
|
-
formData: PropTypes.object
|
|
102
|
-
};
|
|
103
|
-
UiFieldApplierField = __decorate([
|
|
104
|
-
VirtualSchemaField_1.default
|
|
105
|
-
], UiFieldApplierField);
|
|
106
|
-
exports.default = UiFieldApplierField;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export default class UiFieldMapperArrayField extends React.Component<any, any, any> {
|
|
2
|
-
static propTypes: {
|
|
3
|
-
uiSchema: PropTypes.Validator<PropTypes.InferProps<{
|
|
4
|
-
"ui:options": PropTypes.Requireable<PropTypes.InferProps<{
|
|
5
|
-
functions: PropTypes.Requireable<PropTypes.InferProps<{
|
|
6
|
-
"ui:field": PropTypes.Validator<string>;
|
|
7
|
-
"ui:options": PropTypes.Requireable<object>;
|
|
8
|
-
}> | (PropTypes.InferProps<{
|
|
9
|
-
"ui:field": PropTypes.Validator<string>;
|
|
10
|
-
"ui:options": PropTypes.Requireable<object>;
|
|
11
|
-
}> | null | undefined)[]>;
|
|
12
|
-
}>>;
|
|
13
|
-
uiSchema: PropTypes.Requireable<object>;
|
|
14
|
-
}>>;
|
|
15
|
-
schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
16
|
-
type: PropTypes.Requireable<string>;
|
|
17
|
-
}>>;
|
|
18
|
-
formData: PropTypes.Requireable<any[]>;
|
|
19
|
-
};
|
|
20
|
-
static getName(): string;
|
|
21
|
-
constructor(props: any);
|
|
22
|
-
childProps: any[];
|
|
23
|
-
functionOutputProps: any[];
|
|
24
|
-
updateChildProps: (props: any) => void;
|
|
25
|
-
getFieldPropsForIdx: (props: any, idx: any) => any;
|
|
26
|
-
tmpItemFormData: any;
|
|
27
|
-
applyFunctionsToChildProps: (props: any, childProps: any) => any;
|
|
28
|
-
getFunctionOutputForIdx: (props: any, idx: any) => any;
|
|
29
|
-
getStateFromProps(props: any, origProps: any): {
|
|
30
|
-
schema: any;
|
|
31
|
-
uiSchema: any;
|
|
32
|
-
formData: any;
|
|
33
|
-
idSchema: any;
|
|
34
|
-
errorSchema: any;
|
|
35
|
-
formContext: any;
|
|
36
|
-
registry: any;
|
|
37
|
-
onChange: (formData: any) => void;
|
|
38
|
-
};
|
|
39
|
-
onChange: (formData: any) => void;
|
|
40
|
-
}
|
|
41
|
-
import * as React from "react";
|
|
42
|
-
import * as PropTypes from "prop-types";
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
9
|
-
var t = {};
|
|
10
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
11
|
-
t[p] = s[p];
|
|
12
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
13
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
14
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
15
|
-
t[p[i]] = s[p[i]];
|
|
16
|
-
}
|
|
17
|
-
return t;
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
const React = require("react");
|
|
21
|
-
const PropTypes = require("prop-types");
|
|
22
|
-
const utils_1 = require("@rjsf/utils");
|
|
23
|
-
const utils_2 = require("../../utils");
|
|
24
|
-
const VirtualSchemaField_1 = require("../VirtualSchemaField");
|
|
25
|
-
const functionPropType = PropTypes.shape({
|
|
26
|
-
"ui:field": PropTypes.string.isRequired,
|
|
27
|
-
"ui:options": PropTypes.object
|
|
28
|
-
});
|
|
29
|
-
let UiFieldMapperArrayField = class UiFieldMapperArrayField extends React.Component {
|
|
30
|
-
constructor(props) {
|
|
31
|
-
super(props);
|
|
32
|
-
this.updateChildProps = (props) => {
|
|
33
|
-
(props.formData || []).forEach((item, idx) => {
|
|
34
|
-
const currentFieldProps = this.childProps[idx];
|
|
35
|
-
const nextFieldProps = this.getFieldPropsForIdx(props, idx);
|
|
36
|
-
if (!utils_1.deepEquals([currentFieldProps, nextFieldProps])) {
|
|
37
|
-
this.functionOutputProps[idx] = this.applyFunctionsToChildProps(props, nextFieldProps);
|
|
38
|
-
this.childProps[idx] = nextFieldProps;
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
this.getFieldPropsForIdx = (props, idx) => {
|
|
43
|
-
return Object.assign(Object.assign({}, props), { schema: props.schema.items, uiSchema: (props.uiSchema.uiSchema || props.uiSchema).items, idSchema: props.idSchema, formData: (props.formData || [])[idx], errorSchema: (props.errorSchema || {})[idx] || {}, onChange: formData => {
|
|
44
|
-
this.tmpItemFormData = formData;
|
|
45
|
-
} });
|
|
46
|
-
};
|
|
47
|
-
this.applyFunctionsToChildProps = (props, childProps) => {
|
|
48
|
-
let { functions } = utils_2.getUiOptions(props.uiSchema);
|
|
49
|
-
return ((Array.isArray(functions)) ? functions : [functions]).reduce((_props, { "ui:field": uiField, "ui:options": uiOptions }) => {
|
|
50
|
-
const _a = _props.uiSchema || {}, { "ui:functions": uiFunctions, uiSchema, "ui:field": origUiField, "ui:options": origUiOptions, "ui:settings": origUiSettings } = _a, _propsUiSchema = __rest(_a, ["ui:functions", "uiSchema", "ui:field", "ui:options", "ui:settings"]);
|
|
51
|
-
_props = Object.assign(Object.assign({}, _props), { uiSchema: Object.assign(Object.assign({}, _propsUiSchema), { "ui:field": uiField, "ui:options": uiOptions }) });
|
|
52
|
-
const { state = {} } = new props.registry.fields[uiField](_props);
|
|
53
|
-
return Object.assign(Object.assign(Object.assign({}, _props), state), { uiSchema: Object.assign(Object.assign(Object.assign({}, _props.uiSchema), state.uiSchema), { "ui:functions": uiFunctions, "ui:field": origUiField, "ui:options": origUiOptions, "ui:settings": origUiSettings, uiSchema }) });
|
|
54
|
-
}, childProps);
|
|
55
|
-
};
|
|
56
|
-
this.getFunctionOutputForIdx = (props, idx) => {
|
|
57
|
-
return this.applyFunctionsToChildProps(props, this.getFieldPropsForIdx(props, idx));
|
|
58
|
-
};
|
|
59
|
-
this.onChange = (formData) => {
|
|
60
|
-
this.props.onChange(formData.map((item, idx) => {
|
|
61
|
-
if (!utils_1.deepEquals(item, (this.props.formData || [])[idx])) {
|
|
62
|
-
const output = this.functionOutputProps[idx] || this.getFunctionOutputForIdx(this.props, idx);
|
|
63
|
-
output.onChange(item); // Will trigger child instance onChange, which will set this.tmpItemFormData.
|
|
64
|
-
return this.tmpItemFormData;
|
|
65
|
-
}
|
|
66
|
-
return item;
|
|
67
|
-
}));
|
|
68
|
-
};
|
|
69
|
-
this.childProps = [];
|
|
70
|
-
this.functionOutputProps = [];
|
|
71
|
-
this.updateChildProps(props);
|
|
72
|
-
}
|
|
73
|
-
static getName() { return "UiFieldMapperArrayField"; }
|
|
74
|
-
UNSAFE_componentWillReceiveProps(props) {
|
|
75
|
-
this.updateChildProps(props);
|
|
76
|
-
this.setState(this.getStateFromProps(props));
|
|
77
|
-
}
|
|
78
|
-
getStateFromProps(props, origProps) {
|
|
79
|
-
const templateOutput = this.functionOutputProps && this.functionOutputProps.length ?
|
|
80
|
-
this.functionOutputProps[0] :
|
|
81
|
-
this.getFunctionOutputForIdx(origProps, undefined);
|
|
82
|
-
const addBaseErrors = (errorSchema) => (props.errorSchema || {}).__errors
|
|
83
|
-
? Object.assign(Object.assign({}, errorSchema), { __errors: props.errorSchema.__errors }) : errorSchema;
|
|
84
|
-
const schema = Object.assign(Object.assign({}, props.schema), { items: templateOutput.schema });
|
|
85
|
-
const state = {
|
|
86
|
-
schema,
|
|
87
|
-
uiSchema: Object.assign(Object.assign({}, props.uiSchema), { items: Object.assign(Object.assign({}, props.uiSchema.items), templateOutput.uiSchema) }),
|
|
88
|
-
formData: (props.formData || []).map((item, idx) => this.functionOutputProps[idx].formData),
|
|
89
|
-
idSchema: templateOutput.idSchema,
|
|
90
|
-
errorSchema: addBaseErrors(Object.keys((props.errorSchema || {})).reduce((errorSchema, idx) => {
|
|
91
|
-
if (!this.functionOutputProps[idx])
|
|
92
|
-
return errorSchema;
|
|
93
|
-
errorSchema[idx] = this.functionOutputProps[idx].errorSchema;
|
|
94
|
-
return errorSchema;
|
|
95
|
-
}, {})),
|
|
96
|
-
formContext: templateOutput.formContext,
|
|
97
|
-
registry: templateOutput.registry,
|
|
98
|
-
onChange: this.onChange
|
|
99
|
-
};
|
|
100
|
-
return state;
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
UiFieldMapperArrayField.propTypes = {
|
|
104
|
-
uiSchema: PropTypes.shape({
|
|
105
|
-
"ui:options": PropTypes.shape({
|
|
106
|
-
functions: PropTypes.oneOfType([
|
|
107
|
-
PropTypes.arrayOf(functionPropType),
|
|
108
|
-
functionPropType
|
|
109
|
-
])
|
|
110
|
-
}),
|
|
111
|
-
uiSchema: PropTypes.object
|
|
112
|
-
}).isRequired,
|
|
113
|
-
schema: PropTypes.shape({
|
|
114
|
-
type: PropTypes.oneOf(["array"])
|
|
115
|
-
}).isRequired,
|
|
116
|
-
formData: PropTypes.array
|
|
117
|
-
};
|
|
118
|
-
UiFieldMapperArrayField = __decorate([
|
|
119
|
-
VirtualSchemaField_1.default
|
|
120
|
-
], UiFieldMapperArrayField);
|
|
121
|
-
exports.default = UiFieldMapperArrayField;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export default class UnitCountShorthandField extends React.Component<any, any, any> {
|
|
2
|
-
static propTypes: {
|
|
3
|
-
uiSchema: PropTypes.Validator<PropTypes.InferProps<{
|
|
4
|
-
"ui:options": PropTypes.Validator<PropTypes.InferProps<{
|
|
5
|
-
shorthandField: PropTypes.Validator<string>;
|
|
6
|
-
pairCountField: PropTypes.Validator<string>;
|
|
7
|
-
taxonIDField: PropTypes.Validator<string>;
|
|
8
|
-
}>>;
|
|
9
|
-
}>>;
|
|
10
|
-
schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
11
|
-
type: PropTypes.Requireable<string>;
|
|
12
|
-
}>>;
|
|
13
|
-
formData: PropTypes.Validator<object>;
|
|
14
|
-
};
|
|
15
|
-
static getName(): string;
|
|
16
|
-
constructor(props: any);
|
|
17
|
-
parseCode(value: any, taxonId: any): Promise<any>;
|
|
18
|
-
getStateFromProps(props: any): any;
|
|
19
|
-
promiseTimestamp: number | undefined;
|
|
20
|
-
}
|
|
21
|
-
import * as React from "react";
|
|
22
|
-
import * as PropTypes from "prop-types";
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
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 BaseComponent_1 = require("../BaseComponent");
|
|
14
|
-
const components_1 = require("../components");
|
|
15
|
-
const merge = require("deepmerge");
|
|
16
|
-
const ReactContext_1 = require("../../ReactContext");
|
|
17
|
-
let UnitCountShorthandField = class UnitCountShorthandField extends React.Component {
|
|
18
|
-
constructor(props) {
|
|
19
|
-
super(props);
|
|
20
|
-
this.parseCode = this.parseCode.bind(this);
|
|
21
|
-
}
|
|
22
|
-
static getName() { return "UnitCountShorthandField"; }
|
|
23
|
-
getStateFromProps(props) {
|
|
24
|
-
const { uiSchema, formData } = props;
|
|
25
|
-
const { shorthandField, taxonIDField } = utils_1.getUiOptions(props.uiSchema);
|
|
26
|
-
const shortHandUiSchema = merge(utils_1.parseJSONPointer(props.uiSchema, shorthandField) || {}, {
|
|
27
|
-
"ui:widget": CodeReader,
|
|
28
|
-
"ui:options": {
|
|
29
|
-
parseCode: this.parseCode,
|
|
30
|
-
taxonID: utils_1.parseJSONPointer(formData, taxonIDField)
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
const _uiSchema = utils_1.updateSafelyWithJSONPointer(uiSchema, shortHandUiSchema, shorthandField);
|
|
34
|
-
return Object.assign(Object.assign({}, props), { uiSchema: _uiSchema });
|
|
35
|
-
}
|
|
36
|
-
parseCode(value, taxonId) {
|
|
37
|
-
const { apiClient } = this.props.formContext;
|
|
38
|
-
let formData = this.props.formData;
|
|
39
|
-
const { shorthandField, pairCountField } = utils_1.getUiOptions(this.props.uiSchema);
|
|
40
|
-
let timestamp = Date.now();
|
|
41
|
-
this.promiseTimestamp = timestamp;
|
|
42
|
-
return new Promise((resolve, reject) => {
|
|
43
|
-
if (!value || !taxonId) {
|
|
44
|
-
formData = utils_1.updateSafelyWithJSONPointer(formData, undefined, pairCountField);
|
|
45
|
-
this.props.onChange(formData);
|
|
46
|
-
resolve({ success: undefined });
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
apiClient.fetchCached("/autocomplete/pairCount", { q: value, taxonID: taxonId }).then(suggestion => {
|
|
50
|
-
if (timestamp !== this.promiseTimestamp) {
|
|
51
|
-
reject();
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
formData = utils_1.updateSafelyWithJSONPointer(formData, suggestion.key, shorthandField);
|
|
55
|
-
formData = utils_1.updateSafelyWithJSONPointer(formData, suggestion.value, pairCountField);
|
|
56
|
-
this.props.onChange(formData);
|
|
57
|
-
resolve({ success: suggestion.key ? true : undefined, value: suggestion.key });
|
|
58
|
-
}).catch(() => {
|
|
59
|
-
if (timestamp !== this.promiseTimestamp) {
|
|
60
|
-
reject();
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
formData = utils_1.updateSafelyWithJSONPointer(formData, undefined, pairCountField);
|
|
64
|
-
this.props.onChange(formData);
|
|
65
|
-
resolve({ success: false, value: value });
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
UnitCountShorthandField.propTypes = {
|
|
71
|
-
uiSchema: PropTypes.shape({
|
|
72
|
-
"ui:options": PropTypes.shape({
|
|
73
|
-
shorthandField: PropTypes.string.isRequired,
|
|
74
|
-
pairCountField: PropTypes.string.isRequired,
|
|
75
|
-
taxonIDField: PropTypes.string.isRequired
|
|
76
|
-
}).isRequired
|
|
77
|
-
}).isRequired,
|
|
78
|
-
schema: PropTypes.shape({
|
|
79
|
-
type: PropTypes.oneOf(["object"])
|
|
80
|
-
}).isRequired,
|
|
81
|
-
formData: PropTypes.object.isRequired
|
|
82
|
-
};
|
|
83
|
-
UnitCountShorthandField = __decorate([
|
|
84
|
-
VirtualSchemaField_1.default
|
|
85
|
-
], UnitCountShorthandField);
|
|
86
|
-
exports.default = UnitCountShorthandField;
|
|
87
|
-
let CodeReader = class CodeReader extends React.Component {
|
|
88
|
-
constructor(props) {
|
|
89
|
-
super(props);
|
|
90
|
-
this.onChange = ({ target: { value } }) => {
|
|
91
|
-
this.props.onChange(value);
|
|
92
|
-
};
|
|
93
|
-
this.onKeyDown = (e) => {
|
|
94
|
-
if (e.key === "Enter") {
|
|
95
|
-
this.onBlur();
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
this.state = { loading: false };
|
|
99
|
-
this.onBlur = this.onBlur.bind(this);
|
|
100
|
-
}
|
|
101
|
-
componentDidUpdate(prevProps) {
|
|
102
|
-
if (prevProps.options.taxonID !== this.props.options.taxonID) {
|
|
103
|
-
this.onBlur();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
render() {
|
|
107
|
-
let validationState = null;
|
|
108
|
-
if (this.state.success === false) {
|
|
109
|
-
validationState = "error";
|
|
110
|
-
}
|
|
111
|
-
else if (this.state.success) {
|
|
112
|
-
validationState = "success";
|
|
113
|
-
}
|
|
114
|
-
const { formContext } = this.props;
|
|
115
|
-
const { translations } = formContext;
|
|
116
|
-
const inputElem = (React.createElement(components_1.FetcherInput, { id: this.props.id, loading: this.state.loading, value: this.props.value || "", validationState: validationState, onBlur: this.onBlur, onKeyDown: this.onKeyDown, onChange: this.onChange }));
|
|
117
|
-
const { FormGroup, HelpBlock } = this.context.theme;
|
|
118
|
-
return (React.createElement(FormGroup, { validationState: this.state.success === false ? "error" : undefined },
|
|
119
|
-
inputElem,
|
|
120
|
-
this.state.success === false ? (React.createElement(HelpBlock, null, translations.InvalidUnitCode)) : null,
|
|
121
|
-
React.createElement("div", { className: "small text-muted", dangerouslySetInnerHTML: { __html: this.props.help } })));
|
|
122
|
-
}
|
|
123
|
-
onBlur() {
|
|
124
|
-
const { value, options } = this.props;
|
|
125
|
-
const { parseCode, taxonID } = options;
|
|
126
|
-
if (!(value === this.state.value && taxonID === this.state.taxonID)) {
|
|
127
|
-
this.setState({ value, taxonID, loading: true, success: undefined });
|
|
128
|
-
this.props.formContext.services.submitHooks.add(this.props, () => {
|
|
129
|
-
return parseCode(value, taxonID).then((result) => {
|
|
130
|
-
this.setState({ loading: false, success: result.success, value: result.value });
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
CodeReader.contextType = ReactContext_1.default;
|
|
137
|
-
CodeReader.propTypes = {
|
|
138
|
-
options: PropTypes.shape({
|
|
139
|
-
parseCode: PropTypes.func.isRequired,
|
|
140
|
-
taxonID: PropTypes.string
|
|
141
|
-
}).isRequired,
|
|
142
|
-
schema: PropTypes.shape({
|
|
143
|
-
type: PropTypes.oneOf(["string"])
|
|
144
|
-
}),
|
|
145
|
-
value: PropTypes.string
|
|
146
|
-
};
|
|
147
|
-
CodeReader = __decorate([
|
|
148
|
-
BaseComponent_1.default
|
|
149
|
-
], CodeReader);
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compatible only with unit array.
|
|
3
|
-
*/
|
|
4
|
-
export default class UnitListShorthandArrayField extends React.Component<any, any, any> {
|
|
5
|
-
static contextType: React.Context<import("../../ReactContext").ContextProps>;
|
|
6
|
-
static propTypes: {
|
|
7
|
-
schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
8
|
-
type: PropTypes.Requireable<string>;
|
|
9
|
-
}>>;
|
|
10
|
-
formData: PropTypes.Validator<any[]>;
|
|
11
|
-
};
|
|
12
|
-
constructor(props: any);
|
|
13
|
-
constructor(props: any, context: any);
|
|
14
|
-
getStateFromProps(props: any): {
|
|
15
|
-
uiSchema: any;
|
|
16
|
-
};
|
|
17
|
-
onButtonClick: () => () => void;
|
|
18
|
-
onHide: () => void;
|
|
19
|
-
onTagFieldChange: (tags: any) => void;
|
|
20
|
-
onSubmit: () => void;
|
|
21
|
-
onKeyDown: (e: any) => void;
|
|
22
|
-
setTagArrayRef: (ref: any) => void;
|
|
23
|
-
tagRef: any;
|
|
24
|
-
}
|
|
25
|
-
import * as React from "react";
|
|
26
|
-
import * as PropTypes from "prop-types";
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
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 components_1 = require("../components");
|
|
14
|
-
const ReactContext_1 = require("../../ReactContext");
|
|
15
|
-
const TagArrayField_1 = require("./TagArrayField");
|
|
16
|
-
/**
|
|
17
|
-
* Compatible only with unit array.
|
|
18
|
-
*/
|
|
19
|
-
let UnitListShorthandArrayField = class UnitListShorthandArrayField extends React.Component {
|
|
20
|
-
constructor() {
|
|
21
|
-
super(...arguments);
|
|
22
|
-
this.onButtonClick = () => () => {
|
|
23
|
-
this.setState({ show: !this.state.show });
|
|
24
|
-
};
|
|
25
|
-
this.onHide = () => {
|
|
26
|
-
this.setState({ show: false, value: "" });
|
|
27
|
-
};
|
|
28
|
-
this.onTagFieldChange = (tags) => {
|
|
29
|
-
this.setState({ value: tags.join(",") });
|
|
30
|
-
};
|
|
31
|
-
this.onSubmit = () => {
|
|
32
|
-
const value = this.state.value + (utils_1.isEmptyString(this.tagRef.state.value) ? "" : `,${this.tagRef.state.value}`);
|
|
33
|
-
this.onHide();
|
|
34
|
-
const { translations, notifier, apiClient } = this.props.formContext;
|
|
35
|
-
this.props.formContext.services.blocker.push();
|
|
36
|
-
apiClient.fetch("/autocomplete/unit", { q: value, list: true, includePayload: true }).then(({ payload: { units, nonMatchingCount } }) => {
|
|
37
|
-
units = units.map(unit => {
|
|
38
|
-
unit = utils_1.getDefaultFormState(this.props.schema.items, unit);
|
|
39
|
-
unit = utils_1.bringRemoteFormData(unit, this.props.formContext);
|
|
40
|
-
unit = utils_1.assignUUID(unit);
|
|
41
|
-
return unit;
|
|
42
|
-
});
|
|
43
|
-
const formData = this.props.formData;
|
|
44
|
-
const last = formData[formData.length - 1];
|
|
45
|
-
if (last && utils_1.isDefaultData(last, this.props.schema.items)) {
|
|
46
|
-
formData.pop();
|
|
47
|
-
}
|
|
48
|
-
this.props.onChange([...formData, ...units]);
|
|
49
|
-
nonMatchingCount
|
|
50
|
-
? notifier.warning(`${translations.UnitListShorthandWarning} ${nonMatchingCount}`)
|
|
51
|
-
: notifier.success(translations.UnitListShorthandSuccess);
|
|
52
|
-
this.props.formContext.services.blocker.pop();
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
this.onKeyDown = (e) => {
|
|
56
|
-
if (e.key === "Enter") {
|
|
57
|
-
this.onSubmit(e);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
this.setTagArrayRef = (ref) => {
|
|
61
|
-
this.tagRef = ref;
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
getStateFromProps(props) {
|
|
65
|
-
const buttonDefinition = {
|
|
66
|
-
fn: this.onButtonClick,
|
|
67
|
-
fnName: "addUnitList",
|
|
68
|
-
glyph: "align-justify",
|
|
69
|
-
label: this.props.formContext.translations.AddUnitList,
|
|
70
|
-
id: this.props.idSchema.$id,
|
|
71
|
-
changesFormData: true,
|
|
72
|
-
rules: {
|
|
73
|
-
canAdd: true
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
const innerUiSchema = utils_1.getInnerUiSchema(props.uiSchema);
|
|
77
|
-
const options = utils_1.getUiOptions(innerUiSchema);
|
|
78
|
-
const uiSchema = Object.assign(Object.assign({}, innerUiSchema), { "ui:options": Object.assign(Object.assign({}, options), { buttons: [
|
|
79
|
-
...(options.buttons || []),
|
|
80
|
-
buttonDefinition
|
|
81
|
-
] }) });
|
|
82
|
-
return { uiSchema };
|
|
83
|
-
}
|
|
84
|
-
render() {
|
|
85
|
-
const { SchemaField } = this.props.registry.fields;
|
|
86
|
-
const { Modal } = this.context.theme;
|
|
87
|
-
return (React.createElement(React.Fragment, null,
|
|
88
|
-
React.createElement(SchemaField, Object.assign({}, this.props, { uiSchema: this.state.uiSchema })),
|
|
89
|
-
this.state.show && (React.createElement(Modal, { show: true, onHide: this.onHide, dialogClassName: "unit-list-shorthand-modal" },
|
|
90
|
-
React.createElement(Modal.Body, null,
|
|
91
|
-
React.createElement(TagArrayField_1.TagInputComponent, { tags: utils_1.isEmptyString(this.state.value) ? [] : this.state.value.split(",").filter(s => !utils_1.isEmptyString(s)), onChange: this.onTagFieldChange, schema: {}, idSchema: {}, uiSchema: { "ui:options": { separatorKeys: [","] } }, inputProps: { autoFocus: true }, onKeyDown: this.onKeyDown, ref: this.setTagArrayRef, formContext: this.props.formContext }),
|
|
92
|
-
React.createElement("span", { className: "text-muted" },
|
|
93
|
-
React.createElement("i", null, this.props.formContext.translations.UnitListShorthandHelp)),
|
|
94
|
-
React.createElement("br", null),
|
|
95
|
-
React.createElement(components_1.Button, { type: "submit", disabled: utils_1.isEmptyString(this.state.value), onClick: this.onSubmit }, this.props.formContext.translations.Add))))));
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
UnitListShorthandArrayField.contextType = ReactContext_1.default;
|
|
99
|
-
UnitListShorthandArrayField.propTypes = {
|
|
100
|
-
schema: PropTypes.shape({
|
|
101
|
-
type: PropTypes.oneOf(["array"])
|
|
102
|
-
}).isRequired,
|
|
103
|
-
formData: PropTypes.array.isRequired
|
|
104
|
-
};
|
|
105
|
-
UnitListShorthandArrayField = __decorate([
|
|
106
|
-
BaseComponent_1.default
|
|
107
|
-
], UnitListShorthandArrayField);
|
|
108
|
-
exports.default = UnitListShorthandArrayField;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export default class UnitShorthandField extends React.Component<any, any, any> {
|
|
2
|
-
static propTypes: {
|
|
3
|
-
uiSchema: PropTypes.Requireable<PropTypes.InferProps<{
|
|
4
|
-
"ui:options": PropTypes.Validator<PropTypes.InferProps<{
|
|
5
|
-
shorthandField: PropTypes.Requireable<string>;
|
|
6
|
-
formID: PropTypes.Requireable<string>;
|
|
7
|
-
showSchema: PropTypes.Requireable<boolean>;
|
|
8
|
-
persistenceKey: PropTypes.Requireable<string>;
|
|
9
|
-
}>>;
|
|
10
|
-
uiSchema: PropTypes.Requireable<object>;
|
|
11
|
-
}>>;
|
|
12
|
-
schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
13
|
-
type: PropTypes.Requireable<string>;
|
|
14
|
-
}>>;
|
|
15
|
-
formData: PropTypes.Validator<object>;
|
|
16
|
-
};
|
|
17
|
-
constructor(props: any);
|
|
18
|
-
getStateFromProps: (props: any) => any;
|
|
19
|
-
onNextTick: (() => void) | undefined;
|
|
20
|
-
shouldShowSchema: (props: any) => any;
|
|
21
|
-
onToggleButtonClick: () => () => void;
|
|
22
|
-
getToggleButton: () => {
|
|
23
|
-
glyph: string;
|
|
24
|
-
fn: () => () => void;
|
|
25
|
-
tooltip: any;
|
|
26
|
-
tooltipPlacement: string;
|
|
27
|
-
active: boolean;
|
|
28
|
-
};
|
|
29
|
-
onCodeChange: (formData?: {}) => void;
|
|
30
|
-
}
|
|
31
|
-
import * as React from "react";
|
|
32
|
-
import * as PropTypes from "prop-types";
|