dynamic-mui 1.0.72 → 1.0.73

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.
@@ -155,7 +155,7 @@ function Stepper(_ref) {
155
155
  }, "Last step")
156
156
  }, attributes.MuiStepLabelAttributes), step.label), /*#__PURE__*/_react.default.createElement(_material.StepContent, attributes.MuiStepContentAttributes, step.components ? /*#__PURE__*/_react.default.createElement(_stepperComponents.default, {
157
157
  onUpdate: handleUpdate,
158
- components: (0, _helper.updatePatchData)(step.components, stepperResponse)
158
+ components: (0, _helper.updatePatchData)(step.components, stepperResponse, '', {}, step.enableDisableIds)
159
159
  }) : /*#__PURE__*/_react.default.createElement(_material.Typography, null, step.description), renderButtons(index, step.isScreenChange, step.mandatoryIds, step.optionalMandatoryIds))))));
160
160
  }
161
161
 
@@ -147,6 +147,14 @@ const mui = exports.mui = [{
147
147
  value: 'Assign',
148
148
  mandatoryIds: ['cost']
149
149
  }],
150
+ enableDisableIds: [{
151
+ key: 'determinecost',
152
+ disableIds: ['cost'],
153
+ compareValues: {
154
+ Skip: true,
155
+ Assign: false
156
+ }
157
+ }],
150
158
  components: [{
151
159
  id: 'determinecost',
152
160
  type: 'radio',
@@ -161,6 +169,13 @@ const mui = exports.mui = [{
161
169
  MuiRGAttributes: {
162
170
  row: true
163
171
  }
172
+ },
173
+ enableDisableConfig: {
174
+ disableId: 'cost',
175
+ compareValue: {
176
+ Skip: true,
177
+ Assign: false
178
+ }
164
179
  }
165
180
  }, {
166
181
  id: 'cost',
@@ -12,7 +12,6 @@ var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
12
12
  var _material = require("@mui/material");
13
13
  var _xDatePickers = require("@mui/x-date-pickers");
14
14
  var _react = _interopRequireDefault(require("react"));
15
- var _utils = require("@mui/x-data-grid/utils/utils");
16
15
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
16
  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); }
18
17
  function generateLayout(data) {
@@ -85,29 +84,63 @@ function isEmptyCustom(value) {
85
84
  }
86
85
  const updatePatchData = function (fields, patch, guid) {
87
86
  let response = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
87
+ let enableDisableIds = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
88
88
  try {
89
+ // Update response with the patch for the provided GUID
89
90
  response[guid] = patch;
90
- const formData = Object.assign([], fields);
91
- return (0, _lodash.map)(formData, field => {
92
- const newField = (0, _utils.deepClone)({
93
- ...field
94
- });
91
+
92
+ // Map and update fields with response data
93
+ const updatedFields = (0, _lodash.map)(fields, field => {
94
+ const newField = (0, _lodash.cloneDeep)(field);
95
95
  const id = newField?.id || newField?.props?.id;
96
96
  if (id && response[guid] && !isEmptyCustom(response[guid][id])) {
97
- const defaultValue = newField?.type === 'switch' || newField?.type === 'checkbox' ? false : '';
98
- const isUndefined = response[guid][id] === undefined;
97
+ const defaultValue = ['switch', 'checkbox'].includes(newField?.type) ? false : '';
99
98
  newField.props = {
100
99
  ...newField.props,
101
- value: isUndefined ? defaultValue || '' : response[guid][id]
100
+ value: response[guid][id] === undefined ? defaultValue : response[guid][id]
102
101
  };
103
- // newField.props.value = response[guid][id] || defaultValue;
104
102
  }
105
103
  return newField;
106
104
  });
107
- } catch (e) {
105
+
106
+ // Handle enable/disable logic
107
+ if (enableDisableIds.length > 0) {
108
+ enableDisableIds.forEach(_ref => {
109
+ let {
110
+ key,
111
+ disableIds,
112
+ compareValues = {}
113
+ } = _ref;
114
+ const controllingField = updatedFields.find(field => field?.id === key || field?.props?.id === key);
115
+ if (controllingField) {
116
+ const disabled = compareValues[controllingField?.props?.value];
117
+ disableIds.forEach(patchId => {
118
+ const targetFieldIndex = updatedFields.findIndex(field => field?.id === patchId || field?.props?.id === patchId);
119
+ if (targetFieldIndex !== -1) {
120
+ const tElement = updatedFields[targetFieldIndex];
121
+ const id = tElement?.id || tElement?.props?.id;
122
+ response[guid][id] = disabled ? '' : response[guid][id];
123
+ updatedFields[targetFieldIndex] = {
124
+ ...updatedFields[targetFieldIndex],
125
+ props: {
126
+ ...updatedFields[targetFieldIndex].props,
127
+ value: disabled ? '' : updatedFields[targetFieldIndex]?.props?.value,
128
+ MuiAttributes: {
129
+ ...updatedFields[targetFieldIndex].props?.MuiAttributes,
130
+ disabled
131
+ }
132
+ }
133
+ };
134
+ }
135
+ });
136
+ }
137
+ });
138
+ }
139
+ return updatedFields;
140
+ } catch (error) {
108
141
  // eslint-disable-next-line no-console
109
- console.log(e);
110
- return fields;
142
+ console.error('Error updating patch data:', error);
143
+ return fields; // Return original fields on error
111
144
  }
112
145
  };
113
146
  exports.updatePatchData = updatePatchData;
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "files": {
3
- "main.js": "/DinakaranS/-dynamic-mui/build/bundle.e8059e90.js",
3
+ "main.js": "/DinakaranS/-dynamic-mui/build/bundle.5a4707c5.js",
4
4
  "index.html": "/DinakaranS/-dynamic-mui/index.html"
5
5
  },
6
6
  "entrypoints": [
7
- "build/bundle.e8059e90.js"
7
+ "build/bundle.5a4707c5.js"
8
8
  ]
9
9
  }