dynamic-mui 1.0.70 → 1.0.72
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/build/asset-manifest.json +3 -3
- package/build/index.html +1 -1
- package/build/static/js/{main.c9bfd94c.js → main.9e08a04c.js} +3 -3
- package/build/static/js/{main.c9bfd94c.js.map → main.9e08a04c.js.map} +1 -1
- package/dist-modules/components/controls/Stepper/stepper.js +71 -105
- package/dist-modules/data/stepper.js +5 -0
- package/docs/asset-manifest.json +2 -2
- package/docs/build/{bundle.7bf57cc2.js → bundle.e8059e90.js} +3 -3
- package/docs/index.html +1 -1
- package/package.json +1 -1
- /package/build/static/js/{main.c9bfd94c.js.LICENSE.txt → main.9e08a04c.js.LICENSE.txt} +0 -0
- /package/docs/build/{bundle.7bf57cc2.js.LICENSE.txt → bundle.e8059e90.js.LICENSE.txt} +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _material = require("@mui/material");
|
|
@@ -13,43 +13,43 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
13
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
14
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
15
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } // eslint-disable-next-line import/no-cycle
|
|
16
|
+
// Initial State
|
|
16
17
|
const initialState = {
|
|
17
18
|
activeStep: 0,
|
|
18
19
|
stepperResponse: {},
|
|
19
20
|
MuiSteps: []
|
|
20
21
|
};
|
|
21
|
-
const response = {}; // Reintegrated response object
|
|
22
22
|
|
|
23
|
+
// Reducer Logic
|
|
23
24
|
const reducer = (state, action) => {
|
|
24
|
-
|
|
25
|
+
const {
|
|
26
|
+
type,
|
|
27
|
+
payload
|
|
28
|
+
} = action;
|
|
29
|
+
switch (type) {
|
|
25
30
|
case 'SET_STEPS':
|
|
26
31
|
return {
|
|
27
32
|
...state,
|
|
28
|
-
MuiSteps:
|
|
33
|
+
MuiSteps: payload.MuiSteps
|
|
29
34
|
};
|
|
30
35
|
case 'SET_STEP':
|
|
31
36
|
return {
|
|
32
37
|
...state,
|
|
33
|
-
activeStep:
|
|
34
|
-
};
|
|
35
|
-
case 'NEXT_STEP':
|
|
36
|
-
return {
|
|
37
|
-
...state,
|
|
38
|
-
activeStep: state.activeStep + 1
|
|
39
|
-
};
|
|
40
|
-
case 'PREVIOUS_STEP':
|
|
41
|
-
return {
|
|
42
|
-
...state,
|
|
43
|
-
activeStep: state.activeStep - 1
|
|
38
|
+
activeStep: payload.currentStep
|
|
44
39
|
};
|
|
45
40
|
case 'UPDATE_RESPONSE':
|
|
46
41
|
return {
|
|
47
42
|
...state,
|
|
48
43
|
stepperResponse: {
|
|
49
44
|
...state.stepperResponse,
|
|
50
|
-
[
|
|
45
|
+
[payload.id]: payload.value
|
|
51
46
|
}
|
|
52
47
|
};
|
|
48
|
+
case 'CHANGE_STEP':
|
|
49
|
+
return {
|
|
50
|
+
...state,
|
|
51
|
+
activeStep: state.activeStep + payload.stepChange
|
|
52
|
+
};
|
|
53
53
|
default:
|
|
54
54
|
return state;
|
|
55
55
|
}
|
|
@@ -62,37 +62,33 @@ function Stepper(_ref) {
|
|
|
62
62
|
currentStep,
|
|
63
63
|
patch
|
|
64
64
|
} = _ref;
|
|
65
|
-
const [state, dispatch] = (0, _react.useReducer)(reducer, initialState,
|
|
66
|
-
...init,
|
|
65
|
+
const [state, dispatch] = (0, _react.useReducer)(reducer, initialState, () => ({
|
|
67
66
|
activeStep: currentStep,
|
|
68
67
|
stepperResponse: patch,
|
|
69
|
-
MuiSteps:
|
|
68
|
+
MuiSteps: attributes.MuiSteps || []
|
|
70
69
|
}));
|
|
71
70
|
const {
|
|
72
71
|
activeStep,
|
|
73
72
|
stepperResponse,
|
|
74
73
|
MuiSteps
|
|
75
74
|
} = state;
|
|
76
|
-
(0, _react.useEffect)(() => {
|
|
77
|
-
response[attributes.id] = patch; // Update response on patch change
|
|
78
|
-
return () => {
|
|
79
|
-
response[attributes.id] = {}; // Cleanup response on component unmount
|
|
80
|
-
// eslint-disable-next-line no-console
|
|
81
|
-
// console.log('Component unmounted');
|
|
82
|
-
};
|
|
83
|
-
}, [patch, attributes.id]);
|
|
84
75
|
(0, _react.useEffect)(() => {
|
|
85
76
|
dispatch({
|
|
86
77
|
type: 'SET_STEP',
|
|
87
|
-
|
|
78
|
+
payload: {
|
|
79
|
+
currentStep
|
|
80
|
+
}
|
|
88
81
|
});
|
|
89
82
|
}, [currentStep]);
|
|
90
83
|
const handleStepChange = (0, _react.useCallback)((stepChange, isScreenChange, isLastStep) => {
|
|
91
84
|
dispatch({
|
|
92
|
-
type:
|
|
85
|
+
type: 'CHANGE_STEP',
|
|
86
|
+
payload: {
|
|
87
|
+
stepChange
|
|
88
|
+
}
|
|
93
89
|
});
|
|
94
|
-
const newStep = activeStep +
|
|
95
|
-
onStepUpdate?.(newStep, isScreenChange && stepChange
|
|
90
|
+
const newStep = activeStep + stepChange;
|
|
91
|
+
onStepUpdate?.(newStep, isScreenChange && stepChange > 0, isLastStep);
|
|
96
92
|
if (isLastStep) {
|
|
97
93
|
onChange?.({
|
|
98
94
|
id: attributes.id,
|
|
@@ -105,82 +101,45 @@ function Stepper(_ref) {
|
|
|
105
101
|
id,
|
|
106
102
|
value
|
|
107
103
|
} = _ref2;
|
|
108
|
-
response[attributes.id][id] = value;
|
|
109
104
|
dispatch({
|
|
110
105
|
type: 'UPDATE_RESPONSE',
|
|
111
|
-
|
|
112
|
-
|
|
106
|
+
payload: {
|
|
107
|
+
id,
|
|
108
|
+
value
|
|
109
|
+
}
|
|
113
110
|
});
|
|
114
111
|
onChange?.({
|
|
115
112
|
id,
|
|
116
113
|
value
|
|
117
114
|
});
|
|
118
|
-
// let updateUI = false;
|
|
119
|
-
// const newMuiSteps = MuiSteps.map((step) => {
|
|
120
|
-
// let newComponents = step.components || [];
|
|
121
|
-
// const fElement = newComponents?.find(
|
|
122
|
-
// (component) => component?.id === id || component?.props?.id === id,
|
|
123
|
-
// );
|
|
124
|
-
// if (fElement && fElement.onChangeUpdate) {
|
|
125
|
-
// fElement.onChangeUpdate.forEach(({ enableDisableConfig, patchId, replaceUiConfig }) => {
|
|
126
|
-
// if (enableDisableConfig) {
|
|
127
|
-
// let disableElement = newComponents.find(
|
|
128
|
-
// (k) => k.id === patchId || k?.props?.id === patchId,
|
|
129
|
-
// );
|
|
130
|
-
// if (disableElement && disableElement?.props?.MuiAttributes) {
|
|
131
|
-
// disableElement = {
|
|
132
|
-
// ...disableElement,
|
|
133
|
-
// props: {
|
|
134
|
-
// ...disableElement?.props,
|
|
135
|
-
// MuiAttributes: {
|
|
136
|
-
// ...disableElement?.props?.MuiAttributes,
|
|
137
|
-
// disabled: enableDisableConfig[value],
|
|
138
|
-
// },
|
|
139
|
-
// },
|
|
140
|
-
// };
|
|
141
|
-
// newComponents = newComponents.filter((k) => k?.props?.id !== patchId);
|
|
142
|
-
// newComponents.push(disableElement);
|
|
143
|
-
// updateUI = true;
|
|
144
|
-
// }
|
|
145
|
-
// }
|
|
146
|
-
// if (replaceUiConfig) {
|
|
147
|
-
// newComponents = newComponents.filter((k) => k?.props?.id !== patchId);
|
|
148
|
-
// newComponents.push(replaceUiConfig);
|
|
149
|
-
// updateUI = true;
|
|
150
|
-
// }
|
|
151
|
-
// });
|
|
152
|
-
// }
|
|
153
|
-
// return { ...step, components: newComponents };
|
|
154
|
-
// });
|
|
155
|
-
// if (updateUI) {
|
|
156
|
-
// dispatch({ type: 'SET_STEPS', MuiSteps: newMuiSteps });
|
|
157
|
-
// }
|
|
158
115
|
}, [onChange]);
|
|
159
|
-
const
|
|
160
|
-
let mandatoryIds = arguments.length >
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
mb: 2
|
|
164
|
-
}
|
|
165
|
-
}, /*#__PURE__*/_react.default.createElement(_material.Button, _extends({
|
|
166
|
-
variant: "contained",
|
|
167
|
-
onClick: () => handleStepChange('NEXT_STEP', isScreenChange, index === MuiSteps.length - 1),
|
|
168
|
-
disabled: mandatoryIds.some(id => !patch[id]),
|
|
169
|
-
sx: {
|
|
170
|
-
mt: 1,
|
|
171
|
-
mr: 1
|
|
172
|
-
}
|
|
173
|
-
}, attributes.MuiButtonAttributes.next, index === MuiSteps.length - 1 && {
|
|
174
|
-
...attributes.MuiButtonAttributes.final
|
|
175
|
-
}), index === MuiSteps.length - 1 ? 'Finish' : 'Continue'), /*#__PURE__*/_react.default.createElement(_material.Button, _extends({
|
|
176
|
-
disabled: index === 0,
|
|
177
|
-
onClick: () => handleStepChange('PREVIOUS_STEP', isScreenChange, false),
|
|
178
|
-
sx: {
|
|
179
|
-
mt: 1,
|
|
180
|
-
mr: 1
|
|
181
|
-
}
|
|
182
|
-
}, attributes.MuiButtonAttributes.back), "Back"));
|
|
116
|
+
const isDisabled = function () {
|
|
117
|
+
let mandatoryIds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
118
|
+
let optionalMandatoryIds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
119
|
+
return mandatoryIds.some(id => !stepperResponse[id]) || optionalMandatoryIds.some(item => stepperResponse[item.key] === item.value && item.mandatoryIds.some(id => !stepperResponse[id]));
|
|
183
120
|
};
|
|
121
|
+
const renderButtons = (index, isScreenChange, mandatoryIds, optionalMandatoryIds) => /*#__PURE__*/_react.default.createElement(_material.Box, {
|
|
122
|
+
sx: {
|
|
123
|
+
mb: 2
|
|
124
|
+
}
|
|
125
|
+
}, /*#__PURE__*/_react.default.createElement(_material.Button, _extends({
|
|
126
|
+
variant: "contained",
|
|
127
|
+
onClick: () => handleStepChange(1, isScreenChange, index === MuiSteps.length - 1),
|
|
128
|
+
disabled: isDisabled(mandatoryIds, optionalMandatoryIds),
|
|
129
|
+
sx: {
|
|
130
|
+
mt: 1,
|
|
131
|
+
mr: 1
|
|
132
|
+
}
|
|
133
|
+
}, attributes.MuiButtonAttributes.next, index === MuiSteps.length - 1 && {
|
|
134
|
+
...attributes.MuiButtonAttributes.final
|
|
135
|
+
}), index === MuiSteps.length - 1 ? 'Finish' : 'Continue'), /*#__PURE__*/_react.default.createElement(_material.Button, _extends({
|
|
136
|
+
disabled: index === 0,
|
|
137
|
+
onClick: () => handleStepChange(-1, isScreenChange, false),
|
|
138
|
+
sx: {
|
|
139
|
+
mt: 1,
|
|
140
|
+
mr: 1
|
|
141
|
+
}
|
|
142
|
+
}, attributes.MuiButtonAttributes.back), "Back"));
|
|
184
143
|
return /*#__PURE__*/_react.default.createElement(_material.Box, _extends({
|
|
185
144
|
sx: {
|
|
186
145
|
maxWidth: 400
|
|
@@ -196,9 +155,11 @@ function Stepper(_ref) {
|
|
|
196
155
|
}, "Last step")
|
|
197
156
|
}, attributes.MuiStepLabelAttributes), step.label), /*#__PURE__*/_react.default.createElement(_material.StepContent, attributes.MuiStepContentAttributes, step.components ? /*#__PURE__*/_react.default.createElement(_stepperComponents.default, {
|
|
198
157
|
onUpdate: handleUpdate,
|
|
199
|
-
components: (0, _helper.updatePatchData)(step.components, stepperResponse
|
|
200
|
-
}) : /*#__PURE__*/_react.default.createElement(_material.Typography, null, step.description),
|
|
158
|
+
components: (0, _helper.updatePatchData)(step.components, stepperResponse)
|
|
159
|
+
}) : /*#__PURE__*/_react.default.createElement(_material.Typography, null, step.description), renderButtons(index, step.isScreenChange, step.mandatoryIds, step.optionalMandatoryIds))))));
|
|
201
160
|
}
|
|
161
|
+
|
|
162
|
+
// PropTypes Definition
|
|
202
163
|
Stepper.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
203
164
|
attributes: _propTypes.default.shape({
|
|
204
165
|
id: _propTypes.default.string.isRequired,
|
|
@@ -206,7 +167,9 @@ Stepper.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
206
167
|
label: _propTypes.default.string.isRequired,
|
|
207
168
|
description: _propTypes.default.string,
|
|
208
169
|
isScreenChange: _propTypes.default.bool,
|
|
209
|
-
components: _propTypes.default.array
|
|
170
|
+
components: _propTypes.default.array,
|
|
171
|
+
mandatoryIds: _propTypes.default.array,
|
|
172
|
+
optionalMandatoryIds: _propTypes.default.array
|
|
210
173
|
})).isRequired,
|
|
211
174
|
MuiButtonAttributes: _propTypes.default.object,
|
|
212
175
|
MuiBoxAttributes: _propTypes.default.object,
|
|
@@ -220,10 +183,13 @@ Stepper.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
220
183
|
currentStep: _propTypes.default.number,
|
|
221
184
|
patch: _propTypes.default.object
|
|
222
185
|
} : {};
|
|
186
|
+
|
|
187
|
+
// Default Props
|
|
223
188
|
Stepper.defaultProps = {
|
|
224
189
|
attributes: {},
|
|
225
|
-
currentStep: 0,
|
|
226
|
-
patch: {},
|
|
227
190
|
onChange: () => {},
|
|
228
|
-
onStepUpdate: () => {}
|
|
229
|
-
|
|
191
|
+
onStepUpdate: () => {},
|
|
192
|
+
currentStep: 0,
|
|
193
|
+
patch: {}
|
|
194
|
+
};
|
|
195
|
+
var _default = exports.default = Stepper;
|
|
@@ -142,6 +142,11 @@ const mui = exports.mui = [{
|
|
|
142
142
|
}]
|
|
143
143
|
}, {
|
|
144
144
|
label: 'Determine Cost',
|
|
145
|
+
optionalMandatoryIds: [{
|
|
146
|
+
key: 'determinecost',
|
|
147
|
+
value: 'Assign',
|
|
148
|
+
mandatoryIds: ['cost']
|
|
149
|
+
}],
|
|
145
150
|
components: [{
|
|
146
151
|
id: 'determinecost',
|
|
147
152
|
type: 'radio',
|
package/docs/asset-manifest.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"files": {
|
|
3
|
-
"main.js": "/DinakaranS/-dynamic-mui/build/bundle.
|
|
3
|
+
"main.js": "/DinakaranS/-dynamic-mui/build/bundle.e8059e90.js",
|
|
4
4
|
"index.html": "/DinakaranS/-dynamic-mui/index.html"
|
|
5
5
|
},
|
|
6
6
|
"entrypoints": [
|
|
7
|
-
"build/bundle.
|
|
7
|
+
"build/bundle.e8059e90.js"
|
|
8
8
|
]
|
|
9
9
|
}
|