@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
package/dist/App.js CHANGED
@@ -1,261 +1,262 @@
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
- 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 _a;
60
- import { jsx as _jsx } from "react/jsx-runtime";
61
- import axios from 'axios';
62
- import { useEffect, useRef, useState } from 'react';
63
- import Loader from './shared/Loader/Loader';
64
- import styles from './App.module.css';
65
- import FormComponent from './FormComponents/Form/Form';
66
- import StepTypes from './constants/FormStepTypes';
67
- function App(_a) {
68
- var _this = this;
69
- var apiKey = _a.apiKey, domain = _a.domain, preview = _a.preview, formData = _a.formData, postview = _a.postview, isWidget = _a.isWidget, internal = _a.internal, valuesData = _a.valuesData, others = __rest(_a, ["apiKey", "domain", "preview", "formData", "postview", "isWidget", "internal", "valuesData"]);
70
- var _b = useState(undefined), form = _b[0], setForm = _b[1];
71
- var _c = useState({}), originalValues = _c[0], setOriginalValues = _c[1];
72
- var _d = useState(undefined), organizationInfo = _d[0], setOrganizationInfo = _d[1];
73
- function fetchOrgData(domain) {
74
- return __awaiter(this, void 0, void 0, function () {
75
- var url, response, currentOrg, favicon;
76
- return __generator(this, function (_a) {
77
- switch (_a.label) {
78
- case 0:
79
- url = 'https://dbsedeq00i.execute-api.us-east-1.amazonaws.com/Prod/organization';
80
- if (domain) {
81
- url += "?domain=" + domain;
82
- }
83
- return [4 /*yield*/, axios.get(url)];
84
- case 1:
85
- response = _a.sent();
86
- if (response === null || response === void 0 ? void 0 : response.data) {
87
- currentOrg = response.data;
88
- favicon = document.getElementById('favicon');
89
- favicon.href = currentOrg.partialLogoUrl;
90
- return [2 /*return*/, currentOrg];
91
- }
92
- return [2 /*return*/];
93
- }
94
- });
95
- });
96
- }
97
- function fetchPreview(formData) {
98
- return __awaiter(this, void 0, void 0, function () {
99
- var response;
100
- return __generator(this, function (_a) {
101
- switch (_a.label) {
102
- case 0: return [4 /*yield*/, axios.get('https://dbsedeq00i.execute-api.us-east-1.amazonaws.com/Prod/organization')];
103
- case 1:
104
- response = _a.sent();
105
- if (response.data) {
106
- console.log('ORGANIZATON', response);
107
- setOrganizationInfo(response.data);
108
- setForm(migrateFormData(formData));
109
- }
110
- return [2 /*return*/];
111
- }
112
- });
113
- });
114
- }
115
- useEffect(function () {
116
- if (formData !== undefined) {
117
- if (preview && formData.isStandAlone) {
118
- fetchPreview(formData);
119
- }
120
- else {
121
- setForm(migrateFormData(__assign({}, formData)));
122
- setOrganizationInfo(null);
123
- }
124
- if (valuesData !== undefined) {
125
- setOriginalValues(valuesData);
126
- }
127
- }
128
- else if (!isWidget && apiKey) {
129
- //Is iframe
130
- loadInfo(apiKey, domain);
131
- }
132
- else if (isWidget && apiKey && domain) {
133
- //Is iframe
134
- loadInfo(apiKey, domain);
135
- }
136
- else {
137
- //Error in embed
138
- setForm(null);
139
- setOrganizationInfo(null);
140
- }
141
- }, []);
142
- var containerRef = useRef();
143
- var loadInfo = function (apiKey, domain) { return __awaiter(_this, void 0, void 0, function () {
144
- var url, _a, response, orgInfo, error_1;
145
- return __generator(this, function (_b) {
146
- switch (_b.label) {
147
- case 0:
148
- _b.trys.push([0, 2, , 3]);
149
- url = "https://dbsedeq00i.execute-api.us-east-1.amazonaws.com/Prod/form/" + apiKey;
150
- if (domain) {
151
- url += "?domain=" + domain;
152
- }
153
- return [4 /*yield*/, Promise.all([
154
- axios.get(url),
155
- fetchOrgData(domain),
156
- ])];
157
- case 1:
158
- _a = _b.sent(), response = _a[0], orgInfo = _a[1];
159
- if (response) {
160
- setForm(migrateFormData(response.data));
161
- if (valuesData !== undefined) {
162
- setOriginalValues(valuesData);
163
- }
164
- }
165
- if (orgInfo) {
166
- console.log(orgInfo);
167
- setOrganizationInfo(orgInfo);
168
- }
169
- else {
170
- setOrganizationInfo(null);
171
- }
172
- return [3 /*break*/, 3];
173
- case 2:
174
- error_1 = _b.sent();
175
- setForm(null);
176
- setOrganizationInfo(null);
177
- return [3 /*break*/, 3];
178
- case 3: return [2 /*return*/];
179
- }
180
- });
181
- }); };
182
- if (form === undefined || organizationInfo === undefined) {
183
- if (isWidget) {
184
- return (_jsx("div", __assign({ className: styles.widgetContainer }, { children: _jsx("div", __assign({ className: styles.curtain }, { children: _jsx(Loader, { size: 50 }, void 0) }), void 0) }), void 0));
185
- }
186
- return (_jsx("div", __assign({ className: styles.curtain }, { children: _jsx(Loader, { size: 50 }, void 0) }), void 0));
187
- }
188
- else if (form === null) {
189
- if (organizationInfo === null) {
190
- if (isWidget) {
191
- return (_jsx("div", __assign({ className: styles.widgetContainer }, { children: _jsx("div", __assign({ className: styles.curtain }, { children: "Error" }), void 0) }), void 0));
192
- }
193
- return _jsx("div", __assign({ className: styles.curtain }, { children: "Error" }), void 0);
194
- }
195
- else {
196
- if (isWidget) {
197
- return (_jsx("div", __assign({ className: styles.widgetContainer }, { children: _jsx("div", __assign({ className: styles.curtain }, { children: "404" }), void 0) }), void 0));
198
- }
199
- return _jsx("div", __assign({ className: styles.curtain }, { children: "404" }), void 0);
200
- }
201
- }
202
- else {
203
- return (_jsx("div", __assign({ ref: containerRef, className: styles.container }, { children: _jsx(FormComponent, __assign({}, others, { form: form, reload: function () {
204
- var tempForm = __assign({}, form);
205
- setForm(undefined);
206
- setTimeout(function () {
207
- setForm(tempForm);
208
- }, 100);
209
- }, postview: postview === true, internal: internal === true, apiKey: apiKey, domain: domain, originalValues: originalValues, containerRef: containerRef, organization: organizationInfo }), void 0) }), void 0));
210
- }
211
- }
212
- export default App;
213
- //THIS IS TEMP
214
- export var SIZES;
215
- (function (SIZES) {
216
- SIZES["SMALL"] = "SMALL";
217
- SIZES["MEDIUM"] = "MEDIUM";
218
- SIZES["LARGE"] = "LARGE";
219
- })(SIZES || (SIZES = {}));
220
- export var SizesToNum = (_a = {},
221
- _a[SIZES.LARGE] = 4,
222
- _a[SIZES.MEDIUM] = 2,
223
- _a[SIZES.SMALL] = 1,
224
- _a);
225
- var migrateFormData = function (form) {
226
- var steps = __assign({}, form.steps);
227
- for (var _i = 0, _a = Object.keys(form.steps); _i < _a.length; _i++) {
228
- var idStep = _a[_i];
229
- var step = __assign({}, form.steps[idStep]);
230
- if (step.size && isNaN(step.size)) {
231
- step.size = getStaticWidth(step);
232
- }
233
- steps[idStep] = step;
234
- }
235
- var newForm = __assign(__assign({}, form), { steps: steps });
236
- if (form.spacingSize === undefined) {
237
- newForm.spacingSize = 20;
238
- newForm.blockNum = 4;
239
- newForm.blockSize = 210;
240
- }
241
- return newForm;
242
- };
243
- function getStaticWidth(step) {
244
- if (step.type === StepTypes.SELECTOR ||
245
- step.type === StepTypes.TEXTINPUT ||
246
- step.type === StepTypes.CLASSIFIER_SELECTOR) {
247
- switch (step.size) {
248
- case SIZES.LARGE:
249
- return 4;
250
- case SIZES.MEDIUM:
251
- return 2;
252
- case SIZES.SMALL:
253
- return 1;
254
- default:
255
- return 1;
256
- }
257
- }
258
- else {
259
- return 4;
260
- }
261
- }
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
+ 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 _a;
60
+ import { jsx as _jsx } from "react/jsx-runtime";
61
+ import axios from 'axios';
62
+ import { useEffect, useRef, useState } from 'react';
63
+ import Loader from './shared/Loader/Loader';
64
+ import styles from './App.module.css';
65
+ import FormComponent from './FormComponents/Form/Form';
66
+ import StepTypes from './constants/FormStepTypes';
67
+ function App(_a) {
68
+ var _this = this;
69
+ var apiKey = _a.apiKey, domain = _a.domain, preview = _a.preview, formData = _a.formData, postview = _a.postview, isWidget = _a.isWidget, internal = _a.internal, valuesData = _a.valuesData, customSteps = _a.customSteps, others = __rest(_a, ["apiKey", "domain", "preview", "formData", "postview", "isWidget", "internal", "valuesData", "customSteps"]);
70
+ var _b = useState(undefined), form = _b[0], setForm = _b[1];
71
+ var _c = useState({}), originalValues = _c[0], setOriginalValues = _c[1];
72
+ var _d = useState(undefined), organizationInfo = _d[0], setOrganizationInfo = _d[1];
73
+ //
74
+ function fetchOrgData(domain) {
75
+ return __awaiter(this, void 0, void 0, function () {
76
+ var url, response, currentOrg, favicon;
77
+ return __generator(this, function (_a) {
78
+ switch (_a.label) {
79
+ case 0:
80
+ url = 'https://dbsedeq00i.execute-api.us-east-1.amazonaws.com/Prod/organization';
81
+ if (domain) {
82
+ url += "?domain=" + domain;
83
+ }
84
+ return [4 /*yield*/, axios.get(url)];
85
+ case 1:
86
+ response = _a.sent();
87
+ if (response === null || response === void 0 ? void 0 : response.data) {
88
+ currentOrg = response.data;
89
+ favicon = document.getElementById('favicon');
90
+ favicon.href = currentOrg.partialLogoUrl;
91
+ return [2 /*return*/, currentOrg];
92
+ }
93
+ return [2 /*return*/];
94
+ }
95
+ });
96
+ });
97
+ }
98
+ function fetchPreview(formData) {
99
+ return __awaiter(this, void 0, void 0, function () {
100
+ var response;
101
+ return __generator(this, function (_a) {
102
+ switch (_a.label) {
103
+ case 0: return [4 /*yield*/, axios.get('https://dbsedeq00i.execute-api.us-east-1.amazonaws.com/Prod/organization')];
104
+ case 1:
105
+ response = _a.sent();
106
+ if (response.data) {
107
+ console.log('ORGANIZATON', response);
108
+ setOrganizationInfo(response.data);
109
+ setForm(migrateFormData(formData));
110
+ }
111
+ return [2 /*return*/];
112
+ }
113
+ });
114
+ });
115
+ }
116
+ useEffect(function () {
117
+ if (formData !== undefined) {
118
+ if (preview && formData.isStandAlone) {
119
+ fetchPreview(formData);
120
+ }
121
+ else {
122
+ setForm(migrateFormData(__assign({}, formData)));
123
+ setOrganizationInfo(null);
124
+ }
125
+ if (valuesData !== undefined) {
126
+ setOriginalValues(valuesData);
127
+ }
128
+ }
129
+ else if (!isWidget && apiKey) {
130
+ //Is iframe
131
+ loadInfo(apiKey, domain);
132
+ }
133
+ else if (isWidget && apiKey && domain) {
134
+ //Is iframe
135
+ loadInfo(apiKey, domain);
136
+ }
137
+ else {
138
+ //Error in embed
139
+ setForm(null);
140
+ setOrganizationInfo(null);
141
+ }
142
+ }, []);
143
+ var containerRef = useRef();
144
+ var loadInfo = function (apiKey, domain) { return __awaiter(_this, void 0, void 0, function () {
145
+ var url, _a, response, orgInfo, error_1;
146
+ return __generator(this, function (_b) {
147
+ switch (_b.label) {
148
+ case 0:
149
+ _b.trys.push([0, 2, , 3]);
150
+ url = "https://dbsedeq00i.execute-api.us-east-1.amazonaws.com/Prod/form/" + apiKey;
151
+ if (domain) {
152
+ url += "?domain=" + domain;
153
+ }
154
+ return [4 /*yield*/, Promise.all([
155
+ axios.get(url),
156
+ fetchOrgData(domain),
157
+ ])];
158
+ case 1:
159
+ _a = _b.sent(), response = _a[0], orgInfo = _a[1];
160
+ if (response) {
161
+ setForm(migrateFormData(response.data));
162
+ if (valuesData !== undefined) {
163
+ setOriginalValues(valuesData);
164
+ }
165
+ }
166
+ if (orgInfo) {
167
+ console.log(orgInfo);
168
+ setOrganizationInfo(orgInfo);
169
+ }
170
+ else {
171
+ setOrganizationInfo(null);
172
+ }
173
+ return [3 /*break*/, 3];
174
+ case 2:
175
+ error_1 = _b.sent();
176
+ setForm(null);
177
+ setOrganizationInfo(null);
178
+ return [3 /*break*/, 3];
179
+ case 3: return [2 /*return*/];
180
+ }
181
+ });
182
+ }); };
183
+ if (form === undefined || organizationInfo === undefined) {
184
+ if (isWidget) {
185
+ return (_jsx("div", __assign({ className: styles.widgetContainer }, { children: _jsx("div", __assign({ className: styles.curtain }, { children: _jsx(Loader, { size: 50 }, void 0) }), void 0) }), void 0));
186
+ }
187
+ return (_jsx("div", __assign({ className: styles.curtain }, { children: _jsx(Loader, { size: 50 }, void 0) }), void 0));
188
+ }
189
+ else if (form === null) {
190
+ if (organizationInfo === null) {
191
+ if (isWidget) {
192
+ return (_jsx("div", __assign({ className: styles.widgetContainer }, { children: _jsx("div", __assign({ className: styles.curtain }, { children: "Error" }), void 0) }), void 0));
193
+ }
194
+ return _jsx("div", __assign({ className: styles.curtain }, { children: "Error" }), void 0);
195
+ }
196
+ else {
197
+ if (isWidget) {
198
+ return (_jsx("div", __assign({ className: styles.widgetContainer }, { children: _jsx("div", __assign({ className: styles.curtain }, { children: "404" }), void 0) }), void 0));
199
+ }
200
+ return _jsx("div", __assign({ className: styles.curtain }, { children: "404" }), void 0);
201
+ }
202
+ }
203
+ else {
204
+ return (_jsx("div", __assign({ ref: containerRef, className: styles.container }, { children: _jsx(FormComponent, __assign({}, others, { form: form, reload: function () {
205
+ var tempForm = __assign({}, form);
206
+ setForm(undefined);
207
+ setTimeout(function () {
208
+ setForm(tempForm);
209
+ }, 100);
210
+ }, postview: postview === true, internal: internal === true, apiKey: apiKey, domain: domain, originalValues: originalValues, containerRef: containerRef, organization: organizationInfo, customSteps: customSteps !== null && customSteps !== void 0 ? customSteps : {} }), void 0) }), void 0));
211
+ }
212
+ }
213
+ export default App;
214
+ //THIS IS TEMP
215
+ export var SIZES;
216
+ (function (SIZES) {
217
+ SIZES["SMALL"] = "SMALL";
218
+ SIZES["MEDIUM"] = "MEDIUM";
219
+ SIZES["LARGE"] = "LARGE";
220
+ })(SIZES || (SIZES = {}));
221
+ export var SizesToNum = (_a = {},
222
+ _a[SIZES.LARGE] = 4,
223
+ _a[SIZES.MEDIUM] = 2,
224
+ _a[SIZES.SMALL] = 1,
225
+ _a);
226
+ var migrateFormData = function (form) {
227
+ var steps = __assign({}, form.steps);
228
+ for (var _i = 0, _a = Object.keys(form.steps); _i < _a.length; _i++) {
229
+ var idStep = _a[_i];
230
+ var step = __assign({}, form.steps[idStep]);
231
+ if (step.size && isNaN(step.size)) {
232
+ step.size = getStaticWidth(step);
233
+ }
234
+ steps[idStep] = step;
235
+ }
236
+ var newForm = __assign(__assign({}, form), { steps: steps });
237
+ if (form.spacingSize === undefined) {
238
+ newForm.spacingSize = 20;
239
+ newForm.blockNum = 4;
240
+ newForm.blockSize = 210;
241
+ }
242
+ return newForm;
243
+ };
244
+ function getStaticWidth(step) {
245
+ if (step.type === StepTypes.SELECTOR ||
246
+ step.type === StepTypes.TEXTINPUT ||
247
+ step.type === StepTypes.CLASSIFIER_SELECTOR) {
248
+ switch (step.size) {
249
+ case SIZES.LARGE:
250
+ return 4;
251
+ case SIZES.MEDIUM:
252
+ return 2;
253
+ case SIZES.SMALL:
254
+ return 1;
255
+ default:
256
+ return 1;
257
+ }
258
+ }
259
+ else {
260
+ return 4;
261
+ }
262
+ }
@@ -0,0 +1,21 @@
1
+ .curtain {
2
+ position: absolute;
3
+ width: 100%;
4
+ height: 100%;
5
+ max-width: 100%;
6
+ display: flex;
7
+ justify-content: center;
8
+ align-items: center;
9
+ background-color: white;
10
+ }
11
+
12
+ .container {
13
+ width: 100%;
14
+ position: relative;
15
+ }
16
+
17
+ .widgetContainer {
18
+ position: relative;
19
+ max-width: 100%;
20
+ height: 100%;
21
+ }
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
2
- import { FormComponentProps } from '../Form';
3
- declare function ColumnForm({ form, apiKey, reload, domain, postview, internal, formStyle, widthStats, originalValues, }: FormComponentProps): JSX.Element;
4
- export default ColumnForm;
1
+ /// <reference types="react" />
2
+ import { FormComponentProps } from '../Form';
3
+ declare function ColumnForm({ form, apiKey, reload, domain, postview, internal, formStyle, widthStats, customSteps, originalValues, }: FormComponentProps): JSX.Element;
4
+ export default ColumnForm;