@arquimedes.co/eureka-forms 1.9.127-test → 1.9.128-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.
Files changed (142) hide show
  1. package/dist/App.js +2 -2
  2. package/dist/{FormComponents/Form → Form}/ConfirmationDialog/ConfirmationDialog.d.ts +1 -1
  3. package/dist/{FormComponents/Form → Form}/Form.d.ts +19 -8
  4. package/dist/Form/Form.js +264 -0
  5. package/dist/Form/FormFunctions.d.ts +6 -0
  6. package/dist/Form/FormFunctions.js +201 -0
  7. package/dist/Form/FormTypes/ColumnForm/ColumnForm.d.ts +4 -0
  8. package/dist/Form/FormTypes/ColumnForm/ColumnForm.js +106 -0
  9. package/dist/{FormComponents/Form → Form/FormTypes}/StepperForm/StepperForm.d.ts +1 -1
  10. package/dist/{FormComponents → Form}/Section/MaterialSection/MaterialSection.js +1 -1
  11. package/dist/{FormComponents → Form}/Section/Section.d.ts +1 -4
  12. package/dist/{FormComponents → Form/Terms}/Term/MaterialTerm/MaterialTerm.js +2 -2
  13. package/dist/{FormComponents → Form/Terms}/Term/Term.d.ts +1 -1
  14. package/dist/{FormComponents → Form/Terms}/Term/Term.js +1 -1
  15. package/dist/Form/Terms/Terms.d.ts +4 -0
  16. package/dist/Form/Terms/Terms.js +37 -0
  17. package/dist/{FormComponents/Step → FormSteps}/@Construction/CBRElementStep/CBRElementStep.d.ts +1 -1
  18. package/dist/{FormComponents/Step → FormSteps}/@Construction/CBRElementStep/CBRElementStep.js +2 -2
  19. package/dist/{FormComponents/Step → FormSteps}/@Construction/CBRIncidentsStep/CBRIncidentsStep.d.ts +1 -1
  20. package/dist/{FormComponents/Step → FormSteps}/@Construction/CBRIncidentsStep/CBRIncidentsStep.js +1 -1
  21. package/dist/{FormComponents/Step → FormSteps}/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.js +2 -2
  22. package/dist/{FormComponents/Step → FormSteps}/@Construction/CBRPropertyStep/CBRPropertyStep.d.ts +1 -1
  23. package/dist/{FormComponents/Step → FormSteps}/@Construction/CBRPropertyStep/CBRPropertyStep.js +2 -2
  24. package/dist/{FormComponents/Step → FormSteps}/AYFStepMapper.d.ts +1 -1
  25. package/dist/{FormComponents/Step → FormSteps}/AYFStepMapper.js +1 -1
  26. package/dist/{FormComponents/Step → FormSteps}/ApiSelectorStep/ApiSelectorStep.d.ts +1 -1
  27. package/dist/{FormComponents/Step → FormSteps}/ApiSelectorStep/ApiSelectorStep.js +1 -1
  28. package/dist/{FormComponents/Step → FormSteps}/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.js +4 -4
  29. package/dist/{FormComponents/Step → FormSteps}/CBRStepMapper.d.ts +1 -1
  30. package/dist/{FormComponents/Step → FormSteps}/CBRStepMapper.js +2 -2
  31. package/dist/{FormComponents/Step → FormSteps}/CheckBoxStep/CheckBoxStep.d.ts +1 -1
  32. package/dist/{FormComponents/Step → FormSteps}/CheckBoxStep/CheckBoxStep.js +1 -1
  33. package/dist/{FormComponents/Step → FormSteps}/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.js +1 -1
  34. package/dist/{FormComponents/Step → FormSteps}/ClassifierSelectorStep/ClassifierSelectorStep.d.ts +1 -1
  35. package/dist/{FormComponents/Step → FormSteps}/ClassifierSelectorStep/ClassifierSelectorStep.js +1 -1
  36. package/dist/{FormComponents/Step → FormSteps}/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +2 -2
  37. package/dist/{FormComponents/Step → FormSteps}/CollapsibleStep/CollapsibleStep.d.ts +1 -1
  38. package/dist/{FormComponents/Step → FormSteps}/CollapsibleStep/CollapsibleStep.js +1 -1
  39. package/dist/{FormComponents/Step → FormSteps}/DatePickerStep/DatePickerStep.d.ts +1 -1
  40. package/dist/{FormComponents/Step → FormSteps}/DatePickerStep/DatePickerStep.js +1 -1
  41. package/dist/{FormComponents/Step → FormSteps}/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.js +1 -1
  42. package/dist/{FormComponents/Step → FormSteps}/EntityValueStep/EntityValuePickerStep.d.ts +1 -1
  43. package/dist/{FormComponents/Step → FormSteps}/EntityValueStep/EntityValuePickerStep.js +1 -1
  44. package/dist/{FormComponents/Step → FormSteps}/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +4 -4
  45. package/dist/{FormComponents/Step → FormSteps}/FileUploadStep/FileUploadStep.d.ts +1 -1
  46. package/dist/{FormComponents/Step → FormSteps}/FileUploadStep/FileUploadStep.js +1 -1
  47. package/dist/{FormComponents/Step → FormSteps}/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.d.ts +1 -1
  48. package/dist/{FormComponents/Step → FormSteps}/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.js +11 -3
  49. package/dist/{FormComponents/Step → FormSteps}/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.d.ts +2 -0
  50. package/dist/{FormComponents/Step → FormSteps}/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.js +7 -4
  51. package/dist/{FormComponents/Step → FormSteps}/MapperStep/MapperStep.d.ts +1 -1
  52. package/dist/{FormComponents/Step → FormSteps}/MapperStep/MapperStep.js +1 -1
  53. package/dist/{FormComponents/Step → FormSteps}/MapperStep/MaterialMapperStep/Element/MapperElement.js +1 -1
  54. package/dist/{FormComponents/Step → FormSteps}/MapperStep/MaterialMapperStep/MaterialMapperStep.js +6 -6
  55. package/dist/{FormComponents/Step → FormSteps}/RatingStep/MaterialRatingStep/MaterialRatingStep.js +2 -2
  56. package/dist/{FormComponents/Step → FormSteps}/RatingStep/RatingStep.d.ts +1 -1
  57. package/dist/{FormComponents/Step → FormSteps}/RatingStep/RatingStep.js +1 -1
  58. package/dist/{FormComponents/Step → FormSteps}/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.js +2 -2
  59. package/dist/{FormComponents/Step → FormSteps}/SelectorStep/SelectorStep.d.ts +1 -1
  60. package/dist/{FormComponents/Step → FormSteps}/SelectorStep/SelectorStep.js +1 -1
  61. package/dist/{FormComponents/Step → FormSteps}/SeparatorStep/SeparatorStep.d.ts +1 -1
  62. package/dist/{FormComponents/Step → FormSteps}/SeparatorStep/SeparatorStep.js +1 -1
  63. package/dist/{FormComponents/Step → FormSteps}/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +1 -1
  64. package/dist/{FormComponents/Step → FormSteps}/SmartSelectStep/SmartSelectStep.d.ts +4 -4
  65. package/dist/{FormComponents/Step → FormSteps}/SmartSelectStep/SmartSelectStep.js +1 -1
  66. package/dist/{FormComponents/Step → FormSteps}/Step.d.ts +2 -2
  67. package/dist/{FormComponents/Step → FormSteps}/Step.js +1 -1
  68. package/dist/{FormComponents/Step → FormSteps}/StepFunctions.d.ts +2 -2
  69. package/dist/{FormComponents/Step → FormSteps}/StepFunctions.js +1 -1
  70. package/dist/{FormComponents/Step → FormSteps}/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.js +1 -1
  71. package/dist/{FormComponents/Step → FormSteps}/TextAreaStep/TextAreaStep.d.ts +1 -1
  72. package/dist/{FormComponents/Step → FormSteps}/TextAreaStep/TextAreaStep.js +1 -1
  73. package/dist/{FormComponents/Step → FormSteps}/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.js +1 -1
  74. package/dist/{FormComponents/Step → FormSteps}/TextInputStep/TextInputStep.d.ts +1 -1
  75. package/dist/{FormComponents/Step → FormSteps}/TextInputStep/TextInputStep.js +1 -1
  76. package/dist/{FormComponents/Step → FormSteps}/TitleStep/TitleStep.d.ts +1 -1
  77. package/dist/{FormComponents/Step → FormSteps}/TitleStep/TitleStep.js +1 -1
  78. package/dist/index.lib.d.ts +2 -2
  79. package/dist/index.lib.js +1 -1
  80. package/dist/shared/RoundedDatePicker/RoundedDatePicker.js +1 -1
  81. package/package.json +1 -1
  82. package/dist/FormComponents/Form/ColumnForm/ColumnForm.d.ts +0 -15
  83. package/dist/FormComponents/Form/ColumnForm/ColumnForm.js +0 -411
  84. package/dist/FormComponents/Form/Form.js +0 -147
  85. /package/dist/{FormComponents/Form → Form}/ConfirmationDialog/ConfirmationDialog.js +0 -0
  86. /package/dist/{FormComponents/Form → Form}/ConfirmationDialog/ConfirmationDialog.module.css +0 -0
  87. /package/dist/{FormComponents/Form → Form}/Form.module.css +0 -0
  88. /package/dist/{FormComponents/Form → Form/FormTypes}/ColumnForm/ColumnForm.module.css +0 -0
  89. /package/dist/{FormComponents/Form → Form/FormTypes}/StepperForm/StepperForm.js +0 -0
  90. /package/dist/{FormComponents/Form → Form/FormTypes}/StepperForm/StepperForm.module.css +0 -0
  91. /package/dist/{FormComponents → Form}/Section/MaterialSection/MaterialSection.d.ts +0 -0
  92. /package/dist/{FormComponents → Form}/Section/MaterialSection/MaterialSection.module.css +0 -0
  93. /package/dist/{FormComponents → Form}/Section/Section.js +0 -0
  94. /package/dist/{FormComponents → Form/Terms}/Term/MaterialTerm/MaterialTerm.d.ts +0 -0
  95. /package/dist/{FormComponents → Form/Terms}/Term/MaterialTerm/MaterialTerm.module.css +0 -0
  96. /package/dist/{FormComponents/Step → FormSteps}/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.d.ts +0 -0
  97. /package/dist/{FormComponents/Step → FormSteps}/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.js +0 -0
  98. /package/dist/{FormComponents/Step → FormSteps}/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.module.css +0 -0
  99. /package/dist/{FormComponents/Step → FormSteps}/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.d.ts +0 -0
  100. /package/dist/{FormComponents/Step → FormSteps}/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.module.css +0 -0
  101. /package/dist/{FormComponents/Step → FormSteps}/@Construction/CBRPropertyStep/CBRPropertyStep.module.css +0 -0
  102. /package/dist/{FormComponents/Step → FormSteps}/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.d.ts +0 -0
  103. /package/dist/{FormComponents/Step → FormSteps}/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.module.css +0 -0
  104. /package/dist/{FormComponents/Step → FormSteps}/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.d.ts +0 -0
  105. /package/dist/{FormComponents/Step → FormSteps}/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.module.css +0 -0
  106. /package/dist/{FormComponents/Step → FormSteps}/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.d.ts +0 -0
  107. /package/dist/{FormComponents/Step → FormSteps}/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.module.css +0 -0
  108. /package/dist/{FormComponents/Step → FormSteps}/CollapsibleStep/MaterialTitleStep/MaterialCollapsibleStep.d.ts +0 -0
  109. /package/dist/{FormComponents/Step → FormSteps}/CollapsibleStep/MaterialTitleStep/MaterialCollapsibleStep.js +0 -0
  110. /package/dist/{FormComponents/Step → FormSteps}/CollapsibleStep/MaterialTitleStep/MaterialCollapsibleStep.module.css +0 -0
  111. /package/dist/{FormComponents/Step → FormSteps}/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.d.ts +0 -0
  112. /package/dist/{FormComponents/Step → FormSteps}/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.module.css +0 -0
  113. /package/dist/{FormComponents/Step → FormSteps}/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.d.ts +0 -0
  114. /package/dist/{FormComponents/Step → FormSteps}/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.module.css +0 -0
  115. /package/dist/{FormComponents/Step → FormSteps}/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.module.css +0 -0
  116. /package/dist/{FormComponents/Step → FormSteps}/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.module.css +0 -0
  117. /package/dist/{FormComponents/Step → FormSteps}/MapperStep/MaterialMapperStep/Element/ListMapperElement/ListMapperElement.d.ts +0 -0
  118. /package/dist/{FormComponents/Step → FormSteps}/MapperStep/MaterialMapperStep/Element/ListMapperElement/ListMapperElement.js +0 -0
  119. /package/dist/{FormComponents/Step → FormSteps}/MapperStep/MaterialMapperStep/Element/ListMapperElement/ListMapperElement.module.css +0 -0
  120. /package/dist/{FormComponents/Step → FormSteps}/MapperStep/MaterialMapperStep/Element/MapperElement.d.ts +0 -0
  121. /package/dist/{FormComponents/Step → FormSteps}/MapperStep/MaterialMapperStep/Element/PillMapperElement/PillMapperElement.d.ts +0 -0
  122. /package/dist/{FormComponents/Step → FormSteps}/MapperStep/MaterialMapperStep/Element/PillMapperElement/PillMapperElement.js +0 -0
  123. /package/dist/{FormComponents/Step → FormSteps}/MapperStep/MaterialMapperStep/Element/PillMapperElement/PillMapperElement.module.css +0 -0
  124. /package/dist/{FormComponents/Step → FormSteps}/MapperStep/MaterialMapperStep/MaterialMapperStep.d.ts +0 -0
  125. /package/dist/{FormComponents/Step → FormSteps}/MapperStep/MaterialMapperStep/MaterialMapperStep.module.css +0 -0
  126. /package/dist/{FormComponents/Step → FormSteps}/RatingStep/MaterialRatingStep/MaterialRatingStep.d.ts +0 -0
  127. /package/dist/{FormComponents/Step → FormSteps}/RatingStep/MaterialRatingStep/MaterialRatingStep.module.css +0 -0
  128. /package/dist/{FormComponents/Step → FormSteps}/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.d.ts +0 -0
  129. /package/dist/{FormComponents/Step → FormSteps}/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.module.css +0 -0
  130. /package/dist/{FormComponents/Step → FormSteps}/SeparatorStep/MaterialSeparatorStep/MaterialSeparatorStep.d.ts +0 -0
  131. /package/dist/{FormComponents/Step → FormSteps}/SeparatorStep/MaterialSeparatorStep/MaterialSeparatorStep.js +0 -0
  132. /package/dist/{FormComponents/Step → FormSteps}/SeparatorStep/MaterialSeparatorStep/MaterialSeparatorStep.module.css +0 -0
  133. /package/dist/{FormComponents/Step → FormSteps}/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.d.ts +0 -0
  134. /package/dist/{FormComponents/Step → FormSteps}/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.module.css +0 -0
  135. /package/dist/{FormComponents/Step → FormSteps}/TextAreaStep/MaterialTextAreaStep/DraftEditor.css +0 -0
  136. /package/dist/{FormComponents/Step → FormSteps}/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.d.ts +0 -0
  137. /package/dist/{FormComponents/Step → FormSteps}/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.module.css +0 -0
  138. /package/dist/{FormComponents/Step → FormSteps}/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.d.ts +0 -0
  139. /package/dist/{FormComponents/Step → FormSteps}/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.module.css +0 -0
  140. /package/dist/{FormComponents/Step → FormSteps}/TitleStep/MaterialTitleStep/MaterialTitleStep.d.ts +0 -0
  141. /package/dist/{FormComponents/Step → FormSteps}/TitleStep/MaterialTitleStep/MaterialTitleStep.js +0 -0
  142. /package/dist/{FormComponents/Step → FormSteps}/TitleStep/MaterialTitleStep/MaterialTitleStep.module.css +0 -0
package/dist/App.js CHANGED
@@ -60,7 +60,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
60
60
  import { useEffect, useRef, useState } from 'react';
61
61
  import Loader from './shared/Loader/Loader';
62
62
  import styles from './App.module.css';
63
- import FormComponent from './FormComponents/Form/Form';
63
+ import FormComponent from './Form/Form';
64
64
  import StepTypes from './constants/FormStepTypes';
65
65
  import axiosInstance from './AxiosAPI';
66
66
  import widgetInstance from './AxiosWidget';
@@ -68,7 +68,7 @@ import { calcCbrForm } from './utils/CbrFunctions';
68
68
  import CBRStepTypes from './constants/CBRFormStepTypes';
69
69
  import { nanoid } from 'nanoid';
70
70
  import { EditorState, convertFromRaw } from 'draft-js';
71
- import { stringToDraft, getRawText, } from './FormComponents/Step/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep';
71
+ import { stringToDraft, getRawText, } from './FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep';
72
72
  function App(_a) {
73
73
  var _this = this;
74
74
  var _b, _c, _d, _e;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { FormStyle } from '../../../@Types/Form';
2
+ import { FormStyle } from '../../@Types/Form';
3
3
  interface ConfirmationDialogProps {
4
4
  confirmation: {
5
5
  case: string;
@@ -1,9 +1,17 @@
1
- /// <reference types="react" />
2
- import { Organization } from '../../@Types/@Types';
3
- import { Form, FormStyle } from '../../@Types/Form';
4
- import { CustomStep } from '../../App';
5
- import { Branding } from '../../@Types/Branding';
1
+ import React from 'react';
2
+ import { Organization } from '../@Types/@Types';
3
+ import { Form, FormStyle } from '../@Types/Form';
4
+ import { CustomStep } from '../App';
5
+ import { Branding } from '../@Types/Branding';
6
+ import StepTypes from '../constants/FormStepTypes';
7
+ import { FieldValues, UseFormReturn } from 'react-hook-form';
6
8
  export declare const getLocale: () => any;
9
+ export interface StepDependency {
10
+ value: any | undefined;
11
+ type: StepTypes | 'ORIGINAL';
12
+ empty?: boolean;
13
+ }
14
+ export type DependencyStore = Record<string, StepDependency>;
7
15
  export interface WidthStats {
8
16
  currentBreakPoint: number;
9
17
  isResponsive: boolean;
@@ -11,6 +19,7 @@ export interface WidthStats {
11
19
  }
12
20
  export interface FormComponentProps {
13
21
  form: Form;
22
+ formController: UseFormReturn;
14
23
  organization: Organization;
15
24
  branding?: Branding;
16
25
  originalValues: Record<string, unknown>;
@@ -29,14 +38,16 @@ export interface FormComponentProps {
29
38
  apiKey: string | undefined;
30
39
  /** Function to call on postview to fetch the download url of a file */
31
40
  fetchDownloadUrl?: (S3Key: string, fileName: string) => Promise<string>;
32
- /** Function to call when the form has loaded */
33
- handleLoaded: () => void;
34
41
  /** If the form can be edited (For entities) */
35
42
  editable: boolean;
36
43
  /** The custom send label to display */
37
44
  sendLabel?: string;
45
+ /** Function called when users clicks submit */
46
+ onSubmit: (values: FieldValues) => Promise<any>;
47
+ dependencyStore: DependencyStore;
48
+ setDependencyStore: React.Dispatch<React.SetStateAction<DependencyStore>>;
38
49
  }
39
- declare function FormComponent({ form, isWidget, internal, postview, branding, organization, containerRef, ...others }: Omit<FormComponentProps, 'widthStats' | 'formStyle' | 'handleLoaded'> & {
50
+ declare function FormComponent({ form, isWidget, internal, postview, branding, organization, containerRef, ...others }: Omit<FormComponentProps, 'widthStats' | 'formStyle' | 'formController' | 'onSubmit' | 'setDependencyStore' | 'dependencyStore'> & {
40
51
  containerRef: any;
41
52
  organization: Organization | null;
42
53
  isWidget: boolean;
@@ -0,0 +1,264 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ var __rest = (this && this.__rest) || function (s, e) {
49
+ var t = {};
50
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
51
+ t[p] = s[p];
52
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
53
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
54
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
55
+ t[p[i]] = s[p[i]];
56
+ }
57
+ return t;
58
+ };
59
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
60
+ import React, { useEffect, useMemo, useRef, useState } from 'react';
61
+ import Navbar from '../shared/Navbar/Navbar';
62
+ import styles from './Form.module.css';
63
+ import InternalFormStyle from '../constants/InternalFormStyle';
64
+ import enLocale from 'date-fns/locale/en-US';
65
+ import esLocale from 'date-fns/locale/es';
66
+ import ColumnForm from './FormTypes/ColumnForm/ColumnForm';
67
+ import StepperForm from './FormTypes/StepperForm/StepperForm';
68
+ import { FormStyleTypes, FormTypes, } from '../constants/FormStepTypes';
69
+ import { MuiPickersUtilsProvider } from '@material-ui/pickers';
70
+ import DateFnsUtils from '@date-io/date-fns';
71
+ import { createGenerateClassName, createTheme, StylesProvider, ThemeProvider, } from '@material-ui/core';
72
+ import { SEED } from '../constants/MaterialClassNameSeed';
73
+ import { calcDependencies, calcValue } from './FormFunctions';
74
+ import { useForm } from 'react-hook-form';
75
+ import widgetInstance from '../AxiosWidget';
76
+ import axiosInstance from '../AxiosAPI';
77
+ import ReCAPTCHA from 'react-google-recaptcha';
78
+ import ConfirmationDialog from './ConfirmationDialog/ConfirmationDialog';
79
+ var localeMap = {
80
+ en: enLocale,
81
+ 'en-US': enLocale,
82
+ es: esLocale,
83
+ };
84
+ export var getLocale = function () {
85
+ var _a;
86
+ return ((_a = localeMap[navigator.languages && navigator.languages.length
87
+ ? navigator.languages[0]
88
+ : navigator.userLanguage ||
89
+ navigator.language ||
90
+ navigator.browserLanguage]) !== null && _a !== void 0 ? _a : localeMap.es);
91
+ };
92
+ function FormComponent(_a) {
93
+ var _this = this;
94
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
95
+ var form = _a.form, isWidget = _a.isWidget, internal = _a.internal, postview = _a.postview, branding = _a.branding, organization = _a.organization, containerRef = _a.containerRef, others = __rest(_a, ["form", "isWidget", "internal", "postview", "branding", "organization", "containerRef"]);
96
+ var apiKey = others.apiKey, domain = others.domain, customSteps = others.customSteps, originalValues = others.originalValues, customSend = others.customSend;
97
+ var _m = useState(calcDependencies(form.steps, originalValues, customSteps)), dependencyStore = _m[0], setDependencyStore = _m[1];
98
+ var formController = useForm({
99
+ defaultValues: originalValues,
100
+ mode: 'onTouched',
101
+ shouldFocusError: true,
102
+ });
103
+ var recaptchaRef = useRef();
104
+ var _o = useState(), showConfirmation = _o[0], setShowConfirmation = _o[1];
105
+ var onSubmit = function (values) { return __awaiter(_this, void 0, void 0, function () {
106
+ var token, token_1, newValues, deleteIds, _i, _a, idStep, _b, deleteIds_1, id, customResp, params, url, axios, resp, error_1;
107
+ return __generator(this, function (_c) {
108
+ switch (_c.label) {
109
+ case 0:
110
+ token = null;
111
+ if (!(form.hasCaptcha && !internal && !customSend)) return [3 /*break*/, 2];
112
+ token_1 = recaptchaRef.current.getValue();
113
+ if (!!token_1) return [3 /*break*/, 2];
114
+ return [4 /*yield*/, (recaptchaRef === null || recaptchaRef === void 0 ? void 0 : recaptchaRef.current.executeAsync())];
115
+ case 1:
116
+ token_1 = _c.sent();
117
+ _c.label = 2;
118
+ case 2:
119
+ if (!apiKey && !internal && !customSend)
120
+ return [2 /*return*/];
121
+ _c.label = 3;
122
+ case 3:
123
+ _c.trys.push([3, 7, , 8]);
124
+ newValues = {};
125
+ deleteIds = [];
126
+ for (_i = 0, _a = Object.keys(values); _i < _a.length; _i++) {
127
+ idStep = _a[_i];
128
+ newValues[idStep] = calcValue(idStep, form.steps, values, customSteps, deleteIds);
129
+ }
130
+ for (_b = 0, deleteIds_1 = deleteIds; _b < deleteIds_1.length; _b++) {
131
+ id = deleteIds_1[_b];
132
+ delete newValues[id];
133
+ }
134
+ if (!customSend) return [3 /*break*/, 5];
135
+ return [4 /*yield*/, customSend(newValues, others.reload)];
136
+ case 4:
137
+ customResp = _c.sent();
138
+ return [2 /*return*/, customResp];
139
+ case 5:
140
+ params = new URLSearchParams();
141
+ if (domain || internal)
142
+ params.set('idOrganization', domain !== null && domain !== void 0 ? domain : '');
143
+ if (token)
144
+ params.set('token', token);
145
+ url = "/ticket/".concat(internal ? form.apiKey : apiKey);
146
+ if (params.toString()) {
147
+ url += "?".concat(params.toString());
148
+ }
149
+ axios = domain || internal ? widgetInstance : axiosInstance;
150
+ return [4 /*yield*/, axios.post(url, newValues)];
151
+ case 6:
152
+ resp = _c.sent();
153
+ setShowConfirmation(resp === null || resp === void 0 ? void 0 : resp.data);
154
+ return [3 /*break*/, 8];
155
+ case 7:
156
+ error_1 = _c.sent();
157
+ console.error(error_1);
158
+ return [3 /*break*/, 8];
159
+ case 8: return [2 /*return*/];
160
+ }
161
+ });
162
+ }); };
163
+ var _p = useState(undefined), widthStats = _p[0], setWidthStats = _p[1];
164
+ /** Calcs the currentBreakPoint and if is mobile */
165
+ var handleResize = function () {
166
+ var _a;
167
+ var currentWidth = (_a = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth;
168
+ if (currentWidth !== undefined) {
169
+ var currentBreakPoint = form.size.blockNum;
170
+ var padding = postview || internal || !form.isStandAlone ? 0 : 40;
171
+ while (currentWidth <
172
+ (form.size.blockSize + form.size.spacingSize) *
173
+ currentBreakPoint +
174
+ padding) {
175
+ currentBreakPoint--;
176
+ }
177
+ setWidthStats({
178
+ isResponsive: currentWidth <
179
+ (form.size.blockSize + form.size.spacingSize) *
180
+ form.size.blockNum +
181
+ padding,
182
+ isMobile: currentWidth <
183
+ (form.size.blockSize + form.size.spacingSize) * 2 + padding,
184
+ currentBreakPoint: currentBreakPoint,
185
+ });
186
+ }
187
+ };
188
+ useEffect(function () {
189
+ /** On load add a resize listener to calc the currentBreakpoint */
190
+ window.addEventListener('resize', handleResize);
191
+ handleResize();
192
+ return function () {
193
+ window.removeEventListener('resize', handleResize);
194
+ };
195
+ }, [containerRef.current, (_b = containerRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth]);
196
+ var formStyle = useMemo(function () {
197
+ var _a;
198
+ return internal
199
+ ? InternalFormStyle
200
+ : __assign(__assign({}, InternalFormStyle), ((_a = form.style) !== null && _a !== void 0 ? _a : {}));
201
+ }, []);
202
+ if (!widthStats)
203
+ return _jsx("div", {});
204
+ var renderForm = function () {
205
+ return (_jsxs(React.Fragment, { children: [showConfirmation !== undefined && (_jsx(ConfirmationDialog, { formStyle: formStyle, confirmation: showConfirmation, onClose: function () {
206
+ others.reload();
207
+ setShowConfirmation(undefined);
208
+ } })), form.hasCaptcha && !internal && (_jsx(ReCAPTCHA, { ref: recaptchaRef, sitekey: "6LcL22kkAAAAAEotDeAFbRATob-u5vbibbCyWL2p", size: 'invisible', badge: 'bottomright' })), _jsx(FormTypeComponent, __assign({}, others, { branding: branding, widthStats: widthStats, form: form, internal: internal, postview: postview, organization: organization, formStyle: formStyle, onSubmit: onSubmit, formController: formController, dependencyStore: dependencyStore, setDependencyStore: setDependencyStore }))] }));
209
+ };
210
+ //If currently displaying internal or form is standalone
211
+ if ((postview || internal || !form.isStandAlone) &&
212
+ widthStats !== undefined) {
213
+ return (_jsx("div", __assign({ style: {
214
+ backgroundColor: internal
215
+ ? 'transparent'
216
+ : (_d = (_c = form.style) === null || _c === void 0 ? void 0 : _c.backgroundColor) !== null && _d !== void 0 ? _d : InternalFormStyle.backgroundColor,
217
+ minHeight: form.isStandAlone && !isWidget ? '100vh' : '100%',
218
+ } }, { children: _jsx("div", __assign({ className: styles.widgetFormContainer, ref: containerRef }, { children: renderForm() })) })));
219
+ }
220
+ else if (organization && widthStats !== undefined) {
221
+ //Standalone cant have widget
222
+ return (_jsxs(React.Fragment, { children: [_jsx(Navbar, { logo: branding === null || branding === void 0 ? void 0 : branding.images.logoUrl, color: (_f = (_e = branding === null || branding === void 0 ? void 0 : branding.colors) === null || _e === void 0 ? void 0 : _e.navbarColor) !== null && _f !== void 0 ? _f : (_g = branding === null || branding === void 0 ? void 0 : branding.colors) === null || _g === void 0 ? void 0 : _g.primaryColor }), _jsx("div", __assign({ className: styles.standAloneFormContainer, ref: containerRef, style: {
223
+ background: (_j = (_h = form.style) === null || _h === void 0 ? void 0 : _h.standAloneBackgroundColor) !== null && _j !== void 0 ? _j : '#ffffff',
224
+ } }, { children: _jsx("div", __assign({ className: widthStats.isResponsive
225
+ ? styles.fullScreenStandAloneForm
226
+ : styles.standAloneFormCard, style: {
227
+ backgroundColor: (_l = (_k = form.style) === null || _k === void 0 ? void 0 : _k.backgroundColor) !== null && _l !== void 0 ? _l : InternalFormStyle.backgroundColor,
228
+ // visibility: loaded ? 'visible' : 'hidden',
229
+ } }, { children: renderForm() })) }))] }));
230
+ }
231
+ else {
232
+ return _jsx("div", {});
233
+ }
234
+ }
235
+ export default FormComponent;
236
+ var muiTheme = createTheme({
237
+ typography: {
238
+ fontFamily: 'inherit',
239
+ },
240
+ });
241
+ var generateClassName = createGenerateClassName({
242
+ seed: SEED,
243
+ productionPrefix: 'efjss',
244
+ });
245
+ function FormTypeComponent(_a) {
246
+ var props = __rest(_a, []);
247
+ var renderTypes = function () {
248
+ switch (props.form.type) {
249
+ case FormTypes.STEPPER: {
250
+ return _jsx(StepperForm, __assign({}, props));
251
+ }
252
+ case FormTypes.COLUMN:
253
+ default: {
254
+ return _jsx(ColumnForm, __assign({}, props));
255
+ }
256
+ }
257
+ };
258
+ switch (props.formStyle.type) {
259
+ case FormStyleTypes.MATERIAL:
260
+ return (_jsx(StylesProvider, __assign({ generateClassName: generateClassName }, { children: _jsx(ThemeProvider, __assign({ theme: muiTheme }, { children: _jsx(MuiPickersUtilsProvider, __assign({ utils: DateFnsUtils, locale: getLocale() }, { children: renderTypes() })) })) })));
261
+ default:
262
+ return renderTypes();
263
+ }
264
+ }
@@ -0,0 +1,6 @@
1
+ import { FormStep } from '../@Types/FormStep';
2
+ import { CustomStep } from '../App';
3
+ import { DependencyStore, StepDependency } from './Form';
4
+ export declare const calcValue: (idStep: string, steps: Record<string, FormStep>, values: Record<string, any>, customSteps: Record<string, CustomStep>, deleteIds: string[], value?: any) => any;
5
+ export declare function calcDependencies(steps: Record<string, FormStep>, originalValues: Record<string, any>, customSteps?: Record<string, CustomStep>, allSteps?: Record<string, FormStep>, dependencies?: DependencyStore): DependencyStore;
6
+ export declare function calcStepDependencyValue(depStep: FormStep, originalValues: Record<string, any>, customSteps?: Record<string, CustomStep>): StepDependency['value'];
@@ -0,0 +1,201 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
13
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14
+ if (ar || !(i in from)) {
15
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
16
+ ar[i] = from[i];
17
+ }
18
+ }
19
+ return to.concat(ar || Array.prototype.slice.call(from));
20
+ };
21
+ import { convertToRaw } from 'draft-js';
22
+ import StepTypes, { EntityValueDataTypes } from '../constants/FormStepTypes';
23
+ export var calcValue = function (idStep, steps, values, customSteps, deleteIds, value) {
24
+ var _a, _b;
25
+ if (value === void 0) { value = values[idStep]; }
26
+ var step = steps[idStep];
27
+ if (!step)
28
+ return value;
29
+ var custom = customSteps[step === null || step === void 0 ? void 0 : step.type];
30
+ if (custom !== undefined) {
31
+ return (_b = (_a = custom.calcValue) === null || _a === void 0 ? void 0 : _a.call(custom, step, value)) !== null && _b !== void 0 ? _b : value;
32
+ }
33
+ else {
34
+ switch (step === null || step === void 0 ? void 0 : step.type) {
35
+ case StepTypes.TEXTAREA: {
36
+ if (step.hasTextEditor) {
37
+ var currentContent = value.getCurrentContent();
38
+ return {
39
+ value: currentContent.getPlainText(),
40
+ draft: convertToRaw(currentContent),
41
+ };
42
+ }
43
+ else {
44
+ return {
45
+ value: value,
46
+ draft: stringToDraft(value),
47
+ };
48
+ }
49
+ }
50
+ case StepTypes.FILEUPLOAD: {
51
+ return value.map(function (val) { return ({
52
+ fileName: val.fileName,
53
+ S3Key: val.S3Key,
54
+ }); });
55
+ }
56
+ case StepTypes.SELECTOR:
57
+ case StepTypes.CLASSIFIER_SELECTOR: {
58
+ return value.value;
59
+ }
60
+ case StepTypes.COLLAPSIBLE: {
61
+ return !!value;
62
+ }
63
+ case StepTypes.MAPPER: {
64
+ var elements = value === null || value === void 0 ? void 0 : value.filter(function (element) { return element.deleted !== true; });
65
+ var mappedValues = [];
66
+ for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) {
67
+ var element = elements_1[_i];
68
+ var newValue = {
69
+ id: element.id,
70
+ };
71
+ for (var _c = 0, _d = Object.keys(element.originalValues); _c < _d.length; _c++) {
72
+ var key = _d[_c];
73
+ newValue[key] = element.originalValues[key];
74
+ }
75
+ if (element.value)
76
+ newValue.value = element.value;
77
+ for (var _e = 0, _f = Object.keys(step.steps); _e < _f.length; _e++) {
78
+ var idStep_1 = _f[_e];
79
+ var mappedId = element.ids[idStep_1];
80
+ if (values[mappedId] !== undefined) {
81
+ newValue[idStep_1] = calcValue(idStep_1, step.steps, values, customSteps, deleteIds, values[mappedId]);
82
+ deleteIds.push(mappedId);
83
+ }
84
+ }
85
+ mappedValues.push(newValue);
86
+ }
87
+ return mappedValues;
88
+ }
89
+ default:
90
+ if ((step === null || step === void 0 ? void 0 : step.type) === 'CBR_INCIDENCIAS') {
91
+ return value === null || value === void 0 ? void 0 : value.filter(function (incidencia) { return incidencia.deleted !== true; });
92
+ }
93
+ return value;
94
+ }
95
+ }
96
+ };
97
+ function stringToDraft(text) {
98
+ var draftStructure = {
99
+ blocks: [],
100
+ entityMap: {},
101
+ };
102
+ text.split('\n').forEach(function (element, index) {
103
+ draftStructure.blocks.push({
104
+ key: String(index),
105
+ text: element,
106
+ type: 'unstyled',
107
+ depth: 0,
108
+ inlineStyleRanges: [],
109
+ entityRanges: [],
110
+ data: {},
111
+ });
112
+ });
113
+ return draftStructure;
114
+ }
115
+ export function calcDependencies(steps, originalValues, customSteps, allSteps, dependencies) {
116
+ var _a, _b, _c, _d;
117
+ if (customSteps === void 0) { customSteps = {}; }
118
+ if (allSteps === void 0) { allSteps = steps; }
119
+ if (dependencies === void 0) { dependencies = {}; }
120
+ for (var _i = 0, _e = Object.values(steps); _i < _e.length; _i++) {
121
+ var step = _e[_i];
122
+ if (step.dependencies) {
123
+ for (var _f = 0, _g = step.dependencies; _f < _g.length; _f++) {
124
+ var idDep = _g[_f];
125
+ var depStep = allSteps[idDep];
126
+ if (depStep && dependencies[idDep] === undefined) {
127
+ dependencies[idDep] = {
128
+ type: depStep.type,
129
+ value: calcStepDependencyValue(depStep, originalValues, customSteps),
130
+ };
131
+ }
132
+ else if (dependencies[idDep] === undefined) {
133
+ dependencies[idDep] = {
134
+ type: (_a = depStep === null || depStep === void 0 ? void 0 : depStep.type) !== null && _a !== void 0 ? _a : 'ORIGINAL',
135
+ value: originalValues[idDep],
136
+ };
137
+ }
138
+ }
139
+ }
140
+ if (step.type === StepTypes.MAPPER) {
141
+ var newSteps = {};
142
+ var elements = (_b = originalValues[step.id]) !== null && _b !== void 0 ? _b : [];
143
+ var _loop_1 = function (element) {
144
+ for (var _o = 0, _p = Object.keys(step.steps); _o < _p.length; _o++) {
145
+ var idSubStep = _p[_o];
146
+ var subStep = step.steps[idSubStep];
147
+ var mappedId = element.ids[idSubStep];
148
+ newSteps[mappedId] = __assign(__assign({}, subStep), { id: mappedId, dependencies: (_c = subStep.dependencies) === null || _c === void 0 ? void 0 : _c.map(function (dep) { var _a; return (_a = element.ids[dep]) !== null && _a !== void 0 ? _a : dep; }) });
149
+ }
150
+ };
151
+ for (var _h = 0, elements_2 = elements; _h < elements_2.length; _h++) {
152
+ var element = elements_2[_h];
153
+ _loop_1(element);
154
+ }
155
+ if (elements.length === 0) {
156
+ newSteps = step.steps;
157
+ }
158
+ calcDependencies(newSteps, originalValues, customSteps, __assign(__assign({}, allSteps), newSteps), dependencies);
159
+ }
160
+ }
161
+ /** After all steps have been checked check missing entityvalue dependencies */
162
+ for (var _j = 0, _k = Object.values(steps); _j < _k.length; _j++) {
163
+ var step = _k[_j];
164
+ if (step.type === StepTypes.ENTITYVALUEPICKER) {
165
+ for (var _l = 0, _m = __spreadArray(__spreadArray([], step.path, true), step.filters, true); _l < _m.length; _l++) {
166
+ var path = _m[_l];
167
+ if (path.type !== EntityValueDataTypes.STEP)
168
+ continue;
169
+ if ((_d = step.dependencies) === null || _d === void 0 ? void 0 : _d.includes(path.idStep))
170
+ continue;
171
+ if (dependencies[path.idStep] === undefined) {
172
+ dependencies[path.idStep] = originalValues[path.idStep];
173
+ }
174
+ }
175
+ }
176
+ }
177
+ return dependencies;
178
+ }
179
+ export function calcStepDependencyValue(depStep, originalValues, customSteps) {
180
+ var _a, _b, _c, _d;
181
+ if (customSteps === void 0) { customSteps = {}; }
182
+ var custom = customSteps[depStep === null || depStep === void 0 ? void 0 : depStep.type];
183
+ if (custom === null || custom === void 0 ? void 0 : custom.calcDependencyValue) {
184
+ return custom.calcDependencyValue(depStep, originalValues[depStep.id]);
185
+ }
186
+ switch (depStep.type) {
187
+ case StepTypes.TEXTAREA: {
188
+ if (depStep.hasTextEditor) {
189
+ return null;
190
+ }
191
+ else {
192
+ return (_a = originalValues[depStep.id]) === null || _a === void 0 ? void 0 : _a.value;
193
+ }
194
+ }
195
+ case StepTypes.MAPPER: {
196
+ return ((_c = (_b = originalValues[depStep.id]) === null || _b === void 0 ? void 0 : _b.map(function (mapperValue) { var _a; return (_a = mapperValue.value) !== null && _a !== void 0 ? _a : mapperValue; })) !== null && _c !== void 0 ? _c : null);
197
+ }
198
+ default:
199
+ return (_d = originalValues[depStep.id]) !== null && _d !== void 0 ? _d : null;
200
+ }
201
+ }
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { FormComponentProps } from '../../Form';
3
+ declare function ColumnForm({ onSubmit, formController, ...props }: FormComponentProps): JSX.Element;
4
+ export default ColumnForm;
@@ -0,0 +1,106 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ var __rest = (this && this.__rest) || function (s, e) {
49
+ var t = {};
50
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
51
+ t[p] = s[p];
52
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
53
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
54
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
55
+ t[p[i]] = s[p[i]];
56
+ }
57
+ return t;
58
+ };
59
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
60
+ import { cloneElement, useState } from 'react';
61
+ import SectionComponent from '../../Section/Section';
62
+ import styles from './ColumnForm.module.css';
63
+ import Loader from '../../../shared/Loader/Loader';
64
+ import React from 'react';
65
+ import Terms from '../../Terms/Terms';
66
+ function ColumnForm(_a) {
67
+ var _this = this;
68
+ var _b;
69
+ var onSubmit = _a.onSubmit, formController = _a.formController, props = __rest(_a, ["onSubmit", "formController"]);
70
+ var form = props.form, formStyle = props.formStyle, customSubmit = props.customSubmit;
71
+ var _c = useState(false), loading = _c[0], setLoading = _c[1];
72
+ var getValues = formController.getValues, setValue = formController.setValue, clearErrors = formController.clearErrors, handleSubmit = formController.handleSubmit, control = formController.control, errors = formController.formState.errors, setFocus = formController.setFocus;
73
+ return (_jsxs("div", __assign({ className: styles.container, style: { color: formStyle.textColor } }, { children: [loading && _jsx("div", { className: styles.curtain }), _jsx(ColumnSection, __assign({ control: control, errors: errors, getValues: getValues, setValue: setValue, clearErrors: clearErrors, setFocus: setFocus, section: form.sections[form.firstSection] }, props)), _jsx(Terms, __assign({}, props, { onSubmit: onSubmit, formController: formController })), !props.postview && props.editable && (_jsxs(React.Fragment, { children: [!customSubmit && (_jsx("div", __assign({ className: styles.submitBtnContainer }, { children: _jsxs("button", __assign({ "data-testid": "form__submit", className: styles.submitBtn, onClick: function () {
74
+ handleSubmit(function (values) { return __awaiter(_this, void 0, void 0, function () {
75
+ return __generator(this, function (_a) {
76
+ switch (_a.label) {
77
+ case 0:
78
+ setLoading(true);
79
+ return [4 /*yield*/, onSubmit(values)];
80
+ case 1:
81
+ _a.sent();
82
+ setLoading(false);
83
+ return [2 /*return*/];
84
+ }
85
+ });
86
+ }); });
87
+ }, style: {
88
+ background: formStyle.primaryColor,
89
+ color: formStyle.primaryContrastColor,
90
+ }, disabled: loading }, { children: [_jsx("div", __assign({ style: {
91
+ visibility: loading
92
+ ? 'hidden'
93
+ : 'visible',
94
+ } }, { children: (_b = props.sendLabel) !== null && _b !== void 0 ? _b : 'Enviar' })), loading && (_jsx("div", __assign({ className: styles.loaderContainer }, { children: _jsx(Loader, { color: formStyle.primaryContrastColor, position: "unset" }) })))] })) }))), customSubmit &&
95
+ cloneElement(customSubmit, {
96
+ onSubmit: onSubmit,
97
+ loading: loading,
98
+ })] }))] })));
99
+ }
100
+ export default ColumnForm;
101
+ function ColumnSection(props) {
102
+ var section = props.section;
103
+ if (!props.section)
104
+ return _jsx(_Fragment, {});
105
+ return (_jsxs(React.Fragment, { children: [_jsx(SectionComponent, __assign({}, props)), section.nextSection && (_jsx(ColumnSection, __assign({}, props, { section: props.form.sections[section.nextSection] })))] }));
106
+ }