@luomus/laji-form 15.1.4 → 15.1.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/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 +616 -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/AsArrayField.d.ts +292 -0
- package/lib/components/fields/AsArrayField.js +38 -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 +172 -0
- package/lib/components/fields/ImageArrayField.js +699 -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/PdfArrayField.d.ts +21 -0
- package/lib/components/fields/PdfArrayField.js +40 -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 +618 -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 +847 -0
- package/lib/utils.d.ts +167 -0
- package/lib/utils.js +1185 -0
- package/lib/validation.d.ts +7 -0
- package/lib/validation.js +141 -0
- package/package.json +2 -2
- package/patches/protractor++webdriver-manager+12.1.8.patch +0 -20395
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Translations, Lang } from "./components/LajiForm";
|
|
2
|
+
interface Query {
|
|
3
|
+
[param: string]: any;
|
|
4
|
+
}
|
|
5
|
+
interface Options {
|
|
6
|
+
failSilently?: boolean;
|
|
7
|
+
[option: string]: any;
|
|
8
|
+
}
|
|
9
|
+
export interface ApiClientImplementation {
|
|
10
|
+
fetch: (path: string, query: Query, options: any) => Promise<any>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* ApiClient "interface". Wraps the given apiClient as a singleton object.
|
|
14
|
+
* Given apiClient must implement fetch().
|
|
15
|
+
*/
|
|
16
|
+
export default class ApiClient {
|
|
17
|
+
apiClient: ApiClientImplementation;
|
|
18
|
+
lang: Lang;
|
|
19
|
+
translations: Translations;
|
|
20
|
+
cache: {
|
|
21
|
+
[path: string]: {
|
|
22
|
+
[cacheKey: string]: Promise<any>;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
on: {
|
|
26
|
+
[path: string]: (() => void)[];
|
|
27
|
+
};
|
|
28
|
+
constructor(apiClient: ApiClientImplementation, lang: Lang | undefined, translations: Translations);
|
|
29
|
+
/**
|
|
30
|
+
* Implementing apiClient must return a promise that passes the raw response as 1st arg.
|
|
31
|
+
* @param path URL for GET.
|
|
32
|
+
* @param query Object, where keys are param names and values are param values.
|
|
33
|
+
* @returns a Promise.
|
|
34
|
+
*/
|
|
35
|
+
fetchRaw(path: string, query?: Query, options?: any): Promise<any>;
|
|
36
|
+
fetch<T>(path: string, query?: Query, options?: Options): Promise<T>;
|
|
37
|
+
getCacheKey(query?: Query, options?: Options): string;
|
|
38
|
+
fetchCached<T>(path: string, query?: Query, options?: Options): Promise<T>;
|
|
39
|
+
invalidateCachePath(path: string): void;
|
|
40
|
+
invalidateCachePathQuery(path: string, query: string): void;
|
|
41
|
+
flushCache: () => void;
|
|
42
|
+
onCachePathInvalidation(path: string, callback: () => void): void;
|
|
43
|
+
removeOnCachePathInvalidation(path: string, callback: () => void): void;
|
|
44
|
+
setLang(lang: Lang): void;
|
|
45
|
+
}
|
|
46
|
+
export {};
|
package/lib/ApiClient.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
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
|
+
/**
|
|
15
|
+
* ApiClient "interface". Wraps the given apiClient as a singleton object.
|
|
16
|
+
* Given apiClient must implement fetch().
|
|
17
|
+
*/
|
|
18
|
+
class ApiClient {
|
|
19
|
+
constructor(apiClient, lang = "en", translations) {
|
|
20
|
+
this.cache = {};
|
|
21
|
+
this.on = {};
|
|
22
|
+
this.flushCache = () => {
|
|
23
|
+
this.cache = {};
|
|
24
|
+
};
|
|
25
|
+
this.apiClient = apiClient;
|
|
26
|
+
this.lang = lang;
|
|
27
|
+
this.translations = translations;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Implementing apiClient must return a promise that passes the raw response as 1st arg.
|
|
31
|
+
* @param path URL for GET.
|
|
32
|
+
* @param query Object, where keys are param names and values are param values.
|
|
33
|
+
* @returns a Promise.
|
|
34
|
+
*/
|
|
35
|
+
fetchRaw(path, query, options) {
|
|
36
|
+
const _query = Object.assign({ lang: this.lang }, (query || {}));
|
|
37
|
+
if (!_query.lang) {
|
|
38
|
+
delete _query.lang;
|
|
39
|
+
}
|
|
40
|
+
return this.apiClient.fetch(path, _query, options).catch(() => {
|
|
41
|
+
throw new Error(this.translations[this.lang].RequestFailed);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
fetch(path, query, options = {}) {
|
|
45
|
+
const { failSilently = false } = options, fetchOptions = __rest(options, ["failSilently"]);
|
|
46
|
+
return this.fetchRaw(path, query, fetchOptions).then(response => {
|
|
47
|
+
if (!failSilently && response.status >= 400) {
|
|
48
|
+
throw new Error("Request failed");
|
|
49
|
+
}
|
|
50
|
+
return response.json();
|
|
51
|
+
}).catch(() => {
|
|
52
|
+
if (this.cache[path])
|
|
53
|
+
delete this.cache[path][this.getCacheKey(query, options)];
|
|
54
|
+
throw new Error(this.translations[this.lang].RequestFailed);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
getCacheKey(query, options) {
|
|
58
|
+
return JSON.stringify(query) + JSON.stringify(options);
|
|
59
|
+
}
|
|
60
|
+
fetchCached(path, query, options) {
|
|
61
|
+
const cacheKey = this.getCacheKey(query, options);
|
|
62
|
+
if (!this.cache[path])
|
|
63
|
+
this.cache[path] = {};
|
|
64
|
+
this.cache[path][cacheKey] = cacheKey in this.cache[path] ? this.cache[path][cacheKey] : this.fetch(path, query, options);
|
|
65
|
+
return this.cache[path][cacheKey];
|
|
66
|
+
}
|
|
67
|
+
invalidateCachePath(path) {
|
|
68
|
+
delete this.cache[path];
|
|
69
|
+
if (this.on[path]) {
|
|
70
|
+
this.on[path].forEach(callback => callback());
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//TODO on invalidation callbacks
|
|
74
|
+
invalidateCachePathQuery(path, query) {
|
|
75
|
+
if (this.cache[path])
|
|
76
|
+
delete this.cache[path][query];
|
|
77
|
+
}
|
|
78
|
+
onCachePathInvalidation(path, callback) {
|
|
79
|
+
if (!this.on[path])
|
|
80
|
+
this.on[path] = [];
|
|
81
|
+
this.on[path].push(callback);
|
|
82
|
+
}
|
|
83
|
+
removeOnCachePathInvalidation(path, callback) {
|
|
84
|
+
if (this.on[path]) {
|
|
85
|
+
this.on[path] = this.on[path].filter(fn => fn !== callback);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
setLang(lang) {
|
|
89
|
+
this.lang = lang;
|
|
90
|
+
this.flushCache();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.default = ApiClient;
|
package/lib/Context.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare const _default: (nameSpace?: number | string) => Record<string, unknown>;
|
|
2
|
+
/**
|
|
3
|
+
* A singleton context container for accessing state between components. Should be used for vars that shouldn't affect React change detection, e.g. not suitable to be stored in React context or are updated mutably.
|
|
4
|
+
*
|
|
5
|
+
* Empty namespace "" is used for global vars.
|
|
6
|
+
*/
|
|
7
|
+
export default _default;
|
|
8
|
+
export declare function clear(): void;
|
package/lib/Context.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.clear = void 0;
|
|
4
|
+
let singletonContext = {};
|
|
5
|
+
/**
|
|
6
|
+
* A singleton context container for accessing state between components. Should be used for vars that shouldn't affect React change detection, e.g. not suitable to be stored in React context or are updated mutably.
|
|
7
|
+
*
|
|
8
|
+
* Empty namespace "" is used for global vars.
|
|
9
|
+
*/
|
|
10
|
+
exports.default = (nameSpace = "") => {
|
|
11
|
+
if (!singletonContext[nameSpace])
|
|
12
|
+
singletonContext[nameSpace] = {};
|
|
13
|
+
return singletonContext[nameSpace];
|
|
14
|
+
};
|
|
15
|
+
function clear() {
|
|
16
|
+
singletonContext = {};
|
|
17
|
+
}
|
|
18
|
+
exports.clear = clear;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FieldProps, WidgetProps } from "./LajiForm";
|
|
3
|
+
declare type Constructor<T> = new (...args: any[]) => T;
|
|
4
|
+
interface LajiFormComponentForBaseComponent<P, S> extends React.Component<P, S> {
|
|
5
|
+
getStateFromProps?(props: P): S;
|
|
6
|
+
UNSAFE_componentWillReceiveProps?(props: Readonly<P>, nextContext?: any): void;
|
|
7
|
+
}
|
|
8
|
+
export declare function BaseComponent<P extends FieldProps | WidgetProps, S, LFC extends Constructor<LajiFormComponentForBaseComponent<P, S>>>(ComposedComponent: LFC): any;
|
|
9
|
+
export default BaseComponent;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseComponent = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
function BaseComponent(ComposedComponent) {
|
|
6
|
+
var _a;
|
|
7
|
+
return _a = class BaseComponent extends ComposedComponent {
|
|
8
|
+
constructor(...args) {
|
|
9
|
+
const props = args[0];
|
|
10
|
+
super(props);
|
|
11
|
+
if (!this.state && this.getStateFromProps)
|
|
12
|
+
this.state = this.getStateFromProps(props);
|
|
13
|
+
}
|
|
14
|
+
UNSAFE_componentWillReceiveProps(props, nextContext) {
|
|
15
|
+
if (super.UNSAFE_componentWillReceiveProps) {
|
|
16
|
+
super.UNSAFE_componentWillReceiveProps(props, nextContext);
|
|
17
|
+
}
|
|
18
|
+
else if (this.getStateFromProps) {
|
|
19
|
+
const state = this.getStateFromProps(props);
|
|
20
|
+
if (state)
|
|
21
|
+
this.setState(state);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
_a.displayName = utils_1.getReactComponentName(ComposedComponent),
|
|
26
|
+
_a;
|
|
27
|
+
}
|
|
28
|
+
exports.BaseComponent = BaseComponent;
|
|
29
|
+
exports.default = BaseComponent;
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as PropTypes from "prop-types";
|
|
3
|
+
import { FailedBackgroundJobsPanel } from "./components";
|
|
4
|
+
import { ReactUtilsType } from "../utils";
|
|
5
|
+
import { HasMaybeChildren, Theme } from "../themes/theme";
|
|
6
|
+
import { ContextProps } from "../ReactContext";
|
|
7
|
+
import Form from "@rjsf/core";
|
|
8
|
+
import { FieldProps as RJSFFieldProps, WidgetProps as RJSFWidgetProps, Field, Widget, TemplatesType } from "@rjsf/utils";
|
|
9
|
+
import ApiClient, { ApiClientImplementation } from "../ApiClient";
|
|
10
|
+
import KeyHandlerService, { ShortcutKeys } from "../services/key-handler-service";
|
|
11
|
+
import SettingsService, { Settings } from "../services/settings-service";
|
|
12
|
+
import FocusService from "../services/focus-service";
|
|
13
|
+
import BlockerService from "../services/blocker-service";
|
|
14
|
+
import CustomEventService from "../services/custom-event-service";
|
|
15
|
+
import SubmitHookService, { SubmitHook } from "../services/submit-hook-service";
|
|
16
|
+
import DOMIdService from "../services/dom-id-service";
|
|
17
|
+
import IdService from "../services/id-service";
|
|
18
|
+
import RootInstanceService from "../services/root-instance-service";
|
|
19
|
+
import SingletonMapService from "../services/singleton-map-service";
|
|
20
|
+
export interface LajiFormProps extends HasMaybeChildren {
|
|
21
|
+
apiClient?: ApiClientImplementation;
|
|
22
|
+
lang?: Lang;
|
|
23
|
+
formData?: any;
|
|
24
|
+
schema?: any;
|
|
25
|
+
uiSchema?: any;
|
|
26
|
+
topOffset?: number;
|
|
27
|
+
bottomOffset?: number;
|
|
28
|
+
formContext?: any;
|
|
29
|
+
uiSchemaContext?: any;
|
|
30
|
+
settings?: any;
|
|
31
|
+
id?: string;
|
|
32
|
+
googleApiKey?: string;
|
|
33
|
+
notifier?: Notifier;
|
|
34
|
+
fields?: {
|
|
35
|
+
[name: string]: Field;
|
|
36
|
+
};
|
|
37
|
+
widgets?: {
|
|
38
|
+
[name: string]: Widget;
|
|
39
|
+
};
|
|
40
|
+
templates?: {
|
|
41
|
+
[name: string]: TemplatesType;
|
|
42
|
+
};
|
|
43
|
+
autoFocus?: boolean;
|
|
44
|
+
componentDidMount?: () => void;
|
|
45
|
+
onError?: (e: Error, i: React.ErrorInfo) => void;
|
|
46
|
+
onChange?: (formData: any) => void;
|
|
47
|
+
optimizeOnChange?: boolean;
|
|
48
|
+
showShortcutButton?: boolean;
|
|
49
|
+
renderSubmit?: boolean;
|
|
50
|
+
submitText?: string;
|
|
51
|
+
onSubmit?: (data: {
|
|
52
|
+
formData: any;
|
|
53
|
+
}) => void;
|
|
54
|
+
onValidationError?: (extraErrors: any) => void;
|
|
55
|
+
validators?: any;
|
|
56
|
+
warnings?: any;
|
|
57
|
+
onSettingsChange?: (settings: any, global: boolean) => void;
|
|
58
|
+
mediaMetadata?: MediaMetadata;
|
|
59
|
+
theme?: Theme;
|
|
60
|
+
lajiGeoServerAddress?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface LajiFormState {
|
|
63
|
+
submitHooks?: SubmitHook[];
|
|
64
|
+
formContext: FormContext;
|
|
65
|
+
formData?: any;
|
|
66
|
+
extraErrors?: any;
|
|
67
|
+
error?: boolean;
|
|
68
|
+
runningSubmitHooks?: boolean;
|
|
69
|
+
}
|
|
70
|
+
export interface MediaMetadata {
|
|
71
|
+
capturerVerbatim: string;
|
|
72
|
+
intellectualOwner: string;
|
|
73
|
+
intellectualRights: string;
|
|
74
|
+
}
|
|
75
|
+
export interface FormContext {
|
|
76
|
+
translations: ByLang;
|
|
77
|
+
lang: Lang;
|
|
78
|
+
uiSchemaContext: any;
|
|
79
|
+
formRef: React.RefObject<Form>;
|
|
80
|
+
topOffset: number;
|
|
81
|
+
bottomOffset: number;
|
|
82
|
+
formID: string;
|
|
83
|
+
googleApiKey: string;
|
|
84
|
+
notifier: Notifier;
|
|
85
|
+
apiClient: ApiClient;
|
|
86
|
+
Label: React.Component;
|
|
87
|
+
formDataTransformers?: any[];
|
|
88
|
+
_parentLajiFormId?: number;
|
|
89
|
+
mediaMetadata?: MediaMetadata;
|
|
90
|
+
contextId: number;
|
|
91
|
+
theme: Theme;
|
|
92
|
+
setTimeout: (fn: () => void, time?: number) => void;
|
|
93
|
+
utils: ReactUtilsType;
|
|
94
|
+
lajiGeoServerAddress: string;
|
|
95
|
+
globals: Record<string, unknown>;
|
|
96
|
+
services: {
|
|
97
|
+
keyHandler: KeyHandlerService;
|
|
98
|
+
settings: SettingsService;
|
|
99
|
+
focus: FocusService;
|
|
100
|
+
blocker: BlockerService;
|
|
101
|
+
customEvents: CustomEventService;
|
|
102
|
+
submitHooks: SubmitHookService;
|
|
103
|
+
DOMIds: DOMIdService;
|
|
104
|
+
ids: IdService;
|
|
105
|
+
rootInstance: RootInstanceService;
|
|
106
|
+
singletonMap: SingletonMapService;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
export declare type Lang = "fi" | "en" | "sv";
|
|
110
|
+
export interface FieldProps extends RJSFFieldProps<any, any, FormContext> {
|
|
111
|
+
uiSchema: any;
|
|
112
|
+
errorSchema: any;
|
|
113
|
+
formContext: FormContext;
|
|
114
|
+
}
|
|
115
|
+
export interface WidgetProps extends RJSFWidgetProps<any, any, FormContext> {
|
|
116
|
+
uiSchema: any;
|
|
117
|
+
errorSchema: any;
|
|
118
|
+
formContext: FormContext;
|
|
119
|
+
}
|
|
120
|
+
export declare type NotifyMessager = (msg: string) => void;
|
|
121
|
+
export interface Notifier {
|
|
122
|
+
success: NotifyMessager;
|
|
123
|
+
info: NotifyMessager;
|
|
124
|
+
warning: NotifyMessager;
|
|
125
|
+
error: NotifyMessager;
|
|
126
|
+
}
|
|
127
|
+
export declare type ByLang = {
|
|
128
|
+
[key: string]: string;
|
|
129
|
+
};
|
|
130
|
+
export declare type Translations = Record<Lang, ByLang>;
|
|
131
|
+
export default class LajiForm extends React.Component<LajiFormProps, LajiFormState> {
|
|
132
|
+
static contextType: React.Context<ContextProps>;
|
|
133
|
+
private contextMemoizeKey;
|
|
134
|
+
private contextFormMemoizeKey;
|
|
135
|
+
memoizedContext: ContextProps;
|
|
136
|
+
memoizedFormContext: FormContext;
|
|
137
|
+
translations: Translations;
|
|
138
|
+
bgJobRef: React.RefObject<FailedBackgroundJobsPanel>;
|
|
139
|
+
shortcutHelpRef: React.RefObject<any>;
|
|
140
|
+
apiClient: ApiClient;
|
|
141
|
+
_id: number;
|
|
142
|
+
propagateSubmit: boolean;
|
|
143
|
+
formRef: React.RefObject<Form<any, import("@rjsf/utils").RJSFSchema, any>>;
|
|
144
|
+
mounted: boolean;
|
|
145
|
+
keyCombo: string;
|
|
146
|
+
defaultNotifier: Notifier;
|
|
147
|
+
validating: boolean;
|
|
148
|
+
cachedNonliveValidations: any;
|
|
149
|
+
helpVisible: boolean;
|
|
150
|
+
helpTimeout: number;
|
|
151
|
+
helpStarted: boolean;
|
|
152
|
+
eventListeners: [typeof document | typeof window, string, (e: Event) => void][];
|
|
153
|
+
timeouts: number[];
|
|
154
|
+
static propTypes: {
|
|
155
|
+
uiSchemaContext: PropTypes.Requireable<object>;
|
|
156
|
+
settings: PropTypes.Requireable<object>;
|
|
157
|
+
validators: PropTypes.Requireable<object>;
|
|
158
|
+
warnings: PropTypes.Requireable<object>;
|
|
159
|
+
};
|
|
160
|
+
static defaultProps: {
|
|
161
|
+
lang: Lang;
|
|
162
|
+
schema: {};
|
|
163
|
+
uiSchema: {};
|
|
164
|
+
};
|
|
165
|
+
constructor(props: LajiFormProps);
|
|
166
|
+
UNSAFE_componentWillReceiveProps(props: LajiFormProps): void;
|
|
167
|
+
getStateFromProps(props: LajiFormProps): LajiFormState;
|
|
168
|
+
getMemoizedFormContext(props: LajiFormProps): FormContext;
|
|
169
|
+
componentDidMount(): void;
|
|
170
|
+
componentWillUnmount(): void;
|
|
171
|
+
componentDidCatch(e: Error, i: React.ErrorInfo): void;
|
|
172
|
+
componentDidUpdate(prevProps: LajiFormProps): void;
|
|
173
|
+
onSubmitHooksChange: (submitHooks: SubmitHook[], callback?: (() => void) | undefined) => void;
|
|
174
|
+
resetShortcuts(shortcuts?: ShortcutKeys): void;
|
|
175
|
+
constructTranslations(): Translations;
|
|
176
|
+
getDefaultNotifier: () => Notifier;
|
|
177
|
+
onChange: ({ formData }: {
|
|
178
|
+
formData: any;
|
|
179
|
+
}) => void;
|
|
180
|
+
getFields: (_fields?: {
|
|
181
|
+
[name: string]: Field<any, import("@rjsf/utils").RJSFSchema, any>;
|
|
182
|
+
} | undefined) => {
|
|
183
|
+
[x: string]: Field<any, import("@rjsf/utils").RJSFSchema, any>;
|
|
184
|
+
};
|
|
185
|
+
getWidgets: (_widgets?: {
|
|
186
|
+
[name: string]: Widget<any, import("@rjsf/utils").RJSFSchema, any>;
|
|
187
|
+
} | undefined) => {
|
|
188
|
+
[x: string]: Widget<any, import("@rjsf/utils").RJSFSchema, any>;
|
|
189
|
+
};
|
|
190
|
+
getTemplates: (_templates?: {
|
|
191
|
+
[name: string]: TemplatesType<any, import("@rjsf/utils").RJSFSchema, any>;
|
|
192
|
+
} | undefined) => {
|
|
193
|
+
[x: string]: TemplatesType<any, import("@rjsf/utils").RJSFSchema, any>;
|
|
194
|
+
};
|
|
195
|
+
getContext: (props: LajiFormProps, context: ContextProps) => ContextProps;
|
|
196
|
+
render(): JSX.Element | null;
|
|
197
|
+
renderSubmitHooks: () => JSX.Element | null | undefined;
|
|
198
|
+
validateAndSubmit: (warnings?: boolean, onlySchema?: boolean) => Promise<void>;
|
|
199
|
+
validate: (warnings?: boolean, nonlive?: boolean, onlySchema?: boolean) => Promise<unknown>;
|
|
200
|
+
onSubmit: (onlySchemaValidations?: "onlySchemaValidations" | undefined) => false | undefined;
|
|
201
|
+
popErrorListIfNeeded: () => void;
|
|
202
|
+
_onDefaultSubmit: (e: React.SyntheticEvent) => void;
|
|
203
|
+
submit: () => void;
|
|
204
|
+
submitOnlySchemaValidations: () => void;
|
|
205
|
+
getShorcutButtonTooltip: () => string | undefined;
|
|
206
|
+
toggleHelp: (e: React.MouseEvent) => void;
|
|
207
|
+
showHelp: () => void;
|
|
208
|
+
dismissHelp: (e: Event | React.SyntheticEvent) => void;
|
|
209
|
+
keyFunctions: {
|
|
210
|
+
navigate: (e: KeyboardEvent, { reverse }: any) => void;
|
|
211
|
+
help: (e: KeyboardEvent, { delay }: any) => boolean;
|
|
212
|
+
revalidate: () => void;
|
|
213
|
+
};
|
|
214
|
+
pushBlockingLoader: () => void;
|
|
215
|
+
popBlockingLoader: () => void;
|
|
216
|
+
getSettings(global?: boolean): {};
|
|
217
|
+
onSettingsChange: (settings: Settings, global?: boolean) => void;
|
|
218
|
+
addEventListener: (target: typeof document | typeof window, name: string, fn: (e: Event) => void) => void;
|
|
219
|
+
setTimeout: (fn: () => void, time?: number) => number;
|
|
220
|
+
destroy: () => void;
|
|
221
|
+
}
|