@arquimedes.co/eureka-forms 2.0.1-test → 2.0.3-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/README +4 -0
- package/dist/@Types/MapperElement.d.ts +8 -0
- package/dist/@Types/MapperElement.js +1 -0
- package/dist/App/AppFunctions.d.ts +1 -1
- package/dist/FormSteps/CustomStep.d.ts +3 -2
- package/dist/FormSteps/CustomStep.js +2 -3
- package/dist/FormSteps/MapperStep/MapperStep.d.ts +1 -1
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/ListMapperElement/ListMapperElement.d.ts +1 -1
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/{MapperElement.d.ts → MapperElementComponent.d.ts} +1 -1
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/PillMapperElement/PillMapperElement.d.ts +1 -1
- package/dist/FormSteps/MapperStep/MaterialMapperStep/MaterialMapperStep.d.ts +2 -9
- package/dist/FormSteps/MapperStep/MaterialMapperStep/MaterialMapperStep.js +23 -22
- package/dist/setupTests.d.ts +1 -0
- package/dist/setupTests.js +5 -0
- package/package.json +33 -35
- /package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/{MapperElement.js → MapperElementComponent.js} +0 -0
package/README
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Form } from '../@Types';
|
|
2
2
|
import { FormStep, Mapper } from '../@Types/FormStep';
|
|
3
|
-
import { MapperElement } from '../FormSteps/MapperStep/MaterialMapperStep/MaterialMapperStep';
|
|
4
3
|
import { SiteState, ValuesStore } from '../States/SiteStateReducer';
|
|
5
4
|
import { DependencyStore } from '../Form/Form';
|
|
6
5
|
import { CustomStep } from '../FormSteps/CustomStep';
|
|
6
|
+
import { MapperElement } from '../@Types/MapperElement';
|
|
7
7
|
export declare const calcValuesStore: (originalValues: Record<string, any>, form: Form, dependencies: DependencyStore, customSteps: Record<string, CustomStep>) => ValuesStore;
|
|
8
8
|
export declare const addMapperStep: <Type>(step: Mapper, customSteps: Record<string, CustomStep>) => {
|
|
9
9
|
element: MapperElement<Type>;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { UseFormReturn } from 'react-hook-form';
|
|
3
2
|
import { StepProps } from './Step';
|
|
4
3
|
import { Form } from '../@Types';
|
|
5
4
|
import { GlobalState } from '../States/GlobalStateReducer';
|
|
6
|
-
|
|
5
|
+
import { WidthStats } from '../Form/Form';
|
|
6
|
+
export interface CustomStepProps extends StepProps, GlobalState {
|
|
7
7
|
form: Form;
|
|
8
8
|
customStepProps: Record<string, any>;
|
|
9
|
+
widthStats: WidthStats;
|
|
9
10
|
}
|
|
10
11
|
export interface CustomStep {
|
|
11
12
|
componentProps?: Record<string, any>;
|
|
@@ -20,7 +20,6 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
}
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
|
-
import { useFormContext } from 'react-hook-form';
|
|
24
23
|
import FormContext from '../Contexts/FormContext';
|
|
25
24
|
import { useAppSelector } from '../hooks';
|
|
26
25
|
import CustomStepPropsContext from '../Contexts/CustomContext';
|
|
@@ -31,7 +30,7 @@ function CustomStepComponent(_a) {
|
|
|
31
30
|
var form = useContext(FormContext);
|
|
32
31
|
var global = useAppSelector(function (state) { return state.global; });
|
|
33
32
|
var customStepProps = useContext(CustomStepPropsContext);
|
|
34
|
-
var
|
|
35
|
-
return customStep.component(__assign(__assign(__assign(__assign(
|
|
33
|
+
var widthStats = useAppSelector(function (state) { return state.widthStats; });
|
|
34
|
+
return customStep.component(__assign(__assign(__assign(__assign({}, props), { widthStats: widthStats, form: form, customStepProps: customStepProps }), global), ((_b = customStep.componentProps) !== null && _b !== void 0 ? _b : {})));
|
|
36
35
|
}
|
|
37
36
|
export default CustomStepComponent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Mapper } from '../../@Types/FormStep';
|
|
3
|
-
import { MapperElement } from './MaterialMapperStep/MaterialMapperStep';
|
|
4
3
|
import { StepProps } from '../Step';
|
|
4
|
+
import { MapperElement } from '../../@Types/MapperElement';
|
|
5
5
|
interface CustomMapperElementModifiers<Type> {
|
|
6
6
|
calcName?: (element: MapperElement<Type>) => string;
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { MapperStepProps } from '../../../MapperStep';
|
|
3
|
-
import { MapperElementComponentProps } from '../
|
|
3
|
+
import { MapperElementComponentProps } from '../MapperElementComponent';
|
|
4
4
|
declare function ListMapperElement<Type = any>({ step, num, loading, element, children, editable, handleDelete, customElementModifiers, }: MapperStepProps<Type> & MapperElementComponentProps<Type>): JSX.Element;
|
|
5
5
|
export default ListMapperElement;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MapperStepProps } from '../../MapperStep';
|
|
2
|
-
import { MapperElement } from '../MaterialMapperStep';
|
|
3
2
|
import React from 'react';
|
|
3
|
+
import { MapperElement } from '../../../../@Types/MapperElement';
|
|
4
4
|
export interface MapperElementComponentProps<Type> {
|
|
5
5
|
num: number;
|
|
6
6
|
loading: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { MapperStepProps } from '../../../MapperStep';
|
|
3
|
-
import { MapperElementComponentProps } from '../
|
|
3
|
+
import { MapperElementComponentProps } from '../MapperElementComponent';
|
|
4
4
|
declare function PillMapperElement<Type = any>({ step, num, loading, element, children, editable, handleDelete, customElementModifiers, customElementRender, }: MapperStepProps<Type> & MapperElementComponentProps<Type>): JSX.Element;
|
|
5
5
|
export default PillMapperElement;
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { MapperStepProps } from '../MapperStep';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
ids: Record<string, string>;
|
|
6
|
-
deleted?: boolean;
|
|
7
|
-
value?: Type;
|
|
8
|
-
originalValues: Record<string, any>;
|
|
9
|
-
isOriginal: boolean;
|
|
10
|
-
}
|
|
11
|
-
export declare function ElementsComponent<Type = any>({ step, inputRef, editable, elements, customAdd, loading, ...others }: MapperStepProps<Type> & {
|
|
3
|
+
import { MapperElement } from '../../../@Types/MapperElement';
|
|
4
|
+
export declare function ElementsComponent<Type = any>({ step, inputRef, editable, elements, customAdd, loading, onChange, ...others }: MapperStepProps<Type> & {
|
|
12
5
|
loading?: boolean;
|
|
13
6
|
onChange: (elements: MapperElement<Type>[]) => void;
|
|
14
7
|
elements: MapperElement<Type>[];
|
|
@@ -31,12 +31,12 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
31
31
|
};
|
|
32
32
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
33
33
|
import { createElement as _createElement } from "react";
|
|
34
|
-
import React, { useState, useEffect, useContext, useMemo } from 'react';
|
|
34
|
+
import React, { useState, useEffect, useContext, useMemo, useCallback, } from 'react';
|
|
35
35
|
import styles from './MaterialMapperStep.module.css';
|
|
36
36
|
import { Controller, useFormContext } from 'react-hook-form';
|
|
37
37
|
import { MapperStyleTypes } from '../../../constants/FormStepTypes';
|
|
38
38
|
import RoundedButton from '../../../Shared/RoundedButton/RoundedButton';
|
|
39
|
-
import MapperElementComponent from './Element/
|
|
39
|
+
import MapperElementComponent from './Element/MapperElementComponent';
|
|
40
40
|
import { addStepsDependencies } from '../../../States/SiteStateReducer';
|
|
41
41
|
import FormContext from '../../../Contexts/FormContext';
|
|
42
42
|
import { useAppDispatch, useAppSelector } from '../../../hooks';
|
|
@@ -44,7 +44,7 @@ import CustomContext from '../../../Contexts/CustomContext';
|
|
|
44
44
|
import { useStepDependency } from '../../StepHooks';
|
|
45
45
|
import { addMapperStep, calcRecursiveData } from '../../../App/AppFunctions';
|
|
46
46
|
export function ElementsComponent(_a) {
|
|
47
|
-
var step = _a.step, inputRef = _a.inputRef, editable = _a.editable, elements = _a.elements, customAdd = _a.customAdd, _b = _a.loading, loading = _b === void 0 ? false : _b, others = __rest(_a, ["step", "inputRef", "editable", "elements", "customAdd", "loading"]);
|
|
47
|
+
var step = _a.step, inputRef = _a.inputRef, editable = _a.editable, elements = _a.elements, customAdd = _a.customAdd, _b = _a.loading, loading = _b === void 0 ? false : _b, onChange = _a.onChange, others = __rest(_a, ["step", "inputRef", "editable", "elements", "customAdd", "loading", "onChange"]);
|
|
48
48
|
var form = useContext(FormContext);
|
|
49
49
|
var _c = useAppSelector(function (state) { return state.global; }), formStyle = _c.formStyle, postview = _c.postview;
|
|
50
50
|
var customSteps = useContext(CustomContext).customSteps;
|
|
@@ -70,18 +70,13 @@ export function ElementsComponent(_a) {
|
|
|
70
70
|
}
|
|
71
71
|
return newSteps;
|
|
72
72
|
})()), localSteps = _e[0], setLocalSteps = _e[1];
|
|
73
|
-
var onChange = function (elements) {
|
|
74
|
-
if (customAdd)
|
|
75
|
-
handleStepDep(elements.map(function (element) { return element.value; }));
|
|
76
|
-
others.onChange(elements);
|
|
77
|
-
};
|
|
78
73
|
useEffect(function () {
|
|
79
74
|
if (elements.length === 0 && !postview && editable && step.creatable) {
|
|
80
75
|
if (!customAdd)
|
|
81
76
|
handleAddElement();
|
|
82
77
|
}
|
|
83
78
|
}, []);
|
|
84
|
-
var handleAddElement = function (value) {
|
|
79
|
+
var handleAddElement = useCallback(function (value) {
|
|
85
80
|
var _a = addMapperStep(step, customSteps), element = _a.element, steps = _a.steps, mappers = _a.mappers;
|
|
86
81
|
if (value)
|
|
87
82
|
element.value = value;
|
|
@@ -89,11 +84,23 @@ export function ElementsComponent(_a) {
|
|
|
89
84
|
var _c = _b[_i], key = _c[0], elems = _c[1];
|
|
90
85
|
setValue(key, elems);
|
|
91
86
|
}
|
|
92
|
-
|
|
87
|
+
var newElements = __spreadArray(__spreadArray([], elements, true), [element], false);
|
|
88
|
+
if (customAdd)
|
|
89
|
+
handleStepDep(newElements.map(function (element) { return element.value; }));
|
|
90
|
+
onChange(newElements);
|
|
93
91
|
setLocalSteps(__assign(__assign({}, localSteps), steps));
|
|
94
92
|
dispatch(addStepsDependencies({ steps: steps, customSteps: customSteps }));
|
|
95
|
-
};
|
|
96
|
-
var
|
|
93
|
+
}, [step, customSteps, elements]);
|
|
94
|
+
var handleDeleteElement = useCallback(function (index) { return function () {
|
|
95
|
+
var tempElements = __spreadArray([], elements, true);
|
|
96
|
+
tempElements[index] = __assign(__assign({}, tempElements[index]), { deleted: true });
|
|
97
|
+
if (customAdd)
|
|
98
|
+
handleStepDep(tempElements.map(function (element) { return element.value; }));
|
|
99
|
+
onChange(tempElements);
|
|
100
|
+
}; }, [elements, onChange]);
|
|
101
|
+
var subForm = useMemo(function () { return (__assign(__assign({}, form), { steps: __assign(__assign({}, form.steps), localSteps) })); }, [localSteps]);
|
|
102
|
+
var value = useMemo(function () { return JSON.stringify(elements); }, [elements]);
|
|
103
|
+
var container = useMemo(function () {
|
|
97
104
|
var _a;
|
|
98
105
|
switch ((_a = step.style) === null || _a === void 0 ? void 0 : _a.type) {
|
|
99
106
|
case MapperStyleTypes.LIST:
|
|
@@ -102,23 +109,17 @@ export function ElementsComponent(_a) {
|
|
|
102
109
|
default:
|
|
103
110
|
return { container: styles.pillContainer };
|
|
104
111
|
}
|
|
105
|
-
};
|
|
106
|
-
var subForm = useMemo(function () { return (__assign(__assign({}, form), { steps: __assign(__assign({}, form.steps), localSteps) })); }, [localSteps]);
|
|
107
|
-
var container = calcStyles().container;
|
|
112
|
+
}, [step]).container;
|
|
108
113
|
var mapElements = function () {
|
|
109
|
-
return (_jsx(FormContext.Provider, __assign({ value: subForm }, { children: elements.map(function (element, index) { return (_createElement(MapperElementComponent, __assign({}, others, { key: element.id, num: index, loading: loading, element: element, step: step, editable: editable, handleDelete:
|
|
110
|
-
var tempElements = __spreadArray([], elements, true);
|
|
111
|
-
tempElements[index] = __assign(__assign({}, tempElements[index]), { deleted: true });
|
|
112
|
-
onChange(tempElements);
|
|
113
|
-
} }))); }) })));
|
|
114
|
+
return (_jsx(FormContext.Provider, __assign({ value: subForm }, { children: elements.map(function (element, index) { return (_createElement(MapperElementComponent, __assign({}, others, { key: element.id, num: index, loading: loading, element: element, step: step, editable: editable, handleDelete: handleDeleteElement(index) }))); }) })));
|
|
114
115
|
};
|
|
115
116
|
if (step.style.type === MapperStyleTypes.INLINE)
|
|
116
117
|
return _jsx(React.Fragment, { children: mapElements() });
|
|
117
|
-
return (_jsxs("div", __assign({ className: container, style: { color: formStyle.textColor } }, { children: [step.label && _jsx("div", __assign({ className: styles.titleLbl }, { children: step.label })), step.description && (_jsx("p", __assign({ className: styles.descriptionPar, style: {
|
|
118
|
+
return (_jsxs("div", __assign({ className: container, style: { color: formStyle.textColor }, "data-testid": step.id }, { children: [step.label && _jsx("div", __assign({ className: styles.titleLbl }, { children: step.label })), step.description && (_jsx("p", __assign({ className: styles.descriptionPar, style: {
|
|
118
119
|
margin: step.description
|
|
119
120
|
? '10px 0px'
|
|
120
121
|
: '0px 0px 5px 0px',
|
|
121
|
-
} }, { children: step.description }))), mapElements(), _jsx("input", { ref: inputRef, className: 'hidden-input' }), step.creatable !== false && (_jsxs("div", __assign({ className: styles.btnContainer }, { children: [!customAdd && (_jsx(RoundedButton, { disabled: !editable || postview, text: step.addBtnLabel + (step.required ? ' *' : ''), color: formStyle.primaryContrastColor, backgroundColor: formStyle.primaryColor, fontSize: '1rem', padding: '5px 15px 5px 15px', onClick: function () {
|
|
122
|
+
} }, { children: step.description }))), mapElements(), _jsx("input", { id: step.id, ref: inputRef, className: 'hidden-input', readOnly: true, value: value }), step.creatable !== false && (_jsxs("div", __assign({ className: styles.btnContainer }, { children: [!customAdd && (_jsx(RoundedButton, { disabled: !editable || postview, text: step.addBtnLabel + (step.required ? ' *' : ''), color: formStyle.primaryContrastColor, backgroundColor: formStyle.primaryColor, fontSize: '1rem', padding: '5px 15px 5px 15px', onClick: function () {
|
|
122
123
|
if (editable && !postview) {
|
|
123
124
|
handleAddElement();
|
|
124
125
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
package/package.json
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arquimedes.co/eureka-forms",
|
|
3
3
|
"repository": "git://github.com/Arquimede5/Eureka-Forms.git",
|
|
4
|
-
"version":"2.0.
|
|
4
|
+
"version":"2.0.3-test",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "react-scripts start",
|
|
7
7
|
"build": "react-scripts build",
|
|
8
8
|
"lint": "eslint 'src/**/*.ts'",
|
|
9
|
-
"test": "
|
|
10
|
-
"test-ci": "
|
|
11
|
-
"tsc-build": "tsc --noEmit false --outDir ./dist",
|
|
12
|
-
"
|
|
9
|
+
"test": "react-scripts test",
|
|
10
|
+
"test-ci": "react-scripts test --reporters=default --reporters=jest-junit --coverage",
|
|
11
|
+
"tsc-build": "tsc --noEmit false --outDir ./dist --incremental false",
|
|
12
|
+
"watch": "tsc --build -w --preserveWatchOutput",
|
|
13
|
+
"storybook": "storybook dev -p 6006",
|
|
14
|
+
"build-storybook": "storybook build",
|
|
15
|
+
"cypress": "DISPLAY=:0 cypress open"
|
|
13
16
|
},
|
|
14
17
|
"dependencies": {
|
|
15
18
|
"@date-io/date-fns": "^2.17.0",
|
|
@@ -18,12 +21,15 @@
|
|
|
18
21
|
"@material-ui/lab": "4.0.0-alpha.61",
|
|
19
22
|
"@material-ui/pickers": "^3.3.11",
|
|
20
23
|
"@reduxjs/toolkit": "^1.9.7",
|
|
21
|
-
"axios": "^1.6.
|
|
22
|
-
"date-fns": "^2.30.
|
|
23
|
-
"draft-js": "^0.11.
|
|
24
|
+
"axios": "^1.6.2",
|
|
25
|
+
"date-fns": "^2.30.0",
|
|
26
|
+
"draft-js": "^0.11.7",
|
|
27
|
+
"logrocket": "^2.2.1",
|
|
24
28
|
"nanoid": "^3.3.7",
|
|
25
|
-
"react-draft-wysiwyg": "^1.15.
|
|
29
|
+
"react-draft-wysiwyg": "^1.15.0",
|
|
26
30
|
"react-google-recaptcha": "^3.1.0",
|
|
31
|
+
"react-hook-form": "^7.48.2",
|
|
32
|
+
"react-redux": "^8.1.3",
|
|
27
33
|
"typescript": "^4.9.5"
|
|
28
34
|
},
|
|
29
35
|
"eslintConfig": {
|
|
@@ -45,17 +51,21 @@
|
|
|
45
51
|
]
|
|
46
52
|
},
|
|
47
53
|
"devDependencies": {
|
|
48
|
-
"@babel/
|
|
54
|
+
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
|
|
55
|
+
"@babel/preset-env": "^7.23.5",
|
|
56
|
+
"@babel/preset-react": "^7.23.3",
|
|
57
|
+
"@babel/preset-typescript": "^7.23.3",
|
|
58
|
+
"@faker-js/faker": "^8.3.1",
|
|
49
59
|
"@storybook/addon-coverage": "^1.0.0",
|
|
50
|
-
"@storybook/addon-essentials": "^7.6.
|
|
51
|
-
"@storybook/addon-interactions": "^7.6.
|
|
52
|
-
"@storybook/addon-links": "^7.6.
|
|
60
|
+
"@storybook/addon-essentials": "^7.6.4",
|
|
61
|
+
"@storybook/addon-interactions": "^7.6.4",
|
|
62
|
+
"@storybook/addon-links": "^7.6.4",
|
|
53
63
|
"@storybook/addon-onboarding": "^1.0.9",
|
|
54
|
-
"@storybook/addon-themes": "^7.6.
|
|
55
|
-
"@storybook/blocks": "^7.6.
|
|
56
|
-
"@storybook/react": "^7.6.
|
|
57
|
-
"@storybook/react-webpack5": "^7.6.
|
|
58
|
-
"@storybook/test": "^7.6.
|
|
64
|
+
"@storybook/addon-themes": "^7.6.4",
|
|
65
|
+
"@storybook/blocks": "^7.6.4",
|
|
66
|
+
"@storybook/react": "^7.6.4",
|
|
67
|
+
"@storybook/react-webpack5": "^7.6.4",
|
|
68
|
+
"@storybook/test": "^7.6.4",
|
|
59
69
|
"@testing-library/dom": "^9.3.3",
|
|
60
70
|
"@testing-library/jest-dom": "^6.1.5",
|
|
61
71
|
"@testing-library/react": "^12.1.5",
|
|
@@ -69,8 +79,7 @@
|
|
|
69
79
|
"@typescript-eslint/eslint-plugin": "^6.13.1",
|
|
70
80
|
"@typescript-eslint/parser": "^6.13.1",
|
|
71
81
|
"chromatic": "^10.0.0",
|
|
72
|
-
"
|
|
73
|
-
"cypress": "^13.6.0",
|
|
82
|
+
"cypress": "^13.6.1",
|
|
74
83
|
"dotenv-webpack": "^8.0.1",
|
|
75
84
|
"eslint": "^8.55.0",
|
|
76
85
|
"eslint-config-prettier": "^9.1.0",
|
|
@@ -80,26 +89,15 @@
|
|
|
80
89
|
"jest": "^29.7.0",
|
|
81
90
|
"jest-environment-jsdom": "^29.7.0",
|
|
82
91
|
"jest-junit": "^16.0.0",
|
|
83
|
-
"postcss-normalize": "^10.0.1",
|
|
84
92
|
"prettier": "^3.1.0",
|
|
85
|
-
"react": "^
|
|
86
|
-
"react-dom": "^17.0.2",
|
|
93
|
+
"react-refresh": "^0.11.0",
|
|
87
94
|
"react-scripts": "5.0.1",
|
|
88
|
-
"storybook": "^7.6.
|
|
95
|
+
"storybook": "^7.6.4",
|
|
89
96
|
"ts-jest": "^29.1.1"
|
|
90
97
|
},
|
|
91
98
|
"peerDependencies": {
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"date-fns": "^2.30.x",
|
|
95
|
-
"draft-js": "^0.11.x",
|
|
96
|
-
"logrocket": "^2.x.x",
|
|
97
|
-
"react": "^17.0.2",
|
|
98
|
-
"react-dom": "^17.x.x",
|
|
99
|
-
"react-draft-wysiwyg": "^1.15.x",
|
|
100
|
-
"react-hook-form": "^7.48.2",
|
|
101
|
-
"@reduxjs/toolkit": "^1.9.7",
|
|
102
|
-
"react-redux": "^8.1.3"
|
|
99
|
+
"react": "^17.x.x",
|
|
100
|
+
"react-dom": "^17.x.x"
|
|
103
101
|
},
|
|
104
102
|
"publishConfig": {
|
|
105
103
|
"access": "public"
|
|
File without changes
|