dynamic-mui 1.0.44 → 1.0.46
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,9 @@ function FormGenerator(_ref) {
|
|
|
112
113
|
attributes: cProps,
|
|
113
114
|
rules: rules,
|
|
114
115
|
onChange: onUpdate,
|
|
115
|
-
onStepUpdate: onStepUpdate
|
|
116
|
+
onStepUpdate: onStepUpdate,
|
|
117
|
+
currentStep: activeStep,
|
|
118
|
+
patch: patch
|
|
116
119
|
}));
|
|
117
120
|
};
|
|
118
121
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Grid.default, _extends({
|
|
@@ -150,7 +153,9 @@ FormGenerator.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
150
153
|
/** Component On Change Function */
|
|
151
154
|
onStepChange: _propTypes.default.func,
|
|
152
155
|
/** Grid Container Attributes */
|
|
153
|
-
MuiGridAttributes: _propTypes.default.objectOf(_propTypes.default.object)
|
|
156
|
+
MuiGridAttributes: _propTypes.default.objectOf(_propTypes.default.object),
|
|
157
|
+
/** Stepper Active Step */
|
|
158
|
+
activeStep: _propTypes.number
|
|
154
159
|
} : {};
|
|
155
160
|
FormGenerator.defaultProps = {
|
|
156
161
|
patch: {},
|
|
@@ -160,7 +165,8 @@ FormGenerator.defaultProps = {
|
|
|
160
165
|
onStepChange: null,
|
|
161
166
|
MuiGridAttributes: {
|
|
162
167
|
spacing: 2
|
|
163
|
-
}
|
|
168
|
+
},
|
|
169
|
+
activeStep: 0
|
|
164
170
|
};
|
|
165
171
|
var _default = exports.default = {
|
|
166
172
|
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,
|
|
@@ -41,10 +46,7 @@ function reducer(state, action) {
|
|
|
41
46
|
...state,
|
|
42
47
|
stepperResponse: {
|
|
43
48
|
...state.stepperResponse,
|
|
44
|
-
[action.
|
|
45
|
-
...state.stepperResponse[action.guid],
|
|
46
|
-
[action.id]: action.value
|
|
47
|
-
}
|
|
49
|
+
[action.id]: action.value
|
|
48
50
|
}
|
|
49
51
|
};
|
|
50
52
|
}
|
|
@@ -52,22 +54,39 @@ function reducer(state, action) {
|
|
|
52
54
|
return state;
|
|
53
55
|
}
|
|
54
56
|
}
|
|
57
|
+
const response = {};
|
|
55
58
|
function Stepper(_ref) {
|
|
56
59
|
let {
|
|
57
60
|
attributes,
|
|
58
61
|
onChange,
|
|
59
|
-
onStepUpdate
|
|
62
|
+
onStepUpdate,
|
|
63
|
+
currentStep,
|
|
64
|
+
patch
|
|
60
65
|
} = _ref;
|
|
61
66
|
const [state, dispatch] = (0, _react.useReducer)(reducer, {
|
|
62
67
|
...initialState,
|
|
68
|
+
activeStep: currentStep,
|
|
63
69
|
stepperResponse: {
|
|
64
|
-
|
|
70
|
+
...patch
|
|
65
71
|
}
|
|
66
72
|
});
|
|
67
73
|
const {
|
|
68
74
|
activeStep,
|
|
69
75
|
stepperResponse
|
|
70
76
|
} = state;
|
|
77
|
+
(0, _react.useEffect)(() => {
|
|
78
|
+
response[attributes.id] = {
|
|
79
|
+
...patch
|
|
80
|
+
};
|
|
81
|
+
// eslint-disable-next-line no-return-assign
|
|
82
|
+
return () => response[attributes.id] = {};
|
|
83
|
+
}, [patch]);
|
|
84
|
+
(0, _react.useEffect)(() => {
|
|
85
|
+
dispatch({
|
|
86
|
+
type: 'PATCH_STEP',
|
|
87
|
+
currentStep
|
|
88
|
+
});
|
|
89
|
+
}, [currentStep]);
|
|
71
90
|
const handleStepChange = (stepChange, isScreenChange, isLastStep) => {
|
|
72
91
|
dispatch({
|
|
73
92
|
type: stepChange
|
|
@@ -76,7 +95,7 @@ function Stepper(_ref) {
|
|
|
76
95
|
if (isLastStep) {
|
|
77
96
|
onChange === null || onChange === void 0 || onChange({
|
|
78
97
|
id: attributes.id,
|
|
79
|
-
value:
|
|
98
|
+
value: response
|
|
80
99
|
});
|
|
81
100
|
}
|
|
82
101
|
};
|
|
@@ -85,9 +104,9 @@ function Stepper(_ref) {
|
|
|
85
104
|
id,
|
|
86
105
|
value
|
|
87
106
|
} = _ref2;
|
|
107
|
+
response[attributes.id][id] = value;
|
|
88
108
|
dispatch({
|
|
89
109
|
type: 'UPDATE_RESPONSE',
|
|
90
|
-
guid: attributes.id,
|
|
91
110
|
id,
|
|
92
111
|
value
|
|
93
112
|
});
|
|
@@ -132,7 +151,7 @@ function Stepper(_ref) {
|
|
|
132
151
|
}, attributes.MuiStepLabelOptionalLabel || 'Last step')
|
|
133
152
|
}, attributes.MuiStepLabelAttributes), step.label), /*#__PURE__*/_react.default.createElement(_StepContent.default, attributes.MuiStepContentAttributes, step.components ? /*#__PURE__*/_react.default.createElement(_stepperComponents.default, {
|
|
134
153
|
onUpdate: handleUpdate,
|
|
135
|
-
components: (0, _helper.updatePatchData)(step.components, stepperResponse
|
|
154
|
+
components: (0, _helper.updatePatchData)(step.components, stepperResponse, attributes.id, response)
|
|
136
155
|
}) : /*#__PURE__*/_react.default.createElement(_Typography.default, null, step.description), renderStepButtons(index, step.isScreenChange))))));
|
|
137
156
|
}
|
|
138
157
|
Stepper.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
@@ -141,10 +160,16 @@ Stepper.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
141
160
|
/** Function */
|
|
142
161
|
onChange: _propTypes.default.func,
|
|
143
162
|
/** Function */
|
|
144
|
-
onStepUpdate: _propTypes.default.func
|
|
163
|
+
onStepUpdate: _propTypes.default.func,
|
|
164
|
+
/** Default Step */
|
|
165
|
+
currentStep: _propTypes.number,
|
|
166
|
+
/** Default Patch */
|
|
167
|
+
patch: _propTypes.default.objectOf(_propTypes.default.object)
|
|
145
168
|
} : {};
|
|
146
169
|
Stepper.defaultProps = {
|
|
147
170
|
attributes: {},
|
|
148
171
|
onChange: null,
|
|
149
|
-
onStepUpdate: null
|
|
172
|
+
onStepUpdate: null,
|
|
173
|
+
currentStep: 0,
|
|
174
|
+
patch: {}
|
|
150
175
|
};
|
|
@@ -14,6 +14,7 @@ const mui = exports.mui = [{
|
|
|
14
14
|
orientation: 'horizontal',
|
|
15
15
|
MuiSteps: [{
|
|
16
16
|
label: 'Select Service Request',
|
|
17
|
+
mandatoryIds: ['servicetype'],
|
|
17
18
|
components: [{
|
|
18
19
|
type: 'select',
|
|
19
20
|
props: {
|
|
@@ -49,6 +50,7 @@ const mui = exports.mui = [{
|
|
|
49
50
|
}, {
|
|
50
51
|
label: 'Assign Priority',
|
|
51
52
|
isScreenChange: true,
|
|
53
|
+
mandatoryIds: ['priority'],
|
|
52
54
|
components: [{
|
|
53
55
|
type: 'select',
|
|
54
56
|
props: {
|
|
@@ -74,6 +76,7 @@ const mui = exports.mui = [{
|
|
|
74
76
|
}]
|
|
75
77
|
}, {
|
|
76
78
|
label: 'Choose Schedule In Calendar',
|
|
79
|
+
mandatoryIds: ['start', 'end'],
|
|
77
80
|
components: [{
|
|
78
81
|
id: 'start',
|
|
79
82
|
type: 'datetime',
|
|
@@ -106,6 +109,7 @@ const mui = exports.mui = [{
|
|
|
106
109
|
}]
|
|
107
110
|
}, {
|
|
108
111
|
label: 'Assign User',
|
|
112
|
+
mandatoryIds: ['assigntouser'],
|
|
109
113
|
components: [{
|
|
110
114
|
type: 'select',
|
|
111
115
|
props: {
|
|
@@ -167,8 +171,16 @@ const mui = exports.mui = [{
|
|
|
167
171
|
MuiStepContentAttributes: {},
|
|
168
172
|
MuiButtonAttributes: {
|
|
169
173
|
back: {},
|
|
170
|
-
next: {
|
|
171
|
-
|
|
174
|
+
next: {
|
|
175
|
+
sx: {
|
|
176
|
+
bgcolor: 'primary.dark'
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
final: {
|
|
180
|
+
sx: {
|
|
181
|
+
bgcolor: 'success.light'
|
|
182
|
+
}
|
|
183
|
+
},
|
|
172
184
|
backLabel: '',
|
|
173
185
|
nextLabel: '',
|
|
174
186
|
finalLabel: ''
|