dynamic-mui 1.0.44 → 1.0.45
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.
|
@@ -7,7 +7,7 @@ exports.FormData = exports.ClearFormData = void 0;
|
|
|
7
7
|
exports.FormGenerator = FormGenerator;
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _propTypes =
|
|
10
|
+
var _propTypes = _interopRequireWildcard(require("prop-types"));
|
|
11
11
|
var _Grid = _interopRequireDefault(require("@mui/material/Grid"));
|
|
12
12
|
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
13
13
|
var _mui = _interopRequireDefault(require("../config/mui"));
|
|
@@ -46,7 +46,8 @@ function FormGenerator(_ref) {
|
|
|
46
46
|
onStepChange,
|
|
47
47
|
MuiGridAttributes = {
|
|
48
48
|
spacing: 2
|
|
49
|
-
}
|
|
49
|
+
},
|
|
50
|
+
activeStep = 0
|
|
50
51
|
} = _ref;
|
|
51
52
|
const [newPatch, setNewPatch] = (0, _react.useState)(patch);
|
|
52
53
|
const config = LIBMap.MUI;
|
|
@@ -79,9 +80,9 @@ function FormGenerator(_ref) {
|
|
|
79
80
|
submitCallback(response, null, formData, formGuid);
|
|
80
81
|
}
|
|
81
82
|
}, []);
|
|
82
|
-
const onStepUpdate = (
|
|
83
|
+
const onStepUpdate = (currentStep, isScreenChange, isLastStep) => {
|
|
83
84
|
if (typeof onStepChange === 'function') {
|
|
84
|
-
onStepChange(
|
|
85
|
+
onStepChange(currentStep, isScreenChange, isLastStep);
|
|
85
86
|
}
|
|
86
87
|
};
|
|
87
88
|
const renderDynamicComponent = (field, index) => {
|
|
@@ -112,7 +113,8 @@ function FormGenerator(_ref) {
|
|
|
112
113
|
attributes: cProps,
|
|
113
114
|
rules: rules,
|
|
114
115
|
onChange: onUpdate,
|
|
115
|
-
onStepUpdate: onStepUpdate
|
|
116
|
+
onStepUpdate: onStepUpdate,
|
|
117
|
+
currentStep: activeStep
|
|
116
118
|
}));
|
|
117
119
|
};
|
|
118
120
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Grid.default, _extends({
|
|
@@ -150,7 +152,9 @@ FormGenerator.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
150
152
|
/** Component On Change Function */
|
|
151
153
|
onStepChange: _propTypes.default.func,
|
|
152
154
|
/** Grid Container Attributes */
|
|
153
|
-
MuiGridAttributes: _propTypes.default.objectOf(_propTypes.default.object)
|
|
155
|
+
MuiGridAttributes: _propTypes.default.objectOf(_propTypes.default.object),
|
|
156
|
+
/** Stepper Active Step */
|
|
157
|
+
activeStep: _propTypes.number
|
|
154
158
|
} : {};
|
|
155
159
|
FormGenerator.defaultProps = {
|
|
156
160
|
patch: {},
|
|
@@ -160,7 +164,8 @@ FormGenerator.defaultProps = {
|
|
|
160
164
|
onStepChange: null,
|
|
161
165
|
MuiGridAttributes: {
|
|
162
166
|
spacing: 2
|
|
163
|
-
}
|
|
167
|
+
},
|
|
168
|
+
activeStep: 0
|
|
164
169
|
};
|
|
165
170
|
var _default = exports.default = {
|
|
166
171
|
FormGenerator,
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = Stepper;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _propTypes =
|
|
8
|
+
var _propTypes = _interopRequireWildcard(require("prop-types"));
|
|
9
9
|
var _Box = _interopRequireDefault(require("@mui/material/Box"));
|
|
10
10
|
var _Stepper = _interopRequireDefault(require("@mui/material/Stepper"));
|
|
11
11
|
var _Step = _interopRequireDefault(require("@mui/material/Step"));
|
|
@@ -25,6 +25,11 @@ const initialState = {
|
|
|
25
25
|
};
|
|
26
26
|
function reducer(state, action) {
|
|
27
27
|
switch (action.type) {
|
|
28
|
+
case 'PATCH_STEP':
|
|
29
|
+
return {
|
|
30
|
+
...state,
|
|
31
|
+
activeStep: action.currentStep
|
|
32
|
+
};
|
|
28
33
|
case 'NEXT_STEP':
|
|
29
34
|
return {
|
|
30
35
|
...state,
|
|
@@ -56,10 +61,12 @@ function Stepper(_ref) {
|
|
|
56
61
|
let {
|
|
57
62
|
attributes,
|
|
58
63
|
onChange,
|
|
59
|
-
onStepUpdate
|
|
64
|
+
onStepUpdate,
|
|
65
|
+
currentStep
|
|
60
66
|
} = _ref;
|
|
61
67
|
const [state, dispatch] = (0, _react.useReducer)(reducer, {
|
|
62
68
|
...initialState,
|
|
69
|
+
activeStep: currentStep,
|
|
63
70
|
stepperResponse: {
|
|
64
71
|
[attributes.id]: attributes.value
|
|
65
72
|
}
|
|
@@ -68,6 +75,12 @@ function Stepper(_ref) {
|
|
|
68
75
|
activeStep,
|
|
69
76
|
stepperResponse
|
|
70
77
|
} = state;
|
|
78
|
+
(0, _react.useEffect)(() => {
|
|
79
|
+
dispatch({
|
|
80
|
+
type: 'PATCH_STEP',
|
|
81
|
+
currentStep
|
|
82
|
+
});
|
|
83
|
+
}, [currentStep]);
|
|
71
84
|
const handleStepChange = (stepChange, isScreenChange, isLastStep) => {
|
|
72
85
|
dispatch({
|
|
73
86
|
type: stepChange
|
|
@@ -141,10 +154,13 @@ Stepper.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
141
154
|
/** Function */
|
|
142
155
|
onChange: _propTypes.default.func,
|
|
143
156
|
/** Function */
|
|
144
|
-
onStepUpdate: _propTypes.default.func
|
|
157
|
+
onStepUpdate: _propTypes.default.func,
|
|
158
|
+
/** Default Spet */
|
|
159
|
+
currentStep: _propTypes.number
|
|
145
160
|
} : {};
|
|
146
161
|
Stepper.defaultProps = {
|
|
147
162
|
attributes: {},
|
|
148
163
|
onChange: null,
|
|
149
|
-
onStepUpdate: null
|
|
164
|
+
onStepUpdate: null,
|
|
165
|
+
currentStep: 0
|
|
150
166
|
};
|
|
@@ -167,8 +167,16 @@ const mui = exports.mui = [{
|
|
|
167
167
|
MuiStepContentAttributes: {},
|
|
168
168
|
MuiButtonAttributes: {
|
|
169
169
|
back: {},
|
|
170
|
-
next: {
|
|
171
|
-
|
|
170
|
+
next: {
|
|
171
|
+
sx: {
|
|
172
|
+
bgcolor: 'primary.dark'
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
final: {
|
|
176
|
+
sx: {
|
|
177
|
+
bgcolor: 'success.light'
|
|
178
|
+
}
|
|
179
|
+
},
|
|
172
180
|
backLabel: '',
|
|
173
181
|
nextLabel: '',
|
|
174
182
|
finalLabel: ''
|