@luomus/laji-form-builder 1.0.28
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 +3 -0
- package/LICENSE +21 -0
- package/README.md +114 -0
- package/dist/laji-form-builder.js +2 -0
- package/dist/laji-form-builder.js.LICENSE.txt +82 -0
- package/dist/main.js +2 -0
- package/dist/main.js.LICENSE.txt +86 -0
- package/dist/styles.css +4 -0
- package/lib/api-client.d.ts +20 -0
- package/lib/api-client.js +60 -0
- package/lib/api-client.js.map +1 -0
- package/lib/client/LajiFormInterface.d.ts +44 -0
- package/lib/client/LajiFormInterface.js +39 -0
- package/lib/client/LajiFormInterface.js.map +1 -0
- package/lib/client/app.d.ts +9 -0
- package/lib/client/app.js +39 -0
- package/lib/client/app.js.map +1 -0
- package/lib/client/components/Builder.d.ts +101 -0
- package/lib/client/components/Builder.js +357 -0
- package/lib/client/components/Builder.js.map +1 -0
- package/lib/client/components/Context.d.ts +18 -0
- package/lib/client/components/Context.js +25 -0
- package/lib/client/components/Context.js.map +1 -0
- package/lib/client/components/Editor/BasicEditor.d.ts +29 -0
- package/lib/client/components/Editor/BasicEditor.js +185 -0
- package/lib/client/components/Editor/BasicEditor.js.map +1 -0
- package/lib/client/components/Editor/DiffViewer.d.ts +17 -0
- package/lib/client/components/Editor/DiffViewer.js +134 -0
- package/lib/client/components/Editor/DiffViewer.js.map +1 -0
- package/lib/client/components/Editor/Editor.d.ts +111 -0
- package/lib/client/components/Editor/Editor.js +344 -0
- package/lib/client/components/Editor/Editor.js.map +1 -0
- package/lib/client/components/Editor/ElemPicker.d.ts +13 -0
- package/lib/client/components/Editor/ElemPicker.js +170 -0
- package/lib/client/components/Editor/ElemPicker.js.map +1 -0
- package/lib/client/components/Editor/FieldEditor.d.ts +41 -0
- package/lib/client/components/Editor/FieldEditor.js +125 -0
- package/lib/client/components/Editor/FieldEditor.js.map +1 -0
- package/lib/client/components/Editor/Fields.d.ts +27 -0
- package/lib/client/components/Editor/Fields.js +185 -0
- package/lib/client/components/Editor/Fields.js.map +1 -0
- package/lib/client/components/Editor/OptionsEditor.d.ts +20 -0
- package/lib/client/components/Editor/OptionsEditor.js +207 -0
- package/lib/client/components/Editor/OptionsEditor.js.map +1 -0
- package/lib/client/components/Editor/UiSchemaEditor.d.ts +22 -0
- package/lib/client/components/Editor/UiSchemaEditor.js +368 -0
- package/lib/client/components/Editor/UiSchemaEditor.js.map +1 -0
- package/lib/client/components/LajiForm.d.ts +4 -0
- package/lib/client/components/LajiForm.js +32 -0
- package/lib/client/components/LajiForm.js.map +1 -0
- package/lib/client/components/Wizard.d.ts +11 -0
- package/lib/client/components/Wizard.js +364 -0
- package/lib/client/components/Wizard.js.map +1 -0
- package/lib/client/components/components.d.ts +103 -0
- package/lib/client/components/components.js +321 -0
- package/lib/client/components/components.js.map +1 -0
- package/lib/client/services/change-handler-service.d.ts +57 -0
- package/lib/client/services/change-handler-service.js +150 -0
- package/lib/client/services/change-handler-service.js.map +1 -0
- package/lib/client/services/form-service.d.ts +21 -0
- package/lib/client/services/form-service.js +77 -0
- package/lib/client/services/form-service.js.map +1 -0
- package/lib/client/styles.css +227 -0
- package/lib/client/styles.d.ts +2 -0
- package/lib/client/styles.js +5 -0
- package/lib/client/styles.js.map +1 -0
- package/lib/client/themes/bs3.d.ts +3 -0
- package/lib/client/themes/bs3.js +49 -0
- package/lib/client/themes/bs3.js.map +1 -0
- package/lib/client/themes/theme.d.ts +28 -0
- package/lib/client/themes/theme.js +14 -0
- package/lib/client/themes/theme.js.map +1 -0
- package/lib/client/translations.json +272 -0
- package/lib/client/utils.d.ts +63 -0
- package/lib/client/utils.js +370 -0
- package/lib/client/utils.js.map +1 -0
- package/lib/model.d.ts +205 -0
- package/lib/model.js +43 -0
- package/lib/model.js.map +1 -0
- package/lib/services/form-expander-service.d.ts +15 -0
- package/lib/services/form-expander-service.js +77 -0
- package/lib/services/form-expander-service.js.map +1 -0
- package/lib/services/has-cache.d.ts +8 -0
- package/lib/services/has-cache.js +22 -0
- package/lib/services/has-cache.js.map +1 -0
- package/lib/services/metadata-service.d.ts +23 -0
- package/lib/services/metadata-service.js +138 -0
- package/lib/services/metadata-service.js.map +1 -0
- package/lib/utils.d.ts +79 -0
- package/lib/utils.js +117 -0
- package/lib/utils.js.map +1 -0
- package/package.json +114 -0
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
exports.promisify = exports.fullHeightWithOffset = exports.useChain = exports.useBooleanSetter = exports.runAbortable = exports.isSignalAbortError = exports.createRef = exports.handleTranslationChange = exports.scrollIntoViewIfNeeded = exports.getScrollPositionForScrollIntoViewIfNeeded = exports.detectChangePaths = exports.getTranslation = exports.unprefixer = exports.prefixUiSchemaDeeply = exports.unprefixUiSchemaDeeply = exports.alterUiSchemaKeys = exports.prefixSchemaDeeply = exports.unprefixSchemaDeeply = exports.alterSchemaKeys = exports.prefixDeeply = exports.unprefixDeeply = exports.alterObjectKeys = exports.fieldPointerToUiSchemaPointer = exports.fieldPointerToSchemaPointer = exports.getTranslatedUiSchema = exports.propTypesToSchema = exports.getComponentPropTypes = exports.gnmspc = exports.nmspc = exports.CSS_NAMESPACE = exports.classNames = void 0;
|
|
35
|
+
const React = __importStar(require("react"));
|
|
36
|
+
const parse_prop_types_1 = __importDefault(require("parse-prop-types"));
|
|
37
|
+
const memoizee_1 = __importDefault(require("memoizee"));
|
|
38
|
+
const utils_1 = require("../utils");
|
|
39
|
+
const utils_2 = require("@luomus/laji-form/lib/utils");
|
|
40
|
+
const model_1 = require("../model");
|
|
41
|
+
const classNames = (...cs) => cs.filter(s => typeof s === "string").join(" ");
|
|
42
|
+
exports.classNames = classNames;
|
|
43
|
+
exports.CSS_NAMESPACE = "ljb";
|
|
44
|
+
/**
|
|
45
|
+
* Create a CSS Namespace factory relative to the laji-form-builder scope ("ljb").
|
|
46
|
+
*
|
|
47
|
+
* Example:
|
|
48
|
+
* const local = nmspc("local");
|
|
49
|
+
* local(""); // returns "ljb-local"
|
|
50
|
+
* local("foo"); // returns "ljb-local-foo"
|
|
51
|
+
**/
|
|
52
|
+
const nmspc = (_nmspc) => (s) => s === undefined
|
|
53
|
+
? `${exports.CSS_NAMESPACE}${_nmspc ? `-${_nmspc}` : ""}`
|
|
54
|
+
: s
|
|
55
|
+
? `${exports.CSS_NAMESPACE}${_nmspc ? `-${_nmspc}` : ""}-${s}`
|
|
56
|
+
: exports.CSS_NAMESPACE;
|
|
57
|
+
exports.nmspc = nmspc;
|
|
58
|
+
/**
|
|
59
|
+
* CSS namespace relative to global laji-form-builder scope ("ljb").
|
|
60
|
+
*
|
|
61
|
+
* Example:
|
|
62
|
+
* gnmspc(""); // returns "ljb"
|
|
63
|
+
* gnmspc("foo"); // returns "ljb-foo"
|
|
64
|
+
**/
|
|
65
|
+
exports.gnmspc = exports.nmspc();
|
|
66
|
+
const getComponentPropTypes = (field) => field && parse_prop_types_1.default(field);
|
|
67
|
+
exports.getComponentPropTypes = getComponentPropTypes;
|
|
68
|
+
const propTypesToSchema = (propTypes, propPrefix) => {
|
|
69
|
+
const name = propTypes.name || (propTypes.type || {}).name;
|
|
70
|
+
const value = propTypes.value || (propTypes.type || {}).value;
|
|
71
|
+
switch (name) {
|
|
72
|
+
case "shape":
|
|
73
|
+
return { type: "object", properties: Object.keys(value).reduce((properties, prop) => (Object.assign(Object.assign({}, properties), { [typeof propPrefix === "string" ? `${propPrefix}${prop}` : prop]: exports.propTypesToSchema(value[prop], propPrefix) })), {}) };
|
|
74
|
+
case "arrayOf":
|
|
75
|
+
return { type: "array", items: exports.propTypesToSchema(value, propPrefix) };
|
|
76
|
+
case "oneOf":
|
|
77
|
+
return { type: "string", enum: value, enumNames: value };
|
|
78
|
+
case "string":
|
|
79
|
+
return { type: "string" };
|
|
80
|
+
case "number":
|
|
81
|
+
return { type: "number" };
|
|
82
|
+
case "bool":
|
|
83
|
+
return { type: "boolean" };
|
|
84
|
+
case "object":
|
|
85
|
+
case "custom":
|
|
86
|
+
return { type: "object", properties: {} };
|
|
87
|
+
default:
|
|
88
|
+
// console.warn(`Unhandled PropType type ${name}`);
|
|
89
|
+
return { type: "object", properties: {} };
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
exports.propTypesToSchema = propTypesToSchema;
|
|
93
|
+
exports.getTranslatedUiSchema = memoizee_1.default((uiSchema, translations, prefix, schemaForUiSchema) => {
|
|
94
|
+
function translate(obj, schemaForUiSchema) {
|
|
95
|
+
var _a;
|
|
96
|
+
if (model_1.isJSONObject(obj)) {
|
|
97
|
+
return Object.keys(obj).reduce((translated, key) => {
|
|
98
|
+
var _a;
|
|
99
|
+
const propSchemaForUiSchema = (_a = schemaForUiSchema === null || schemaForUiSchema === void 0 ? void 0 : schemaForUiSchema.properties) === null || _a === void 0 ? void 0 : _a[key];
|
|
100
|
+
const _key = propSchemaForUiSchema && prefix ? `${prefix}${key}` : key;
|
|
101
|
+
translated[_key] = translate(obj[key], propSchemaForUiSchema);
|
|
102
|
+
return translated;
|
|
103
|
+
}, {});
|
|
104
|
+
}
|
|
105
|
+
else if (Array.isArray(obj)) {
|
|
106
|
+
return obj.map(item => translate(item, schemaForUiSchema === null || schemaForUiSchema === void 0 ? void 0 : schemaForUiSchema.items));
|
|
107
|
+
}
|
|
108
|
+
if (typeof obj === "string" && obj[0] === "@") {
|
|
109
|
+
return (_a = translations[obj]) !== null && _a !== void 0 ? _a : translations[obj.substr(1)];
|
|
110
|
+
}
|
|
111
|
+
return obj;
|
|
112
|
+
}
|
|
113
|
+
return translate(uiSchema, schemaForUiSchema);
|
|
114
|
+
});
|
|
115
|
+
const fieldPointerToSchemaPointer = (schema, pointer) => {
|
|
116
|
+
if (pointer === "") {
|
|
117
|
+
return pointer;
|
|
118
|
+
}
|
|
119
|
+
let schemaPointer = schema;
|
|
120
|
+
return pointer.split("/").filter(s => s).reduce((resultPointer, s) => {
|
|
121
|
+
if (schemaPointer.items && schemaPointer.items.properties) {
|
|
122
|
+
schemaPointer = schemaPointer.items.properties[s];
|
|
123
|
+
return `${resultPointer}/items/properties/${s}`;
|
|
124
|
+
}
|
|
125
|
+
if (schemaPointer.properties) {
|
|
126
|
+
schemaPointer = schemaPointer.properties[s];
|
|
127
|
+
return `${resultPointer}/properties/${s}`;
|
|
128
|
+
}
|
|
129
|
+
throw new Error(`failed to parse field schema pointer ${pointer}`);
|
|
130
|
+
}, "");
|
|
131
|
+
};
|
|
132
|
+
exports.fieldPointerToSchemaPointer = fieldPointerToSchemaPointer;
|
|
133
|
+
const fieldPointerToUiSchemaPointer = (schema, pointer) => {
|
|
134
|
+
let schemaPointer = schema;
|
|
135
|
+
return pointer.split("/").filter(s => s).reduce((resultPointer, s) => {
|
|
136
|
+
if (schemaPointer.items && schemaPointer.items.properties) {
|
|
137
|
+
schemaPointer = schemaPointer.items.properties[s];
|
|
138
|
+
return `${resultPointer}/items/${s}`;
|
|
139
|
+
}
|
|
140
|
+
if (schemaPointer.properties) {
|
|
141
|
+
schemaPointer = schemaPointer.properties[s];
|
|
142
|
+
return `${resultPointer}/${s}`;
|
|
143
|
+
}
|
|
144
|
+
throw new Error(`failed to parse field uischema pointer ${pointer}`);
|
|
145
|
+
}, "");
|
|
146
|
+
};
|
|
147
|
+
exports.fieldPointerToUiSchemaPointer = fieldPointerToUiSchemaPointer;
|
|
148
|
+
const alterObjectKeys = (obj, replace) => {
|
|
149
|
+
if (utils_1.isObject(obj)) {
|
|
150
|
+
return Object.keys(obj).reduce((translated, key) => (Object.assign(Object.assign({}, translated), { [replace(key)]: exports.alterObjectKeys(obj[key], replace) })), {});
|
|
151
|
+
}
|
|
152
|
+
else if (Array.isArray(obj)) {
|
|
153
|
+
return obj.map(i => exports.alterObjectKeys(i, replace));
|
|
154
|
+
}
|
|
155
|
+
return obj;
|
|
156
|
+
};
|
|
157
|
+
exports.alterObjectKeys = alterObjectKeys;
|
|
158
|
+
const unprefixDeeply = (obj, prefix) => {
|
|
159
|
+
return exports.alterObjectKeys(obj, (key => key.startsWith(prefix) ? key.substr(prefix.length, key.length) : key));
|
|
160
|
+
};
|
|
161
|
+
exports.unprefixDeeply = unprefixDeeply;
|
|
162
|
+
const prefixDeeply = (obj, prefix) => {
|
|
163
|
+
if (prefix === undefined) {
|
|
164
|
+
return obj;
|
|
165
|
+
}
|
|
166
|
+
return exports.alterObjectKeys(obj, (key => `${prefix}${key}`));
|
|
167
|
+
};
|
|
168
|
+
exports.prefixDeeply = prefixDeeply;
|
|
169
|
+
const alterSchemaKeys = (schema, replace) => {
|
|
170
|
+
if (schema.type === "object") {
|
|
171
|
+
return Object.assign(Object.assign({}, schema), { properties: Object.keys(schema.properties).reduce((translated, key) => (Object.assign(Object.assign({}, translated), { [replace(key)]: exports.alterSchemaKeys(schema.properties[key], replace) })), {}) });
|
|
172
|
+
}
|
|
173
|
+
else if (schema.type === "array" && schema.items.type === "object") {
|
|
174
|
+
return Object.assign(Object.assign({}, schema), { items: Object.assign(Object.assign({}, schema.items), { properties: Object.keys(schema.items.properties).reduce((translated, key) => (Object.assign(Object.assign({}, translated), { [replace(key)]: exports.alterSchemaKeys(schema.items.properties[key], replace) })), {}) }) });
|
|
175
|
+
}
|
|
176
|
+
return schema;
|
|
177
|
+
};
|
|
178
|
+
exports.alterSchemaKeys = alterSchemaKeys;
|
|
179
|
+
const unprefixSchemaDeeply = (schema, prefix) => {
|
|
180
|
+
return exports.alterSchemaKeys(schema, (key => key.startsWith(prefix) ? key.substr(prefix.length, key.length) : key));
|
|
181
|
+
};
|
|
182
|
+
exports.unprefixSchemaDeeply = unprefixSchemaDeeply;
|
|
183
|
+
const prefixSchemaDeeply = (schema, prefix) => {
|
|
184
|
+
if (prefix === undefined) {
|
|
185
|
+
return schema;
|
|
186
|
+
}
|
|
187
|
+
return exports.alterSchemaKeys(schema, (key => `${prefix}${key}`));
|
|
188
|
+
};
|
|
189
|
+
exports.prefixSchemaDeeply = prefixSchemaDeeply;
|
|
190
|
+
const alterUiSchemaKeys = (uiSchema, schema, replace) => {
|
|
191
|
+
if (schema
|
|
192
|
+
&& schema.type === "object"
|
|
193
|
+
&& Object.keys(schema.properties).length // For 'custom' prop type
|
|
194
|
+
) {
|
|
195
|
+
return Object.keys(uiSchema).reduce((translated, key) => (Object.assign(Object.assign({}, translated), { [replace(key)]: exports.alterUiSchemaKeys(uiSchema[key], schema.properties[key], replace) })), {});
|
|
196
|
+
}
|
|
197
|
+
else if (schema
|
|
198
|
+
&& schema.type === "array"
|
|
199
|
+
&& schema.items.type === "object"
|
|
200
|
+
&& Object.keys(schema.items.properties).length // For 'custom' prop type
|
|
201
|
+
) {
|
|
202
|
+
if (!uiSchema.items) {
|
|
203
|
+
return uiSchema;
|
|
204
|
+
}
|
|
205
|
+
return Object.assign(Object.assign({}, uiSchema), { items: Object.assign(Object.assign({}, uiSchema.items), Object.keys(schema.items.properties).reduce((translated, key) => {
|
|
206
|
+
if (uiSchema.items[key] && Object.keys(uiSchema.items[key]).length) {
|
|
207
|
+
translated[key] = exports.alterUiSchemaKeys(uiSchema.items[key], schema.items.properties[key], replace);
|
|
208
|
+
}
|
|
209
|
+
return translated;
|
|
210
|
+
}, {})) });
|
|
211
|
+
}
|
|
212
|
+
return uiSchema;
|
|
213
|
+
};
|
|
214
|
+
exports.alterUiSchemaKeys = alterUiSchemaKeys;
|
|
215
|
+
const unprefixUiSchemaDeeply = (uiSchema, schema, prefix) => {
|
|
216
|
+
return exports.alterUiSchemaKeys(uiSchema, schema, (key => key.startsWith(prefix) ? key.substr(prefix.length, key.length) : key));
|
|
217
|
+
};
|
|
218
|
+
exports.unprefixUiSchemaDeeply = unprefixUiSchemaDeeply;
|
|
219
|
+
const prefixUiSchemaDeeply = (uiSchema, schema, prefix) => {
|
|
220
|
+
if (prefix === undefined) {
|
|
221
|
+
return uiSchema;
|
|
222
|
+
}
|
|
223
|
+
return exports.alterUiSchemaKeys(uiSchema, schema, (key => `${prefix}${key}`));
|
|
224
|
+
};
|
|
225
|
+
exports.prefixUiSchemaDeeply = prefixUiSchemaDeeply;
|
|
226
|
+
const unprefixer = (prefix = "") => (s) => s.startsWith(prefix) ? s.substr(prefix.length, s.length) : s;
|
|
227
|
+
exports.unprefixer = unprefixer;
|
|
228
|
+
const getTranslation = (key, translations) => {
|
|
229
|
+
if (typeof key === "string") {
|
|
230
|
+
return translations[key] || (key[0] === "@" && translations[exports.unprefixer("@")(key)] || undefined);
|
|
231
|
+
}
|
|
232
|
+
return;
|
|
233
|
+
};
|
|
234
|
+
exports.getTranslation = getTranslation;
|
|
235
|
+
const detectChangePaths = (eventObject, translatedObj) => {
|
|
236
|
+
const detectChangePaths = (_eventObject, _translatedObj, path) => {
|
|
237
|
+
if (utils_1.isObject(_eventObject) || utils_1.isObject(_translatedObj)) {
|
|
238
|
+
if (!utils_1.isObject(_translatedObj) || !utils_1.isObject(_eventObject)) {
|
|
239
|
+
return [path];
|
|
240
|
+
}
|
|
241
|
+
return Object.keys(Object.assign(Object.assign({}, _eventObject), _translatedObj)).reduce((paths, key) => {
|
|
242
|
+
if (!(key in _eventObject) || !(key in _translatedObj)) {
|
|
243
|
+
const value = ((key in _eventObject) ? _eventObject : _translatedObj)[key];
|
|
244
|
+
if (utils_1.isObject(value) && !Object.keys(value).length) {
|
|
245
|
+
return paths;
|
|
246
|
+
}
|
|
247
|
+
return [...paths, `${path}/${key}`];
|
|
248
|
+
}
|
|
249
|
+
const changes = detectChangePaths(_eventObject[key], _translatedObj[key], `${path}/${key}`);
|
|
250
|
+
return changes.length ? [...paths, ...changes] : paths;
|
|
251
|
+
}, []);
|
|
252
|
+
}
|
|
253
|
+
else if (Array.isArray(_eventObject) || Array.isArray(_translatedObj)) {
|
|
254
|
+
if (!_translatedObj || !_eventObject || _eventObject.length !== _translatedObj.length) {
|
|
255
|
+
return [path];
|
|
256
|
+
}
|
|
257
|
+
return _eventObject.reduce((paths, item, idx) => {
|
|
258
|
+
const changes = detectChangePaths(item, _translatedObj[idx], `${path}/${idx}`);
|
|
259
|
+
return changes.length ? [...paths, ...changes] : paths;
|
|
260
|
+
}, []);
|
|
261
|
+
}
|
|
262
|
+
if (utils_1.parseJSONPointer(eventObject, path) !== utils_1.parseJSONPointer(translatedObj, path)) {
|
|
263
|
+
return [path];
|
|
264
|
+
}
|
|
265
|
+
return [];
|
|
266
|
+
};
|
|
267
|
+
if (!eventObject && translatedObj || eventObject && !translatedObj) {
|
|
268
|
+
return ["/"];
|
|
269
|
+
}
|
|
270
|
+
return detectChangePaths(eventObject, translatedObj, "");
|
|
271
|
+
};
|
|
272
|
+
exports.detectChangePaths = detectChangePaths;
|
|
273
|
+
const getScrollPositionForScrollIntoViewIfNeeded = (elem, topOffset = 0, bottomOffset = 0, container = document.documentElement) => {
|
|
274
|
+
if (!elem)
|
|
275
|
+
return container.scrollTop;
|
|
276
|
+
const elemTop = elem.offsetTop;
|
|
277
|
+
const elemBottom = elemTop + elem.clientHeight;
|
|
278
|
+
const containerTop = container.scrollTop + topOffset;
|
|
279
|
+
const containerBottom = containerTop + container.clientHeight - bottomOffset;
|
|
280
|
+
const toTop = () => containerTop - containerTop + elemTop;
|
|
281
|
+
const toBottom = () => container.scrollTop + elemBottom - containerBottom;
|
|
282
|
+
if (elemTop < containerTop) {
|
|
283
|
+
return toTop();
|
|
284
|
+
}
|
|
285
|
+
else if (elemBottom > containerBottom) {
|
|
286
|
+
// If scrolling to bottom would obscure top, don't scroll.
|
|
287
|
+
return elemTop < toBottom() + topOffset
|
|
288
|
+
? container.scrollTop
|
|
289
|
+
: toBottom();
|
|
290
|
+
}
|
|
291
|
+
return container.scrollTop;
|
|
292
|
+
};
|
|
293
|
+
exports.getScrollPositionForScrollIntoViewIfNeeded = getScrollPositionForScrollIntoViewIfNeeded;
|
|
294
|
+
const scrollIntoViewIfNeeded = (elem, topOffset = 0, bottomOffset = 0, container = document.documentElement) => container.scrollTo(0, exports.getScrollPositionForScrollIntoViewIfNeeded(elem, topOffset, bottomOffset, container));
|
|
295
|
+
exports.scrollIntoViewIfNeeded = scrollIntoViewIfNeeded;
|
|
296
|
+
function handleTranslationChange(obj, events, path, changedPath, context, currentValue, newValue) {
|
|
297
|
+
const doConfirm = (translationKey, value) => !confirm(`${context.translations["editor.confirmDontTranslate"]}\n${translationKey}: ${value}`);
|
|
298
|
+
if (newValue === undefined) {
|
|
299
|
+
if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue[0]) === "@") {
|
|
300
|
+
events.push({ type: "translations", op: "delete", key: currentValue });
|
|
301
|
+
}
|
|
302
|
+
return utils_2.immutableDelete(obj, changedPath);
|
|
303
|
+
}
|
|
304
|
+
else if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue[0]) === "@") {
|
|
305
|
+
events.push({ type: "translations", key: currentValue, value: newValue !== null && newValue !== void 0 ? newValue : "" });
|
|
306
|
+
return obj;
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
const translationKey = `@${path}${changedPath}`;
|
|
310
|
+
if (utils_2.isEmptyString(currentValue)) {
|
|
311
|
+
return utils_2.updateSafelyWithJSONPointer(obj, newValue, changedPath);
|
|
312
|
+
}
|
|
313
|
+
else if (doConfirm(changedPath, newValue)) {
|
|
314
|
+
events.push({
|
|
315
|
+
type: "translations",
|
|
316
|
+
op: "add",
|
|
317
|
+
key: translationKey,
|
|
318
|
+
value: ["fi", "sv", "en"].reduce((byLang, lang) => (Object.assign(Object.assign({}, byLang), { [lang]: lang === context.editorLang ? newValue : currentValue })), {})
|
|
319
|
+
});
|
|
320
|
+
return utils_2.updateSafelyWithJSONPointer(obj, translationKey, changedPath);
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
return utils_2.updateSafelyWithJSONPointer(obj, newValue, changedPath);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
exports.handleTranslationChange = handleTranslationChange;
|
|
328
|
+
const createRef = (value) => ({ current: value });
|
|
329
|
+
exports.createRef = createRef;
|
|
330
|
+
const isSignalAbortError = (e) => e instanceof DOMException && e.name === "AbortError";
|
|
331
|
+
exports.isSignalAbortError = isSignalAbortError;
|
|
332
|
+
const runAbortable = (fn, controllerRef) => __awaiter(void 0, void 0, void 0, function* () {
|
|
333
|
+
var _a;
|
|
334
|
+
(_a = controllerRef.current) === null || _a === void 0 ? void 0 : _a.abort();
|
|
335
|
+
const controller = new AbortController();
|
|
336
|
+
controllerRef.current = controller;
|
|
337
|
+
try {
|
|
338
|
+
return yield fn(controller.signal);
|
|
339
|
+
}
|
|
340
|
+
catch (e) {
|
|
341
|
+
if (!exports.isSignalAbortError(e)) {
|
|
342
|
+
throw e;
|
|
343
|
+
}
|
|
344
|
+
return e;
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
exports.runAbortable = runAbortable;
|
|
348
|
+
function useBooleanSetter(value) {
|
|
349
|
+
const [open, setOpen] = React.useState(value);
|
|
350
|
+
// (complains even though inside a custom hook).
|
|
351
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
352
|
+
const openStateToCallback = (v) => React.useCallback(() => setOpen(v), [v]);
|
|
353
|
+
return [open, openStateToCallback(true), openStateToCallback(false)];
|
|
354
|
+
}
|
|
355
|
+
exports.useBooleanSetter = useBooleanSetter;
|
|
356
|
+
/**
|
|
357
|
+
* Chain two function calls.
|
|
358
|
+
*/
|
|
359
|
+
function useChain(fn1, fn2) {
|
|
360
|
+
return React.useCallback((...params) => {
|
|
361
|
+
fn1 === null || fn1 === void 0 ? void 0 : fn1(...params);
|
|
362
|
+
fn2();
|
|
363
|
+
}, [fn1, fn2]);
|
|
364
|
+
}
|
|
365
|
+
exports.useChain = useChain;
|
|
366
|
+
const fullHeightWithOffset = (offset) => `calc(100% - ${offset}px)`;
|
|
367
|
+
exports.fullHeightWithOffset = fullHeightWithOffset;
|
|
368
|
+
const promisify = (fn) => (params) => new Promise(resolve => fn(params, resolve));
|
|
369
|
+
exports.promisify = promisify;
|
|
370
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/client/utils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EAAE,EAAE;QAC3C,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAG,GAAG,MAAM,CAAC,CAAC;QACjB,GAAG,EAAE,CAAC;IACP,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAChB,CAAC;AALD,4BAKC;AAEM,MAAM,oBAAoB,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,eAAe,MAAM,KAAK,CAAC;AAAtE,QAAA,oBAAoB,wBAAkD;AAE5E,MAAM,SAAS,GAAG,CAAO,EAAuD,EAAE,EAAE,CAC1F,CAAC,MAAS,EAAE,EAAE,CAAC,IAAI,OAAO,CAAW,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AADzD,QAAA,SAAS,aACgD"}
|
package/lib/model.d.ts
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
export declare enum PropertyRange {
|
|
2
|
+
Int = "xsd:integer",
|
|
3
|
+
Boolean = "xsd:boolean",
|
|
4
|
+
String = "xsd:string",
|
|
5
|
+
Id = "@id",
|
|
6
|
+
PositiveInteger = "xsd:positiveInteger",
|
|
7
|
+
DateTime = "xsd:dateTime",
|
|
8
|
+
NonNegativeInteger = "xsd:nonNegativeInteger",
|
|
9
|
+
keyValue = "MZ.keyValue",
|
|
10
|
+
keyAny = "MZ.keyAny",
|
|
11
|
+
Decimal = "xsd:decimal"
|
|
12
|
+
}
|
|
13
|
+
export declare type Property = {
|
|
14
|
+
property: string;
|
|
15
|
+
label: Partial<Record<Lang, string>>;
|
|
16
|
+
range: (PropertyRange | string)[];
|
|
17
|
+
shortName: string;
|
|
18
|
+
comment?: Partial<Record<Lang, string>>;
|
|
19
|
+
maxOccurs: string;
|
|
20
|
+
minOccurs: string;
|
|
21
|
+
multiLanguage: boolean;
|
|
22
|
+
isEmbeddable: boolean;
|
|
23
|
+
required: boolean;
|
|
24
|
+
domain: string[];
|
|
25
|
+
};
|
|
26
|
+
export declare type PropertyContext = {
|
|
27
|
+
"@id": string;
|
|
28
|
+
"@type"?: PropertyRange;
|
|
29
|
+
"@container"?: "@set";
|
|
30
|
+
};
|
|
31
|
+
export declare type Lang = "fi" | "sv" | "en";
|
|
32
|
+
export declare const LANGS: Lang[];
|
|
33
|
+
export declare const isLang: (lang: unknown) => lang is Lang;
|
|
34
|
+
export declare type CompleteTranslations = Record<Lang, Record<string, string>>;
|
|
35
|
+
export declare type Translations = Partial<CompleteTranslations>;
|
|
36
|
+
declare type KnownFormOptions = {
|
|
37
|
+
prepopulatedDocument?: Record<string, JSONObject>;
|
|
38
|
+
prepopulateWithInformalTaxonGroups?: string[];
|
|
39
|
+
prepopulateWithTaxonSets?: string[];
|
|
40
|
+
useSchemaCommentsAsHelpTexts?: boolean;
|
|
41
|
+
};
|
|
42
|
+
export declare type FormOptions = JSONObject & KnownFormOptions;
|
|
43
|
+
export declare type CommonFormat = {
|
|
44
|
+
id?: string;
|
|
45
|
+
options?: FormOptions;
|
|
46
|
+
title?: string;
|
|
47
|
+
logo?: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
shortDescription?: string;
|
|
50
|
+
supportedLanguage?: Lang[];
|
|
51
|
+
category?: string;
|
|
52
|
+
collectionID?: string;
|
|
53
|
+
name?: string;
|
|
54
|
+
translations?: Translations;
|
|
55
|
+
language?: Lang;
|
|
56
|
+
};
|
|
57
|
+
export declare type FormListing = CommonFormat & {
|
|
58
|
+
id: string;
|
|
59
|
+
};
|
|
60
|
+
export declare type CommonExpanded = CommonFormat & {
|
|
61
|
+
uiSchema?: JSONObject;
|
|
62
|
+
};
|
|
63
|
+
export declare type JSON = string | number | boolean | JSONObject | JSON[] | null;
|
|
64
|
+
export declare type JSONObject = {
|
|
65
|
+
[prop: string]: JSON;
|
|
66
|
+
};
|
|
67
|
+
export declare const isJSONObject: (json?: JSON | undefined) => json is JSONObject;
|
|
68
|
+
export declare const isJSONObjectOrUndefined: (v?: JSON | undefined) => v is JSON | undefined;
|
|
69
|
+
export declare type Master = CommonExpanded & {
|
|
70
|
+
fields?: Field[];
|
|
71
|
+
baseFormID?: string;
|
|
72
|
+
fieldsFormID?: string;
|
|
73
|
+
patch?: any[];
|
|
74
|
+
"@type"?: string;
|
|
75
|
+
"@context"?: string;
|
|
76
|
+
context?: string;
|
|
77
|
+
extra?: Record<string, {
|
|
78
|
+
altParent: AltParentMap;
|
|
79
|
+
}>;
|
|
80
|
+
};
|
|
81
|
+
export declare function isMaster(master: unknown): master is Master;
|
|
82
|
+
export declare type SchemaFormat<T extends JSONSchemaEnumOneOf | JSONSchemaV6Enum = JSONSchemaEnumOneOf> = CommonExpanded & {
|
|
83
|
+
schema: JSONSchema<T>;
|
|
84
|
+
validators: {
|
|
85
|
+
[prop: string]: (JSONObject | boolean);
|
|
86
|
+
};
|
|
87
|
+
warnings: {
|
|
88
|
+
[prop: string]: (JSONObject | boolean);
|
|
89
|
+
};
|
|
90
|
+
excludeFromCopy: string[];
|
|
91
|
+
uiSchema: JSONObject;
|
|
92
|
+
attributes?: {
|
|
93
|
+
id: string;
|
|
94
|
+
};
|
|
95
|
+
extra?: Record<string, {
|
|
96
|
+
altParent: AltParentMap;
|
|
97
|
+
}>;
|
|
98
|
+
uiSchemaContext?: Record<string, {
|
|
99
|
+
tree: AltTreeParent;
|
|
100
|
+
}>;
|
|
101
|
+
language?: Lang;
|
|
102
|
+
context?: string;
|
|
103
|
+
translations?: Translations;
|
|
104
|
+
};
|
|
105
|
+
export declare type ExpandedJSONFormat = CommonExpanded & {
|
|
106
|
+
fields?: ExpandedField[];
|
|
107
|
+
};
|
|
108
|
+
export declare type SupportedFormat = ExpandedJSONFormat | SchemaFormat | RemoteMaster;
|
|
109
|
+
export declare type ExpandedMaster = Omit<Master, "baseFormID" | "patch"> & {
|
|
110
|
+
fields?: Field[];
|
|
111
|
+
uiSchema: JSONObject;
|
|
112
|
+
};
|
|
113
|
+
export declare type RemoteMaster = Master & {
|
|
114
|
+
id: string;
|
|
115
|
+
};
|
|
116
|
+
export declare type FieldOptions = {
|
|
117
|
+
excludeFromCopy?: boolean;
|
|
118
|
+
default?: JSON;
|
|
119
|
+
whitelist?: string[];
|
|
120
|
+
blacklist?: string[];
|
|
121
|
+
uniqueItems?: boolean;
|
|
122
|
+
maxItems?: number;
|
|
123
|
+
minItems?: number;
|
|
124
|
+
value_options?: Record<string, string>;
|
|
125
|
+
};
|
|
126
|
+
export declare type Field = {
|
|
127
|
+
name: string;
|
|
128
|
+
type?: "hidden" | "string" | "checkbox";
|
|
129
|
+
required?: boolean;
|
|
130
|
+
options?: FieldOptions;
|
|
131
|
+
validators?: Record<string, JSONObject | boolean>;
|
|
132
|
+
warnings?: Record<string, JSONObject | boolean>;
|
|
133
|
+
label?: string;
|
|
134
|
+
fields?: Field[];
|
|
135
|
+
};
|
|
136
|
+
export declare type ExpandedFieldType = "text" | "fieldset" | "select" | "checkbox" | "string" | "number" | "integer" | "integer:nonNegativeInteger" | "integer:positiveInteger";
|
|
137
|
+
export declare type ExpandedFieldOptions = FieldOptions & {
|
|
138
|
+
target_element?: {
|
|
139
|
+
type: ExpandedFieldType;
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
export declare type ExpandedField = Omit<Field, "type" | "fields"> & {
|
|
143
|
+
type?: "hidden" | "collection" | ExpandedFieldType;
|
|
144
|
+
fields?: ExpandedField[];
|
|
145
|
+
options?: ExpandedFieldOptions;
|
|
146
|
+
};
|
|
147
|
+
export declare type AltTreeParent = {
|
|
148
|
+
children: Record<string, AltTreeNode>;
|
|
149
|
+
order: string[];
|
|
150
|
+
};
|
|
151
|
+
export declare type AltTreeLeaf = {
|
|
152
|
+
[K in any]: never;
|
|
153
|
+
};
|
|
154
|
+
export declare type AltTreeNode = AltTreeParent | AltTreeLeaf;
|
|
155
|
+
export declare type AltParentMap = Record<string, string[]>;
|
|
156
|
+
export declare type Range = {
|
|
157
|
+
id: string;
|
|
158
|
+
value?: Partial<Record<Lang, string>>;
|
|
159
|
+
vernacularName?: Partial<Record<Lang, string>>;
|
|
160
|
+
altParent?: string;
|
|
161
|
+
};
|
|
162
|
+
export declare type Class = {
|
|
163
|
+
class: string;
|
|
164
|
+
label: Partial<Record<Lang, string>>;
|
|
165
|
+
shortName: string;
|
|
166
|
+
};
|
|
167
|
+
export declare type FormDeleteResult = {
|
|
168
|
+
affected: number;
|
|
169
|
+
};
|
|
170
|
+
export declare enum Format {
|
|
171
|
+
Schema = "schema",
|
|
172
|
+
SchemaWithEnums = "schema-with-enums",
|
|
173
|
+
JSON = "json"
|
|
174
|
+
}
|
|
175
|
+
export declare type JSONSchema<E extends (JSONSchemaEnumOneOf | JSONSchemaV6Enum) = JSONSchemaEnumOneOf> = JSONSchemaObject | JSONSchemaArray | JSONSchemaNumber | JSONSchemaInteger | JSONSchemaBoolean | JSONSchemaString | E;
|
|
176
|
+
declare type JSONShemaTypeCommon<T, D> = {
|
|
177
|
+
type: T;
|
|
178
|
+
default?: D;
|
|
179
|
+
title?: string;
|
|
180
|
+
};
|
|
181
|
+
export declare type JSONSchemaObject<E extends (JSONSchemaEnumOneOf | JSONSchemaV6Enum) = JSONSchemaEnumOneOf> = JSONShemaTypeCommon<"object", Record<string, unknown>> & {
|
|
182
|
+
properties: Record<string, JSONSchema<E>>;
|
|
183
|
+
required?: string[];
|
|
184
|
+
};
|
|
185
|
+
export declare function isJSONSchemaObject<E extends (JSONSchemaEnumOneOf | JSONSchemaV6Enum) = JSONSchemaEnumOneOf>(schema: JSONSchema<E>): schema is JSONSchemaObject;
|
|
186
|
+
export declare type JSONSchemaArray = JSONShemaTypeCommon<"array", unknown[]> & {
|
|
187
|
+
items: JSONSchema;
|
|
188
|
+
uniqueItems?: boolean;
|
|
189
|
+
};
|
|
190
|
+
export declare type JSONSchemaNumber = JSONShemaTypeCommon<"number", number>;
|
|
191
|
+
export declare type JSONSchemaInteger = JSONShemaTypeCommon<"integer", number>;
|
|
192
|
+
export declare type JSONSchemaBoolean = JSONShemaTypeCommon<"boolean", boolean>;
|
|
193
|
+
export declare type JSONSchemaString = JSONShemaTypeCommon<"string", string>;
|
|
194
|
+
export declare type JSONSchemaEnumOneOf = JSONSchemaString & {
|
|
195
|
+
oneOf: {
|
|
196
|
+
const: string;
|
|
197
|
+
title: string;
|
|
198
|
+
}[];
|
|
199
|
+
};
|
|
200
|
+
export declare function isJSONSchemaEnumOneOf(jsonSchema: JSONSchema): jsonSchema is JSONSchemaEnumOneOf;
|
|
201
|
+
export declare type JSONSchemaV6Enum = JSONSchemaString & {
|
|
202
|
+
enum: string[];
|
|
203
|
+
enumNames: string[];
|
|
204
|
+
};
|
|
205
|
+
export {};
|
package/lib/model.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isJSONSchemaEnumOneOf = exports.isJSONSchemaObject = exports.Format = exports.isMaster = exports.isJSONObjectOrUndefined = exports.isJSONObject = exports.isLang = exports.LANGS = exports.PropertyRange = void 0;
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
|
+
var PropertyRange;
|
|
6
|
+
(function (PropertyRange) {
|
|
7
|
+
PropertyRange["Int"] = "xsd:integer";
|
|
8
|
+
PropertyRange["Boolean"] = "xsd:boolean";
|
|
9
|
+
PropertyRange["String"] = "xsd:string";
|
|
10
|
+
PropertyRange["Id"] = "@id";
|
|
11
|
+
PropertyRange["PositiveInteger"] = "xsd:positiveInteger";
|
|
12
|
+
PropertyRange["DateTime"] = "xsd:dateTime";
|
|
13
|
+
PropertyRange["NonNegativeInteger"] = "xsd:nonNegativeInteger";
|
|
14
|
+
PropertyRange["keyValue"] = "MZ.keyValue";
|
|
15
|
+
PropertyRange["keyAny"] = "MZ.keyAny";
|
|
16
|
+
PropertyRange["Decimal"] = "xsd:decimal";
|
|
17
|
+
})(PropertyRange = exports.PropertyRange || (exports.PropertyRange = {}));
|
|
18
|
+
exports.LANGS = ["fi", "en", "sv"];
|
|
19
|
+
const isLang = (lang) => typeof lang === "string" && exports.LANGS.includes(lang);
|
|
20
|
+
exports.isLang = isLang;
|
|
21
|
+
const isJSONObject = (json) => utils_1.isObject(json);
|
|
22
|
+
exports.isJSONObject = isJSONObject;
|
|
23
|
+
const isJSONObjectOrUndefined = (v) => v === undefined || exports.isJSONObject(v);
|
|
24
|
+
exports.isJSONObjectOrUndefined = isJSONObjectOrUndefined;
|
|
25
|
+
function isMaster(master) {
|
|
26
|
+
return utils_1.isObject(master);
|
|
27
|
+
}
|
|
28
|
+
exports.isMaster = isMaster;
|
|
29
|
+
var Format;
|
|
30
|
+
(function (Format) {
|
|
31
|
+
Format["Schema"] = "schema";
|
|
32
|
+
Format["SchemaWithEnums"] = "schema-with-enums";
|
|
33
|
+
Format["JSON"] = "json";
|
|
34
|
+
})(Format = exports.Format || (exports.Format = {}));
|
|
35
|
+
function isJSONSchemaObject(schema) {
|
|
36
|
+
return schema.type === "object";
|
|
37
|
+
}
|
|
38
|
+
exports.isJSONSchemaObject = isJSONSchemaObject;
|
|
39
|
+
function isJSONSchemaEnumOneOf(jsonSchema) {
|
|
40
|
+
return !!jsonSchema.oneOf;
|
|
41
|
+
}
|
|
42
|
+
exports.isJSONSchemaEnumOneOf = isJSONSchemaEnumOneOf;
|
|
43
|
+
//# sourceMappingURL=model.js.map
|
package/lib/model.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AAEnC,IAAY,aAWX;AAXD,WAAY,aAAa;IACxB,oCAAmB,CAAA;IACnB,wCAAuB,CAAA;IACvB,sCAAqB,CAAA;IACrB,2BAAU,CAAA;IACV,wDAAuC,CAAA;IACvC,0CAAyB,CAAA;IACzB,8DAA6C,CAAA;IAC7C,yCAAwB,CAAA;IACxB,qCAAoB,CAAA;IACpB,wCAAuB,CAAA;AACxB,CAAC,EAXW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAWxB;AAwBY,QAAA,KAAK,GAAW,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAEzC,MAAM,MAAM,GAAG,CAAC,IAAa,EAAgB,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,aAAK,CAAC,QAAQ,CAAC,IAAW,CAAC,CAAC;AAAlG,QAAA,MAAM,UAA4F;AAuCxG,MAAM,YAAY,GAAG,CAAC,IAAW,EAAsB,EAAE,CAAC,gBAAQ,CAAC,IAAI,CAAC,CAAC;AAAnE,QAAA,YAAY,gBAAuD;AAEzE,MAAM,uBAAuB,GAAG,CAAC,CAAQ,EAA2B,EAAE,CAAC,CAAC,KAAK,SAAS,IAAI,oBAAY,CAAC,CAAC,CAAC,CAAC;AAApG,QAAA,uBAAuB,2BAA6E;AAajH,SAAgB,QAAQ,CAAC,MAAe;IACvC,OAAO,gBAAQ,CAAC,MAAM,CAAC,CAAC;AACzB,CAAC;AAFD,4BAEC;AAwGD,IAAY,MAIX;AAJD,WAAY,MAAM;IACjB,2BAAiB,CAAA;IACjB,+CAAqC,CAAA;IACrC,uBAAa,CAAA;AACd,CAAC,EAJW,MAAM,GAAN,cAAM,KAAN,cAAM,QAIjB;AAuBD,SAAgB,kBAAkB,CACjC,MAAqB;IACrB,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;AACjC,CAAC;AAHD,gDAGC;AAmBD,SAAgB,qBAAqB,CAAC,UAAsB;IAC3D,OAAO,CAAC,CAAE,UAAkB,CAAC,KAAK,CAAC;AACpC,CAAC;AAFD,sDAEC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ExpandedMaster, Master } from "../model";
|
|
2
|
+
declare type HasGetForm = {
|
|
3
|
+
getForm: (id: string, abort?: AbortSignal) => Promise<Master>;
|
|
4
|
+
};
|
|
5
|
+
export default class FormExpanderService {
|
|
6
|
+
private storeService;
|
|
7
|
+
constructor(storeService: HasGetForm);
|
|
8
|
+
linkMaster(master: Master, signal?: AbortSignal): Promise<Omit<Omit<Master, "baseFormID">, "fieldsFormID">>;
|
|
9
|
+
private mapBaseForm;
|
|
10
|
+
private mapBaseFormFrom;
|
|
11
|
+
mapFieldsFormID: <T extends Pick<Master, "uiSchema" | "fields" | "translations" | "fieldsFormID" | "context">>(master: T) => Promise<Omit<T, "fieldsFormID">>;
|
|
12
|
+
expandMaster(master: Master, signal?: AbortSignal): Promise<ExpandedMaster>;
|
|
13
|
+
private applyPatches;
|
|
14
|
+
}
|
|
15
|
+
export {};
|