datastake-daf 0.6.754 → 0.6.755

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.
@@ -10061,42 +10061,37 @@ const handleDataLinkGroupWithTableKeys = _ref2 => {
10061
10061
  }
10062
10062
  };
10063
10063
 
10064
- const handleDataLinkWithTableKeys = _ref => {
10065
- var _inputConfig$meta, _inputConfig$meta3, _inputConfig$meta4, _inputConfig$meta5;
10066
- let {
10067
- inputConfig,
10068
- inputKey,
10069
- value,
10070
- level,
10071
- t,
10072
- rootForm,
10073
- allData,
10074
- user,
10075
- getApiBaseUrl = () => {},
10076
- getAppHeader = () => {},
10077
- app,
10078
- TreeNodeComponent
10079
- } = _ref;
10080
- 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)) {
10064
+ const handleDataLinkWithTableKeys = ({
10065
+ inputConfig,
10066
+ inputKey,
10067
+ value,
10068
+ level,
10069
+ t,
10070
+ rootForm,
10071
+ allData,
10072
+ user,
10073
+ getApiBaseUrl = () => {},
10074
+ getAppHeader = () => {},
10075
+ app,
10076
+ TreeNodeComponent
10077
+ }) => {
10078
+ if (inputConfig?.type !== 'dataLink' || !inputConfig?.meta?.tableKeys) {
10081
10079
  return null;
10082
10080
  }
10083
10081
  const tableKeys = inputConfig.meta.tableKeys;
10084
- const isAjaxModal = React.useMemo(() => {
10085
- var _inputConfig$meta2;
10086
- return !!(inputConfig !== null && inputConfig !== void 0 && (_inputConfig$meta2 = inputConfig.meta) !== null && _inputConfig$meta2 !== void 0 && _inputConfig$meta2.namespace);
10087
- }, [inputConfig]);
10082
+ const isAjaxModal = React.useMemo(() => !!inputConfig?.meta?.namespace, [inputConfig]);
10088
10083
  const ajaxModalValues = useAjaxModal$2({
10089
10084
  name: inputKey,
10090
10085
  user,
10091
- namespace: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta3 = inputConfig.meta) === null || _inputConfig$meta3 === void 0 ? void 0 : _inputConfig$meta3.namespace,
10092
- skipFetch: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta4 = inputConfig.meta) === null || _inputConfig$meta4 === void 0 ? void 0 : _inputConfig$meta4.skipFetch,
10086
+ namespace: inputConfig?.meta?.namespace,
10087
+ skipFetch: inputConfig?.meta?.skipFetch,
10093
10088
  isAjaxModal,
10094
- formScope: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta5 = inputConfig.meta) === null || _inputConfig$meta5 === void 0 ? void 0 : _inputConfig$meta5.formScope,
10089
+ formScope: inputConfig?.meta?.formScope,
10095
10090
  APP: app,
10096
10091
  apiBaseUrl: getApiBaseUrl(),
10097
10092
  _getAppHeader: getAppHeader
10098
10093
  });
10099
- const dataLinkForm = ajaxModalValues === null || ajaxModalValues === void 0 ? void 0 : ajaxModalValues.form;
10094
+ const dataLinkForm = ajaxModalValues?.form;
10100
10095
  const createInputsAndValues = item => {
10101
10096
  const inputs = {};
10102
10097
  const values = {};
@@ -10109,20 +10104,19 @@ const handleDataLinkWithTableKeys = _ref => {
10109
10104
  };
10110
10105
  const isUploadFieldEmpty = (fieldKey, itemToCheck) => {
10111
10106
  if (uploadTypeFields.includes(fieldKey)) {
10112
- const itemValue = itemToCheck === null || itemToCheck === void 0 ? void 0 : itemToCheck[fieldKey];
10107
+ const itemValue = itemToCheck?.[fieldKey];
10113
10108
  return itemValue === undefined || itemValue === null || Array.isArray(itemValue) && itemValue.length === 0;
10114
10109
  }
10115
10110
  return false;
10116
10111
  };
10117
10112
  const processedTableKeys = processConditionalTableKeys(tableKeys, item);
10118
10113
  processedTableKeys.filter(tableKey => tableKey !== 'datastakeId').filter(tableKey => !isUploadFieldEmpty(tableKey, item)).forEach(tableKey => {
10119
- var _dataLinkForm$identif;
10120
- 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]);
10114
+ const formInputConfig = dataLinkForm?.[tableKey] || dataLinkForm?.['identification']?.[tableKey];
10121
10115
  if (formInputConfig) {
10122
- var _item$linking, _formInputConfig$meta, _formInputConfig$tabl;
10123
- inputs[tableKey] = _objectSpread2(_objectSpread2({}, formInputConfig), {}, {
10116
+ inputs[tableKey] = {
10117
+ ...formInputConfig,
10124
10118
  label: uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : formInputConfig.label || formInputConfig.tableLabel || tableKey
10125
- });
10119
+ };
10126
10120
  if (formInputConfig.label && typeof formInputConfig.label === 'object') {
10127
10121
  const dynamicLabelKeys = Object.keys(formInputConfig.label);
10128
10122
  let resolvedLabel = null;
@@ -10130,7 +10124,7 @@ const handleDataLinkWithTableKeys = _ref => {
10130
10124
  const parts = labelKey.split(' is ');
10131
10125
  if (parts.length === 2) {
10132
10126
  const [conditionKey, conditionValue] = parts;
10133
- if ((item === null || item === void 0 ? void 0 : item[conditionKey]) === conditionValue) {
10127
+ if (item?.[conditionKey] === conditionValue) {
10134
10128
  resolvedLabel = formInputConfig.label[labelKey];
10135
10129
  break;
10136
10130
  }
@@ -10138,17 +10132,16 @@ const handleDataLinkWithTableKeys = _ref => {
10138
10132
  }
10139
10133
  inputs[tableKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] || (uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : tableKey);
10140
10134
  }
10141
- 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]);
10135
+ values[tableKey] = item?.linking?.SCL?.[item?.[tableKey]]?.name || item[formInputConfig?.meta?.onNewSetValueKey] || item?.[formInputConfig?.tableLabel?.toLowerCase()] || item?.[tableKey];
10142
10136
  } else {
10143
- var _item$linking2;
10144
10137
  inputs[tableKey] = {
10145
10138
  label: uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : tableKey,
10146
- type: inputConfig === null || inputConfig === void 0 ? void 0 : inputConfig.type
10139
+ type: inputConfig?.type
10147
10140
  };
10148
- 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]);
10141
+ values[tableKey] = item?.linking?.SCL?.[item?.[tableKey]]?.name || item?.[tableKey];
10149
10142
  }
10150
10143
  });
10151
- if (dataLinkForm !== null && dataLinkForm !== void 0 && dataLinkForm.identification && typeof dataLinkForm.identification === 'object') {
10144
+ if (dataLinkForm?.identification && typeof dataLinkForm.identification === 'object') {
10152
10145
  Object.keys(dataLinkForm.identification).filter(fieldKey => {
10153
10146
  if (uploadTypeFields.includes(fieldKey)) {
10154
10147
  return !isUploadFieldEmpty(fieldKey, item);
@@ -10158,11 +10151,11 @@ const handleDataLinkWithTableKeys = _ref => {
10158
10151
  const formInputConfig = dataLinkForm.identification[fieldKey];
10159
10152
  return formInputConfig && typeof formInputConfig === 'object' && !Array.isArray(formInputConfig);
10160
10153
  }).forEach(fieldKey => {
10161
- var _item$linking3, _formInputConfig$tabl2;
10162
10154
  const formInputConfig = dataLinkForm.identification[fieldKey];
10163
- inputs[fieldKey] = _objectSpread2(_objectSpread2({}, formInputConfig), {}, {
10155
+ inputs[fieldKey] = {
10156
+ ...formInputConfig,
10164
10157
  label: uploadTypeFields.includes(fieldKey) ? uploadTypeLabels[fieldKey] : formInputConfig.label || formInputConfig.tableLabel || fieldKey
10165
- });
10158
+ };
10166
10159
  if (formInputConfig.label && typeof formInputConfig.label === 'object') {
10167
10160
  const dynamicLabelKeys = Object.keys(formInputConfig.label);
10168
10161
  let resolvedLabel = null;
@@ -10170,7 +10163,7 @@ const handleDataLinkWithTableKeys = _ref => {
10170
10163
  const parts = labelKey.split(' is ');
10171
10164
  if (parts.length === 2) {
10172
10165
  const [conditionKey, conditionValue] = parts;
10173
- if ((item === null || item === void 0 ? void 0 : item[conditionKey]) === conditionValue) {
10166
+ if (item?.[conditionKey] === conditionValue) {
10174
10167
  resolvedLabel = formInputConfig.label[labelKey];
10175
10168
  break;
10176
10169
  }
@@ -10178,7 +10171,7 @@ const handleDataLinkWithTableKeys = _ref => {
10178
10171
  }
10179
10172
  inputs[fieldKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] || (uploadTypeFields.includes(fieldKey) ? uploadTypeLabels[fieldKey] : fieldKey);
10180
10173
  }
10181
- 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]);
10174
+ values[fieldKey] = item?.linking?.SCL?.[item?.[fieldKey]]?.name || item?.[formInputConfig?.tableLabel?.toLowerCase()] || item?.[fieldKey];
10182
10175
  });
10183
10176
  }
10184
10177
  return {
@@ -10188,7 +10181,7 @@ const handleDataLinkWithTableKeys = _ref => {
10188
10181
  };
10189
10182
  if (Array.isArray(value)) {
10190
10183
  return value.map((item, itemIndex) => {
10191
- const datastakeIdValue = item === null || item === void 0 ? void 0 : item.datastakeId;
10184
+ const datastakeIdValue = item?.datastakeId;
10192
10185
  const {
10193
10186
  inputs,
10194
10187
  values
@@ -10197,9 +10190,9 @@ const handleDataLinkWithTableKeys = _ref => {
10197
10190
  return null;
10198
10191
  }
10199
10192
  return /*#__PURE__*/jsxRuntime.jsx(TreeNodeComponent, {
10200
- nodeKey: datastakeIdValue || t("No ID ".concat(itemIndex + 1)),
10193
+ nodeKey: datastakeIdValue || t(`No ID ${itemIndex + 1}`),
10201
10194
  config: {
10202
- label: datastakeIdValue || t("No ID ".concat(itemIndex + 1)),
10195
+ label: datastakeIdValue || t(`No ID ${itemIndex + 1}`),
10203
10196
  type: 'custom-datalink',
10204
10197
  inputs: inputs
10205
10198
  },
@@ -10213,10 +10206,10 @@ const handleDataLinkWithTableKeys = _ref => {
10213
10206
  getApiBaseUrl: getApiBaseUrl,
10214
10207
  getAppHeader: getAppHeader,
10215
10208
  app: app
10216
- }, "".concat(inputKey, "-").concat(itemIndex));
10209
+ }, `${inputKey}-${itemIndex}`);
10217
10210
  });
10218
10211
  } else {
10219
- const datastakeIdValue = value === null || value === void 0 ? void 0 : value.datastakeId;
10212
+ const datastakeIdValue = value?.datastakeId;
10220
10213
  const {
10221
10214
  inputs,
10222
10215
  values
@@ -10241,7 +10234,7 @@ const handleDataLinkWithTableKeys = _ref => {
10241
10234
  getApiBaseUrl: getApiBaseUrl,
10242
10235
  getAppHeader: getAppHeader,
10243
10236
  app: app
10244
- }, "".concat(inputKey, "-single"));
10237
+ }, `${inputKey}-single`);
10245
10238
  }
10246
10239
  };
10247
10240
 
@@ -10291,20 +10284,22 @@ const handleGroupChildren = _ref => {
10291
10284
  });
10292
10285
  };
10293
10286
 
10294
- const GroupInputsHandler = ({
10295
- config,
10296
- allData,
10297
- value
10298
- }) => {
10287
+ const GroupInputsHandler = _ref => {
10288
+ let {
10289
+ config,
10290
+ allData,
10291
+ value
10292
+ } = _ref;
10299
10293
  const renderGroupInputsValue = () => {
10300
- if (!config?.inputs) return '';
10294
+ if (!(config !== null && config !== void 0 && config.inputs)) return '';
10301
10295
  const inputKeys = Object.keys(config.inputs).sort((a, b) => {
10302
- const positionA = config.inputs[a]?.position || 0;
10303
- const positionB = config.inputs[b]?.position || 0;
10296
+ var _config$inputs$a, _config$inputs$b;
10297
+ const positionA = ((_config$inputs$a = config.inputs[a]) === null || _config$inputs$a === void 0 ? void 0 : _config$inputs$a.position) || 0;
10298
+ const positionB = ((_config$inputs$b = config.inputs[b]) === null || _config$inputs$b === void 0 ? void 0 : _config$inputs$b.position) || 0;
10304
10299
  return positionA - positionB;
10305
10300
  });
10306
10301
  const values = inputKeys.map(inputKey => {
10307
- let inputValue = allData?.[inputKey] || value?.[inputKey];
10302
+ let inputValue = (allData === null || allData === void 0 ? void 0 : allData[inputKey]) || (value === null || value === void 0 ? void 0 : value[inputKey]);
10308
10303
  const inputConfig = config.inputs[inputKey];
10309
10304
  if (inputValue === null || inputValue === undefined || inputValue === '') {
10310
10305
  return '';
@@ -10317,7 +10312,7 @@ const GroupInputsHandler = ({
10317
10312
  return JSON.stringify(inputValue);
10318
10313
  }
10319
10314
  } else {
10320
- if (inputConfig?.options) {
10315
+ if (inputConfig !== null && inputConfig !== void 0 && inputConfig.options) {
10321
10316
  const option = findOptions(inputValue, inputConfig.options);
10322
10317
  return option || String(inputValue);
10323
10318
  }
@@ -10422,12 +10417,11 @@ const AjaxSubGroup$2 = ({
10422
10417
  };
10423
10418
 
10424
10419
  const handleAjaxSubGroupChildren = props => {
10425
- if (props.config?.type !== 'ajaxSubGroup' || !Array.isArray(props.value)) {
10420
+ var _props$config;
10421
+ if (((_props$config = props.config) === null || _props$config === void 0 ? void 0 : _props$config.type) !== 'ajaxSubGroup' || !Array.isArray(props.value)) {
10426
10422
  return null;
10427
10423
  }
10428
- return [/*#__PURE__*/jsxRuntime.jsx(AjaxSubGroup$2, {
10429
- ...props
10430
- }, "ajax-subgroup")];
10424
+ return [/*#__PURE__*/jsxRuntime.jsx(AjaxSubGroup$2, _objectSpread2({}, props), "ajax-subgroup")];
10431
10425
  };
10432
10426
 
10433
10427
  const TreeNode = _ref => {