@arquimedes.co/eureka-forms 1.9.134 → 2.0.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.
- package/dist/@Types/Form.d.ts +1 -1
- package/dist/@Types/FormStep.d.ts +2 -2
- package/dist/@Types/GenericFormSteps.d.ts +1 -0
- package/dist/App/App.css +6 -0
- package/dist/{App.d.ts → App/App.d.ts} +13 -21
- package/dist/App/App.js +76 -0
- package/dist/App/AppFunctions.d.ts +16 -0
- package/dist/App/AppFunctions.js +210 -0
- package/dist/App/AppHooks.d.ts +10 -0
- package/dist/App/AppHooks.js +235 -0
- package/dist/Contexts/CustomContext.d.ts +11 -0
- package/dist/Contexts/CustomContext.js +6 -0
- package/dist/Contexts/FormContext.d.ts +4 -0
- package/dist/Contexts/FormContext.js +19 -0
- package/dist/Contexts/SectionContext.d.ts +3 -0
- package/dist/Contexts/SectionContext.js +3 -0
- package/dist/Form/ConfirmationDialog/ConfirmationDialog.d.ts +2 -4
- package/dist/Form/ConfirmationDialog/ConfirmationDialog.js +3 -1
- package/dist/Form/Form.d.ts +17 -34
- package/dist/Form/Form.js +73 -124
- package/dist/Form/FormFunctions.d.ts +5 -4
- package/dist/Form/FormFunctions.js +24 -25
- package/dist/Form/FormTypes/ColumnForm/ColumnForm.d.ts +1 -1
- package/dist/Form/FormTypes/ColumnForm/ColumnForm.js +34 -58
- package/dist/Form/FormTypes/ColumnForm/ColumnForm.module.css +0 -4
- package/dist/Form/FormTypes/StepperForm/StepperForm.d.ts +1 -1
- package/dist/Form/FormTypes/StepperForm/StepperForm.js +122 -3
- package/dist/Form/FormTypes/StepperForm/StepperForm.module.css +53 -0
- package/dist/Form/Hooks.d.ts +9 -0
- package/dist/Form/Hooks.js +7 -0
- package/dist/Form/Section/MaterialSection/MaterialSection.d.ts +1 -1
- package/dist/Form/Section/MaterialSection/MaterialSection.js +15 -16
- package/dist/Form/Section/Section.d.ts +2 -34
- package/dist/Form/Section/Section.js +11 -5
- package/dist/Form/Terms/Term/MaterialTerm/MaterialTerm.d.ts +1 -1
- package/dist/Form/Terms/Term/MaterialTerm/MaterialTerm.js +19 -14
- package/dist/Form/Terms/Term/Term.d.ts +1 -8
- package/dist/Form/Terms/Term/Term.js +3 -1
- package/dist/Form/Terms/Terms.d.ts +1 -2
- package/dist/Form/Terms/Terms.js +17 -8
- package/dist/Form/Terms/Terms.module.css +3 -0
- package/dist/FormSteps/@Construction/CBRElementStep/CBRElementStep.d.ts +3 -3
- package/dist/FormSteps/@Construction/CBRElementStep/CBRElementStep.js +49 -38
- package/dist/FormSteps/@Construction/CBRIncidentsStep/CBRIncidentsStep.js +3 -1
- package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.d.ts +2 -2
- package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.js +11 -5
- package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.js +29 -27
- package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.module.css +0 -6
- package/dist/FormSteps/@Construction/CBRPropertyStep/CBRPropertyStep.js +39 -31
- package/dist/FormSteps/AYFStepMapper.js +42 -43
- package/dist/FormSteps/ApiSelectorStep/ApiSelectorStep.d.ts +1 -1
- package/dist/FormSteps/ApiSelectorStep/ApiSelectorStep.js +4 -14
- package/dist/FormSteps/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.js +84 -97
- package/dist/FormSteps/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.module.css +0 -9
- package/dist/FormSteps/CBRStepMapper.js +78 -74
- package/dist/FormSteps/CheckBoxStep/CheckBoxStep.d.ts +1 -1
- package/dist/FormSteps/CheckBoxStep/CheckBoxStep.js +4 -14
- package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.js +33 -26
- package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.module.css +17 -0
- package/dist/FormSteps/ClassifierSelectorStep/ClassifierSelectorStep.d.ts +1 -1
- package/dist/FormSteps/ClassifierSelectorStep/ClassifierSelectorStep.js +4 -14
- package/dist/FormSteps/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +34 -27
- package/dist/FormSteps/CollapsibleStep/CollapsibleStep.d.ts +1 -1
- package/dist/FormSteps/CollapsibleStep/CollapsibleStep.js +4 -2
- package/dist/FormSteps/CollapsibleStep/MaterialTitleStep/MaterialCollapsibleStep.js +16 -11
- package/dist/FormSteps/CustomStep.d.ts +23 -0
- package/dist/FormSteps/CustomStep.js +37 -0
- package/dist/FormSteps/DatePickerStep/DatePickerStep.js +3 -1
- package/dist/FormSteps/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.d.ts +1 -1
- package/dist/FormSteps/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.js +26 -14
- package/dist/FormSteps/EntityValueStep/EntityValuePickerStep.d.ts +1 -1
- package/dist/FormSteps/EntityValueStep/EntityValuePickerStep.js +4 -14
- package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +93 -112
- package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.module.css +0 -9
- package/dist/FormSteps/FileUploadStep/FileUploadStep.js +3 -1
- package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.d.ts +1 -1
- package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.js +1 -1
- package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.module.css +0 -7
- package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.js +32 -18
- package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.module.css +0 -7
- package/dist/FormSteps/MapperStep/MapperStep.d.ts +2 -2
- package/dist/FormSteps/MapperStep/MapperStep.js +4 -14
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/ListMapperElement/ListMapperElement.d.ts +1 -9
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/ListMapperElement/ListMapperElement.js +7 -2
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/MapperElement.d.ts +3 -2
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/MapperElement.js +18 -10
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/PillMapperElement/PillMapperElement.d.ts +1 -9
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/PillMapperElement/PillMapperElement.js +7 -2
- package/dist/FormSteps/MapperStep/MaterialMapperStep/MaterialMapperStep.d.ts +1 -1
- package/dist/FormSteps/MapperStep/MaterialMapperStep/MaterialMapperStep.js +44 -228
- package/dist/FormSteps/MapperStep/MaterialMapperStep/MaterialMapperStep.module.css +0 -7
- package/dist/FormSteps/RatingStep/MaterialRatingStep/MaterialRatingStep.js +30 -14
- package/dist/FormSteps/RatingStep/RatingStep.js +3 -1
- package/dist/FormSteps/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.js +36 -26
- package/dist/FormSteps/SelectorStep/SelectorStep.d.ts +1 -1
- package/dist/FormSteps/SelectorStep/SelectorStep.js +4 -14
- package/dist/FormSteps/SeparatorStep/MaterialSeparatorStep/MaterialSeparatorStep.d.ts +1 -1
- package/dist/FormSteps/SeparatorStep/MaterialSeparatorStep/MaterialSeparatorStep.js +3 -1
- package/dist/FormSteps/SeparatorStep/SeparatorStep.d.ts +1 -1
- package/dist/FormSteps/SeparatorStep/SeparatorStep.js +4 -14
- package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.d.ts +5 -2
- package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +119 -199
- package/dist/FormSteps/SmartSelectStep/SmartSelectStep.d.ts +9 -10
- package/dist/FormSteps/SmartSelectStep/SmartSelectStep.js +3 -1
- package/dist/FormSteps/Step.d.ts +3 -4
- package/dist/FormSteps/Step.js +12 -8
- package/dist/FormSteps/StepFunctions.d.ts +10 -0
- package/dist/FormSteps/StepFunctions.js +156 -1
- package/dist/FormSteps/StepHooks.d.ts +23 -0
- package/dist/FormSteps/StepHooks.js +87 -0
- package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaEditorStep.d.ts +10 -0
- package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaEditorStep.js +148 -0
- package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.d.ts +1 -6
- package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.js +40 -186
- package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.module.css +0 -9
- package/dist/FormSteps/TextAreaStep/TextAreaStep.js +8 -2
- package/dist/FormSteps/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.d.ts +1 -1
- package/dist/FormSteps/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.js +43 -42
- package/dist/FormSteps/TextInputStep/TextInputStep.js +3 -1
- package/dist/FormSteps/TitleStep/MaterialTitleStep/MaterialTitleStep.js +11 -6
- package/dist/FormSteps/TitleStep/TitleStep.d.ts +1 -1
- package/dist/FormSteps/TitleStep/TitleStep.js +4 -14
- package/dist/Icons/Construction/LeakIcon.d.ts +2 -2
- package/dist/Icons/Construction/LeakIcon.js +2 -1
- package/dist/Icons/Construction/ProjectIcon.d.ts +2 -2
- package/dist/Icons/Construction/ProjectIcon.js +2 -1
- package/dist/Icons/Construction/PropertyIcon.d.ts +2 -2
- package/dist/Icons/Construction/PropertyIcon.js +2 -1
- package/dist/Icons/Construction/SpaceIcon.d.ts +2 -2
- package/dist/Icons/Construction/SpaceIcon.js +2 -1
- package/dist/Icons/DocumentIcon.d.ts +2 -2
- package/dist/Icons/DocumentIcon.js +2 -1
- package/dist/Icons/Entities/CheckListIcon.d.ts +2 -2
- package/dist/Icons/Entities/CheckListIcon.js +2 -1
- package/dist/Icons/Entities/GenericEntityIcon.d.ts +2 -1
- package/dist/Icons/Entities/GenericEntityIcon.js +1 -1
- package/dist/Icons/Entities/HandshakeIcon.d.ts +2 -1
- package/dist/Icons/Entities/HandshakeIcon.js +1 -1
- package/dist/Icons/Entities/SupplierIcon.d.ts +2 -1
- package/dist/Icons/Entities/SupplierIcon.js +4 -1
- package/dist/{controllers → Services}/FileService.d.ts +1 -1
- package/dist/{controllers → Services}/FileService.js +5 -5
- package/dist/Services/FormService.d.ts +5 -0
- package/dist/Services/FormService.js +59 -0
- package/dist/Services/OrganizationService.d.ts +2 -0
- package/dist/Services/OrganizationService.js +65 -0
- package/dist/Shared/Navbar/Navbar.module.css +8 -0
- package/dist/{shared → Shared}/Rating/Rating.d.ts +1 -1
- package/dist/Shared/Rating/Rating.module.css +18 -0
- package/dist/{shared → Shared}/Rating/Ratings/LikeRating.js +5 -5
- package/dist/{shared → Shared}/Rating/Ratings/SatisfactionRating.js +9 -9
- package/dist/{shared → Shared}/Rating/Ratings/ScaleRating.js +1 -2
- package/dist/{shared → Shared}/RoundedCheckBox/RoundedCheckBox.d.ts +1 -1
- package/dist/{shared → Shared}/RoundedSmartSelect/RoundedSmartSelect.js +4 -4
- package/dist/{shared → Shared}/RoundedTextField/RoundedTextField.d.ts +1 -1
- package/dist/{shared → Shared}/RoundedTextField/RoundedTextField.js +3 -2
- package/dist/Shared/RoundedTextField/RoundedTextField.stories.d.ts +24 -0
- package/dist/Shared/RoundedTextField/RoundedTextField.stories.js +25 -0
- package/dist/States/GlobalStateReducer.d.ts +35 -0
- package/dist/States/GlobalStateReducer.js +34 -0
- package/dist/States/SiteStateReducer.d.ts +63 -0
- package/dist/States/SiteStateReducer.js +110 -0
- package/dist/States/WidthStatsStateReducer.d.ts +11 -0
- package/dist/States/WidthStatsStateReducer.js +64 -0
- package/dist/Utils/DraftFunctions.d.ts +3 -0
- package/dist/Utils/DraftFunctions.js +42 -0
- package/dist/Utils/MaterialProviders.d.ts +6 -0
- package/dist/Utils/MaterialProviders.js +31 -0
- package/dist/Utils/store.d.ts +25 -0
- package/dist/Utils/store.js +52 -0
- package/dist/Widget.js +3 -3
- package/dist/constants/CBRFormStepTypes.d.ts +2 -2
- package/dist/constants/CBRFormStepTypes.js +22 -22
- package/dist/hooks.d.ts +5 -0
- package/dist/hooks.js +7 -0
- package/dist/index.js +1 -1
- package/dist/index.lib.d.ts +1 -1
- package/dist/index.lib.js +1 -1
- package/package.json +63 -44
- package/dist/App.js +0 -472
- package/dist/shared/Navbar/Navbar.module.css +0 -18
- package/dist/shared/Rating/Rating.module.css +0 -32
- package/dist/{App.module.css → App/App.module.css} +0 -0
- package/dist/{shared → Shared}/InputIcon/InputIcon.d.ts +0 -0
- package/dist/{shared → Shared}/InputIcon/InputIcon.js +0 -0
- package/dist/{shared → Shared}/Loader/Loader.d.ts +0 -0
- package/dist/{shared → Shared}/Loader/Loader.js +0 -0
- package/dist/{shared → Shared}/Loader/Loader.module.css +0 -0
- package/dist/{shared → Shared}/Navbar/Navbar.d.ts +0 -0
- package/dist/{shared → Shared}/Navbar/Navbar.js +0 -0
- package/dist/{shared → Shared}/Rating/Rating.js +2 -2
- /package/dist/{shared → Shared}/Rating/Ratings/LikeRating.d.ts +0 -0
- /package/dist/{shared → Shared}/Rating/Ratings/SatisfactionRating.d.ts +0 -0
- /package/dist/{shared → Shared}/Rating/Ratings/ScaleRating.d.ts +0 -0
- /package/dist/{shared → Shared}/RoundedButton/RoundedButton.d.ts +0 -0
- /package/dist/{shared → Shared}/RoundedButton/RoundedButton.js +0 -0
- /package/dist/{shared → Shared}/RoundedCheckBox/RoundedCheckBox.js +0 -0
- /package/dist/{shared → Shared}/RoundedDatePicker/RoundedDatePicker.d.ts +0 -0
- /package/dist/{shared → Shared}/RoundedDatePicker/RoundedDatePicker.js +0 -0
- /package/dist/{shared → Shared}/RoundedSelect/RoundedSelect.d.ts +0 -0
- /package/dist/{shared → Shared}/RoundedSelect/RoundedSelect.js +0 -0
- /package/dist/{shared → Shared}/RoundedSmartSelect/RoundedSmartSelect.d.ts +0 -0
- /package/dist/{AxiosAPI.d.ts → Utils/AxiosAPI.d.ts} +0 -0
- /package/dist/{AxiosAPI.js → Utils/AxiosAPI.js} +0 -0
- /package/dist/{AxiosWidget.d.ts → Utils/AxiosWidget.d.ts} +0 -0
- /package/dist/{AxiosWidget.js → Utils/AxiosWidget.js} +0 -0
- /package/dist/{utils/CbrFunctions.d.ts → Utils/CBRFunctions.d.ts} +0 -0
- /package/dist/{utils/CbrFunctions.js → Utils/CBRFunctions.js} +0 -0
package/dist/@Types/Form.d.ts
CHANGED
|
@@ -94,7 +94,7 @@ interface NestedStepClassifierOption {
|
|
|
94
94
|
}
|
|
95
95
|
interface HideValueOption {
|
|
96
96
|
type: ClassifierOptionTypes.HIDE;
|
|
97
|
-
idClassifier:
|
|
97
|
+
idClassifier: string;
|
|
98
98
|
}
|
|
99
99
|
export interface EntityValuePicker extends GSteps.GSmartSelect {
|
|
100
100
|
type: Types.ENTITYVALUEPICKER;
|
|
@@ -113,7 +113,7 @@ interface NestedEntityValuePickerOption {
|
|
|
113
113
|
}
|
|
114
114
|
interface HideFormEntityValuePickerOption {
|
|
115
115
|
type: EntityValueOptionTypes.HIDE;
|
|
116
|
-
idEntityValue:
|
|
116
|
+
idEntityValue: string;
|
|
117
117
|
}
|
|
118
118
|
export type EntityValuePickerPath = StepEntityValuePickerPath | ValueEntityValuePickerPath;
|
|
119
119
|
export interface StepEntityValuePickerPath {
|
package/dist/App/App.css
ADDED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
import { Classifier, Form } from '
|
|
3
|
-
import
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Classifier, Form } from '../@Types/Form';
|
|
3
|
+
import './App.css';
|
|
4
|
+
import { FormComponentProps } from '../Form/Form';
|
|
5
|
+
import { CustomStep } from '../FormSteps/CustomStep';
|
|
4
6
|
export interface AppProps {
|
|
5
7
|
/** If the app is currently a widget */
|
|
6
8
|
isWidget?: boolean;
|
|
7
9
|
/** The apikey of the Form */
|
|
8
10
|
apiKey?: string;
|
|
9
|
-
/** The
|
|
10
|
-
|
|
11
|
+
/** The id of the form's organization */
|
|
12
|
+
idOrganization?: string;
|
|
11
13
|
/** The form to display, (used for postviews) */
|
|
12
14
|
formData?: Form;
|
|
13
15
|
/** If the widget is usedInternally */
|
|
@@ -27,27 +29,17 @@ export interface AppProps {
|
|
|
27
29
|
/** Custom steps to display */
|
|
28
30
|
customSteps?: Record<string, CustomStep>;
|
|
29
31
|
/** Custom steps to display */
|
|
30
|
-
customStepProps?: Record<string,
|
|
32
|
+
customStepProps?: Record<string, unknown>;
|
|
31
33
|
/** Classifiers dict */
|
|
32
34
|
classifiers?: Record<string, Classifier>;
|
|
33
35
|
/** Custom function to call on send */
|
|
34
|
-
|
|
36
|
+
customSubmit?: (values: Record<string, unknown>, reload: () => void) => Promise<void>;
|
|
35
37
|
/** Custom submit buttons */
|
|
36
|
-
|
|
38
|
+
customSubmitBtns?: (onSubmit: FormComponentProps['onSubmit'], loading: boolean) => JSX.Element;
|
|
37
39
|
/** Function to call on postview to fetch the download url of a file */
|
|
38
40
|
fetchDownloadUrl?: (S3Key: string, fileName: string) => Promise<string>;
|
|
39
41
|
/** Function to call after the confimation dialog has been closed */
|
|
40
|
-
handleConfirmed?:
|
|
42
|
+
handleConfirmed?: () => void;
|
|
41
43
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
component: ReactNode;
|
|
45
|
-
calcValue?: (step: any, value: any) => any;
|
|
46
|
-
/** Function to change custom steps nested step ids to the generated ones. */
|
|
47
|
-
calcRecursiveData?: (step: any, ids: Record<string, string>) => void;
|
|
48
|
-
calcDependencyValue?: (step: any, value: any) => any;
|
|
49
|
-
}
|
|
50
|
-
declare function App({ apiKey, domain, preview, partial, formData, postview, editable, isWidget, internal, valuesData, customSend, customSteps, classifiers, handleConfirmed, customStepProps, ...others }: AppProps): JSX.Element;
|
|
51
|
-
export default App;
|
|
52
|
-
export declare const addInitialMapper: (newValues: Record<string, any>, step: Mapper) => void;
|
|
53
|
-
export declare const mapOriginalValue: (step: FormStep, value: any, newValues: Record<string, any>, form?: Form) => any;
|
|
44
|
+
declare function AppComponent({ formData, valuesData, ...props }: AppProps): JSX.Element;
|
|
45
|
+
export default AppComponent;
|
package/dist/App/App.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
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 __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
+
import { useRef } from 'react';
|
|
25
|
+
import Loader from '../Shared/Loader/Loader';
|
|
26
|
+
import styles from './App.module.css';
|
|
27
|
+
import './App.css';
|
|
28
|
+
import FormComponent from '../Form/Form';
|
|
29
|
+
import { Provider } from 'react-redux';
|
|
30
|
+
import { store } from '../Utils/store';
|
|
31
|
+
import { useLogRocket, useSetupApp } from './AppHooks';
|
|
32
|
+
import { useAppSelector } from '../hooks';
|
|
33
|
+
import CustomContext from '../Contexts/CustomContext';
|
|
34
|
+
function AppComponent(_a) {
|
|
35
|
+
var formData = _a.formData, valuesData = _a.valuesData, props = __rest(_a, ["formData", "valuesData"]);
|
|
36
|
+
return (_jsx(Provider, __assign({ store: store }, { children: _jsx(App, __assign({ formData: formData, valuesData: valuesData }, props)) })));
|
|
37
|
+
}
|
|
38
|
+
export default AppComponent;
|
|
39
|
+
function App(_a) {
|
|
40
|
+
var _b, _c, _d, _e, _f, _g;
|
|
41
|
+
var _h = _a.isWidget, isWidget = _h === void 0 ? true : _h, props = __rest(_a, ["isWidget"]);
|
|
42
|
+
var containerRef = useRef(null);
|
|
43
|
+
var loaded = useAppSelector(function (state) { return state.global.loaded; });
|
|
44
|
+
var _j = useSetupApp(isWidget, props), form = _j.form, organization = _j.organization, branding = _j.branding, reload = _j.reload;
|
|
45
|
+
useLogRocket(organization, form, props);
|
|
46
|
+
var loading = form === undefined || organization === undefined || !loaded;
|
|
47
|
+
if (loading) {
|
|
48
|
+
if (isWidget) {
|
|
49
|
+
return (_jsx("div", __assign({ className: styles.widgetContainer }, { children: _jsx("div", __assign({ className: styles.curtain }, { children: _jsx(Loader, { size: 50, color: (_c = (_b = branding === null || branding === void 0 ? void 0 : branding.colors) === null || _b === void 0 ? void 0 : _b.primaryColor) !== null && _c !== void 0 ? _c : '#b8b8b8' }) })) })));
|
|
50
|
+
}
|
|
51
|
+
return (_jsx("div", __assign({ className: styles.curtain }, { children: _jsx(Loader, { size: 50, color: (_e = (_d = branding === null || branding === void 0 ? void 0 : branding.colors) === null || _d === void 0 ? void 0 : _d.primaryColor) !== null && _e !== void 0 ? _e : '#b8b8b8' }) })));
|
|
52
|
+
}
|
|
53
|
+
else if (form === null) {
|
|
54
|
+
if (organization === null) {
|
|
55
|
+
if (isWidget) {
|
|
56
|
+
return (_jsx("div", __assign({ className: styles.widgetContainer }, { children: _jsx("div", __assign({ className: styles.curtain }, { children: "Error" })) })));
|
|
57
|
+
}
|
|
58
|
+
return _jsx("div", __assign({ className: styles.curtain }, { children: "Error" }));
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
if (isWidget) {
|
|
62
|
+
return (_jsx("div", __assign({ className: styles.widgetContainer }, { children: _jsx("div", __assign({ className: styles.curtain }, { children: "404" })) })));
|
|
63
|
+
}
|
|
64
|
+
return _jsx("div", __assign({ className: styles.curtain }, { children: "404" }));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
var customSteps = (_f = props.customSteps) !== null && _f !== void 0 ? _f : {};
|
|
69
|
+
return (_jsx(CustomContext.Provider, __assign({ value: {
|
|
70
|
+
customSteps: customSteps,
|
|
71
|
+
sendLabel: props.sendLabel,
|
|
72
|
+
fetchDownloadUrl: props.fetchDownloadUrl,
|
|
73
|
+
customStepProps: (_g = props.customStepProps) !== null && _g !== void 0 ? _g : {},
|
|
74
|
+
} }, { children: _jsx("div", __assign({ className: styles.container }, { children: _jsx(FormComponent, { form: form, reload: reload, branding: branding, apiKey: props.apiKey, isWidget: !!isWidget, customSteps: customSteps, containerRef: containerRef, customSubmit: props.customSubmit, customSubmitBtns: props.customSubmitBtns }) })) })));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Form } from '../@Types';
|
|
2
|
+
import { FormStep, Mapper } from '../@Types/FormStep';
|
|
3
|
+
import { MapperElement } from '../FormSteps/MapperStep/MaterialMapperStep/MaterialMapperStep';
|
|
4
|
+
import { SiteState, ValuesStore } from '../States/SiteStateReducer';
|
|
5
|
+
import { DependencyStore } from '../Form/Form';
|
|
6
|
+
import { CustomStep } from '../FormSteps/CustomStep';
|
|
7
|
+
export declare const calcValuesStore: (originalValues: Record<string, any>, form: Form, dependencies: DependencyStore, customSteps: Record<string, CustomStep>) => ValuesStore;
|
|
8
|
+
export declare const addMapperStep: <Type>(step: Mapper, customSteps: Record<string, CustomStep>) => {
|
|
9
|
+
element: MapperElement<Type>;
|
|
10
|
+
/** Record of all the new mapper values created */
|
|
11
|
+
mappers: Record<string, MapperElement<Type>[]>;
|
|
12
|
+
/** Record of all the new steps created */
|
|
13
|
+
steps: Record<string, FormStep>;
|
|
14
|
+
};
|
|
15
|
+
export declare function calcRecursiveData<Type>(element: Readonly<MapperElement<Type>>, newSteps: Record<string, FormStep>, customSteps: Record<string, CustomStep>): void;
|
|
16
|
+
export declare const calcInitialSections: (form: Form) => Pick<SiteState, 'previousSections' | 'idCurrentSection' | 'nextSections'>;
|
|
@@ -0,0 +1,210 @@
|
|
|
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 { nanoid } from 'nanoid';
|
|
13
|
+
import StepTypes, { FormTypes } from '../constants/FormStepTypes';
|
|
14
|
+
import { EditorState, convertFromRaw } from 'draft-js';
|
|
15
|
+
import { getRawText, stringToDraft } from '../Utils/DraftFunctions';
|
|
16
|
+
import { calcDependencies } from '../Form/FormFunctions';
|
|
17
|
+
import { calcSubSteps } from '../FormSteps/StepFunctions';
|
|
18
|
+
export var calcValuesStore = function (originalValues, form, dependencies, customSteps) {
|
|
19
|
+
var _a;
|
|
20
|
+
var _b;
|
|
21
|
+
var values = {
|
|
22
|
+
global: {},
|
|
23
|
+
sections: {},
|
|
24
|
+
};
|
|
25
|
+
for (var _i = 0, _c = Object.keys(originalValues); _i < _c.length; _i++) {
|
|
26
|
+
var idValue = _c[_i];
|
|
27
|
+
var step = form.steps[idValue];
|
|
28
|
+
if (step) {
|
|
29
|
+
var value = mapOriginalValue(step, originalValues[step.id], values, form);
|
|
30
|
+
if (value !== undefined) {
|
|
31
|
+
if (!values.sections[step.idSection])
|
|
32
|
+
values.sections[step.idSection] = {};
|
|
33
|
+
values.sections[step.idSection][step.id] = value;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
values.global[idValue] = originalValues[idValue];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
for (var _d = 0, _e = Object.values(form.steps); _d < _e.length; _d++) {
|
|
41
|
+
var step = _e[_d];
|
|
42
|
+
if (step.type !== StepTypes.MAPPER ||
|
|
43
|
+
((_b = values.sections[step.idSection]) === null || _b === void 0 ? void 0 : _b[step.id]) ||
|
|
44
|
+
!step.required)
|
|
45
|
+
continue;
|
|
46
|
+
if (!values.sections[step.idSection])
|
|
47
|
+
values.sections[step.idSection] = {};
|
|
48
|
+
var _f = addMapperStep(step, customSteps), element = _f.element, steps = _f.steps, mappers = _f.mappers;
|
|
49
|
+
values.sections[step.idSection] = __assign(__assign(__assign({}, values.sections[step.idSection]), mappers), (_a = {}, _a[step.id] = [element], _a));
|
|
50
|
+
calcDependencies(steps, {}, customSteps, __assign(__assign({}, form.steps), steps), dependencies);
|
|
51
|
+
}
|
|
52
|
+
return values;
|
|
53
|
+
};
|
|
54
|
+
export var addMapperStep = function (step, customSteps) {
|
|
55
|
+
var idElement = nanoid();
|
|
56
|
+
var element = {
|
|
57
|
+
ids: {},
|
|
58
|
+
id: idElement,
|
|
59
|
+
originalValues: {},
|
|
60
|
+
isOriginal: false,
|
|
61
|
+
};
|
|
62
|
+
var steps = {};
|
|
63
|
+
var mappers = {};
|
|
64
|
+
for (var _i = 0, _a = Object.keys(step.steps); _i < _a.length; _i++) {
|
|
65
|
+
var idStep = _a[_i];
|
|
66
|
+
var baseStep = JSON.parse(JSON.stringify(step.steps[idStep]));
|
|
67
|
+
var newIdStep = step.id + '-' + idStep + '-' + idElement;
|
|
68
|
+
baseStep.id = newIdStep;
|
|
69
|
+
element.ids[idStep] = newIdStep;
|
|
70
|
+
steps[newIdStep] = baseStep;
|
|
71
|
+
}
|
|
72
|
+
calcRecursiveData(element, steps, customSteps);
|
|
73
|
+
for (var _b = 0, _c = Object.values(steps); _b < _c.length; _b++) {
|
|
74
|
+
var nestedStep = _c[_b];
|
|
75
|
+
if (nestedStep.type === StepTypes.MAPPER && nestedStep.required) {
|
|
76
|
+
var nested = addMapperStep(nestedStep, customSteps);
|
|
77
|
+
steps = __assign(__assign({}, steps), nested.steps);
|
|
78
|
+
mappers = __assign(__assign({}, mappers), nested.mappers);
|
|
79
|
+
mappers[nestedStep.id] = [nested.element];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return { element: element, mappers: mappers, steps: steps };
|
|
83
|
+
};
|
|
84
|
+
export function calcRecursiveData(element, newSteps, customSteps) {
|
|
85
|
+
if (!newSteps)
|
|
86
|
+
return;
|
|
87
|
+
for (var _i = 0, _a = Object.keys(newSteps); _i < _a.length; _i++) {
|
|
88
|
+
var idStep = _a[_i];
|
|
89
|
+
var step = newSteps[idStep];
|
|
90
|
+
if (step.dependencies) {
|
|
91
|
+
for (var i = 0; i < step.dependencies.length; i++) {
|
|
92
|
+
var idDep = step.dependencies[i];
|
|
93
|
+
var newId = element.ids[idDep];
|
|
94
|
+
if (newId) {
|
|
95
|
+
step.dependencies[i] = newId;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
var custom = customSteps[step === null || step === void 0 ? void 0 : step.type];
|
|
100
|
+
if (custom === null || custom === void 0 ? void 0 : custom.calcRecursiveData) {
|
|
101
|
+
custom.calcRecursiveData(step, element.ids);
|
|
102
|
+
}
|
|
103
|
+
calcSubSteps(step, function (idStep) { var _a; return (_a = element.ids[idStep]) !== null && _a !== void 0 ? _a : idStep; });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
var mapOriginalValue = function (step, value, values, form) {
|
|
107
|
+
var _a, _b, _c, _d, _e, _f;
|
|
108
|
+
if (!value)
|
|
109
|
+
return value;
|
|
110
|
+
switch (step === null || step === void 0 ? void 0 : step.type) {
|
|
111
|
+
case StepTypes.MAPPER: {
|
|
112
|
+
var elements = value;
|
|
113
|
+
var mappedElements = [];
|
|
114
|
+
for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) {
|
|
115
|
+
var element = elements_1[_i];
|
|
116
|
+
var idElement = (_a = element.id) !== null && _a !== void 0 ? _a : nanoid();
|
|
117
|
+
var mappedElement = {
|
|
118
|
+
id: idElement,
|
|
119
|
+
ids: {},
|
|
120
|
+
originalValues: {},
|
|
121
|
+
isOriginal: true,
|
|
122
|
+
};
|
|
123
|
+
if (element.value) {
|
|
124
|
+
mappedElement.value = element.value;
|
|
125
|
+
}
|
|
126
|
+
for (var _g = 0, _h = Object.keys(step.steps); _g < _h.length; _g++) {
|
|
127
|
+
var idStep = _h[_g];
|
|
128
|
+
var newIdStep = step.id + '-' + idStep + '-' + idElement;
|
|
129
|
+
mappedElement.ids[idStep] = newIdStep;
|
|
130
|
+
var value_1 = mapOriginalValue(step.steps[idStep], element[idStep], values, form);
|
|
131
|
+
if (value_1 !== undefined) {
|
|
132
|
+
if (!values.sections[step.idSection])
|
|
133
|
+
values.sections[step.idSection] = {};
|
|
134
|
+
values.sections[step.idSection][step.id] = value_1;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
for (var _j = 0, _k = Object.keys(element); _j < _k.length; _j++) {
|
|
138
|
+
var key = _k[_j];
|
|
139
|
+
if (step.steps[key])
|
|
140
|
+
continue;
|
|
141
|
+
mappedElement.originalValues[key] = element[key];
|
|
142
|
+
}
|
|
143
|
+
mappedElements.push(mappedElement);
|
|
144
|
+
}
|
|
145
|
+
return mappedElements;
|
|
146
|
+
}
|
|
147
|
+
case StepTypes.TEXTAREA: {
|
|
148
|
+
if (step.hasTextEditor) {
|
|
149
|
+
return calcDefaultDraftValue(value);
|
|
150
|
+
}
|
|
151
|
+
var defaultValue = (_b = value.value) !== null && _b !== void 0 ? _b : value;
|
|
152
|
+
if (typeof defaultValue === 'string') {
|
|
153
|
+
return defaultValue;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
return (_c = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.text) !== null && _c !== void 0 ? _c : '';
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
case StepTypes.SELECTOR: {
|
|
160
|
+
var option = step.options.find(function (option) { return option.value == value; });
|
|
161
|
+
if (!(value === null || value === void 0 ? void 0 : value.value))
|
|
162
|
+
return option;
|
|
163
|
+
return value;
|
|
164
|
+
}
|
|
165
|
+
case StepTypes.CLASSIFIER_SELECTOR: {
|
|
166
|
+
var stepClassifier = (_d = form === null || form === void 0 ? void 0 : form.classifiers) === null || _d === void 0 ? void 0 : _d[(_e = step.idClassifier) !== null && _e !== void 0 ? _e : ''];
|
|
167
|
+
if (stepClassifier) {
|
|
168
|
+
var classifier = (_f = form.classifiers) === null || _f === void 0 ? void 0 : _f[value];
|
|
169
|
+
if (!(value === null || value === void 0 ? void 0 : value.value))
|
|
170
|
+
return { value: value, label: classifier === null || classifier === void 0 ? void 0 : classifier.name };
|
|
171
|
+
}
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
default:
|
|
175
|
+
if (step.type.startsWith('CBR_') &&
|
|
176
|
+
(value === null || value === void 0 ? void 0 : value.id) &&
|
|
177
|
+
typeof value.id === 'number') {
|
|
178
|
+
return __assign(__assign({}, value), { id: value.id.toString() });
|
|
179
|
+
}
|
|
180
|
+
return value;
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
var calcDefaultDraftValue = function (defaultValue) {
|
|
184
|
+
if (typeof defaultValue === 'string') {
|
|
185
|
+
return EditorState.createWithContent(convertFromRaw(stringToDraft(defaultValue)));
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
return EditorState.createWithContent(convertFromRaw(getRawText(defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.draft, defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.text)));
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
export var calcInitialSections = function (form) {
|
|
192
|
+
var previousSections = [];
|
|
193
|
+
var nextSections = calcNextSections(form.firstSection, form);
|
|
194
|
+
var idCurrentSection = null;
|
|
195
|
+
if (form.type === FormTypes.STEPPER) {
|
|
196
|
+
var firstSection = nextSections.shift();
|
|
197
|
+
if (firstSection)
|
|
198
|
+
idCurrentSection = firstSection;
|
|
199
|
+
}
|
|
200
|
+
return { previousSections: previousSections, idCurrentSection: idCurrentSection, nextSections: nextSections };
|
|
201
|
+
};
|
|
202
|
+
var calcNextSections = function (idSection, form) {
|
|
203
|
+
var section = form.sections[idSection];
|
|
204
|
+
if (!section)
|
|
205
|
+
return [];
|
|
206
|
+
var sections = [idSection];
|
|
207
|
+
if (section.nextSection)
|
|
208
|
+
sections.push.apply(sections, calcNextSections(section.nextSection, form));
|
|
209
|
+
return sections;
|
|
210
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Form, Organization } from '../@Types';
|
|
2
|
+
import { AppProps } from './App';
|
|
3
|
+
import { Branding } from '../@Types/Branding';
|
|
4
|
+
export declare const useSetupApp: (isEmbedded: boolean, { preview, internal, postview, partial, editable, handleConfirmed, customSteps, valuesData, apiKey, formData, classifiers, ...others }: Omit<AppProps, 'isWidget'>) => {
|
|
5
|
+
form: Form | undefined | null;
|
|
6
|
+
organization: Organization | undefined | null;
|
|
7
|
+
branding: Branding | undefined;
|
|
8
|
+
reload: () => void;
|
|
9
|
+
};
|
|
10
|
+
export declare const useLogRocket: (organization: Organization | null | undefined, form: Form | null | undefined, { apiKey, internal, postview, preview, }: Pick<AppProps, 'apiKey' | 'internal' | 'postview' | 'preview'>) => void;
|
|
@@ -0,0 +1,235 @@
|
|
|
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 (g && (g = 0, op[0] && (_ = 0)), _) 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
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
60
|
+
import { reset } from '../States/GlobalStateReducer';
|
|
61
|
+
import { fetchOrganization } from '../Services/OrganizationService';
|
|
62
|
+
import { fetchForm } from '../Services/FormService';
|
|
63
|
+
import { calcCbrForm } from '../Utils/CBRFunctions';
|
|
64
|
+
import { calcInitialSections, calcValuesStore } from './AppFunctions';
|
|
65
|
+
import { useAppDispatch } from '../hooks';
|
|
66
|
+
import InternalFormStyle from '../constants/InternalFormStyle';
|
|
67
|
+
import { calcDependencies } from '../Form/FormFunctions';
|
|
68
|
+
import { iterateNestedSteps } from '../FormSteps/StepFunctions';
|
|
69
|
+
export var useSetupApp = function (isEmbedded, _a) {
|
|
70
|
+
var preview = _a.preview, internal = _a.internal, postview = _a.postview, partial = _a.partial, editable = _a.editable, handleConfirmed = _a.handleConfirmed, customSteps = _a.customSteps, valuesData = _a.valuesData, apiKey = _a.apiKey, formData = _a.formData, classifiers = _a.classifiers, others = __rest(_a, ["preview", "internal", "postview", "partial", "editable", "handleConfirmed", "customSteps", "valuesData", "apiKey", "formData", "classifiers"]);
|
|
71
|
+
var _b = useState(undefined), form = _b[0], setForm = _b[1];
|
|
72
|
+
var _c = useState(undefined), organization = _c[0], setOrganization = _c[1];
|
|
73
|
+
var _d = useState(), branding = _d[0], setBranding = _d[1];
|
|
74
|
+
var dispatch = useAppDispatch();
|
|
75
|
+
var loadOrg = function (idOrganization) { return __awaiter(void 0, void 0, void 0, function () {
|
|
76
|
+
var organization;
|
|
77
|
+
return __generator(this, function (_a) {
|
|
78
|
+
switch (_a.label) {
|
|
79
|
+
case 0: return [4 /*yield*/, fetchOrganization(idOrganization)];
|
|
80
|
+
case 1:
|
|
81
|
+
organization = _a.sent();
|
|
82
|
+
if (organization) {
|
|
83
|
+
if (!isEmbedded) {
|
|
84
|
+
// document.title = currentOrg.name;
|
|
85
|
+
// const favicon: any = document.getElementById('favicon');
|
|
86
|
+
// if (favicon !== undefined) {
|
|
87
|
+
// favicon.href = currentOrg.partialLogoUrl;
|
|
88
|
+
// }
|
|
89
|
+
//TODO cambiar el color del navbar en movil
|
|
90
|
+
// eslint-disable-next-line no-console
|
|
91
|
+
}
|
|
92
|
+
if (!organization.customBrandings) {
|
|
93
|
+
setBranding(organization.branding);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return [2 /*return*/, organization];
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}); };
|
|
100
|
+
var loadForm = function (apiKey, idOrganization) { return __awaiter(void 0, void 0, void 0, function () {
|
|
101
|
+
var form;
|
|
102
|
+
return __generator(this, function (_a) {
|
|
103
|
+
switch (_a.label) {
|
|
104
|
+
case 0: return [4 /*yield*/, fetchForm(apiKey, idOrganization)];
|
|
105
|
+
case 1:
|
|
106
|
+
form = _a.sent();
|
|
107
|
+
if (form && form.branding)
|
|
108
|
+
setBranding(form.branding);
|
|
109
|
+
return [2 /*return*/, form];
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}); };
|
|
113
|
+
var loadData = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
114
|
+
var idOrganization, organization, form, match, _loop_1, _i, _a, section, CBRStep, dependencies, values;
|
|
115
|
+
var _b;
|
|
116
|
+
var _c;
|
|
117
|
+
return __generator(this, function (_d) {
|
|
118
|
+
switch (_d.label) {
|
|
119
|
+
case 0:
|
|
120
|
+
idOrganization = others.idOrganization;
|
|
121
|
+
organization = null;
|
|
122
|
+
form = formData !== null && formData !== void 0 ? formData : null;
|
|
123
|
+
if (!(form && preview && form.isStandAlone)) return [3 /*break*/, 2];
|
|
124
|
+
return [4 /*yield*/, loadOrg()];
|
|
125
|
+
case 1:
|
|
126
|
+
organization = _d.sent();
|
|
127
|
+
return [3 /*break*/, 4];
|
|
128
|
+
case 2:
|
|
129
|
+
if (!(!form && apiKey)) return [3 /*break*/, 4];
|
|
130
|
+
return [4 /*yield*/, Promise.all([
|
|
131
|
+
loadOrg(idOrganization),
|
|
132
|
+
loadForm(apiKey, idOrganization),
|
|
133
|
+
])];
|
|
134
|
+
case 3:
|
|
135
|
+
//Is iframe or widget
|
|
136
|
+
_b = _d.sent(), organization = _b[0], form = _b[1];
|
|
137
|
+
_d.label = 4;
|
|
138
|
+
case 4:
|
|
139
|
+
if (organization && !idOrganization)
|
|
140
|
+
idOrganization = organization.idOrganization;
|
|
141
|
+
setOrganization(organization);
|
|
142
|
+
/** For localhost development */
|
|
143
|
+
if (!idOrganization && process.env.NODE_ENV !== 'production') {
|
|
144
|
+
match = location.origin.match(/\/\/(.*?)\./);
|
|
145
|
+
idOrganization = match ? match[1] : '';
|
|
146
|
+
}
|
|
147
|
+
if (form) {
|
|
148
|
+
if (form)
|
|
149
|
+
form.classifiers = classifiers;
|
|
150
|
+
_loop_1 = function (section) {
|
|
151
|
+
for (var _e = 0, _f = section.steps; _e < _f.length; _e++) {
|
|
152
|
+
var idStep = _f[_e];
|
|
153
|
+
iterateNestedSteps(idStep, form.steps, function (step) {
|
|
154
|
+
step.idSection = section.id;
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
/** Assign the idSection to all the forms steps */
|
|
159
|
+
for (_i = 0, _a = Object.values(form.sections); _i < _a.length; _i++) {
|
|
160
|
+
section = _a[_i];
|
|
161
|
+
_loop_1(section);
|
|
162
|
+
}
|
|
163
|
+
CBRStep = Object.values(form.steps).find(function (step) { return step.type.startsWith('CBR'); });
|
|
164
|
+
if (CBRStep)
|
|
165
|
+
form = calcCbrForm(form, valuesData !== null && valuesData !== void 0 ? valuesData : {});
|
|
166
|
+
}
|
|
167
|
+
setForm(form);
|
|
168
|
+
if (!form || !idOrganization)
|
|
169
|
+
return [2 /*return*/];
|
|
170
|
+
dependencies = {};
|
|
171
|
+
values = calcValuesStore(valuesData !== null && valuesData !== void 0 ? valuesData : {}, form, dependencies, customSteps !== null && customSteps !== void 0 ? customSteps : {});
|
|
172
|
+
dispatch(reset(__assign(__assign({ formStyle: internal
|
|
173
|
+
? InternalFormStyle
|
|
174
|
+
: __assign(__assign({}, InternalFormStyle), ((_c = form === null || form === void 0 ? void 0 : form.style) !== null && _c !== void 0 ? _c : {})), internal: !!internal, idOrganization: idOrganization, preview: !!preview, partial: !!partial, postview: !!postview, editable: !!(editable !== null && editable !== void 0 ? editable : true), values: values }, calcInitialSections(form)), { dependencies: calcDependencies(form.steps, valuesData, customSteps, form.steps, dependencies) })));
|
|
175
|
+
return [2 /*return*/];
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}); };
|
|
179
|
+
useEffect(function () {
|
|
180
|
+
loadData();
|
|
181
|
+
}, []);
|
|
182
|
+
var reload = useCallback(function () {
|
|
183
|
+
if (!form)
|
|
184
|
+
return;
|
|
185
|
+
var tempForm = __assign({}, form);
|
|
186
|
+
setForm(undefined);
|
|
187
|
+
setTimeout(function () {
|
|
188
|
+
setForm(tempForm);
|
|
189
|
+
}, 100);
|
|
190
|
+
if (handleConfirmed) {
|
|
191
|
+
handleConfirmed();
|
|
192
|
+
}
|
|
193
|
+
}, [form]);
|
|
194
|
+
return { form: form, organization: organization, branding: branding, reload: reload };
|
|
195
|
+
};
|
|
196
|
+
export var useLogRocket = function (organization, form, _a) {
|
|
197
|
+
var apiKey = _a.apiKey, internal = _a.internal, postview = _a.postview, preview = _a.preview;
|
|
198
|
+
var loadLogRocket = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
199
|
+
var LogRocket, error_1;
|
|
200
|
+
return __generator(this, function (_a) {
|
|
201
|
+
switch (_a.label) {
|
|
202
|
+
case 0:
|
|
203
|
+
if (!(form &&
|
|
204
|
+
organization &&
|
|
205
|
+
process.env.NODE_ENV === 'production' &&
|
|
206
|
+
//Tools
|
|
207
|
+
// apiKey !== 'rCgWiEfOSN1TlUmHO28Y0' &&
|
|
208
|
+
!internal &&
|
|
209
|
+
!postview &&
|
|
210
|
+
!preview)) return [3 /*break*/, 4];
|
|
211
|
+
_a.label = 1;
|
|
212
|
+
case 1:
|
|
213
|
+
_a.trys.push([1, 3, , 4]);
|
|
214
|
+
return [4 /*yield*/, import('logrocket')];
|
|
215
|
+
case 2:
|
|
216
|
+
LogRocket = _a.sent();
|
|
217
|
+
LogRocket.default.init('63mg8a/forms-uv0gd');
|
|
218
|
+
LogRocket.default.identify(organization.idOrganization + '/' + apiKey, {
|
|
219
|
+
name: organization.name +
|
|
220
|
+
'/' +
|
|
221
|
+
((form === null || form === void 0 ? void 0 : form.name) ? form === null || form === void 0 ? void 0 : form.name : '404'),
|
|
222
|
+
});
|
|
223
|
+
return [3 /*break*/, 4];
|
|
224
|
+
case 3:
|
|
225
|
+
error_1 = _a.sent();
|
|
226
|
+
console.error('LogRocker Error', error_1);
|
|
227
|
+
return [3 /*break*/, 4];
|
|
228
|
+
case 4: return [2 /*return*/];
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
}); };
|
|
232
|
+
useEffect(function () {
|
|
233
|
+
loadLogRocket();
|
|
234
|
+
}, [organization, form]);
|
|
235
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CustomStep } from '../FormSteps/CustomStep';
|
|
3
|
+
export interface CustomContextData {
|
|
4
|
+
sendLabel?: string;
|
|
5
|
+
customStepProps: Record<string, unknown>;
|
|
6
|
+
customSteps: Record<string, CustomStep>;
|
|
7
|
+
/** Function to call on postview to fetch the download url of a file */
|
|
8
|
+
fetchDownloadUrl?: (S3Key: string, fileName: string) => Promise<string>;
|
|
9
|
+
}
|
|
10
|
+
declare const CustomContext: import("react").Context<CustomContextData>;
|
|
11
|
+
export default CustomContext;
|