@arquimedes.co/eureka-forms 1.9.61-test → 1.9.62-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,32 @@ 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 classifer = __assign({}, form.classifiers[idClassifier]);
|
|
341
|
+
mappedClassifiers[idClassifier] = classifer;
|
|
342
|
+
if (classifer.children &&
|
|
343
|
+
classifer.children.find(function (child) { return typeof child !== 'string'; })) {
|
|
344
|
+
var children = [];
|
|
345
|
+
for (var _d = 0, _e = classifer.children; _d < _e.length; _d++) {
|
|
346
|
+
var child = _e[_d];
|
|
347
|
+
if (typeof child === 'string') {
|
|
348
|
+
children.push(child);
|
|
349
|
+
}
|
|
350
|
+
else if (child._id) {
|
|
351
|
+
mappedClassifiers[child._id] = child;
|
|
352
|
+
children.push(child._id);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
newForm.classifiers = mappedClassifiers;
|
|
358
|
+
}
|
|
359
|
+
else if (classifiers) {
|
|
360
|
+
newForm.classifiers = classifiers;
|
|
361
|
+
}
|
|
336
362
|
return newForm;
|
|
337
363
|
};
|
|
338
364
|
function getStaticWidth(step) {
|
|
@@ -400,7 +426,7 @@ var mapOriginalValues = function (originalValues, form) {
|
|
|
400
426
|
return newValues;
|
|
401
427
|
};
|
|
402
428
|
var mapOriginalValue = function (step, value, form) {
|
|
403
|
-
var _a, _b, _c;
|
|
429
|
+
var _a, _b, _c, _d;
|
|
404
430
|
switch (step === null || step === void 0 ? void 0 : step.type) {
|
|
405
431
|
case StepTypes.TEXTAREA: {
|
|
406
432
|
if (step.hasTextEditor) {
|
|
@@ -415,11 +441,11 @@ var mapOriginalValue = function (step, value, form) {
|
|
|
415
441
|
return value;
|
|
416
442
|
}
|
|
417
443
|
case StepTypes.CLASSIFIER_SELECTOR: {
|
|
418
|
-
var
|
|
419
|
-
if (
|
|
420
|
-
var
|
|
444
|
+
var stepClassifier = (_b = form.classifiers) === null || _b === void 0 ? void 0 : _b[(_c = step.idClassifier) !== null && _c !== void 0 ? _c : ''];
|
|
445
|
+
if (stepClassifier) {
|
|
446
|
+
var classifier = (_d = form.classifiers) === null || _d === void 0 ? void 0 : _d[value];
|
|
421
447
|
if (!(value === null || value === void 0 ? void 0 : value.value))
|
|
422
|
-
return { value: value, label:
|
|
448
|
+
return { value: value, label: classifier === null || classifier === void 0 ? void 0 : classifier.name };
|
|
423
449
|
}
|
|
424
450
|
break;
|
|
425
451
|
}
|
|
@@ -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