@arquimedes.co/eureka-forms 1.9.128-test → 1.9.128

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/ColumnForm/ColumnForm.d.ts +15 -0
  3. package/dist/FormComponents/Form/ColumnForm/ColumnForm.js +411 -0
  4. package/dist/{Form → FormComponents/Form}/ConfirmationDialog/ConfirmationDialog.d.ts +1 -1
  5. package/dist/{Form → FormComponents/Form}/Form.d.ts +8 -19
  6. package/dist/FormComponents/Form/Form.js +147 -0
  7. package/dist/{Form/FormTypes → FormComponents/Form}/StepperForm/StepperForm.d.ts +1 -1
  8. package/dist/{Form → FormComponents}/Section/MaterialSection/MaterialSection.js +1 -1
  9. package/dist/{Form → FormComponents}/Section/Section.d.ts +4 -1
  10. package/dist/{FormSteps → FormComponents/Step}/@Construction/CBRElementStep/CBRElementStep.d.ts +1 -1
  11. package/dist/{FormSteps → FormComponents/Step}/@Construction/CBRElementStep/CBRElementStep.js +2 -2
  12. package/dist/{FormSteps → FormComponents/Step}/@Construction/CBRIncidentsStep/CBRIncidentsStep.d.ts +1 -1
  13. package/dist/{FormSteps → FormComponents/Step}/@Construction/CBRIncidentsStep/CBRIncidentsStep.js +1 -1
  14. package/dist/{FormSteps → FormComponents/Step}/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.js +2 -2
  15. package/dist/{FormSteps → FormComponents/Step}/@Construction/CBRPropertyStep/CBRPropertyStep.d.ts +1 -1
  16. package/dist/{FormSteps → FormComponents/Step}/@Construction/CBRPropertyStep/CBRPropertyStep.js +2 -2
  17. package/dist/{FormSteps → FormComponents/Step}/AYFStepMapper.d.ts +1 -1
  18. package/dist/{FormSteps → FormComponents/Step}/AYFStepMapper.js +1 -1
  19. package/dist/{FormSteps → FormComponents/Step}/ApiSelectorStep/ApiSelectorStep.d.ts +1 -1
  20. package/dist/{FormSteps → FormComponents/Step}/ApiSelectorStep/ApiSelectorStep.js +1 -1
  21. package/dist/{FormSteps → FormComponents/Step}/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.js +4 -4
  22. package/dist/{FormSteps → FormComponents/Step}/CBRStepMapper.d.ts +1 -1
  23. package/dist/{FormSteps → FormComponents/Step}/CBRStepMapper.js +2 -2
  24. package/dist/{FormSteps → FormComponents/Step}/CheckBoxStep/CheckBoxStep.d.ts +1 -1
  25. package/dist/{FormSteps → FormComponents/Step}/CheckBoxStep/CheckBoxStep.js +1 -1
  26. package/dist/{FormSteps → FormComponents/Step}/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.js +1 -1
  27. package/dist/{FormSteps → FormComponents/Step}/ClassifierSelectorStep/ClassifierSelectorStep.d.ts +1 -1
  28. package/dist/{FormSteps → FormComponents/Step}/ClassifierSelectorStep/ClassifierSelectorStep.js +1 -1
  29. package/dist/{FormSteps → FormComponents/Step}/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +2 -2
  30. package/dist/{FormSteps → FormComponents/Step}/CollapsibleStep/CollapsibleStep.d.ts +1 -1
  31. package/dist/{FormSteps → FormComponents/Step}/CollapsibleStep/CollapsibleStep.js +1 -1
  32. package/dist/{FormSteps → FormComponents/Step}/DatePickerStep/DatePickerStep.d.ts +1 -1
  33. package/dist/{FormSteps → FormComponents/Step}/DatePickerStep/DatePickerStep.js +1 -1
  34. package/dist/{FormSteps → FormComponents/Step}/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.js +1 -1
  35. package/dist/{FormSteps → FormComponents/Step}/EntityValueStep/EntityValuePickerStep.d.ts +1 -1
  36. package/dist/{FormSteps → FormComponents/Step}/EntityValueStep/EntityValuePickerStep.js +1 -1
  37. package/dist/{FormSteps → FormComponents/Step}/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +4 -4
  38. package/dist/{FormSteps → FormComponents/Step}/FileUploadStep/FileUploadStep.d.ts +1 -1
  39. package/dist/{FormSteps → FormComponents/Step}/FileUploadStep/FileUploadStep.js +1 -1
  40. package/dist/{FormSteps → FormComponents/Step}/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.d.ts +1 -1
  41. package/dist/{FormSteps → FormComponents/Step}/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.js +1 -1
  42. package/dist/{FormSteps → FormComponents/Step}/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.js +4 -4
  43. package/dist/{FormSteps → FormComponents/Step}/MapperStep/MapperStep.d.ts +1 -1
  44. package/dist/{FormSteps → FormComponents/Step}/MapperStep/MapperStep.js +1 -1
  45. package/dist/{FormSteps → FormComponents/Step}/MapperStep/MaterialMapperStep/Element/MapperElement.js +1 -1
  46. package/dist/{FormSteps → FormComponents/Step}/MapperStep/MaterialMapperStep/MaterialMapperStep.js +6 -6
  47. package/dist/{FormSteps → FormComponents/Step}/RatingStep/MaterialRatingStep/MaterialRatingStep.js +2 -2
  48. package/dist/{FormSteps → FormComponents/Step}/RatingStep/RatingStep.d.ts +1 -1
  49. package/dist/{FormSteps → FormComponents/Step}/RatingStep/RatingStep.js +1 -1
  50. package/dist/{FormSteps → FormComponents/Step}/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.js +2 -2
  51. package/dist/{FormSteps → FormComponents/Step}/SelectorStep/SelectorStep.d.ts +1 -1
  52. package/dist/{FormSteps → FormComponents/Step}/SelectorStep/SelectorStep.js +1 -1
  53. package/dist/{FormSteps → FormComponents/Step}/SeparatorStep/SeparatorStep.d.ts +1 -1
  54. package/dist/{FormSteps → FormComponents/Step}/SeparatorStep/SeparatorStep.js +1 -1
  55. package/dist/{FormSteps → FormComponents/Step}/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +1 -1
  56. package/dist/{FormSteps → FormComponents/Step}/SmartSelectStep/SmartSelectStep.d.ts +4 -4
  57. package/dist/{FormSteps → FormComponents/Step}/SmartSelectStep/SmartSelectStep.js +1 -1
  58. package/dist/{FormSteps → FormComponents/Step}/Step.d.ts +2 -2
  59. package/dist/{FormSteps → FormComponents/Step}/Step.js +1 -1
  60. package/dist/{FormSteps → FormComponents/Step}/StepFunctions.d.ts +2 -2
  61. package/dist/{FormSteps → FormComponents/Step}/StepFunctions.js +1 -1
  62. package/dist/{FormSteps → FormComponents/Step}/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.js +1 -1
  63. package/dist/{FormSteps → FormComponents/Step}/TextAreaStep/TextAreaStep.d.ts +1 -1
  64. package/dist/{FormSteps → FormComponents/Step}/TextAreaStep/TextAreaStep.js +1 -1
  65. package/dist/{FormSteps → FormComponents/Step}/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.js +1 -1
  66. package/dist/{FormSteps → FormComponents/Step}/TextInputStep/TextInputStep.d.ts +1 -1
  67. package/dist/{FormSteps → FormComponents/Step}/TextInputStep/TextInputStep.js +1 -1
  68. package/dist/{FormSteps → FormComponents/Step}/TitleStep/TitleStep.d.ts +1 -1
  69. package/dist/{FormSteps → FormComponents/Step}/TitleStep/TitleStep.js +1 -1
  70. package/dist/{Form/Terms → FormComponents}/Term/MaterialTerm/MaterialTerm.js +2 -2
  71. package/dist/{Form/Terms → FormComponents}/Term/Term.d.ts +1 -1
  72. package/dist/{Form/Terms → FormComponents}/Term/Term.js +1 -1
  73. package/dist/index.lib.d.ts +2 -2
  74. package/dist/index.lib.js +1 -1
  75. package/dist/shared/RoundedDatePicker/RoundedDatePicker.js +1 -1
  76. package/package.json +1 -1
  77. package/dist/Form/Form.js +0 -264
  78. package/dist/Form/FormFunctions.d.ts +0 -6
  79. package/dist/Form/FormFunctions.js +0 -201
  80. package/dist/Form/FormTypes/ColumnForm/ColumnForm.d.ts +0 -4
  81. package/dist/Form/FormTypes/ColumnForm/ColumnForm.js +0 -106
  82. package/dist/Form/Terms/Terms.d.ts +0 -4
  83. package/dist/Form/Terms/Terms.js +0 -37
  84. /package/dist/{Form/FormTypes → FormComponents/Form}/ColumnForm/ColumnForm.module.css +0 -0
  85. /package/dist/{Form → FormComponents/Form}/ConfirmationDialog/ConfirmationDialog.js +0 -0
  86. /package/dist/{Form → FormComponents/Form}/ConfirmationDialog/ConfirmationDialog.module.css +0 -0
  87. /package/dist/{Form → FormComponents/Form}/Form.module.css +0 -0
  88. /package/dist/{Form/FormTypes → FormComponents/Form}/StepperForm/StepperForm.js +0 -0
  89. /package/dist/{Form/FormTypes → FormComponents/Form}/StepperForm/StepperForm.module.css +0 -0
  90. /package/dist/{Form → FormComponents}/Section/MaterialSection/MaterialSection.d.ts +0 -0
  91. /package/dist/{Form → FormComponents}/Section/MaterialSection/MaterialSection.module.css +0 -0
  92. /package/dist/{Form → FormComponents}/Section/Section.js +0 -0
  93. /package/dist/{FormSteps → FormComponents/Step}/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.d.ts +0 -0
  94. /package/dist/{FormSteps → FormComponents/Step}/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.js +0 -0
  95. /package/dist/{FormSteps → FormComponents/Step}/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.module.css +0 -0
  96. /package/dist/{FormSteps → FormComponents/Step}/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.d.ts +0 -0
  97. /package/dist/{FormSteps → FormComponents/Step}/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.module.css +0 -0
  98. /package/dist/{FormSteps → FormComponents/Step}/@Construction/CBRPropertyStep/CBRPropertyStep.module.css +0 -0
  99. /package/dist/{FormSteps → FormComponents/Step}/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.d.ts +0 -0
  100. /package/dist/{FormSteps → FormComponents/Step}/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.module.css +0 -0
  101. /package/dist/{FormSteps → FormComponents/Step}/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.d.ts +0 -0
  102. /package/dist/{FormSteps → FormComponents/Step}/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.module.css +0 -0
  103. /package/dist/{FormSteps → FormComponents/Step}/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.d.ts +0 -0
  104. /package/dist/{FormSteps → FormComponents/Step}/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.module.css +0 -0
  105. /package/dist/{FormSteps → FormComponents/Step}/CollapsibleStep/MaterialTitleStep/MaterialCollapsibleStep.d.ts +0 -0
  106. /package/dist/{FormSteps → FormComponents/Step}/CollapsibleStep/MaterialTitleStep/MaterialCollapsibleStep.js +0 -0
  107. /package/dist/{FormSteps → FormComponents/Step}/CollapsibleStep/MaterialTitleStep/MaterialCollapsibleStep.module.css +0 -0
  108. /package/dist/{FormSteps → FormComponents/Step}/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.d.ts +0 -0
  109. /package/dist/{FormSteps → FormComponents/Step}/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.module.css +0 -0
  110. /package/dist/{FormSteps → FormComponents/Step}/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.d.ts +0 -0
  111. /package/dist/{FormSteps → FormComponents/Step}/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.module.css +0 -0
  112. /package/dist/{FormSteps → FormComponents/Step}/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.module.css +0 -0
  113. /package/dist/{FormSteps → FormComponents/Step}/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.d.ts +0 -0
  114. /package/dist/{FormSteps → FormComponents/Step}/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.module.css +0 -0
  115. /package/dist/{FormSteps → FormComponents/Step}/MapperStep/MaterialMapperStep/Element/ListMapperElement/ListMapperElement.d.ts +0 -0
  116. /package/dist/{FormSteps → FormComponents/Step}/MapperStep/MaterialMapperStep/Element/ListMapperElement/ListMapperElement.js +0 -0
  117. /package/dist/{FormSteps → FormComponents/Step}/MapperStep/MaterialMapperStep/Element/ListMapperElement/ListMapperElement.module.css +0 -0
  118. /package/dist/{FormSteps → FormComponents/Step}/MapperStep/MaterialMapperStep/Element/MapperElement.d.ts +0 -0
  119. /package/dist/{FormSteps → FormComponents/Step}/MapperStep/MaterialMapperStep/Element/PillMapperElement/PillMapperElement.d.ts +0 -0
  120. /package/dist/{FormSteps → FormComponents/Step}/MapperStep/MaterialMapperStep/Element/PillMapperElement/PillMapperElement.js +0 -0
  121. /package/dist/{FormSteps → FormComponents/Step}/MapperStep/MaterialMapperStep/Element/PillMapperElement/PillMapperElement.module.css +0 -0
  122. /package/dist/{FormSteps → FormComponents/Step}/MapperStep/MaterialMapperStep/MaterialMapperStep.d.ts +0 -0
  123. /package/dist/{FormSteps → FormComponents/Step}/MapperStep/MaterialMapperStep/MaterialMapperStep.module.css +0 -0
  124. /package/dist/{FormSteps → FormComponents/Step}/RatingStep/MaterialRatingStep/MaterialRatingStep.d.ts +0 -0
  125. /package/dist/{FormSteps → FormComponents/Step}/RatingStep/MaterialRatingStep/MaterialRatingStep.module.css +0 -0
  126. /package/dist/{FormSteps → FormComponents/Step}/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.d.ts +0 -0
  127. /package/dist/{FormSteps → FormComponents/Step}/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.module.css +0 -0
  128. /package/dist/{FormSteps → FormComponents/Step}/SeparatorStep/MaterialSeparatorStep/MaterialSeparatorStep.d.ts +0 -0
  129. /package/dist/{FormSteps → FormComponents/Step}/SeparatorStep/MaterialSeparatorStep/MaterialSeparatorStep.js +0 -0
  130. /package/dist/{FormSteps → FormComponents/Step}/SeparatorStep/MaterialSeparatorStep/MaterialSeparatorStep.module.css +0 -0
  131. /package/dist/{FormSteps → FormComponents/Step}/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.d.ts +0 -0
  132. /package/dist/{FormSteps → FormComponents/Step}/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.module.css +0 -0
  133. /package/dist/{FormSteps → FormComponents/Step}/TextAreaStep/MaterialTextAreaStep/DraftEditor.css +0 -0
  134. /package/dist/{FormSteps → FormComponents/Step}/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.d.ts +0 -0
  135. /package/dist/{FormSteps → FormComponents/Step}/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.module.css +0 -0
  136. /package/dist/{FormSteps → FormComponents/Step}/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.d.ts +0 -0
  137. /package/dist/{FormSteps → FormComponents/Step}/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.module.css +0 -0
  138. /package/dist/{FormSteps → FormComponents/Step}/TitleStep/MaterialTitleStep/MaterialTitleStep.d.ts +0 -0
  139. /package/dist/{FormSteps → FormComponents/Step}/TitleStep/MaterialTitleStep/MaterialTitleStep.js +0 -0
  140. /package/dist/{FormSteps → FormComponents/Step}/TitleStep/MaterialTitleStep/MaterialTitleStep.module.css +0 -0
  141. /package/dist/{Form/Terms → FormComponents}/Term/MaterialTerm/MaterialTerm.d.ts +0 -0
  142. /package/dist/{Form/Terms → FormComponents}/Term/MaterialTerm/MaterialTerm.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 './Form/Form';
63
+ import FormComponent from './FormComponents/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 './FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep';
71
+ import { stringToDraft, getRawText, } from './FormComponents/Step/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep';
72
72
  function App(_a) {
73
73
  var _this = this;
74
74
  var _b, _c, _d, _e;
@@ -0,0 +1,15 @@
1
+ /// <reference types="react" />
2
+ import { FormComponentProps } from '../Form';
3
+ import Types from '../../../constants/FormStepTypes';
4
+ import { CustomStep } from '../../../App';
5
+ import { FormStep } from '../../../@Types/FormStep';
6
+ export interface StepDependency {
7
+ value: any | undefined;
8
+ type: Types | 'ORIGINAL';
9
+ empty?: boolean;
10
+ }
11
+ export type DependencyStore = Record<string, StepDependency>;
12
+ declare function ColumnForm({ form, apiKey, reload, domain, postview, internal, formStyle, sendLabel, widthStats, customSteps, customSend, customSubmit, handleLoaded, originalValues, ...others }: FormComponentProps): JSX.Element;
13
+ export default ColumnForm;
14
+ export declare const calcValue: (idStep: string, steps: Record<string, FormStep>, values: Record<string, any>, customSteps: Record<string, CustomStep>, deleteIds: string[], value?: any) => any;
15
+ export declare function calcStepDependencyValue(depStep: FormStep, originalValues: Record<string, any>, customSteps?: Record<string, CustomStep>): StepDependency['value'];
@@ -0,0 +1,411 @@
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
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
60
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
61
+ if (ar || !(i in from)) {
62
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
63
+ ar[i] = from[i];
64
+ }
65
+ }
66
+ return to.concat(ar || Array.prototype.slice.call(from));
67
+ };
68
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
69
+ import { cloneElement, useEffect, useRef, useState } from 'react';
70
+ import ReCAPTCHA from 'react-google-recaptcha';
71
+ import SectionComponent from '../../Section/Section';
72
+ import { useForm } from 'react-hook-form';
73
+ import styles from './ColumnForm.module.css';
74
+ import Types, { EntityValueDataTypes } from '../../../constants/FormStepTypes';
75
+ import { convertToRaw } from 'draft-js';
76
+ import TermComponent from '../../Term/Term';
77
+ import ConfirmationDialog from '../ConfirmationDialog/ConfirmationDialog';
78
+ import Loader from '../../../shared/Loader/Loader';
79
+ import axiosInstance from '../../../AxiosAPI';
80
+ import widgetInstance from '../../../AxiosWidget';
81
+ import React from 'react';
82
+ function ColumnForm(_a) {
83
+ var _this = this;
84
+ var form = _a.form, apiKey = _a.apiKey, reload = _a.reload, domain = _a.domain, postview = _a.postview, internal = _a.internal, formStyle = _a.formStyle, sendLabel = _a.sendLabel, widthStats = _a.widthStats, customSteps = _a.customSteps, customSend = _a.customSend, customSubmit = _a.customSubmit, handleLoaded = _a.handleLoaded, originalValues = _a.originalValues, others = __rest(_a, ["form", "apiKey", "reload", "domain", "postview", "internal", "formStyle", "sendLabel", "widthStats", "customSteps", "customSend", "customSubmit", "handleLoaded", "originalValues"]);
85
+ var _b = useState(false), tempError = _b[0], setTempError = _b[1];
86
+ var _c = useState(calcDependencies(form.steps, originalValues, customSteps)), dependencyStore = _c[0], setDependencyStore = _c[1];
87
+ var _d = useForm({
88
+ defaultValues: originalValues,
89
+ mode: 'onTouched',
90
+ shouldFocusError: true,
91
+ }), getValues = _d.getValues, setValue = _d.setValue, clearErrors = _d.clearErrors, control = _d.control, errors = _d.formState.errors, trigger = _d.trigger, setFocus = _d.setFocus;
92
+ var recaptchaRef = useRef();
93
+ var _e = useState(undefined), sections = _e[0], setSections = _e[1];
94
+ var _f = useState(false), loading = _f[0], setLoading = _f[1];
95
+ var _g = useState(), showConfirmation = _g[0], setShowConfirmation = _g[1];
96
+ useEffect(function () {
97
+ var tempSections = [];
98
+ calcNextSection(form, form.firstSection, tempSections);
99
+ setSections(tempSections);
100
+ handleLoaded();
101
+ }, []);
102
+ if (sections === undefined) {
103
+ return _jsx("div", {});
104
+ }
105
+ var onSubmit = function (token) { return __awaiter(_this, void 0, void 0, function () {
106
+ var valid, values, 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
+ if (!apiKey && !internal && !customSend)
111
+ return [2 /*return*/];
112
+ return [4 /*yield*/, trigger(undefined, { shouldFocus: true })];
113
+ case 1:
114
+ valid = _c.sent();
115
+ values = getValues();
116
+ if (!valid) {
117
+ console.error('ERRORS:', errors);
118
+ setTempError(true);
119
+ setTimeout(function () {
120
+ setTempError(false);
121
+ }, 500);
122
+ return [2 /*return*/];
123
+ }
124
+ _c.label = 2;
125
+ case 2:
126
+ _c.trys.push([2, 6, , 7]);
127
+ setLoading(true);
128
+ newValues = {};
129
+ deleteIds = [];
130
+ for (_i = 0, _a = Object.keys(values); _i < _a.length; _i++) {
131
+ idStep = _a[_i];
132
+ newValues[idStep] = calcValue(idStep, form.steps, values, customSteps, deleteIds);
133
+ }
134
+ for (_b = 0, deleteIds_1 = deleteIds; _b < deleteIds_1.length; _b++) {
135
+ id = deleteIds_1[_b];
136
+ delete newValues[id];
137
+ }
138
+ if (!customSend) return [3 /*break*/, 4];
139
+ return [4 /*yield*/, customSend(newValues, reload)];
140
+ case 3:
141
+ customResp = _c.sent();
142
+ setLoading(false);
143
+ return [2 /*return*/, customResp];
144
+ case 4:
145
+ params = new URLSearchParams();
146
+ if (domain || internal)
147
+ params.set('idOrganization', domain !== null && domain !== void 0 ? domain : '');
148
+ if (token)
149
+ params.set('token', token);
150
+ url = "/ticket/".concat(internal ? form.apiKey : apiKey);
151
+ if (params.toString()) {
152
+ url += "?".concat(params.toString());
153
+ }
154
+ axios = domain || internal ? widgetInstance : axiosInstance;
155
+ return [4 /*yield*/, axios.post(url, newValues)];
156
+ case 5:
157
+ resp = _c.sent();
158
+ setShowConfirmation(resp === null || resp === void 0 ? void 0 : resp.data);
159
+ return [3 /*break*/, 7];
160
+ case 6:
161
+ error_1 = _c.sent();
162
+ console.error(error_1);
163
+ return [3 /*break*/, 7];
164
+ case 7:
165
+ setLoading(false);
166
+ return [2 /*return*/];
167
+ }
168
+ });
169
+ }); };
170
+ return (_jsxs("div", __assign({ className: styles.container, style: { color: formStyle.textColor } }, { children: [loading && _jsx("div", { className: styles.curtain }), showConfirmation !== undefined && (_jsx(ConfirmationDialog, { formStyle: formStyle, confirmation: showConfirmation, onClose: function () {
171
+ reload();
172
+ setShowConfirmation(undefined);
173
+ } })), sections.map(function (idSection, index) { return (_jsx(SectionComponent, __assign({ form: form, sendLabel: sendLabel, 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, setFocus: setFocus, setValue: setValue }, others), idSection)); }), form.terms &&
174
+ (!internal || (internal && postview)) &&
175
+ (originalValues === null || originalValues === void 0 ? void 0 : originalValues['INTERNAL_CREATING_AGENT']) === undefined && (_jsx("div", __assign({ className: styles.termsContainer, style: {
176
+ width: (form.size.blockSize + form.size.spacingSize) *
177
+ form.size.blockNum,
178
+ } }, { children: form.terms.map(function (term) { return (_jsx(TermComponent, { setValue: setValue, postview: postview, tempError: tempError, term: term, control: control, errors: errors, form: form, formStyle: formStyle }, term.id)); }) }))), !postview && others.editable && (_jsxs(React.Fragment, { children: [form.hasCaptcha && !internal && (_jsx(ReCAPTCHA, { ref: recaptchaRef, sitekey: "6LcL22kkAAAAAEotDeAFbRATob-u5vbibbCyWL2p", size: 'invisible', badge: 'bottomright' })), !customSubmit && (_jsx("div", __assign({ className: styles.submitBtnContainer }, { children: _jsxs("button", __assign({ "data-testid": "form__submit", className: styles.submitBtn, onClick: function () { return __awaiter(_this, void 0, void 0, function () {
179
+ var valid, captcha;
180
+ return __generator(this, function (_a) {
181
+ switch (_a.label) {
182
+ case 0:
183
+ if (!(form.hasCaptcha && !internal)) return [3 /*break*/, 5];
184
+ return [4 /*yield*/, trigger(undefined, {
185
+ shouldFocus: true,
186
+ })];
187
+ case 1:
188
+ valid = _a.sent();
189
+ if (!valid) return [3 /*break*/, 4];
190
+ captcha = recaptchaRef.current.getValue();
191
+ if (!!captcha) return [3 /*break*/, 3];
192
+ return [4 /*yield*/, (recaptchaRef === null || recaptchaRef === void 0 ? void 0 : recaptchaRef.current.executeAsync())];
193
+ case 2:
194
+ captcha =
195
+ _a.sent();
196
+ _a.label = 3;
197
+ case 3:
198
+ onSubmit(captcha);
199
+ _a.label = 4;
200
+ case 4: return [3 /*break*/, 6];
201
+ case 5:
202
+ onSubmit();
203
+ _a.label = 6;
204
+ case 6: return [2 /*return*/];
205
+ }
206
+ });
207
+ }); }, style: {
208
+ background: formStyle.primaryColor,
209
+ color: formStyle.primaryContrastColor,
210
+ }, disabled: loading }, { children: [_jsx("div", __assign({ style: {
211
+ visibility: loading
212
+ ? 'hidden'
213
+ : 'visible',
214
+ } }, { children: sendLabel !== null && sendLabel !== void 0 ? sendLabel : 'Enviar' })), loading && (_jsx("div", __assign({ className: styles.loaderContainer }, { children: _jsx(Loader, { color: formStyle.primaryContrastColor, position: "unset" }) })))] })) }))), customSubmit &&
215
+ cloneElement(customSubmit, {
216
+ onSubmit: onSubmit,
217
+ loading: loading,
218
+ })] }))] })));
219
+ }
220
+ export default ColumnForm;
221
+ function calcNextSection(form, idSection, sections) {
222
+ var _a;
223
+ var section = form.sections[idSection];
224
+ if (section) {
225
+ sections.push(idSection);
226
+ var nextSectionId = (_a = section.nextSection) !== null && _a !== void 0 ? _a : '';
227
+ var nextSection = form.sections[nextSectionId];
228
+ if (nextSection) {
229
+ calcNextSection(form, nextSectionId, sections);
230
+ }
231
+ }
232
+ }
233
+ export var calcValue = function (idStep, steps, values, customSteps, deleteIds, value) {
234
+ var _a, _b;
235
+ if (value === void 0) { value = values[idStep]; }
236
+ var step = steps[idStep];
237
+ if (!step)
238
+ return value;
239
+ var custom = customSteps[step === null || step === void 0 ? void 0 : step.type];
240
+ if (custom !== undefined) {
241
+ return (_b = (_a = custom.calcValue) === null || _a === void 0 ? void 0 : _a.call(custom, step, value)) !== null && _b !== void 0 ? _b : value;
242
+ }
243
+ else {
244
+ switch (step === null || step === void 0 ? void 0 : step.type) {
245
+ case Types.TEXTAREA: {
246
+ if (step.hasTextEditor) {
247
+ var currentContent = value.getCurrentContent();
248
+ return {
249
+ value: currentContent.getPlainText(),
250
+ draft: convertToRaw(currentContent),
251
+ };
252
+ }
253
+ else {
254
+ return {
255
+ value: value,
256
+ draft: stringToDraft(value),
257
+ };
258
+ }
259
+ }
260
+ case Types.FILEUPLOAD: {
261
+ return value.map(function (val) { return ({
262
+ fileName: val.fileName,
263
+ S3Key: val.S3Key,
264
+ }); });
265
+ }
266
+ case Types.SELECTOR:
267
+ case Types.CLASSIFIER_SELECTOR: {
268
+ return value.value;
269
+ }
270
+ case Types.COLLAPSIBLE: {
271
+ return !!value;
272
+ }
273
+ case Types.MAPPER: {
274
+ var elements = value === null || value === void 0 ? void 0 : value.filter(function (element) { return element.deleted !== true; });
275
+ var mappedValues = [];
276
+ for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) {
277
+ var element = elements_1[_i];
278
+ var newValue = {
279
+ id: element.id,
280
+ };
281
+ for (var _c = 0, _d = Object.keys(element.originalValues); _c < _d.length; _c++) {
282
+ var key = _d[_c];
283
+ newValue[key] = element.originalValues[key];
284
+ }
285
+ if (element.value)
286
+ newValue.value = element.value;
287
+ for (var _e = 0, _f = Object.keys(step.steps); _e < _f.length; _e++) {
288
+ var idStep_1 = _f[_e];
289
+ var mappedId = element.ids[idStep_1];
290
+ if (values[mappedId] !== undefined) {
291
+ newValue[idStep_1] = calcValue(idStep_1, step.steps, values, customSteps, deleteIds, values[mappedId]);
292
+ deleteIds.push(mappedId);
293
+ }
294
+ }
295
+ mappedValues.push(newValue);
296
+ }
297
+ return mappedValues;
298
+ }
299
+ default:
300
+ if ((step === null || step === void 0 ? void 0 : step.type) === 'CBR_INCIDENCIAS') {
301
+ return value === null || value === void 0 ? void 0 : value.filter(function (incidencia) { return incidencia.deleted !== true; });
302
+ }
303
+ return value;
304
+ }
305
+ }
306
+ };
307
+ function stringToDraft(text) {
308
+ var draftStructure = {
309
+ blocks: [],
310
+ entityMap: {},
311
+ };
312
+ text.split('\n').forEach(function (element, index) {
313
+ draftStructure.blocks.push({
314
+ key: String(index),
315
+ text: element,
316
+ type: 'unstyled',
317
+ depth: 0,
318
+ inlineStyleRanges: [],
319
+ entityRanges: [],
320
+ data: {},
321
+ });
322
+ });
323
+ return draftStructure;
324
+ }
325
+ function calcDependencies(steps, originalValues, customSteps, allSteps, dependencies) {
326
+ var _a, _b, _c, _d;
327
+ if (customSteps === void 0) { customSteps = {}; }
328
+ if (allSteps === void 0) { allSteps = steps; }
329
+ if (dependencies === void 0) { dependencies = {}; }
330
+ for (var _i = 0, _e = Object.values(steps); _i < _e.length; _i++) {
331
+ var step = _e[_i];
332
+ if (step.dependencies) {
333
+ for (var _f = 0, _g = step.dependencies; _f < _g.length; _f++) {
334
+ var idDep = _g[_f];
335
+ var depStep = allSteps[idDep];
336
+ if (depStep && dependencies[idDep] === undefined) {
337
+ dependencies[idDep] = {
338
+ type: depStep.type,
339
+ value: calcStepDependencyValue(depStep, originalValues, customSteps),
340
+ };
341
+ }
342
+ else if (dependencies[idDep] === undefined) {
343
+ dependencies[idDep] = {
344
+ type: (_a = depStep === null || depStep === void 0 ? void 0 : depStep.type) !== null && _a !== void 0 ? _a : 'ORIGINAL',
345
+ value: originalValues[idDep],
346
+ };
347
+ }
348
+ }
349
+ }
350
+ if (step.type === Types.MAPPER) {
351
+ var newSteps = {};
352
+ var elements = (_b = originalValues[step.id]) !== null && _b !== void 0 ? _b : [];
353
+ var _loop_1 = function (element) {
354
+ for (var _o = 0, _p = Object.keys(step.steps); _o < _p.length; _o++) {
355
+ var idSubStep = _p[_o];
356
+ var subStep = step.steps[idSubStep];
357
+ var mappedId = element.ids[idSubStep];
358
+ 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; }) });
359
+ }
360
+ };
361
+ for (var _h = 0, elements_2 = elements; _h < elements_2.length; _h++) {
362
+ var element = elements_2[_h];
363
+ _loop_1(element);
364
+ }
365
+ if (elements.length === 0) {
366
+ newSteps = step.steps;
367
+ }
368
+ calcDependencies(newSteps, originalValues, customSteps, __assign(__assign({}, allSteps), newSteps), dependencies);
369
+ }
370
+ }
371
+ /** After all steps have been checked check missing entityvalue dependencies */
372
+ for (var _j = 0, _k = Object.values(steps); _j < _k.length; _j++) {
373
+ var step = _k[_j];
374
+ if (step.type === Types.ENTITYVALUEPICKER) {
375
+ for (var _l = 0, _m = __spreadArray(__spreadArray([], step.path, true), step.filters, true); _l < _m.length; _l++) {
376
+ var path = _m[_l];
377
+ if (path.type !== EntityValueDataTypes.STEP)
378
+ continue;
379
+ if ((_d = step.dependencies) === null || _d === void 0 ? void 0 : _d.includes(path.idStep))
380
+ continue;
381
+ if (dependencies[path.idStep] === undefined) {
382
+ dependencies[path.idStep] = originalValues[path.idStep];
383
+ }
384
+ }
385
+ }
386
+ }
387
+ return dependencies;
388
+ }
389
+ export function calcStepDependencyValue(depStep, originalValues, customSteps) {
390
+ var _a, _b, _c, _d;
391
+ if (customSteps === void 0) { customSteps = {}; }
392
+ var custom = customSteps[depStep === null || depStep === void 0 ? void 0 : depStep.type];
393
+ if (custom === null || custom === void 0 ? void 0 : custom.calcDependencyValue) {
394
+ return custom.calcDependencyValue(depStep, originalValues[depStep.id]);
395
+ }
396
+ switch (depStep.type) {
397
+ case Types.TEXTAREA: {
398
+ if (depStep.hasTextEditor) {
399
+ return null;
400
+ }
401
+ else {
402
+ return (_a = originalValues[depStep.id]) === null || _a === void 0 ? void 0 : _a.value;
403
+ }
404
+ }
405
+ case Types.MAPPER: {
406
+ 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);
407
+ }
408
+ default:
409
+ return (_d = originalValues[depStep.id]) !== null && _d !== void 0 ? _d : null;
410
+ }
411
+ }
@@ -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,17 +1,9 @@
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';
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';
8
6
  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>;
15
7
  export interface WidthStats {
16
8
  currentBreakPoint: number;
17
9
  isResponsive: boolean;
@@ -19,7 +11,6 @@ export interface WidthStats {
19
11
  }
20
12
  export interface FormComponentProps {
21
13
  form: Form;
22
- formController: UseFormReturn;
23
14
  organization: Organization;
24
15
  branding?: Branding;
25
16
  originalValues: Record<string, unknown>;
@@ -38,16 +29,14 @@ export interface FormComponentProps {
38
29
  apiKey: string | undefined;
39
30
  /** Function to call on postview to fetch the download url of a file */
40
31
  fetchDownloadUrl?: (S3Key: string, fileName: string) => Promise<string>;
32
+ /** Function to call when the form has loaded */
33
+ handleLoaded: () => void;
41
34
  /** If the form can be edited (For entities) */
42
35
  editable: boolean;
43
36
  /** The custom send label to display */
44
37
  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>>;
49
38
  }
50
- declare function FormComponent({ form, isWidget, internal, postview, branding, organization, containerRef, ...others }: Omit<FormComponentProps, 'widthStats' | 'formStyle' | 'formController' | 'onSubmit' | 'setDependencyStore' | 'dependencyStore'> & {
39
+ declare function FormComponent({ form, isWidget, internal, postview, branding, organization, containerRef, ...others }: Omit<FormComponentProps, 'widthStats' | 'formStyle' | 'handleLoaded'> & {
51
40
  containerRef: any;
52
41
  organization: Organization | null;
53
42
  isWidget: boolean;
@@ -0,0 +1,147 @@
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 __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
+ import React, { useEffect, useState } from 'react';
25
+ import { FormStyleTypes, FormTypes } from '../../constants/FormStepTypes';
26
+ import Navbar from '../../shared/Navbar/Navbar';
27
+ import ColumnForm from './ColumnForm/ColumnForm';
28
+ import StepperForm from './StepperForm/StepperForm';
29
+ import styles from './Form.module.css';
30
+ import { MuiPickersUtilsProvider } from '@material-ui/pickers';
31
+ import DateFnsUtils from '@date-io/date-fns';
32
+ import { createGenerateClassName, createTheme, StylesProvider, ThemeProvider, } from '@material-ui/core';
33
+ import { SEED } from '../../constants/MaterialClassNameSeed';
34
+ import InternalFormStyle from '../../constants/InternalFormStyle';
35
+ import enLocale from 'date-fns/locale/en-US';
36
+ import esLocale from 'date-fns/locale/es';
37
+ var localeMap = {
38
+ en: enLocale,
39
+ 'en-US': enLocale,
40
+ es: esLocale,
41
+ };
42
+ export var getLocale = function () {
43
+ var _a;
44
+ return ((_a = localeMap[navigator.languages && navigator.languages.length
45
+ ? navigator.languages[0]
46
+ : navigator.userLanguage ||
47
+ navigator.language ||
48
+ navigator.browserLanguage]) !== null && _a !== void 0 ? _a : localeMap.es);
49
+ };
50
+ function FormComponent(_a) {
51
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
52
+ 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"]);
53
+ var _p = useState(false), loaded = _p[0], setLoaded = _p[1];
54
+ var _q = useState(undefined), widthStats = _q[0], setWidthStats = _q[1];
55
+ /** Calcs the currentBreakPoint and if is mobile */
56
+ var handleResize = function () {
57
+ var _a;
58
+ var currentWidth = (_a = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth;
59
+ if (currentWidth !== undefined) {
60
+ var currentBreakPoint = form.size.blockNum;
61
+ var padding = postview || internal || !form.isStandAlone ? 0 : 40;
62
+ while (currentWidth <
63
+ (form.size.blockSize + form.size.spacingSize) *
64
+ currentBreakPoint +
65
+ padding) {
66
+ currentBreakPoint--;
67
+ }
68
+ setWidthStats({
69
+ isResponsive: currentWidth <
70
+ (form.size.blockSize + form.size.spacingSize) *
71
+ form.size.blockNum +
72
+ padding,
73
+ isMobile: currentWidth <
74
+ (form.size.blockSize + form.size.spacingSize) * 2 + padding,
75
+ currentBreakPoint: currentBreakPoint,
76
+ });
77
+ }
78
+ };
79
+ useEffect(function () {
80
+ /** On load add a resize listener to calc the currentBreakpoint */
81
+ window.addEventListener('resize', handleResize);
82
+ handleResize();
83
+ return function () {
84
+ window.removeEventListener('resize', handleResize);
85
+ };
86
+ }, [containerRef.current, (_b = containerRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth]);
87
+ //If currently displaying internal or form is standalone
88
+ if ((postview || internal || !form.isStandAlone) &&
89
+ widthStats !== undefined) {
90
+ return (_jsx("div", __assign({ style: {
91
+ backgroundColor: internal
92
+ ? 'transparent'
93
+ : (_d = (_c = form.style) === null || _c === void 0 ? void 0 : _c.backgroundColor) !== null && _d !== void 0 ? _d : InternalFormStyle.backgroundColor,
94
+ minHeight: form.isStandAlone && !isWidget ? '100vh' : '100%',
95
+ } }, { children: _jsx("div", __assign({ className: styles.widgetFormContainer, ref: containerRef }, { children: _jsx(FormTypeComponent, __assign({}, others, { branding: branding, handleLoaded: function () {
96
+ setLoaded(true);
97
+ }, widthStats: widthStats, form: form, internal: internal, postview: postview, organization: organization, formStyle: internal
98
+ ? InternalFormStyle
99
+ : __assign(__assign({}, InternalFormStyle), ((_e = form.style) !== null && _e !== void 0 ? _e : {})) })) })) })));
100
+ }
101
+ else if (organization && widthStats !== undefined) {
102
+ //Standalone cant have widget
103
+ return (_jsxs(React.Fragment, { children: [_jsx(Navbar, { logo: branding === null || branding === void 0 ? void 0 : branding.images.logoUrl, color: (_g = (_f = branding === null || branding === void 0 ? void 0 : branding.colors) === null || _f === void 0 ? void 0 : _f.navbarColor) !== null && _g !== void 0 ? _g : (_h = branding === null || branding === void 0 ? void 0 : branding.colors) === null || _h === void 0 ? void 0 : _h.primaryColor }), _jsx("div", __assign({ className: styles.standAloneFormContainer, ref: containerRef, style: {
104
+ background: (_k = (_j = form.style) === null || _j === void 0 ? void 0 : _j.standAloneBackgroundColor) !== null && _k !== void 0 ? _k : '#ffffff',
105
+ } }, { children: _jsx("div", __assign({ className: widthStats.isResponsive
106
+ ? styles.fullScreenStandAloneForm
107
+ : styles.standAloneFormCard, style: {
108
+ backgroundColor: (_m = (_l = form.style) === null || _l === void 0 ? void 0 : _l.backgroundColor) !== null && _m !== void 0 ? _m : InternalFormStyle.backgroundColor,
109
+ visibility: loaded ? 'visible' : 'hidden',
110
+ } }, { children: _jsx(FormTypeComponent, __assign({}, others, { branding: branding, internal: internal, postview: postview, widthStats: widthStats, form: form, formStyle: (_o = form.style) !== null && _o !== void 0 ? _o : InternalFormStyle, organization: organization, handleLoaded: function () {
111
+ setLoaded(true);
112
+ } })) })) }))] }));
113
+ }
114
+ else {
115
+ return _jsx("div", {});
116
+ }
117
+ }
118
+ var muiTheme = createTheme({
119
+ typography: {
120
+ fontFamily: 'inherit',
121
+ },
122
+ });
123
+ var generateClassName = createGenerateClassName({
124
+ seed: SEED,
125
+ productionPrefix: 'efjss',
126
+ });
127
+ function FormTypeComponent(_a) {
128
+ var props = __rest(_a, []);
129
+ var renderTypes = function () {
130
+ switch (props.form.type) {
131
+ case FormTypes.STEPPER: {
132
+ return _jsx(StepperForm, __assign({}, props));
133
+ }
134
+ case FormTypes.COLUMN:
135
+ default: {
136
+ return _jsx(ColumnForm, __assign({}, props));
137
+ }
138
+ }
139
+ };
140
+ switch (props.formStyle.type) {
141
+ case FormStyleTypes.MATERIAL:
142
+ return (_jsx(StylesProvider, __assign({ generateClassName: generateClassName }, { children: _jsx(ThemeProvider, __assign({ theme: muiTheme }, { children: _jsx(MuiPickersUtilsProvider, __assign({ utils: DateFnsUtils, locale: getLocale() }, { children: renderTypes() })) })) })));
143
+ default:
144
+ return renderTypes();
145
+ }
146
+ }
147
+ export default FormComponent;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
- import { FormComponentProps } from '../../Form';
2
+ import { FormComponentProps } from '../Form';
3
3
  declare function StepperForm({}: FormComponentProps): JSX.Element;
4
4
  export default StepperForm;