@arquimedes.co/eureka-forms 0.2.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.
package/dist/App.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  import { Form } from './@Types/Form';
3
3
  interface AppProps {
4
4
  /** If the app is currently a widget */
5
- isWidget: boolean;
5
+ isWidget?: boolean;
6
6
  /** The apikey of the Form */
7
7
  apiKey?: string;
8
8
  /** The domain of the form's organization */
@@ -17,8 +17,10 @@ interface AppProps {
17
17
  preview?: boolean;
18
18
  /** The data to fill the form with */
19
19
  valuesData?: Record<string, unknown>;
20
+ /** Custom steps to display */
21
+ customSteps?: Record<string, JSX.Element>;
20
22
  }
21
- declare function App({ apiKey, domain, preview, formData, postview, isWidget, internal, valuesData, ...others }: AppProps): JSX.Element;
23
+ declare function App({ apiKey, domain, preview, formData, postview, isWidget, internal, valuesData, customSteps, ...others }: AppProps): JSX.Element;
22
24
  export default App;
23
25
  export declare enum SIZES {
24
26
  SMALL = "SMALL",
package/dist/App.js CHANGED
@@ -66,10 +66,11 @@ import FormComponent from './FormComponents/Form/Form';
66
66
  import StepTypes from './constants/FormStepTypes';
67
67
  function App(_a) {
68
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"]);
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
70
  var _b = useState(undefined), form = _b[0], setForm = _b[1];
71
71
  var _c = useState({}), originalValues = _c[0], setOriginalValues = _c[1];
72
72
  var _d = useState(undefined), organizationInfo = _d[0], setOrganizationInfo = _d[1];
73
+ //
73
74
  function fetchOrgData(domain) {
74
75
  return __awaiter(this, void 0, void 0, function () {
75
76
  var url, response, currentOrg, favicon;
@@ -206,7 +207,7 @@ function App(_a) {
206
207
  setTimeout(function () {
207
208
  setForm(tempForm);
208
209
  }, 100);
209
- }, postview: postview === true, internal: internal === true, apiKey: apiKey, domain: domain, originalValues: originalValues, containerRef: containerRef, organization: organizationInfo }), void 0) }), void 0));
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));
210
211
  }
211
212
  }
212
213
  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, originalValues, }: FormComponentProps): JSX.Element;
3
+ declare function ColumnForm({ form, apiKey, reload, domain, postview, internal, formStyle, widthStats, customSteps, originalValues, }: FormComponentProps): JSX.Element;
4
4
  export default ColumnForm;
@@ -58,7 +58,7 @@ import Loader from '../../../shared/Loader/Loader';
58
58
  import axios from 'axios';
59
59
  function ColumnForm(_a) {
60
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;
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
62
  var _b = useState(false), tempError = _b[0], setTempError = _b[1];
63
63
  var _c = useForm({
64
64
  defaultValues: mapValues(originalValues, form),
@@ -126,7 +126,7 @@ function ColumnForm(_a) {
126
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
127
  reload();
128
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 &&
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
130
  !internal &&
131
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
132
  onSubmit();
@@ -8,6 +8,7 @@ export interface WidthStats {
8
8
  export interface FormComponentProps {
9
9
  form: Form;
10
10
  originalValues: Record<string, unknown>;
11
+ customSteps: Record<string, JSX.Element>;
11
12
  widthStats: WidthStats;
12
13
  internal: boolean;
13
14
  reload: Function;
@@ -13,6 +13,7 @@ export interface RecursiveData {
13
13
  clearErrors: Function;
14
14
  getValues: UseFormGetValues<FieldValues>;
15
15
  originalValues: Record<string, any>;
16
+ customSteps: Record<string, JSX.Element>;
16
17
  }
17
18
  export interface SectionComponentProps extends RecursiveData {
18
19
  section: Section;
@@ -6,5 +6,5 @@ export interface StepProps extends RecursiveData {
6
6
  handleSizeChange: Function;
7
7
  level: number;
8
8
  }
9
- declare function StepComponent({ step, ...others }: StepProps): JSX.Element;
9
+ declare function StepComponent({ step, ...props }: StepProps): JSX.Element;
10
10
  export default StepComponent;
@@ -30,35 +30,44 @@ 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';
33
34
  function StepComponent(_a) {
34
- var step = _a.step, others = __rest(_a, ["step"]);
35
+ var step = _a.step, props = __rest(_a, ["step"]);
35
36
  switch (step.type) {
36
37
  case Types.TITLE: {
37
- return _jsx(TitleStep, __assign({ step: step }, others), void 0);
38
+ return _jsx(TitleStep, __assign({ step: step }, props), void 0);
38
39
  }
39
40
  case Types.SELECTOR: {
40
- return _jsx(SelectorStep, __assign({ step: step }, others), void 0);
41
+ return _jsx(SelectorStep, __assign({ step: step }, props), void 0);
41
42
  }
42
43
  case Types.CLASSIFIER_SELECTOR: {
43
- return (_jsx(ClassifierSelectorStep, __assign({ step: step }, others), void 0));
44
+ return (_jsx(ClassifierSelectorStep, __assign({ step: step }, props), void 0));
44
45
  }
45
46
  case Types.TEXTAREA: {
46
- return _jsx(TextAreaStep, __assign({ step: step }, others), void 0);
47
+ return _jsx(TextAreaStep, __assign({ step: step }, props), void 0);
47
48
  }
48
49
  case Types.TEXTINPUT: {
49
- return _jsx(TextInputStep, __assign({ step: step }, others), void 0);
50
+ return _jsx(TextInputStep, __assign({ step: step }, props), void 0);
50
51
  }
51
52
  case Types.DATEPICKER: {
52
- return _jsx(DatePickerStep, __assign({ step: step }, others), void 0);
53
+ return _jsx(DatePickerStep, __assign({ step: step }, props), void 0);
53
54
  }
54
55
  case Types.SEPARATOR: {
55
- return _jsx(SeparatorStep, __assign({ step: step }, others), void 0);
56
+ return _jsx(SeparatorStep, __assign({ step: step }, props), void 0);
56
57
  }
57
58
  case Types.FILEUPLOAD: {
58
- return _jsx(FileUploadStep, __assign({ step: step }, others), void 0);
59
+ return _jsx(FileUploadStep, __assign({ step: step }, props), void 0);
59
60
  }
60
61
  default:
61
- return _jsx("div", {}, void 0);
62
+ console.log('TYPENOTFOUND', step.type);
63
+ var customStep = props.customSteps[step.type];
64
+ console.log(customStep);
65
+ if (customStep) {
66
+ return React.cloneElement(customStep, __assign({ step: step }, props));
67
+ }
68
+ else {
69
+ return _jsx("div", {}, void 0);
70
+ }
62
71
  }
63
72
  }
64
73
  export default StepComponent;
package/dist/Widget.js CHANGED
@@ -31,26 +31,9 @@ if (element) {
31
31
  }
32
32
  }
33
33
  }
34
- var formDataString = element.getAttribute('data-formdata');
35
- if (formDataString) {
36
- props.formData = JSON.parse(formDataString);
37
- }
38
34
  var valuesString = element.getAttribute('data-values');
39
35
  if (valuesString) {
40
36
  props.valuesData = JSON.parse(valuesString);
41
37
  }
42
- var internal = element.getAttribute('data-internal');
43
- if (internal) {
44
- props.internal = true;
45
- }
46
- var postview = element.getAttribute('data-postview');
47
- if (postview) {
48
- props.postview = true;
49
- }
50
- var preview = element.getAttribute('data-preview');
51
- if (preview) {
52
- props.preview = true;
53
- }
54
- console.log(props);
55
38
  }
56
39
  ReactDOM.render(_jsx(App, __assign({ isWidget: true }, props), void 0), document.getElementById(WIDGET_ID));
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.2",
4
+ "version": "0.2.5",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
7
7
  "build": "react-scripts build",