@luomus/laji-form 14.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +215 -0
- package/LICENSE +21 -0
- package/README.md +180 -0
- package/cypress/fixtures/example.json +5 -0
- closes suggestion list (failed).png +0 -0
- is marked as suggested (failed).png +0 -0
- package/dist/images/finnish-flag.png +0 -0
- package/dist/images/handled.png +0 -0
- package/dist/images/heard.png +0 -0
- package/dist/images/indirect.png +0 -0
- package/dist/images/media.png +0 -0
- package/dist/images/seen.png +0 -0
- package/dist/images/specimen.png +0 -0
- package/dist/laji-form.js +2 -0
- package/dist/laji-form.js.LICENSE.txt +92 -0
- package/dist/styles.css +3771 -0
- package/lib/ApiClient.d.ts +46 -0
- package/lib/ApiClient.js +93 -0
- package/lib/Context.d.ts +8 -0
- package/lib/Context.js +18 -0
- package/lib/ReactContext.d.ts +7 -0
- package/lib/ReactContext.js +5 -0
- package/lib/components/BaseComponent.d.ts +9 -0
- package/lib/components/BaseComponent.js +29 -0
- package/lib/components/LajiForm.d.ts +221 -0
- package/lib/components/LajiForm.js +614 -0
- package/lib/components/VirtualSchemaField.d.ts +42 -0
- package/lib/components/VirtualSchemaField.js +74 -0
- package/lib/components/components.d.ts +119 -0
- package/lib/components/components.js +606 -0
- package/lib/components/fields/AnnotationField.d.ts +34 -0
- package/lib/components/fields/AnnotationField.js +242 -0
- package/lib/components/fields/AnyToBooleanField.d.ts +18 -0
- package/lib/components/fields/AnyToBooleanField.js +20 -0
- package/lib/components/fields/ArrayBulkField.d.ts +23 -0
- package/lib/components/fields/ArrayBulkField.js +82 -0
- package/lib/components/fields/ArrayCombinerField.d.ts +36 -0
- package/lib/components/fields/ArrayCombinerField.js +138 -0
- package/lib/components/fields/ArrayField.d.ts +39 -0
- package/lib/components/fields/ArrayField.js +148 -0
- package/lib/components/fields/AudioArrayField.d.ts +22 -0
- package/lib/components/fields/AudioArrayField.js +100 -0
- package/lib/components/fields/AutoArrayField.d.ts +24 -0
- package/lib/components/fields/AutoArrayField.js +56 -0
- package/lib/components/fields/AutosuggestField.d.ts +69 -0
- package/lib/components/fields/AutosuggestField.js +299 -0
- package/lib/components/fields/CombinedValueDisplayField.d.ts +41 -0
- package/lib/components/fields/CombinedValueDisplayField.js +100 -0
- package/lib/components/fields/ConditionalOnChangeField.d.ts +42 -0
- package/lib/components/fields/ConditionalOnChangeField.js +107 -0
- package/lib/components/fields/ConditionalUiSchemaField.d.ts +123 -0
- package/lib/components/fields/ConditionalUiSchemaField.js +143 -0
- package/lib/components/fields/ContextInjectionField.d.ts +24 -0
- package/lib/components/fields/ContextInjectionField.js +68 -0
- package/lib/components/fields/DataLeakerField.d.ts +40 -0
- package/lib/components/fields/DataLeakerField.js +68 -0
- package/lib/components/fields/DefaultValueArrayField.d.ts +34 -0
- package/lib/components/fields/DefaultValueArrayField.js +59 -0
- package/lib/components/fields/DependentBooleanField.d.ts +38 -0
- package/lib/components/fields/DependentBooleanField.js +87 -0
- package/lib/components/fields/DependentDisableField.d.ts +35 -0
- package/lib/components/fields/DependentDisableField.js +71 -0
- package/lib/components/fields/EnumRangeArrayField.d.ts +27 -0
- package/lib/components/fields/EnumRangeArrayField.js +115 -0
- package/lib/components/fields/ExtraLabelRowField.d.ts +38 -0
- package/lib/components/fields/ExtraLabelRowField.js +100 -0
- package/lib/components/fields/FakePropertyField.d.ts +18 -0
- package/lib/components/fields/FakePropertyField.js +48 -0
- package/lib/components/fields/FilterArrayField.d.ts +73 -0
- package/lib/components/fields/FilterArrayField.js +121 -0
- package/lib/components/fields/FlatField.d.ts +29 -0
- package/lib/components/fields/FlatField.js +171 -0
- package/lib/components/fields/GeocoderField.d.ts +47 -0
- package/lib/components/fields/GeocoderField.js +372 -0
- package/lib/components/fields/GridLayoutField.d.ts +18 -0
- package/lib/components/fields/GridLayoutField.js +32 -0
- package/lib/components/fields/HiddenField.d.ts +10 -0
- package/lib/components/fields/HiddenField.js +11 -0
- package/lib/components/fields/ImageArrayField.d.ts +153 -0
- package/lib/components/fields/ImageArrayField.js +696 -0
- package/lib/components/fields/ImageDisplayField.d.ts +18 -0
- package/lib/components/fields/ImageDisplayField.js +44 -0
- package/lib/components/fields/InitiallyHiddenField.d.ts +21 -0
- package/lib/components/fields/InitiallyHiddenField.js +58 -0
- package/lib/components/fields/InjectDefaultValueField.d.ts +37 -0
- package/lib/components/fields/InjectDefaultValueField.js +68 -0
- package/lib/components/fields/InjectField.d.ts +46 -0
- package/lib/components/fields/InjectField.js +88 -0
- package/lib/components/fields/InputWithDefaultValueButtonField.d.ts +25 -0
- package/lib/components/fields/InputWithDefaultValueButtonField.js +61 -0
- package/lib/components/fields/LocalityField.d.ts +22 -0
- package/lib/components/fields/LocalityField.js +94 -0
- package/lib/components/fields/LocationChooserField.d.ts +27 -0
- package/lib/components/fields/LocationChooserField.js +440 -0
- package/lib/components/fields/MapArrayField.d.ts +78 -0
- package/lib/components/fields/MapArrayField.js +1783 -0
- package/lib/components/fields/MapField.d.ts +48 -0
- package/lib/components/fields/MapField.js +434 -0
- package/lib/components/fields/MultiAnyToBooleanField.d.ts +25 -0
- package/lib/components/fields/MultiAnyToBooleanField.js +100 -0
- package/lib/components/fields/MultiArrayField.d.ts +53 -0
- package/lib/components/fields/MultiArrayField.js +224 -0
- package/lib/components/fields/MultiLanguageField.d.ts +13 -0
- package/lib/components/fields/MultiLanguageField.js +52 -0
- package/lib/components/fields/MultiTagArrayField.d.ts +36 -0
- package/lib/components/fields/MultiTagArrayField.js +142 -0
- package/lib/components/fields/NamedPlaceChooserField.d.ts +29 -0
- package/lib/components/fields/NamedPlaceChooserField.js +380 -0
- package/lib/components/fields/NamedPlaceSaverField.d.ts +29 -0
- package/lib/components/fields/NamedPlaceSaverField.js +237 -0
- package/lib/components/fields/NestField.d.ts +148 -0
- package/lib/components/fields/NestField.js +289 -0
- package/lib/components/fields/ObjectField.d.ts +2 -0
- package/lib/components/fields/ObjectField.js +119 -0
- package/lib/components/fields/PrefillingArrayField.d.ts +22 -0
- package/lib/components/fields/PrefillingArrayField.js +65 -0
- package/lib/components/fields/SchemaField.d.ts +7 -0
- package/lib/components/fields/SchemaField.js +109 -0
- package/lib/components/fields/ScopeField.d.ts +85 -0
- package/lib/components/fields/ScopeField.js +521 -0
- package/lib/components/fields/SectionArrayField.d.ts +38 -0
- package/lib/components/fields/SectionArrayField.js +614 -0
- package/lib/components/fields/SelectTreeField.d.ts +39 -0
- package/lib/components/fields/SelectTreeField.js +143 -0
- package/lib/components/fields/SingleActiveArrayField.d.ts +49 -0
- package/lib/components/fields/SingleActiveArrayField.js +974 -0
- package/lib/components/fields/SingleItemArrayField.d.ts +15 -0
- package/lib/components/fields/SingleItemArrayField.js +60 -0
- package/lib/components/fields/SortArrayField.d.ts +73 -0
- package/lib/components/fields/SortArrayField.js +351 -0
- package/lib/components/fields/SplitField.d.ts +28 -0
- package/lib/components/fields/SplitField.js +65 -0
- package/lib/components/fields/StringToArrayField.d.ts +24 -0
- package/lib/components/fields/StringToArrayField.js +48 -0
- package/lib/components/fields/SumField.d.ts +35 -0
- package/lib/components/fields/SumField.js +83 -0
- package/lib/components/fields/TableField.d.ts +18 -0
- package/lib/components/fields/TableField.js +136 -0
- package/lib/components/fields/TagArrayField.d.ts +38 -0
- package/lib/components/fields/TagArrayField.js +128 -0
- package/lib/components/fields/ToggleAdditionalArrayFieldsField.d.ts +26 -0
- package/lib/components/fields/ToggleAdditionalArrayFieldsField.js +81 -0
- package/lib/components/fields/UiFieldApplierField.d.ts +30 -0
- package/lib/components/fields/UiFieldApplierField.js +106 -0
- package/lib/components/fields/UiFieldMapperArrayField.d.ts +42 -0
- package/lib/components/fields/UiFieldMapperArrayField.js +121 -0
- package/lib/components/fields/UnitCountShorthandField.d.ts +22 -0
- package/lib/components/fields/UnitCountShorthandField.js +149 -0
- package/lib/components/fields/UnitListShorthandArrayField.d.ts +26 -0
- package/lib/components/fields/UnitListShorthandArrayField.js +108 -0
- package/lib/components/fields/UnitShorthandField.d.ts +32 -0
- package/lib/components/fields/UnitShorthandField.js +220 -0
- package/lib/components/templates/ArrayFieldTemplate.d.ts +85 -0
- package/lib/components/templates/ArrayFieldTemplate.js +416 -0
- package/lib/components/templates/BaseInputTemplate.d.ts +11 -0
- package/lib/components/templates/BaseInputTemplate.js +80 -0
- package/lib/components/templates/DescriptionField.d.ts +1 -0
- package/lib/components/templates/DescriptionField.js +37 -0
- package/lib/components/templates/ErrorListTemplate.d.ts +9 -0
- package/lib/components/templates/ErrorListTemplate.js +95 -0
- package/lib/components/templates/FieldTemplate.d.ts +6 -0
- package/lib/components/templates/FieldTemplate.js +112 -0
- package/lib/components/templates/ObjectFieldTemplate.d.ts +7 -0
- package/lib/components/templates/ObjectFieldTemplate.js +66 -0
- package/lib/components/templates/TitleField.d.ts +9 -0
- package/lib/components/templates/TitleField.js +51 -0
- package/lib/components/widgets/AnyToBooleanWidget.d.ts +20 -0
- package/lib/components/widgets/AnyToBooleanWidget.js +49 -0
- package/lib/components/widgets/AutosuggestWidget.d.ts +66 -0
- package/lib/components/widgets/AutosuggestWidget.js +1127 -0
- package/lib/components/widgets/CheckboxWidget.d.ts +37 -0
- package/lib/components/widgets/CheckboxWidget.js +139 -0
- package/lib/components/widgets/DateTimeWidget.d.ts +62 -0
- package/lib/components/widgets/DateTimeWidget.js +251 -0
- package/lib/components/widgets/DateWidget.d.ts +23 -0
- package/lib/components/widgets/DateWidget.js +41 -0
- package/lib/components/widgets/HiddenWidget.d.ts +15 -0
- package/lib/components/widgets/HiddenWidget.js +19 -0
- package/lib/components/widgets/ImageSelectWidget.d.ts +14 -0
- package/lib/components/widgets/ImageSelectWidget.js +57 -0
- package/lib/components/widgets/InformalTaxonGroupChooserWidget.d.ts +43 -0
- package/lib/components/widgets/InformalTaxonGroupChooserWidget.js +237 -0
- package/lib/components/widgets/InputGroupWidget.d.ts +21 -0
- package/lib/components/widgets/InputGroupWidget.js +36 -0
- package/lib/components/widgets/InputWithDefaultValueButtonWidget.d.ts +21 -0
- package/lib/components/widgets/InputWithDefaultValueButtonWidget.js +47 -0
- package/lib/components/widgets/NumberWidget.d.ts +13 -0
- package/lib/components/widgets/NumberWidget.js +21 -0
- package/lib/components/widgets/PlainTextWidget.d.ts +12 -0
- package/lib/components/widgets/PlainTextWidget.js +24 -0
- package/lib/components/widgets/SelectWidget.d.ts +52 -0
- package/lib/components/widgets/SelectWidget.js +158 -0
- package/lib/components/widgets/SeparatedDateTimeWidget.d.ts +19 -0
- package/lib/components/widgets/SeparatedDateTimeWidget.js +59 -0
- package/lib/components/widgets/TaxonImageWidget.d.ts +13 -0
- package/lib/components/widgets/TaxonImageWidget.js +30 -0
- package/lib/components/widgets/TextSelectWidget.d.ts +25 -0
- package/lib/components/widgets/TextSelectWidget.js +94 -0
- package/lib/components/widgets/TextareaWidget.d.ts +32 -0
- package/lib/components/widgets/TextareaWidget.js +87 -0
- package/lib/components/widgets/TimeWidget.d.ts +11 -0
- package/lib/components/widgets/TimeWidget.js +19 -0
- package/lib/components/widgets/URLWidget.d.ts +14 -0
- package/lib/components/widgets/URLWidget.js +12 -0
- package/lib/components/widgets/UpperCaseWidget.d.ts +13 -0
- package/lib/components/widgets/UpperCaseWidget.js +21 -0
- package/lib/index.d.ts +20 -0
- package/lib/index.js +50 -0
- package/lib/services/blocker-service.d.ts +11 -0
- package/lib/services/blocker-service.js +55 -0
- package/lib/services/custom-event-service.d.ts +17 -0
- package/lib/services/custom-event-service.js +35 -0
- package/lib/services/dom-id-service.d.ts +8 -0
- package/lib/services/dom-id-service.js +30 -0
- package/lib/services/focus-service.d.ts +13 -0
- package/lib/services/focus-service.js +60 -0
- package/lib/services/id-service.d.ts +22 -0
- package/lib/services/id-service.js +130 -0
- package/lib/services/key-handler-service.d.ts +56 -0
- package/lib/services/key-handler-service.js +184 -0
- package/lib/services/root-instance-service.d.ts +25 -0
- package/lib/services/root-instance-service.js +49 -0
- package/lib/services/settings-service.d.ts +34 -0
- package/lib/services/settings-service.js +154 -0
- package/lib/services/singleton-map-service.d.ts +23 -0
- package/lib/services/singleton-map-service.js +44 -0
- package/lib/services/submit-hook-service.d.ts +24 -0
- package/lib/services/submit-hook-service.js +73 -0
- package/lib/styles.d.ts +1 -0
- package/lib/styles.js +4 -0
- package/lib/themes/bs3.d.ts +3 -0
- package/lib/themes/bs3.js +133 -0
- package/lib/themes/bs5.d.ts +3 -0
- package/lib/themes/bs5.js +111 -0
- package/lib/themes/glyphicon-fa-mapping.d.ts +3 -0
- package/lib/themes/glyphicon-fa-mapping.js +271 -0
- package/lib/themes/stub.d.ts +3 -0
- package/lib/themes/stub.js +82 -0
- package/lib/themes/theme.d.ts +233 -0
- package/lib/themes/theme.js +2 -0
- package/lib/translations.json +842 -0
- package/lib/utils.d.ts +167 -0
- package/lib/utils.js +1191 -0
- package/lib/validation.d.ts +7 -0
- package/lib/validation.js +141 -0
- package/llol +10 -0
- package/llol.pdf +10 -0
- package/package.json +99 -0
- package/q +196 -0
- package/test-export/array-spec.d.ts +1 -0
- package/test-export/array-spec.js +204 -0
- package/test-export/bird-point-count-spec.d.ts +1 -0
- package/test-export/bird-point-count-spec.js +62 -0
- package/test-export/collection-contest-form-spec.d.ts +1 -0
- package/test-export/collection-contest-form-spec.js +38 -0
- package/test-export/dataset-form-spec.d.ts +1 -0
- package/test-export/dataset-form-spec.js +50 -0
- package/test-export/date-time-widget-spec.d.ts +1 -0
- package/test-export/date-time-widget-spec.js +188 -0
- package/test-export/geocoder-spec.d.ts +1 -0
- package/test-export/geocoder-spec.js +135 -0
- package/test-export/image-array-spec.d.ts +1 -0
- package/test-export/image-array-spec.js +94 -0
- package/test-export/inject-field-spec.d.ts +1 -0
- package/test-export/inject-field-spec.js +148 -0
- package/test-export/internal-uuids-spec.d.ts +1 -0
- package/test-export/internal-uuids-spec.js +157 -0
- package/test-export/invasive-species-eradication-np-spec.d.ts +1 -0
- package/test-export/invasive-species-eradication-np-spec.js +18 -0
- package/test-export/invasive-species-eradication-spec.d.ts +1 -0
- package/test-export/invasive-species-eradication-spec.js +25 -0
- package/test-export/line-transect-spec.d.ts +1 -0
- package/test-export/line-transect-spec.js +121 -0
- package/test-export/mobile-form-spec.d.ts +1 -0
- package/test-export/mobile-form-spec.js +84 -0
- package/test-export/nafi-spec.d.ts +1 -0
- package/test-export/nafi-spec.js +85 -0
- package/test-export/select-widget-spec.d.ts +1 -0
- package/test-export/select-widget-spec.js +68 -0
- package/test-export/single-item-array-field-spec.d.ts +1 -0
- package/test-export/single-item-array-field-spec.js +92 -0
- package/test-export/syke-butterfly-spec.d.ts +1 -0
- package/test-export/syke-butterfly-spec.js +163 -0
- package/test-export/test-utils.d.ts +184 -0
- package/test-export/test-utils.js +354 -0
- package/test-export/transaction-form-spec.d.ts +1 -0
- package/test-export/transaction-form-spec.js +63 -0
- package/test-export/trip-report-autosuggest-spec.d.ts +1 -0
- package/test-export/trip-report-autosuggest-spec.js +272 -0
- package/test-export/trip-report-spec.d.ts +1 -0
- package/test-export/trip-report-spec.js +456 -0
- package/test-export/unit-list-shorthand-array-field-spec.d.ts +1 -0
- package/test-export/unit-list-shorthand-array-field-spec.js +71 -0
- package/test-export/validation-spec.d.ts +1 -0
- package/test-export/validation-spec.js +336 -0
- package/test-export/water-bird-spec.d.ts +1 -0
- package/test-export/water-bird-spec.js +30 -0
- package/test-export/wbc-spec.d.ts +1 -0
- package/test-export/wbc-spec.js +82 -0
- package/tsconfig.json +25 -0
- package/tsconfig.lib.json +11 -0
- package/tsconfig.test.json +10 -0
package/lib/index.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
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 LajiForm_1 = require("./components/LajiForm");
|
|
15
|
+
const React = require("react");
|
|
16
|
+
const react_dom_1 = require("react-dom");
|
|
17
|
+
class LajiFormWrapper {
|
|
18
|
+
constructor(props) {
|
|
19
|
+
this.submit = () => {
|
|
20
|
+
this.lajiForm.submit();
|
|
21
|
+
};
|
|
22
|
+
this.submitOnlySchemaValidations = () => {
|
|
23
|
+
this.lajiForm.submitOnlySchemaValidations();
|
|
24
|
+
};
|
|
25
|
+
this.setState = (state) => {
|
|
26
|
+
this.state = Object.assign(Object.assign({}, this.state), state);
|
|
27
|
+
this.lajiForm = react_dom_1.render(React.createElement(LajiForm_1.default, Object.assign(Object.assign({}, this.props), this.state), null), this.rootElem);
|
|
28
|
+
};
|
|
29
|
+
this.pushBlockingLoader = () => {
|
|
30
|
+
this.lajiForm.pushBlockingLoader();
|
|
31
|
+
};
|
|
32
|
+
this.popBlockingLoader = () => {
|
|
33
|
+
this.lajiForm.popBlockingLoader();
|
|
34
|
+
};
|
|
35
|
+
this.getSettings = () => {
|
|
36
|
+
return this.lajiForm.getSettings();
|
|
37
|
+
};
|
|
38
|
+
this.destroy = () => {
|
|
39
|
+
this.lajiForm.destroy();
|
|
40
|
+
react_dom_1.unmountComponentAtNode(this.rootElem);
|
|
41
|
+
};
|
|
42
|
+
this.unmount = this.destroy;
|
|
43
|
+
const { rootElem } = props, _props = __rest(props, ["rootElem"]);
|
|
44
|
+
this.props = props;
|
|
45
|
+
this.rootElem = rootElem;
|
|
46
|
+
this.lajiForm = react_dom_1.render(React.createElement(LajiForm_1.default, _props, null), this.rootElem);
|
|
47
|
+
this.state = {};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.default = LajiFormWrapper;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FormContext } from "../components/LajiForm";
|
|
2
|
+
export default class BlockerService {
|
|
3
|
+
private formContext;
|
|
4
|
+
private blockingLoaderCounter;
|
|
5
|
+
private blockingLoaderRef;
|
|
6
|
+
constructor(formContext: FormContext);
|
|
7
|
+
initialize(): void;
|
|
8
|
+
destroy(): void;
|
|
9
|
+
push: () => void;
|
|
10
|
+
pop: () => void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class BlockerService {
|
|
4
|
+
constructor(formContext) {
|
|
5
|
+
this.blockingLoaderCounter = 0;
|
|
6
|
+
this.push = () => {
|
|
7
|
+
this.blockingLoaderCounter++;
|
|
8
|
+
if (this.blockingLoaderCounter === 1) {
|
|
9
|
+
this.blockingLoaderRef.className = "laji-form blocking-loader entering";
|
|
10
|
+
this.formContext.services.keyHandler.block();
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
this.pop = () => {
|
|
14
|
+
this.blockingLoaderCounter--;
|
|
15
|
+
if (this.blockingLoaderCounter < 0) {
|
|
16
|
+
console.warn("laji-form: Blocking loader was popped before pushing!");
|
|
17
|
+
}
|
|
18
|
+
else if (this.blockingLoaderCounter === 0) {
|
|
19
|
+
this.blockingLoaderRef.className = "laji-form blocking-loader leave-start";
|
|
20
|
+
this.formContext.setTimeout(() => {
|
|
21
|
+
if (this.blockingLoaderCounter > 0) {
|
|
22
|
+
this.blockingLoaderRef.className = "laji-form blocking-loader entering";
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (this.blockingLoaderRef)
|
|
26
|
+
this.blockingLoaderRef.className = "laji-form blocking-loader leaving";
|
|
27
|
+
this.formContext.setTimeout(() => {
|
|
28
|
+
if (!this.blockingLoaderRef) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (this.blockingLoaderCounter > 0) {
|
|
32
|
+
this.blockingLoaderRef.className = "laji-form blocking-loader entering";
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
this.blockingLoaderRef.className = "laji-form blocking-loader";
|
|
36
|
+
}
|
|
37
|
+
}, 200); // should match css transition time.
|
|
38
|
+
});
|
|
39
|
+
this.formContext.services.keyHandler.unblock();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
this.formContext = formContext;
|
|
43
|
+
}
|
|
44
|
+
initialize() {
|
|
45
|
+
this.blockingLoaderRef = document.createElement("div");
|
|
46
|
+
this.blockingLoaderRef.className = "laji-form blocking-loader";
|
|
47
|
+
if (this.blockingLoaderCounter > 0)
|
|
48
|
+
this.blockingLoaderRef.className = "laji-form blocking-loader entering";
|
|
49
|
+
document.body.appendChild(this.blockingLoaderRef);
|
|
50
|
+
}
|
|
51
|
+
destroy() {
|
|
52
|
+
document.body.removeChild(this.blockingLoaderRef);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.default = BlockerService;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare type CustomEventListener = (data?: any, callback?: () => void) => boolean | void;
|
|
2
|
+
/**
|
|
3
|
+
* A service for sending events outside DOM.
|
|
4
|
+
*/
|
|
5
|
+
export default class CustomEventService {
|
|
6
|
+
eventListeners: {
|
|
7
|
+
[eventName: string]: {
|
|
8
|
+
[id: string]: CustomEventListener[];
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
add(id: string, eventName: string, fn: CustomEventListener): void;
|
|
12
|
+
remove(id: string, eventName: string, fn: CustomEventListener): void;
|
|
13
|
+
send(id: string, eventName: string, data?: any, callback?: () => void, { bubble }?: {
|
|
14
|
+
bubble?: boolean | undefined;
|
|
15
|
+
}): void;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* A service for sending events outside DOM.
|
|
5
|
+
*/
|
|
6
|
+
class CustomEventService {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.eventListeners = {};
|
|
9
|
+
}
|
|
10
|
+
add(id, eventName, fn) {
|
|
11
|
+
if (!this.eventListeners[eventName])
|
|
12
|
+
this.eventListeners[eventName] = {};
|
|
13
|
+
if (!this.eventListeners[eventName][id])
|
|
14
|
+
this.eventListeners[eventName][id] = [];
|
|
15
|
+
this.eventListeners[eventName][id].push(fn);
|
|
16
|
+
}
|
|
17
|
+
remove(id, eventName, fn) {
|
|
18
|
+
this.eventListeners[eventName][id] = this.eventListeners[eventName][id].filter(_fn => _fn !== fn);
|
|
19
|
+
}
|
|
20
|
+
send(id, eventName, data, callback, { bubble = true } = {}) {
|
|
21
|
+
const ids = Object.keys(this.eventListeners[eventName] || {}).filter(_id => id.startsWith(_id)).sort().reverse();
|
|
22
|
+
outer: for (let _id of ids) {
|
|
23
|
+
for (let listener of this.eventListeners[eventName][_id]) {
|
|
24
|
+
const result = listener(data, callback);
|
|
25
|
+
if (!bubble)
|
|
26
|
+
break outer;
|
|
27
|
+
if (result === true || result === undefined) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
callback && callback();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.default = CustomEventService;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeps track of reserved DOM IDs so that the IDs are rendered only once.
|
|
3
|
+
**/
|
|
4
|
+
export default class DOMIdService {
|
|
5
|
+
private ids;
|
|
6
|
+
reserve: (id: string, sendId: (id: string) => void) => string | void;
|
|
7
|
+
release: (id: string, sendId: (id: string) => void) => void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Keeps track of reserved DOM IDs so that the IDs are rendered only once.
|
|
5
|
+
**/
|
|
6
|
+
class DOMIdService {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.ids = {};
|
|
9
|
+
// First call returns id, next call (and only the very next) reserves the id until it is released.
|
|
10
|
+
this.reserve = (id, sendId) => {
|
|
11
|
+
if (this.ids[id] && this.ids[id].length) {
|
|
12
|
+
this.ids[id].push(sendId);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
this.ids[id] = [sendId]; // Just mark that the id is now used. It isn't reserved yet.
|
|
16
|
+
return id;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
this.release = (id, sendId) => {
|
|
20
|
+
if (this.ids[id]) {
|
|
21
|
+
const idx = this.ids[id].indexOf(sendId);
|
|
22
|
+
this.ids[id].splice(idx, 1);
|
|
23
|
+
if (this.ids[id].length > 0) {
|
|
24
|
+
this.ids[id][0](id);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.default = DOMIdService;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FormContext } from "../components/LajiForm";
|
|
2
|
+
declare type FocusHandler = () => Promise<void> | void;
|
|
3
|
+
export default class FocusService {
|
|
4
|
+
private formContext;
|
|
5
|
+
private focusHandlers;
|
|
6
|
+
constructor(formContext: FormContext);
|
|
7
|
+
setFormContext(formContext: FormContext): void;
|
|
8
|
+
addFocusHandler(id: string, fn: FocusHandler): void;
|
|
9
|
+
removeFocusHandler(id: string, fn: FocusHandler): void;
|
|
10
|
+
focus(id: string): void;
|
|
11
|
+
focusNextInput(reverse?: boolean): void;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("../utils");
|
|
4
|
+
class FocusService {
|
|
5
|
+
constructor(formContext) {
|
|
6
|
+
this.focusHandlers = {};
|
|
7
|
+
this.formContext = formContext;
|
|
8
|
+
this.focus = this.focus.bind(this);
|
|
9
|
+
this.focusNextInput = this.focusNextInput.bind(this);
|
|
10
|
+
}
|
|
11
|
+
setFormContext(formContext) {
|
|
12
|
+
this.formContext = formContext;
|
|
13
|
+
}
|
|
14
|
+
addFocusHandler(id, fn) {
|
|
15
|
+
if (!this.focusHandlers[id])
|
|
16
|
+
this.focusHandlers[id] = [];
|
|
17
|
+
this.focusHandlers[id].push(fn);
|
|
18
|
+
}
|
|
19
|
+
removeFocusHandler(id, fn) {
|
|
20
|
+
if (!this.focusHandlers[id]) {
|
|
21
|
+
console.warn(`laji-form warning: removing focus handler that isn't registered for id ${id}.`);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
this.focusHandlers[id] = this.focusHandlers[id].filter(_fn => fn !== _fn);
|
|
25
|
+
}
|
|
26
|
+
focus(id) {
|
|
27
|
+
const idParts = id.split("_");
|
|
28
|
+
// Some components focus asynchronously (due to state changes etc), so we reduce
|
|
29
|
+
// the focus handlers to a promise chain.
|
|
30
|
+
let _id = "";
|
|
31
|
+
idParts.reduce((promise, idPart) => {
|
|
32
|
+
return promise.then(() => {
|
|
33
|
+
_id = _id ? `${_id}_${idPart}` : idPart;
|
|
34
|
+
return (this.focusHandlers[_id] || []).reduce((_promise, fn) => {
|
|
35
|
+
const status = fn(); // Either undefined or a Promise.
|
|
36
|
+
return status && status.then ? status : Promise.resolve();
|
|
37
|
+
}, Promise.resolve());
|
|
38
|
+
});
|
|
39
|
+
}, Promise.resolve()).then(() => {
|
|
40
|
+
const container = this.formContext.utils.getSchemaElementById(id);
|
|
41
|
+
const elem = container || document.querySelector(`#laji-form-error-container-${id}`);
|
|
42
|
+
const input = document.querySelector(`#${id}`);
|
|
43
|
+
if (elem)
|
|
44
|
+
utils_1.scrollIntoViewIfNeeded(elem, this.formContext.topOffset, this.formContext.bottomOffset);
|
|
45
|
+
if (input && input.focus)
|
|
46
|
+
input.focus();
|
|
47
|
+
if (!elem)
|
|
48
|
+
return;
|
|
49
|
+
utils_1.highlightElem(elem);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
focusNextInput(reverse = false) {
|
|
53
|
+
if (!this.formContext.formRef.current) {
|
|
54
|
+
console.warn("Focus service can't doesn't have ref to the form");
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
return this.formContext.utils.focusNextInput(reverse);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.default = FocusService;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RJSFSchema } from "@rjsf/utils";
|
|
2
|
+
export default class IdService {
|
|
3
|
+
private tmpIdTree;
|
|
4
|
+
private formData;
|
|
5
|
+
constructor(schema: RJSFSchema, formData: any);
|
|
6
|
+
setSchema(schema: RJSFSchema): void;
|
|
7
|
+
setFormData(formData: any): void;
|
|
8
|
+
addLajiFormIds(formData: any, immutably?: boolean): [any, {
|
|
9
|
+
[id: string]: true;
|
|
10
|
+
}];
|
|
11
|
+
getAllLajiFormIdsDeeply(formData: any): {
|
|
12
|
+
[id: string]: true;
|
|
13
|
+
};
|
|
14
|
+
removeLajiFormIds(formData: any): any;
|
|
15
|
+
getUUID: (item: any) => any;
|
|
16
|
+
findPointerForLajiFormId(tmpIdTree: any, formData: any, lajiFormId: string | number): string | undefined;
|
|
17
|
+
getJSONPointerFromLajiFormIdAndRelativePointer(lajiFormId: string | number, relativePointer: string): string;
|
|
18
|
+
getJSONPointerFromLajiFormIdAndFormDataAndIdSchemaId(idSchemaId: string, lajiFormId: string | number): string;
|
|
19
|
+
getRelativePointer(idSchemaId: string, lajiFormId: string | number): string | undefined;
|
|
20
|
+
getRelativeTmpIdTree(id: string): any;
|
|
21
|
+
}
|
|
22
|
+
export declare function createTmpIdTree(schema: RJSFSchema): {} | undefined;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createTmpIdTree = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
class IdService {
|
|
6
|
+
constructor(schema, formData) {
|
|
7
|
+
this.getUUID = (item) => item ? (item.id || item._lajiFormId) : undefined;
|
|
8
|
+
this.tmpIdTree = createTmpIdTree(schema);
|
|
9
|
+
this.formData = formData;
|
|
10
|
+
}
|
|
11
|
+
setSchema(schema) {
|
|
12
|
+
this.tmpIdTree = createTmpIdTree(schema);
|
|
13
|
+
}
|
|
14
|
+
setFormData(formData) {
|
|
15
|
+
this.formData = formData;
|
|
16
|
+
}
|
|
17
|
+
addLajiFormIds(formData, immutably = true) {
|
|
18
|
+
return utils_1.addLajiFormIds(formData, this.tmpIdTree, immutably);
|
|
19
|
+
}
|
|
20
|
+
getAllLajiFormIdsDeeply(formData) {
|
|
21
|
+
return utils_1.getAllLajiFormIdsDeeply(formData, this.tmpIdTree);
|
|
22
|
+
}
|
|
23
|
+
removeLajiFormIds(formData) {
|
|
24
|
+
return utils_1.removeLajiFormIds(formData, this.tmpIdTree);
|
|
25
|
+
}
|
|
26
|
+
findPointerForLajiFormId(tmpIdTree = {}, formData, lajiFormId) {
|
|
27
|
+
if (tmpIdTree._hasId) {
|
|
28
|
+
if (Array.isArray(formData)) {
|
|
29
|
+
for (let idx in (formData || [])) {
|
|
30
|
+
const item = formData[idx];
|
|
31
|
+
if (this.getUUID(item) === lajiFormId) {
|
|
32
|
+
return "/" + idx;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else if (formData && this.getUUID(formData) === lajiFormId) {
|
|
37
|
+
return "";
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
for (const k of Object.keys(tmpIdTree)) {
|
|
41
|
+
if (utils_1.isObject(formData[k])) {
|
|
42
|
+
const find = this.findPointerForLajiFormId(tmpIdTree[k], formData[k], lajiFormId);
|
|
43
|
+
if (find !== undefined || find === "") {
|
|
44
|
+
return `/${k}${find}`;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else if (Array.isArray(formData[k])) {
|
|
48
|
+
for (const i in formData[k]) {
|
|
49
|
+
const item = formData[k][i];
|
|
50
|
+
const find = this.findPointerForLajiFormId(tmpIdTree[k], item, lajiFormId);
|
|
51
|
+
if (find !== undefined || find === "") {
|
|
52
|
+
return `/${k}/${i}${find}`;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
getJSONPointerFromLajiFormIdAndRelativePointer(lajiFormId, relativePointer) {
|
|
60
|
+
const containerPointer = this.findPointerForLajiFormId(this.tmpIdTree, this.formData, lajiFormId);
|
|
61
|
+
if (!containerPointer) {
|
|
62
|
+
return "";
|
|
63
|
+
}
|
|
64
|
+
return containerPointer + relativePointer;
|
|
65
|
+
}
|
|
66
|
+
getJSONPointerFromLajiFormIdAndFormDataAndIdSchemaId(idSchemaId, lajiFormId) {
|
|
67
|
+
const relativePointer = this.getRelativePointer(idSchemaId, lajiFormId);
|
|
68
|
+
return this.getJSONPointerFromLajiFormIdAndRelativePointer(lajiFormId, relativePointer || "");
|
|
69
|
+
}
|
|
70
|
+
getRelativePointer(idSchemaId, lajiFormId) {
|
|
71
|
+
var _a;
|
|
72
|
+
const containerPointer = this.findPointerForLajiFormId(this.tmpIdTree, this.formData, lajiFormId);
|
|
73
|
+
if (!containerPointer) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const indicesCount = ((_a = containerPointer.match(/\/[0-9]+/g)) === null || _a === void 0 ? void 0 : _a.length) || 0;
|
|
77
|
+
const containerPointerWithoutArrayIndices = containerPointer.replace(/[0-9]+/g, "");
|
|
78
|
+
const thisPointer = idSchemaId.replace("root", "").replace(/_/g, "/");
|
|
79
|
+
let thisPointerWithoutContainerIndices = thisPointer;
|
|
80
|
+
for (let i = indicesCount; i > 0; i--) {
|
|
81
|
+
thisPointerWithoutContainerIndices = thisPointerWithoutContainerIndices.replace(/[0-9]+/, "");
|
|
82
|
+
}
|
|
83
|
+
return thisPointerWithoutContainerIndices.replace(containerPointerWithoutArrayIndices, "");
|
|
84
|
+
}
|
|
85
|
+
getRelativeTmpIdTree(id) {
|
|
86
|
+
let tmpIdTree = this.tmpIdTree;
|
|
87
|
+
if (!tmpIdTree) {
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
const treePath = id.replace(/root|_[0-9]+|_/g, "_").split("_").filter(i => i);
|
|
91
|
+
for (const k of treePath) {
|
|
92
|
+
if (tmpIdTree[k]) {
|
|
93
|
+
tmpIdTree = tmpIdTree[k];
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
tmpIdTree = undefined;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return tmpIdTree;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.default = IdService;
|
|
104
|
+
function createTmpIdTree(schema) {
|
|
105
|
+
function walk(_schema) {
|
|
106
|
+
if (_schema.properties) {
|
|
107
|
+
const _walked = Object.keys(_schema.properties).reduce((paths, key) => {
|
|
108
|
+
const walked = walk(_schema.properties[key]);
|
|
109
|
+
if (walked) {
|
|
110
|
+
paths[key] = walked;
|
|
111
|
+
}
|
|
112
|
+
return paths;
|
|
113
|
+
}, {});
|
|
114
|
+
if (Object.keys(_walked).length)
|
|
115
|
+
return _walked;
|
|
116
|
+
}
|
|
117
|
+
else if (_schema.type === "array" && _schema.items.type === "object") {
|
|
118
|
+
return Object.keys(_schema.items.properties).reduce((paths, key) => {
|
|
119
|
+
const walked = walk(_schema.items.properties[key]);
|
|
120
|
+
if (walked) {
|
|
121
|
+
paths[key] = walked;
|
|
122
|
+
}
|
|
123
|
+
return paths;
|
|
124
|
+
}, { _hasId: true });
|
|
125
|
+
}
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
return walk(schema);
|
|
129
|
+
}
|
|
130
|
+
exports.createTmpIdTree = createTmpIdTree;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FormContext } from "../components/LajiForm";
|
|
3
|
+
export declare type KeyFunctions = {
|
|
4
|
+
[fnName: string]: (e: KeyboardEvent, options: any) => boolean | void;
|
|
5
|
+
};
|
|
6
|
+
interface ShortcutKey {
|
|
7
|
+
fn: string;
|
|
8
|
+
target?: string;
|
|
9
|
+
[param: string]: any;
|
|
10
|
+
}
|
|
11
|
+
export declare type ShortcutKeys = Record<string, ShortcutKey>;
|
|
12
|
+
export interface InternalKeyHandler extends ShortcutKey {
|
|
13
|
+
conditions: ((e: KeyboardEvent) => boolean)[];
|
|
14
|
+
}
|
|
15
|
+
declare type InternalKeyHandlers = InternalKeyHandler[];
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* A service for adding key listeners. Key events are handled in a custom event handling system, which allows many useful
|
|
19
|
+
* features like listening to DOM document root, fine grained control over the order of event bubbling etc and passing any
|
|
20
|
+
* needed data to the event handler.
|
|
21
|
+
*
|
|
22
|
+
* When initialized, it adds a global keydown listener to the document which handles the LajiForm key shortcuts defined in
|
|
23
|
+
* uiSchema["ui:shortcuts"].
|
|
24
|
+
*
|
|
25
|
+
**/
|
|
26
|
+
export default class KeyhandlerService {
|
|
27
|
+
shortcuts: ShortcutKeys;
|
|
28
|
+
private keyHandlers;
|
|
29
|
+
private keyHandlerTargets;
|
|
30
|
+
private keyHandleListeners;
|
|
31
|
+
private keyHandleIdFunctions;
|
|
32
|
+
private blocked;
|
|
33
|
+
private formContext;
|
|
34
|
+
private globalEventsRootHandler;
|
|
35
|
+
private globalEventHandlers;
|
|
36
|
+
constructor(formContext: FormContext);
|
|
37
|
+
initialize(): void;
|
|
38
|
+
destroy(): void;
|
|
39
|
+
block(): void;
|
|
40
|
+
unblock(): void;
|
|
41
|
+
setShortcuts(shortcuts: ShortcutKeys | undefined, keyFunctions: KeyFunctions): void;
|
|
42
|
+
setFormContext(formContext: FormContext): void;
|
|
43
|
+
getKeyHandlers(shortcuts?: ShortcutKeys): InternalKeyHandlers;
|
|
44
|
+
addKeyHandler: (id: string, keyFunctions: KeyFunctions, additionalParams?: any) => void;
|
|
45
|
+
removeKeyHandler: (_id: string, _keyFunctions: {
|
|
46
|
+
[fnName: string]: () => boolean | void;
|
|
47
|
+
}) => void;
|
|
48
|
+
onKeyDown(e: KeyboardEvent): void;
|
|
49
|
+
/**
|
|
50
|
+
* Global event handlers are listened for the whole DOM document. React can't listen to events on document level, hence this is useful.
|
|
51
|
+
**/
|
|
52
|
+
addGlobalEventHandler(name: string, fn: React.EventHandler<any>): void;
|
|
53
|
+
removeGlobalEventHandler(name: string, fn: React.EventHandler<any>): void;
|
|
54
|
+
private handleKeysWith;
|
|
55
|
+
}
|
|
56
|
+
export {};
|