@arquimedes.co/eureka-forms 0.1.2 → 0.2.5

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 (117) hide show
  1. package/dist/@Types/@Types.d.ts +1 -1
  2. package/dist/@Types/@Types.js +1 -1
  3. package/dist/@Types/Form.d.ts +63 -63
  4. package/dist/@Types/Form.js +1 -1
  5. package/dist/@Types/FormStep.d.ts +105 -105
  6. package/dist/@Types/FormStep.js +1 -1
  7. package/dist/@Types/Organization.d.ts +16 -16
  8. package/dist/@Types/Organization.js +1 -1
  9. package/dist/App.d.ts +34 -32
  10. package/dist/App.js +262 -261
  11. package/dist/App.module.css +21 -0
  12. package/dist/FormComponents/Form/ColumnForm/ColumnForm.d.ts +4 -4
  13. package/dist/FormComponents/Form/ColumnForm/ColumnForm.js +232 -232
  14. package/dist/FormComponents/Form/ColumnForm/ColumnForm.module.css +46 -0
  15. package/dist/FormComponents/Form/ConfirmationDialog/ConfirmationDialog.d.ts +12 -12
  16. package/dist/FormComponents/Form/ConfirmationDialog/ConfirmationDialog.js +33 -33
  17. package/dist/FormComponents/Form/ConfirmationDialog/ConfirmationDialog.module.css +48 -0
  18. package/dist/FormComponents/Form/Form.d.ts +24 -23
  19. package/dist/FormComponents/Form/Form.js +116 -116
  20. package/dist/FormComponents/Form/Form.module.css +39 -0
  21. package/dist/FormComponents/Form/StepperForm/StepperForm.d.ts +4 -4
  22. package/dist/FormComponents/Form/StepperForm/StepperForm.js +6 -6
  23. package/dist/FormComponents/Form/StepperForm/StepperForm.module.css +0 -0
  24. package/dist/FormComponents/Section/MaterialSection/MaterialSection.d.ts +4 -4
  25. package/dist/FormComponents/Section/MaterialSection/MaterialSection.js +42 -42
  26. package/dist/FormComponents/Section/MaterialSection/MaterialSection.module.css +8 -0
  27. package/dist/FormComponents/Section/Section.d.ts +24 -23
  28. package/dist/FormComponents/Section/Section.js +25 -25
  29. package/dist/FormComponents/Step/ClassifierSelectorStep/ClassifierSelectorStep.d.ts +9 -9
  30. package/dist/FormComponents/Step/ClassifierSelectorStep/ClassifierSelectorStep.js +37 -37
  31. package/dist/FormComponents/Step/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.d.ts +4 -4
  32. package/dist/FormComponents/Step/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +105 -105
  33. package/dist/FormComponents/Step/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.module.css +25 -0
  34. package/dist/FormComponents/Step/DatePickerStep/DatePickerStep.d.ts +9 -9
  35. package/dist/FormComponents/Step/DatePickerStep/DatePickerStep.js +25 -25
  36. package/dist/FormComponents/Step/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.d.ts +4 -4
  37. package/dist/FormComponents/Step/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.js +35 -35
  38. package/dist/FormComponents/Step/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.module.css +9 -0
  39. package/dist/FormComponents/Step/FileUploadStep/FileUploadStep.d.ts +9 -9
  40. package/dist/FormComponents/Step/FileUploadStep/FileUploadStep.js +25 -25
  41. package/dist/FormComponents/Step/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.d.ts +11 -11
  42. package/dist/FormComponents/Step/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.js +110 -110
  43. package/dist/FormComponents/Step/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.module.css +52 -0
  44. package/dist/FormComponents/Step/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.d.ts +13 -13
  45. package/dist/FormComponents/Step/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.js +165 -165
  46. package/dist/FormComponents/Step/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.module.css +45 -0
  47. package/dist/FormComponents/Step/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.d.ts +4 -4
  48. package/dist/FormComponents/Step/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.js +99 -99
  49. package/dist/FormComponents/Step/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.module.css +25 -0
  50. package/dist/FormComponents/Step/SelectorStep/SelectorStep.d.ts +9 -9
  51. package/dist/FormComponents/Step/SelectorStep/SelectorStep.js +37 -37
  52. package/dist/FormComponents/Step/SeparatorStep/MaterialSeparatorStep/MaterialSeparatorStep.d.ts +4 -4
  53. package/dist/FormComponents/Step/SeparatorStep/MaterialSeparatorStep/MaterialSeparatorStep.js +11 -11
  54. package/dist/FormComponents/Step/SeparatorStep/MaterialSeparatorStep/MaterialSeparatorStep.module.css +7 -0
  55. package/dist/FormComponents/Step/SeparatorStep/SeparatorStep.d.ts +9 -9
  56. package/dist/FormComponents/Step/SeparatorStep/SeparatorStep.js +37 -37
  57. package/dist/FormComponents/Step/Step.d.ts +10 -10
  58. package/dist/FormComponents/Step/Step.js +73 -64
  59. package/dist/FormComponents/Step/StepFunctions.d.ts +5 -5
  60. package/dist/FormComponents/Step/StepFunctions.js +51 -51
  61. package/dist/FormComponents/Step/TextAreaStep/MaterialTextAreaStep/DraftEditor.css +35 -0
  62. package/dist/FormComponents/Step/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.d.ts +6 -6
  63. package/dist/FormComponents/Step/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.js +112 -112
  64. package/dist/FormComponents/Step/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.module.css +58 -0
  65. package/dist/FormComponents/Step/TextAreaStep/TextAreaStep.d.ts +9 -9
  66. package/dist/FormComponents/Step/TextAreaStep/TextAreaStep.js +25 -25
  67. package/dist/FormComponents/Step/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.d.ts +4 -4
  68. package/dist/FormComponents/Step/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.js +43 -43
  69. package/dist/FormComponents/Step/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.module.css +9 -0
  70. package/dist/FormComponents/Step/TextInputStep/TextInputStep.d.ts +9 -9
  71. package/dist/FormComponents/Step/TextInputStep/TextInputStep.js +25 -25
  72. package/dist/FormComponents/Step/TitleStep/MaterialTitleStep/MaterialTitleStep.d.ts +4 -4
  73. package/dist/FormComponents/Step/TitleStep/MaterialTitleStep/MaterialTitleStep.js +18 -18
  74. package/dist/FormComponents/Step/TitleStep/MaterialTitleStep/MaterialTitleStep.module.css +35 -0
  75. package/dist/FormComponents/Step/TitleStep/TitleStep.d.ts +9 -9
  76. package/dist/FormComponents/Step/TitleStep/TitleStep.js +37 -37
  77. package/dist/FormComponents/Term/MaterialTerm/MaterialTerm.d.ts +4 -4
  78. package/dist/FormComponents/Term/MaterialTerm/MaterialTerm.js +77 -77
  79. package/dist/FormComponents/Term/MaterialTerm/MaterialTerm.module.css +73 -0
  80. package/dist/FormComponents/Term/Term.d.ts +15 -15
  81. package/dist/FormComponents/Term/Term.js +25 -25
  82. package/dist/Widget.d.ts +1 -1
  83. package/dist/Widget.js +39 -56
  84. package/dist/constants/Files/FileExtensions.d.ts +3 -3
  85. package/dist/constants/Files/FileExtensions.js +65 -65
  86. package/dist/constants/Files/FileMaxSize.d.ts +2 -2
  87. package/dist/constants/Files/FileMaxSize.js +2 -2
  88. package/dist/constants/FormStepTypes.d.ts +33 -33
  89. package/dist/constants/FormStepTypes.js +39 -39
  90. package/dist/constants/InternalFormStyle.d.ts +3 -3
  91. package/dist/constants/InternalFormStyle.js +12 -12
  92. package/dist/constants/MaterialClassNameSeed.d.ts +1 -1
  93. package/dist/constants/MaterialClassNameSeed.js +1 -1
  94. package/dist/controllers/FileService.d.ts +5 -5
  95. package/dist/controllers/FileService.js +89 -89
  96. package/dist/index.d.ts +1 -2
  97. package/dist/index.js +16 -17
  98. package/dist/index.lib.d.ts +3 -0
  99. package/dist/index.lib.js +3 -0
  100. package/dist/index.module.css +14 -0
  101. package/dist/shared/Loader/Loader.d.ts +18 -18
  102. package/dist/shared/Loader/Loader.js +26 -26
  103. package/dist/shared/Loader/Loader.module.css +12 -0
  104. package/dist/shared/Navbar/Navbar.d.ts +9 -9
  105. package/dist/shared/Navbar/Navbar.js +18 -18
  106. package/dist/shared/Navbar/Navbar.module.css +18 -0
  107. package/dist/shared/RoundedButton/RoundedButton.d.ts +30 -30
  108. package/dist/shared/RoundedButton/RoundedButton.js +45 -45
  109. package/dist/shared/RoundedCheckBox/RoundedCheckBox.d.ts +24 -24
  110. package/dist/shared/RoundedCheckBox/RoundedCheckBox.js +101 -101
  111. package/dist/shared/RoundedDatePicker/RoundedDatePicker.d.ts +40 -40
  112. package/dist/shared/RoundedDatePicker/RoundedDatePicker.js +246 -246
  113. package/dist/shared/RoundedSelect/RoundedSelect.d.ts +42 -42
  114. package/dist/shared/RoundedSelect/RoundedSelect.js +171 -171
  115. package/dist/shared/RoundedTextField/RoundedTextField.d.ts +41 -41
  116. package/dist/shared/RoundedTextField/RoundedTextField.js +138 -138
  117. package/package.json +2 -2
@@ -1,232 +1,232 @@
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 (_) 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
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
49
- import { useEffect, useState } from 'react';
50
- import SectionComponent from '../../Section/Section';
51
- import { useForm } from 'react-hook-form';
52
- import styles from './ColumnForm.module.css';
53
- import Types from '../../../constants/FormStepTypes';
54
- import { convertToRaw } from 'draft-js';
55
- import TermComponent from '../../Term/Term';
56
- import ConfirmationDialog from '../ConfirmationDialog/ConfirmationDialog';
57
- import Loader from '../../../shared/Loader/Loader';
58
- import axios from 'axios';
59
- function ColumnForm(_a) {
60
- var _this = this;
61
- var form = _a.form, apiKey = _a.apiKey, reload = _a.reload, domain = _a.domain, postview = _a.postview, internal = _a.internal, formStyle = _a.formStyle, widthStats = _a.widthStats, originalValues = _a.originalValues;
62
- var _b = useState(false), tempError = _b[0], setTempError = _b[1];
63
- var _c = useForm({
64
- defaultValues: mapValues(originalValues, form),
65
- mode: 'onTouched',
66
- shouldFocusError: true,
67
- }), getValues = _c.getValues, setValue = _c.setValue, clearErrors = _c.clearErrors, control = _c.control, errors = _c.formState.errors, trigger = _c.trigger;
68
- var _d = useState(undefined), sections = _d[0], setSections = _d[1];
69
- var _e = useState(false), loading = _e[0], setLoading = _e[1];
70
- var _f = useState(), showConfirmation = _f[0], setShowConfirmation = _f[1];
71
- useEffect(function () {
72
- var tempSections = [];
73
- calcNextSection(form, form.firstSection, tempSections);
74
- setSections(tempSections);
75
- }, []);
76
- if (sections === undefined) {
77
- return _jsx("div", {}, void 0);
78
- }
79
- var onSubmit = function () { return __awaiter(_this, void 0, void 0, function () {
80
- var valid, values, _i, _a, idStep, url, resp, error_1;
81
- return __generator(this, function (_b) {
82
- switch (_b.label) {
83
- case 0:
84
- if (!(apiKey || internal)) return [3 /*break*/, 5];
85
- return [4 /*yield*/, trigger()];
86
- case 1:
87
- valid = _b.sent();
88
- values = getValues();
89
- if (!!valid) return [3 /*break*/, 2];
90
- console.log('ERRORS:', errors);
91
- setTempError(true);
92
- setTimeout(function () {
93
- setTempError(false);
94
- }, 500);
95
- return [3 /*break*/, 5];
96
- case 2:
97
- _b.trys.push([2, 4, , 5]);
98
- setLoading(true);
99
- for (_i = 0, _a = Object.keys(values); _i < _a.length; _i++) {
100
- idStep = _a[_i];
101
- updateValue(idStep, values, form);
102
- }
103
- url = "https://dbsedeq00i.execute-api.us-east-1.amazonaws.com/Prod/ticket?apiKey=" + (internal ? form.apiKey : apiKey);
104
- if (domain) {
105
- url += "&domain=" + domain;
106
- }
107
- console.log(values);
108
- return [4 /*yield*/, axios.post(url, {
109
- formValues: { steps: values },
110
- })];
111
- case 3:
112
- resp = _b.sent();
113
- console.log(resp);
114
- setShowConfirmation(resp === null || resp === void 0 ? void 0 : resp.data);
115
- setLoading(false);
116
- return [3 /*break*/, 5];
117
- case 4:
118
- error_1 = _b.sent();
119
- console.error(error_1);
120
- setLoading(false);
121
- return [3 /*break*/, 5];
122
- case 5: return [2 /*return*/];
123
- }
124
- });
125
- }); };
126
- return (_jsxs("div", __assign({ className: styles.container, style: { color: formStyle.textColor } }, { children: [loading && _jsx("div", { className: styles.curtain }, void 0), showConfirmation !== undefined && (_jsx(ConfirmationDialog, { formStyle: formStyle, confirmation: showConfirmation, onClose: function () {
127
- reload();
128
- setShowConfirmation(undefined);
129
- } }, void 0)), sections.map(function (idSection, index) { return (_jsx(SectionComponent, { form: form, postview: postview, clearErrors: clearErrors, widthStats: widthStats, control: control, getValues: getValues, originalValues: originalValues, errors: errors, index: index, setSections: setSections, section: form.sections[idSection], formStyle: formStyle }, index)); }), form.terms &&
130
- !internal &&
131
- form.terms.map(function (term, index) { return (_jsx(TermComponent, { setValue: setValue, postview: postview, tempError: tempError, term: term, control: control, errors: errors, form: form, formStyle: formStyle }, index)); }), !postview && (_jsx("div", __assign({ className: styles.submitBtnContainer }, { children: _jsxs("button", __assign({ "data-testid": "login__submit", className: styles.submitBtn, onClick: function () {
132
- onSubmit();
133
- }, style: {
134
- background: formStyle.primaryColor,
135
- color: formStyle.primaryContrastColor,
136
- }, disabled: loading }, { children: [_jsx("div", __assign({ style: {
137
- visibility: loading ? 'hidden' : 'visible',
138
- } }, { children: "Enviar" }), void 0), loading && (_jsx("div", __assign({ className: styles.loaderContainer }, { children: _jsx(Loader, { color: formStyle.primaryContrastColor, position: "unset" }, void 0) }), void 0))] }), void 0) }), void 0))] }), void 0));
139
- }
140
- export default ColumnForm;
141
- function calcNextSection(form, idSection, sections) {
142
- var _a;
143
- var section = form.sections[idSection];
144
- if (section) {
145
- sections.push(idSection);
146
- var nextSectionId = (_a = section.nextSection) !== null && _a !== void 0 ? _a : '';
147
- var nextSection = form.sections[nextSectionId];
148
- if (nextSection) {
149
- calcNextSection(form, nextSectionId, sections);
150
- }
151
- }
152
- }
153
- var updateValue = function (idStep, values, form) {
154
- var step = form.steps[idStep];
155
- switch (step === null || step === void 0 ? void 0 : step.type) {
156
- case Types.TEXTAREA: {
157
- var value = values[step.id];
158
- if (step.hasTextEditor) {
159
- var currentContent = value.getCurrentContent();
160
- values[step.id] = {
161
- value: currentContent.getPlainText(),
162
- draft: convertToRaw(currentContent),
163
- };
164
- }
165
- else {
166
- values[step.id] = {
167
- value: value,
168
- draft: stringToDraft(value),
169
- };
170
- }
171
- break;
172
- }
173
- case Types.CLASSIFIER_SELECTOR: {
174
- var value = values[step.id];
175
- if (value !== undefined) {
176
- values[step.id] = {
177
- value: value,
178
- path: form.classifiers[value],
179
- idClassifier: step.idClassifier,
180
- };
181
- }
182
- break;
183
- }
184
- default:
185
- break;
186
- }
187
- };
188
- function stringToDraft(text) {
189
- var draftStructure = {
190
- blocks: [],
191
- entityMap: {},
192
- };
193
- text.split('\n').forEach(function (element, index) {
194
- draftStructure.blocks.push({
195
- key: String(index),
196
- text: element,
197
- type: 'unstyled',
198
- depth: 0,
199
- inlineStyleRanges: [],
200
- entityRanges: [],
201
- data: {},
202
- });
203
- });
204
- return draftStructure;
205
- }
206
- function mapValues(pValues, form) {
207
- var _a, _b, _c;
208
- var values = __assign({}, (pValues !== null && pValues !== void 0 ? pValues : {}));
209
- for (var _i = 0, _d = Object.keys(values); _i < _d.length; _i++) {
210
- var idStep = _d[_i];
211
- var step = form.steps[idStep];
212
- switch (step === null || step === void 0 ? void 0 : step.type) {
213
- case Types.TEXTAREA: {
214
- var value = __assign({}, values[step.id]);
215
- if (step.hasTextEditor) {
216
- delete values[step.id];
217
- }
218
- else if (value.value != undefined) {
219
- values[step.id] = (_a = value.value) !== null && _a !== void 0 ? _a : '';
220
- }
221
- break;
222
- }
223
- case Types.CLASSIFIER_SELECTOR: {
224
- values[step.id] = (_c = (_b = values[step.id]) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : '';
225
- break;
226
- }
227
- default:
228
- break;
229
- }
230
- }
231
- return values;
232
- }
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 (_) 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
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
49
+ import { useEffect, useState } from 'react';
50
+ import SectionComponent from '../../Section/Section';
51
+ import { useForm } from 'react-hook-form';
52
+ import styles from './ColumnForm.module.css';
53
+ import Types from '../../../constants/FormStepTypes';
54
+ import { convertToRaw } from 'draft-js';
55
+ import TermComponent from '../../Term/Term';
56
+ import ConfirmationDialog from '../ConfirmationDialog/ConfirmationDialog';
57
+ import Loader from '../../../shared/Loader/Loader';
58
+ import axios from 'axios';
59
+ function ColumnForm(_a) {
60
+ var _this = this;
61
+ var form = _a.form, apiKey = _a.apiKey, reload = _a.reload, domain = _a.domain, postview = _a.postview, internal = _a.internal, formStyle = _a.formStyle, widthStats = _a.widthStats, customSteps = _a.customSteps, originalValues = _a.originalValues;
62
+ var _b = useState(false), tempError = _b[0], setTempError = _b[1];
63
+ var _c = useForm({
64
+ defaultValues: mapValues(originalValues, form),
65
+ mode: 'onTouched',
66
+ shouldFocusError: true,
67
+ }), getValues = _c.getValues, setValue = _c.setValue, clearErrors = _c.clearErrors, control = _c.control, errors = _c.formState.errors, trigger = _c.trigger;
68
+ var _d = useState(undefined), sections = _d[0], setSections = _d[1];
69
+ var _e = useState(false), loading = _e[0], setLoading = _e[1];
70
+ var _f = useState(), showConfirmation = _f[0], setShowConfirmation = _f[1];
71
+ useEffect(function () {
72
+ var tempSections = [];
73
+ calcNextSection(form, form.firstSection, tempSections);
74
+ setSections(tempSections);
75
+ }, []);
76
+ if (sections === undefined) {
77
+ return _jsx("div", {}, void 0);
78
+ }
79
+ var onSubmit = function () { return __awaiter(_this, void 0, void 0, function () {
80
+ var valid, values, _i, _a, idStep, url, resp, error_1;
81
+ return __generator(this, function (_b) {
82
+ switch (_b.label) {
83
+ case 0:
84
+ if (!(apiKey || internal)) return [3 /*break*/, 5];
85
+ return [4 /*yield*/, trigger()];
86
+ case 1:
87
+ valid = _b.sent();
88
+ values = getValues();
89
+ if (!!valid) return [3 /*break*/, 2];
90
+ console.log('ERRORS:', errors);
91
+ setTempError(true);
92
+ setTimeout(function () {
93
+ setTempError(false);
94
+ }, 500);
95
+ return [3 /*break*/, 5];
96
+ case 2:
97
+ _b.trys.push([2, 4, , 5]);
98
+ setLoading(true);
99
+ for (_i = 0, _a = Object.keys(values); _i < _a.length; _i++) {
100
+ idStep = _a[_i];
101
+ updateValue(idStep, values, form);
102
+ }
103
+ url = "https://dbsedeq00i.execute-api.us-east-1.amazonaws.com/Prod/ticket?apiKey=" + (internal ? form.apiKey : apiKey);
104
+ if (domain) {
105
+ url += "&domain=" + domain;
106
+ }
107
+ console.log(values);
108
+ return [4 /*yield*/, axios.post(url, {
109
+ formValues: { steps: values },
110
+ })];
111
+ case 3:
112
+ resp = _b.sent();
113
+ console.log(resp);
114
+ setShowConfirmation(resp === null || resp === void 0 ? void 0 : resp.data);
115
+ setLoading(false);
116
+ return [3 /*break*/, 5];
117
+ case 4:
118
+ error_1 = _b.sent();
119
+ console.error(error_1);
120
+ setLoading(false);
121
+ return [3 /*break*/, 5];
122
+ case 5: return [2 /*return*/];
123
+ }
124
+ });
125
+ }); };
126
+ return (_jsxs("div", __assign({ className: styles.container, style: { color: formStyle.textColor } }, { children: [loading && _jsx("div", { className: styles.curtain }, void 0), showConfirmation !== undefined && (_jsx(ConfirmationDialog, { formStyle: formStyle, confirmation: showConfirmation, onClose: function () {
127
+ reload();
128
+ setShowConfirmation(undefined);
129
+ } }, void 0)), sections.map(function (idSection, index) { return (_jsx(SectionComponent, { form: form, 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 }, index)); }), form.terms &&
130
+ !internal &&
131
+ form.terms.map(function (term, index) { return (_jsx(TermComponent, { setValue: setValue, postview: postview, tempError: tempError, term: term, control: control, errors: errors, form: form, formStyle: formStyle }, index)); }), !postview && (_jsx("div", __assign({ className: styles.submitBtnContainer }, { children: _jsxs("button", __assign({ "data-testid": "login__submit", className: styles.submitBtn, onClick: function () {
132
+ onSubmit();
133
+ }, style: {
134
+ background: formStyle.primaryColor,
135
+ color: formStyle.primaryContrastColor,
136
+ }, disabled: loading }, { children: [_jsx("div", __assign({ style: {
137
+ visibility: loading ? 'hidden' : 'visible',
138
+ } }, { children: "Enviar" }), void 0), loading && (_jsx("div", __assign({ className: styles.loaderContainer }, { children: _jsx(Loader, { color: formStyle.primaryContrastColor, position: "unset" }, void 0) }), void 0))] }), void 0) }), void 0))] }), void 0));
139
+ }
140
+ export default ColumnForm;
141
+ function calcNextSection(form, idSection, sections) {
142
+ var _a;
143
+ var section = form.sections[idSection];
144
+ if (section) {
145
+ sections.push(idSection);
146
+ var nextSectionId = (_a = section.nextSection) !== null && _a !== void 0 ? _a : '';
147
+ var nextSection = form.sections[nextSectionId];
148
+ if (nextSection) {
149
+ calcNextSection(form, nextSectionId, sections);
150
+ }
151
+ }
152
+ }
153
+ var updateValue = function (idStep, values, form) {
154
+ var step = form.steps[idStep];
155
+ switch (step === null || step === void 0 ? void 0 : step.type) {
156
+ case Types.TEXTAREA: {
157
+ var value = values[step.id];
158
+ if (step.hasTextEditor) {
159
+ var currentContent = value.getCurrentContent();
160
+ values[step.id] = {
161
+ value: currentContent.getPlainText(),
162
+ draft: convertToRaw(currentContent),
163
+ };
164
+ }
165
+ else {
166
+ values[step.id] = {
167
+ value: value,
168
+ draft: stringToDraft(value),
169
+ };
170
+ }
171
+ break;
172
+ }
173
+ case Types.CLASSIFIER_SELECTOR: {
174
+ var value = values[step.id];
175
+ if (value !== undefined) {
176
+ values[step.id] = {
177
+ value: value,
178
+ path: form.classifiers[value],
179
+ idClassifier: step.idClassifier,
180
+ };
181
+ }
182
+ break;
183
+ }
184
+ default:
185
+ break;
186
+ }
187
+ };
188
+ function stringToDraft(text) {
189
+ var draftStructure = {
190
+ blocks: [],
191
+ entityMap: {},
192
+ };
193
+ text.split('\n').forEach(function (element, index) {
194
+ draftStructure.blocks.push({
195
+ key: String(index),
196
+ text: element,
197
+ type: 'unstyled',
198
+ depth: 0,
199
+ inlineStyleRanges: [],
200
+ entityRanges: [],
201
+ data: {},
202
+ });
203
+ });
204
+ return draftStructure;
205
+ }
206
+ function mapValues(pValues, form) {
207
+ var _a, _b, _c;
208
+ var values = __assign({}, (pValues !== null && pValues !== void 0 ? pValues : {}));
209
+ for (var _i = 0, _d = Object.keys(values); _i < _d.length; _i++) {
210
+ var idStep = _d[_i];
211
+ var step = form.steps[idStep];
212
+ switch (step === null || step === void 0 ? void 0 : step.type) {
213
+ case Types.TEXTAREA: {
214
+ var value = __assign({}, values[step.id]);
215
+ if (step.hasTextEditor) {
216
+ delete values[step.id];
217
+ }
218
+ else if (value.value != undefined) {
219
+ values[step.id] = (_a = value.value) !== null && _a !== void 0 ? _a : '';
220
+ }
221
+ break;
222
+ }
223
+ case Types.CLASSIFIER_SELECTOR: {
224
+ values[step.id] = (_c = (_b = values[step.id]) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : '';
225
+ break;
226
+ }
227
+ default:
228
+ break;
229
+ }
230
+ }
231
+ return values;
232
+ }
@@ -0,0 +1,46 @@
1
+ .container {
2
+ width: fit-content;
3
+ display: flex;
4
+ flex-direction: column;
5
+ align-items: center;
6
+ max-width: 100%;
7
+ position: relative;
8
+ }
9
+ .curtain {
10
+ position: absolute;
11
+ width: 100%;
12
+ height: 100%;
13
+ z-index: 2;
14
+ }
15
+ .submitBtnContainer {
16
+ margin-top: 10px;
17
+ width: 200px;
18
+ }
19
+
20
+ .submitBtn {
21
+ border-radius: 20px;
22
+ padding: 15px 10px;
23
+ width: 100%;
24
+ margin: 0 auto 0 auto;
25
+ font-size: 1.4rem;
26
+ cursor: pointer;
27
+ -moz-user-select: none;
28
+ -khtml-user-select: none;
29
+ -webkit-user-select: none;
30
+ -ms-user-select: none;
31
+ user-select: none;
32
+ border: none;
33
+ position: relative;
34
+ }
35
+ .submitBtn[disabled] {
36
+ pointer-events: none;
37
+ opacity: 0.5;
38
+ }
39
+
40
+ .loaderContainer {
41
+ top: 0px;
42
+ bottom: 0px;
43
+ right: 0px;
44
+ left: 0px;
45
+ position: absolute;
46
+ }
@@ -1,12 +1,12 @@
1
- /// <reference types="react" />
2
- import { FormStyle } from '../../../@Types/Form';
3
- interface ConfirmationDialogProps {
4
- confirmation: {
5
- case: string;
6
- url: string;
7
- };
8
- onClose: Function;
9
- formStyle: FormStyle;
10
- }
11
- declare function ConfirmationDialog({ confirmation, formStyle, onClose, }: ConfirmationDialogProps): JSX.Element;
12
- export default ConfirmationDialog;
1
+ /// <reference types="react" />
2
+ import { FormStyle } from '../../../@Types/Form';
3
+ interface ConfirmationDialogProps {
4
+ confirmation: {
5
+ case: string;
6
+ url: string;
7
+ };
8
+ onClose: Function;
9
+ formStyle: FormStyle;
10
+ }
11
+ declare function ConfirmationDialog({ confirmation, formStyle, onClose, }: ConfirmationDialogProps): JSX.Element;
12
+ export default ConfirmationDialog;
@@ -1,33 +1,33 @@
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
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- import CheckCircleOutlineRoundedIcon from '@material-ui/icons/CheckCircleOutlineRounded';
14
- import styles from './ConfirmationDialog.module.css';
15
- import Dialog from '@material-ui/core/Dialog';
16
- import CloseRoundedIcon from '@material-ui/icons/CloseRounded';
17
- function ConfirmationDialog(_a) {
18
- var confirmation = _a.confirmation, formStyle = _a.formStyle, onClose = _a.onClose;
19
- return (_jsx(Dialog, __assign({ PaperProps: {
20
- style: {
21
- borderRadius: '20px',
22
- maxWidth: '60vw',
23
- },
24
- }, onClose: function () {
25
- onClose();
26
- }, open: true }, { children: _jsxs("div", __assign({ className: styles.confirmationContainer, style: { color: formStyle.textColor } }, { children: [_jsx("div", __assign({ className: styles.closeIcon, onClick: function () {
27
- onClose();
28
- } }, { children: _jsx(CloseRoundedIcon, { fontSize: "inherit" }, void 0) }), void 0), _jsx("div", __assign({ className: styles.checkContainer, style: { color: formStyle.primaryColor } }, { children: _jsx(CheckCircleOutlineRoundedIcon, { fontSize: "inherit" }, void 0) }), void 0), _jsxs("div", __assign({ className: styles.messageContainer }, { children: ["Tu caso n\u00FAmero", ' ', _jsx("span", __assign({ style: { fontWeight: 'bold' } }, { children: confirmation.case }), void 0), ' ', "ha sido registrado!"] }), void 0), _jsx("div", __assign({ className: styles.messageContainer }, { children: "Pronto te estaremos dando respuesta." }), void 0), _jsxs("div", __assign({ className: styles.linkContainer }, { children: ["Puedes consultar el estado aqui:", ' '] }), void 0), _jsx("div", __assign({ className: styles.url, onClick: function () {
29
- var _a, _b, _c;
30
- (_c = (_b = (_a = window.open) === null || _a === void 0 ? void 0 : _a.call(window, confirmation.url, '_blank')) === null || _b === void 0 ? void 0 : _b.focus) === null || _c === void 0 ? void 0 : _c.call(_b);
31
- } }, { children: confirmation.url }), void 0)] }), void 0) }), void 0));
32
- }
33
- export default ConfirmationDialog;
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
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import CheckCircleOutlineRoundedIcon from '@material-ui/icons/CheckCircleOutlineRounded';
14
+ import styles from './ConfirmationDialog.module.css';
15
+ import Dialog from '@material-ui/core/Dialog';
16
+ import CloseRoundedIcon from '@material-ui/icons/CloseRounded';
17
+ function ConfirmationDialog(_a) {
18
+ var confirmation = _a.confirmation, formStyle = _a.formStyle, onClose = _a.onClose;
19
+ return (_jsx(Dialog, __assign({ PaperProps: {
20
+ style: {
21
+ borderRadius: '20px',
22
+ maxWidth: '60vw',
23
+ },
24
+ }, onClose: function () {
25
+ onClose();
26
+ }, open: true }, { children: _jsxs("div", __assign({ className: styles.confirmationContainer, style: { color: formStyle.textColor } }, { children: [_jsx("div", __assign({ className: styles.closeIcon, onClick: function () {
27
+ onClose();
28
+ } }, { children: _jsx(CloseRoundedIcon, { fontSize: "inherit" }, void 0) }), void 0), _jsx("div", __assign({ className: styles.checkContainer, style: { color: formStyle.primaryColor } }, { children: _jsx(CheckCircleOutlineRoundedIcon, { fontSize: "inherit" }, void 0) }), void 0), _jsxs("div", __assign({ className: styles.messageContainer }, { children: ["Tu caso n\u00FAmero", ' ', _jsx("span", __assign({ style: { fontWeight: 'bold' } }, { children: confirmation.case }), void 0), ' ', "ha sido registrado!"] }), void 0), _jsx("div", __assign({ className: styles.messageContainer }, { children: "Pronto te estaremos dando respuesta." }), void 0), _jsxs("div", __assign({ className: styles.linkContainer }, { children: ["Puedes consultar el estado aqui:", ' '] }), void 0), _jsx("div", __assign({ className: styles.url, onClick: function () {
29
+ var _a, _b, _c;
30
+ (_c = (_b = (_a = window.open) === null || _a === void 0 ? void 0 : _a.call(window, confirmation.url, '_blank')) === null || _b === void 0 ? void 0 : _b.focus) === null || _c === void 0 ? void 0 : _c.call(_b);
31
+ } }, { children: confirmation.url }), void 0)] }), void 0) }), void 0));
32
+ }
33
+ export default ConfirmationDialog;