datastake-daf 0.6.751 → 0.6.752

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.
@@ -9667,28 +9667,30 @@ const handleSectionChildren = _ref => {
9667
9667
  });
9668
9668
  };
9669
9669
 
9670
- const handleArrayChildren = ({
9671
- value,
9672
- config,
9673
- label,
9674
- level,
9675
- t,
9676
- rootForm,
9677
- allData,
9678
- user,
9679
- getApiBaseUrl = () => {},
9680
- getAppHeader = () => {},
9681
- app,
9682
- TreeNodeComponent
9683
- }) => {
9670
+ const handleArrayChildren = _ref => {
9671
+ let {
9672
+ value,
9673
+ config,
9674
+ label,
9675
+ level,
9676
+ t,
9677
+ rootForm,
9678
+ allData,
9679
+ user,
9680
+ getApiBaseUrl = () => {},
9681
+ getAppHeader = () => {},
9682
+ app,
9683
+ TreeNodeComponent
9684
+ } = _ref;
9684
9685
  if (!Array.isArray(value)) {
9685
9686
  return null;
9686
9687
  }
9687
9688
  return value.map((item, itemIndex) => /*#__PURE__*/jsxRuntime.jsx("div", {
9688
9689
  className: "array-item",
9689
9690
  children: Object.keys(config.inputs).sort((a, b) => {
9690
- const positionA = config.inputs[a]?.position || 0;
9691
- const positionB = config.inputs[b]?.position || 0;
9691
+ var _config$inputs$a, _config$inputs$b;
9692
+ const positionA = ((_config$inputs$a = config.inputs[a]) === null || _config$inputs$a === void 0 ? void 0 : _config$inputs$a.position) || 0;
9693
+ const positionB = ((_config$inputs$b = config.inputs[b]) === null || _config$inputs$b === void 0 ? void 0 : _config$inputs$b.position) || 0;
9692
9694
  return positionA - positionB;
9693
9695
  }).map(subInputKey => {
9694
9696
  const subInputConfig = config.inputs[subInputKey];
@@ -9706,9 +9708,9 @@ const handleArrayChildren = ({
9706
9708
  getApiBaseUrl: getApiBaseUrl,
9707
9709
  getAppHeader: getAppHeader,
9708
9710
  app: app
9709
- }, `${itemIndex}-${subInputKey}`);
9711
+ }, "".concat(itemIndex, "-").concat(subInputKey));
9710
9712
  })
9711
- }, `${itemIndex}`));
9713
+ }, "".concat(itemIndex)));
9712
9714
  };
9713
9715
 
9714
9716
  const noDafApps = ['tif', 'cukura']; //PACKAGE_CHANGE_LATER (remove sbg)
@@ -10068,42 +10070,37 @@ const handleDataLinkGroupWithTableKeys = _ref2 => {
10068
10070
  }
10069
10071
  };
10070
10072
 
10071
- const handleDataLinkWithTableKeys = _ref => {
10072
- var _inputConfig$meta, _inputConfig$meta3, _inputConfig$meta4, _inputConfig$meta5;
10073
- let {
10074
- inputConfig,
10075
- inputKey,
10076
- value,
10077
- level,
10078
- t,
10079
- rootForm,
10080
- allData,
10081
- user,
10082
- getApiBaseUrl = () => {},
10083
- getAppHeader = () => {},
10084
- app,
10085
- TreeNodeComponent
10086
- } = _ref;
10087
- if ((inputConfig === null || inputConfig === void 0 ? void 0 : inputConfig.type) !== 'dataLink' || !(inputConfig !== null && inputConfig !== void 0 && (_inputConfig$meta = inputConfig.meta) !== null && _inputConfig$meta !== void 0 && _inputConfig$meta.tableKeys)) {
10073
+ const handleDataLinkWithTableKeys = ({
10074
+ inputConfig,
10075
+ inputKey,
10076
+ value,
10077
+ level,
10078
+ t,
10079
+ rootForm,
10080
+ allData,
10081
+ user,
10082
+ getApiBaseUrl = () => {},
10083
+ getAppHeader = () => {},
10084
+ app,
10085
+ TreeNodeComponent
10086
+ }) => {
10087
+ if (inputConfig?.type !== 'dataLink' || !inputConfig?.meta?.tableKeys) {
10088
10088
  return null;
10089
10089
  }
10090
10090
  const tableKeys = inputConfig.meta.tableKeys;
10091
- const isAjaxModal = React.useMemo(() => {
10092
- var _inputConfig$meta2;
10093
- return !!(inputConfig !== null && inputConfig !== void 0 && (_inputConfig$meta2 = inputConfig.meta) !== null && _inputConfig$meta2 !== void 0 && _inputConfig$meta2.namespace);
10094
- }, [inputConfig]);
10091
+ const isAjaxModal = React.useMemo(() => !!inputConfig?.meta?.namespace, [inputConfig]);
10095
10092
  const ajaxModalValues = useAjaxModal$2({
10096
10093
  name: inputKey,
10097
10094
  user,
10098
- namespace: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta3 = inputConfig.meta) === null || _inputConfig$meta3 === void 0 ? void 0 : _inputConfig$meta3.namespace,
10099
- skipFetch: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta4 = inputConfig.meta) === null || _inputConfig$meta4 === void 0 ? void 0 : _inputConfig$meta4.skipFetch,
10095
+ namespace: inputConfig?.meta?.namespace,
10096
+ skipFetch: inputConfig?.meta?.skipFetch,
10100
10097
  isAjaxModal,
10101
- formScope: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta5 = inputConfig.meta) === null || _inputConfig$meta5 === void 0 ? void 0 : _inputConfig$meta5.formScope,
10098
+ formScope: inputConfig?.meta?.formScope,
10102
10099
  APP: app,
10103
10100
  apiBaseUrl: getApiBaseUrl(),
10104
10101
  _getAppHeader: getAppHeader
10105
10102
  });
10106
- const dataLinkForm = ajaxModalValues === null || ajaxModalValues === void 0 ? void 0 : ajaxModalValues.form;
10103
+ const dataLinkForm = ajaxModalValues?.form;
10107
10104
  const createInputsAndValues = item => {
10108
10105
  const inputs = {};
10109
10106
  const values = {};
@@ -10116,20 +10113,19 @@ const handleDataLinkWithTableKeys = _ref => {
10116
10113
  };
10117
10114
  const isUploadFieldEmpty = (fieldKey, itemToCheck) => {
10118
10115
  if (uploadTypeFields.includes(fieldKey)) {
10119
- const itemValue = itemToCheck === null || itemToCheck === void 0 ? void 0 : itemToCheck[fieldKey];
10116
+ const itemValue = itemToCheck?.[fieldKey];
10120
10117
  return itemValue === undefined || itemValue === null || Array.isArray(itemValue) && itemValue.length === 0;
10121
10118
  }
10122
10119
  return false;
10123
10120
  };
10124
10121
  const processedTableKeys = processConditionalTableKeys(tableKeys, item);
10125
10122
  processedTableKeys.filter(tableKey => tableKey !== 'datastakeId').filter(tableKey => !isUploadFieldEmpty(tableKey, item)).forEach(tableKey => {
10126
- var _dataLinkForm$identif;
10127
- const formInputConfig = (dataLinkForm === null || dataLinkForm === void 0 ? void 0 : dataLinkForm[tableKey]) || (dataLinkForm === null || dataLinkForm === void 0 || (_dataLinkForm$identif = dataLinkForm['identification']) === null || _dataLinkForm$identif === void 0 ? void 0 : _dataLinkForm$identif[tableKey]);
10123
+ const formInputConfig = dataLinkForm?.[tableKey] || dataLinkForm?.['identification']?.[tableKey];
10128
10124
  if (formInputConfig) {
10129
- var _item$linking, _formInputConfig$meta, _formInputConfig$tabl;
10130
- inputs[tableKey] = _objectSpread2(_objectSpread2({}, formInputConfig), {}, {
10125
+ inputs[tableKey] = {
10126
+ ...formInputConfig,
10131
10127
  label: uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : formInputConfig.label || formInputConfig.tableLabel || tableKey
10132
- });
10128
+ };
10133
10129
  if (formInputConfig.label && typeof formInputConfig.label === 'object') {
10134
10130
  const dynamicLabelKeys = Object.keys(formInputConfig.label);
10135
10131
  let resolvedLabel = null;
@@ -10137,7 +10133,7 @@ const handleDataLinkWithTableKeys = _ref => {
10137
10133
  const parts = labelKey.split(' is ');
10138
10134
  if (parts.length === 2) {
10139
10135
  const [conditionKey, conditionValue] = parts;
10140
- if ((item === null || item === void 0 ? void 0 : item[conditionKey]) === conditionValue) {
10136
+ if (item?.[conditionKey] === conditionValue) {
10141
10137
  resolvedLabel = formInputConfig.label[labelKey];
10142
10138
  break;
10143
10139
  }
@@ -10145,17 +10141,16 @@ const handleDataLinkWithTableKeys = _ref => {
10145
10141
  }
10146
10142
  inputs[tableKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] || (uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : tableKey);
10147
10143
  }
10148
- values[tableKey] = (item === null || item === void 0 || (_item$linking = item.linking) === null || _item$linking === void 0 || (_item$linking = _item$linking.SCL) === null || _item$linking === void 0 || (_item$linking = _item$linking[item === null || item === void 0 ? void 0 : item[tableKey]]) === null || _item$linking === void 0 ? void 0 : _item$linking.name) || item[formInputConfig === null || formInputConfig === void 0 || (_formInputConfig$meta = formInputConfig.meta) === null || _formInputConfig$meta === void 0 ? void 0 : _formInputConfig$meta.onNewSetValueKey] || (item === null || item === void 0 ? void 0 : item[formInputConfig === null || formInputConfig === void 0 || (_formInputConfig$tabl = formInputConfig.tableLabel) === null || _formInputConfig$tabl === void 0 ? void 0 : _formInputConfig$tabl.toLowerCase()]) || (item === null || item === void 0 ? void 0 : item[tableKey]);
10144
+ values[tableKey] = item?.linking?.SCL?.[item?.[tableKey]]?.name || item[formInputConfig?.meta?.onNewSetValueKey] || item?.[formInputConfig?.tableLabel?.toLowerCase()] || item?.[tableKey];
10149
10145
  } else {
10150
- var _item$linking2;
10151
10146
  inputs[tableKey] = {
10152
10147
  label: uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : tableKey,
10153
- type: inputConfig === null || inputConfig === void 0 ? void 0 : inputConfig.type
10148
+ type: inputConfig?.type
10154
10149
  };
10155
- values[tableKey] = (item === null || item === void 0 || (_item$linking2 = item.linking) === null || _item$linking2 === void 0 || (_item$linking2 = _item$linking2.SCL) === null || _item$linking2 === void 0 || (_item$linking2 = _item$linking2[item === null || item === void 0 ? void 0 : item[tableKey]]) === null || _item$linking2 === void 0 ? void 0 : _item$linking2.name) || (item === null || item === void 0 ? void 0 : item[tableKey]);
10150
+ values[tableKey] = item?.linking?.SCL?.[item?.[tableKey]]?.name || item?.[tableKey];
10156
10151
  }
10157
10152
  });
10158
- if (dataLinkForm !== null && dataLinkForm !== void 0 && dataLinkForm.identification && typeof dataLinkForm.identification === 'object') {
10153
+ if (dataLinkForm?.identification && typeof dataLinkForm.identification === 'object') {
10159
10154
  Object.keys(dataLinkForm.identification).filter(fieldKey => {
10160
10155
  if (uploadTypeFields.includes(fieldKey)) {
10161
10156
  return !isUploadFieldEmpty(fieldKey, item);
@@ -10165,11 +10160,11 @@ const handleDataLinkWithTableKeys = _ref => {
10165
10160
  const formInputConfig = dataLinkForm.identification[fieldKey];
10166
10161
  return formInputConfig && typeof formInputConfig === 'object' && !Array.isArray(formInputConfig);
10167
10162
  }).forEach(fieldKey => {
10168
- var _item$linking3, _formInputConfig$tabl2;
10169
10163
  const formInputConfig = dataLinkForm.identification[fieldKey];
10170
- inputs[fieldKey] = _objectSpread2(_objectSpread2({}, formInputConfig), {}, {
10164
+ inputs[fieldKey] = {
10165
+ ...formInputConfig,
10171
10166
  label: uploadTypeFields.includes(fieldKey) ? uploadTypeLabels[fieldKey] : formInputConfig.label || formInputConfig.tableLabel || fieldKey
10172
- });
10167
+ };
10173
10168
  if (formInputConfig.label && typeof formInputConfig.label === 'object') {
10174
10169
  const dynamicLabelKeys = Object.keys(formInputConfig.label);
10175
10170
  let resolvedLabel = null;
@@ -10177,7 +10172,7 @@ const handleDataLinkWithTableKeys = _ref => {
10177
10172
  const parts = labelKey.split(' is ');
10178
10173
  if (parts.length === 2) {
10179
10174
  const [conditionKey, conditionValue] = parts;
10180
- if ((item === null || item === void 0 ? void 0 : item[conditionKey]) === conditionValue) {
10175
+ if (item?.[conditionKey] === conditionValue) {
10181
10176
  resolvedLabel = formInputConfig.label[labelKey];
10182
10177
  break;
10183
10178
  }
@@ -10185,7 +10180,7 @@ const handleDataLinkWithTableKeys = _ref => {
10185
10180
  }
10186
10181
  inputs[fieldKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] || (uploadTypeFields.includes(fieldKey) ? uploadTypeLabels[fieldKey] : fieldKey);
10187
10182
  }
10188
- values[fieldKey] = (item === null || item === void 0 || (_item$linking3 = item.linking) === null || _item$linking3 === void 0 || (_item$linking3 = _item$linking3.SCL) === null || _item$linking3 === void 0 || (_item$linking3 = _item$linking3[item === null || item === void 0 ? void 0 : item[fieldKey]]) === null || _item$linking3 === void 0 ? void 0 : _item$linking3.name) || (item === null || item === void 0 ? void 0 : item[formInputConfig === null || formInputConfig === void 0 || (_formInputConfig$tabl2 = formInputConfig.tableLabel) === null || _formInputConfig$tabl2 === void 0 ? void 0 : _formInputConfig$tabl2.toLowerCase()]) || (item === null || item === void 0 ? void 0 : item[fieldKey]);
10183
+ values[fieldKey] = item?.linking?.SCL?.[item?.[fieldKey]]?.name || item?.[formInputConfig?.tableLabel?.toLowerCase()] || item?.[fieldKey];
10189
10184
  });
10190
10185
  }
10191
10186
  return {
@@ -10195,7 +10190,7 @@ const handleDataLinkWithTableKeys = _ref => {
10195
10190
  };
10196
10191
  if (Array.isArray(value)) {
10197
10192
  return value.map((item, itemIndex) => {
10198
- const datastakeIdValue = item === null || item === void 0 ? void 0 : item.datastakeId;
10193
+ const datastakeIdValue = item?.datastakeId;
10199
10194
  const {
10200
10195
  inputs,
10201
10196
  values
@@ -10204,9 +10199,9 @@ const handleDataLinkWithTableKeys = _ref => {
10204
10199
  return null;
10205
10200
  }
10206
10201
  return /*#__PURE__*/jsxRuntime.jsx(TreeNodeComponent, {
10207
- nodeKey: datastakeIdValue || t("No ID ".concat(itemIndex + 1)),
10202
+ nodeKey: datastakeIdValue || t(`No ID ${itemIndex + 1}`),
10208
10203
  config: {
10209
- label: datastakeIdValue || t("No ID ".concat(itemIndex + 1)),
10204
+ label: datastakeIdValue || t(`No ID ${itemIndex + 1}`),
10210
10205
  type: 'custom-datalink',
10211
10206
  inputs: inputs
10212
10207
  },
@@ -10220,10 +10215,10 @@ const handleDataLinkWithTableKeys = _ref => {
10220
10215
  getApiBaseUrl: getApiBaseUrl,
10221
10216
  getAppHeader: getAppHeader,
10222
10217
  app: app
10223
- }, "".concat(inputKey, "-").concat(itemIndex));
10218
+ }, `${inputKey}-${itemIndex}`);
10224
10219
  });
10225
10220
  } else {
10226
- const datastakeIdValue = value === null || value === void 0 ? void 0 : value.datastakeId;
10221
+ const datastakeIdValue = value?.datastakeId;
10227
10222
  const {
10228
10223
  inputs,
10229
10224
  values
@@ -10248,7 +10243,7 @@ const handleDataLinkWithTableKeys = _ref => {
10248
10243
  getApiBaseUrl: getApiBaseUrl,
10249
10244
  getAppHeader: getAppHeader,
10250
10245
  app: app
10251
- }, "".concat(inputKey, "-single"));
10246
+ }, `${inputKey}-single`);
10252
10247
  }
10253
10248
  };
10254
10249
 
@@ -39907,20 +39902,27 @@ function DynamicForm(_ref) {
39907
39902
  }
39908
39903
  }, [data]);
39909
39904
 
39910
- // Initialize default values for hidden fields
39905
+ // Initialize default values for hidden and disabled fields
39911
39906
  React.useEffect(() => {
39912
39907
  if (Object.keys(form).length > 0) {
39913
39908
  const updatedValues = _objectSpread2({}, values);
39914
39909
  let hasChanges = false;
39910
+ const isEditMode = data && (data.id || data._id);
39915
39911
 
39916
- // Process all form fields to set default values for hidden fields
39912
+ // Process all form fields to set default values for hidden and disabled fields
39917
39913
  Object.keys(form).forEach(formKey => {
39918
39914
  Object.keys(form[formKey]).forEach(fieldKey => {
39919
- var _field$meta, _field$meta2;
39915
+ var _field$meta, _field$meta2, _field$meta3, _field$meta4, _field$meta5, _field$meta6;
39920
39916
  const field = form[formKey][fieldKey];
39921
- if ((field === null || field === void 0 || (_field$meta = field.meta) === null || _field$meta === void 0 ? void 0 : _field$meta.hidden) === true && (field === null || field === void 0 || (_field$meta2 = field.meta) === null || _field$meta2 === void 0 ? void 0 : _field$meta2.defaultValue) !== undefined) {
39922
- const fieldId = field.dataId || fieldKey;
39923
- if (!propHasValue(updatedValues[fieldId])) {
39917
+ const fieldId = field.dataId || fieldKey;
39918
+
39919
+ // Check if field is disabled
39920
+ const isDisabled = field !== null && field !== void 0 && (_field$meta = field.meta) !== null && _field$meta !== void 0 && _field$meta.disableEdit && typeof (field === null || field === void 0 || (_field$meta2 = field.meta) === null || _field$meta2 === void 0 ? void 0 : _field$meta2.disableEdit) === 'object' ? isModal ? field.meta.disableEdit.create || field.meta.disableEdit.modal || (field === null || field === void 0 || (_field$meta3 = field.meta) === null || _field$meta3 === void 0 || (_field$meta3 = _field$meta3.disableEdit) === null || _field$meta3 === void 0 ? void 0 : _field$meta3.edit) && isEditMode : field.meta.disableEdit.create || field.meta.disableEdit.drawer || (field === null || field === void 0 || (_field$meta4 = field.meta) === null || _field$meta4 === void 0 || (_field$meta4 = _field$meta4.disableEdit) === null || _field$meta4 === void 0 ? void 0 : _field$meta4.edit) && isEditMode : field === null || field === void 0 || (_field$meta5 = field.meta) === null || _field$meta5 === void 0 ? void 0 : _field$meta5.disableEdit;
39921
+
39922
+ // Set default value for hidden fields or disabled fields with default values
39923
+ if ((field === null || field === void 0 || (_field$meta6 = field.meta) === null || _field$meta6 === void 0 ? void 0 : _field$meta6.defaultValue) !== undefined && !propHasValue(updatedValues[fieldId])) {
39924
+ var _field$meta7;
39925
+ if ((field === null || field === void 0 || (_field$meta7 = field.meta) === null || _field$meta7 === void 0 ? void 0 : _field$meta7.hidden) === true || isDisabled) {
39924
39926
  updatedValues[fieldId] = field.meta.defaultValue;
39925
39927
  hasChanges = true;
39926
39928
  }
@@ -39933,7 +39935,7 @@ function DynamicForm(_ref) {
39933
39935
  MainForm.setFieldsValue(updatedValues);
39934
39936
  }
39935
39937
  }
39936
- }, [form]);
39938
+ }, [form, data, isModal]);
39937
39939
  const setSelectedForm = id => {
39938
39940
  setForms(Forms.map(form => {
39939
39941
  id === form.id ? form.selected = true : form.selected = false;
@@ -39970,7 +39972,7 @@ function DynamicForm(_ref) {
39970
39972
  }).every(key => key);
39971
39973
  };
39972
39974
  const getData = (name, input, value, commentValue, path, disabledPath) => {
39973
- var _input$meta, _input$meta2, _input$meta3, _input$meta4, _input$meta5, _input$meta6, _input$meta7, _input$meta8, _input$meta9, _input$meta10, _input$meta11, _input$meta12;
39975
+ var _input$meta, _input$meta2, _input$meta3, _input$meta4, _input$meta5, _input$meta6, _input$meta7, _input$meta9, _input$meta10, _input$meta11, _input$meta12;
39974
39976
  const props = {
39975
39977
  // placeholder: input.labelHint ? input.labelHint : getInputLabel(input, values, true),
39976
39978
  placeholder: input.labelHint,
@@ -40007,11 +40009,16 @@ function DynamicForm(_ref) {
40007
40009
  }
40008
40010
  value = fileList;
40009
40011
  }
40010
- // Handle default values for hidden fields
40011
- if ((input === null || input === void 0 || (_input$meta7 = input.meta) === null || _input$meta7 === void 0 ? void 0 : _input$meta7.hidden) === true && (input === null || input === void 0 || (_input$meta8 = input.meta) === null || _input$meta8 === void 0 ? void 0 : _input$meta8.defaultValue) !== undefined && !propHasValue(value)) {
40012
- value = input.meta.defaultValue;
40013
- if (typeof path === 'string') {
40014
- dot__default["default"].str(path, value, values);
40012
+ // Handle default values for hidden fields and disabled fields
40013
+ if ((input === null || input === void 0 || (_input$meta7 = input.meta) === null || _input$meta7 === void 0 ? void 0 : _input$meta7.defaultValue) !== undefined && !propHasValue(value)) {
40014
+ var _input$meta8;
40015
+ const isFieldHidden = (input === null || input === void 0 || (_input$meta8 = input.meta) === null || _input$meta8 === void 0 ? void 0 : _input$meta8.hidden) === true;
40016
+ const isFieldDisabled = props.disabled || isDisabled;
40017
+ if (isFieldHidden || isFieldDisabled) {
40018
+ value = input.meta.defaultValue;
40019
+ if (typeof path === 'string') {
40020
+ dot__default["default"].str(path, value, values);
40021
+ }
40015
40022
  }
40016
40023
  }
40017
40024
  const config = {
@@ -29374,21 +29374,27 @@ function DynamicForm({
29374
29374
  }
29375
29375
  }, [data]);
29376
29376
 
29377
- // Initialize default values for hidden fields
29377
+ // Initialize default values for hidden and disabled fields
29378
29378
  React.useEffect(() => {
29379
29379
  if (Object.keys(form).length > 0) {
29380
29380
  const updatedValues = {
29381
29381
  ...values
29382
29382
  };
29383
29383
  let hasChanges = false;
29384
+ const isEditMode = data && (data.id || data._id);
29384
29385
 
29385
- // Process all form fields to set default values for hidden fields
29386
+ // Process all form fields to set default values for hidden and disabled fields
29386
29387
  Object.keys(form).forEach(formKey => {
29387
29388
  Object.keys(form[formKey]).forEach(fieldKey => {
29388
29389
  const field = form[formKey][fieldKey];
29389
- if (field?.meta?.hidden === true && field?.meta?.defaultValue !== undefined) {
29390
- const fieldId = field.dataId || fieldKey;
29391
- if (!propHasValue(updatedValues[fieldId])) {
29390
+ const fieldId = field.dataId || fieldKey;
29391
+
29392
+ // Check if field is disabled
29393
+ const isDisabled = field?.meta?.disableEdit && typeof field?.meta?.disableEdit === 'object' ? isModal ? field.meta.disableEdit.create || field.meta.disableEdit.modal || field?.meta?.disableEdit?.edit && isEditMode : field.meta.disableEdit.create || field.meta.disableEdit.drawer || field?.meta?.disableEdit?.edit && isEditMode : field?.meta?.disableEdit;
29394
+
29395
+ // Set default value for hidden fields or disabled fields with default values
29396
+ if (field?.meta?.defaultValue !== undefined && !propHasValue(updatedValues[fieldId])) {
29397
+ if (field?.meta?.hidden === true || isDisabled) {
29392
29398
  updatedValues[fieldId] = field.meta.defaultValue;
29393
29399
  hasChanges = true;
29394
29400
  }
@@ -29401,7 +29407,7 @@ function DynamicForm({
29401
29407
  MainForm.setFieldsValue(updatedValues);
29402
29408
  }
29403
29409
  }
29404
- }, [form]);
29410
+ }, [form, data, isModal]);
29405
29411
  const setSelectedForm = id => {
29406
29412
  setForms(Forms.map(form => {
29407
29413
  id === form.id ? form.selected = true : form.selected = false;
@@ -29474,11 +29480,15 @@ function DynamicForm({
29474
29480
  }
29475
29481
  value = fileList;
29476
29482
  }
29477
- // Handle default values for hidden fields
29478
- if (input?.meta?.hidden === true && input?.meta?.defaultValue !== undefined && !propHasValue(value)) {
29479
- value = input.meta.defaultValue;
29480
- if (typeof path === 'string') {
29481
- dot__default["default"].str(path, value, values);
29483
+ // Handle default values for hidden fields and disabled fields
29484
+ if (input?.meta?.defaultValue !== undefined && !propHasValue(value)) {
29485
+ const isFieldHidden = input?.meta?.hidden === true;
29486
+ const isFieldDisabled = props.disabled || isDisabled;
29487
+ if (isFieldHidden || isFieldDisabled) {
29488
+ value = input.meta.defaultValue;
29489
+ if (typeof path === 'string') {
29490
+ dot__default["default"].str(path, value, values);
29491
+ }
29482
29492
  }
29483
29493
  }
29484
29494
  const config = {
@@ -0,0 +1,330 @@
1
+ /* Isolated Mapbox GL CSS - Scoped to prevent Leaflet conflicts */
2
+
3
+ /* Mapbox GL Core Styles - Scoped with .mapbox-gl-scope */
4
+ .mapbox-gl-scope .mapboxgl-map {
5
+ font: 12px/20px Helvetica Neue, Arial, Helvetica, sans-serif;
6
+ overflow: hidden;
7
+ position: relative;
8
+ -webkit-tap-highlight-color: rgb(0 0 0/0);
9
+ }
10
+
11
+ .mapbox-gl-scope .mapboxgl-canvas {
12
+ left: 0;
13
+ position: absolute;
14
+ top: 0;
15
+ }
16
+
17
+ .mapbox-gl-scope .mapboxgl-map:-webkit-full-screen {
18
+ height: 100%;
19
+ width: 100%;
20
+ }
21
+
22
+ .mapbox-gl-scope .mapboxgl-canary {
23
+ background-color: salmon;
24
+ }
25
+
26
+ .mapbox-gl-scope .mapboxgl-canvas-container.mapboxgl-interactive,
27
+ .mapbox-gl-scope .mapboxgl-ctrl-group button.mapboxgl-ctrl-compass {
28
+ cursor: grab;
29
+ -webkit-user-select: none;
30
+ user-select: none;
31
+ }
32
+
33
+ .mapbox-gl-scope .mapboxgl-canvas-container.mapboxgl-interactive.mapboxgl-track-pointer {
34
+ cursor: pointer;
35
+ }
36
+
37
+ .mapbox-gl-scope .mapboxgl-canvas-container.mapboxgl-interactive:active,
38
+ .mapbox-gl-scope .mapboxgl-ctrl-group button.mapboxgl-ctrl-compass:active {
39
+ cursor: grabbing;
40
+ }
41
+
42
+ .mapbox-gl-scope .mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate,
43
+ .mapbox-gl-scope .mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate .mapboxgl-canvas {
44
+ touch-action: pan-x pan-y;
45
+ }
46
+
47
+ .mapbox-gl-scope .mapboxgl-canvas-container.mapboxgl-touch-drag-pan,
48
+ .mapbox-gl-scope .mapboxgl-canvas-container.mapboxgl-touch-drag-pan .mapboxgl-canvas {
49
+ touch-action: pinch-zoom;
50
+ }
51
+
52
+ .mapbox-gl-scope .mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate.mapboxgl-touch-drag-pan,
53
+ .mapbox-gl-scope .mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate.mapboxgl-touch-drag-pan .mapboxgl-canvas {
54
+ touch-action: none;
55
+ }
56
+
57
+ /* Control positioning */
58
+ .mapbox-gl-scope .mapboxgl-ctrl-bottom,
59
+ .mapbox-gl-scope .mapboxgl-ctrl-bottom-left,
60
+ .mapbox-gl-scope .mapboxgl-ctrl-bottom-right,
61
+ .mapbox-gl-scope .mapboxgl-ctrl-left,
62
+ .mapbox-gl-scope .mapboxgl-ctrl-right,
63
+ .mapbox-gl-scope .mapboxgl-ctrl-top,
64
+ .mapbox-gl-scope .mapboxgl-ctrl-top-left,
65
+ .mapbox-gl-scope .mapboxgl-ctrl-top-right {
66
+ pointer-events: none;
67
+ position: absolute;
68
+ z-index: 2;
69
+ }
70
+
71
+ .mapbox-gl-scope .mapboxgl-ctrl-top-left {
72
+ left: 0;
73
+ top: 0;
74
+ }
75
+
76
+ .mapbox-gl-scope .mapboxgl-ctrl-top {
77
+ left: 50%;
78
+ top: 0;
79
+ transform: translateX(-50%);
80
+ }
81
+
82
+ .mapbox-gl-scope .mapboxgl-ctrl-top-right {
83
+ right: 0;
84
+ top: 0;
85
+ }
86
+
87
+ .mapbox-gl-scope .mapboxgl-ctrl-right {
88
+ right: 0;
89
+ top: 50%;
90
+ transform: translateY(-50%);
91
+ }
92
+
93
+ .mapbox-gl-scope .mapboxgl-ctrl-bottom-right {
94
+ bottom: 0;
95
+ right: 0;
96
+ }
97
+
98
+ .mapbox-gl-scope .mapboxgl-ctrl-bottom {
99
+ bottom: 0;
100
+ left: 50%;
101
+ transform: translateX(-50%);
102
+ }
103
+
104
+ .mapbox-gl-scope .mapboxgl-ctrl-bottom-left {
105
+ bottom: 0;
106
+ left: 0;
107
+ }
108
+
109
+ .mapbox-gl-scope .mapboxgl-ctrl-left {
110
+ left: 0;
111
+ top: 50%;
112
+ transform: translateY(-50%);
113
+ }
114
+
115
+ .mapbox-gl-scope .mapboxgl-ctrl {
116
+ clear: both;
117
+ pointer-events: auto;
118
+ transform: translate(0);
119
+ }
120
+
121
+ .mapbox-gl-scope .mapboxgl-ctrl-top-left .mapboxgl-ctrl {
122
+ float: left;
123
+ margin: 10px 0 0 10px;
124
+ }
125
+
126
+ .mapbox-gl-scope .mapboxgl-ctrl-top .mapboxgl-ctrl {
127
+ float: left;
128
+ margin: 10px 0;
129
+ }
130
+
131
+ .mapbox-gl-scope .mapboxgl-ctrl-top-right .mapboxgl-ctrl {
132
+ float: right;
133
+ margin: 10px 10px 0 0;
134
+ }
135
+
136
+ .mapbox-gl-scope .mapboxgl-ctrl-bottom-right .mapboxgl-ctrl,
137
+ .mapbox-gl-scope .mapboxgl-ctrl-right .mapboxgl-ctrl {
138
+ float: right;
139
+ margin: 0 10px 10px 0;
140
+ }
141
+
142
+ .mapbox-gl-scope .mapboxgl-ctrl-bottom .mapboxgl-ctrl {
143
+ float: left;
144
+ margin: 10px 0;
145
+ }
146
+
147
+ .mapbox-gl-scope .mapboxgl-ctrl-bottom-left .mapboxgl-ctrl,
148
+ .mapbox-gl-scope .mapboxgl-ctrl-left .mapboxgl-ctrl {
149
+ float: left;
150
+ margin: 0 0 10px 10px;
151
+ }
152
+
153
+ /* Control group styling */
154
+ .mapbox-gl-scope .mapboxgl-ctrl-group {
155
+ background: #fff;
156
+ border-radius: 4px;
157
+ }
158
+
159
+ .mapbox-gl-scope .mapboxgl-ctrl-group:not(:empty) {
160
+ box-shadow: 0 0 0 2px #0000001a;
161
+ }
162
+
163
+ .mapbox-gl-scope .mapboxgl-ctrl-group button {
164
+ background-color: initial;
165
+ border: 0;
166
+ box-sizing: border-box;
167
+ cursor: pointer;
168
+ display: block;
169
+ height: 29px;
170
+ outline: none;
171
+ overflow: hidden;
172
+ padding: 0;
173
+ width: 29px;
174
+ }
175
+
176
+ .mapbox-gl-scope .mapboxgl-ctrl-group button+button {
177
+ border-top: 1px solid #ddd;
178
+ }
179
+
180
+ .mapbox-gl-scope .mapboxgl-ctrl button .mapboxgl-ctrl-icon {
181
+ background-position: 50%;
182
+ background-repeat: no-repeat;
183
+ display: block;
184
+ height: 100%;
185
+ width: 100%;
186
+ }
187
+
188
+ .mapbox-gl-scope .mapboxgl-ctrl-attrib-button:focus,
189
+ .mapbox-gl-scope .mapboxgl-ctrl-group button:focus {
190
+ box-shadow: 0 0 2px 2px #0096ff;
191
+ }
192
+
193
+ .mapbox-gl-scope .mapboxgl-ctrl button:disabled {
194
+ cursor: not-allowed;
195
+ }
196
+
197
+ .mapbox-gl-scope .mapboxgl-ctrl button:disabled .mapboxgl-ctrl-icon {
198
+ opacity: .25;
199
+ }
200
+
201
+ .mapbox-gl-scope .mapboxgl-ctrl-group button:first-child {
202
+ border-radius: 4px 4px 0 0;
203
+ }
204
+
205
+ .mapbox-gl-scope .mapboxgl-ctrl-group button:last-child {
206
+ border-radius: 0 0 4px 4px;
207
+ }
208
+
209
+ .mapbox-gl-scope .mapboxgl-ctrl-group button:only-child {
210
+ border-radius: inherit;
211
+ }
212
+
213
+ .mapbox-gl-scope .mapboxgl-ctrl button:not(:disabled):hover {
214
+ background-color: #0000000d;
215
+ }
216
+
217
+ /* Marker styles */
218
+ .mapbox-gl-scope .mapboxgl-marker {
219
+ position: absolute;
220
+ z-index: 1;
221
+ }
222
+
223
+ .mapbox-gl-scope .mapboxgl-marker svg {
224
+ display: block;
225
+ }
226
+
227
+ /* Popup styles */
228
+ .mapbox-gl-scope .mapboxgl-popup {
229
+ position: absolute;
230
+ text-align: center;
231
+ margin-bottom: 20px;
232
+ }
233
+
234
+ .mapbox-gl-scope .mapboxgl-popup-content-wrapper {
235
+ padding: 1px;
236
+ text-align: left;
237
+ border-radius: 12px;
238
+ }
239
+
240
+ .mapbox-gl-scope .mapboxgl-popup-content {
241
+ margin: 13px 24px 13px 20px;
242
+ line-height: 1.3;
243
+ font-size: 13px;
244
+ min-height: 1px;
245
+ }
246
+
247
+ .mapbox-gl-scope .mapboxgl-popup-content p {
248
+ margin: 17px 0;
249
+ }
250
+
251
+ .mapbox-gl-scope .mapboxgl-popup-tip-container {
252
+ width: 40px;
253
+ height: 20px;
254
+ position: absolute;
255
+ left: 50%;
256
+ margin-top: -1px;
257
+ margin-left: -20px;
258
+ overflow: hidden;
259
+ pointer-events: none;
260
+ }
261
+
262
+ .mapbox-gl-scope .mapboxgl-popup-tip {
263
+ width: 17px;
264
+ height: 17px;
265
+ padding: 1px;
266
+ margin: -10px auto 0;
267
+ pointer-events: auto;
268
+ -webkit-transform: rotate(45deg);
269
+ -moz-transform: rotate(45deg);
270
+ -ms-transform: rotate(45deg);
271
+ transform: rotate(45deg);
272
+ }
273
+
274
+ .mapbox-gl-scope .mapboxgl-popup-content-wrapper,
275
+ .mapbox-gl-scope .mapboxgl-popup-tip {
276
+ background: white;
277
+ color: #333;
278
+ box-shadow: 0 3px 14px rgba(0, 0, 0, 0.4);
279
+ }
280
+
281
+ .mapbox-gl-scope .mapboxgl-popup-close-button {
282
+ position: absolute;
283
+ top: 0;
284
+ right: 0;
285
+ border: none;
286
+ text-align: center;
287
+ width: 24px;
288
+ height: 24px;
289
+ font: 16px/24px Tahoma, Verdana, sans-serif;
290
+ color: #757575;
291
+ text-decoration: none;
292
+ background: transparent;
293
+ }
294
+
295
+ .mapbox-gl-scope .mapboxgl-popup-close-button:hover,
296
+ .mapbox-gl-scope .mapboxgl-popup-close-button:focus {
297
+ color: #585858;
298
+ }
299
+
300
+ /* Attribution */
301
+ .mapbox-gl-scope .mapboxgl-ctrl-attribution {
302
+ background: #fff;
303
+ background: rgba(255, 255, 255, 0.8);
304
+ margin: 0;
305
+ }
306
+
307
+ .mapbox-gl-scope .mapboxgl-ctrl-attribution,
308
+ .mapbox-gl-scope .mapboxgl-ctrl-scale-line {
309
+ padding: 0 5px;
310
+ color: #333;
311
+ line-height: 1.4;
312
+ }
313
+
314
+ .mapbox-gl-scope .mapboxgl-ctrl-attribution a {
315
+ text-decoration: none;
316
+ }
317
+
318
+ .mapbox-gl-scope .mapboxgl-ctrl-attribution a:hover,
319
+ .mapbox-gl-scope .mapboxgl-ctrl-attribution a:focus {
320
+ text-decoration: underline;
321
+ }
322
+
323
+ /* Hide attribution by default */
324
+ .mapbox-gl-scope .mapboxgl-ctrl-attribution {
325
+ display: none !important;
326
+ }
327
+
328
+ .mapbox-gl-scope .mapboxgl-ctrl-logo {
329
+ display: none !important;
330
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.751",
3
+ "version": "0.6.752",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -168,19 +168,29 @@ export default function DynamicForm({
168
168
  }
169
169
  }, [data]);
170
170
 
171
- // Initialize default values for hidden fields
171
+ // Initialize default values for hidden and disabled fields
172
172
  useEffect(() => {
173
173
  if (Object.keys(form).length > 0) {
174
174
  const updatedValues = { ...values };
175
175
  let hasChanges = false;
176
+ const isEditMode = data && (data.id || data._id);
176
177
 
177
- // Process all form fields to set default values for hidden fields
178
+ // Process all form fields to set default values for hidden and disabled fields
178
179
  Object.keys(form).forEach(formKey => {
179
180
  Object.keys(form[formKey]).forEach(fieldKey => {
180
181
  const field = form[formKey][fieldKey];
181
- if (field?.meta?.hidden === true && field?.meta?.defaultValue !== undefined) {
182
- const fieldId = field.dataId || fieldKey;
183
- if (!propHasValue(updatedValues[fieldId])) {
182
+ const fieldId = field.dataId || fieldKey;
183
+
184
+ // Check if field is disabled
185
+ const isDisabled = (field?.meta?.disableEdit && typeof field?.meta?.disableEdit === 'object')
186
+ ? isModal
187
+ ? field.meta.disableEdit.create || field.meta.disableEdit.modal || (field?.meta?.disableEdit?.edit && isEditMode)
188
+ : field.meta.disableEdit.create || field.meta.disableEdit.drawer || (field?.meta?.disableEdit?.edit && isEditMode)
189
+ : field?.meta?.disableEdit;
190
+
191
+ // Set default value for hidden fields or disabled fields with default values
192
+ if (field?.meta?.defaultValue !== undefined && !propHasValue(updatedValues[fieldId])) {
193
+ if (field?.meta?.hidden === true || isDisabled) {
184
194
  updatedValues[fieldId] = field.meta.defaultValue;
185
195
  hasChanges = true;
186
196
  }
@@ -194,7 +204,7 @@ export default function DynamicForm({
194
204
  MainForm.setFieldsValue(updatedValues);
195
205
  }
196
206
  }
197
- }, [form]);
207
+ }, [form, data, isModal]);
198
208
 
199
209
  const setSelectedForm = (id) => {
200
210
  setForms(Forms.map(form => {
@@ -295,11 +305,16 @@ export default function DynamicForm({
295
305
  }
296
306
  value = fileList;
297
307
  }
298
- // Handle default values for hidden fields
299
- if (input?.meta?.hidden === true && input?.meta?.defaultValue !== undefined && !propHasValue(value)) {
300
- value = input.meta.defaultValue;
301
- if (typeof path === 'string') {
302
- dot.str(path, value, values);
308
+ // Handle default values for hidden fields and disabled fields
309
+ if (input?.meta?.defaultValue !== undefined && !propHasValue(value)) {
310
+ const isFieldHidden = input?.meta?.hidden === true;
311
+ const isFieldDisabled = props.disabled || isDisabled;
312
+
313
+ if (isFieldHidden || isFieldDisabled) {
314
+ value = input.meta.defaultValue;
315
+ if (typeof path === 'string') {
316
+ dot.str(path, value, values);
317
+ }
303
318
  }
304
319
  }
305
320