@arquimedes.co/eureka-forms 0.2.10-test → 0.2.15-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.
package/dist/App.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
1
+ import { ReactNode } from 'react';
2
2
  import { Form } from './@Types/Form';
3
- interface AppProps {
3
+ export interface AppProps {
4
4
  /** If the app is currently a widget */
5
5
  isWidget?: boolean;
6
6
  /** The apikey of the Form */
@@ -18,7 +18,11 @@ interface AppProps {
18
18
  /** The data to fill the form with */
19
19
  valuesData?: Record<string, unknown>;
20
20
  /** Custom steps to display */
21
- customSteps?: Record<string, JSX.Element>;
21
+ customSteps?: Record<string, CustomStep>;
22
+ }
23
+ export interface CustomStep {
24
+ component: ReactNode;
25
+ updateValue: (idStep: string, values: Record<string, any>, form: Form) => void;
22
26
  }
23
27
  declare function App({ apiKey, domain, preview, formData, postview, isWidget, internal, valuesData, customSteps, ...others }: AppProps): JSX.Element;
24
28
  export default App;
@@ -99,14 +99,14 @@ function ColumnForm(_a) {
99
99
  setLoading(true);
100
100
  for (_i = 0, _a = Object.keys(values); _i < _a.length; _i++) {
101
101
  idStep = _a[_i];
102
- updateValue(idStep, values, form);
102
+ updateValue(idStep, values, form, customSteps);
103
103
  }
104
104
  url = "https://" + domain + ".forms." + process.env.REACT_APP_DOMAIN + "/api/ticket?apiKey=" + (internal ? form.apiKey : apiKey) + "&domain=" + domain;
105
105
  console.log(values);
106
106
  payload = {
107
107
  formValues: { steps: values },
108
108
  };
109
- if (!domain) return [3 /*break*/, 4];
109
+ if (!(domain || internal)) return [3 /*break*/, 4];
110
110
  return [4 /*yield*/, axios.post(url, payload)];
111
111
  case 3:
112
112
  _b = _c.sent();
@@ -157,7 +157,7 @@ function calcNextSection(form, idSection, sections) {
157
157
  }
158
158
  }
159
159
  }
160
- var updateValue = function (idStep, values, form) {
160
+ var updateValue = function (idStep, values, form, customSteps) {
161
161
  var step = form.steps[idStep];
162
162
  switch (step === null || step === void 0 ? void 0 : step.type) {
163
163
  case Types.TEXTAREA: {
@@ -178,6 +178,10 @@ var updateValue = function (idStep, values, form) {
178
178
  break;
179
179
  }
180
180
  default:
181
+ var custom = customSteps[idStep];
182
+ if (custom !== undefined) {
183
+ custom.updateValue(idStep, values, form);
184
+ }
181
185
  break;
182
186
  }
183
187
  };
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { Organization } from '../../@Types/@Types';
3
3
  import { Form, FormStyle } from '../../@Types/Form';
4
+ import { CustomStep } from '../../App';
4
5
  export interface WidthStats {
5
6
  currentBreakPoint: number;
6
7
  isMobile: boolean;
@@ -8,7 +9,7 @@ export interface WidthStats {
8
9
  export interface FormComponentProps {
9
10
  form: Form;
10
11
  originalValues: Record<string, unknown>;
11
- customSteps: Record<string, JSX.Element>;
12
+ customSteps: Record<string, CustomStep>;
12
13
  widthStats: WidthStats;
13
14
  internal: boolean;
14
15
  reload: Function;
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { Control, FieldValues, UseFormGetValues } from 'react-hook-form';
3
3
  import { Form, FormStyle, Section } from '../../@Types/Form';
4
+ import { CustomStep } from '../../App';
4
5
  import { WidthStats } from '../Form/Form';
5
6
  export interface RecursiveData {
6
7
  form: Form;
@@ -13,7 +14,7 @@ export interface RecursiveData {
13
14
  clearErrors: Function;
14
15
  getValues: UseFormGetValues<FieldValues>;
15
16
  originalValues: Record<string, any>;
16
- customSteps: Record<string, JSX.Element>;
17
+ customSteps: Record<string, CustomStep>;
17
18
  }
18
19
  export interface SectionComponentProps extends RecursiveData {
19
20
  section: Section;
@@ -30,7 +30,6 @@ import ClassifierSelectorStep from './ClassifierSelectorStep/ClassifierSelectorS
30
30
  import TextAreaStep from './TextAreaStep/TextAreaStep';
31
31
  import DatePickerStep from './DatePickerStep/DatePickerStep';
32
32
  import FileUploadStep from './FileUploadStep/FileUploadStep';
33
- import React from 'react';
34
33
  function StepComponent(_a) {
35
34
  var step = _a.step, props = __rest(_a, ["step"]);
36
35
  switch (step.type) {
@@ -59,11 +58,9 @@ function StepComponent(_a) {
59
58
  return _jsx(FileUploadStep, __assign({ step: step }, props), void 0);
60
59
  }
61
60
  default:
62
- console.log('TYPENOTFOUND', step.type);
63
61
  var customStep = props.customSteps[step.type];
64
- console.log(customStep);
65
62
  if (customStep) {
66
- return React.cloneElement(customStep, __assign({ step: step }, props));
63
+ return customStep.component(__assign({ step: step }, props));
67
64
  }
68
65
  else {
69
66
  return _jsx("div", {}, void 0);
@@ -16,7 +16,7 @@ import { Controller } from 'react-hook-form';
16
16
  import { Editor } from 'react-draft-wysiwyg'; //Load programatically only if step has editor
17
17
  import 'react-draft-wysiwyg/dist/react-draft-wysiwyg.css';
18
18
  import './DraftEditor.css';
19
- import { convertFromRaw, EditorState } from 'draft-js';
19
+ import { EditorState } from 'draft-js';
20
20
  import { useState } from 'react';
21
21
  import { ClickAwayListener } from '@material-ui/core';
22
22
  function TextAreaStep(_a) {
@@ -63,9 +63,14 @@ function TextAreaStep(_a) {
63
63
  if (!postview) {
64
64
  setFocus(true);
65
65
  }
66
- } }, { children: [postview && (_jsx("div", { className: styles.disabledCurtain }, void 0)), _jsx(Controller, { name: step.id, control: control, defaultValue: originalValues[step.id]
67
- ? EditorState.createWithContent(convertFromRaw(originalValues[step.id].draft))
68
- : EditorState.createEmpty(), rules: step.required
66
+ } }, { children: [postview && (_jsx("div", { className: styles.disabledCurtain }, void 0)), _jsx(Controller, { name: step.id, control: control, defaultValue:
67
+ // originalValues[step.id]
68
+ // ? EditorState.createWithContent(
69
+ // convertFromRaw(
70
+ // originalValues[step.id].draft
71
+ // )
72
+ // )
73
+ EditorState.createEmpty(), rules: step.required
69
74
  ? {
70
75
  validate: function (editorState) {
71
76
  return editorState
@@ -1,3 +1,6 @@
1
- import App from './App';
2
- export { App };
3
- export default App;
1
+ import EurekaForm, { AppProps as EurekaFormProps } from './App';
2
+ import { StepProps } from './FormComponents/Step/Step';
3
+ import * as StepFunctions from './FormComponents/Step/StepFunctions';
4
+ export type { StepProps, EurekaFormProps };
5
+ export { EurekaForm, StepFunctions };
6
+ export default EurekaForm;
package/dist/index.lib.js CHANGED
@@ -1,3 +1,4 @@
1
- import App from './App';
2
- export { App };
3
- export default App;
1
+ import EurekaForm from './App';
2
+ import * as StepFunctions from './FormComponents/Step/StepFunctions';
3
+ export { EurekaForm, StepFunctions };
4
+ export default EurekaForm;
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": "0.2.10-test",
4
+ "version": "0.2.15-test",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
7
7
  "build": "react-scripts build",