@arquimedes.co/eureka-forms 1.9.61 → 1.9.63-test
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/@Types/Form.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface Form {
|
|
|
11
11
|
hasCaptcha?: boolean;
|
|
12
12
|
isStandAlone?: boolean;
|
|
13
13
|
style?: FormStyle;
|
|
14
|
-
classifiers?: Record<string,
|
|
14
|
+
classifiers?: Record<string, Classifier>;
|
|
15
15
|
terms?: Term[];
|
|
16
16
|
}
|
|
17
17
|
export interface FormSize {
|
|
@@ -36,9 +36,7 @@ interface TermLink {
|
|
|
36
36
|
export interface Classifier {
|
|
37
37
|
_id: string;
|
|
38
38
|
name: string;
|
|
39
|
-
|
|
40
|
-
export interface ParentClassifier extends Classifier {
|
|
41
|
-
children: Classifier[];
|
|
39
|
+
children: string[];
|
|
42
40
|
}
|
|
43
41
|
export type FormStyle = MaterialStyle;
|
|
44
42
|
export type StyleKeys = keyof Omit<FormStyle, 'type'>;
|
package/dist/App.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { Form } from './@Types/Form';
|
|
2
|
+
import { Classifier, Form } from './@Types/Form';
|
|
3
3
|
export interface AppProps {
|
|
4
4
|
/** If the app is currently a widget */
|
|
5
5
|
isWidget?: boolean;
|
|
@@ -25,6 +25,8 @@ export interface AppProps {
|
|
|
25
25
|
valuesData?: Record<string, unknown>;
|
|
26
26
|
/** Custom steps to display */
|
|
27
27
|
customSteps?: Record<string, CustomStep>;
|
|
28
|
+
/** Classifiers dict */
|
|
29
|
+
classifiers?: Record<string, Classifier>;
|
|
28
30
|
/** Custom function to call on send */
|
|
29
31
|
customSend?: (values: any, reload: Function) => Promise<void>;
|
|
30
32
|
/** Custom submit buttons */
|
|
@@ -39,7 +41,7 @@ export interface CustomStep {
|
|
|
39
41
|
component: ReactNode;
|
|
40
42
|
calcValue?: (step: any, value: any) => any;
|
|
41
43
|
}
|
|
42
|
-
declare function App({ apiKey, domain, preview, partial, formData, postview, editable, isWidget, internal, valuesData, customSend, customSteps, handleConfirmed, ...others }: AppProps): JSX.Element;
|
|
44
|
+
declare function App({ apiKey, domain, preview, partial, formData, postview, editable, isWidget, internal, valuesData, customSend, customSteps, classifiers, handleConfirmed, ...others }: AppProps): JSX.Element;
|
|
43
45
|
export default App;
|
|
44
46
|
export declare enum SIZES {
|
|
45
47
|
SMALL = "SMALL",
|
package/dist/App.js
CHANGED
|
@@ -74,12 +74,12 @@ import { stringToDraft, getRawText, } from './FormComponents/Step/TextAreaStep/M
|
|
|
74
74
|
function App(_a) {
|
|
75
75
|
var _this = this;
|
|
76
76
|
var _b, _c, _d, _e;
|
|
77
|
-
var apiKey = _a.apiKey, domain = _a.domain, preview = _a.preview, partial = _a.partial, formData = _a.formData, postview = _a.postview, _f = _a.editable, editable = _f === void 0 ? true : _f, isWidget = _a.isWidget, internal = _a.internal, valuesData = _a.valuesData, customSend = _a.customSend, customSteps = _a.customSteps, handleConfirmed = _a.handleConfirmed, others = __rest(_a, ["apiKey", "domain", "preview", "partial", "formData", "postview", "editable", "isWidget", "internal", "valuesData", "customSend", "customSteps", "handleConfirmed"]);
|
|
77
|
+
var apiKey = _a.apiKey, domain = _a.domain, preview = _a.preview, partial = _a.partial, formData = _a.formData, postview = _a.postview, _f = _a.editable, editable = _f === void 0 ? true : _f, isWidget = _a.isWidget, internal = _a.internal, valuesData = _a.valuesData, customSend = _a.customSend, customSteps = _a.customSteps, classifiers = _a.classifiers, handleConfirmed = _a.handleConfirmed, others = __rest(_a, ["apiKey", "domain", "preview", "partial", "formData", "postview", "editable", "isWidget", "internal", "valuesData", "customSend", "customSteps", "classifiers", "handleConfirmed"]);
|
|
78
78
|
var _g = useState(undefined), form = _g[0], setForm = _g[1];
|
|
79
79
|
var _h = useState({}), originalValues = _h[0], setOriginalValues = _h[1];
|
|
80
80
|
var _j = useState(undefined), organizationInfo = _j[0], setOrganizationInfo = _j[1];
|
|
81
81
|
var migrateFormData = function (formData, valuesData) {
|
|
82
|
-
var form = migrateForm(formData);
|
|
82
|
+
var form = migrateForm(formData, classifiers);
|
|
83
83
|
var steps = Object.values(form.steps);
|
|
84
84
|
var hasCBR = steps.find(function (step) {
|
|
85
85
|
return step.type.startsWith('CBR');
|
|
@@ -289,7 +289,7 @@ export var SizesToNum = (_a = {},
|
|
|
289
289
|
_a[SIZES.MEDIUM] = 2,
|
|
290
290
|
_a[SIZES.SMALL] = 1,
|
|
291
291
|
_a);
|
|
292
|
-
var migrateForm = function (form) {
|
|
292
|
+
var migrateForm = function (form, classifiers) {
|
|
293
293
|
var steps = __assign({}, form.steps);
|
|
294
294
|
for (var _i = 0, _a = Object.keys(form.steps); _i < _a.length; _i++) {
|
|
295
295
|
var idStep = _a[_i];
|
|
@@ -333,6 +333,33 @@ var migrateForm = function (form) {
|
|
|
333
333
|
if (form.style === undefined) {
|
|
334
334
|
newForm.style = InternalFormStyle;
|
|
335
335
|
}
|
|
336
|
+
if (form.classifiers) {
|
|
337
|
+
var mappedClassifiers = {};
|
|
338
|
+
for (var _b = 0, _c = Object.keys(form.classifiers); _b < _c.length; _b++) {
|
|
339
|
+
var idClassifier = _c[_b];
|
|
340
|
+
var classifier = __assign({}, form.classifiers[idClassifier]);
|
|
341
|
+
if (classifier.children &&
|
|
342
|
+
classifier.children.find(function (child) { return typeof child !== 'string'; })) {
|
|
343
|
+
var children = [];
|
|
344
|
+
for (var _d = 0, _e = classifier.children; _d < _e.length; _d++) {
|
|
345
|
+
var child = _e[_d];
|
|
346
|
+
if (typeof child === 'string') {
|
|
347
|
+
children.push(child);
|
|
348
|
+
}
|
|
349
|
+
else if (child._id) {
|
|
350
|
+
mappedClassifiers[child._id] = child;
|
|
351
|
+
children.push(child._id);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
classifier.children = children;
|
|
355
|
+
}
|
|
356
|
+
mappedClassifiers[idClassifier] = classifier;
|
|
357
|
+
}
|
|
358
|
+
newForm.classifiers = mappedClassifiers;
|
|
359
|
+
}
|
|
360
|
+
else if (classifiers) {
|
|
361
|
+
newForm.classifiers = classifiers;
|
|
362
|
+
}
|
|
336
363
|
return newForm;
|
|
337
364
|
};
|
|
338
365
|
function getStaticWidth(step) {
|
|
@@ -400,7 +427,7 @@ var mapOriginalValues = function (originalValues, form) {
|
|
|
400
427
|
return newValues;
|
|
401
428
|
};
|
|
402
429
|
var mapOriginalValue = function (step, value, form) {
|
|
403
|
-
var _a, _b, _c;
|
|
430
|
+
var _a, _b, _c, _d;
|
|
404
431
|
switch (step === null || step === void 0 ? void 0 : step.type) {
|
|
405
432
|
case StepTypes.TEXTAREA: {
|
|
406
433
|
if (step.hasTextEditor) {
|
|
@@ -415,11 +442,11 @@ var mapOriginalValue = function (step, value, form) {
|
|
|
415
442
|
return value;
|
|
416
443
|
}
|
|
417
444
|
case StepTypes.CLASSIFIER_SELECTOR: {
|
|
418
|
-
var
|
|
419
|
-
if (
|
|
420
|
-
var
|
|
445
|
+
var stepClassifier = (_b = form.classifiers) === null || _b === void 0 ? void 0 : _b[(_c = step.idClassifier) !== null && _c !== void 0 ? _c : ''];
|
|
446
|
+
if (stepClassifier) {
|
|
447
|
+
var classifier = (_d = form.classifiers) === null || _d === void 0 ? void 0 : _d[value];
|
|
421
448
|
if (!(value === null || value === void 0 ? void 0 : value.value))
|
|
422
|
-
return { value: value, label:
|
|
449
|
+
return { value: value, label: classifier === null || classifier === void 0 ? void 0 : classifier.name };
|
|
423
450
|
}
|
|
424
451
|
break;
|
|
425
452
|
}
|
|
@@ -43,20 +43,13 @@ function ClassifierSelector(_a) {
|
|
|
43
43
|
return _jsx("div", {});
|
|
44
44
|
}
|
|
45
45
|
var options = classifier.children
|
|
46
|
-
.filter(function (
|
|
46
|
+
.filter(function (idClassifier) { var _a; return ((_a = step.options[idClassifier]) === null || _a === void 0 ? void 0 : _a.type) !== ClassifierOptionTypes.HIDE; })
|
|
47
|
+
.map(function (idClassifier) {
|
|
47
48
|
var _a;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
.map(function (classifier) {
|
|
53
|
-
var _a, _b;
|
|
54
|
-
return typeof classifier === 'string'
|
|
55
|
-
? {
|
|
56
|
-
value: classifier,
|
|
57
|
-
label: (_b = (_a = form.classifiers) === null || _a === void 0 ? void 0 : _a[classifier]) === null || _b === void 0 ? void 0 : _b.name,
|
|
58
|
-
}
|
|
59
|
-
: { value: classifier._id, label: classifier.name };
|
|
49
|
+
var classifier = (_a = form.classifiers) === null || _a === void 0 ? void 0 : _a[idClassifier];
|
|
50
|
+
if (!classifier)
|
|
51
|
+
return _jsx("div", {});
|
|
52
|
+
return { value: classifier._id, label: classifier.name };
|
|
60
53
|
});
|
|
61
54
|
var sizeChange = function () {
|
|
62
55
|
handleSizeChange === null || handleSizeChange === void 0 ? void 0 : handleSizeChange();
|
package/package.json
CHANGED