@arquimedes.co/eureka-forms 1.3.0-test → 1.4.0-test

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import Types, { ClassifierOptionTypes, ClientInfoTypes, OptionTypes } from '../constants/FormStepTypes';
1
+ import Types, { ClassifierOptionTypes, OptionTypes } from '../constants/FormStepTypes';
2
2
  export declare type FormStep = Title | CheckBox | TextArea | TextInput | DatePicker | FileUpload | Separator | FormSelector | ClassifierSelector;
3
3
  export interface Title {
4
4
  id: string;
@@ -34,7 +34,6 @@ export interface TextArea {
34
34
  description: string | null;
35
35
  required: boolean;
36
36
  hasTextEditor: boolean;
37
- isPrimary: boolean;
38
37
  }
39
38
  export interface TextInput {
40
39
  id: string;
@@ -43,9 +42,6 @@ export interface TextInput {
43
42
  description: string | null;
44
43
  validation?: FormValidation;
45
44
  required: boolean;
46
- isSubject: boolean;
47
- isClientInfo: boolean;
48
- clientInfoType?: ClientInfoTypes;
49
45
  size: 1 | 2 | 3 | 4;
50
46
  }
51
47
  export interface DatePicker {
package/dist/App.d.ts CHANGED
@@ -19,6 +19,8 @@ export interface AppProps {
19
19
  valuesData?: Record<string, unknown>;
20
20
  /** Custom steps to display */
21
21
  customSteps?: Record<string, CustomStep>;
22
+ /** Custom function to call on send */
23
+ customSend?: (values: any, reload: Function) => Promise<void>;
22
24
  /** Function to call on postview to fetch the download url of a file */
23
25
  fetchDownloadUrl?: (S3Key: string, fileName: string) => Promise<string>;
24
26
  /** Function to call after the confimation dialog has been closed */
@@ -28,7 +30,7 @@ export interface CustomStep {
28
30
  component: ReactNode;
29
31
  updateValue: (idStep: string, values: Record<string, any>, form: Form) => void;
30
32
  }
31
- declare function App({ apiKey, domain, preview, formData, postview, isWidget, internal, valuesData, customSteps, handleConfirmed, ...others }: AppProps): JSX.Element;
33
+ declare function App({ apiKey, domain, preview, formData, postview, isWidget, internal, valuesData, customSend, customSteps, handleConfirmed, ...others }: AppProps): JSX.Element;
32
34
  export default App;
33
35
  export declare enum SIZES {
34
36
  SMALL = "SMALL",
package/dist/App.js CHANGED
@@ -68,7 +68,7 @@ import widgetInstance from './AxiosWidget';
68
68
  function App(_a) {
69
69
  var _this = this;
70
70
  var _b, _c, _d, _e;
71
- var apiKey = _a.apiKey, domain = _a.domain, preview = _a.preview, formData = _a.formData, postview = _a.postview, isWidget = _a.isWidget, internal = _a.internal, valuesData = _a.valuesData, customSteps = _a.customSteps, handleConfirmed = _a.handleConfirmed, others = __rest(_a, ["apiKey", "domain", "preview", "formData", "postview", "isWidget", "internal", "valuesData", "customSteps", "handleConfirmed"]);
71
+ var apiKey = _a.apiKey, domain = _a.domain, preview = _a.preview, formData = _a.formData, postview = _a.postview, isWidget = _a.isWidget, internal = _a.internal, valuesData = _a.valuesData, customSend = _a.customSend, customSteps = _a.customSteps, handleConfirmed = _a.handleConfirmed, others = __rest(_a, ["apiKey", "domain", "preview", "formData", "postview", "isWidget", "internal", "valuesData", "customSend", "customSteps", "handleConfirmed"]);
72
72
  var _f = useState(undefined), form = _f[0], setForm = _f[1];
73
73
  var _g = useState({}), originalValues = _g[0], setOriginalValues = _g[1];
74
74
  var _h = useState(undefined), organizationInfo = _h[0], setOrganizationInfo = _h[1];
@@ -256,7 +256,7 @@ function App(_a) {
256
256
  if (handleConfirmed) {
257
257
  handleConfirmed();
258
258
  }
259
- }, postview: postview === true, internal: internal === true, apiKey: apiKey, domain: domain, originalValues: originalValues, containerRef: containerRef, organization: organizationInfo, customSteps: customSteps !== null && customSteps !== void 0 ? customSteps : {} }), void 0) }), void 0));
259
+ }, postview: postview === true, internal: internal === true, apiKey: apiKey, domain: domain, customSend: customSend, originalValues: originalValues, containerRef: containerRef, organization: organizationInfo, customSteps: customSteps !== null && customSteps !== void 0 ? customSteps : {} }), void 0) }), void 0));
260
260
  }
261
261
  }
262
262
  export default App;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { FormComponentProps } from '../Form';
3
- declare function ColumnForm({ form, apiKey, reload, domain, postview, internal, formStyle, widthStats, customSteps, originalValues, ...others }: FormComponentProps): JSX.Element;
3
+ declare function ColumnForm({ form, apiKey, reload, domain, postview, internal, formStyle, widthStats, customSteps, customSend, originalValues, ...others }: FormComponentProps): JSX.Element;
4
4
  export default ColumnForm;
@@ -70,7 +70,7 @@ import axiosInstance from '../../../AxiosAPI';
70
70
  import widgetInstance from '../../../AxiosWidget';
71
71
  function ColumnForm(_a) {
72
72
  var _this = this;
73
- var form = _a.form, apiKey = _a.apiKey, reload = _a.reload, domain = _a.domain, postview = _a.postview, internal = _a.internal, formStyle = _a.formStyle, widthStats = _a.widthStats, customSteps = _a.customSteps, originalValues = _a.originalValues, others = __rest(_a, ["form", "apiKey", "reload", "domain", "postview", "internal", "formStyle", "widthStats", "customSteps", "originalValues"]);
73
+ var form = _a.form, apiKey = _a.apiKey, reload = _a.reload, domain = _a.domain, postview = _a.postview, internal = _a.internal, formStyle = _a.formStyle, widthStats = _a.widthStats, customSteps = _a.customSteps, customSend = _a.customSend, originalValues = _a.originalValues, others = __rest(_a, ["form", "apiKey", "reload", "domain", "postview", "internal", "formStyle", "widthStats", "customSteps", "customSend", "originalValues"]);
74
74
  var _b = useState(false), tempError = _b[0], setTempError = _b[1];
75
75
  var _c = useForm({
76
76
  defaultValues: mapOriginal(originalValues, form),
@@ -93,7 +93,7 @@ function ColumnForm(_a) {
93
93
  return __generator(this, function (_c) {
94
94
  switch (_c.label) {
95
95
  case 0:
96
- if (!(apiKey || internal)) return [3 /*break*/, 8];
96
+ if (!(apiKey || internal)) return [3 /*break*/, 11];
97
97
  return [4 /*yield*/, trigger(undefined, { shouldFocus: true })];
98
98
  case 1:
99
99
  valid = _c.sent();
@@ -104,42 +104,46 @@ function ColumnForm(_a) {
104
104
  setTimeout(function () {
105
105
  setTempError(false);
106
106
  }, 500);
107
- return [3 /*break*/, 8];
107
+ return [3 /*break*/, 11];
108
108
  case 2:
109
- _c.trys.push([2, 7, , 8]);
109
+ _c.trys.push([2, 10, , 11]);
110
110
  setLoading(true);
111
111
  for (_i = 0, _a = Object.keys(values); _i < _a.length; _i++) {
112
112
  idStep = _a[_i];
113
113
  updateValue(idStep, values, form, customSteps);
114
114
  }
115
- if (internal) {
116
- // eslint-disable-next-line no-console
117
- console.log('UPDATED:', values);
118
- }
115
+ if (!customSend) return [3 /*break*/, 4];
116
+ return [4 /*yield*/, customSend(values, reload)];
117
+ case 3:
118
+ _c.sent();
119
+ return [3 /*break*/, 9];
120
+ case 4:
119
121
  payload = {
120
122
  formValues: { steps: values },
121
123
  };
122
124
  url = "/ticket/" + (internal ? form.apiKey : apiKey);
123
- if (!(domain || internal)) return [3 /*break*/, 4];
125
+ if (!(domain || internal)) return [3 /*break*/, 6];
124
126
  return [4 /*yield*/, widgetInstance.post(url + "?idOrganization=" + domain, payload)];
125
- case 3:
126
- _b = _c.sent();
127
- return [3 /*break*/, 6];
128
- case 4: return [4 /*yield*/, axiosInstance.post(url, payload)];
129
127
  case 5:
130
128
  _b = _c.sent();
131
- _c.label = 6;
132
- case 6:
129
+ return [3 /*break*/, 8];
130
+ case 6: return [4 /*yield*/, axiosInstance.post(url, payload)];
131
+ case 7:
132
+ _b = _c.sent();
133
+ _c.label = 8;
134
+ case 8:
133
135
  resp = _b;
134
136
  setShowConfirmation(resp === null || resp === void 0 ? void 0 : resp.data);
137
+ _c.label = 9;
138
+ case 9:
135
139
  setLoading(false);
136
- return [3 /*break*/, 8];
137
- case 7:
140
+ return [3 /*break*/, 11];
141
+ case 10:
138
142
  error_1 = _c.sent();
139
143
  console.error(error_1);
140
144
  setLoading(false);
141
- return [3 /*break*/, 8];
142
- case 8: return [2 /*return*/];
145
+ return [3 /*break*/, 11];
146
+ case 11: return [2 /*return*/];
143
147
  }
144
148
  });
145
149
  }); };
@@ -196,38 +200,40 @@ var mapOriginal = function (values, form) {
196
200
  };
197
201
  var updateValue = function (idStep, values, form, customSteps) {
198
202
  var step = form.steps[idStep];
199
- switch (step === null || step === void 0 ? void 0 : step.type) {
200
- case Types.TEXTAREA: {
201
- var value = values[step.id];
202
- if (step.hasTextEditor) {
203
- var currentContent = value.getCurrentContent();
204
- values[step.id] = {
205
- value: currentContent.getPlainText(),
206
- draft: convertToRaw(currentContent),
207
- };
203
+ var custom = customSteps[step === null || step === void 0 ? void 0 : step.type];
204
+ if (custom !== undefined) {
205
+ custom.updateValue(idStep, values, form);
206
+ }
207
+ else {
208
+ switch (step === null || step === void 0 ? void 0 : step.type) {
209
+ case Types.TEXTAREA: {
210
+ var value = values[step.id];
211
+ if (step.hasTextEditor) {
212
+ var currentContent = value.getCurrentContent();
213
+ values[step.id] = {
214
+ value: currentContent.getPlainText(),
215
+ draft: convertToRaw(currentContent),
216
+ };
217
+ }
218
+ else {
219
+ values[step.id] = {
220
+ value: value,
221
+ draft: stringToDraft(value),
222
+ };
223
+ }
224
+ break;
208
225
  }
209
- else {
210
- values[step.id] = {
211
- value: value,
212
- draft: stringToDraft(value),
213
- };
226
+ case Types.FILEUPLOAD: {
227
+ var value = values[step.id];
228
+ values[step.id] = value.map(function (val) { return ({
229
+ fileName: val.fileName,
230
+ S3Key: val.S3Key,
231
+ }); });
232
+ break;
214
233
  }
215
- break;
234
+ default:
235
+ break;
216
236
  }
217
- case Types.FILEUPLOAD: {
218
- var value = values[step.id];
219
- values[step.id] = value.map(function (val) { return ({
220
- fileName: val.fileName,
221
- S3Key: val.S3Key,
222
- }); });
223
- break;
224
- }
225
- default:
226
- var custom = customSteps[step === null || step === void 0 ? void 0 : step.type];
227
- if (custom !== undefined) {
228
- custom.updateValue(idStep, values, form);
229
- }
230
- break;
231
237
  }
232
238
  };
233
239
  function stringToDraft(text) {
@@ -11,6 +11,7 @@ export interface FormComponentProps {
11
11
  form: Form;
12
12
  originalValues: Record<string, unknown>;
13
13
  customSteps: Record<string, CustomStep>;
14
+ customSend?: (values: any, reload: Function) => Promise<void>;
14
15
  widthStats: WidthStats;
15
16
  internal: boolean;
16
17
  reload: Function;
@@ -33,6 +33,10 @@ import FileUploadStep from './FileUploadStep/FileUploadStep';
33
33
  import CheckBoxStep from './CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep';
34
34
  function StepComponent(_a) {
35
35
  var step = _a.step, props = __rest(_a, ["step"]);
36
+ var customStep = props.customSteps[step.type];
37
+ if (customStep) {
38
+ return customStep.component(__assign({ step: step }, props));
39
+ }
36
40
  switch (step.type) {
37
41
  case Types.TITLE: {
38
42
  return _jsx(TitleStep, __assign({ step: step }, props), void 0);
@@ -62,13 +66,7 @@ function StepComponent(_a) {
62
66
  return _jsx(FileUploadStep, __assign({ step: step }, props), void 0);
63
67
  }
64
68
  default:
65
- var customStep = props.customSteps[step.type];
66
- if (customStep) {
67
- return customStep.component(__assign({ step: step }, props));
68
- }
69
- else {
70
- return _jsx("div", {}, void 0);
71
- }
69
+ return _jsx("div", {}, void 0);
72
70
  }
73
71
  }
74
72
  export default StepComponent;
@@ -27,7 +27,7 @@
27
27
 
28
28
  .editor {
29
29
  margin: -5px 10px 0 10px;
30
- height: calc(100% - 46px) !important;
30
+ height: calc(100% - 22px) !important;
31
31
  }
32
32
 
33
33
  .wrapper {
@@ -25,10 +25,4 @@ export declare enum ClassifierOptionTypes {
25
25
  HIDE = "CLASSIFIER_HIDE",
26
26
  NESTED = "CLASSIFIER_NESTED"
27
27
  }
28
- export declare enum ClientInfoTypes {
29
- NAME = "NAME",
30
- LASTNAME = "LASTNAME",
31
- EMAIL = "EMAIL",
32
- OTHER = "OTHER"
33
- }
34
28
  export default TYPES;
@@ -30,11 +30,4 @@ export var ClassifierOptionTypes;
30
30
  ClassifierOptionTypes["HIDE"] = "CLASSIFIER_HIDE";
31
31
  ClassifierOptionTypes["NESTED"] = "CLASSIFIER_NESTED";
32
32
  })(ClassifierOptionTypes || (ClassifierOptionTypes = {}));
33
- export var ClientInfoTypes;
34
- (function (ClientInfoTypes) {
35
- ClientInfoTypes["NAME"] = "NAME";
36
- ClientInfoTypes["LASTNAME"] = "LASTNAME";
37
- ClientInfoTypes["EMAIL"] = "EMAIL";
38
- ClientInfoTypes["OTHER"] = "OTHER";
39
- })(ClientInfoTypes || (ClientInfoTypes = {}));
40
33
  export default TYPES;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arquimedes.co/eureka-forms",
3
3
  "repository": "git://github.com/Arquimede5/Eureka-Forms.git",
4
- "version":"1.3.0-test",
4
+ "version":"1.4.0-test",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
7
7
  "build": "react-scripts build",