@luomus/laji-form 15.1.63 → 15.1.65
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/dist/laji-form.js +1 -1
- package/dist/laji-form.js.LICENSE.txt +1 -1
- package/lib/Context.d.ts +1 -1
- package/lib/Context.js +1 -2
- package/lib/ReactContext.js +22 -8
- package/lib/components/BaseComponent.d.ts +1 -2
- package/lib/components/BaseComponent.js +2 -3
- package/lib/components/LajiForm.d.ts +13 -13
- package/lib/components/LajiForm.js +51 -35
- package/lib/components/VirtualSchemaField.d.ts +14 -14
- package/lib/components/VirtualSchemaField.js +31 -18
- package/lib/components/components/Affix.d.ts +2 -2
- package/lib/components/components/Affix.js +25 -12
- package/lib/components/components/Button.d.ts +6 -6
- package/lib/components/components/Button.js +23 -9
- package/lib/components/components/DeleteButton.d.ts +4 -4
- package/lib/components/components/DeleteButton.js +25 -11
- package/lib/components/components/ErrorPanel.d.ts +3 -3
- package/lib/components/components/ErrorPanel.js +22 -8
- package/lib/components/components/FailedBackgroundJobsPanel.d.ts +2 -2
- package/lib/components/components/FailedBackgroundJobsPanel.js +25 -11
- package/lib/components/components/FetcherInput.d.ts +1 -1
- package/lib/components/components/FetcherInput.js +28 -14
- package/lib/components/components/Fullscreen.d.ts +1 -1
- package/lib/components/components/Fullscreen.js +23 -9
- package/lib/components/components/GlyphButton.d.ts +5 -5
- package/lib/components/components/GlyphButton.js +22 -8
- package/lib/components/components/Help.d.ts +1 -1
- package/lib/components/components/Help.js +25 -12
- package/lib/components/components/Label.d.ts +1 -1
- package/lib/components/components/Label.js +24 -11
- package/lib/components/components/OverlayTrigger.d.ts +4 -4
- package/lib/components/components/OverlayTrigger.js +22 -8
- package/lib/components/components/Stretch.d.ts +4 -4
- package/lib/components/components/Stretch.js +25 -11
- package/lib/components/components/TooltipComponent.d.ts +1 -1
- package/lib/components/components/TooltipComponent.js +26 -12
- package/lib/components/components/index.js +5 -1
- package/lib/components/fields/AnnotationField.d.ts +8 -4
- package/lib/components/fields/AnnotationField.js +34 -20
- package/lib/components/fields/AnyToBooleanField.d.ts +4 -4
- package/lib/components/fields/AnyToBooleanField.js +22 -8
- package/lib/components/fields/ArrayBulkField.d.ts +9 -4
- package/lib/components/fields/ArrayBulkField.js +24 -10
- package/lib/components/fields/ArrayCombinerField.d.ts +4 -4
- package/lib/components/fields/ArrayCombinerField.js +25 -11
- package/lib/components/fields/ArrayField.d.ts +1 -0
- package/lib/components/fields/ArrayField.js +41 -27
- package/lib/components/fields/ArrayPropertySumField.d.ts +2 -2
- package/lib/components/fields/ArrayPropertySumField.js +24 -10
- package/lib/components/fields/AsArrayField.d.ts +7 -5
- package/lib/components/fields/AsArrayField.js +22 -8
- package/lib/components/fields/AudioArrayField.js +22 -8
- package/lib/components/fields/AutoArrayField.d.ts +2 -2
- package/lib/components/fields/AutoArrayField.js +26 -12
- package/lib/components/fields/AutosuggestField.d.ts +14 -6
- package/lib/components/fields/AutosuggestField.js +61 -47
- package/lib/components/fields/CombinedValueDisplayField.d.ts +6 -6
- package/lib/components/fields/CombinedValueDisplayField.js +24 -10
- package/lib/components/fields/CondensedObjectField.d.ts +3 -3
- package/lib/components/fields/CondensedObjectField.js +33 -19
- package/lib/components/fields/ConditionalOnChangeField.d.ts +7 -7
- package/lib/components/fields/ConditionalOnChangeField.js +22 -8
- package/lib/components/fields/ConditionalUiSchemaField.d.ts +19 -19
- package/lib/components/fields/ConditionalUiSchemaField.js +28 -14
- package/lib/components/fields/ContextInjectionField.d.ts +7 -7
- package/lib/components/fields/ContextInjectionField.js +26 -13
- package/lib/components/fields/DataLeakerField.d.ts +6 -6
- package/lib/components/fields/DataLeakerField.js +25 -11
- package/lib/components/fields/DefaultValueArrayField.d.ts +6 -6
- package/lib/components/fields/DefaultValueArrayField.js +23 -9
- package/lib/components/fields/DependentBooleanField.d.ts +6 -6
- package/lib/components/fields/DependentBooleanField.js +24 -10
- package/lib/components/fields/DependentDisableField.d.ts +4 -4
- package/lib/components/fields/DependentDisableField.js +24 -10
- package/lib/components/fields/EnumRangeArrayField.d.ts +2 -3
- package/lib/components/fields/EnumRangeArrayField.js +26 -12
- package/lib/components/fields/ExtraLabelRowField.d.ts +9 -8
- package/lib/components/fields/ExtraLabelRowField.js +27 -13
- package/lib/components/fields/FakePropertyField.d.ts +2 -2
- package/lib/components/fields/FakePropertyField.js +26 -12
- package/lib/components/fields/FillDateRangeField.d.ts +28 -0
- package/lib/components/fields/FillDateRangeField.js +91 -0
- package/lib/components/fields/FilterArrayField.d.ts +13 -12
- package/lib/components/fields/FilterArrayField.js +27 -13
- package/lib/components/fields/FlatField.d.ts +4 -4
- package/lib/components/fields/FlatField.js +35 -21
- package/lib/components/fields/GeocoderField.d.ts +12 -4
- package/lib/components/fields/GeocoderField.js +38 -24
- package/lib/components/fields/GridLayoutField.d.ts +7 -7
- package/lib/components/fields/GridLayoutField.js +23 -9
- package/lib/components/fields/HiddenField.d.ts +2 -2
- package/lib/components/fields/HiddenField.js +22 -8
- package/lib/components/fields/HiddenWithTextField.d.ts +6 -7
- package/lib/components/fields/HiddenWithTextField.js +22 -8
- package/lib/components/fields/ImageArrayField.d.ts +17 -17
- package/lib/components/fields/ImageArrayField.js +53 -39
- package/lib/components/fields/ImageDisplayField.d.ts +4 -3
- package/lib/components/fields/ImageDisplayField.js +25 -11
- package/lib/components/fields/InitiallyHiddenField.d.ts +9 -4
- package/lib/components/fields/InitiallyHiddenField.js +23 -9
- package/lib/components/fields/InjectDefaultValueField.d.ts +6 -6
- package/lib/components/fields/InjectDefaultValueField.js +23 -9
- package/lib/components/fields/InjectField.d.ts +8 -8
- package/lib/components/fields/InjectField.js +34 -20
- package/lib/components/fields/InputWithDefaultValueButtonField.d.ts +8 -8
- package/lib/components/fields/InputWithDefaultValueButtonField.js +29 -15
- package/lib/components/fields/LocalityField.d.ts +4 -2
- package/lib/components/fields/LocalityField.js +28 -14
- package/lib/components/fields/LocationChooserField.d.ts +5 -4
- package/lib/components/fields/LocationChooserField.js +60 -46
- package/lib/components/fields/MapArrayField.d.ts +17 -4
- package/lib/components/fields/MapArrayField.js +137 -132
- package/lib/components/fields/MapField.d.ts +10 -2
- package/lib/components/fields/MapField.js +42 -29
- package/lib/components/fields/MultiActiveArrayField.d.ts +3 -3
- package/lib/components/fields/MultiActiveArrayField.js +29 -15
- package/lib/components/fields/MultiAnyToBooleanField.d.ts +6 -2
- package/lib/components/fields/MultiAnyToBooleanField.js +25 -11
- package/lib/components/fields/MultiArrayField.d.ts +11 -10
- package/lib/components/fields/MultiArrayField.js +45 -31
- package/lib/components/fields/MultiLanguageField.d.ts +3 -2
- package/lib/components/fields/MultiLanguageField.js +23 -9
- package/lib/components/fields/MultiTagArrayField.d.ts +8 -4
- package/lib/components/fields/MultiTagArrayField.js +34 -20
- package/lib/components/fields/NamedPlaceChooserField/NamedPlaceChooser.d.ts +2 -2
- package/lib/components/fields/NamedPlaceChooserField/NamedPlaceChooser.js +25 -11
- package/lib/components/fields/NamedPlaceChooserField/NamedPlaceChooserField.d.ts +6 -6
- package/lib/components/fields/NamedPlaceChooserField/NamedPlaceChooserField.js +29 -16
- package/lib/components/fields/NamedPlaceChooserField/Popup.d.ts +1 -1
- package/lib/components/fields/NamedPlaceChooserField/Popup.js +29 -15
- package/lib/components/fields/NamedPlaceSaverField.d.ts +7 -5
- package/lib/components/fields/NamedPlaceSaverField.js +35 -21
- package/lib/components/fields/NestField.d.ts +4 -4
- package/lib/components/fields/NestField.js +36 -23
- package/lib/components/fields/ObjectField.js +36 -22
- package/lib/components/fields/PdfArrayField.js +22 -8
- package/lib/components/fields/PrefillingArrayField.d.ts +2 -2
- package/lib/components/fields/PrefillingArrayField.js +23 -9
- package/lib/components/fields/PrefixArrayField.d.ts +35 -0
- package/lib/components/fields/PrefixArrayField.js +138 -0
- package/lib/components/fields/SchemaField.d.ts +1 -1
- package/lib/components/fields/SchemaField.js +34 -20
- package/lib/components/fields/ScopeField.d.ts +14 -6
- package/lib/components/fields/ScopeField.js +53 -39
- package/lib/components/fields/SectionArrayField.d.ts +2 -2
- package/lib/components/fields/SectionArrayField.js +110 -96
- package/lib/components/fields/SelectTreeField.d.ts +0 -1
- package/lib/components/fields/SelectTreeField.js +30 -16
- package/lib/components/fields/SingleActiveArrayField.d.ts +14 -2
- package/lib/components/fields/SingleActiveArrayField.js +112 -98
- package/lib/components/fields/SingleItemArrayField.d.ts +3 -2
- package/lib/components/fields/SingleItemArrayField.js +28 -14
- package/lib/components/fields/SortArrayField.d.ts +9 -9
- package/lib/components/fields/SortArrayField.js +43 -29
- package/lib/components/fields/SplitField.d.ts +4 -4
- package/lib/components/fields/SplitField.js +26 -12
- package/lib/components/fields/StringToArrayField.d.ts +5 -5
- package/lib/components/fields/StringToArrayField.js +23 -9
- package/lib/components/fields/SumField.d.ts +6 -6
- package/lib/components/fields/SumField.js +22 -8
- package/lib/components/fields/TableField.d.ts +4 -3
- package/lib/components/fields/TableField.js +31 -17
- package/lib/components/fields/TagArrayField.d.ts +8 -2
- package/lib/components/fields/TagArrayField.js +37 -23
- package/lib/components/fields/ToggleAdditionalArrayFieldsField.d.ts +10 -5
- package/lib/components/fields/ToggleAdditionalArrayFieldsField.js +30 -16
- package/lib/components/fields/UiFieldApplierField.d.ts +4 -4
- package/lib/components/fields/UiFieldApplierField.js +33 -19
- package/lib/components/fields/UiFieldMapperArrayField.d.ts +7 -6
- package/lib/components/fields/UiFieldMapperArrayField.js +26 -12
- package/lib/components/fields/UnitCountShorthandField.d.ts +6 -6
- package/lib/components/fields/UnitCountShorthandField.js +31 -17
- package/lib/components/fields/UnitListShorthandArrayField.d.ts +6 -5
- package/lib/components/fields/UnitListShorthandArrayField.js +31 -17
- package/lib/components/fields/UnitShorthandField.d.ts +11 -5
- package/lib/components/fields/UnitShorthandField.js +41 -27
- package/lib/components/templates/ArrayFieldTemplate.d.ts +2 -1
- package/lib/components/templates/ArrayFieldTemplate.js +60 -46
- package/lib/components/templates/BaseInputTemplate.d.ts +3 -0
- package/lib/components/templates/BaseInputTemplate.js +26 -13
- package/lib/components/templates/DescriptionField.js +25 -11
- package/lib/components/templates/ErrorListTemplate.d.ts +5 -0
- package/lib/components/templates/ErrorListTemplate.js +26 -12
- package/lib/components/templates/FieldTemplate.d.ts +8 -0
- package/lib/components/templates/FieldTemplate.js +31 -17
- package/lib/components/templates/ObjectFieldTemplate.js +30 -17
- package/lib/components/templates/TitleField.js +27 -13
- package/lib/components/widgets/AnyToBooleanWidget.d.ts +6 -6
- package/lib/components/widgets/AnyToBooleanWidget.js +24 -10
- package/lib/components/widgets/AutosuggestWidget.d.ts +14 -2
- package/lib/components/widgets/AutosuggestWidget.js +49 -35
- package/lib/components/widgets/CheckboxWidget.d.ts +3 -0
- package/lib/components/widgets/CheckboxWidget.js +32 -18
- package/lib/components/widgets/DateTimeWidget.d.ts +16 -8
- package/lib/components/widgets/DateTimeWidget.js +67 -35
- package/lib/components/widgets/DateWidget.d.ts +11 -11
- package/lib/components/widgets/DateWidget.js +36 -14
- package/lib/components/widgets/HiddenWidget.d.ts +4 -4
- package/lib/components/widgets/HiddenWidget.js +22 -8
- package/lib/components/widgets/ImageSelectWidget.d.ts +1 -0
- package/lib/components/widgets/ImageSelectWidget.js +24 -10
- package/lib/components/widgets/InformalTaxonGroupChooserWidget.d.ts +12 -0
- package/lib/components/widgets/InformalTaxonGroupChooserWidget.js +26 -12
- package/lib/components/widgets/InputGroupWidget.d.ts +4 -3
- package/lib/components/widgets/InputGroupWidget.js +25 -11
- package/lib/components/widgets/InputWithDefaultValueButtonWidget.d.ts +18 -8
- package/lib/components/widgets/InputWithDefaultValueButtonWidget.js +50 -14
- package/lib/components/widgets/NumberWidget.d.ts +3 -2
- package/lib/components/widgets/NumberWidget.js +23 -9
- package/lib/components/widgets/PlainTextWidget.d.ts +3 -3
- package/lib/components/widgets/PlainTextWidget.js +24 -10
- package/lib/components/widgets/SelectWidget.d.ts +5 -6
- package/lib/components/widgets/SelectWidget.js +92 -72
- package/lib/components/widgets/SeparatedDateTimeWidget.d.ts +3 -2
- package/lib/components/widgets/SeparatedDateTimeWidget.js +22 -8
- package/lib/components/widgets/TaxonImageWidget.d.ts +3 -2
- package/lib/components/widgets/TaxonImageWidget.js +24 -10
- package/lib/components/widgets/TextSelectWidget.d.ts +10 -2
- package/lib/components/widgets/TextSelectWidget.js +26 -12
- package/lib/components/widgets/TextareaWidget.d.ts +5 -0
- package/lib/components/widgets/TextareaWidget.js +25 -11
- package/lib/components/widgets/TimeWidget.d.ts +2 -2
- package/lib/components/widgets/TimeWidget.js +24 -10
- package/lib/components/widgets/URLWidget.d.ts +2 -2
- package/lib/components/widgets/URLWidget.js +22 -8
- package/lib/components/widgets/UpperCaseWidget.d.ts +3 -2
- package/lib/components/widgets/UpperCaseWidget.js +23 -9
- package/lib/index.d.ts +1 -1
- package/lib/index.js +25 -11
- package/lib/services/custom-event-service.d.ts +1 -1
- package/lib/services/focus-service.d.ts +1 -1
- package/lib/services/focus-service.js +3 -3
- package/lib/services/id-service.d.ts +1 -1
- package/lib/services/id-service.js +5 -6
- package/lib/services/key-handler-service.d.ts +3 -4
- package/lib/services/key-handler-service.js +4 -4
- package/lib/services/multi-active-array-service.d.ts +1 -1
- package/lib/services/settings-service.d.ts +2 -3
- package/lib/services/settings-service.js +3 -3
- package/lib/services/submit-hook-service.js +1 -1
- package/lib/themes/bs3.js +22 -8
- package/lib/themes/bs5.js +23 -9
- package/lib/themes/stub.js +22 -8
- package/lib/themes/theme.d.ts +15 -15
- package/lib/translations.json +5 -0
- package/lib/types.d.ts +18 -19
- package/lib/types.js +3 -4
- package/lib/utils.d.ts +9 -9
- package/lib/utils.js +138 -134
- package/lib/validation.js +28 -12
- package/package.json +12 -11
- package/test-export/test-utils.d.ts +7 -7
- package/test-export/test-utils.js +36 -22
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as PropTypes from "prop-types";
|
|
3
|
+
import { FieldProps, JSONSchemaArray, UiSchema } from "../../types";
|
|
4
|
+
import memoize from "memoizee";
|
|
5
|
+
interface FieldValue {
|
|
6
|
+
prefix: string;
|
|
7
|
+
value: string;
|
|
8
|
+
}
|
|
9
|
+
interface State {
|
|
10
|
+
fieldValues: FieldValue[];
|
|
11
|
+
}
|
|
12
|
+
export default class PrefixArrayField extends React.Component<FieldProps<JSONSchemaArray>, State> {
|
|
13
|
+
static propTypes: {
|
|
14
|
+
uiSchema: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
15
|
+
"ui:options": PropTypes.Requireable<PropTypes.InferProps<{
|
|
16
|
+
prefixValues: PropTypes.Validator<(string | null | undefined)[]>;
|
|
17
|
+
separator: PropTypes.Requireable<string>;
|
|
18
|
+
addFieldPlaceholder: PropTypes.Requireable<string>;
|
|
19
|
+
}>>;
|
|
20
|
+
uiSchema: PropTypes.Requireable<object>;
|
|
21
|
+
}>>>;
|
|
22
|
+
schema: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
23
|
+
type: PropTypes.Requireable<string>;
|
|
24
|
+
}>>>;
|
|
25
|
+
formData: PropTypes.Requireable<any[]>;
|
|
26
|
+
};
|
|
27
|
+
static getName(): string;
|
|
28
|
+
getSeparator(uiSchema: UiSchema): string;
|
|
29
|
+
getStateFromProps(props: FieldProps<JSONSchemaArray>): State;
|
|
30
|
+
onSelectFieldChange: (prefix: string) => void;
|
|
31
|
+
onFieldChange: ((idx: number) => (value: any) => void) & memoize.Memoized<(idx: number) => (value: any) => void>;
|
|
32
|
+
onFieldDelete: ((idx: number) => () => void) & memoize.Memoized<(idx: number) => () => void>;
|
|
33
|
+
render(): JSX.Element;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
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;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
42
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
const React = __importStar(require("react"));
|
|
46
|
+
const PropTypes = __importStar(require("prop-types"));
|
|
47
|
+
const SelectWidget_1 = __importDefault(require("../widgets/SelectWidget"));
|
|
48
|
+
const utils_1 = require("../../utils");
|
|
49
|
+
const components_1 = require("../components");
|
|
50
|
+
const memoizee_1 = __importDefault(require("memoizee"));
|
|
51
|
+
const immutability_helper_1 = __importDefault(require("immutability-helper"));
|
|
52
|
+
const BaseComponent_1 = __importDefault(require("../BaseComponent"));
|
|
53
|
+
let PrefixArrayField = class PrefixArrayField extends React.Component {
|
|
54
|
+
constructor() {
|
|
55
|
+
super(...arguments);
|
|
56
|
+
this.onSelectFieldChange = (prefix) => {
|
|
57
|
+
const separator = this.getSeparator(this.props.uiSchema);
|
|
58
|
+
const newFormData = [...(this.props.formData || []), prefix + separator];
|
|
59
|
+
this.props.onChange(newFormData);
|
|
60
|
+
};
|
|
61
|
+
this.onFieldChange = (0, memoizee_1.default)((idx) => (value) => {
|
|
62
|
+
const separator = this.getSeparator(this.props.uiSchema);
|
|
63
|
+
const newValue = this.state.fieldValues[idx].prefix + separator + value;
|
|
64
|
+
const newFormData = (0, immutability_helper_1.default)(this.props.formData, { [idx]: { $set: newValue } });
|
|
65
|
+
this.props.onChange(newFormData);
|
|
66
|
+
});
|
|
67
|
+
this.onFieldDelete = (0, memoizee_1.default)((idx) => () => {
|
|
68
|
+
const newFormData = (0, immutability_helper_1.default)(this.props.formData, { $splice: [[idx, 1]] });
|
|
69
|
+
this.props.onChange(newFormData);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
static getName() { return "PrefixArrayField"; }
|
|
73
|
+
getSeparator(uiSchema) {
|
|
74
|
+
const { separator = ":" } = (0, utils_1.getUiOptions)(uiSchema);
|
|
75
|
+
return separator;
|
|
76
|
+
}
|
|
77
|
+
getStateFromProps(props) {
|
|
78
|
+
const { formData = [], uiSchema } = props;
|
|
79
|
+
const separator = this.getSeparator(uiSchema);
|
|
80
|
+
return {
|
|
81
|
+
fieldValues: formData.map((value) => {
|
|
82
|
+
const sepIdx = value.indexOf(separator);
|
|
83
|
+
return {
|
|
84
|
+
prefix: value.substring(0, sepIdx),
|
|
85
|
+
value: value.substring(sepIdx + 1)
|
|
86
|
+
};
|
|
87
|
+
})
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
render() {
|
|
91
|
+
const SchemaField = this.props.registry.fields.SchemaField;
|
|
92
|
+
const { schema, uiSchema, idSchema, errorSchema, required, formContext: { Label, translations } } = this.props;
|
|
93
|
+
const { prefixValues = [], addFieldPlaceholder } = (0, utils_1.getUiOptions)(uiSchema);
|
|
94
|
+
const childProps = this.state.fieldValues.map((value, idx) => {
|
|
95
|
+
return {
|
|
96
|
+
schema: schema.items,
|
|
97
|
+
uiSchema: {
|
|
98
|
+
"ui:title": "",
|
|
99
|
+
"ui:widget": "InputGroupWidget",
|
|
100
|
+
"ui:options": Object.assign({ "inputGroupText": value.prefix, "className": "condensed-object-field-input-group" }, (uiSchema["ui:options"] || {})),
|
|
101
|
+
},
|
|
102
|
+
idSchema: { $id: `${idSchema.$id}_${idx}` },
|
|
103
|
+
errorSchema: errorSchema[idx] || {},
|
|
104
|
+
formData: value.value
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
const selectableFieldEnums = prefixValues.map((value) => ({
|
|
108
|
+
value,
|
|
109
|
+
label: value
|
|
110
|
+
}));
|
|
111
|
+
return (React.createElement(React.Fragment, null,
|
|
112
|
+
React.createElement(Label, { label: this.props.schema.title, required: required || uiSchema["ui:required"], id: this.props.idSchema.$id, uiSchema: this.props.uiSchema }),
|
|
113
|
+
childProps.map((props, idx) => React.createElement("div", { key: idx, className: "laji-form-field-template-item condensed-object-field-item" },
|
|
114
|
+
React.createElement("div", { className: "laji-form-field-template-schema" },
|
|
115
|
+
React.createElement(SchemaField, Object.assign({}, this.props, props, { key: idx, onChange: this.onFieldChange(idx) }))),
|
|
116
|
+
React.createElement("div", { className: "laji-form-field-template-buttons" },
|
|
117
|
+
React.createElement(components_1.DeleteButton, { id: props.idSchema.$id, onClick: this.onFieldDelete(idx), translations: translations })))),
|
|
118
|
+
React.createElement(SelectWidget_1.default, { key: childProps.length, options: { enumOptions: selectableFieldEnums, placeholder: addFieldPlaceholder !== null && addFieldPlaceholder !== void 0 ? addFieldPlaceholder : `${translations.AddField}` }, onChange: this.onSelectFieldChange, includeEmpty: true, schema: {}, id: `${idSchema.$id}_field_select`, formContext: this.props.formContext, disabled: this.props.disabled, readonly: this.props.readonly })));
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
PrefixArrayField.propTypes = {
|
|
122
|
+
uiSchema: PropTypes.shape({
|
|
123
|
+
"ui:options": PropTypes.shape({
|
|
124
|
+
prefixValues: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
125
|
+
separator: PropTypes.string,
|
|
126
|
+
addFieldPlaceholder: PropTypes.string
|
|
127
|
+
}),
|
|
128
|
+
uiSchema: PropTypes.object
|
|
129
|
+
}).isRequired,
|
|
130
|
+
schema: PropTypes.shape({
|
|
131
|
+
type: PropTypes.oneOf(["array"])
|
|
132
|
+
}).isRequired,
|
|
133
|
+
formData: PropTypes.array
|
|
134
|
+
};
|
|
135
|
+
PrefixArrayField = __decorate([
|
|
136
|
+
BaseComponent_1.default
|
|
137
|
+
], PrefixArrayField);
|
|
138
|
+
exports.default = PrefixArrayField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { FieldProps } from "../../types";
|
|
3
3
|
export default class _SchemaField extends React.Component<FieldProps> {
|
|
4
|
-
applyFunction(props: FieldProps): FieldProps
|
|
4
|
+
applyFunction(props: FieldProps): FieldProps;
|
|
5
5
|
render(): JSX.Element;
|
|
6
6
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -11,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
11
15
|
}) : function(o, v) {
|
|
12
16
|
o["default"] = v;
|
|
13
17
|
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
21
35
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
22
36
|
var t = {};
|
|
23
37
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -39,7 +53,7 @@ const types_1 = require("../../types");
|
|
|
39
53
|
class _SchemaField extends React.Component {
|
|
40
54
|
applyFunction(props) {
|
|
41
55
|
let _a = (props.uiSchema || {}), { "ui:functions": functions, "ui:childFunctions": childFunctions, "ui:annotations": annotations, "ui:multiLanguage": multiLanguage } = _a, _uiSchema = __rest(_a, ["ui:functions", "ui:childFunctions", "ui:annotations", "ui:multiLanguage"]);
|
|
42
|
-
functions = functions ? utils_1.asArray(functions) : [];
|
|
56
|
+
functions = functions ? (0, utils_1.asArray)(functions) : [];
|
|
43
57
|
if (childFunctions) {
|
|
44
58
|
functions = [
|
|
45
59
|
{ "ui:field": "UiFieldMapperArrayField", "ui:options": { functions: childFunctions } },
|
|
@@ -48,7 +62,7 @@ class _SchemaField extends React.Component {
|
|
|
48
62
|
}
|
|
49
63
|
if (annotations) {
|
|
50
64
|
functions = [
|
|
51
|
-
{ "ui:field": "AnnotationField", "ui:options": (utils_2.isObject(annotations) ? annotations : {}) },
|
|
65
|
+
{ "ui:field": "AnnotationField", "ui:options": ((0, utils_2.isObject)(annotations) ? annotations : {}) },
|
|
52
66
|
...functions
|
|
53
67
|
];
|
|
54
68
|
}
|
|
@@ -64,11 +78,11 @@ class _SchemaField extends React.Component {
|
|
|
64
78
|
let [uiFn, ...restUiFns] = functions;
|
|
65
79
|
const { "ui:injections": injections } = uiFn;
|
|
66
80
|
if (injections) {
|
|
67
|
-
const injectedUiSchema = ContextInjectionField_1.getInjectedUiSchema(uiFn, injections, props.registry.formContext.uiSchemaContext);
|
|
81
|
+
const injectedUiSchema = (0, ContextInjectionField_1.getInjectedUiSchema)(uiFn, injections, props.registry.formContext.uiSchemaContext);
|
|
68
82
|
uiFn = Object.assign(Object.assign({}, injectedUiSchema), { "ui:injections": undefined });
|
|
69
83
|
}
|
|
70
|
-
const buttons = !_props.uiSchema["ui:field"] ? utils_1.getUiOptions(_props.uiSchema).buttons : undefined;
|
|
71
|
-
const uiButtons = !_props.uiSchema["ui:field"] ? utils_1.getUiOptions(_props.uiSchema)["ui:buttons"] : undefined;
|
|
84
|
+
const buttons = !_props.uiSchema["ui:field"] ? (0, utils_1.getUiOptions)(_props.uiSchema).buttons : undefined;
|
|
85
|
+
const uiButtons = !_props.uiSchema["ui:field"] ? (0, utils_1.getUiOptions)(_props.uiSchema)["ui:buttons"] : undefined;
|
|
72
86
|
_props = Object.assign(Object.assign({}, _props), { uiSchema: (_props.uiSchema["ui:field"] || _props.uiSchema["ui:widget"])
|
|
73
87
|
? Object.assign(Object.assign({}, uiFn), { uiSchema: _props.uiSchema }) : Object.assign(Object.assign({}, _props.uiSchema), uiFn) });
|
|
74
88
|
if (buttons || uiButtons) {
|
|
@@ -79,21 +93,21 @@ class _SchemaField extends React.Component {
|
|
|
79
93
|
render() {
|
|
80
94
|
var _a, _b;
|
|
81
95
|
const props = this.applyFunction(this.props);
|
|
82
|
-
let { schema, uiSchema = {}, formContext, registry } = props, _props = __rest(props, ["schema", "uiSchema", "formContext", "registry"]);
|
|
96
|
+
let { schema, uiSchema = {}, formContext, registry } = props, _props = __rest(props, ["schema", "uiSchema", "formContext", "registry"]);
|
|
83
97
|
const { formContext: _formContext } = registry;
|
|
84
98
|
// rjsf displays a duplicate label if 'uniqueItems' is true in some cases. We prevent that here.
|
|
85
99
|
// Example of when it shows duplicate is http://localhost:8083/?id=JX.652&local=true, "Elinympäristö" on gathering
|
|
86
100
|
// level.
|
|
87
|
-
if (types_1.isJSONSchemaArray(schema) && ((_a = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema.items) === null || _a === void 0 ? void 0 : _a["ui:field"])) {
|
|
101
|
+
if ((0, types_1.isJSONSchemaArray)(schema) && ((_a = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema.items) === null || _a === void 0 ? void 0 : _a["ui:field"])) {
|
|
88
102
|
schema = Object.assign(Object.assign({}, schema), { uniqueItems: false });
|
|
89
103
|
}
|
|
90
|
-
const options = utils_1.getUiOptions(uiSchema);
|
|
104
|
+
const options = (0, utils_1.getUiOptions)(uiSchema);
|
|
91
105
|
if (typeof options.label === "string") {
|
|
92
106
|
schema = Object.assign(Object.assign({}, schema), { title: options.label });
|
|
93
107
|
}
|
|
94
108
|
const { "ui:injections": injections } = uiSchema;
|
|
95
109
|
if (injections) {
|
|
96
|
-
const injectedUiSchema = ContextInjectionField_1.getInjectedUiSchema(uiSchema, injections, _formContext.uiSchemaContext);
|
|
110
|
+
const injectedUiSchema = (0, ContextInjectionField_1.getInjectedUiSchema)(uiSchema, injections, _formContext.uiSchemaContext);
|
|
97
111
|
uiSchema = Object.assign(Object.assign({}, injectedUiSchema), { "ui:injections": undefined });
|
|
98
112
|
}
|
|
99
113
|
// Remove unnecessary formDataTransformers in order to prevent unnecessary rendering.
|
|
@@ -105,12 +119,12 @@ class _SchemaField extends React.Component {
|
|
|
105
119
|
registry = Object.assign(Object.assign({}, registry), { formContext: Object.assign(Object.assign({}, _formContext), { formDataTransformers: filtered }) });
|
|
106
120
|
}
|
|
107
121
|
}
|
|
108
|
-
const idPointer = props.idSchema.$id ? utils_1.idSchemaIdToJSONPointer(props.idSchema.$id) : undefined;
|
|
122
|
+
const idPointer = props.idSchema.$id ? (0, utils_1.idSchemaIdToJSONPointer)(props.idSchema.$id) : undefined;
|
|
109
123
|
if (idPointer && ((_b = _formContext.uiSchemaContext.additionalClassNames) === null || _b === void 0 ? void 0 : _b[idPointer])) {
|
|
110
124
|
const additionalClassNames = _formContext.uiSchemaContext.additionalClassNames[idPointer];
|
|
111
|
-
uiSchema = Object.assign(Object.assign({}, uiSchema), { "ui:classNames": utils_1.classNames(uiSchema["ui:classNames"], additionalClassNames) });
|
|
125
|
+
uiSchema = Object.assign(Object.assign({}, uiSchema), { "ui:classNames": (0, utils_1.classNames)(uiSchema["ui:classNames"], additionalClassNames) });
|
|
112
126
|
}
|
|
113
|
-
const { SchemaField } = core_1.getDefaultRegistry().fields;
|
|
127
|
+
const { SchemaField } = (0, core_1.getDefaultRegistry)().fields;
|
|
114
128
|
return React.createElement(SchemaField, Object.assign({}, _props, { registry: registry, schema: schema, uiSchema: uiSchema }));
|
|
115
129
|
}
|
|
116
130
|
}
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
export default class ScopeField extends React.Component<any, any, any> {
|
|
34
34
|
static contextType: React.Context<import("../../ReactContext").ContextProps>;
|
|
35
35
|
static propTypes: {
|
|
36
|
-
uiSchema: PropTypes.Validator<PropTypes.InferProps<{
|
|
37
|
-
"ui:options": PropTypes.Validator<PropTypes.InferProps<{
|
|
36
|
+
uiSchema: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
37
|
+
"ui:options": PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
38
38
|
includeAdditionalFieldsChooserButton: PropTypes.Requireable<boolean>;
|
|
39
39
|
additionalsGroupingPath: PropTypes.Requireable<string>;
|
|
40
40
|
additionalsGroupsTranslator: PropTypes.Requireable<string>;
|
|
@@ -44,15 +44,23 @@ export default class ScopeField extends React.Component<any, any, any> {
|
|
|
44
44
|
fields: PropTypes.Requireable<(string | null | undefined)[]>;
|
|
45
45
|
definitions: PropTypes.Requireable<object>;
|
|
46
46
|
uiSchema: PropTypes.Requireable<object>;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
47
|
+
}>>>;
|
|
48
|
+
}>>>;
|
|
49
|
+
schema: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
50
50
|
type: PropTypes.Requireable<string>;
|
|
51
|
-
}
|
|
51
|
+
}>>>;
|
|
52
52
|
formData: PropTypes.Validator<object>;
|
|
53
53
|
};
|
|
54
54
|
constructor(props: any);
|
|
55
|
+
state: {
|
|
56
|
+
includeAdditionalFieldsChooserButton: boolean;
|
|
57
|
+
};
|
|
58
|
+
UNSAFE_componentWillReceiveProps(props: any): void;
|
|
59
|
+
componentDidMount(): void;
|
|
55
60
|
mounted: boolean | undefined;
|
|
61
|
+
componentWillUnmount(): void;
|
|
62
|
+
render(): JSX.Element;
|
|
63
|
+
componentDidUpdate(prevProps: any, prevState: any): void;
|
|
56
64
|
getAdditionalPersistenceValue: (props: any, includeUndefined?: boolean) => any[];
|
|
57
65
|
getStateFromProps(props: any): {
|
|
58
66
|
includeAdditionalFieldsChooserButton: boolean;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -11,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
11
15
|
}) : function(o, v) {
|
|
12
16
|
o["default"] = v;
|
|
13
17
|
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
21
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
37
|
};
|
|
@@ -80,10 +94,10 @@ class ScopeField extends React.Component {
|
|
|
80
94
|
constructor(props) {
|
|
81
95
|
super(props);
|
|
82
96
|
this.getAdditionalPersistenceValue = (props, includeUndefined = true) => {
|
|
83
|
-
const { additionalsPersistenceField, additionalPersistenceContextKey } = utils_1.getUiOptions(props.uiSchema);
|
|
97
|
+
const { additionalsPersistenceField, additionalPersistenceContextKey } = (0, utils_1.getUiOptions)(props.uiSchema);
|
|
84
98
|
let formDataItem = props.formData[additionalsPersistenceField];
|
|
85
99
|
if (additionalPersistenceContextKey && (formDataItem === undefined || Array.isArray(formDataItem) && formDataItem.length === 0)) {
|
|
86
|
-
formDataItem = Context_1.default(this.props.formContext.contextId)[additionalPersistenceContextKey];
|
|
100
|
+
formDataItem = (0, Context_1.default)(this.props.formContext.contextId)[additionalPersistenceContextKey];
|
|
87
101
|
}
|
|
88
102
|
let items = (Array.isArray(formDataItem) ? formDataItem : [formDataItem]);
|
|
89
103
|
if (includeUndefined)
|
|
@@ -99,9 +113,9 @@ class ScopeField extends React.Component {
|
|
|
99
113
|
}
|
|
100
114
|
});
|
|
101
115
|
let defaultFields = (state && state.defaultFields) ? Object.assign({}, state.defaultFields) : {};
|
|
102
|
-
const options = utils_1.getUiOptions(uiSchema);
|
|
116
|
+
const options = (0, utils_1.getUiOptions)(uiSchema);
|
|
103
117
|
let { fields, definitions, glyphFields = [], geometryField = "unitGathering_geometry", taxonField } = options;
|
|
104
|
-
let generatedUiSchema = utils_1.getInnerUiSchema(uiSchema);
|
|
118
|
+
let generatedUiSchema = (0, utils_1.getInnerUiSchema)(uiSchema);
|
|
105
119
|
let fieldsToShow = {};
|
|
106
120
|
(fields || []).forEach(field => {
|
|
107
121
|
fieldsToShow[field] = schema.properties[field];
|
|
@@ -124,7 +138,7 @@ class ScopeField extends React.Component {
|
|
|
124
138
|
let refs = fieldScope.refs;
|
|
125
139
|
fieldScope = Object.assign(Object.assign({}, fieldScope), { refs: undefined });
|
|
126
140
|
refs.forEach(ref => {
|
|
127
|
-
fieldScope = deepmerge_1.default(fieldScope, definitions[ref]);
|
|
141
|
+
fieldScope = (0, deepmerge_1.default)(fieldScope, definitions[ref]);
|
|
128
142
|
});
|
|
129
143
|
}
|
|
130
144
|
const { excludeFields = [], fields: _fields = [], defaultFields: _defaultFields = [] } = fieldScope;
|
|
@@ -143,7 +157,7 @@ class ScopeField extends React.Component {
|
|
|
143
157
|
});
|
|
144
158
|
if (fieldScope.uiSchema) {
|
|
145
159
|
const { uiSchemaMergeType = "merge" } = fieldScope;
|
|
146
|
-
generatedUiSchema = ConditionalUiSchemaField_1.computeUiSchema(generatedUiSchema, { type: uiSchemaMergeType, uiSchema: fieldScope.uiSchema });
|
|
160
|
+
generatedUiSchema = (0, ConditionalUiSchemaField_1.computeUiSchema)(generatedUiSchema, { type: uiSchemaMergeType, uiSchema: fieldScope.uiSchema });
|
|
147
161
|
}
|
|
148
162
|
if (fieldScope.fieldScopes) {
|
|
149
163
|
addFieldScopeFieldsToFieldsToShow(fieldScope);
|
|
@@ -162,14 +176,14 @@ class ScopeField extends React.Component {
|
|
|
162
176
|
}
|
|
163
177
|
if (!Array.isArray(fieldSelectorValues))
|
|
164
178
|
fieldSelectorValues = [fieldSelectorValues];
|
|
165
|
-
if (scopes[fieldSelector]["+"] && fieldSelectorValues.length > 0 && fieldSelectorValues.some(_fieldSelectorValue => _fieldSelectorValue !== "undefined" && utils_1.hasData(_fieldSelectorValue) && !utils_1.isDefaultData(_fieldSelectorValue, schema.properties[fieldSelector]))) {
|
|
179
|
+
if (scopes[fieldSelector]["+"] && fieldSelectorValues.length > 0 && fieldSelectorValues.some(_fieldSelectorValue => _fieldSelectorValue !== "undefined" && (0, utils_1.hasData)(_fieldSelectorValue) && !(0, utils_1.isDefaultData)(_fieldSelectorValue, schema.properties[fieldSelector]))) {
|
|
166
180
|
addFieldSelectorsValues(scopes, fieldSelector, "+");
|
|
167
181
|
}
|
|
168
182
|
if (scopes[fieldSelector]["*"]) {
|
|
169
183
|
addFieldSelectorsValues(scopes, fieldSelector, "*");
|
|
170
184
|
}
|
|
171
185
|
fieldSelectorValues.forEach(fieldSelectorValue => {
|
|
172
|
-
if (utils_1.hasData(fieldSelectorValue) && !utils_1.isDefaultData(fieldSelectorValue, schema.properties[fieldSelector].type === "array" ? schema.properties[fieldSelector].items : schema.properties[fieldSelector])) {
|
|
186
|
+
if ((0, utils_1.hasData)(fieldSelectorValue) && !(0, utils_1.isDefaultData)(fieldSelectorValue, schema.properties[fieldSelector].type === "array" ? schema.properties[fieldSelector].items : schema.properties[fieldSelector])) {
|
|
173
187
|
addFieldSelectorsValues(scopes, fieldSelector, fieldSelectorValue);
|
|
174
188
|
}
|
|
175
189
|
});
|
|
@@ -210,7 +224,7 @@ class ScopeField extends React.Component {
|
|
|
210
224
|
Object.keys(formData).forEach((property) => {
|
|
211
225
|
if (!schema.properties[property])
|
|
212
226
|
return;
|
|
213
|
-
const isDefault = utils_1.isDefaultData(formData[property], schema.properties[property]);
|
|
227
|
+
const isDefault = (0, utils_1.isDefaultData)(formData[property], schema.properties[property]);
|
|
214
228
|
if (!isDefault) {
|
|
215
229
|
fieldsToShow[property] = props.schema.properties[property];
|
|
216
230
|
}
|
|
@@ -231,7 +245,7 @@ class ScopeField extends React.Component {
|
|
|
231
245
|
}
|
|
232
246
|
};
|
|
233
247
|
const uiFunctions = generatedUiSchema["ui:functions"]
|
|
234
|
-
? utils_1.isObject(generatedUiSchema["ui:functions"])
|
|
248
|
+
? (0, utils_1.isObject)(generatedUiSchema["ui:functions"])
|
|
235
249
|
? [generatedUiSchema["ui:functions"], locationFn]
|
|
236
250
|
: [...generatedUiSchema["ui:functions"], locationFn]
|
|
237
251
|
: [locationFn];
|
|
@@ -256,7 +270,7 @@ class ScopeField extends React.Component {
|
|
|
256
270
|
}
|
|
257
271
|
return [];
|
|
258
272
|
}
|
|
259
|
-
const { additionalsGroupingPath } = utils_1.getUiOptions(this.props.uiSchema);
|
|
273
|
+
const { additionalsGroupingPath } = (0, utils_1.getUiOptions)(this.props.uiSchema);
|
|
260
274
|
let additionalProperties = {};
|
|
261
275
|
Object.keys(this.props.schema.properties).forEach(property => {
|
|
262
276
|
if (!this.state.fieldsToShow[property] ||
|
|
@@ -281,10 +295,10 @@ class ScopeField extends React.Component {
|
|
|
281
295
|
this.renderFieldsModal = (additionalProperties) => {
|
|
282
296
|
const { translations } = this.props.formContext;
|
|
283
297
|
let list = [];
|
|
284
|
-
const options = utils_1.getUiOptions(this.props.uiSchema);
|
|
298
|
+
const options = (0, utils_1.getUiOptions)(this.props.uiSchema);
|
|
285
299
|
const { additionalsGroupingPath } = options;
|
|
286
300
|
let groupTranslations = this.state.additionalsGroupsTranslations;
|
|
287
|
-
const groups = additionalsGroupingPath ? utils_1.parseJSONPointer(options, additionalsGroupingPath) : {};
|
|
301
|
+
const groups = additionalsGroupingPath ? (0, utils_1.parseJSONPointer)(options, additionalsGroupingPath) : {};
|
|
288
302
|
const additionalsPersistenceValue = this.getAdditionalPersistenceValue(this.props);
|
|
289
303
|
let groupNames = Object.keys(groups);
|
|
290
304
|
if (additionalsPersistenceValue)
|
|
@@ -307,7 +321,7 @@ class ScopeField extends React.Component {
|
|
|
307
321
|
React.createElement(components_1.GlyphButton, { glyph: "cog", onClick: this.onToggleAdditionals, id: `${this.props.idSchema.$id}-additionals`, variant: "primary" })));
|
|
308
322
|
};
|
|
309
323
|
this.renderGlyphFields = () => {
|
|
310
|
-
const { glyphFields } = utils_1.getUiOptions(this.props.uiSchema);
|
|
324
|
+
const { glyphFields } = (0, utils_1.getUiOptions)(this.props.uiSchema);
|
|
311
325
|
return glyphFields ?
|
|
312
326
|
glyphFields.filter(settings => !settings.fn || settings.fn !== "setLocation").map((settings, i) => React.createElement(GlyphField, { key: i, settings: settings, idSchema: this.props.idSchema, formData: this.props.formData, schema: this.props.schema, registry: this.props.registry, isIncluded: this.propertyIsIncluded(settings.show), toggleAdditionalProperty: this.toggleAdditionalProperty })) : null;
|
|
313
327
|
};
|
|
@@ -317,7 +331,7 @@ class ScopeField extends React.Component {
|
|
|
317
331
|
return !!isIncluded;
|
|
318
332
|
};
|
|
319
333
|
this.toggleAdditionalProperty = (fields) => {
|
|
320
|
-
const { additionalsPersistenceField, additionalsPersistenceKey } = utils_1.getUiOptions(this.props.uiSchema);
|
|
334
|
+
const { additionalsPersistenceField, additionalsPersistenceKey } = (0, utils_1.getUiOptions)(this.props.uiSchema);
|
|
321
335
|
if (!Array.isArray(fields))
|
|
322
336
|
fields = [fields];
|
|
323
337
|
const additionalFields = fields.reduce((additionalFields, field) => {
|
|
@@ -344,11 +358,11 @@ class ScopeField extends React.Component {
|
|
|
344
358
|
this.setState(Object.assign({ additionalFields }, this.getSchemasAndAdditionals(this.props, Object.assign(Object.assign({}, this.state), { additionalFields }))));
|
|
345
359
|
};
|
|
346
360
|
this.additionalPropertiesToList = (properties, ElemType) => {
|
|
347
|
-
const titles = utils_1.getUiOptions(this.props.uiSchema).titles || {};
|
|
348
|
-
return utils_2.orderProperties(Object.keys(properties), this.props.uiSchema["ui:order"])
|
|
361
|
+
const titles = (0, utils_1.getUiOptions)(this.props.uiSchema).titles || {};
|
|
362
|
+
return (0, utils_2.orderProperties)(Object.keys(properties), this.props.uiSchema["ui:order"])
|
|
349
363
|
.map(property => {
|
|
350
364
|
const isIncluded = this.propertyIsIncluded(property);
|
|
351
|
-
const hasData = utils_1.propertyHasData(property, this.props.formData) && (!this.props.formData || !utils_1.isDefaultData(this.props.formData[property], this.props.schema.properties[property]));
|
|
365
|
+
const hasData = (0, utils_1.propertyHasData)(property, this.props.formData) && (!this.props.formData || !(0, utils_1.isDefaultData)(this.props.formData[property], this.props.schema.properties[property]));
|
|
352
366
|
if (!this.propertyTogglers) {
|
|
353
367
|
this.propertyTogglers = {};
|
|
354
368
|
}
|
|
@@ -359,18 +373,18 @@ class ScopeField extends React.Component {
|
|
|
359
373
|
});
|
|
360
374
|
};
|
|
361
375
|
this.translateAdditionalsGroups = (props) => {
|
|
362
|
-
let options = utils_1.getUiOptions(props.uiSchema);
|
|
376
|
+
let options = (0, utils_1.getUiOptions)(props.uiSchema);
|
|
363
377
|
const { additionalsGroupingPath, additionalsGroupsTranslator } = options;
|
|
364
378
|
if (!additionalsGroupingPath)
|
|
365
379
|
return;
|
|
366
|
-
const groups = utils_1.parseJSONPointer(options, additionalsGroupingPath);
|
|
367
|
-
const groupNames = Object.keys(groups).filter(groupName => !utils_1.isNullOrUndefined(groups[groupName]));
|
|
380
|
+
const groups = (0, utils_1.parseJSONPointer)(options, additionalsGroupingPath);
|
|
381
|
+
const groupNames = Object.keys(groups).filter(groupName => !(0, utils_1.isNullOrUndefined)(groups[groupName]));
|
|
368
382
|
let translations = {};
|
|
369
383
|
let translationsToKeys = {};
|
|
370
384
|
let translationCount = 0;
|
|
371
385
|
groupNames.forEach(groupName => {
|
|
372
386
|
const title = groups[groupName].title;
|
|
373
|
-
const promise = (!utils_1.isNullOrUndefined(title)) ?
|
|
387
|
+
const promise = (!(0, utils_1.isNullOrUndefined)(title)) ?
|
|
374
388
|
new Promise(resolve => resolve(title)) :
|
|
375
389
|
scopeFieldSettings[additionalsGroupsTranslator].translate(props, groupName);
|
|
376
390
|
promise.then(translation => {
|
|
@@ -402,7 +416,7 @@ class ScopeField extends React.Component {
|
|
|
402
416
|
}
|
|
403
417
|
render() {
|
|
404
418
|
const SchemaField = this.props.registry.fields.SchemaField;
|
|
405
|
-
const { additionalsGroupingPath } = utils_1.getUiOptions(this.props.uiSchema);
|
|
419
|
+
const { additionalsGroupingPath } = (0, utils_1.getUiOptions)(this.props.uiSchema);
|
|
406
420
|
let uiSchema = Object.assign(Object.assign({}, this.state.uiSchema), { "ui:buttons": [
|
|
407
421
|
...(this.props.uiSchema["ui:buttons"] || []),
|
|
408
422
|
...this.renderAdditionalsButtons()
|
|
@@ -421,7 +435,7 @@ class ScopeField extends React.Component {
|
|
|
421
435
|
componentDidUpdate(prevProps, prevState) {
|
|
422
436
|
if (this.state.additionalsOpen
|
|
423
437
|
&& (!this.state.additionalsGroupsTranslations || prevProps.formContext.lang !== this.props.formContext.lang ||
|
|
424
|
-
utils_1.getUiOptions(prevProps.uiSchema).additionalsGroupsTranslator !== utils_1.getUiOptions(this.props.uiSchema).additionalsGroupsTranslator)) {
|
|
438
|
+
(0, utils_1.getUiOptions)(prevProps.uiSchema).additionalsGroupsTranslator !== (0, utils_1.getUiOptions)(this.props.uiSchema).additionalsGroupsTranslator)) {
|
|
425
439
|
this.translateAdditionalsGroups(this.props);
|
|
426
440
|
}
|
|
427
441
|
if (!equals(prevState.fieldsToShow, this.state.fieldsToShow)) {
|
|
@@ -429,12 +443,12 @@ class ScopeField extends React.Component {
|
|
|
429
443
|
}
|
|
430
444
|
}
|
|
431
445
|
getStateFromProps(props) {
|
|
432
|
-
const options = utils_1.getUiOptions(props.uiSchema);
|
|
446
|
+
const options = (0, utils_1.getUiOptions)(props.uiSchema);
|
|
433
447
|
const includeAdditionalFieldsChooserButton = !!options.includeAdditionalFieldsChooserButton;
|
|
434
448
|
let state = {
|
|
435
449
|
includeAdditionalFieldsChooserButton
|
|
436
450
|
};
|
|
437
|
-
const { additionalsPersistenceField, additionalsPersistenceKey } = utils_1.getUiOptions(props.uiSchema);
|
|
451
|
+
const { additionalsPersistenceField, additionalsPersistenceKey } = (0, utils_1.getUiOptions)(props.uiSchema);
|
|
438
452
|
let additionalFields = additionalsPersistenceField
|
|
439
453
|
? {}
|
|
440
454
|
: (this.state ? this.state.additionalFields : {});
|
|
@@ -470,7 +484,6 @@ class ScopeField extends React.Component {
|
|
|
470
484
|
React.createElement(Dropdown.Menu, { onSelect: this.onSelect }, this.additionalPropertiesToList(additionalProperties, MenuItem)))));
|
|
471
485
|
}
|
|
472
486
|
}
|
|
473
|
-
exports.default = ScopeField;
|
|
474
487
|
ScopeField.contextType = ReactContext_1.default;
|
|
475
488
|
ScopeField.propTypes = {
|
|
476
489
|
uiSchema: PropTypes.shape({
|
|
@@ -491,10 +504,11 @@ ScopeField.propTypes = {
|
|
|
491
504
|
}).isRequired,
|
|
492
505
|
formData: PropTypes.object.isRequired
|
|
493
506
|
};
|
|
507
|
+
exports.default = ScopeField;
|
|
494
508
|
const getGroupFields = (group, additionalProperties, schema) => {
|
|
495
509
|
const { fields = [], additionalFields = [] } = group;
|
|
496
|
-
const additionalFieldsDict = utils_1.dictionarify(additionalFields);
|
|
497
|
-
let combinedFields = Object.keys(Object.assign(Object.assign({}, utils_1.dictionarify(fields)), additionalFieldsDict));
|
|
510
|
+
const additionalFieldsDict = (0, utils_1.dictionarify)(additionalFields);
|
|
511
|
+
let combinedFields = Object.keys(Object.assign(Object.assign({}, (0, utils_1.dictionarify)(fields)), additionalFieldsDict));
|
|
498
512
|
let groupFields = {};
|
|
499
513
|
combinedFields.forEach(field => {
|
|
500
514
|
if (additionalProperties[field]) {
|
|
@@ -535,9 +549,9 @@ function GlyphField({ settings, idSchema, formData, schema, isIncluded, toggleAd
|
|
|
535
549
|
if (!show) {
|
|
536
550
|
return null;
|
|
537
551
|
}
|
|
538
|
-
const hasData = utils_1.propertyHasData(property, formData) && (!formData || !utils_1.isDefaultData(formData[property], schema.properties[property]));
|
|
552
|
+
const hasData = (0, utils_1.propertyHasData)(property, formData) && (!formData || !(0, utils_1.isDefaultData)(formData[property], schema.properties[property]));
|
|
539
553
|
const tooltip = React.createElement(Tooltip, { id: `${idSchema.$id}-${property}-tooltip-${glyph}` }, label);
|
|
540
554
|
return (React.createElement(OverlayTrigger, { key: property, overlay: tooltip, placement: "left" },
|
|
541
555
|
React.createElement(components_1.GlyphButton, { glyph: glyph, disabled: hasData, active: isIncluded, onClick: onButtonClick })));
|
|
542
556
|
}
|
|
543
|
-
Context_1.default("SCHEMA_FIELD_WRAPPERS").ScopeField = true;
|
|
557
|
+
(0, Context_1.default)("SCHEMA_FIELD_WRAPPERS").ScopeField = true;
|
|
@@ -3,9 +3,9 @@ export default class SectionArrayField extends React.Component<any, any, any> {
|
|
|
3
3
|
uiSchema: PropTypes.Requireable<PropTypes.InferProps<{
|
|
4
4
|
"ui:options": PropTypes.Requireable<PropTypes.InferProps<{}>>;
|
|
5
5
|
}>>;
|
|
6
|
-
schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
6
|
+
schema: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
7
7
|
type: PropTypes.Requireable<string>;
|
|
8
|
-
}
|
|
8
|
+
}>>>;
|
|
9
9
|
formData: PropTypes.Requireable<any[]>;
|
|
10
10
|
};
|
|
11
11
|
static getName(): string;
|