@arquimedes.co/eureka-forms 1.3.0-test → 1.4.3-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/CBRFormStep.d.ts +72 -0
- package/dist/@Types/CBRFormStep.js +1 -0
- package/dist/@Types/Form.d.ts +4 -1
- package/dist/@Types/FormStep.d.ts +11 -46
- package/dist/@Types/GenericFormSteps.d.ts +58 -0
- package/dist/@Types/GenericFormSteps.js +1 -0
- package/dist/App.d.ts +3 -1
- package/dist/App.js +17 -6
- package/dist/App.module.css +1 -0
- package/dist/FormComponents/Form/ColumnForm/ColumnForm.d.ts +1 -1
- package/dist/FormComponents/Form/ColumnForm/ColumnForm.js +98 -59
- package/dist/FormComponents/Form/Form.d.ts +5 -1
- package/dist/FormComponents/Form/Form.js +22 -10
- package/dist/FormComponents/Section/MaterialSection/MaterialSection.js +2 -1
- package/dist/FormComponents/Section/Section.d.ts +4 -1
- package/dist/FormComponents/Step/@Construction/CBRIncidentsStep/CBRIncidentsStep.d.ts +9 -0
- package/dist/FormComponents/Step/@Construction/CBRIncidentsStep/CBRIncidentsStep.js +25 -0
- package/dist/FormComponents/Step/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.d.ts +8 -0
- package/dist/FormComponents/Step/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.js +48 -0
- package/dist/FormComponents/Step/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.module.css +60 -0
- package/dist/FormComponents/Step/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.d.ts +11 -0
- package/dist/FormComponents/Step/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.js +112 -0
- package/dist/FormComponents/Step/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.module.css +34 -0
- package/dist/FormComponents/Step/@Construction/CBRLocativasStep/CBRLocativasStep.d.ts +9 -0
- package/dist/FormComponents/Step/@Construction/CBRLocativasStep/CBRLocativasStep.js +122 -0
- package/dist/FormComponents/Step/CBRStepMapper.d.ts +13 -0
- package/dist/FormComponents/Step/CBRStepMapper.js +243 -0
- package/dist/FormComponents/Step/CBRStepValuesTemp/CBR_INMUEBLE.json +13151 -0
- package/dist/FormComponents/Step/CBRStepValuesTemp/CBR_LOCATIVAS.json +71 -0
- package/dist/FormComponents/Step/CBRStepValuesTemp/CBR_PROYECTO.json +74 -0
- package/dist/FormComponents/Step/CBRStepValuesTemp/CBR_TIPO_DOC.json +50 -0
- package/dist/FormComponents/Step/CBRStepValuesTemp/CBR_TIPO_ESPACIO.json +320 -0
- package/dist/FormComponents/Step/CBRStepValuesTemp/CBR_TIPO_SOLICITANTE.json +42 -0
- package/dist/FormComponents/Step/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.js +2 -2
- package/dist/FormComponents/Step/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +12 -7
- package/dist/FormComponents/Step/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.js +1 -1
- package/dist/FormComponents/Step/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.js +7 -5
- package/dist/FormComponents/Step/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.d.ts +4 -0
- package/dist/FormComponents/Step/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +145 -0
- package/dist/FormComponents/Step/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.module.css +9 -0
- package/dist/FormComponents/Step/SmartSelectStep/SmartSelectStep.d.ts +22 -0
- package/dist/FormComponents/Step/SmartSelectStep/SmartSelectStep.js +25 -0
- package/dist/FormComponents/Step/Step.js +10 -7
- package/dist/FormComponents/Step/StepFunctions.d.ts +3 -3
- package/dist/FormComponents/Step/StepFunctions.js +5 -5
- package/dist/FormComponents/Step/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.js +5 -2
- package/dist/FormComponents/Step/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.module.css +1 -2
- package/dist/FormComponents/Step/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.d.ts +1 -1
- package/dist/FormComponents/Step/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.js +3 -3
- package/dist/FormComponents/Step/TextInputStep/TextInputStep.d.ts +2 -0
- package/dist/FormComponents/Step/TitleStep/MaterialTitleStep/MaterialTitleStep.js +3 -1
- package/dist/FormComponents/Step/TitleStep/MaterialTitleStep/MaterialTitleStep.module.css +1 -8
- package/dist/constants/CBRFormStepTypes.d.ts +20 -0
- package/dist/constants/CBRFormStepTypes.js +21 -0
- package/dist/constants/FormStepTypes.d.ts +0 -6
- package/dist/constants/FormStepTypes.js +0 -7
- package/dist/shared/RoundedCheckBox/RoundedCheckBox.d.ts +1 -1
- package/dist/shared/RoundedCheckBox/RoundedCheckBox.js +1 -1
- package/dist/shared/RoundedDatePicker/RoundedDatePicker.js +1 -1
- package/dist/shared/RoundedSelect/RoundedSelect.d.ts +5 -1
- package/dist/shared/RoundedSelect/RoundedSelect.js +8 -2
- package/dist/shared/RoundedSmartSelect/RoundedSmartSelect.d.ts +63 -0
- package/dist/shared/RoundedSmartSelect/RoundedSmartSelect.js +172 -0
- package/dist/shared/RoundedTextField/RoundedTextField.d.ts +2 -0
- package/dist/shared/RoundedTextField/RoundedTextField.js +7 -2
- package/package.json +2 -1
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import Types from '../constants/CBRFormStepTypes';
|
|
2
|
+
import { GSmartSelect, GTextArea, GTextInput, GBaseStep } from './GenericFormSteps';
|
|
3
|
+
export declare type CBRFormStep = CBRFirstNameStep | CBRMiddleNameStep | CBRLastNameStep | CBRSecondLastNameStep | PostVentaStep | CBRProjectStep | CBRDocStep | CBRCelStep | CBRPhoneStep | CBRDocTypeStep | CBREmailStep | CBRRequesterTypeStep | CBRPropertyStep | CBRSpaceTypeStep | CBRElementStep | CBRCommentStep | CBRIncidentsStep;
|
|
4
|
+
export interface PostVentaStep extends GBaseStep {
|
|
5
|
+
type: Types.CBR_POSTVENTA;
|
|
6
|
+
}
|
|
7
|
+
export interface CBRProjectStep extends GSmartSelect {
|
|
8
|
+
type: Types.CBR_PROYECTO;
|
|
9
|
+
steps: string[];
|
|
10
|
+
/** Only has maxSize if level === 0 */
|
|
11
|
+
maxSize: number;
|
|
12
|
+
}
|
|
13
|
+
export interface CBRDocTypeStep extends Omit<GSmartSelect, 'showIcon'> {
|
|
14
|
+
type: Types.CBR_TIPO_DOC;
|
|
15
|
+
}
|
|
16
|
+
export interface CBRRequesterTypeStep extends GSmartSelect {
|
|
17
|
+
type: Types.CBR_TIPO_SOLICITANTE;
|
|
18
|
+
}
|
|
19
|
+
export interface CBRPropertyStep extends GSmartSelect {
|
|
20
|
+
type: Types.CBR_INMUEBLE;
|
|
21
|
+
}
|
|
22
|
+
export interface CBRSpaceTypeStep extends GSmartSelect {
|
|
23
|
+
type: Types.CBR_TIPO_ESPACIO;
|
|
24
|
+
}
|
|
25
|
+
export interface CBRFirstNameStep extends GTextInput {
|
|
26
|
+
type: Types.CBR_FIRST_NAME;
|
|
27
|
+
}
|
|
28
|
+
export interface CBRMiddleNameStep extends GTextInput {
|
|
29
|
+
type: Types.CBR_MIDDLE_NAME;
|
|
30
|
+
}
|
|
31
|
+
export interface CBRLastNameStep extends GTextInput {
|
|
32
|
+
type: Types.CBR_LAST_NAME;
|
|
33
|
+
}
|
|
34
|
+
export interface CBRSecondLastNameStep extends GTextInput {
|
|
35
|
+
type: Types.CBR_SECOND_LAST_NAME;
|
|
36
|
+
}
|
|
37
|
+
export interface CBRDocStep extends GTextInput {
|
|
38
|
+
type: Types.CBR_DOC;
|
|
39
|
+
showIcon: boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface CBRCelStep extends GTextInput {
|
|
42
|
+
type: Types.CBR_CEL;
|
|
43
|
+
}
|
|
44
|
+
export interface CBRPhoneStep extends GTextInput {
|
|
45
|
+
type: Types.CBR_PHONE;
|
|
46
|
+
}
|
|
47
|
+
export interface CBREmailStep extends GTextInput {
|
|
48
|
+
type: Types.CBR_EMAIL;
|
|
49
|
+
}
|
|
50
|
+
export interface CBRElementStep extends GSmartSelect {
|
|
51
|
+
type: Types.CBR_LOCATIVAS;
|
|
52
|
+
subStep: string | null;
|
|
53
|
+
parentStep: string | null;
|
|
54
|
+
}
|
|
55
|
+
export interface CBRCommentStep extends Omit<GTextArea, 'hasTextEditor'> {
|
|
56
|
+
type: Types.CBR_COMENTARIO;
|
|
57
|
+
}
|
|
58
|
+
export interface CBRIncidentsStep extends GBaseStep {
|
|
59
|
+
type: Types.CBR_INCIDENCIAS;
|
|
60
|
+
label: string;
|
|
61
|
+
description: string | null;
|
|
62
|
+
addBtnLabel: string;
|
|
63
|
+
required: boolean;
|
|
64
|
+
unitLabel: string;
|
|
65
|
+
spaceStep: Omit<CBRSpaceTypeStep, 'id' | 'type'>;
|
|
66
|
+
newLineAfterSpace: boolean;
|
|
67
|
+
elementStep: IncidentElementStep;
|
|
68
|
+
commentStep: Omit<CBRCommentStep, 'id' | 'type'>;
|
|
69
|
+
}
|
|
70
|
+
export interface IncidentElementStep extends Omit<CBRElementStep, 'id' | 'subStep' | 'parentStep' | 'type'> {
|
|
71
|
+
subStep?: IncidentElementStep;
|
|
72
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/@Types/Form.d.ts
CHANGED
|
@@ -16,6 +16,9 @@ export interface Form {
|
|
|
16
16
|
style: FormStyle;
|
|
17
17
|
classifiers: Record<string, ParentClassifier>;
|
|
18
18
|
terms: Term[];
|
|
19
|
+
size: FormSize;
|
|
20
|
+
}
|
|
21
|
+
export interface FormSize {
|
|
19
22
|
blockNum: 1 | 2 | 3 | 4;
|
|
20
23
|
blockSize: number;
|
|
21
24
|
spacingSize: number;
|
|
@@ -34,7 +37,7 @@ interface TermLink {
|
|
|
34
37
|
type: 'LINK';
|
|
35
38
|
url: string;
|
|
36
39
|
}
|
|
37
|
-
interface Classifier {
|
|
40
|
+
export interface Classifier {
|
|
38
41
|
_id: string;
|
|
39
42
|
name: string;
|
|
40
43
|
}
|
|
@@ -1,68 +1,34 @@
|
|
|
1
|
-
import Types, { ClassifierOptionTypes,
|
|
1
|
+
import Types, { ClassifierOptionTypes, OptionTypes } from '../constants/FormStepTypes';
|
|
2
|
+
import * as GSteps from './GenericFormSteps';
|
|
2
3
|
export declare type FormStep = Title | CheckBox | TextArea | TextInput | DatePicker | FileUpload | Separator | FormSelector | ClassifierSelector;
|
|
3
|
-
export interface Title {
|
|
4
|
-
id: string;
|
|
4
|
+
export interface Title extends GSteps.GBaseStep {
|
|
5
5
|
type: Types.TITLE;
|
|
6
6
|
title: string;
|
|
7
7
|
description: string | null;
|
|
8
8
|
}
|
|
9
|
-
export interface CheckBox {
|
|
10
|
-
label: string;
|
|
11
|
-
description: string | null;
|
|
12
|
-
id: string;
|
|
9
|
+
export interface CheckBox extends GSteps.GCheckBox {
|
|
13
10
|
type: Types.CHECKBOX;
|
|
14
|
-
required: boolean;
|
|
15
|
-
size: 1 | 2 | 3 | 4;
|
|
16
11
|
}
|
|
17
|
-
export interface FileUpload {
|
|
18
|
-
id: string;
|
|
12
|
+
export interface FileUpload extends GSteps.GBaseStep {
|
|
19
13
|
type: Types.FILEUPLOAD;
|
|
20
14
|
label: string;
|
|
21
15
|
description: string | null;
|
|
22
16
|
required: boolean;
|
|
23
17
|
value: string[];
|
|
24
18
|
}
|
|
25
|
-
export interface Separator {
|
|
26
|
-
id: string;
|
|
19
|
+
export interface Separator extends GSteps.GSeparator {
|
|
27
20
|
type: Types.SEPARATOR;
|
|
28
|
-
transparent: boolean;
|
|
29
21
|
}
|
|
30
|
-
export interface TextArea {
|
|
31
|
-
id: string;
|
|
22
|
+
export interface TextArea extends GSteps.GTextArea {
|
|
32
23
|
type: Types.TEXTAREA;
|
|
33
|
-
label: string;
|
|
34
|
-
description: string | null;
|
|
35
|
-
required: boolean;
|
|
36
|
-
hasTextEditor: boolean;
|
|
37
|
-
isPrimary: boolean;
|
|
38
24
|
}
|
|
39
|
-
export interface TextInput {
|
|
40
|
-
id: string;
|
|
25
|
+
export interface TextInput extends GSteps.GTextInput {
|
|
41
26
|
type: Types.TEXTINPUT;
|
|
42
|
-
label: string;
|
|
43
|
-
description: string | null;
|
|
44
|
-
validation?: FormValidation;
|
|
45
|
-
required: boolean;
|
|
46
|
-
isSubject: boolean;
|
|
47
|
-
isClientInfo: boolean;
|
|
48
|
-
clientInfoType?: ClientInfoTypes;
|
|
49
|
-
size: 1 | 2 | 3 | 4;
|
|
50
27
|
}
|
|
51
|
-
export interface DatePicker {
|
|
52
|
-
id: string;
|
|
28
|
+
export interface DatePicker extends GSteps.GDatePicker {
|
|
53
29
|
type: Types.DATEPICKER;
|
|
54
|
-
label: string;
|
|
55
|
-
pickTime: boolean;
|
|
56
|
-
description: string | null;
|
|
57
|
-
required: boolean;
|
|
58
|
-
size: 1 | 2 | 3 | 4;
|
|
59
30
|
}
|
|
60
|
-
|
|
61
|
-
message: string;
|
|
62
|
-
value: string;
|
|
63
|
-
};
|
|
64
|
-
export interface FormSelector {
|
|
65
|
-
id: string;
|
|
31
|
+
export interface FormSelector extends GSteps.GBaseStep {
|
|
66
32
|
type: Types.SELECTOR;
|
|
67
33
|
label: string;
|
|
68
34
|
description: string;
|
|
@@ -89,8 +55,7 @@ interface AddSectionOption {
|
|
|
89
55
|
type: OptionTypes.ADD_SECTION;
|
|
90
56
|
idSection: string;
|
|
91
57
|
}
|
|
92
|
-
export interface ClassifierSelector {
|
|
93
|
-
id: string;
|
|
58
|
+
export interface ClassifierSelector extends GSteps.GBaseStep {
|
|
94
59
|
type: Types.CLASSIFIER_SELECTOR;
|
|
95
60
|
idClassifier: string | null;
|
|
96
61
|
label: string;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export interface GBaseStep {
|
|
2
|
+
id: string;
|
|
3
|
+
type: string;
|
|
4
|
+
dependencies?: string[];
|
|
5
|
+
}
|
|
6
|
+
export interface GTitle extends GBaseStep {
|
|
7
|
+
title: string;
|
|
8
|
+
description: string | null;
|
|
9
|
+
}
|
|
10
|
+
export interface GCheckBox extends GBaseStep {
|
|
11
|
+
label: string;
|
|
12
|
+
description: string | null;
|
|
13
|
+
required: boolean;
|
|
14
|
+
size: 1 | 2 | 3 | 4;
|
|
15
|
+
}
|
|
16
|
+
export interface GSeparator extends GBaseStep {
|
|
17
|
+
transparent: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface GTextArea extends GBaseStep {
|
|
20
|
+
label: string;
|
|
21
|
+
description: string | null;
|
|
22
|
+
required: boolean;
|
|
23
|
+
hasTextEditor: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface GTextInput extends GBaseStep {
|
|
26
|
+
label: string;
|
|
27
|
+
description: string | null;
|
|
28
|
+
validation?: {
|
|
29
|
+
message: string;
|
|
30
|
+
value: string;
|
|
31
|
+
type: 'EMAIL' | 'OTHER';
|
|
32
|
+
};
|
|
33
|
+
required: boolean;
|
|
34
|
+
showIcon?: boolean;
|
|
35
|
+
size: 1 | 2 | 3 | 4;
|
|
36
|
+
}
|
|
37
|
+
export interface GDatePicker extends GBaseStep {
|
|
38
|
+
label: string;
|
|
39
|
+
description: string | null;
|
|
40
|
+
pickTime: boolean;
|
|
41
|
+
required: boolean;
|
|
42
|
+
size: 1 | 2 | 3 | 4;
|
|
43
|
+
}
|
|
44
|
+
export interface GAgentPicker extends GBaseStep {
|
|
45
|
+
label: string;
|
|
46
|
+
description: string | null;
|
|
47
|
+
required: boolean;
|
|
48
|
+
multiple: boolean;
|
|
49
|
+
size: 1 | 2 | 3 | 4;
|
|
50
|
+
}
|
|
51
|
+
export interface GSmartSelect extends GBaseStep {
|
|
52
|
+
label: string;
|
|
53
|
+
description: string | null;
|
|
54
|
+
showIcon: boolean;
|
|
55
|
+
required: boolean;
|
|
56
|
+
searchable: boolean;
|
|
57
|
+
size: 1 | 2 | 3 | 4;
|
|
58
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/App.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ export interface AppProps {
|
|
|
19
19
|
valuesData?: Record<string, unknown>;
|
|
20
20
|
/** Custom steps to display */
|
|
21
21
|
customSteps?: Record<string, CustomStep>;
|
|
22
|
+
/** Custom function to call on send */
|
|
23
|
+
customSend?: (values: any, reload: Function) => Promise<void>;
|
|
22
24
|
/** Function to call on postview to fetch the download url of a file */
|
|
23
25
|
fetchDownloadUrl?: (S3Key: string, fileName: string) => Promise<string>;
|
|
24
26
|
/** Function to call after the confimation dialog has been closed */
|
|
@@ -28,7 +30,7 @@ export interface CustomStep {
|
|
|
28
30
|
component: ReactNode;
|
|
29
31
|
updateValue: (idStep: string, values: Record<string, any>, form: Form) => void;
|
|
30
32
|
}
|
|
31
|
-
declare function App({ apiKey, domain, preview, formData, postview, isWidget, internal, valuesData, customSteps, handleConfirmed, ...others }: AppProps): JSX.Element;
|
|
33
|
+
declare function App({ apiKey, domain, preview, formData, postview, isWidget, internal, valuesData, customSend, customSteps, handleConfirmed, ...others }: AppProps): JSX.Element;
|
|
32
34
|
export default App;
|
|
33
35
|
export declare enum SIZES {
|
|
34
36
|
SMALL = "SMALL",
|
package/dist/App.js
CHANGED
|
@@ -68,7 +68,7 @@ import widgetInstance from './AxiosWidget';
|
|
|
68
68
|
function App(_a) {
|
|
69
69
|
var _this = this;
|
|
70
70
|
var _b, _c, _d, _e;
|
|
71
|
-
var apiKey = _a.apiKey, domain = _a.domain, preview = _a.preview, formData = _a.formData, postview = _a.postview, isWidget = _a.isWidget, internal = _a.internal, valuesData = _a.valuesData, customSteps = _a.customSteps, handleConfirmed = _a.handleConfirmed, others = __rest(_a, ["apiKey", "domain", "preview", "formData", "postview", "isWidget", "internal", "valuesData", "customSteps", "handleConfirmed"]);
|
|
71
|
+
var apiKey = _a.apiKey, domain = _a.domain, preview = _a.preview, formData = _a.formData, postview = _a.postview, isWidget = _a.isWidget, internal = _a.internal, valuesData = _a.valuesData, customSend = _a.customSend, customSteps = _a.customSteps, handleConfirmed = _a.handleConfirmed, others = __rest(_a, ["apiKey", "domain", "preview", "formData", "postview", "isWidget", "internal", "valuesData", "customSend", "customSteps", "handleConfirmed"]);
|
|
72
72
|
var _f = useState(undefined), form = _f[0], setForm = _f[1];
|
|
73
73
|
var _g = useState({}), originalValues = _g[0], setOriginalValues = _g[1];
|
|
74
74
|
var _h = useState(undefined), organizationInfo = _h[0], setOrganizationInfo = _h[1];
|
|
@@ -256,7 +256,7 @@ function App(_a) {
|
|
|
256
256
|
if (handleConfirmed) {
|
|
257
257
|
handleConfirmed();
|
|
258
258
|
}
|
|
259
|
-
}, postview: postview === true, internal: internal === true, apiKey: apiKey, domain: domain, originalValues: originalValues, containerRef: containerRef, organization: organizationInfo, customSteps: customSteps !== null && customSteps !== void 0 ? customSteps : {} }), void 0) }), void 0));
|
|
259
|
+
}, postview: postview === true, internal: internal === true, apiKey: apiKey, domain: domain, customSend: customSend, originalValues: originalValues, containerRef: containerRef, organization: organizationInfo, customSteps: customSteps !== null && customSteps !== void 0 ? customSteps : {} }), void 0) }), void 0));
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
export default App;
|
|
@@ -283,10 +283,21 @@ var migrateFormData = function (form) {
|
|
|
283
283
|
steps[idStep] = step;
|
|
284
284
|
}
|
|
285
285
|
var newForm = __assign(__assign({}, form), { steps: steps });
|
|
286
|
-
if (form.
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
286
|
+
if (form.size === undefined) {
|
|
287
|
+
if (form.spacingSize) {
|
|
288
|
+
newForm.size = {
|
|
289
|
+
spacingSize: form.spacingSize,
|
|
290
|
+
blockNum: form.blockNum,
|
|
291
|
+
blockSize: form.blockSize,
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
newForm.size = {
|
|
296
|
+
spacingSize: 20,
|
|
297
|
+
blockNum: 4,
|
|
298
|
+
blockSize: 210,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
290
301
|
}
|
|
291
302
|
return newForm;
|
|
292
303
|
};
|
package/dist/App.module.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { FormComponentProps } from '../Form';
|
|
3
|
-
declare function ColumnForm({ form, apiKey, reload, domain, postview, internal, formStyle, widthStats, customSteps, originalValues, ...others }: FormComponentProps): JSX.Element;
|
|
3
|
+
declare function ColumnForm({ form, apiKey, reload, domain, postview, internal, formStyle, widthStats, customSteps, customSend, handleLoaded, originalValues, ...others }: FormComponentProps): JSX.Element;
|
|
4
4
|
export default ColumnForm;
|
|
@@ -70,20 +70,22 @@ import axiosInstance from '../../../AxiosAPI';
|
|
|
70
70
|
import widgetInstance from '../../../AxiosWidget';
|
|
71
71
|
function ColumnForm(_a) {
|
|
72
72
|
var _this = this;
|
|
73
|
-
var form = _a.form, apiKey = _a.apiKey, reload = _a.reload, domain = _a.domain, postview = _a.postview, internal = _a.internal, formStyle = _a.formStyle, widthStats = _a.widthStats, customSteps = _a.customSteps, originalValues = _a.originalValues, others = __rest(_a, ["form", "apiKey", "reload", "domain", "postview", "internal", "formStyle", "widthStats", "customSteps", "originalValues"]);
|
|
73
|
+
var form = _a.form, apiKey = _a.apiKey, reload = _a.reload, domain = _a.domain, postview = _a.postview, internal = _a.internal, formStyle = _a.formStyle, widthStats = _a.widthStats, customSteps = _a.customSteps, customSend = _a.customSend, handleLoaded = _a.handleLoaded, originalValues = _a.originalValues, others = __rest(_a, ["form", "apiKey", "reload", "domain", "postview", "internal", "formStyle", "widthStats", "customSteps", "customSend", "handleLoaded", "originalValues"]);
|
|
74
74
|
var _b = useState(false), tempError = _b[0], setTempError = _b[1];
|
|
75
|
-
var _c =
|
|
76
|
-
|
|
75
|
+
var _c = useState(calcDependencies(form.steps, originalValues)), dependencyStore = _c[0], setDependencyStore = _c[1];
|
|
76
|
+
var _d = useForm({
|
|
77
|
+
defaultValues: mapOriginalValues(originalValues, form),
|
|
77
78
|
mode: 'onTouched',
|
|
78
79
|
shouldFocusError: true,
|
|
79
|
-
}), getValues =
|
|
80
|
-
var
|
|
81
|
-
var
|
|
82
|
-
var
|
|
80
|
+
}), getValues = _d.getValues, setValue = _d.setValue, clearErrors = _d.clearErrors, control = _d.control, errors = _d.formState.errors, trigger = _d.trigger;
|
|
81
|
+
var _e = useState(undefined), sections = _e[0], setSections = _e[1];
|
|
82
|
+
var _f = useState(false), loading = _f[0], setLoading = _f[1];
|
|
83
|
+
var _g = useState(), showConfirmation = _g[0], setShowConfirmation = _g[1];
|
|
83
84
|
useEffect(function () {
|
|
84
85
|
var tempSections = [];
|
|
85
86
|
calcNextSection(form, form.firstSection, tempSections);
|
|
86
87
|
setSections(tempSections);
|
|
88
|
+
handleLoaded();
|
|
87
89
|
}, []);
|
|
88
90
|
if (sections === undefined) {
|
|
89
91
|
return _jsx("div", {}, void 0);
|
|
@@ -93,7 +95,7 @@ function ColumnForm(_a) {
|
|
|
93
95
|
return __generator(this, function (_c) {
|
|
94
96
|
switch (_c.label) {
|
|
95
97
|
case 0:
|
|
96
|
-
if (!(apiKey || internal)) return [3 /*break*/,
|
|
98
|
+
if (!(apiKey || internal)) return [3 /*break*/, 11];
|
|
97
99
|
return [4 /*yield*/, trigger(undefined, { shouldFocus: true })];
|
|
98
100
|
case 1:
|
|
99
101
|
valid = _c.sent();
|
|
@@ -104,49 +106,53 @@ function ColumnForm(_a) {
|
|
|
104
106
|
setTimeout(function () {
|
|
105
107
|
setTempError(false);
|
|
106
108
|
}, 500);
|
|
107
|
-
return [3 /*break*/,
|
|
109
|
+
return [3 /*break*/, 11];
|
|
108
110
|
case 2:
|
|
109
|
-
_c.trys.push([2,
|
|
111
|
+
_c.trys.push([2, 10, , 11]);
|
|
110
112
|
setLoading(true);
|
|
111
113
|
for (_i = 0, _a = Object.keys(values); _i < _a.length; _i++) {
|
|
112
114
|
idStep = _a[_i];
|
|
113
115
|
updateValue(idStep, values, form, customSteps);
|
|
114
116
|
}
|
|
115
|
-
if (
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
if (!customSend) return [3 /*break*/, 4];
|
|
118
|
+
return [4 /*yield*/, customSend(values, reload)];
|
|
119
|
+
case 3:
|
|
120
|
+
_c.sent();
|
|
121
|
+
return [3 /*break*/, 9];
|
|
122
|
+
case 4:
|
|
119
123
|
payload = {
|
|
120
124
|
formValues: { steps: values },
|
|
121
125
|
};
|
|
122
126
|
url = "/ticket/" + (internal ? form.apiKey : apiKey);
|
|
123
|
-
if (!(domain || internal)) return [3 /*break*/,
|
|
127
|
+
if (!(domain || internal)) return [3 /*break*/, 6];
|
|
124
128
|
return [4 /*yield*/, widgetInstance.post(url + "?idOrganization=" + domain, payload)];
|
|
125
|
-
case 3:
|
|
126
|
-
_b = _c.sent();
|
|
127
|
-
return [3 /*break*/, 6];
|
|
128
|
-
case 4: return [4 /*yield*/, axiosInstance.post(url, payload)];
|
|
129
129
|
case 5:
|
|
130
130
|
_b = _c.sent();
|
|
131
|
-
|
|
132
|
-
case 6:
|
|
131
|
+
return [3 /*break*/, 8];
|
|
132
|
+
case 6: return [4 /*yield*/, axiosInstance.post(url, payload)];
|
|
133
|
+
case 7:
|
|
134
|
+
_b = _c.sent();
|
|
135
|
+
_c.label = 8;
|
|
136
|
+
case 8:
|
|
133
137
|
resp = _b;
|
|
134
138
|
setShowConfirmation(resp === null || resp === void 0 ? void 0 : resp.data);
|
|
139
|
+
_c.label = 9;
|
|
140
|
+
case 9:
|
|
135
141
|
setLoading(false);
|
|
136
|
-
return [3 /*break*/,
|
|
137
|
-
case
|
|
142
|
+
return [3 /*break*/, 11];
|
|
143
|
+
case 10:
|
|
138
144
|
error_1 = _c.sent();
|
|
139
145
|
console.error(error_1);
|
|
140
146
|
setLoading(false);
|
|
141
|
-
return [3 /*break*/,
|
|
142
|
-
case
|
|
147
|
+
return [3 /*break*/, 11];
|
|
148
|
+
case 11: return [2 /*return*/];
|
|
143
149
|
}
|
|
144
150
|
});
|
|
145
151
|
}); };
|
|
146
152
|
return (_jsxs("div", __assign({ className: styles.container, style: { color: formStyle.textColor } }, { children: [loading && _jsx("div", { className: styles.curtain }, void 0), showConfirmation !== undefined && (_jsx(ConfirmationDialog, { formStyle: formStyle, confirmation: showConfirmation, onClose: function () {
|
|
147
153
|
reload();
|
|
148
154
|
setShowConfirmation(undefined);
|
|
149
|
-
} }, void 0)), sections.map(function (idSection, index) { return (_jsx(SectionComponent, __assign({ form: form, domain: domain, postview: postview, clearErrors: clearErrors, widthStats: widthStats, control: control, getValues: getValues, originalValues: originalValues, errors: errors, index: index, setSections: setSections, section: form.sections[idSection], formStyle: formStyle, customSteps: customSteps }, others), index)); }), form.terms &&
|
|
155
|
+
} }, void 0)), sections.map(function (idSection, index) { return (_jsx(SectionComponent, __assign({ form: form, domain: domain, postview: postview, clearErrors: clearErrors, widthStats: widthStats, control: control, getValues: getValues, originalValues: originalValues, errors: errors, index: index, setSections: setSections, section: form.sections[idSection], formStyle: formStyle, customSteps: customSteps, setDependencyStore: setDependencyStore, dependencyStore: dependencyStore, trigger: trigger }, others), index)); }), form.terms &&
|
|
150
156
|
!internal &&
|
|
151
157
|
form.terms.map(function (term, index) { return (_jsx(TermComponent, { setValue: setValue, postview: postview, tempError: tempError, term: term, control: control, errors: errors, form: form, formStyle: formStyle }, index)); }), !postview && (_jsx("div", __assign({ className: styles.submitBtnContainer }, { children: _jsxs("button", __assign({ "data-testid": "form__submit", className: styles.submitBtn, onClick: function () {
|
|
152
158
|
onSubmit();
|
|
@@ -170,15 +176,15 @@ function calcNextSection(form, idSection, sections) {
|
|
|
170
176
|
}
|
|
171
177
|
}
|
|
172
178
|
}
|
|
173
|
-
var
|
|
174
|
-
var newValues = __assign({},
|
|
175
|
-
for (var _i = 0, _a = Object.keys(
|
|
179
|
+
var mapOriginalValues = function (originalValues, form) {
|
|
180
|
+
var newValues = __assign({}, originalValues);
|
|
181
|
+
for (var _i = 0, _a = Object.keys(originalValues); _i < _a.length; _i++) {
|
|
176
182
|
var val = _a[_i];
|
|
177
183
|
var step = form.steps[val];
|
|
178
184
|
if (step) {
|
|
179
185
|
switch (step === null || step === void 0 ? void 0 : step.type) {
|
|
180
186
|
case Types.TEXTAREA: {
|
|
181
|
-
var value =
|
|
187
|
+
var value = originalValues[step.id];
|
|
182
188
|
if (step.hasTextEditor) {
|
|
183
189
|
delete newValues[step.id];
|
|
184
190
|
}
|
|
@@ -196,38 +202,40 @@ var mapOriginal = function (values, form) {
|
|
|
196
202
|
};
|
|
197
203
|
var updateValue = function (idStep, values, form, customSteps) {
|
|
198
204
|
var step = form.steps[idStep];
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
205
|
+
var custom = customSteps[step === null || step === void 0 ? void 0 : step.type];
|
|
206
|
+
if (custom !== undefined) {
|
|
207
|
+
custom.updateValue(idStep, values, form);
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
switch (step === null || step === void 0 ? void 0 : step.type) {
|
|
211
|
+
case Types.TEXTAREA: {
|
|
212
|
+
var value = values[step.id];
|
|
213
|
+
if (step.hasTextEditor) {
|
|
214
|
+
var currentContent = value.getCurrentContent();
|
|
215
|
+
values[step.id] = {
|
|
216
|
+
value: currentContent.getPlainText(),
|
|
217
|
+
draft: convertToRaw(currentContent),
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
values[step.id] = {
|
|
222
|
+
value: value,
|
|
223
|
+
draft: stringToDraft(value),
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
break;
|
|
208
227
|
}
|
|
209
|
-
|
|
210
|
-
values[step.id]
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
228
|
+
case Types.FILEUPLOAD: {
|
|
229
|
+
var value = values[step.id];
|
|
230
|
+
values[step.id] = value.map(function (val) { return ({
|
|
231
|
+
fileName: val.fileName,
|
|
232
|
+
S3Key: val.S3Key,
|
|
233
|
+
}); });
|
|
234
|
+
break;
|
|
214
235
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
case Types.FILEUPLOAD: {
|
|
218
|
-
var value = values[step.id];
|
|
219
|
-
values[step.id] = value.map(function (val) { return ({
|
|
220
|
-
fileName: val.fileName,
|
|
221
|
-
S3Key: val.S3Key,
|
|
222
|
-
}); });
|
|
223
|
-
break;
|
|
236
|
+
default:
|
|
237
|
+
break;
|
|
224
238
|
}
|
|
225
|
-
default:
|
|
226
|
-
var custom = customSteps[step === null || step === void 0 ? void 0 : step.type];
|
|
227
|
-
if (custom !== undefined) {
|
|
228
|
-
custom.updateValue(idStep, values, form);
|
|
229
|
-
}
|
|
230
|
-
break;
|
|
231
239
|
}
|
|
232
240
|
};
|
|
233
241
|
function stringToDraft(text) {
|
|
@@ -248,3 +256,34 @@ function stringToDraft(text) {
|
|
|
248
256
|
});
|
|
249
257
|
return draftStructure;
|
|
250
258
|
}
|
|
259
|
+
function calcDependencies(steps, originalValues) {
|
|
260
|
+
var dependencies = {};
|
|
261
|
+
for (var _i = 0, _a = Object.values(steps); _i < _a.length; _i++) {
|
|
262
|
+
var step = _a[_i];
|
|
263
|
+
if (step.dependencies) {
|
|
264
|
+
for (var _b = 0, _c = step.dependencies; _b < _c.length; _b++) {
|
|
265
|
+
var idDep = _c[_b];
|
|
266
|
+
var depStep = steps[idDep];
|
|
267
|
+
if (depStep && dependencies[idDep] === undefined) {
|
|
268
|
+
switch (depStep === null || depStep === void 0 ? void 0 : depStep.type) {
|
|
269
|
+
case Types.TEXTAREA: {
|
|
270
|
+
if (depStep.hasTextEditor) {
|
|
271
|
+
dependencies[idDep] = null;
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
dependencies[idDep] =
|
|
275
|
+
originalValues[idDep].value;
|
|
276
|
+
}
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
default:
|
|
280
|
+
dependencies[idDep] = originalValues[idDep];
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
dependencies['CBR_PROYECTO'] = null; //REMOVE
|
|
288
|
+
return dependencies;
|
|
289
|
+
}
|
|
@@ -5,12 +5,14 @@ import { CustomStep } from '../../App';
|
|
|
5
5
|
export declare const getLocale: () => any;
|
|
6
6
|
export interface WidthStats {
|
|
7
7
|
currentBreakPoint: number;
|
|
8
|
+
isResponsive: boolean;
|
|
8
9
|
isMobile: boolean;
|
|
9
10
|
}
|
|
10
11
|
export interface FormComponentProps {
|
|
11
12
|
form: Form;
|
|
12
13
|
originalValues: Record<string, unknown>;
|
|
13
14
|
customSteps: Record<string, CustomStep>;
|
|
15
|
+
customSend?: (values: any, reload: Function) => Promise<void>;
|
|
14
16
|
widthStats: WidthStats;
|
|
15
17
|
internal: boolean;
|
|
16
18
|
reload: Function;
|
|
@@ -20,8 +22,10 @@ export interface FormComponentProps {
|
|
|
20
22
|
apiKey: string | undefined;
|
|
21
23
|
/** Function to call on postview to fetch the download url of a file */
|
|
22
24
|
fetchDownloadUrl?: (S3Key: string, fileName: string) => Promise<string>;
|
|
25
|
+
/** Function to call when the form has loaded */
|
|
26
|
+
handleLoaded: () => void;
|
|
23
27
|
}
|
|
24
|
-
declare function FormComponent({ form, internal, postview, organization, containerRef, ...others }: Omit<FormComponentProps, 'widthStats' | 'formStyle'> & {
|
|
28
|
+
declare function FormComponent({ form, internal, postview, organization, containerRef, ...others }: Omit<FormComponentProps, 'widthStats' | 'formStyle' | 'handleLoaded'> & {
|
|
25
29
|
containerRef: any;
|
|
26
30
|
organization: Organization | null;
|
|
27
31
|
}): JSX.Element;
|
|
@@ -47,25 +47,30 @@ export var getLocale = function () {
|
|
|
47
47
|
navigator.language ||
|
|
48
48
|
navigator.browserLanguage]) !== null && _a !== void 0 ? _a : localeMap.es);
|
|
49
49
|
};
|
|
50
|
-
var blockSize = 210;
|
|
51
|
-
var spacingSize = 20;
|
|
52
|
-
var blockNum = 4;
|
|
53
50
|
function FormComponent(_a) {
|
|
54
51
|
var _b, _c;
|
|
55
52
|
var form = _a.form, internal = _a.internal, postview = _a.postview, organization = _a.organization, containerRef = _a.containerRef, others = __rest(_a, ["form", "internal", "postview", "organization", "containerRef"]);
|
|
56
|
-
var _d = useState(
|
|
53
|
+
var _d = useState(false), loaded = _d[0], setLoaded = _d[1];
|
|
54
|
+
var _e = useState(undefined), widthStats = _e[0], setWidthStats = _e[1];
|
|
57
55
|
/** Calcs the currentBreakPoint and if is mobile */
|
|
58
56
|
var handleResize = function () {
|
|
59
57
|
var _a;
|
|
60
58
|
var currentWidth = (_a = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth;
|
|
61
59
|
if (currentWidth !== undefined) {
|
|
62
|
-
var currentBreakPoint = blockNum;
|
|
60
|
+
var currentBreakPoint = form.size.blockNum;
|
|
63
61
|
while (currentWidth <
|
|
64
|
-
(blockSize + spacingSize) *
|
|
62
|
+
(form.size.blockSize + form.size.spacingSize) *
|
|
63
|
+
currentBreakPoint +
|
|
64
|
+
40) {
|
|
65
65
|
currentBreakPoint--;
|
|
66
66
|
}
|
|
67
67
|
setWidthStats({
|
|
68
|
-
|
|
68
|
+
isResponsive: currentWidth <
|
|
69
|
+
(form.size.blockSize + form.size.spacingSize) *
|
|
70
|
+
form.size.blockNum +
|
|
71
|
+
40,
|
|
72
|
+
isMobile: currentWidth <
|
|
73
|
+
(form.size.blockSize + form.size.spacingSize) * 2 + 40,
|
|
69
74
|
currentBreakPoint: currentBreakPoint,
|
|
70
75
|
});
|
|
71
76
|
}
|
|
@@ -85,13 +90,20 @@ function FormComponent(_a) {
|
|
|
85
90
|
backgroundColor: internal
|
|
86
91
|
? InternalFormStyle.backgroundColor
|
|
87
92
|
: form.style.backgroundColor,
|
|
88
|
-
} }, { children: _jsx(FormTypeComponent, __assign({}, others, {
|
|
93
|
+
} }, { children: _jsx(FormTypeComponent, __assign({}, others, { handleLoaded: function () {
|
|
94
|
+
setLoaded(true);
|
|
95
|
+
}, widthStats: widthStats, form: form, internal: internal, postview: postview, formStyle: internal ? InternalFormStyle : form.style }), void 0) }), void 0));
|
|
89
96
|
}
|
|
90
97
|
else if (organization && widthStats !== undefined) {
|
|
91
98
|
//Standalone cant have widget
|
|
92
|
-
return (_jsxs(React.Fragment, { children: [_jsx(Navbar, { logo: organization.logoUrl, color: (_c = organization.styles) === null || _c === void 0 ? void 0 : _c.primaryColor }, void 0), _jsx("div", __assign({ className: styles.standAloneFormContainer, ref: containerRef }, { children: _jsx("div", __assign({ className: widthStats.
|
|
99
|
+
return (_jsxs(React.Fragment, { children: [_jsx(Navbar, { logo: organization.logoUrl, color: (_c = organization.styles) === null || _c === void 0 ? void 0 : _c.primaryColor }, void 0), _jsx("div", __assign({ className: styles.standAloneFormContainer, ref: containerRef }, { children: _jsx("div", __assign({ className: widthStats.isResponsive
|
|
93
100
|
? styles.fullScreenStandAloneForm
|
|
94
|
-
: styles.standAloneFormCard, style: {
|
|
101
|
+
: styles.standAloneFormCard, style: {
|
|
102
|
+
backgroundColor: form.style.backgroundColor,
|
|
103
|
+
visibility: loaded ? 'visible' : 'hidden',
|
|
104
|
+
} }, { children: _jsx(FormTypeComponent, __assign({}, others, { internal: internal, postview: postview, widthStats: widthStats, form: form, formStyle: form.style, handleLoaded: function () {
|
|
105
|
+
setLoaded(true);
|
|
106
|
+
} }), void 0) }), void 0) }), void 0)] }, void 0));
|
|
95
107
|
}
|
|
96
108
|
else {
|
|
97
109
|
return _jsx("div", {}, void 0);
|