@luomus/laji-form 14.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +215 -0
- package/LICENSE +21 -0
- package/README.md +180 -0
- package/cypress/fixtures/example.json +5 -0
- closes suggestion list (failed).png +0 -0
- is marked as suggested (failed).png +0 -0
- package/dist/images/finnish-flag.png +0 -0
- package/dist/images/handled.png +0 -0
- package/dist/images/heard.png +0 -0
- package/dist/images/indirect.png +0 -0
- package/dist/images/media.png +0 -0
- package/dist/images/seen.png +0 -0
- package/dist/images/specimen.png +0 -0
- package/dist/laji-form.js +2 -0
- package/dist/laji-form.js.LICENSE.txt +92 -0
- package/dist/styles.css +3771 -0
- package/lib/ApiClient.d.ts +46 -0
- package/lib/ApiClient.js +93 -0
- package/lib/Context.d.ts +8 -0
- package/lib/Context.js +18 -0
- package/lib/ReactContext.d.ts +7 -0
- package/lib/ReactContext.js +5 -0
- package/lib/components/BaseComponent.d.ts +9 -0
- package/lib/components/BaseComponent.js +29 -0
- package/lib/components/LajiForm.d.ts +221 -0
- package/lib/components/LajiForm.js +614 -0
- package/lib/components/VirtualSchemaField.d.ts +42 -0
- package/lib/components/VirtualSchemaField.js +74 -0
- package/lib/components/components.d.ts +119 -0
- package/lib/components/components.js +606 -0
- package/lib/components/fields/AnnotationField.d.ts +34 -0
- package/lib/components/fields/AnnotationField.js +242 -0
- package/lib/components/fields/AnyToBooleanField.d.ts +18 -0
- package/lib/components/fields/AnyToBooleanField.js +20 -0
- package/lib/components/fields/ArrayBulkField.d.ts +23 -0
- package/lib/components/fields/ArrayBulkField.js +82 -0
- package/lib/components/fields/ArrayCombinerField.d.ts +36 -0
- package/lib/components/fields/ArrayCombinerField.js +138 -0
- package/lib/components/fields/ArrayField.d.ts +39 -0
- package/lib/components/fields/ArrayField.js +148 -0
- package/lib/components/fields/AudioArrayField.d.ts +22 -0
- package/lib/components/fields/AudioArrayField.js +100 -0
- package/lib/components/fields/AutoArrayField.d.ts +24 -0
- package/lib/components/fields/AutoArrayField.js +56 -0
- package/lib/components/fields/AutosuggestField.d.ts +69 -0
- package/lib/components/fields/AutosuggestField.js +299 -0
- package/lib/components/fields/CombinedValueDisplayField.d.ts +41 -0
- package/lib/components/fields/CombinedValueDisplayField.js +100 -0
- package/lib/components/fields/ConditionalOnChangeField.d.ts +42 -0
- package/lib/components/fields/ConditionalOnChangeField.js +107 -0
- package/lib/components/fields/ConditionalUiSchemaField.d.ts +123 -0
- package/lib/components/fields/ConditionalUiSchemaField.js +143 -0
- package/lib/components/fields/ContextInjectionField.d.ts +24 -0
- package/lib/components/fields/ContextInjectionField.js +68 -0
- package/lib/components/fields/DataLeakerField.d.ts +40 -0
- package/lib/components/fields/DataLeakerField.js +68 -0
- package/lib/components/fields/DefaultValueArrayField.d.ts +34 -0
- package/lib/components/fields/DefaultValueArrayField.js +59 -0
- package/lib/components/fields/DependentBooleanField.d.ts +38 -0
- package/lib/components/fields/DependentBooleanField.js +87 -0
- package/lib/components/fields/DependentDisableField.d.ts +35 -0
- package/lib/components/fields/DependentDisableField.js +71 -0
- package/lib/components/fields/EnumRangeArrayField.d.ts +27 -0
- package/lib/components/fields/EnumRangeArrayField.js +115 -0
- package/lib/components/fields/ExtraLabelRowField.d.ts +38 -0
- package/lib/components/fields/ExtraLabelRowField.js +100 -0
- package/lib/components/fields/FakePropertyField.d.ts +18 -0
- package/lib/components/fields/FakePropertyField.js +48 -0
- package/lib/components/fields/FilterArrayField.d.ts +73 -0
- package/lib/components/fields/FilterArrayField.js +121 -0
- package/lib/components/fields/FlatField.d.ts +29 -0
- package/lib/components/fields/FlatField.js +171 -0
- package/lib/components/fields/GeocoderField.d.ts +47 -0
- package/lib/components/fields/GeocoderField.js +372 -0
- package/lib/components/fields/GridLayoutField.d.ts +18 -0
- package/lib/components/fields/GridLayoutField.js +32 -0
- package/lib/components/fields/HiddenField.d.ts +10 -0
- package/lib/components/fields/HiddenField.js +11 -0
- package/lib/components/fields/ImageArrayField.d.ts +153 -0
- package/lib/components/fields/ImageArrayField.js +696 -0
- package/lib/components/fields/ImageDisplayField.d.ts +18 -0
- package/lib/components/fields/ImageDisplayField.js +44 -0
- package/lib/components/fields/InitiallyHiddenField.d.ts +21 -0
- package/lib/components/fields/InitiallyHiddenField.js +58 -0
- package/lib/components/fields/InjectDefaultValueField.d.ts +37 -0
- package/lib/components/fields/InjectDefaultValueField.js +68 -0
- package/lib/components/fields/InjectField.d.ts +46 -0
- package/lib/components/fields/InjectField.js +88 -0
- package/lib/components/fields/InputWithDefaultValueButtonField.d.ts +25 -0
- package/lib/components/fields/InputWithDefaultValueButtonField.js +61 -0
- package/lib/components/fields/LocalityField.d.ts +22 -0
- package/lib/components/fields/LocalityField.js +94 -0
- package/lib/components/fields/LocationChooserField.d.ts +27 -0
- package/lib/components/fields/LocationChooserField.js +440 -0
- package/lib/components/fields/MapArrayField.d.ts +78 -0
- package/lib/components/fields/MapArrayField.js +1783 -0
- package/lib/components/fields/MapField.d.ts +48 -0
- package/lib/components/fields/MapField.js +434 -0
- package/lib/components/fields/MultiAnyToBooleanField.d.ts +25 -0
- package/lib/components/fields/MultiAnyToBooleanField.js +100 -0
- package/lib/components/fields/MultiArrayField.d.ts +53 -0
- package/lib/components/fields/MultiArrayField.js +224 -0
- package/lib/components/fields/MultiLanguageField.d.ts +13 -0
- package/lib/components/fields/MultiLanguageField.js +52 -0
- package/lib/components/fields/MultiTagArrayField.d.ts +36 -0
- package/lib/components/fields/MultiTagArrayField.js +142 -0
- package/lib/components/fields/NamedPlaceChooserField.d.ts +29 -0
- package/lib/components/fields/NamedPlaceChooserField.js +380 -0
- package/lib/components/fields/NamedPlaceSaverField.d.ts +29 -0
- package/lib/components/fields/NamedPlaceSaverField.js +237 -0
- package/lib/components/fields/NestField.d.ts +148 -0
- package/lib/components/fields/NestField.js +289 -0
- package/lib/components/fields/ObjectField.d.ts +2 -0
- package/lib/components/fields/ObjectField.js +119 -0
- package/lib/components/fields/PrefillingArrayField.d.ts +22 -0
- package/lib/components/fields/PrefillingArrayField.js +65 -0
- package/lib/components/fields/SchemaField.d.ts +7 -0
- package/lib/components/fields/SchemaField.js +109 -0
- package/lib/components/fields/ScopeField.d.ts +85 -0
- package/lib/components/fields/ScopeField.js +521 -0
- package/lib/components/fields/SectionArrayField.d.ts +38 -0
- package/lib/components/fields/SectionArrayField.js +614 -0
- package/lib/components/fields/SelectTreeField.d.ts +39 -0
- package/lib/components/fields/SelectTreeField.js +143 -0
- package/lib/components/fields/SingleActiveArrayField.d.ts +49 -0
- package/lib/components/fields/SingleActiveArrayField.js +974 -0
- package/lib/components/fields/SingleItemArrayField.d.ts +15 -0
- package/lib/components/fields/SingleItemArrayField.js +60 -0
- package/lib/components/fields/SortArrayField.d.ts +73 -0
- package/lib/components/fields/SortArrayField.js +351 -0
- package/lib/components/fields/SplitField.d.ts +28 -0
- package/lib/components/fields/SplitField.js +65 -0
- package/lib/components/fields/StringToArrayField.d.ts +24 -0
- package/lib/components/fields/StringToArrayField.js +48 -0
- package/lib/components/fields/SumField.d.ts +35 -0
- package/lib/components/fields/SumField.js +83 -0
- package/lib/components/fields/TableField.d.ts +18 -0
- package/lib/components/fields/TableField.js +136 -0
- package/lib/components/fields/TagArrayField.d.ts +38 -0
- package/lib/components/fields/TagArrayField.js +128 -0
- package/lib/components/fields/ToggleAdditionalArrayFieldsField.d.ts +26 -0
- package/lib/components/fields/ToggleAdditionalArrayFieldsField.js +81 -0
- package/lib/components/fields/UiFieldApplierField.d.ts +30 -0
- package/lib/components/fields/UiFieldApplierField.js +106 -0
- package/lib/components/fields/UiFieldMapperArrayField.d.ts +42 -0
- package/lib/components/fields/UiFieldMapperArrayField.js +121 -0
- package/lib/components/fields/UnitCountShorthandField.d.ts +22 -0
- package/lib/components/fields/UnitCountShorthandField.js +149 -0
- package/lib/components/fields/UnitListShorthandArrayField.d.ts +26 -0
- package/lib/components/fields/UnitListShorthandArrayField.js +108 -0
- package/lib/components/fields/UnitShorthandField.d.ts +32 -0
- package/lib/components/fields/UnitShorthandField.js +220 -0
- package/lib/components/templates/ArrayFieldTemplate.d.ts +85 -0
- package/lib/components/templates/ArrayFieldTemplate.js +416 -0
- package/lib/components/templates/BaseInputTemplate.d.ts +11 -0
- package/lib/components/templates/BaseInputTemplate.js +80 -0
- package/lib/components/templates/DescriptionField.d.ts +1 -0
- package/lib/components/templates/DescriptionField.js +37 -0
- package/lib/components/templates/ErrorListTemplate.d.ts +9 -0
- package/lib/components/templates/ErrorListTemplate.js +95 -0
- package/lib/components/templates/FieldTemplate.d.ts +6 -0
- package/lib/components/templates/FieldTemplate.js +112 -0
- package/lib/components/templates/ObjectFieldTemplate.d.ts +7 -0
- package/lib/components/templates/ObjectFieldTemplate.js +66 -0
- package/lib/components/templates/TitleField.d.ts +9 -0
- package/lib/components/templates/TitleField.js +51 -0
- package/lib/components/widgets/AnyToBooleanWidget.d.ts +20 -0
- package/lib/components/widgets/AnyToBooleanWidget.js +49 -0
- package/lib/components/widgets/AutosuggestWidget.d.ts +66 -0
- package/lib/components/widgets/AutosuggestWidget.js +1127 -0
- package/lib/components/widgets/CheckboxWidget.d.ts +37 -0
- package/lib/components/widgets/CheckboxWidget.js +139 -0
- package/lib/components/widgets/DateTimeWidget.d.ts +62 -0
- package/lib/components/widgets/DateTimeWidget.js +251 -0
- package/lib/components/widgets/DateWidget.d.ts +23 -0
- package/lib/components/widgets/DateWidget.js +41 -0
- package/lib/components/widgets/HiddenWidget.d.ts +15 -0
- package/lib/components/widgets/HiddenWidget.js +19 -0
- package/lib/components/widgets/ImageSelectWidget.d.ts +14 -0
- package/lib/components/widgets/ImageSelectWidget.js +57 -0
- package/lib/components/widgets/InformalTaxonGroupChooserWidget.d.ts +43 -0
- package/lib/components/widgets/InformalTaxonGroupChooserWidget.js +237 -0
- package/lib/components/widgets/InputGroupWidget.d.ts +21 -0
- package/lib/components/widgets/InputGroupWidget.js +36 -0
- package/lib/components/widgets/InputWithDefaultValueButtonWidget.d.ts +21 -0
- package/lib/components/widgets/InputWithDefaultValueButtonWidget.js +47 -0
- package/lib/components/widgets/NumberWidget.d.ts +13 -0
- package/lib/components/widgets/NumberWidget.js +21 -0
- package/lib/components/widgets/PlainTextWidget.d.ts +12 -0
- package/lib/components/widgets/PlainTextWidget.js +24 -0
- package/lib/components/widgets/SelectWidget.d.ts +52 -0
- package/lib/components/widgets/SelectWidget.js +158 -0
- package/lib/components/widgets/SeparatedDateTimeWidget.d.ts +19 -0
- package/lib/components/widgets/SeparatedDateTimeWidget.js +59 -0
- package/lib/components/widgets/TaxonImageWidget.d.ts +13 -0
- package/lib/components/widgets/TaxonImageWidget.js +30 -0
- package/lib/components/widgets/TextSelectWidget.d.ts +25 -0
- package/lib/components/widgets/TextSelectWidget.js +94 -0
- package/lib/components/widgets/TextareaWidget.d.ts +32 -0
- package/lib/components/widgets/TextareaWidget.js +87 -0
- package/lib/components/widgets/TimeWidget.d.ts +11 -0
- package/lib/components/widgets/TimeWidget.js +19 -0
- package/lib/components/widgets/URLWidget.d.ts +14 -0
- package/lib/components/widgets/URLWidget.js +12 -0
- package/lib/components/widgets/UpperCaseWidget.d.ts +13 -0
- package/lib/components/widgets/UpperCaseWidget.js +21 -0
- package/lib/index.d.ts +20 -0
- package/lib/index.js +50 -0
- package/lib/services/blocker-service.d.ts +11 -0
- package/lib/services/blocker-service.js +55 -0
- package/lib/services/custom-event-service.d.ts +17 -0
- package/lib/services/custom-event-service.js +35 -0
- package/lib/services/dom-id-service.d.ts +8 -0
- package/lib/services/dom-id-service.js +30 -0
- package/lib/services/focus-service.d.ts +13 -0
- package/lib/services/focus-service.js +60 -0
- package/lib/services/id-service.d.ts +22 -0
- package/lib/services/id-service.js +130 -0
- package/lib/services/key-handler-service.d.ts +56 -0
- package/lib/services/key-handler-service.js +184 -0
- package/lib/services/root-instance-service.d.ts +25 -0
- package/lib/services/root-instance-service.js +49 -0
- package/lib/services/settings-service.d.ts +34 -0
- package/lib/services/settings-service.js +154 -0
- package/lib/services/singleton-map-service.d.ts +23 -0
- package/lib/services/singleton-map-service.js +44 -0
- package/lib/services/submit-hook-service.d.ts +24 -0
- package/lib/services/submit-hook-service.js +73 -0
- package/lib/styles.d.ts +1 -0
- package/lib/styles.js +4 -0
- package/lib/themes/bs3.d.ts +3 -0
- package/lib/themes/bs3.js +133 -0
- package/lib/themes/bs5.d.ts +3 -0
- package/lib/themes/bs5.js +111 -0
- package/lib/themes/glyphicon-fa-mapping.d.ts +3 -0
- package/lib/themes/glyphicon-fa-mapping.js +271 -0
- package/lib/themes/stub.d.ts +3 -0
- package/lib/themes/stub.js +82 -0
- package/lib/themes/theme.d.ts +233 -0
- package/lib/themes/theme.js +2 -0
- package/lib/translations.json +842 -0
- package/lib/utils.d.ts +167 -0
- package/lib/utils.js +1191 -0
- package/lib/validation.d.ts +7 -0
- package/lib/validation.js +141 -0
- package/llol +10 -0
- package/llol.pdf +10 -0
- package/package.json +99 -0
- package/q +196 -0
- package/test-export/array-spec.d.ts +1 -0
- package/test-export/array-spec.js +204 -0
- package/test-export/bird-point-count-spec.d.ts +1 -0
- package/test-export/bird-point-count-spec.js +62 -0
- package/test-export/collection-contest-form-spec.d.ts +1 -0
- package/test-export/collection-contest-form-spec.js +38 -0
- package/test-export/dataset-form-spec.d.ts +1 -0
- package/test-export/dataset-form-spec.js +50 -0
- package/test-export/date-time-widget-spec.d.ts +1 -0
- package/test-export/date-time-widget-spec.js +188 -0
- package/test-export/geocoder-spec.d.ts +1 -0
- package/test-export/geocoder-spec.js +135 -0
- package/test-export/image-array-spec.d.ts +1 -0
- package/test-export/image-array-spec.js +94 -0
- package/test-export/inject-field-spec.d.ts +1 -0
- package/test-export/inject-field-spec.js +148 -0
- package/test-export/internal-uuids-spec.d.ts +1 -0
- package/test-export/internal-uuids-spec.js +157 -0
- package/test-export/invasive-species-eradication-np-spec.d.ts +1 -0
- package/test-export/invasive-species-eradication-np-spec.js +18 -0
- package/test-export/invasive-species-eradication-spec.d.ts +1 -0
- package/test-export/invasive-species-eradication-spec.js +25 -0
- package/test-export/line-transect-spec.d.ts +1 -0
- package/test-export/line-transect-spec.js +121 -0
- package/test-export/mobile-form-spec.d.ts +1 -0
- package/test-export/mobile-form-spec.js +84 -0
- package/test-export/nafi-spec.d.ts +1 -0
- package/test-export/nafi-spec.js +85 -0
- package/test-export/select-widget-spec.d.ts +1 -0
- package/test-export/select-widget-spec.js +68 -0
- package/test-export/single-item-array-field-spec.d.ts +1 -0
- package/test-export/single-item-array-field-spec.js +92 -0
- package/test-export/syke-butterfly-spec.d.ts +1 -0
- package/test-export/syke-butterfly-spec.js +163 -0
- package/test-export/test-utils.d.ts +184 -0
- package/test-export/test-utils.js +354 -0
- package/test-export/transaction-form-spec.d.ts +1 -0
- package/test-export/transaction-form-spec.js +63 -0
- package/test-export/trip-report-autosuggest-spec.d.ts +1 -0
- package/test-export/trip-report-autosuggest-spec.js +272 -0
- package/test-export/trip-report-spec.d.ts +1 -0
- package/test-export/trip-report-spec.js +456 -0
- package/test-export/unit-list-shorthand-array-field-spec.d.ts +1 -0
- package/test-export/unit-list-shorthand-array-field-spec.js +71 -0
- package/test-export/validation-spec.d.ts +1 -0
- package/test-export/validation-spec.js +336 -0
- package/test-export/water-bird-spec.d.ts +1 -0
- package/test-export/water-bird-spec.js +30 -0
- package/test-export/wbc-spec.d.ts +1 -0
- package/test-export/wbc-spec.js +82 -0
- package/tsconfig.json +25 -0
- package/tsconfig.lib.json +11 -0
- package/tsconfig.test.json +10 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export default class SumField extends React.Component<any, any, any> {
|
|
2
|
+
static propTypes: {
|
|
3
|
+
uiSchema: PropTypes.Validator<PropTypes.InferProps<{
|
|
4
|
+
"ui:options": PropTypes.Requireable<PropTypes.InferProps<{
|
|
5
|
+
sums: PropTypes.Validator<PropTypes.InferProps<{
|
|
6
|
+
resultField: PropTypes.Validator<string>;
|
|
7
|
+
summedFields: PropTypes.Validator<(string | null | undefined)[]>;
|
|
8
|
+
summedProperty: PropTypes.Requireable<string>;
|
|
9
|
+
}> | (PropTypes.InferProps<{
|
|
10
|
+
resultField: PropTypes.Validator<string>;
|
|
11
|
+
summedFields: PropTypes.Validator<(string | null | undefined)[]>;
|
|
12
|
+
summedProperty: PropTypes.Requireable<string>;
|
|
13
|
+
}> | null | undefined)[]>;
|
|
14
|
+
}>>;
|
|
15
|
+
uiSchema: PropTypes.Requireable<object>;
|
|
16
|
+
}>>;
|
|
17
|
+
schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
18
|
+
type: PropTypes.Requireable<string>;
|
|
19
|
+
}>>;
|
|
20
|
+
formData: PropTypes.Validator<object>;
|
|
21
|
+
};
|
|
22
|
+
static getName(): string;
|
|
23
|
+
constructor(props: any);
|
|
24
|
+
constructor(props: any, context: any);
|
|
25
|
+
getStateFromProps({ formData }: {
|
|
26
|
+
formData: any;
|
|
27
|
+
}): {
|
|
28
|
+
prevResult: {};
|
|
29
|
+
onChange: (formData: any) => void;
|
|
30
|
+
};
|
|
31
|
+
onChange: (formData: any) => void;
|
|
32
|
+
getSums: (formData: any) => {};
|
|
33
|
+
}
|
|
34
|
+
import * as React from "react";
|
|
35
|
+
import * as PropTypes from "prop-types";
|
|
@@ -0,0 +1,83 @@
|
|
|
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 sumPropType = PropTypes.shape({
|
|
13
|
+
resultField: PropTypes.string.isRequired,
|
|
14
|
+
summedFields: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
15
|
+
summedProperty: PropTypes.string
|
|
16
|
+
});
|
|
17
|
+
let SumField = class SumField extends React.Component {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.onChange = (formData) => {
|
|
21
|
+
let { sums } = this.getUiOptions();
|
|
22
|
+
sums = Array.isArray(sums) ? sums : [sums];
|
|
23
|
+
const newSums = this.getSums(formData);
|
|
24
|
+
sums.forEach(options => {
|
|
25
|
+
if (newSums[options.resultField] !== this.state.prevResult[options.resultField]) {
|
|
26
|
+
formData = Object.assign(Object.assign({}, formData), { [options.resultField]: newSums[options.resultField] });
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
this.props.onChange(formData);
|
|
30
|
+
};
|
|
31
|
+
this.getSums = (formData) => {
|
|
32
|
+
let { sums } = this.getUiOptions();
|
|
33
|
+
sums = Array.isArray(sums) ? sums : [sums];
|
|
34
|
+
const results = {};
|
|
35
|
+
sums.forEach(options => {
|
|
36
|
+
const { resultField, summedFields, summedProperty } = options;
|
|
37
|
+
const resultType = this.props.schema.properties[resultField].type;
|
|
38
|
+
let result = 0;
|
|
39
|
+
let allEmpty = true;
|
|
40
|
+
summedFields.forEach(field => {
|
|
41
|
+
if (formData[field] !== undefined) {
|
|
42
|
+
if (summedProperty === "arrayLength") {
|
|
43
|
+
result += formData[field].length;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
result += Number(formData[field]);
|
|
47
|
+
}
|
|
48
|
+
allEmpty = false;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
result = allEmpty || isNaN(result) ? undefined : result;
|
|
52
|
+
if (result !== undefined && resultType !== "number" && resultType !== "integer") {
|
|
53
|
+
result = result + "";
|
|
54
|
+
}
|
|
55
|
+
results[resultField] = result;
|
|
56
|
+
});
|
|
57
|
+
return results;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
static getName() { return "SumField"; }
|
|
61
|
+
getStateFromProps({ formData }) {
|
|
62
|
+
return { prevResult: this.getSums(formData), onChange: this.onChange };
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
SumField.propTypes = {
|
|
66
|
+
uiSchema: PropTypes.shape({
|
|
67
|
+
"ui:options": PropTypes.shape({
|
|
68
|
+
"sums": PropTypes.oneOfType([
|
|
69
|
+
sumPropType,
|
|
70
|
+
PropTypes.arrayOf(sumPropType)
|
|
71
|
+
]).isRequired
|
|
72
|
+
}),
|
|
73
|
+
uiSchema: PropTypes.object
|
|
74
|
+
}).isRequired,
|
|
75
|
+
schema: PropTypes.shape({
|
|
76
|
+
type: PropTypes.oneOf(["object"])
|
|
77
|
+
}).isRequired,
|
|
78
|
+
formData: PropTypes.object.isRequired
|
|
79
|
+
};
|
|
80
|
+
SumField = __decorate([
|
|
81
|
+
VirtualSchemaField_1.default
|
|
82
|
+
], SumField);
|
|
83
|
+
exports.default = SumField;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export default class TableField extends React.Component<any, any, any> {
|
|
2
|
+
static contextType: React.Context<import("../../ReactContext").ContextProps>;
|
|
3
|
+
static propTypes: {
|
|
4
|
+
uiSchema: PropTypes.Requireable<PropTypes.InferProps<{
|
|
5
|
+
"ui:options": PropTypes.Requireable<PropTypes.InferProps<{
|
|
6
|
+
specialRules: PropTypes.Requireable<string | (string | null | undefined)[]>;
|
|
7
|
+
}>>;
|
|
8
|
+
}>>;
|
|
9
|
+
schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
10
|
+
type: PropTypes.Requireable<string>;
|
|
11
|
+
items: PropTypes.Requireable<object>;
|
|
12
|
+
}>>;
|
|
13
|
+
};
|
|
14
|
+
constructor(props: any);
|
|
15
|
+
constructor(props: any, context: any);
|
|
16
|
+
}
|
|
17
|
+
import * as React from "react";
|
|
18
|
+
import * as PropTypes from "prop-types";
|
|
@@ -0,0 +1,136 @@
|
|
|
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 utils_2 = require("@rjsf/utils");
|
|
13
|
+
const components_1 = require("../components");
|
|
14
|
+
const ArrayFieldTemplate_1 = require("../templates/ArrayFieldTemplate");
|
|
15
|
+
const BaseComponent_1 = require("../BaseComponent");
|
|
16
|
+
const ReactContext_1 = require("../../ReactContext");
|
|
17
|
+
const specialRules = {
|
|
18
|
+
legEditors: {
|
|
19
|
+
filterProperties: ({ properties, formData, uiSchemaContext }) => {
|
|
20
|
+
if (!uiSchemaContext)
|
|
21
|
+
return properties;
|
|
22
|
+
const { creator } = uiSchemaContext;
|
|
23
|
+
return (!formData ||
|
|
24
|
+
formData.some(item => item && item.leg && item.leg.match(/MA\.\d+/) && item.leg !== creator)) ? properties : properties.filter(field => field !== "editors");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const specialRulesPropTypes = PropTypes.oneOf(["legEditors"]);
|
|
29
|
+
let TableField = class TableField extends React.Component {
|
|
30
|
+
render() {
|
|
31
|
+
const { schema, uiSchema = {}, formData, registry: { fields: { ArrayField } }, formContext } = this.props;
|
|
32
|
+
const { uiSchemaContext } = formContext;
|
|
33
|
+
const schemaProps = schema.additionalItems ? schema.additionalItems.properties : schema.items.properties;
|
|
34
|
+
const options = utils_1.getUiOptions(uiSchema);
|
|
35
|
+
let schemaPropsArray = Object.keys(schemaProps);
|
|
36
|
+
const optionsSpecialRules = options.specialRules;
|
|
37
|
+
if (optionsSpecialRules) {
|
|
38
|
+
(Array.isArray(optionsSpecialRules) ? optionsSpecialRules : [optionsSpecialRules]).forEach(specialRule => {
|
|
39
|
+
schemaPropsArray = specialRules[specialRule].filterProperties({
|
|
40
|
+
properties: schemaPropsArray, uiSchema, uiSchemaContext, formData
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
const schemaLength = schemaPropsArray.filter(col => !utils_1.isHidden(uiSchema.items, col)).length;
|
|
45
|
+
const defaultCol = parseInt(12 / schemaLength);
|
|
46
|
+
const defaultWrapperCol = parseInt(12 / (1 + (Object.keys(schemaProps).filter(col => !utils_1.isHidden(uiSchema.items, col)).length - schemaLength)));
|
|
47
|
+
const cols = { xs: undefined, sm: undefined, md: undefined, lg: undefined };
|
|
48
|
+
const wrapperCols = Object.assign({}, cols);
|
|
49
|
+
Object.keys(cols).forEach(col => {
|
|
50
|
+
cols[col] = options[col] ? Math.min(options[col], defaultCol) : defaultCol;
|
|
51
|
+
wrapperCols[col] = options[col] ? Math.min(options[col], defaultWrapperCol) : defaultWrapperCol;
|
|
52
|
+
});
|
|
53
|
+
const itemsSchema = schemaPropsArray.reduce((constructedSchema, prop) => {
|
|
54
|
+
constructedSchema.properties[prop] = schema.items.properties[prop];
|
|
55
|
+
return constructedSchema;
|
|
56
|
+
}, Object.assign(Object.assign({}, schema.items), { properties: {} }));
|
|
57
|
+
const itemsUiSchema = {
|
|
58
|
+
"ui:field": "GridLayoutField",
|
|
59
|
+
"ui:options": Object.assign(Object.assign({}, cols), { label: false }),
|
|
60
|
+
};
|
|
61
|
+
let _uiSchema = uiSchema;
|
|
62
|
+
if (uiSchema.items) {
|
|
63
|
+
if (uiSchema.items.uiSchema) {
|
|
64
|
+
_uiSchema = Object.assign(Object.assign({}, _uiSchema), { items: utils_1.updateTailUiSchema(uiSchema.items, { $merge: { uiSchema: itemsUiSchema } }) });
|
|
65
|
+
}
|
|
66
|
+
else if (uiSchema.items["ui:field"] || uiSchema.items["ui:functions"]) {
|
|
67
|
+
_uiSchema = Object.assign(Object.assign({}, _uiSchema), { items: Object.assign(Object.assign({}, _uiSchema.items), { uiSchema: itemsUiSchema }) });
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
_uiSchema = Object.assign(Object.assign({}, _uiSchema), { items: Object.assign(Object.assign(Object.assign({}, (uiSchema.items || {})), itemsUiSchema), { "ui:options": Object.assign(Object.assign({}, utils_1.getUiOptions(uiSchema.items)), utils_1.getUiOptions(itemsUiSchema)) }) });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
_uiSchema["ui:ArrayFieldTemplate"] = TableArrayFieldTemplate;
|
|
74
|
+
const _formContext = Object.assign(Object.assign({}, formContext), { cols,
|
|
75
|
+
wrapperCols,
|
|
76
|
+
schemaPropsArray });
|
|
77
|
+
return (React.createElement(ArrayField, Object.assign({}, this.props, { schema: Object.assign(Object.assign({}, schema), { items: itemsSchema }), uiSchema: _uiSchema, registry: Object.assign(Object.assign({}, this.props.registry), { formContext: _formContext }), formContext: _formContext })));
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
TableField.contextType = ReactContext_1.default;
|
|
81
|
+
TableField.propTypes = {
|
|
82
|
+
uiSchema: PropTypes.shape({
|
|
83
|
+
"ui:options": PropTypes.shape({
|
|
84
|
+
specialRules: PropTypes.oneOfType([
|
|
85
|
+
specialRulesPropTypes,
|
|
86
|
+
PropTypes.arrayOf(specialRulesPropTypes)
|
|
87
|
+
])
|
|
88
|
+
})
|
|
89
|
+
}),
|
|
90
|
+
schema: PropTypes.shape({
|
|
91
|
+
type: PropTypes.oneOf(["array"]),
|
|
92
|
+
items: PropTypes.oneOfType([PropTypes.object, PropTypes.array])
|
|
93
|
+
}).isRequired
|
|
94
|
+
};
|
|
95
|
+
TableField = __decorate([
|
|
96
|
+
BaseComponent_1.default
|
|
97
|
+
], TableField);
|
|
98
|
+
exports.default = TableField;
|
|
99
|
+
let TableArrayFieldTemplate = class TableArrayFieldTemplate extends React.Component {
|
|
100
|
+
render() {
|
|
101
|
+
const { props } = this;
|
|
102
|
+
const { schema, uiSchema, formContext: { cols, wrapperCols, schemaPropsArray }, idSchema, readonly, disabled } = props;
|
|
103
|
+
const schemaProps = schema.additionalItems ? schema.additionalItems.properties : schema.items.properties;
|
|
104
|
+
const { Label } = this.props.formContext;
|
|
105
|
+
const { Row, Col } = this.context.theme;
|
|
106
|
+
const labels = utils_2.orderProperties(schemaPropsArray.filter(col => !utils_1.isHidden(uiSchema.items, col)), (uiSchema.items || {})["ui:order"]).map(propName => {
|
|
107
|
+
const propUiSchema = uiSchema && uiSchema.items && uiSchema.items[propName] || {};
|
|
108
|
+
return (React.createElement(Col, Object.assign({}, cols, { key: propName + "-label" }),
|
|
109
|
+
React.createElement(Label, { label: "title" in schemaProps[propName] ? schemaProps[propName].title : propName, disabled: false, id: idSchema[propName].$id, required: (schema.items.required && schema.items.required.indexOf(propName) > -1)
|
|
110
|
+
|| propUiSchema["ui:required"], uiSchema: propUiSchema })));
|
|
111
|
+
});
|
|
112
|
+
const options = utils_1.getUiOptions(props.uiSchema);
|
|
113
|
+
const { confirmDelete, deleteCorner, removable = true, nonRemovables = [], buttons, "ui:deleteHelp": deleteHelp } = options;
|
|
114
|
+
if (!this.deleteButtonRefs)
|
|
115
|
+
this.deleteButtonRefs = [];
|
|
116
|
+
const getRefFor = i => elem => { this.deleteButtonRefs[i] = elem; };
|
|
117
|
+
return (React.createElement("div", { className: "table-field" },
|
|
118
|
+
React.createElement(Row, null,
|
|
119
|
+
React.createElement("div", { className: "laji-form-field-template-item" },
|
|
120
|
+
React.createElement("div", { className: "laji-form-field-template-schema" }, labels),
|
|
121
|
+
React.createElement("div", { className: "laji-form-field-template-buttons" }))),
|
|
122
|
+
props.items.map((item, i) => {
|
|
123
|
+
const deleteButton = (React.createElement(components_1.DeleteButton, { ref: getRefFor(i), id: `${props.idSchema.$id}_${i}`, disabled: readonly || disabled, onClick: item.onDropIndexClick(item.index), confirm: confirmDelete, corner: deleteCorner, tooltip: deleteHelp, translations: props.formContext.translations }));
|
|
124
|
+
return (React.createElement(Row, { key: utils_1.getUUID(props.formData[item.index]) || item.key },
|
|
125
|
+
React.createElement(Col, Object.assign({}, wrapperCols),
|
|
126
|
+
React.createElement("div", { className: "laji-form-field-template-item keep-vertical" },
|
|
127
|
+
React.createElement("div", { className: "laji-form-field-template-schema" }, item.children),
|
|
128
|
+
item.hasRemove && !nonRemovables.includes(item.index) && removable && deleteButton))));
|
|
129
|
+
}),
|
|
130
|
+
ArrayFieldTemplate_1.getButtonElems(buttons, props)));
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
TableArrayFieldTemplate.contextType = ReactContext_1.default;
|
|
134
|
+
TableArrayFieldTemplate = __decorate([
|
|
135
|
+
ArrayFieldTemplate_1.handlesArrayKeys
|
|
136
|
+
], TableArrayFieldTemplate);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export default class TagArrayField extends React.Component<any, any, any> {
|
|
2
|
+
static propTypes: {
|
|
3
|
+
uiSchema: PropTypes.Requireable<PropTypes.InferProps<{
|
|
4
|
+
"ui:options": PropTypes.Requireable<PropTypes.InferProps<{
|
|
5
|
+
separatorKeys: PropTypes.Requireable<(string | null | undefined)[]>;
|
|
6
|
+
showDeleteButton: PropTypes.Requireable<boolean>;
|
|
7
|
+
}>>;
|
|
8
|
+
}>>;
|
|
9
|
+
schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
10
|
+
type: PropTypes.Requireable<string>;
|
|
11
|
+
}>>;
|
|
12
|
+
formData: PropTypes.Requireable<any[]>;
|
|
13
|
+
};
|
|
14
|
+
constructor(props: any);
|
|
15
|
+
constructor(props: any, context: any);
|
|
16
|
+
}
|
|
17
|
+
export class TagInputComponent extends React.Component<any, any, any> {
|
|
18
|
+
constructor(props: any);
|
|
19
|
+
getStateFromProps: ({ value }: {
|
|
20
|
+
value: any;
|
|
21
|
+
}) => {
|
|
22
|
+
value: any;
|
|
23
|
+
};
|
|
24
|
+
getSeparatorKeys: (uiSchema: any) => any;
|
|
25
|
+
onKeyDown: (e: any) => void;
|
|
26
|
+
onRemove: ((idx: any) => () => void) & memoize.Memoized<(idx: any) => () => void>;
|
|
27
|
+
onFocus: (e: any) => void;
|
|
28
|
+
onBlur: (e: any) => void;
|
|
29
|
+
setInputRef: (ref: any) => void;
|
|
30
|
+
inputRef: any;
|
|
31
|
+
onClick: () => void;
|
|
32
|
+
onInputChange: (e: any) => void;
|
|
33
|
+
onTagClick: ((idx: any) => () => void) & memoize.Memoized<(idx: any) => () => void>;
|
|
34
|
+
getTrimmedValue(): any;
|
|
35
|
+
}
|
|
36
|
+
import * as React from "react";
|
|
37
|
+
import * as PropTypes from "prop-types";
|
|
38
|
+
import * as memoize from "memoizee";
|
|
@@ -0,0 +1,128 @@
|
|
|
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
|
+
exports.TagInputComponent = void 0;
|
|
10
|
+
const React = require("react");
|
|
11
|
+
const react_dom_1 = require("react-dom");
|
|
12
|
+
const PropTypes = require("prop-types");
|
|
13
|
+
const utils_1 = require("../../utils");
|
|
14
|
+
const BaseComponent_1 = require("../BaseComponent");
|
|
15
|
+
const memoize = require("memoizee");
|
|
16
|
+
let TagArrayField = class TagArrayField extends React.Component {
|
|
17
|
+
render() {
|
|
18
|
+
const { FieldTemplate } = this.props.registry.templates;
|
|
19
|
+
const { uiSchema } = this.props;
|
|
20
|
+
return (React.createElement(FieldTemplate, Object.assign({}, this.props, { forceDisplayLabel: true, rawHelp: uiSchema["ui:help"], description: uiSchema["ui:description"], rawErrors: [] }),
|
|
21
|
+
React.createElement(TagInputComponent, Object.assign({}, this.props, { id: this.props.idSchema.$id, tags: this.props.formData }))));
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
TagArrayField.propTypes = {
|
|
25
|
+
uiSchema: PropTypes.shape({
|
|
26
|
+
"ui:options": PropTypes.shape({
|
|
27
|
+
separatorKeys: PropTypes.arrayOf(PropTypes.string),
|
|
28
|
+
showDeleteButton: PropTypes.bool
|
|
29
|
+
})
|
|
30
|
+
}),
|
|
31
|
+
schema: PropTypes.shape({
|
|
32
|
+
type: PropTypes.oneOf(["array"])
|
|
33
|
+
}).isRequired,
|
|
34
|
+
formData: PropTypes.array
|
|
35
|
+
};
|
|
36
|
+
TagArrayField = __decorate([
|
|
37
|
+
BaseComponent_1.default
|
|
38
|
+
], TagArrayField);
|
|
39
|
+
exports.default = TagArrayField;
|
|
40
|
+
class TagInputComponent extends React.Component {
|
|
41
|
+
constructor(props) {
|
|
42
|
+
super(props);
|
|
43
|
+
this.getStateFromProps = ({ value }) => {
|
|
44
|
+
return { value };
|
|
45
|
+
};
|
|
46
|
+
this.getSeparatorKeys = (uiSchema) => {
|
|
47
|
+
const { separatorKeys = ["Enter", ",", ";"] } = utils_1.getUiOptions(uiSchema);
|
|
48
|
+
return separatorKeys;
|
|
49
|
+
};
|
|
50
|
+
this.onKeyDown = (e) => {
|
|
51
|
+
const value = this.getTrimmedValue();
|
|
52
|
+
const { tags = [] } = this.props;
|
|
53
|
+
const separatorKeys = this.getSeparatorKeys(this.props.uiSchema);
|
|
54
|
+
if (separatorKeys.includes(e.key) && !utils_1.isEmptyString(value)) {
|
|
55
|
+
this.props.onChange([...tags, value], "enter");
|
|
56
|
+
e.stopPropagation();
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
}
|
|
59
|
+
else if (e.key === "Backspace" && utils_1.isEmptyString(value) && tags.length) {
|
|
60
|
+
this.onRemove(tags.length - 1)();
|
|
61
|
+
}
|
|
62
|
+
utils_1.triggerParentComponent("onKeyDown", e, this.props);
|
|
63
|
+
};
|
|
64
|
+
this.onRemove = memoize((idx) => () => {
|
|
65
|
+
const tags = [...(this.props.tags || [])];
|
|
66
|
+
tags.splice(idx, 1);
|
|
67
|
+
this.props.onChange(tags, "remove");
|
|
68
|
+
});
|
|
69
|
+
this.onFocus = (e) => {
|
|
70
|
+
this.setState({ focused: true }, () => {
|
|
71
|
+
utils_1.triggerParentComponent("onFocus", e, this.props);
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
this.onBlur = (e) => {
|
|
75
|
+
this.setState({ focused: false });
|
|
76
|
+
utils_1.triggerParentComponent("onBlur", e, this.props);
|
|
77
|
+
const value = this.getTrimmedValue();
|
|
78
|
+
if (!utils_1.isEmptyString(value)) {
|
|
79
|
+
this.props.onChange([...(this.props.tags || []), value], "blur");
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
this.setInputRef = (ref) => {
|
|
83
|
+
this.inputRef = ref;
|
|
84
|
+
};
|
|
85
|
+
this.onClick = () => {
|
|
86
|
+
react_dom_1.findDOMNode(this.inputRef).focus();
|
|
87
|
+
};
|
|
88
|
+
this.onInputChange = (e) => {
|
|
89
|
+
const { onInputChange } = this.props;
|
|
90
|
+
onInputChange && e.persist();
|
|
91
|
+
const { target: { value } } = e;
|
|
92
|
+
const separatorKeys = this.getSeparatorKeys(this.props.uiSchema);
|
|
93
|
+
const splitted = separatorKeys.reduce((splitted, separator) => splitted.reduce((_splitted, i) => ([..._splitted, ...i.split(separator)]), []), [value]).map(s => s.trim()).filter(s => !utils_1.isEmptyString(s));
|
|
94
|
+
this.setState({ value }, () => {
|
|
95
|
+
onInputChange && this.props.onInputChange(e);
|
|
96
|
+
if (splitted.length > 1) {
|
|
97
|
+
this.props.onChange([...(this.props.tags || []), ...splitted]);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
this.onTagClick = memoize((idx) => () => {
|
|
102
|
+
const { onTagClick } = utils_1.getUiOptions(this.props.uiSchema);
|
|
103
|
+
onTagClick === null || onTagClick === void 0 ? void 0 : onTagClick(idx);
|
|
104
|
+
});
|
|
105
|
+
this.state = this.getStateFromProps(props);
|
|
106
|
+
}
|
|
107
|
+
UNSAFE_componentWillReceiveProps(props) {
|
|
108
|
+
this.setState(this.getStateFromProps(props));
|
|
109
|
+
}
|
|
110
|
+
getTrimmedValue() {
|
|
111
|
+
const { value } = this.state;
|
|
112
|
+
return value === null || value === void 0 ? void 0 : value.trim();
|
|
113
|
+
}
|
|
114
|
+
render() {
|
|
115
|
+
let { tags = [], InputComponent, readonly, disabled, uiSchema } = this.props;
|
|
116
|
+
tags = tags.filter(s => !utils_1.isEmptyString(s));
|
|
117
|
+
const { value = "" } = this.state;
|
|
118
|
+
const inputProps = Object.assign(Object.assign({ type: "text", className: "rw-input-reset", ref: this.setInputRef, value: value, onChange: this.onInputChange, id: this.props.id }, this.props.inputProps), { onFocus: this.onFocus, onBlur: this.onBlur, onKeyDown: this.onKeyDown });
|
|
119
|
+
const { showDeleteButton = true } = utils_1.getUiOptions(uiSchema);
|
|
120
|
+
return (React.createElement("div", { className: `rw-multiselect rw-widget${this.state.focused ? " rw-state-focus" : ""}${readonly || disabled ? " rw-state-disabled" : ""}`, onClick: this.onClick },
|
|
121
|
+
React.createElement("div", { className: "rw-widget-input rw-widget-picked rw-widget-container" },
|
|
122
|
+
React.createElement("ul", { className: "rw-multiselect-taglist" }, tags.map((item, idx) => React.createElement("li", { key: idx, className: "rw-multiselect-tag", onClick: this.onTagClick(idx) },
|
|
123
|
+
item,
|
|
124
|
+
showDeleteButton ? React.createElement("span", { className: "rw-tag-btn", onClick: this.onRemove(idx), tabIndex: 0, onKeyDown: this.props.formContext.utils.keyboardClick(this.onRemove(idx)) }, "\u00D7") : ""))),
|
|
125
|
+
InputComponent ? React.createElement(InputComponent, Object.assign({}, inputProps)) : React.createElement("input", Object.assign({}, inputProps, { disabled: disabled || readonly })))));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
exports.TagInputComponent = TagInputComponent;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export default class ToggleAdditionalArrayFieldsField extends React.Component<any, any, any> {
|
|
2
|
+
static propTypes: {
|
|
3
|
+
uiSchema: PropTypes.Validator<PropTypes.InferProps<{
|
|
4
|
+
"ui:options": PropTypes.Requireable<PropTypes.InferProps<{
|
|
5
|
+
additionalFields: PropTypes.Validator<(string | null | undefined)[]>;
|
|
6
|
+
toggleLabel: PropTypes.Requireable<string>;
|
|
7
|
+
toggleClassName: PropTypes.Requireable<string>;
|
|
8
|
+
toggleHelp: 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<any[]>;
|
|
16
|
+
};
|
|
17
|
+
constructor(props: any);
|
|
18
|
+
getTogglePersistenceContextKey: (props: any) => string;
|
|
19
|
+
getInitialVisible(props: any): unknown;
|
|
20
|
+
getStateFromProps(props: any): {
|
|
21
|
+
uiSchema: any;
|
|
22
|
+
};
|
|
23
|
+
toggleVisibility: () => void;
|
|
24
|
+
}
|
|
25
|
+
import * as React from "react";
|
|
26
|
+
import * as PropTypes from "prop-types";
|
|
@@ -0,0 +1,81 @@
|
|
|
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 BaseComponent_1 = require("../BaseComponent");
|
|
13
|
+
const Context_1 = require("../../Context");
|
|
14
|
+
let ToggleAdditionalArrayFieldsField = class ToggleAdditionalArrayFieldsField extends React.Component {
|
|
15
|
+
constructor(props) {
|
|
16
|
+
super(props);
|
|
17
|
+
this.getTogglePersistenceContextKey = (props) => `$additional_toggle_persistence_${props.idSchema.$id}`;
|
|
18
|
+
this.toggleVisibility = () => {
|
|
19
|
+
const visible = !this.state.visible;
|
|
20
|
+
const context = Context_1.default(this.props.formContext.contextId);
|
|
21
|
+
context[this.getTogglePersistenceContextKey(this.props)] = visible;
|
|
22
|
+
this.setState({ visible });
|
|
23
|
+
};
|
|
24
|
+
this.state = Object.assign({ visible: this.getInitialVisible(props) }, this.getStateFromProps(props));
|
|
25
|
+
}
|
|
26
|
+
getInitialVisible(props) {
|
|
27
|
+
const { additionalFields } = utils_1.getUiOptions(props.uiSchema);
|
|
28
|
+
const context = Context_1.default(props.formContext.contextId);
|
|
29
|
+
let visible = context[this.getTogglePersistenceContextKey(props)] || false;
|
|
30
|
+
if (!visible) {
|
|
31
|
+
for (const data of props.formData) {
|
|
32
|
+
for (const field of additionalFields) {
|
|
33
|
+
if (!utils_1.isDefaultData(utils_1.parseJSONPointer(data, field), utils_1.parseSchemaFromFormDataPointer(props.schema, field))) {
|
|
34
|
+
visible = true;
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return visible;
|
|
41
|
+
}
|
|
42
|
+
getStateFromProps(props) {
|
|
43
|
+
const innerUiSchema = utils_1.getInnerUiSchema(props.uiSchema);
|
|
44
|
+
return { uiSchema: innerUiSchema };
|
|
45
|
+
}
|
|
46
|
+
render() {
|
|
47
|
+
const { CheckboxWidget } = this.props.registry.widgets;
|
|
48
|
+
const { SchemaField } = this.props.registry.fields;
|
|
49
|
+
const { additionalFields = [], toggleLabel, toggleClassName, toggleHelp } = utils_1.getUiOptions(this.props.uiSchema);
|
|
50
|
+
const shouldShow = Object.values(this.props.errorSchema || {}).some(error => additionalFields.some(field => utils_1.parseJSONPointer(error, field))) || this.state.visible;
|
|
51
|
+
let _uiSchema = this.state.uiSchema;
|
|
52
|
+
if (!shouldShow) {
|
|
53
|
+
additionalFields.forEach(field => {
|
|
54
|
+
_uiSchema = utils_1.updateSafelyWithJSONPointer(_uiSchema, { "ui:field": "HiddenField" }, "items/" + field);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return (React.createElement(React.Fragment, null,
|
|
58
|
+
React.createElement(SchemaField, Object.assign({}, this.props, { uiSchema: _uiSchema })),
|
|
59
|
+
React.createElement("div", { className: toggleClassName },
|
|
60
|
+
React.createElement(CheckboxWidget, Object.assign({}, this.props, { id: this.props.idSchema.$id + "_toggle", schema: { type: "boolean" }, value: this.state.visible, onChange: this.toggleVisibility, label: toggleLabel || "", options: { allowUndefined: false, help: toggleHelp }, required: false })))));
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
ToggleAdditionalArrayFieldsField.propTypes = {
|
|
64
|
+
uiSchema: PropTypes.shape({
|
|
65
|
+
"ui:options": PropTypes.shape({
|
|
66
|
+
additionalFields: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
67
|
+
toggleLabel: PropTypes.string,
|
|
68
|
+
toggleClassName: PropTypes.string,
|
|
69
|
+
toggleHelp: PropTypes.string
|
|
70
|
+
}),
|
|
71
|
+
uiSchema: PropTypes.object
|
|
72
|
+
}).isRequired,
|
|
73
|
+
schema: PropTypes.shape({
|
|
74
|
+
type: PropTypes.oneOf(["array"])
|
|
75
|
+
}).isRequired,
|
|
76
|
+
formData: PropTypes.oneOfType([PropTypes.array]).isRequired
|
|
77
|
+
};
|
|
78
|
+
ToggleAdditionalArrayFieldsField = __decorate([
|
|
79
|
+
BaseComponent_1.default
|
|
80
|
+
], ToggleAdditionalArrayFieldsField);
|
|
81
|
+
exports.default = ToggleAdditionalArrayFieldsField;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export default class UiFieldApplierField extends React.Component<any, any, any> {
|
|
2
|
+
static propTypes: {
|
|
3
|
+
schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
4
|
+
type: PropTypes.Requireable<string>;
|
|
5
|
+
}>>;
|
|
6
|
+
uiSchema: PropTypes.Requireable<PropTypes.InferProps<{
|
|
7
|
+
"ui:options": PropTypes.Requireable<PropTypes.InferProps<{
|
|
8
|
+
field: PropTypes.Requireable<string>;
|
|
9
|
+
functions: PropTypes.Requireable<PropTypes.InferProps<{
|
|
10
|
+
"ui:field": PropTypes.Validator<string>;
|
|
11
|
+
"ui:options": PropTypes.Requireable<object>;
|
|
12
|
+
}> | (PropTypes.InferProps<{
|
|
13
|
+
"ui:field": PropTypes.Validator<string>;
|
|
14
|
+
"ui:options": PropTypes.Requireable<object>;
|
|
15
|
+
}> | null | undefined)[]>;
|
|
16
|
+
}>>;
|
|
17
|
+
}>>;
|
|
18
|
+
formData: PropTypes.Requireable<object>;
|
|
19
|
+
};
|
|
20
|
+
static getName(): string;
|
|
21
|
+
constructor(props: any);
|
|
22
|
+
functions: any[];
|
|
23
|
+
getFunctions: () => any;
|
|
24
|
+
getStateFromProps(props: any): any;
|
|
25
|
+
onChange: (formData: any) => void;
|
|
26
|
+
onChangeFormData: any;
|
|
27
|
+
combinedOnChange(formData: any): void;
|
|
28
|
+
}
|
|
29
|
+
import * as React from "react";
|
|
30
|
+
import * as PropTypes from "prop-types";
|