dynamic-mui 1.0.71 → 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.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = Stepper;
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
- switch (action.type) {
25
+ const {
26
+ type,
27
+ payload
28
+ } = action;
29
+ switch (type) {
25
30
  case 'SET_STEPS':
26
31
  return {
27
32
  ...state,
28
- MuiSteps: action.MuiSteps
33
+ MuiSteps: payload.MuiSteps
29
34
  };
30
35
  case 'SET_STEP':
31
36
  return {
32
37
  ...state,
33
- activeStep: action.currentStep
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
- [action.id]: action.value
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, init => ({
66
- ...init,
65
+ const [state, dispatch] = (0, _react.useReducer)(reducer, initialState, () => ({
67
66
  activeStep: currentStep,
68
67
  stepperResponse: patch,
69
- MuiSteps: [...attributes.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
- currentStep
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: stepChange
85
+ type: 'CHANGE_STEP',
86
+ payload: {
87
+ stepChange
88
+ }
93
89
  });
94
- const newStep = activeStep + (stepChange === 'NEXT_STEP' ? 1 : -1);
95
- onStepUpdate?.(newStep, isScreenChange && stepChange === 'NEXT_STEP', isLastStep);
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
- id,
112
- value
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 renderStepButtons = function (index, isScreenChange) {
160
- let mandatoryIds = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
161
- return /*#__PURE__*/_react.default.createElement(_material.Box, {
162
- sx: {
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 => !response[attributes.id][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, attributes.id, response)
200
- }) : /*#__PURE__*/_react.default.createElement(_material.Typography, null, step.description), renderStepButtons(index, step.isScreenChange, step.mandatoryIds))))));
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;
@@ -16,6 +16,21 @@ const mui = exports.mui = [{
16
16
  label: 'Select Service Request',
17
17
  mandatoryIds: ['servicetype'],
18
18
  components: [{
19
+ id: 'servicetypeselect',
20
+ type: 'radio',
21
+ props: {
22
+ id: 'servicetypeselect',
23
+ value: 'Existing',
24
+ MuiAttributes: {},
25
+ MuiFLabelIcon: {},
26
+ MuiFLabel: '',
27
+ MuiFCLAttributes: {},
28
+ MuiFCLabels: ['Existing', 'New'],
29
+ MuiRGAttributes: {
30
+ row: true
31
+ }
32
+ }
33
+ }, {
19
34
  type: 'select',
20
35
  props: {
21
36
  id: 'servicetype',
@@ -23,17 +38,8 @@ const mui = exports.mui = [{
23
38
  required: true
24
39
  },
25
40
  options: [{
26
- value: 'After Meter Leaking',
27
- label: 'After Meter Leaking'
28
- }, {
29
- value: 'Align Meter',
30
- label: 'Align Meter'
31
- }, {
32
- value: 'Before Meter Leaking',
33
- label: 'Before Meter Leaking'
34
- }, {
35
- value: 'Billing Concerns',
36
- label: 'Billing Concerns'
41
+ value: 'New Installation',
42
+ label: 'New Installation'
37
43
  }, {
38
44
  value: 'Change Classification',
39
45
  label: 'Change Classification'
@@ -44,62 +50,14 @@ const mui = exports.mui = [{
44
50
  value: 'Change Name',
45
51
  label: 'Change Name'
46
52
  }, {
47
- value: 'Meter Servicing',
48
- label: 'Meter Servicing'
49
- }, {
50
- value: 'Disconnection - Involuntary',
51
- label: 'Disconnection - Involuntary'
52
- }, {
53
- value: 'Disconnection - Voluntary',
54
- label: 'Disconnection - Voluntary'
55
- }, {
56
- value: 'Distribution Line Leaking',
57
- label: 'Distribution Line Leaking'
58
- }, {
59
- value: 'Estimate Inner Plumbing',
60
- label: 'Estimate Inner Plumbing'
61
- }, {
62
- value: 'Illegal Activity',
63
- label: 'Illegal Activity'
64
- }, {
65
- value: 'Install Lockwing',
66
- label: 'Install Lockwing'
67
- }, {
68
- value: 'Low Pressure/No Water',
69
- label: 'Low Pressure/No Water'
70
- }, {
71
- value: 'Mainline Leaking',
72
- label: 'Mainline Leaking'
73
- }, {
74
- value: 'Other Complaints',
75
- label: 'Other Complaints'
76
- }, {
77
- value: 'Paid Before Disconnect',
78
- label: 'Paid Before Disconnect'
79
- }, {
80
- value: 'Pull Out Meter',
81
- label: 'Pull Out Meter'
53
+ value: 'Transfer Location',
54
+ label: 'Transfer Location'
82
55
  }, {
83
56
  value: 'Recheck Read',
84
57
  label: 'Recheck Read'
85
58
  }, {
86
- value: 'Reconnection',
87
- label: 'Reconnection'
88
- }, {
89
- value: 'Relocation - Change Zone',
90
- label: 'Relocation - Change Zone'
91
- }, {
92
- value: 'Secondaryline Leaking',
93
- label: 'Secondaryline Leaking'
94
- }, {
95
- value: 'Survey',
96
- label: 'Survey'
97
- }, {
98
- value: 'Relocation',
99
- label: 'Relocation'
100
- }, {
101
- value: 'Water Quality Concern',
102
- label: 'Water Quality Concern'
59
+ value: 'Disconnection - Voluntary',
60
+ label: 'Disconnection - Voluntary'
103
61
  }],
104
62
  MuiBoxAttributes: {}
105
63
  }
@@ -112,6 +70,9 @@ const mui = exports.mui = [{
112
70
  type: 'select',
113
71
  props: {
114
72
  id: 'priority',
73
+ MuiAttributes: {
74
+ required: true
75
+ },
115
76
  options: [{
116
77
  value: 'Emergency',
117
78
  label: 'Emergency'
@@ -163,33 +124,29 @@ const mui = exports.mui = [{
163
124
  }]
164
125
  }, {
165
126
  label: 'Assign User',
166
- mandatoryIds: ['assignedTo'],
127
+ mandatoryIds: ['assigntouser'],
167
128
  components: [{
168
129
  type: 'select',
169
130
  props: {
170
- id: 'assignedTo',
131
+ id: 'assigntouser',
171
132
  MuiAttributes: {},
172
133
  options: [{
173
- value: 'gwdteller1',
174
- label: 'gwdteller1'
175
- }, {
176
- value: 'gwdreader1',
177
- label: 'gwdreader1'
178
- }, {
179
- value: 'gwdreader2',
180
- label: 'gwdreader2'
134
+ value: 'Dinakaran',
135
+ label: 'Dinakaran'
181
136
  }, {
182
- value: 'gmrolandobill',
183
- label: 'gmrolandobill'
184
- }, {
185
- value: 'mungGuiuan',
186
- label: 'mungGuiuan'
137
+ value: 'Thiyagarajan',
138
+ label: 'Thiyagarajan'
187
139
  }],
188
140
  MuiBoxAttributes: {}
189
141
  }
190
142
  }]
191
143
  }, {
192
144
  label: 'Determine Cost',
145
+ optionalMandatoryIds: [{
146
+ key: 'determinecost',
147
+ value: 'Assign',
148
+ mandatoryIds: ['cost']
149
+ }],
193
150
  components: [{
194
151
  id: 'determinecost',
195
152
  type: 'radio',
@@ -206,23 +163,20 @@ const mui = exports.mui = [{
206
163
  }
207
164
  }
208
165
  }, {
209
- id: 'serviceCost',
166
+ id: 'cost',
210
167
  type: 'textfield',
211
168
  props: {
212
- id: 'serviceCost',
213
- MuiAttributes: {
214
- type: 'number'
215
- },
216
- value: 0
169
+ id: 'cost',
170
+ MuiAttributes: {}
217
171
  }
218
172
  }]
219
173
  }, {
220
174
  label: 'Description',
221
175
  components: [{
222
- id: 'descriptionDetails',
176
+ id: 'description',
223
177
  type: 'textfield',
224
178
  props: {
225
- id: 'descriptionDetails',
179
+ id: 'description',
226
180
  MuiAttributes: {
227
181
  multiline: true,
228
182
  rows: 3
@@ -232,47 +186,19 @@ const mui = exports.mui = [{
232
186
  }, {
233
187
  label: 'Review'
234
188
  }],
235
- MuiStepAttributes: {
236
- sx: {
237
- '& .MuiStepLabel-root .Mui-completed': {
238
- color: 'primary.dark'
239
- },
240
- '& .MuiStepLabel-label.Mui-completed.MuiStepLabel-alternativeLabel': {
241
- color: 'grey.500'
242
- },
243
- '& .MuiStepLabel-root .Mui-active': {
244
- color: 'primary.dark'
245
- },
246
- '& .MuiStepLabel-label.Mui-active.MuiStepLabel-alternativeLabel': {
247
- color: 'common.white'
248
- },
249
- '& .MuiStepLabel-root .Mui-active .MuiStepIcon-text': {
250
- fill: 'common.white'
251
- }
252
- }
253
- },
189
+ MuiStepAttributes: {},
254
190
  MuiStepLabelAttributes: {},
255
191
  MuiStepContentAttributes: {},
256
192
  MuiButtonAttributes: {
257
- back: {
258
- sx: {
259
- color: 'primary.dark',
260
- mt: 1
261
- }
262
- },
193
+ back: {},
263
194
  next: {
264
195
  sx: {
265
- bgcolor: 'primary.dark',
266
- mt: 1
196
+ bgcolor: 'primary.dark'
267
197
  }
268
198
  },
269
199
  final: {
270
200
  sx: {
271
- bgcolor: 'success.light',
272
- mt: 1,
273
- '&:hover': {
274
- bgcolor: 'success.dark'
275
- }
201
+ bgcolor: 'success.light'
276
202
  }
277
203
  },
278
204
  backLabel: '',
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "files": {
3
- "main.js": "/DinakaranS/-dynamic-mui/build/bundle.8cf75d73.js",
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.8cf75d73.js"
7
+ "build/bundle.e8059e90.js"
8
8
  ]
9
9
  }