@luomus/laji-form 15.1.0 → 15.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -4
- package/dist/laji-form.js +1 -1
- package/jsonconfig.json +26 -0
- package/migrate.sh +0 -1
- package/package.json +8 -8
- package/test-export/test-utils.d.ts +100 -54
- package/test-export/test-utils.js +102 -84
- package/xsel -b +9 -0
- package/cypress/fixtures/example.json +0 -5
- package/cypress/screenshots/nafi.cy.ts/NAFI (MHL.6) -- selecting species name with keyboard navigation -- and closes suggestion list (failed).png +0 -0
- package/cypress/screenshots/nafi.cy.ts/NAFI (MHL.6) -- selecting species name with keyboard navigation -- and is marked as suggested (failed).png +0 -0
- package/lib/ApiClient.d.ts +0 -46
- package/lib/ApiClient.js +0 -93
- package/lib/Context.d.ts +0 -8
- package/lib/Context.js +0 -18
- package/lib/ReactContext.d.ts +0 -7
- package/lib/ReactContext.js +0 -5
- package/lib/components/BaseComponent.d.ts +0 -9
- package/lib/components/BaseComponent.js +0 -29
- package/lib/components/LajiForm.d.ts +0 -221
- package/lib/components/LajiForm.js +0 -615
- package/lib/components/VirtualSchemaField.d.ts +0 -42
- package/lib/components/VirtualSchemaField.js +0 -74
- package/lib/components/components.d.ts +0 -119
- package/lib/components/components.js +0 -606
- package/lib/components/fields/AnnotationField.d.ts +0 -34
- package/lib/components/fields/AnnotationField.js +0 -242
- package/lib/components/fields/AnyToBooleanField.d.ts +0 -18
- package/lib/components/fields/AnyToBooleanField.js +0 -20
- package/lib/components/fields/ArrayBulkField.d.ts +0 -23
- package/lib/components/fields/ArrayBulkField.js +0 -82
- package/lib/components/fields/ArrayCombinerField.d.ts +0 -36
- package/lib/components/fields/ArrayCombinerField.js +0 -138
- package/lib/components/fields/ArrayField.d.ts +0 -39
- package/lib/components/fields/ArrayField.js +0 -148
- package/lib/components/fields/AudioArrayField.d.ts +0 -22
- package/lib/components/fields/AudioArrayField.js +0 -100
- package/lib/components/fields/AutoArrayField.d.ts +0 -24
- package/lib/components/fields/AutoArrayField.js +0 -56
- package/lib/components/fields/AutosuggestField.d.ts +0 -69
- package/lib/components/fields/AutosuggestField.js +0 -299
- package/lib/components/fields/CombinedValueDisplayField.d.ts +0 -41
- package/lib/components/fields/CombinedValueDisplayField.js +0 -100
- package/lib/components/fields/ConditionalOnChangeField.d.ts +0 -42
- package/lib/components/fields/ConditionalOnChangeField.js +0 -107
- package/lib/components/fields/ConditionalUiSchemaField.d.ts +0 -123
- package/lib/components/fields/ConditionalUiSchemaField.js +0 -143
- package/lib/components/fields/ContextInjectionField.d.ts +0 -24
- package/lib/components/fields/ContextInjectionField.js +0 -68
- package/lib/components/fields/DataLeakerField.d.ts +0 -40
- package/lib/components/fields/DataLeakerField.js +0 -68
- package/lib/components/fields/DefaultValueArrayField.d.ts +0 -34
- package/lib/components/fields/DefaultValueArrayField.js +0 -59
- package/lib/components/fields/DependentBooleanField.d.ts +0 -38
- package/lib/components/fields/DependentBooleanField.js +0 -87
- package/lib/components/fields/DependentDisableField.d.ts +0 -35
- package/lib/components/fields/DependentDisableField.js +0 -71
- package/lib/components/fields/EnumRangeArrayField.d.ts +0 -27
- package/lib/components/fields/EnumRangeArrayField.js +0 -115
- package/lib/components/fields/ExtraLabelRowField.d.ts +0 -38
- package/lib/components/fields/ExtraLabelRowField.js +0 -100
- package/lib/components/fields/FakePropertyField.d.ts +0 -18
- package/lib/components/fields/FakePropertyField.js +0 -48
- package/lib/components/fields/FilterArrayField.d.ts +0 -73
- package/lib/components/fields/FilterArrayField.js +0 -121
- package/lib/components/fields/FlatField.d.ts +0 -29
- package/lib/components/fields/FlatField.js +0 -171
- package/lib/components/fields/GeocoderField.d.ts +0 -47
- package/lib/components/fields/GeocoderField.js +0 -372
- package/lib/components/fields/GridLayoutField.d.ts +0 -18
- package/lib/components/fields/GridLayoutField.js +0 -32
- package/lib/components/fields/HiddenField.d.ts +0 -10
- package/lib/components/fields/HiddenField.js +0 -11
- package/lib/components/fields/ImageArrayField.d.ts +0 -172
- package/lib/components/fields/ImageArrayField.js +0 -697
- package/lib/components/fields/ImageDisplayField.d.ts +0 -18
- package/lib/components/fields/ImageDisplayField.js +0 -44
- package/lib/components/fields/InitiallyHiddenField.d.ts +0 -21
- package/lib/components/fields/InitiallyHiddenField.js +0 -58
- package/lib/components/fields/InjectDefaultValueField.d.ts +0 -37
- package/lib/components/fields/InjectDefaultValueField.js +0 -68
- package/lib/components/fields/InjectField.d.ts +0 -46
- package/lib/components/fields/InjectField.js +0 -88
- package/lib/components/fields/InputWithDefaultValueButtonField.d.ts +0 -25
- package/lib/components/fields/InputWithDefaultValueButtonField.js +0 -61
- package/lib/components/fields/LocalityField.d.ts +0 -22
- package/lib/components/fields/LocalityField.js +0 -94
- package/lib/components/fields/LocationChooserField.d.ts +0 -27
- package/lib/components/fields/LocationChooserField.js +0 -440
- package/lib/components/fields/MapArrayField.d.ts +0 -78
- package/lib/components/fields/MapArrayField.js +0 -1783
- package/lib/components/fields/MapField.d.ts +0 -48
- package/lib/components/fields/MapField.js +0 -434
- package/lib/components/fields/MultiAnyToBooleanField.d.ts +0 -25
- package/lib/components/fields/MultiAnyToBooleanField.js +0 -100
- package/lib/components/fields/MultiArrayField.d.ts +0 -53
- package/lib/components/fields/MultiArrayField.js +0 -224
- package/lib/components/fields/MultiLanguageField.d.ts +0 -13
- package/lib/components/fields/MultiLanguageField.js +0 -52
- package/lib/components/fields/MultiTagArrayField.d.ts +0 -36
- package/lib/components/fields/MultiTagArrayField.js +0 -142
- package/lib/components/fields/NamedPlaceChooserField.d.ts +0 -29
- package/lib/components/fields/NamedPlaceChooserField.js +0 -380
- package/lib/components/fields/NamedPlaceSaverField.d.ts +0 -29
- package/lib/components/fields/NamedPlaceSaverField.js +0 -237
- package/lib/components/fields/NestField.d.ts +0 -148
- package/lib/components/fields/NestField.js +0 -289
- package/lib/components/fields/ObjectField.d.ts +0 -2
- package/lib/components/fields/ObjectField.js +0 -119
- package/lib/components/fields/PdfArrayField.d.ts +0 -21
- package/lib/components/fields/PdfArrayField.js +0 -40
- package/lib/components/fields/PrefillingArrayField.d.ts +0 -22
- package/lib/components/fields/PrefillingArrayField.js +0 -65
- package/lib/components/fields/SchemaField.d.ts +0 -7
- package/lib/components/fields/SchemaField.js +0 -109
- package/lib/components/fields/ScopeField.d.ts +0 -85
- package/lib/components/fields/ScopeField.js +0 -521
- package/lib/components/fields/SectionArrayField.d.ts +0 -38
- package/lib/components/fields/SectionArrayField.js +0 -618
- package/lib/components/fields/SelectTreeField.d.ts +0 -39
- package/lib/components/fields/SelectTreeField.js +0 -143
- package/lib/components/fields/SingleActiveArrayField.d.ts +0 -49
- package/lib/components/fields/SingleActiveArrayField.js +0 -974
- package/lib/components/fields/SingleItemArrayField.d.ts +0 -15
- package/lib/components/fields/SingleItemArrayField.js +0 -60
- package/lib/components/fields/SortArrayField.d.ts +0 -73
- package/lib/components/fields/SortArrayField.js +0 -351
- package/lib/components/fields/SplitField.d.ts +0 -28
- package/lib/components/fields/SplitField.js +0 -65
- package/lib/components/fields/StringToArrayField.d.ts +0 -24
- package/lib/components/fields/StringToArrayField.js +0 -48
- package/lib/components/fields/SumField.d.ts +0 -35
- package/lib/components/fields/SumField.js +0 -83
- package/lib/components/fields/TableField.d.ts +0 -18
- package/lib/components/fields/TableField.js +0 -136
- package/lib/components/fields/TagArrayField.d.ts +0 -38
- package/lib/components/fields/TagArrayField.js +0 -128
- package/lib/components/fields/ToggleAdditionalArrayFieldsField.d.ts +0 -26
- package/lib/components/fields/ToggleAdditionalArrayFieldsField.js +0 -81
- package/lib/components/fields/UiFieldApplierField.d.ts +0 -30
- package/lib/components/fields/UiFieldApplierField.js +0 -106
- package/lib/components/fields/UiFieldMapperArrayField.d.ts +0 -42
- package/lib/components/fields/UiFieldMapperArrayField.js +0 -121
- package/lib/components/fields/UnitCountShorthandField.d.ts +0 -22
- package/lib/components/fields/UnitCountShorthandField.js +0 -149
- package/lib/components/fields/UnitListShorthandArrayField.d.ts +0 -26
- package/lib/components/fields/UnitListShorthandArrayField.js +0 -108
- package/lib/components/fields/UnitShorthandField.d.ts +0 -32
- package/lib/components/fields/UnitShorthandField.js +0 -220
- package/lib/components/templates/ArrayFieldTemplate.d.ts +0 -85
- package/lib/components/templates/ArrayFieldTemplate.js +0 -417
- package/lib/components/templates/BaseInputTemplate.d.ts +0 -11
- package/lib/components/templates/BaseInputTemplate.js +0 -80
- package/lib/components/templates/DescriptionField.d.ts +0 -1
- package/lib/components/templates/DescriptionField.js +0 -37
- package/lib/components/templates/ErrorListTemplate.d.ts +0 -9
- package/lib/components/templates/ErrorListTemplate.js +0 -95
- package/lib/components/templates/FieldTemplate.d.ts +0 -6
- package/lib/components/templates/FieldTemplate.js +0 -112
- package/lib/components/templates/ObjectFieldTemplate.d.ts +0 -7
- package/lib/components/templates/ObjectFieldTemplate.js +0 -66
- package/lib/components/templates/TitleField.d.ts +0 -9
- package/lib/components/templates/TitleField.js +0 -51
- package/lib/components/widgets/AnyToBooleanWidget.d.ts +0 -20
- package/lib/components/widgets/AnyToBooleanWidget.js +0 -49
- package/lib/components/widgets/AutosuggestWidget.d.ts +0 -66
- package/lib/components/widgets/AutosuggestWidget.js +0 -1127
- package/lib/components/widgets/CheckboxWidget.d.ts +0 -37
- package/lib/components/widgets/CheckboxWidget.js +0 -139
- package/lib/components/widgets/DateTimeWidget.d.ts +0 -62
- package/lib/components/widgets/DateTimeWidget.js +0 -251
- package/lib/components/widgets/DateWidget.d.ts +0 -23
- package/lib/components/widgets/DateWidget.js +0 -41
- package/lib/components/widgets/HiddenWidget.d.ts +0 -15
- package/lib/components/widgets/HiddenWidget.js +0 -19
- package/lib/components/widgets/ImageSelectWidget.d.ts +0 -14
- package/lib/components/widgets/ImageSelectWidget.js +0 -57
- package/lib/components/widgets/InformalTaxonGroupChooserWidget.d.ts +0 -43
- package/lib/components/widgets/InformalTaxonGroupChooserWidget.js +0 -237
- package/lib/components/widgets/InputGroupWidget.d.ts +0 -21
- package/lib/components/widgets/InputGroupWidget.js +0 -36
- package/lib/components/widgets/InputWithDefaultValueButtonWidget.d.ts +0 -21
- package/lib/components/widgets/InputWithDefaultValueButtonWidget.js +0 -47
- package/lib/components/widgets/NumberWidget.d.ts +0 -13
- package/lib/components/widgets/NumberWidget.js +0 -21
- package/lib/components/widgets/PlainTextWidget.d.ts +0 -12
- package/lib/components/widgets/PlainTextWidget.js +0 -24
- package/lib/components/widgets/SelectWidget.d.ts +0 -52
- package/lib/components/widgets/SelectWidget.js +0 -158
- package/lib/components/widgets/SeparatedDateTimeWidget.d.ts +0 -19
- package/lib/components/widgets/SeparatedDateTimeWidget.js +0 -59
- package/lib/components/widgets/TaxonImageWidget.d.ts +0 -13
- package/lib/components/widgets/TaxonImageWidget.js +0 -30
- package/lib/components/widgets/TextSelectWidget.d.ts +0 -25
- package/lib/components/widgets/TextSelectWidget.js +0 -94
- package/lib/components/widgets/TextareaWidget.d.ts +0 -32
- package/lib/components/widgets/TextareaWidget.js +0 -87
- package/lib/components/widgets/TimeWidget.d.ts +0 -11
- package/lib/components/widgets/TimeWidget.js +0 -19
- package/lib/components/widgets/URLWidget.d.ts +0 -14
- package/lib/components/widgets/URLWidget.js +0 -12
- package/lib/components/widgets/UpperCaseWidget.d.ts +0 -13
- package/lib/components/widgets/UpperCaseWidget.js +0 -21
- package/lib/index.d.ts +0 -20
- package/lib/index.js +0 -50
- package/lib/services/blocker-service.d.ts +0 -11
- package/lib/services/blocker-service.js +0 -55
- package/lib/services/custom-event-service.d.ts +0 -17
- package/lib/services/custom-event-service.js +0 -35
- package/lib/services/dom-id-service.d.ts +0 -8
- package/lib/services/dom-id-service.js +0 -30
- package/lib/services/focus-service.d.ts +0 -13
- package/lib/services/focus-service.js +0 -60
- package/lib/services/id-service.d.ts +0 -22
- package/lib/services/id-service.js +0 -130
- package/lib/services/key-handler-service.d.ts +0 -56
- package/lib/services/key-handler-service.js +0 -184
- package/lib/services/root-instance-service.d.ts +0 -25
- package/lib/services/root-instance-service.js +0 -49
- package/lib/services/settings-service.d.ts +0 -34
- package/lib/services/settings-service.js +0 -154
- package/lib/services/singleton-map-service.d.ts +0 -23
- package/lib/services/singleton-map-service.js +0 -44
- package/lib/services/submit-hook-service.d.ts +0 -24
- package/lib/services/submit-hook-service.js +0 -73
- package/lib/styles.d.ts +0 -1
- package/lib/styles.js +0 -4
- package/lib/themes/bs3.d.ts +0 -3
- package/lib/themes/bs3.js +0 -133
- package/lib/themes/bs5.d.ts +0 -3
- package/lib/themes/bs5.js +0 -111
- package/lib/themes/glyphicon-fa-mapping.d.ts +0 -3
- package/lib/themes/glyphicon-fa-mapping.js +0 -271
- package/lib/themes/stub.d.ts +0 -3
- package/lib/themes/stub.js +0 -82
- package/lib/themes/theme.d.ts +0 -233
- package/lib/themes/theme.js +0 -2
- package/lib/translations.json +0 -847
- package/lib/utils.d.ts +0 -171
- package/lib/utils.js +0 -1191
- package/lib/validation.d.ts +0 -7
- package/lib/validation.js +0 -141
- package/llol +0 -10
- package/llol.pdf +0 -10
- package/playwright-report/index.html +0 -62
- package/q +0 -196
- package/rename.sh +0 -24
- package/trip-report.spec.ts +0 -594
|
@@ -1,417 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.arrayItemKeyFunctions = exports.arrayKeyFunctions = exports.ArrayFieldTemplateWithoutKeyHandling = exports.handlesArrayKeys = exports.getButtonsForPosition = exports.getButtonElems = exports.getButtons = exports.getButton = exports.beforeAdd = void 0;
|
|
15
|
-
const React = require("react");
|
|
16
|
-
const components_1 = require("../components");
|
|
17
|
-
const merge = require("deepmerge");
|
|
18
|
-
const utils_1 = require("../../utils");
|
|
19
|
-
const Context_1 = require("../../Context");
|
|
20
|
-
const ReactContext_1 = require("../../ReactContext");
|
|
21
|
-
const react_sortable_hoc_1 = require("react-sortable-hoc");
|
|
22
|
-
const utils_2 = require("@rjsf/utils");
|
|
23
|
-
function onAdd(e, props) {
|
|
24
|
-
if (!utils_1.canAdd(props))
|
|
25
|
-
return;
|
|
26
|
-
props.onAddClick(e);
|
|
27
|
-
}
|
|
28
|
-
function beforeAdd(props, addedIdx) {
|
|
29
|
-
if (!utils_1.canAdd(props))
|
|
30
|
-
return;
|
|
31
|
-
const { contextId } = props.formContext;
|
|
32
|
-
const startIdx = props.startIdx || utils_1.getUiOptions(props.uiSchema).startIdx;
|
|
33
|
-
let { idToScrollAfterAdd = `${props.idSchema.$id}-add`, idxOffsets, totalOffset } = utils_1.getUiOptions(props.uiSchema || {});
|
|
34
|
-
let idx = addedIdx !== null && addedIdx !== void 0 ? addedIdx : (props.items || props.formData || []).length;
|
|
35
|
-
const offset = startIdx !== undefined
|
|
36
|
-
? startIdx
|
|
37
|
-
: idxOffsets
|
|
38
|
-
? utils_1.getIdxWithOffset(idx, idxOffsets, totalOffset) - idx
|
|
39
|
-
: 0;
|
|
40
|
-
idx = offset + idx;
|
|
41
|
-
let idToFocus = `${props.idSchema.$id}_${idx}`;
|
|
42
|
-
Context_1.default(contextId).idToFocus = idToFocus;
|
|
43
|
-
Context_1.default(contextId).idToScroll = idToScrollAfterAdd;
|
|
44
|
-
}
|
|
45
|
-
exports.beforeAdd = beforeAdd;
|
|
46
|
-
const buttonDefinitions = {
|
|
47
|
-
add: {
|
|
48
|
-
glyph: "plus",
|
|
49
|
-
fn: (e) => (props) => {
|
|
50
|
-
onAdd(e, props);
|
|
51
|
-
},
|
|
52
|
-
beforeFn: beforeAdd
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
function getButton(button, props = {}) {
|
|
56
|
-
function handleButton(button) {
|
|
57
|
-
function rulesSatisfied(rules = {}) {
|
|
58
|
-
return Object.keys(rules || {}).every(ruleName => {
|
|
59
|
-
const ruleVal = rules[ruleName];
|
|
60
|
-
if (ruleName === "minLength") {
|
|
61
|
-
return (props.formData || []).length >= ruleVal;
|
|
62
|
-
}
|
|
63
|
-
else if (ruleName === "canAdd") {
|
|
64
|
-
return (button.id && button.id !== props.idSchema.$id) || utils_1.canAdd(props);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
const fnName = button.fnName || button.fn;
|
|
69
|
-
const _buttonDefinitions = props.uiSchema && utils_1.getUiOptions(props.uiSchema).buttonDefinitions
|
|
70
|
-
? merge(buttonDefinitions, utils_1.getUiOptions(props.uiSchema).buttonDefinitions)
|
|
71
|
-
: buttonDefinitions;
|
|
72
|
-
const definition = _buttonDefinitions[fnName];
|
|
73
|
-
const _button = Object.assign(Object.assign({}, (definition || {})), button);
|
|
74
|
-
if (!rulesSatisfied(_button.rules))
|
|
75
|
-
return;
|
|
76
|
-
if (!_button.fnName)
|
|
77
|
-
_button.fnName = fnName;
|
|
78
|
-
if (definition && typeof _button.fn !== "function")
|
|
79
|
-
_button.fn = _buttonDefinitions[fnName].fn;
|
|
80
|
-
if (fnName !== "add" || (utils_1.getUiOptions(props.uiSchema).renderAdd !== false && ((button.id && button.id !== props.idSchema.$id) || utils_1.canAdd(props))))
|
|
81
|
-
return _button;
|
|
82
|
-
}
|
|
83
|
-
button = handleButton(button);
|
|
84
|
-
if (!button)
|
|
85
|
-
return;
|
|
86
|
-
const id = button.id || (props.idSchema || {}).$id;
|
|
87
|
-
const buttonId = `${id}-${button.fnName}${button.key ? `-${button.key}` : ""}`;
|
|
88
|
-
return React.createElement(_Button, { key: buttonId, buttonId: buttonId, button: button, props: props });
|
|
89
|
-
}
|
|
90
|
-
exports.getButton = getButton;
|
|
91
|
-
function _Button({ button, props, getProps, buttonId }) {
|
|
92
|
-
let { fn, fnName, glyph, label, className, callforward, beforeFn, callback, render, variant, tooltip, tooltipPlacement, tooltipClass, changesFormData, disabled, help, active } = button, options = __rest(button, ["fn", "fnName", "glyph", "label", "className", "callforward", "beforeFn", "callback", "render", "variant", "tooltip", "tooltipPlacement", "tooltipClass", "changesFormData", "disabled", "help", "active"]);
|
|
93
|
-
label = label !== undefined
|
|
94
|
-
? (glyph ? ` ${label}` : label)
|
|
95
|
-
: "";
|
|
96
|
-
const onClick = React.useCallback(e => {
|
|
97
|
-
const onClickProps = getProps ? getProps() : props;
|
|
98
|
-
let _fn = () => fn(e)(onClickProps, options);
|
|
99
|
-
const __fn = () => {
|
|
100
|
-
beforeFn && beforeFn(onClickProps);
|
|
101
|
-
_fn();
|
|
102
|
-
callback && callback();
|
|
103
|
-
};
|
|
104
|
-
if (callforward) {
|
|
105
|
-
e.persist();
|
|
106
|
-
callforward(__fn);
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
__fn();
|
|
110
|
-
}
|
|
111
|
-
}, [props, getProps, options, callforward, beforeFn, callback, fn]);
|
|
112
|
-
return render ? render(onClick, button) : (React.createElement(components_1.Button, { id: buttonId, className: className, onClick: onClick, variant: variant, active: active, tooltip: tooltip || help, tooltipPlacement: tooltipPlacement, tooltipClass: tooltipClass, disabled: disabled || ((fnName === "add" || changesFormData) && (props.disabled || props.readonly)), style: button.style },
|
|
113
|
-
glyph && React.createElement(ReactContext_1.default.Consumer, null, ({ theme: { Glyphicon } }) => React.createElement(Glyphicon, { glyph: glyph })),
|
|
114
|
-
glyph ? ` ${label}` : label,
|
|
115
|
-
help && React.createElement(components_1.Help, null)));
|
|
116
|
-
}
|
|
117
|
-
function getButtons(buttons = [], props = {}) {
|
|
118
|
-
const addBtnAdded = buttons.some(button => button.fn === "add");
|
|
119
|
-
if (!addBtnAdded && (!props || utils_1.canAdd(props)))
|
|
120
|
-
buttons = [{ fn: "add", id: props.idSchema.$id }, ...buttons];
|
|
121
|
-
return buttons;
|
|
122
|
-
}
|
|
123
|
-
exports.getButtons = getButtons;
|
|
124
|
-
function getButtonElems(buttons = [], props = {}) {
|
|
125
|
-
buttons = getButtons(buttons, props);
|
|
126
|
-
let buttonElems = buttons.map(button => getButton(button, props));
|
|
127
|
-
if (props.uiSchema["ui:buttons"]) {
|
|
128
|
-
buttonElems = [...buttonElems, ...props.uiSchema["ui:buttons"]];
|
|
129
|
-
}
|
|
130
|
-
return getButtonsElem(buttonElems, props);
|
|
131
|
-
}
|
|
132
|
-
exports.getButtonElems = getButtonElems;
|
|
133
|
-
function getButtonsElem(buttonElems = [], props = {}) {
|
|
134
|
-
if (!Array.isArray(buttonElems) || buttonElems.length === 0) {
|
|
135
|
-
return null;
|
|
136
|
-
}
|
|
137
|
-
return (React.createElement(ReactContext_1.default.Consumer, null, ({ theme: { ButtonToolbar } }) => React.createElement(ButtonToolbar, { className: utils_1.getUiOptions(props.uiSchema)["ui:buttonsDesktopLayout"] ? "desktop-layout" : undefined, key: "buttons" }, buttonElems)));
|
|
138
|
-
}
|
|
139
|
-
function getButtonsForPosition(props, buttonDescriptions = [], position, defaultPosition = "bottom") {
|
|
140
|
-
buttonDescriptions = buttonDescriptions.filter(button => button.position === position || (!button.position && position === defaultPosition));
|
|
141
|
-
return (buttonDescriptions && buttonDescriptions.length) ?
|
|
142
|
-
buttonDescriptions.map(buttonDescription => getButton(buttonDescription, props)).filter(button => button) :
|
|
143
|
-
null;
|
|
144
|
-
}
|
|
145
|
-
exports.getButtonsForPosition = getButtonsForPosition;
|
|
146
|
-
function handlesArrayKeys(ComposedComponent) {
|
|
147
|
-
var _a;
|
|
148
|
-
return _a = class ArrayFieldTemplateField extends ComposedComponent {
|
|
149
|
-
constructor() {
|
|
150
|
-
super(...arguments);
|
|
151
|
-
this.onFocus = target => {
|
|
152
|
-
const context = Context_1.default(this.props.formContext.contextId);
|
|
153
|
-
if (target === "last") {
|
|
154
|
-
context.idToFocus = `${this.props.idSchema.$id}_${this.props.formData.length - 1}`;
|
|
155
|
-
context.idToScroll = `_laji-form_${this.props.idSchema.$id}_${this.props.formData.length - 2}`;
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
console.warn(`custom event "focus" has only "last" implemented. Target value was: ${target}`);
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
this.onCopy = (options = {}) => {
|
|
162
|
-
const { type = "blacklist", filter = [] } = options;
|
|
163
|
-
const { buttonDefinitions = {} } = utils_1.getUiOptions(this.props.uiSchema);
|
|
164
|
-
const { copy } = buttonDefinitions;
|
|
165
|
-
if (copy) {
|
|
166
|
-
copy.fn()(this.props, { type, filter });
|
|
167
|
-
if (copy.callback) {
|
|
168
|
-
copy.callback();
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
componentDidMount() {
|
|
174
|
-
this.addKeyHandlers(this.props);
|
|
175
|
-
this.addChildKeyHandlers(this.props);
|
|
176
|
-
this.addCustomEventListeners(this.props);
|
|
177
|
-
if (super.componentDidMount)
|
|
178
|
-
super.componentDidMount();
|
|
179
|
-
}
|
|
180
|
-
componentDidUpdate(prevProps, prevState) {
|
|
181
|
-
this.removeKeyHandlers(prevProps);
|
|
182
|
-
this.addKeyHandlers(this.props);
|
|
183
|
-
this.removeChildKeyHandlers(prevProps);
|
|
184
|
-
this.addChildKeyHandlers(this.props);
|
|
185
|
-
this.removeCustomEventListeners(prevProps);
|
|
186
|
-
this.addCustomEventListeners(this.props);
|
|
187
|
-
if (super.componentDidUpdate)
|
|
188
|
-
super.componentDidUpdate(prevProps, prevState);
|
|
189
|
-
}
|
|
190
|
-
componentWillUnmount() {
|
|
191
|
-
this.removeKeyHandlers(this.props);
|
|
192
|
-
this.removeChildKeyHandlers(this.props);
|
|
193
|
-
this.removeCustomEventListeners(this.props);
|
|
194
|
-
if (super.componentWillUnmount)
|
|
195
|
-
super.componentWillUnmount();
|
|
196
|
-
}
|
|
197
|
-
addKeyHandlers() {
|
|
198
|
-
const [keys, options] = (super.getKeyHandlers || this.getKeyHandlers).call(this, this.props);
|
|
199
|
-
this.arrayKeyFunctions = keys;
|
|
200
|
-
this.props.formContext.services.keyHandler.addKeyHandler(this.props.idSchema.$id, keys, options);
|
|
201
|
-
}
|
|
202
|
-
removeKeyHandlers(props) {
|
|
203
|
-
this.props.formContext.services.keyHandler.removeKeyHandler(props.idSchema.$id, this.arrayKeyFunctions);
|
|
204
|
-
}
|
|
205
|
-
getKeyHandlers(props) {
|
|
206
|
-
const { arrayKeyFunctions: _arrayKeyFunctions } = utils_1.getUiOptions(props.uiSchema);
|
|
207
|
-
return [_arrayKeyFunctions ? Object.assign({}, _arrayKeyFunctions) : Object.assign({}, exports.arrayKeyFunctions), {
|
|
208
|
-
getProps: () => this.props,
|
|
209
|
-
}];
|
|
210
|
-
}
|
|
211
|
-
addChildKeyHandlers(props) {
|
|
212
|
-
this.childKeyHandlers = (super.getChildKeyHandlers || this.getChildKeyHandlers).call(this, props);
|
|
213
|
-
this.childKeyHandlers.forEach(handler => {
|
|
214
|
-
this.props.formContext.services.keyHandler.addKeyHandler(...handler);
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
removeChildKeyHandlers() {
|
|
218
|
-
this.childKeyHandlers.forEach(handler => {
|
|
219
|
-
this.props.formContext.services.keyHandler.removeKeyHandler(...handler);
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
getChildKeyHandlers(props) {
|
|
223
|
-
return props.items.map((item, i) => {
|
|
224
|
-
const id = `${props.idSchema.$id}_${i}`;
|
|
225
|
-
return [id, exports.arrayItemKeyFunctions, { getProps: () => this.props, id, getDeleteButton: () => {
|
|
226
|
-
return this.deleteButtonRefs[i];
|
|
227
|
-
} }];
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
getCustomEventListeners() {
|
|
231
|
-
return [
|
|
232
|
-
["focus", this.onFocus],
|
|
233
|
-
["copy", this.onCopy]
|
|
234
|
-
];
|
|
235
|
-
}
|
|
236
|
-
addCustomEventListeners(props) {
|
|
237
|
-
const { customEvents } = props.formContext.services;
|
|
238
|
-
const customEventListeners = (super.getCustomEventListeners || this.getCustomEventListeners).call(this, props);
|
|
239
|
-
this.customEventListeners = customEventListeners;
|
|
240
|
-
customEventListeners.forEach(params => customEvents.add(props.idSchema.$id, ...params));
|
|
241
|
-
}
|
|
242
|
-
removeCustomEventListeners(props) {
|
|
243
|
-
const { customEvents } = props.formContext.services;
|
|
244
|
-
this.customEventListeners.forEach(params => customEvents.remove(props.idSchema.$id, ...params));
|
|
245
|
-
}
|
|
246
|
-
},
|
|
247
|
-
_a.displayName = utils_1.getReactComponentName(ComposedComponent) + "_handlesArrayKeys",
|
|
248
|
-
_a;
|
|
249
|
-
}
|
|
250
|
-
exports.handlesArrayKeys = handlesArrayKeys;
|
|
251
|
-
const SortableList = react_sortable_hoc_1.SortableContainer(({ items, itemProps, nonOrderables, formData }) => (React.createElement("div", null, items.map((item, i) => {
|
|
252
|
-
return React.createElement(SortableItem, { key: utils_1.isObject(formData[i]) ? utils_1.getUUID(formData[i]) : i, index: i, item: item, disabled: (!itemProps[i].hasMoveDown && !itemProps[i].hasMoveUp) || nonOrderables.includes(i) });
|
|
253
|
-
}))));
|
|
254
|
-
const SortableItem = react_sortable_hoc_1.SortableElement(({ item }) => item);
|
|
255
|
-
class ArrayFieldTemplateWithoutKeyHandling extends React.Component {
|
|
256
|
-
constructor() {
|
|
257
|
-
super(...arguments);
|
|
258
|
-
this.onSort = ({ oldIndex, newIndex }) => {
|
|
259
|
-
this.props.items[oldIndex].onReorderClick(oldIndex, newIndex)();
|
|
260
|
-
};
|
|
261
|
-
this.onFocuses = [];
|
|
262
|
-
this.getOnFocus = (i) => () => {
|
|
263
|
-
Context_1.default(this.props.formContext.contextId)[`${this.props.idSchema.$id}.activeIdx`] = i + (utils_1.getUiOptions(this.props.uiSchema).startIdx || 0);
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
render() {
|
|
267
|
-
const { props } = this;
|
|
268
|
-
const { confirmDelete, renderTitleAsLabel, deleteCorner, removable = true, orderable, nonRemovables = [], nonOrderables = [], "ui:deleteHelp": deleteHelp, buttons = [] } = utils_1.getUiOptions(props.uiSchema);
|
|
269
|
-
const { readonly, disabled } = this.props;
|
|
270
|
-
const { Label } = this.props.formContext;
|
|
271
|
-
const Title = renderTitleAsLabel ? Label : utils_2.getTemplate("TitleFieldTemplate", props.registry, utils_1.getUiOptions(props.uiSchema));
|
|
272
|
-
const Description = utils_2.getTemplate("DescriptionFieldTemplate", this.props.registry, utils_1.getUiOptions(props.uiSchema));
|
|
273
|
-
if (!this.deleteButtonRefs)
|
|
274
|
-
this.deleteButtonRefs = [];
|
|
275
|
-
const _buttons = getButtons(buttons, props);
|
|
276
|
-
const topButtons = getButtonsElem(getButtonsForPosition(props, _buttons, "top"), props);
|
|
277
|
-
const bottomButtons = getButtonsElem(getButtonsForPosition(props, _buttons, "bottom"), props);
|
|
278
|
-
const getRefFor = i => elem => { this.deleteButtonRefs[i] = elem; };
|
|
279
|
-
const items = props.items.map((item, i) => {
|
|
280
|
-
const index = utils_1.getFormDataIndex(i, props.uiSchema);
|
|
281
|
-
const getDeleteButton = () => (React.createElement("div", { className: "laji-form-field-template-buttons" },
|
|
282
|
-
React.createElement(components_1.DeleteButton, { id: `${props.idSchema.$id}_${index}`, disabled: disabled || readonly, ref: getRefFor(i), onClick: item.onDropIndexClick(item.index), confirm: confirmDelete, corner: deleteCorner, tooltip: deleteHelp, translations: props.formContext.translations })));
|
|
283
|
-
if (!this.onFocuses[i]) {
|
|
284
|
-
this.onFocuses[i] = this.getOnFocus(i);
|
|
285
|
-
}
|
|
286
|
-
return (React.createElement("div", { key: utils_1.getUUID(props.formData[i]) || item.key, className: "laji-form-field-template-item keep-vertical field-array-row", onFocus: this.onFocuses[i] },
|
|
287
|
-
React.createElement("div", { className: "laji-form-field-template-schema" }, item.children),
|
|
288
|
-
item.hasRemove && !nonRemovables.includes(item.index) && removable && getDeleteButton()));
|
|
289
|
-
});
|
|
290
|
-
const title = "ui:title" in props.uiSchema ? props.uiSchema["ui:title"] : props.title;
|
|
291
|
-
return (React.createElement("div", { className: props.className },
|
|
292
|
-
React.createElement(Title, { title: title, label: title, uiSchema: this.props.uiSchema, registry: this.props.registry }),
|
|
293
|
-
topButtons,
|
|
294
|
-
props.description && React.createElement(Description, { description: props.description }),
|
|
295
|
-
orderable ?
|
|
296
|
-
React.createElement(SortableList, { helperClass: "laji-form reorder-active", distance: 5, items: items, formData: props.formData, onSortEnd: this.onSort, itemProps: props.items, nonOrderables: nonOrderables }) :
|
|
297
|
-
items,
|
|
298
|
-
bottomButtons));
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
exports.ArrayFieldTemplateWithoutKeyHandling = ArrayFieldTemplateWithoutKeyHandling;
|
|
302
|
-
exports.default = handlesArrayKeys(ArrayFieldTemplateWithoutKeyHandling);
|
|
303
|
-
exports.arrayKeyFunctions = {
|
|
304
|
-
navigateArray: function (e, { reverse, getProps, navigateCallforward, getCurrentIdx, focusByIdx, getIdToScrollAfterNavigate }) {
|
|
305
|
-
var _a;
|
|
306
|
-
function focusIdx(idx, prop) {
|
|
307
|
-
function callback() {
|
|
308
|
-
const options = utils_1.getUiOptions(getProps().uiSchema);
|
|
309
|
-
const { focusOnNavigate = true, idToFocusAfterNavigate, keepPropFocusOnNavigate = false } = options;
|
|
310
|
-
const idByIdx = `${getProps().idSchema.$id}_${idx}`;
|
|
311
|
-
const _idToFocusAfterNavigate = idToFocusAfterNavigate ||
|
|
312
|
-
prop && keepPropFocusOnNavigate
|
|
313
|
-
? `${idByIdx}_${prop}`
|
|
314
|
-
: idByIdx;
|
|
315
|
-
const idToScrollAfterNavigate = options.idToScrollAfterNavigate
|
|
316
|
-
? options.idToScrollAfterNavigate
|
|
317
|
-
: getIdToScrollAfterNavigate
|
|
318
|
-
? getIdToScrollAfterNavigate()
|
|
319
|
-
: undefined;
|
|
320
|
-
getProps().formContext.utils.focusAndScroll(_idToFocusAfterNavigate, idToScrollAfterNavigate, focusOnNavigate);
|
|
321
|
-
}
|
|
322
|
-
if (focusByIdx) {
|
|
323
|
-
focusByIdx(idx, prop, callback);
|
|
324
|
-
}
|
|
325
|
-
else {
|
|
326
|
-
callback();
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
const nearestSchemaElemId = getProps().formContext.utils.findNearestParentSchemaElemId(document.activeElement);
|
|
330
|
-
// Should contain all nested array item ids. We want the last one, which is focused.
|
|
331
|
-
const activeItemQuery = nearestSchemaElemId.match(new RegExp(`${getProps().idSchema.$id}_\\d+`, "g"));
|
|
332
|
-
const focusedIdx = activeItemQuery ? utils_1.getReversedFormDataIndex(+activeItemQuery[0].replace(/^.*_(\d+)$/, "$1"), getProps().uiSchema) : undefined;
|
|
333
|
-
const focusedPropMaybe = (_a = nearestSchemaElemId.match(new RegExp(`${getProps().idSchema.$id}_${focusedIdx}_(.+)`))) === null || _a === void 0 ? void 0 : _a[1];
|
|
334
|
-
const focusedProp = isNaN(focusedPropMaybe) ? focusedPropMaybe : undefined;
|
|
335
|
-
const currentIdx = getCurrentIdx ? getCurrentIdx() : focusedIdx;
|
|
336
|
-
const arrayLength = getProps().formData ? getProps().formData.length : 0;
|
|
337
|
-
if (utils_1.isNullOrUndefined(currentIdx) && arrayLength > 0) {
|
|
338
|
-
focusIdx(reverse ? arrayLength - 1 : 0, focusedProp);
|
|
339
|
-
return true;
|
|
340
|
-
}
|
|
341
|
-
else {
|
|
342
|
-
let amount = 0;
|
|
343
|
-
if (focusedIdx === currentIdx)
|
|
344
|
-
amount = reverse ? -1 : 1;
|
|
345
|
-
const nextIdx = currentIdx + amount;
|
|
346
|
-
if (amount === 0 || amount < 0 && nextIdx >= 0 || amount > 0 && nextIdx < arrayLength) {
|
|
347
|
-
if (navigateCallforward) {
|
|
348
|
-
e.persist();
|
|
349
|
-
navigateCallforward(() => focusIdx(nextIdx, focusedProp), nextIdx);
|
|
350
|
-
}
|
|
351
|
-
else {
|
|
352
|
-
focusIdx(nextIdx, focusedProp);
|
|
353
|
-
}
|
|
354
|
-
return true;
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
return false;
|
|
358
|
-
},
|
|
359
|
-
insert: function (e, _props) {
|
|
360
|
-
const { getProps, insertCallforward } = _props;
|
|
361
|
-
const props = getProps();
|
|
362
|
-
function afterInsert() {
|
|
363
|
-
onAdd(e, props);
|
|
364
|
-
}
|
|
365
|
-
if (!props.disabled && !props.readonly && utils_1.canAdd(props) && utils_1.getUiOptions(props.uiSchema).canAddByKey !== false) {
|
|
366
|
-
if (e.target) {
|
|
367
|
-
e.target.blur();
|
|
368
|
-
}
|
|
369
|
-
if (insertCallforward) {
|
|
370
|
-
e.persist();
|
|
371
|
-
beforeAdd(props);
|
|
372
|
-
insertCallforward(() => {
|
|
373
|
-
afterInsert();
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
else {
|
|
377
|
-
beforeAdd(props);
|
|
378
|
-
afterInsert();
|
|
379
|
-
}
|
|
380
|
-
return true;
|
|
381
|
-
}
|
|
382
|
-
return false;
|
|
383
|
-
}
|
|
384
|
-
};
|
|
385
|
-
exports.arrayItemKeyFunctions = {
|
|
386
|
-
delete: function (e, { getDeleteButton, id, getProps }) {
|
|
387
|
-
const { items, idSchema, formContext, readonly, disabled } = getProps();
|
|
388
|
-
if (readonly || disabled || !utils_1.isDescendant(getProps().formContext.utils.getSchemaElementById(id), e.target)) {
|
|
389
|
-
return;
|
|
390
|
-
}
|
|
391
|
-
if (!getDeleteButton)
|
|
392
|
-
return;
|
|
393
|
-
const deleteButton = getDeleteButton();
|
|
394
|
-
if (!deleteButton || !deleteButton.onClick)
|
|
395
|
-
return;
|
|
396
|
-
const activeId = formContext.utils.findNearestParentSchemaElemId(document.activeElement);
|
|
397
|
-
const idxsMatch = activeId.match(/_\d+/g);
|
|
398
|
-
const idx = +idxsMatch[idxsMatch.length - 1].replace("_", "");
|
|
399
|
-
const elem = getProps().formContext.utils.getSchemaElementById(`${idSchema.$id}_${idx}`);
|
|
400
|
-
const prevElem = elem ? formContext.utils.getNextInput(utils_1.getTabbableFields(elem)[0], !!"reverse") : null;
|
|
401
|
-
deleteButton.onClick(e, (deleted) => {
|
|
402
|
-
if (deleted) {
|
|
403
|
-
const idxToFocus = idx === items.length - 1 ? idx - 1 : idx;
|
|
404
|
-
if (idxToFocus >= 0) {
|
|
405
|
-
getProps().formContext.utils.focusById(`${idSchema.$id}_${idxToFocus}`);
|
|
406
|
-
}
|
|
407
|
-
else if (prevElem) {
|
|
408
|
-
prevElem.focus();
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
else {
|
|
412
|
-
getProps().formContext.utils.focusById(`${activeId}`);
|
|
413
|
-
}
|
|
414
|
-
});
|
|
415
|
-
return true;
|
|
416
|
-
}
|
|
417
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export default class _BaseInputTemplate extends React.Component<any, any, any> {
|
|
2
|
-
static contextType: React.Context<import("../../ReactContext").ContextProps>;
|
|
3
|
-
constructor(props: any);
|
|
4
|
-
getStateFromProps: (props: any) => any;
|
|
5
|
-
onChange: (value: any) => void;
|
|
6
|
-
timeout: any;
|
|
7
|
-
onFocus: (e: any) => void;
|
|
8
|
-
focused: boolean | undefined;
|
|
9
|
-
onBlur: (e: any) => void;
|
|
10
|
-
}
|
|
11
|
-
import * as React from "react";
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
const React = require("react");
|
|
15
|
-
const core_1 = require("@rjsf/core");
|
|
16
|
-
const ReactContext_1 = require("../../ReactContext");
|
|
17
|
-
const utils_1 = require("../../utils");
|
|
18
|
-
class _BaseInputTemplate extends React.Component {
|
|
19
|
-
constructor(props) {
|
|
20
|
-
super(props);
|
|
21
|
-
this.getStateFromProps = (props) => {
|
|
22
|
-
return Object.assign({ value: props.value }, utils_1.getUiOptions(props).inputOptions);
|
|
23
|
-
};
|
|
24
|
-
this.onChange = (value) => {
|
|
25
|
-
if (this.props.formatValue)
|
|
26
|
-
value = this.props.formatValue(value);
|
|
27
|
-
const type = this.props.schema.type;
|
|
28
|
-
// Accept only integers
|
|
29
|
-
if (type === "integer") {
|
|
30
|
-
value = value ? value.replace(/[^0-9-]/g, "") : value;
|
|
31
|
-
value = value ? value.replace(/(.+)-/g, "$1") : value;
|
|
32
|
-
}
|
|
33
|
-
// Accept integers or floats
|
|
34
|
-
if (type === "number") {
|
|
35
|
-
value = value ? value.replace(/[^0-9.-]/g, "") : value;
|
|
36
|
-
value = value ? value.replace(/(\..*)\./g, "$1") : value;
|
|
37
|
-
value = value ? value.replace(/(.+)-/g, "$1") : value;
|
|
38
|
-
}
|
|
39
|
-
this.setState({ value }, () => {
|
|
40
|
-
if (!this.focused) {
|
|
41
|
-
this.props.onChange(value);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
if (this.timeout)
|
|
45
|
-
clearTimeout(this.timeout);
|
|
46
|
-
this.timeout = this.props.formContext.setTimeout(() => {
|
|
47
|
-
this.props.onChange(value);
|
|
48
|
-
}, 1000);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
this.onFocus = (e) => {
|
|
53
|
-
this.focused = true;
|
|
54
|
-
this.props.onFocus && this.props.onFocus(e);
|
|
55
|
-
};
|
|
56
|
-
this.onBlur = (e) => {
|
|
57
|
-
this.focused = false;
|
|
58
|
-
if (this.state.value !== this.props.value) {
|
|
59
|
-
this.props.onChange(this.state.value);
|
|
60
|
-
}
|
|
61
|
-
if (this.timeout)
|
|
62
|
-
clearTimeout(this.timeout);
|
|
63
|
-
this.props.onBlur && this.props.onBlur(e);
|
|
64
|
-
};
|
|
65
|
-
this.state = this.getStateFromProps(props);
|
|
66
|
-
}
|
|
67
|
-
UNSAFE_componentWillReceiveProps(props) {
|
|
68
|
-
this.setState(this.getStateFromProps(props));
|
|
69
|
-
}
|
|
70
|
-
render() {
|
|
71
|
-
const _a = this.props, { formatValue } = _a, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
72
|
-
props = __rest(_a, ["formatValue"]);
|
|
73
|
-
const options = props.schema.type === "number" || props.schema.type === "integer"
|
|
74
|
-
? Object.assign(Object.assign({}, props.options), { inputType: "text" }) : props.options;
|
|
75
|
-
const { BaseInputTemplate } = core_1.getDefaultRegistry().templates;
|
|
76
|
-
return React.createElement(BaseInputTemplate, Object.assign({}, props, this.state, { onChange: this.onChange, onFocus: this.onFocus, onBlur: this.onBlur, options: options }));
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
exports.default = _BaseInputTemplate;
|
|
80
|
-
_BaseInputTemplate.contextType = ReactContext_1.default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function DescriptonField(props: any): JSX.Element | null;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const React = require("react");
|
|
4
|
-
const utils_1 = require("../../utils");
|
|
5
|
-
const L = require("leaflet");
|
|
6
|
-
function DescriptonField(props) {
|
|
7
|
-
const { description } = props;
|
|
8
|
-
if (!description) {
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
const replacePatterns = description.match(/%{.*?}/g) || [];
|
|
12
|
-
const _description = replacePatterns.reduce((desc, replacePattern) => {
|
|
13
|
-
replacePattern = replacePattern.replace(/%|{|}/g, "");
|
|
14
|
-
let replacement;
|
|
15
|
-
const formData = props.registry.formContext.services.rootInstance.getFormData();
|
|
16
|
-
if (replacePattern[0] === "#") {
|
|
17
|
-
replacement = utils_1.parseJSONPointer(formData, replacePattern.substr(1));
|
|
18
|
-
// TODO DescriptionField doesn't receive formData
|
|
19
|
-
//} else if (replacePattern[0] === "/") {
|
|
20
|
-
// replacement = parseJSONPointer(props.formData, replacePattern);
|
|
21
|
-
}
|
|
22
|
-
else if (replacePattern.startsWith("bbox")) {
|
|
23
|
-
const field = replacePattern.match(/\((.*)\)/)[1];
|
|
24
|
-
const value = utils_1.parseJSONPointer(formData, field.substr(1));
|
|
25
|
-
const bounds = L.geoJSON(value).getBounds();
|
|
26
|
-
const sw = bounds.getSouthWest();
|
|
27
|
-
const ne = bounds.getNorthEast();
|
|
28
|
-
replacement = `${sw.lat}:${ne.lat}:${sw.lng}:${ne.lng}:WGS84`;
|
|
29
|
-
}
|
|
30
|
-
else if (replacePattern === "lang") {
|
|
31
|
-
replacement = props.registry.formContext.lang;
|
|
32
|
-
}
|
|
33
|
-
return desc.replace(`%{${replacePattern}}`, replacement);
|
|
34
|
-
}, description);
|
|
35
|
-
return React.createElement("span", { dangerouslySetInnerHTML: { __html: _description } });
|
|
36
|
-
}
|
|
37
|
-
exports.default = DescriptonField;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export default class ErrorListTemplate extends React.Component<any, any, any> {
|
|
2
|
-
static contextType: React.Context<import("../../ReactContext").ContextProps>;
|
|
3
|
-
constructor(props: any);
|
|
4
|
-
expand: () => void;
|
|
5
|
-
poppedToggle: (e: any) => void;
|
|
6
|
-
revalidate: () => void;
|
|
7
|
-
submitWithWarnings: () => void;
|
|
8
|
-
}
|
|
9
|
-
import * as React from "react";
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
const React = require("react");
|
|
15
|
-
const components_1 = require("../components");
|
|
16
|
-
const utils_1 = require("../../utils");
|
|
17
|
-
const ReactContext_1 = require("../../ReactContext");
|
|
18
|
-
class ErrorListTemplate extends React.Component {
|
|
19
|
-
constructor(props) {
|
|
20
|
-
super(props);
|
|
21
|
-
this.expand = () => {
|
|
22
|
-
if (!this.state.popped)
|
|
23
|
-
this.setState({ popped: true });
|
|
24
|
-
this.refs.errorPanel.expand();
|
|
25
|
-
this.refs.warningPanel.expand();
|
|
26
|
-
};
|
|
27
|
-
this.poppedToggle = (e) => {
|
|
28
|
-
e.stopPropagation();
|
|
29
|
-
this.setState({ popped: !this.state.popped, poppedTouched: true });
|
|
30
|
-
};
|
|
31
|
-
this.revalidate = () => {
|
|
32
|
-
this.props.formContext.services.rootInstance.validate();
|
|
33
|
-
this.refs.errorPanel.expand();
|
|
34
|
-
this.refs.warningPanel.expand();
|
|
35
|
-
};
|
|
36
|
-
this.submitWithWarnings = () => {
|
|
37
|
-
this.props.formContext.services.rootInstance.submitWithWarnings();
|
|
38
|
-
};
|
|
39
|
-
this.state = { popped: false, poppedTouched: false };
|
|
40
|
-
this.props.formContext.services.rootInstance.setErrorListInstance(this);
|
|
41
|
-
}
|
|
42
|
-
render() {
|
|
43
|
-
const { errorSchema, schema, formContext, uiSchema } = this.props;
|
|
44
|
-
const { "ui:disabled": disabled, "ui:readonly": readonly } = uiSchema;
|
|
45
|
-
const { translations } = formContext;
|
|
46
|
-
const clickHandler = formContext.services.focus.focus;
|
|
47
|
-
function walkErrors(path, id, errorSchema, uiSchema, defaultTitle) {
|
|
48
|
-
const { __errors } = errorSchema, properties = __rest(errorSchema, ["__errors"]);
|
|
49
|
-
const _schema = utils_1.parseJSONPointer(schema, path);
|
|
50
|
-
const title = _schema.title || defaultTitle;
|
|
51
|
-
let { errors, warnings } = (__errors || []).reduce(({ errors, warnings }, _error) => {
|
|
52
|
-
if (_error.includes("[warning]")) {
|
|
53
|
-
warnings.push({
|
|
54
|
-
label: title,
|
|
55
|
-
error: utils_1.formatErrorMessage(_error),
|
|
56
|
-
id: id
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
errors.push({
|
|
61
|
-
label: title,
|
|
62
|
-
error: utils_1.formatErrorMessage(_error),
|
|
63
|
-
id: id
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
return { errors, warnings };
|
|
67
|
-
}, { errors: [], warnings: [] });
|
|
68
|
-
Object.keys(properties).forEach(prop => {
|
|
69
|
-
let _path = path;
|
|
70
|
-
if (prop.match(/^\d+$/))
|
|
71
|
-
_path = `${_path}/items`;
|
|
72
|
-
else
|
|
73
|
-
_path = `${_path}/properties/${prop}`;
|
|
74
|
-
const _defaultTitle = uiSchema["ui:multiLanguage"] ? `${title} (${prop})` : prop;
|
|
75
|
-
const childErrors = walkErrors(_path, `${id}_${prop}`, errorSchema[prop], uiSchema[prop] || {}, _defaultTitle);
|
|
76
|
-
errors = [...errors, ...childErrors.errors];
|
|
77
|
-
warnings = [...warnings, ...childErrors.warnings];
|
|
78
|
-
});
|
|
79
|
-
return { errors, warnings };
|
|
80
|
-
}
|
|
81
|
-
const { Glyphicon } = this.context.theme;
|
|
82
|
-
const { errors, warnings } = walkErrors("", "root", errorSchema, uiSchema, "");
|
|
83
|
-
const footer = (errors.length > 0
|
|
84
|
-
? React.createElement(components_1.Button, { onClick: this.revalidate },
|
|
85
|
-
React.createElement(Glyphicon, { glyph: "refresh" }),
|
|
86
|
-
" ",
|
|
87
|
-
translations.Revalidate)
|
|
88
|
-
: React.createElement(components_1.Button, { onClick: this.submitWithWarnings, variant: "success", disabled: disabled || readonly }, translations.SubmitWithWarnings));
|
|
89
|
-
return (React.createElement("div", { className: `laji-form-error-list${this.state.popped ? " laji-form-popped" : ""}${errors.length === 0 ? " laji-form-warning-list" : ""}`, style: this.state.popped ? { top: (this.props.formContext.topOffset || 0) + 5 } : null },
|
|
90
|
-
React.createElement(components_1.ErrorPanel, { classNames: "error-panel", ref: "errorPanel", errors: errors, title: translations.Errors, clickHandler: clickHandler, showToggle: true, poppedToggle: this.poppedToggle, footer: footer }),
|
|
91
|
-
React.createElement(components_1.ErrorPanel, { classNames: "warning-panel", ref: "warningPanel", errors: warnings, title: translations.Warnings, clickHandler: clickHandler, showToggle: errors.length === 0, poppedToggle: this.poppedToggle, footer: footer })));
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
exports.default = ErrorListTemplate;
|
|
95
|
-
ErrorListTemplate.contextType = ReactContext_1.default;
|