blixify-ui-web 0.4.208 → 0.4.210

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.
@@ -88,6 +88,7 @@ var loading_1 = require("../display/loading");
88
88
  var table_1 = require("../display/table");
89
89
  var address_1 = require("../input/address");
90
90
  var canvas_1 = require("../input/canvas");
91
+ var checkbox_1 = require("../input/checkbox");
91
92
  var datePicker_1 = require("../input/datePicker");
92
93
  var markdown_1 = require("../input/markdown");
93
94
  var select_1 = require("../input/select");
@@ -108,6 +109,15 @@ var additionalSelect = (react_1.default.createElement("div", { className: "flex
108
109
  //=====================================================================================
109
110
  //SECTION: Update Feature used across Data Components
110
111
  //=====================================================================================
112
+ // Blob URL cache to prevent memory leaks from creating new URLs on every render
113
+ var blobUrlCache = new WeakMap();
114
+ var getBlobUrlForFile = function (file) {
115
+ if (!blobUrlCache.has(file)) {
116
+ var blobUrl = URL.createObjectURL(file);
117
+ blobUrlCache.set(file, blobUrl);
118
+ }
119
+ return blobUrlCache.get(file);
120
+ };
111
121
  var handleCastDataAttribute = function (model, value, clonedSelectedData, server, force) {
112
122
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
113
123
  switch (model.type) {
@@ -304,10 +314,33 @@ var handleCastDataAttribute = function (model, value, clonedSelectedData, server
304
314
  clonedSelectedData[model.id] = value[model.id].filter(function (eachVal) { return eachVal !== "others"; });
305
315
  break;
306
316
  case "canvas":
307
- if (model.defaultValue)
308
- clonedSelectedData[model.id] = (_2 = value[model.id]) !== null && _2 !== void 0 ? _2 : model.defaultValue;
309
- else
310
- clonedSelectedData[model.id] = value[model.id];
317
+ var canvasValue = value[model.id];
318
+ var useNewFormat = model.enableDraw || model.enableImageUpload;
319
+ if (useNewFormat) {
320
+ // New format: normalize to { texts: [], drawings: [], backgroundImage?: { fileName, token } }
321
+ if (model.defaultValue) {
322
+ var defaultValue = model.defaultValue;
323
+ clonedSelectedData[model.id] =
324
+ Array.isArray(defaultValue) || !defaultValue
325
+ ? { texts: defaultValue !== null && defaultValue !== void 0 ? defaultValue : [], drawings: [] }
326
+ : defaultValue;
327
+ }
328
+ else if (canvasValue) {
329
+ clonedSelectedData[model.id] = Array.isArray(canvasValue)
330
+ ? { texts: canvasValue, drawings: [] }
331
+ : canvasValue;
332
+ }
333
+ else {
334
+ clonedSelectedData[model.id] = { texts: [], drawings: [] };
335
+ }
336
+ }
337
+ else {
338
+ // Old format: keep as texts[] array
339
+ if (model.defaultValue)
340
+ clonedSelectedData[model.id] = (_2 = value[model.id]) !== null && _2 !== void 0 ? _2 : model.defaultValue;
341
+ else
342
+ clonedSelectedData[model.id] = value[model.id];
343
+ }
311
344
  break;
312
345
  case "ganttchart":
313
346
  if (model.defaultValue)
@@ -761,7 +794,7 @@ var renderEachListObject = function (type, selectedModelId, model, selectedData,
761
794
  title: eachObj.name,
762
795
  }); })) !== null && _d !== void 0 ? _d : [];
763
796
  clonedSelectedData[selectedModelId].map(function (eachObject) {
764
- var _a, _b;
797
+ var _a, _b, _c, _d, _e, _f, _g;
765
798
  var eachNewList = {
766
799
  id: "",
767
800
  title: "",
@@ -917,6 +950,59 @@ var renderEachListObject = function (type, selectedModelId, model, selectedData,
917
950
  eachNewTable[eachKey] = (react_1.default.createElement("div", { className: "mt-2 prose prose-sm [&>p]:leading-normal [&>p]:mb-0 [&>p]:mt-0", dangerouslySetInnerHTML: { __html: renderedHtml } }));
918
951
  }
919
952
  break;
953
+ case "canvas":
954
+ // Render Canvas component for listObject items
955
+ var canvasValue = eachValue;
956
+ var useNewFormat = (model_1 === null || model_1 === void 0 ? void 0 : model_1.enableDraw) || (model_1 === null || model_1 === void 0 ? void 0 : model_1.enableImageUpload);
957
+ // Normalize canvas data structure
958
+ var normalizedTexts = [];
959
+ var normalizedDrawings = [];
960
+ var backgroundImageUrl = undefined;
961
+ if (useNewFormat) {
962
+ // New format: expect { texts: [], drawings: [], backgroundImage?: { fileName, token } }
963
+ if (Array.isArray(canvasValue) || !canvasValue) {
964
+ normalizedTexts = canvasValue !== null && canvasValue !== void 0 ? canvasValue : [];
965
+ normalizedDrawings = [];
966
+ }
967
+ else {
968
+ normalizedTexts = (_c = canvasValue.texts) !== null && _c !== void 0 ? _c : [];
969
+ normalizedDrawings = (_d = canvasValue.drawings) !== null && _d !== void 0 ? _d : [];
970
+ // Build backgroundImageUrl if token exists, or create blob URL if file exists
971
+ // Skip if _cleared flag is set (was cleared via "Clear All")
972
+ if ((model_1 === null || model_1 === void 0 ? void 0 : model_1.enableImageUpload) &&
973
+ canvasValue.backgroundImage &&
974
+ !canvasValue.backgroundImage._cleared) {
975
+ if (canvasValue.backgroundImage.token) {
976
+ // Image has been uploaded - use token to construct URL
977
+ backgroundImageUrl = (0, blobModule_1.renderImageUrlFromPath)(devSettings.imageEndpoint, model_1.imageCollectionName + "%2F" + dataId, selectedModelId +
978
+ "%2F" +
979
+ eachObject.id +
980
+ "%2F" +
981
+ model_1.id, canvasValue.backgroundImage.fileName, canvasValue.backgroundImage.token, devSettings.bucketName);
982
+ }
983
+ else if (canvasValue.backgroundImage.file &&
984
+ canvasValue.backgroundImage.file instanceof File) {
985
+ // Image hasn't been uploaded yet - use cached blob URL from File object
986
+ backgroundImageUrl = getBlobUrlForFile(canvasValue.backgroundImage.file);
987
+ }
988
+ }
989
+ }
990
+ }
991
+ else {
992
+ // Old format: expect texts[] array
993
+ normalizedTexts = Array.isArray(canvasValue)
994
+ ? canvasValue
995
+ : (_e = canvasValue === null || canvasValue === void 0 ? void 0 : canvasValue.texts) !== null && _e !== void 0 ? _e : [];
996
+ normalizedDrawings = [];
997
+ }
998
+ // For listObject, canvas in list/table view should always be readOnly
999
+ // (editing happens in Modal, not in the list/table view)
1000
+ // Use pointer cursor since the entire listObject item is clickable
1001
+ eachNewList[eachKey] = (react_1.default.createElement("div", { className: "w-full my-2" },
1002
+ react_1.default.createElement(canvas_1.Canvas, { label: (_f = model_1 === null || model_1 === void 0 ? void 0 : model_1.name) !== null && _f !== void 0 ? _f : "", texts: normalizedTexts, drawings: normalizedDrawings, backgroundImageUrl: backgroundImageUrl, enableDraw: false, enableImageUpload: false, readOnly: true, cursor: "pointer" })));
1003
+ eachNewTable[eachKey] = (react_1.default.createElement("div", { className: "w-full my-2" },
1004
+ react_1.default.createElement(canvas_1.Canvas, { label: (_g = model_1 === null || model_1 === void 0 ? void 0 : model_1.name) !== null && _g !== void 0 ? _g : "", texts: normalizedTexts, drawings: normalizedDrawings, backgroundImageUrl: backgroundImageUrl, enableDraw: false, enableImageUpload: false, readOnly: true, cursor: "pointer" })));
1005
+ break;
920
1006
  case "address":
921
1007
  case "object":
922
1008
  break;
@@ -933,8 +1019,8 @@ var renderEachListObject = function (type, selectedModelId, model, selectedData,
933
1019
  }
934
1020
  }
935
1021
  };
936
- for (var _i = 0, _c = Object.entries(eachObject); _i < _c.length; _i++) {
937
- var _d = _c[_i], eachKey = _d[0], eachValue = _d[1];
1022
+ for (var _i = 0, _h = Object.entries(eachObject); _i < _h.length; _i++) {
1023
+ var _j = _h[_i], eachKey = _j[0], eachValue = _j[1];
938
1024
  _loop_1(eachKey, eachValue);
939
1025
  }
940
1026
  if (!checkIdExists_1) {
@@ -1064,7 +1150,7 @@ var renderDataTemplateForm = function (data, model, formInputRef, updateMethod,
1064
1150
  });
1065
1151
  var clonedSelectedData = (0, exports.handleClonedDataAttribute)(data, model, (_d = (_c = referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.devSettings) === null || _c === void 0 ? void 0 : _c.server) !== null && _d !== void 0 ? _d : "mongoServer", false, isRemainId);
1066
1152
  filteredModel.forEach(function (eachAttribute, index) {
1067
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29;
1153
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37;
1068
1154
  var shouldShow = (0, exports.renderShowCondition)(eachAttribute, clonedSelectedData, isForm);
1069
1155
  if (!shouldShow)
1070
1156
  return;
@@ -1282,25 +1368,27 @@ var renderDataTemplateForm = function (data, model, formInputRef, updateMethod,
1282
1368
  break;
1283
1369
  case "boolean":
1284
1370
  if (eachAttribute === null || eachAttribute === void 0 ? void 0 : eachAttribute.enableCheckbox) {
1285
- var value_1 = clonedSelectedData[eachAttribute.id];
1286
- inputList[groupId].push(react_1.default.createElement(react_1.default.Fragment, null,
1287
- react_1.default.createElement("div", { className: "flex flex-row items-center h-full space-x-5 mx-auto" },
1288
- react_1.default.createElement("label", { className: "block text-sm font-medium" },
1289
- label,
1290
- " ",
1291
- labelExtra),
1292
- react_1.default.createElement("input", { key: "checkbox_".concat(eachAttribute.id, "_").concat(index), type: "checkbox", ref: eachAttribute.optional
1293
- ? null
1294
- : formInputRef[(_u = eachAttribute.refIndex) !== null && _u !== void 0 ? _u : index], id: eachAttribute.id, checked: value_1, onClick: function () {
1295
- var _a;
1296
- updateMethod.handleOnChangeSelect(eachAttribute.id, !value_1);
1297
- if ((cellInput === null || cellInput === void 0 ? void 0 : cellInput.active) && cellInput.onBlur) {
1298
- cellInput.onBlur(__assign(__assign({}, clonedSelectedData), (_a = {}, _a[eachAttribute.id] = !value_1, _a)));
1299
- }
1300
- }, disabled: disabled }))));
1371
+ var value = (_u = clonedSelectedData[eachAttribute.id]) !== null && _u !== void 0 ? _u : false;
1372
+ // Use shared Checkbox component so validation can run via handleSubmit
1373
+ inputList[groupId].push(react_1.default.createElement("div", { className: "flex flex-row h-full space-x-5 mx-auto items-center" },
1374
+ react_1.default.createElement(checkbox_1.Checkbox, { ref: eachAttribute.optional
1375
+ ? null
1376
+ : formInputRef[(_v = eachAttribute.refIndex) !== null && _v !== void 0 ? _v : index], id: eachAttribute.id, itemList: [
1377
+ {
1378
+ key: "checked",
1379
+ label: label,
1380
+ },
1381
+ ], selectItemList: value ? ["checked"] : [], optional: eachAttribute.optional, className: "flex items-center space-x-2", inputClassName: "", onChange: function (list) {
1382
+ var _a;
1383
+ var checkedValue = list.includes("checked");
1384
+ updateMethod.handleOnChangeSelect(eachAttribute.id, checkedValue);
1385
+ if ((cellInput === null || cellInput === void 0 ? void 0 : cellInput.active) && cellInput.onBlur) {
1386
+ cellInput.onBlur(__assign(__assign({}, clonedSelectedData), (_a = {}, _a[eachAttribute.id] = checkedValue, _a)));
1387
+ }
1388
+ }, darkMode: false })));
1301
1389
  }
1302
1390
  else if (eachAttribute.enableRadioButtons) {
1303
- var value = (_v = clonedSelectedData[eachAttribute.id]) === null || _v === void 0 ? void 0 : _v.toString();
1391
+ var value = (_w = clonedSelectedData[eachAttribute.id]) === null || _w === void 0 ? void 0 : _w.toString();
1304
1392
  inputList[groupId].push(react_1.default.createElement(react_1.default.Fragment, null,
1305
1393
  react_1.default.createElement("label", { className: "block text-sm font-medium" },
1306
1394
  eachAttribute.name,
@@ -1320,10 +1408,10 @@ var renderDataTemplateForm = function (data, model, formInputRef, updateMethod,
1320
1408
  }, horizontal: true })));
1321
1409
  }
1322
1410
  else {
1323
- var value = (_w = clonedSelectedData[eachAttribute.id]) === null || _w === void 0 ? void 0 : _w.toString();
1411
+ var value = (_x = clonedSelectedData[eachAttribute.id]) === null || _x === void 0 ? void 0 : _x.toString();
1324
1412
  inputList[groupId].push(react_1.default.createElement(select_1.Select, { ref: eachAttribute.optional
1325
1413
  ? null
1326
- : formInputRef[(_x = eachAttribute.refIndex) !== null && _x !== void 0 ? _x : index], id: eachAttribute.id, value: value, label: label, subLabel: subLabel, infoElement: (cellInput === null || cellInput === void 0 ? void 0 : cellInput.active) ? undefined : infoElement, labelExtra: labelExtra, placeholder: placeholder !== eachAttribute.name
1414
+ : formInputRef[(_y = eachAttribute.refIndex) !== null && _y !== void 0 ? _y : index], id: eachAttribute.id, value: value, label: label, subLabel: subLabel, infoElement: (cellInput === null || cellInput === void 0 ? void 0 : cellInput.active) ? undefined : infoElement, labelExtra: labelExtra, placeholder: placeholder !== eachAttribute.name
1327
1415
  ? placeholder
1328
1416
  : "Select An Option", optional: eachAttribute.optional, disableKeyboard: eachAttribute.disabledKeyboardSearch, options: [
1329
1417
  {
@@ -1356,13 +1444,13 @@ var renderDataTemplateForm = function (data, model, formInputRef, updateMethod,
1356
1444
  : (0, blobModule_1.renderImageUrlFromPath)(fileProps === null || fileProps === void 0 ? void 0 : fileProps.imageEndpoint, eachAttribute.imageCollectionName + "%2F" + props.id, objectProps === null || objectProps === void 0 ? void 0 : objectProps.selectedObjectStructureId, eachAttribute.imageFileName, clonedSelectedData[eachAttribute.id], fileProps === null || fileProps === void 0 ? void 0 : fileProps.imageBucketName)
1357
1445
  : (0, blobModule_1.renderImageUrlFromPath)(fileProps === null || fileProps === void 0 ? void 0 : fileProps.imageEndpoint, eachAttribute.imageCollectionName, props === null || props === void 0 ? void 0 : props.id, eachAttribute.imageFileName, clonedSelectedData[eachAttribute.id], fileProps === null || fileProps === void 0 ? void 0 : fileProps.imageBucketName);
1358
1446
  }
1359
- var accept = (_y = eachAttribute.fileExtension) !== null && _y !== void 0 ? _y : (eachAttribute.type === "image"
1447
+ var accept = (_z = eachAttribute.fileExtension) !== null && _z !== void 0 ? _z : (eachAttribute.type === "image"
1360
1448
  ? ".png,.jpg,.jpeg,.heic,.heif,.tiff"
1361
1449
  : ".pdf");
1362
- var fileDescription = (_z = eachAttribute.fileDescription) !== null && _z !== void 0 ? _z : (eachAttribute.type === "image" ? undefined : "PDF up to 30MB");
1363
- inputList[groupId].push(react_1.default.createElement(uploadInput_1.UploadInput, { lib: { axios: (_0 = props === null || props === void 0 ? void 0 : props.lib) === null || _0 === void 0 ? void 0 : _0.axios }, ref: eachAttribute.optional
1450
+ var fileDescription = (_0 = eachAttribute.fileDescription) !== null && _0 !== void 0 ? _0 : (eachAttribute.type === "image" ? undefined : "PDF up to 30MB");
1451
+ inputList[groupId].push(react_1.default.createElement(uploadInput_1.UploadInput, { lib: { axios: (_1 = props === null || props === void 0 ? void 0 : props.lib) === null || _1 === void 0 ? void 0 : _1.axios }, ref: eachAttribute.optional
1364
1452
  ? null
1365
- : formInputRef[(_1 = eachAttribute.refIndex) !== null && _1 !== void 0 ? _1 : index], id: eachAttribute.id, label: label, labelExtra: labelExtra, infoElement: (cellInput === null || cellInput === void 0 ? void 0 : cellInput.active) ? undefined : infoElement, optional: eachAttribute.optional, file: (_2 = url !== null && url !== void 0 ? url : clonedSelectedData[eachAttribute.id]) !== null && _2 !== void 0 ? _2 : "", accept: accept, capture: eachAttribute.imageInputCapture, fileDescription: fileDescription, maxFileSize: fileProps === null || fileProps === void 0 ? void 0 : fileProps.maxFileSize, onChange: updateMethod.handleOnChangeFile, showModal: eachAttribute.showCameraGalleryOptionModal, disabled: disabled, handleCustomDownloadFile: fileProps === null || fileProps === void 0 ? void 0 : fileProps.handleCustomDownloadFile, compress: eachAttribute.maxFileSize && eachAttribute.compressfileQuality
1453
+ : formInputRef[(_2 = eachAttribute.refIndex) !== null && _2 !== void 0 ? _2 : index], id: eachAttribute.id, label: label, labelExtra: labelExtra, infoElement: (cellInput === null || cellInput === void 0 ? void 0 : cellInput.active) ? undefined : infoElement, optional: eachAttribute.optional, file: (_3 = url !== null && url !== void 0 ? url : clonedSelectedData[eachAttribute.id]) !== null && _3 !== void 0 ? _3 : "", accept: accept, capture: eachAttribute.imageInputCapture, fileDescription: fileDescription, maxFileSize: fileProps === null || fileProps === void 0 ? void 0 : fileProps.maxFileSize, onChange: updateMethod.handleOnChangeFile, showModal: eachAttribute.showCameraGalleryOptionModal, disabled: disabled, handleCustomDownloadFile: fileProps === null || fileProps === void 0 ? void 0 : fileProps.handleCustomDownloadFile, compress: eachAttribute.maxFileSize && eachAttribute.compressfileQuality
1366
1454
  ? {
1367
1455
  maxFileSize: eachAttribute.maxFileSize,
1368
1456
  fileQuality: eachAttribute.compressfileQuality,
@@ -1372,7 +1460,7 @@ var renderDataTemplateForm = function (data, model, formInputRef, updateMethod,
1372
1460
  case "multipleImage":
1373
1461
  case "multipleFile":
1374
1462
  var multipleDataUrl = clonedSelectedData[eachAttribute.id]["data"]
1375
- ? (_3 = clonedSelectedData[eachAttribute.id]["data"]) === null || _3 === void 0 ? void 0 : _3.map(function (eachImage) {
1463
+ ? (_4 = clonedSelectedData[eachAttribute.id]["data"]) === null || _4 === void 0 ? void 0 : _4.map(function (eachImage) {
1376
1464
  return {
1377
1465
  token: eachImage.token,
1378
1466
  fileName: (props === null || props === void 0 ? void 0 : props.isObjectList)
@@ -1389,20 +1477,20 @@ var renderDataTemplateForm = function (data, model, formInputRef, updateMethod,
1389
1477
  };
1390
1478
  })
1391
1479
  : [];
1392
- var multiAccept = (_4 = eachAttribute.fileExtension) !== null && _4 !== void 0 ? _4 : (eachAttribute.type === "multipleImage"
1480
+ var multiAccept = (_5 = eachAttribute.fileExtension) !== null && _5 !== void 0 ? _5 : (eachAttribute.type === "multipleImage"
1393
1481
  ? ".png,.jpg,.jpeg,.heic,.heif,.tiff"
1394
1482
  : ".pdf");
1395
- var multiFileDescription = (_5 = eachAttribute.fileDescription) !== null && _5 !== void 0 ? _5 : (eachAttribute.type === "multipleImage"
1483
+ var multiFileDescription = (_6 = eachAttribute.fileDescription) !== null && _6 !== void 0 ? _6 : (eachAttribute.type === "multipleImage"
1396
1484
  ? undefined
1397
1485
  : "PDF up to 30MB");
1398
1486
  inputList[groupId].push(react_1.default.createElement(uploadInput_1.UploadInput, { type: "multi", files: __assign(__assign({}, (!react_1.default.isValidElement(clonedSelectedData[eachAttribute.id])
1399
1487
  ? clonedSelectedData[eachAttribute.id]
1400
1488
  : { upload: [], remove: [] })), { data: multipleDataUrl }), optional: eachAttribute.optional, ref: eachAttribute.optional
1401
1489
  ? null
1402
- : formInputRef[(_6 = eachAttribute.refIndex) !== null && _6 !== void 0 ? _6 : index], id: eachAttribute.id, label: label, labelExtra: labelExtra, infoElement: (cellInput === null || cellInput === void 0 ? void 0 : cellInput.active) ? undefined : infoElement, showModal: eachAttribute.showCameraGalleryOptionModal, accept: multiAccept, capture: eachAttribute.imageInputCapture, fileDescription: multiFileDescription, maxFileSize: fileProps === null || fileProps === void 0 ? void 0 : fileProps.maxFileSize, onChange: function (_a) {
1490
+ : formInputRef[(_7 = eachAttribute.refIndex) !== null && _7 !== void 0 ? _7 : index], id: eachAttribute.id, label: label, labelExtra: labelExtra, infoElement: (cellInput === null || cellInput === void 0 ? void 0 : cellInput.active) ? undefined : infoElement, showModal: eachAttribute.showCameraGalleryOptionModal, accept: multiAccept, capture: eachAttribute.imageInputCapture, fileDescription: multiFileDescription, maxFileSize: fileProps === null || fileProps === void 0 ? void 0 : fileProps.maxFileSize, onChange: function (_a) {
1403
1491
  var value = _a.value, action = _a.action;
1404
1492
  updateMethod.handleOnChangeFiles(eachAttribute.id, value, action);
1405
- }, lib: { axios: (_7 = props === null || props === void 0 ? void 0 : props.lib) === null || _7 === void 0 ? void 0 : _7.axios }, disabled: disabled, confirmOnRemove: eachAttribute.confirmOnRemove, noDuplicateFileName: eachAttribute.noDuplicateFileName, handleCustomDownloadFile: fileProps === null || fileProps === void 0 ? void 0 : fileProps.handleCustomDownloadFile, compress: eachAttribute.maxFileSize && eachAttribute.compressfileQuality
1493
+ }, lib: { axios: (_8 = props === null || props === void 0 ? void 0 : props.lib) === null || _8 === void 0 ? void 0 : _8.axios }, disabled: disabled, confirmOnRemove: eachAttribute.confirmOnRemove, noDuplicateFileName: eachAttribute.noDuplicateFileName, handleCustomDownloadFile: fileProps === null || fileProps === void 0 ? void 0 : fileProps.handleCustomDownloadFile, compress: eachAttribute.maxFileSize && eachAttribute.compressfileQuality
1406
1494
  ? {
1407
1495
  maxFileSize: eachAttribute.maxFileSize,
1408
1496
  fileQuality: eachAttribute.compressfileQuality,
@@ -1412,7 +1500,7 @@ var renderDataTemplateForm = function (data, model, formInputRef, updateMethod,
1412
1500
  case "number":
1413
1501
  inputList[groupId].push(react_1.default.createElement(textInput_1.TextInput, { id: eachAttribute.id, ref: eachAttribute.optional
1414
1502
  ? null
1415
- : formInputRef[(_8 = eachAttribute.refIndex) !== null && _8 !== void 0 ? _8 : index], type: "number", value: (_9 = clonedSelectedData[eachAttribute.id]) !== null && _9 !== void 0 ? _9 : "", placeholder: placeholder, label: label, labelExtra: labelExtra, subLabel: subLabel, infoElement: (cellInput === null || cellInput === void 0 ? void 0 : cellInput.active) ? undefined : infoElement, optional: eachAttribute.optional, onChange: updateMethod.handleOnChangeText, disabled: disabled, minNumber: eachAttribute.minNumber, maxNumber: eachAttribute.maxNumber, cellInput: {
1503
+ : formInputRef[(_9 = eachAttribute.refIndex) !== null && _9 !== void 0 ? _9 : index], type: "number", value: (_10 = clonedSelectedData[eachAttribute.id]) !== null && _10 !== void 0 ? _10 : "", placeholder: placeholder, label: label, labelExtra: labelExtra, subLabel: subLabel, infoElement: (cellInput === null || cellInput === void 0 ? void 0 : cellInput.active) ? undefined : infoElement, optional: eachAttribute.optional, onChange: updateMethod.handleOnChangeText, disabled: disabled, minNumber: eachAttribute.minNumber, maxNumber: eachAttribute.maxNumber, cellInput: {
1416
1504
  active: cellInput === null || cellInput === void 0 ? void 0 : cellInput.active,
1417
1505
  onBlur: cellInput === null || cellInput === void 0 ? void 0 : cellInput.onBlur,
1418
1506
  }, mobileView: mobileView }));
@@ -1420,12 +1508,12 @@ var renderDataTemplateForm = function (data, model, formInputRef, updateMethod,
1420
1508
  case "reference":
1421
1509
  case "listReference":
1422
1510
  var selectedReferenceOptions = (props === null || props === void 0 ? void 0 : props.isObject)
1423
- ? (_10 = referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.referencesOptions[(objectProps === null || objectProps === void 0 ? void 0 : objectProps.selectedObjectStructureId) + "." + eachAttribute.id]) !== null && _10 !== void 0 ? _10 : []
1424
- : (_11 = referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.referencesOptions[eachAttribute.id]) !== null && _11 !== void 0 ? _11 : [];
1511
+ ? (_11 = referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.referencesOptions[(objectProps === null || objectProps === void 0 ? void 0 : objectProps.selectedObjectStructureId) + "." + eachAttribute.id]) !== null && _11 !== void 0 ? _11 : []
1512
+ : (_12 = referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.referencesOptions[eachAttribute.id]) !== null && _12 !== void 0 ? _12 : [];
1425
1513
  inputList[groupId].push(react_1.default.createElement(react_1.default.Fragment, null,
1426
1514
  react_1.default.createElement(select_1.Select, { ref: eachAttribute.optional
1427
1515
  ? null
1428
- : formInputRef[(_12 = eachAttribute.refIndex) !== null && _12 !== void 0 ? _12 : index], id: eachAttribute.id, value: (_13 = clonedSelectedData[eachAttribute.id]) !== null && _13 !== void 0 ? _13 : (eachAttribute.type === "reference" ? "" : []), label: label, labelExtra: labelExtra, subLabel: subLabel, infoElement: (cellInput === null || cellInput === void 0 ? void 0 : cellInput.active) ? undefined : infoElement, optional: eachAttribute.optional, placeholder: placeholder !== eachAttribute.name
1516
+ : formInputRef[(_13 = eachAttribute.refIndex) !== null && _13 !== void 0 ? _13 : index], id: eachAttribute.id, value: (_14 = clonedSelectedData[eachAttribute.id]) !== null && _14 !== void 0 ? _14 : (eachAttribute.type === "reference" ? "" : []), label: label, labelExtra: labelExtra, subLabel: subLabel, infoElement: (cellInput === null || cellInput === void 0 ? void 0 : cellInput.active) ? undefined : infoElement, optional: eachAttribute.optional, placeholder: placeholder !== eachAttribute.name
1429
1517
  ? placeholder
1430
1518
  : "Select An Option", showTag: eachAttribute.showTagSelections, disableKeyboard: eachAttribute.disabledKeyboardSearch, options: selectedReferenceOptions, onChange: function (value) {
1431
1519
  updateMethod.handleOnChangeSelect(eachAttribute.id, value);
@@ -1491,14 +1579,14 @@ var renderDataTemplateForm = function (data, model, formInputRef, updateMethod,
1491
1579
  }
1492
1580
  inputList[groupId].push(react_1.default.createElement(textInput_1.TextInput, { id: eachAttribute.id, ref: eachAttribute.optional
1493
1581
  ? null
1494
- : formInputRef[(_14 = eachAttribute.refIndex) !== null && _14 !== void 0 ? _14 : index], type: textType, value: (_15 = clonedSelectedData[eachAttribute.id]) !== null && _15 !== void 0 ? _15 : "", placeholder: placeholder, label: label, labelExtra: labelExtra, subLabel: subLabel, infoElement: (cellInput === null || cellInput === void 0 ? void 0 : cellInput.active) ? undefined : infoElement, optional: eachAttribute.optional, onChange: updateMethod.handleOnChangeText, disabled: disabled, cellInput: {
1582
+ : formInputRef[(_15 = eachAttribute.refIndex) !== null && _15 !== void 0 ? _15 : index], type: textType, value: (_16 = clonedSelectedData[eachAttribute.id]) !== null && _16 !== void 0 ? _16 : "", placeholder: placeholder, label: label, labelExtra: labelExtra, subLabel: subLabel, infoElement: (cellInput === null || cellInput === void 0 ? void 0 : cellInput.active) ? undefined : infoElement, optional: eachAttribute.optional, onChange: updateMethod.handleOnChangeText, disabled: disabled, cellInput: {
1495
1583
  active: cellInput === null || cellInput === void 0 ? void 0 : cellInput.active,
1496
1584
  onBlur: cellInput === null || cellInput === void 0 ? void 0 : cellInput.onBlur,
1497
1585
  }, mobilePicker: true, mobileCountryEditable: eachAttribute.mobileCountryEditable, capitalize: eachAttribute.type === "string"
1498
1586
  ? eachAttribute.capitalize
1499
1587
  : undefined, strSuggestions: eachAttribute.type === "string" &&
1500
1588
  eachAttribute.stringSuggestions &&
1501
- ((_16 = eachAttribute.stringSuggestions) === null || _16 === void 0 ? void 0 : _16.length) > 0
1589
+ ((_17 = eachAttribute.stringSuggestions) === null || _17 === void 0 ? void 0 : _17.length) > 0
1502
1590
  ? eachAttribute.stringSuggestions
1503
1591
  : undefined, mobileView: mobileView }));
1504
1592
  break;
@@ -1510,8 +1598,8 @@ var renderDataTemplateForm = function (data, model, formInputRef, updateMethod,
1510
1598
  clonedSelectedData[eachAttribute.id] instanceof Date)
1511
1599
  dateValue = clonedSelectedData[eachAttribute.id];
1512
1600
  else if (typeof clonedSelectedData[eachAttribute.id] === "object")
1513
- dateValue = ((_17 = clonedSelectedData === null || clonedSelectedData === void 0 ? void 0 : clonedSelectedData[eachAttribute.id]) === null || _17 === void 0 ? void 0 : _17["_seconds"])
1514
- ? (0, moment_1.default)((_18 = clonedSelectedData === null || clonedSelectedData === void 0 ? void 0 : clonedSelectedData[eachAttribute.id]) === null || _18 === void 0 ? void 0 : _18["_seconds"]).toDate()
1601
+ dateValue = ((_18 = clonedSelectedData === null || clonedSelectedData === void 0 ? void 0 : clonedSelectedData[eachAttribute.id]) === null || _18 === void 0 ? void 0 : _18["_seconds"])
1602
+ ? (0, moment_1.default)((_19 = clonedSelectedData === null || clonedSelectedData === void 0 ? void 0 : clonedSelectedData[eachAttribute.id]) === null || _19 === void 0 ? void 0 : _19["_seconds"]).toDate()
1515
1603
  : (0, moment_1.default)().toDate();
1516
1604
  else if (clonedSelectedData[eachAttribute.id] === undefined)
1517
1605
  dateValue = undefined;
@@ -1519,7 +1607,7 @@ var renderDataTemplateForm = function (data, model, formInputRef, updateMethod,
1519
1607
  var hideDate = eachAttribute.hideShowDate ? true : false;
1520
1608
  inputList[groupId].push(react_1.default.createElement(datePicker_1.InputDatePicker, { title: label, labelExtra: labelExtra, subLabel: subLabel, id: eachAttribute.id, optional: eachAttribute.optional, ref: eachAttribute.optional
1521
1609
  ? null
1522
- : formInputRef[(_19 = eachAttribute.refIndex) !== null && _19 !== void 0 ? _19 : index], onChange: updateMethod.handleOnChangeDate, value: dateValue, disabled: disabled, cellInput: {
1610
+ : formInputRef[(_20 = eachAttribute.refIndex) !== null && _20 !== void 0 ? _20 : index], onChange: updateMethod.handleOnChangeDate, value: dateValue, disabled: disabled, cellInput: {
1523
1611
  active: cellInput === null || cellInput === void 0 ? void 0 : cellInput.active,
1524
1612
  onBlur: cellInput === null || cellInput === void 0 ? void 0 : cellInput.onBlur,
1525
1613
  }, minDate: eachAttribute.minDate, maxDate: eachAttribute.maxDate, staticDropdown: modalInput, showTime: showTime, hideDate: hideDate, infoElement: (cellInput === null || cellInput === void 0 ? void 0 : cellInput.active) ? undefined : infoElement, mobileView: mobileView }));
@@ -1527,12 +1615,12 @@ var renderDataTemplateForm = function (data, model, formInputRef, updateMethod,
1527
1615
  case "markdown":
1528
1616
  inputList[groupId].push(react_1.default.createElement(markdown_1.MarkdownInput, { id: eachAttribute.id, ref: eachAttribute.optional
1529
1617
  ? null
1530
- : formInputRef[(_20 = eachAttribute.refIndex) !== null && _20 !== void 0 ? _20 : index], label: label, labelExtra: labelExtra, subLabel: subLabel, value: (_21 = clonedSelectedData[eachAttribute.id]) !== null && _21 !== void 0 ? _21 : "", placeholder: placeholder, optional: eachAttribute.optional, onChange: updateMethod.handleOnChangeMarkdown, disabled: disabled, infoElement: (cellInput === null || cellInput === void 0 ? void 0 : cellInput.active) ? undefined : infoElement, readOnly: (markdonwProps === null || markdonwProps === void 0 ? void 0 : markdonwProps.readOnly) ? true : false }));
1618
+ : formInputRef[(_21 = eachAttribute.refIndex) !== null && _21 !== void 0 ? _21 : index], label: label, labelExtra: labelExtra, subLabel: subLabel, value: (_22 = clonedSelectedData[eachAttribute.id]) !== null && _22 !== void 0 ? _22 : "", placeholder: placeholder, optional: eachAttribute.optional, onChange: updateMethod.handleOnChangeMarkdown, disabled: disabled, infoElement: (cellInput === null || cellInput === void 0 ? void 0 : cellInput.active) ? undefined : infoElement, readOnly: (markdonwProps === null || markdonwProps === void 0 ? void 0 : markdonwProps.readOnly) ? true : false }));
1531
1619
  break;
1532
1620
  case "textArea":
1533
1621
  inputList[groupId].push(react_1.default.createElement(textArea_1.TextArea, { id: eachAttribute.id, ref: eachAttribute.optional
1534
1622
  ? null
1535
- : formInputRef[(_22 = eachAttribute.refIndex) !== null && _22 !== void 0 ? _22 : index], label: label, labelExtra: labelExtra, subLabel: subLabel, placeholder: placeholder, value: (_23 = clonedSelectedData[eachAttribute.id]) !== null && _23 !== void 0 ? _23 : "", rows: 4, optional: eachAttribute.optional, onChange: updateMethod.handleOnChangeText, infoElement: (cellInput === null || cellInput === void 0 ? void 0 : cellInput.active) ? undefined : infoElement, disabled: disabled }));
1623
+ : formInputRef[(_23 = eachAttribute.refIndex) !== null && _23 !== void 0 ? _23 : index], label: label, labelExtra: labelExtra, subLabel: subLabel, placeholder: placeholder, value: (_24 = clonedSelectedData[eachAttribute.id]) !== null && _24 !== void 0 ? _24 : "", rows: 4, optional: eachAttribute.optional, onChange: updateMethod.handleOnChangeText, infoElement: (cellInput === null || cellInput === void 0 ? void 0 : cellInput.active) ? undefined : infoElement, disabled: disabled }));
1536
1624
  break;
1537
1625
  case "signature":
1538
1626
  var hasSigImageToken = typeof clonedSelectedData[eachAttribute.id] === "string" &&
@@ -1542,24 +1630,177 @@ var renderDataTemplateForm = function (data, model, formInputRef, updateMethod,
1542
1630
  signatureUrl = (0, blobModule_1.renderImageUrlFromPath)(fileProps === null || fileProps === void 0 ? void 0 : fileProps.imageEndpoint, eachAttribute.imageCollectionName, props === null || props === void 0 ? void 0 : props.id, eachAttribute.imageFileName, clonedSelectedData[eachAttribute.id], fileProps === null || fileProps === void 0 ? void 0 : fileProps.imageBucketName);
1543
1631
  }
1544
1632
  inputList[groupId].push(react_1.default.createElement("div", { className: "w-full h-72" },
1545
- react_1.default.createElement(signature_1.Signature, { id: eachAttribute.id, ref: formInputRef[(_24 = eachAttribute.refIndex) !== null && _24 !== void 0 ? _24 : index], label: label, labelExtra: labelExtra, subLabel: subLabel, dataURL: signatureUrl, optional: eachAttribute.optional, signing: signatureProps === null || signatureProps === void 0 ? void 0 : signatureProps.signing, onChange: signatureProps === null || signatureProps === void 0 ? void 0 : signatureProps.setSigning, onSubmit: function (_, dataURL) {
1633
+ react_1.default.createElement(signature_1.Signature, { id: eachAttribute.id, ref: formInputRef[(_25 = eachAttribute.refIndex) !== null && _25 !== void 0 ? _25 : index], label: label, labelExtra: labelExtra, subLabel: subLabel, dataURL: signatureUrl, optional: eachAttribute.optional, signing: signatureProps === null || signatureProps === void 0 ? void 0 : signatureProps.signing, onChange: signatureProps === null || signatureProps === void 0 ? void 0 : signatureProps.setSigning, onSubmit: function (_, dataURL) {
1546
1634
  return updateMethod.handleSignatureComplete(dataURL, eachAttribute.id);
1547
1635
  }, signatureClear: true, canvasContainerClassName: "shadow-none", infoElement: (cellInput === null || cellInput === void 0 ? void 0 : cellInput.active) ? undefined : infoElement })));
1548
1636
  break;
1549
1637
  case "listObject":
1550
1638
  if (eachAttribute.listObjOrder) {
1551
- inputList[groupId].push((0, exports.renderEachListObject)((_25 = props === null || props === void 0 ? void 0 : props.type) !== null && _25 !== void 0 ? _25 : "read", eachAttribute.id, model, data, (_26 = props === null || props === void 0 ? void 0 : props.id) !== null && _26 !== void 0 ? _26 : "", (props === null || props === void 0 ? void 0 : props.remainId) ? false : true, isForm ? false : true, (objectProps === null || objectProps === void 0 ? void 0 : objectProps.organiseListObjTableView) ? true : false, referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.devSettings, objectProps === null || objectProps === void 0 ? void 0 : objectProps.handleSelectListObjectData, referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.referencesOptions, objectProps === null || objectProps === void 0 ? void 0 : objectProps.setSelectedObjectStructureId, objectProps === null || objectProps === void 0 ? void 0 : objectProps.handlePopUpModal, objectProps === null || objectProps === void 0 ? void 0 : objectProps.setSelectedData));
1639
+ inputList[groupId].push((0, exports.renderEachListObject)((_26 = props === null || props === void 0 ? void 0 : props.type) !== null && _26 !== void 0 ? _26 : "read", eachAttribute.id, model, data, (_27 = props === null || props === void 0 ? void 0 : props.id) !== null && _27 !== void 0 ? _27 : "", (props === null || props === void 0 ? void 0 : props.remainId) ? false : true, isForm ? false : true, (objectProps === null || objectProps === void 0 ? void 0 : objectProps.organiseListObjTableView) ? true : false, referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.devSettings, objectProps === null || objectProps === void 0 ? void 0 : objectProps.handleSelectListObjectData, referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.referencesOptions, objectProps === null || objectProps === void 0 ? void 0 : objectProps.setSelectedObjectStructureId, objectProps === null || objectProps === void 0 ? void 0 : objectProps.handlePopUpModal, objectProps === null || objectProps === void 0 ? void 0 : objectProps.setSelectedData));
1552
1640
  }
1553
1641
  break;
1554
1642
  case "canvas":
1643
+ // Normalize canvas data structure based on enableDraw or enableImageUpload
1644
+ var canvasData = clonedSelectedData[eachAttribute.id];
1645
+ var useNewFormat = eachAttribute.enableDraw || eachAttribute.enableImageUpload;
1646
+ var normalizedTexts = [];
1647
+ var normalizedDrawings = [];
1648
+ if (useNewFormat) {
1649
+ // New format: expect { texts: [], drawings: [], backgroundImage?: { fileName, token } } or normalize from old format
1650
+ if (Array.isArray(canvasData) || !canvasData) {
1651
+ normalizedTexts = canvasData !== null && canvasData !== void 0 ? canvasData : [];
1652
+ normalizedDrawings = [];
1653
+ }
1654
+ else {
1655
+ normalizedTexts = (_28 = canvasData.texts) !== null && _28 !== void 0 ? _28 : [];
1656
+ normalizedDrawings = (_29 = canvasData.drawings) !== null && _29 !== void 0 ? _29 : [];
1657
+ }
1658
+ }
1659
+ else {
1660
+ // Old format: expect texts[] array
1661
+ normalizedTexts = Array.isArray(canvasData)
1662
+ ? canvasData
1663
+ : (_30 = canvasData === null || canvasData === void 0 ? void 0 : canvasData.texts) !== null && _30 !== void 0 ? _30 : [];
1664
+ normalizedDrawings = [];
1665
+ }
1555
1666
  inputList[groupId].push(react_1.default.createElement(canvas_1.Canvas, { ref: eachAttribute.optional
1556
1667
  ? null
1557
- : formInputRef[(_27 = eachAttribute.refIndex) !== null && _27 !== void 0 ? _27 : index], id: eachAttribute.id, label: label, labelExtra: labelExtra, infoElement: (cellInput === null || cellInput === void 0 ? void 0 : cellInput.active) ? undefined : infoElement, optional: eachAttribute.optional, texts: (_28 = clonedSelectedData[eachAttribute.id]) !== null && _28 !== void 0 ? _28 : [], backgroundImageUrl: eachAttribute.canvasImage, onChange: function (texts) {
1558
- updateMethod.handleOnChangeSelect(eachAttribute.id, texts);
1668
+ : formInputRef[(_31 = eachAttribute.refIndex) !== null && _31 !== void 0 ? _31 : index], id: eachAttribute.id, label: label, labelExtra: labelExtra, infoElement: (cellInput === null || cellInput === void 0 ? void 0 : cellInput.active) ? undefined : infoElement, optional: eachAttribute.optional, enableDraw: (props === null || props === void 0 ? void 0 : props.type) === "update" ? eachAttribute.enableDraw : false, enableImageUpload: (props === null || props === void 0 ? void 0 : props.type) === "update" ? eachAttribute.enableImageUpload : false, readOnly: (props === null || props === void 0 ? void 0 : props.type) !== "update", texts: normalizedTexts, drawings: normalizedDrawings, backgroundImageUrl: eachAttribute.enableImageUpload &&
1669
+ canvasData &&
1670
+ !Array.isArray(canvasData) &&
1671
+ canvasData.backgroundImage
1672
+ ? // If backgroundImage has token, construct URL from token and fileName
1673
+ // If it has file but no token, create blob URL from File object
1674
+ canvasData.backgroundImage.token
1675
+ ? (props === null || props === void 0 ? void 0 : props.isObjectList)
1676
+ ? (0, blobModule_1.renderImageUrlFromPath)((_32 = fileProps === null || fileProps === void 0 ? void 0 : fileProps.imageEndpoint) !== null && _32 !== void 0 ? _32 : "", eachAttribute.imageCollectionName + "%2F" + props.id, (objectProps === null || objectProps === void 0 ? void 0 : objectProps.selectedObjectStructureId) +
1677
+ "%2F" +
1678
+ (objectProps === null || objectProps === void 0 ? void 0 : objectProps.selectedObjectId) +
1679
+ "%2F" +
1680
+ eachAttribute.id, canvasData.backgroundImage.fileName, canvasData.backgroundImage.token, fileProps === null || fileProps === void 0 ? void 0 : fileProps.imageBucketName)
1681
+ : (props === null || props === void 0 ? void 0 : props.isObject)
1682
+ ? (0, blobModule_1.renderImageUrlFromPath)((_33 = fileProps === null || fileProps === void 0 ? void 0 : fileProps.imageEndpoint) !== null && _33 !== void 0 ? _33 : "", eachAttribute.imageCollectionName + "%2F" + props.id, (objectProps === null || objectProps === void 0 ? void 0 : objectProps.selectedObjectStructureId) +
1683
+ "%2F" +
1684
+ eachAttribute.id +
1685
+ "%2FbaseCanvas", canvasData.backgroundImage.fileName, canvasData.backgroundImage.token, fileProps === null || fileProps === void 0 ? void 0 : fileProps.imageBucketName)
1686
+ : (0, blobModule_1.renderImageUrlFromPath)((_34 = fileProps === null || fileProps === void 0 ? void 0 : fileProps.imageEndpoint) !== null && _34 !== void 0 ? _34 : "", (_35 = eachAttribute.imageCollectionName) !== null && _35 !== void 0 ? _35 : "", ((_36 = props === null || props === void 0 ? void 0 : props.id) !== null && _36 !== void 0 ? _36 : "") + "%2FbaseCanvas", canvasData.backgroundImage.fileName, canvasData.backgroundImage.token, fileProps === null || fileProps === void 0 ? void 0 : fileProps.imageBucketName)
1687
+ : canvasData.backgroundImage.file &&
1688
+ canvasData.backgroundImage.file instanceof File
1689
+ ? // Image hasn't been uploaded yet - use cached blob URL from File object
1690
+ getBlobUrlForFile(canvasData.backgroundImage.file)
1691
+ : undefined
1692
+ : eachAttribute.canvasImage, onChange: function (texts) {
1693
+ var _a, _b, _c;
1694
+ var useNewFormat = eachAttribute.enableDraw || eachAttribute.enableImageUpload;
1695
+ if (useNewFormat) {
1696
+ // New format: save as object with texts, drawings, and optionally backgroundImage
1697
+ var currentData = clonedSelectedData[eachAttribute.id];
1698
+ // Build base canvas data
1699
+ var baseCanvasData = Array.isArray(currentData) || !currentData
1700
+ ? {
1701
+ texts: currentData !== null && currentData !== void 0 ? currentData : [],
1702
+ drawings: [],
1703
+ }
1704
+ : {
1705
+ texts: (_a = currentData.texts) !== null && _a !== void 0 ? _a : [],
1706
+ drawings: (_b = currentData.drawings) !== null && _b !== void 0 ? _b : [],
1707
+ };
1708
+ // Only include backgroundImage if enableImageUpload is true
1709
+ var currentCanvasData = eachAttribute.enableImageUpload
1710
+ ? __assign(__assign({}, baseCanvasData), { backgroundImage: currentData && !Array.isArray(currentData)
1711
+ ? (_c = currentData.backgroundImage) !== null && _c !== void 0 ? _c : null
1712
+ : null }) : baseCanvasData;
1713
+ updateMethod.handleOnChangeSelect(eachAttribute.id, __assign(__assign({}, currentCanvasData), { texts: texts }));
1714
+ }
1715
+ else {
1716
+ // Old format: save as just texts array
1717
+ updateMethod.handleOnChangeSelect(eachAttribute.id, texts);
1718
+ }
1719
+ }, onDrawingsChange: function (drawings) {
1720
+ var _a, _b, _c;
1721
+ if (eachAttribute.enableDraw) {
1722
+ // New format: save as object with texts, drawings, and optionally backgroundImage
1723
+ var currentData = clonedSelectedData[eachAttribute.id];
1724
+ // Build base canvas data
1725
+ var baseCanvasData = Array.isArray(currentData) || !currentData
1726
+ ? {
1727
+ texts: currentData !== null && currentData !== void 0 ? currentData : [],
1728
+ drawings: [],
1729
+ }
1730
+ : {
1731
+ texts: (_a = currentData.texts) !== null && _a !== void 0 ? _a : [],
1732
+ drawings: (_b = currentData.drawings) !== null && _b !== void 0 ? _b : [],
1733
+ };
1734
+ // Only include backgroundImage if enableImageUpload is true
1735
+ var currentCanvasData = eachAttribute.enableImageUpload
1736
+ ? __assign(__assign({}, baseCanvasData), { backgroundImage: currentData && !Array.isArray(currentData)
1737
+ ? (_c = currentData.backgroundImage) !== null && _c !== void 0 ? _c : null
1738
+ : null }) : baseCanvasData;
1739
+ updateMethod.handleOnChangeSelect(eachAttribute.id, __assign(__assign({}, currentCanvasData), { drawings: drawings }));
1740
+ }
1741
+ // If enableDraw is false, drawings are not tracked, so do nothing
1742
+ }, onBackgroundImageChange: function (imageFile) {
1743
+ var _a, _b;
1744
+ if (eachAttribute.enableImageUpload) {
1745
+ // New format: save backgroundImage with fileName and token
1746
+ // For now, store the File object - upload will happen during submission
1747
+ // The File will be uploaded and replaced with { fileName, token } during form submission
1748
+ var currentData = clonedSelectedData[eachAttribute.id];
1749
+ var useNewFormat_1 = eachAttribute.enableDraw || eachAttribute.enableImageUpload;
1750
+ var currentCanvasData = useNewFormat_1
1751
+ ? Array.isArray(currentData) || !currentData
1752
+ ? {
1753
+ texts: currentData !== null && currentData !== void 0 ? currentData : [],
1754
+ drawings: [],
1755
+ }
1756
+ : {
1757
+ texts: (_a = currentData.texts) !== null && _a !== void 0 ? _a : [],
1758
+ drawings: (_b = currentData.drawings) !== null && _b !== void 0 ? _b : [],
1759
+ }
1760
+ : { texts: currentData !== null && currentData !== void 0 ? currentData : [], drawings: [] };
1761
+ // Store the File temporarily - will be uploaded during submission
1762
+ // If imageFile is null (unselected), preserve the existing File object temporarily
1763
+ // so it can be reselected without losing the data
1764
+ // However, we mark it as "unselected" by storing it with a special flag
1765
+ var existingData = clonedSelectedData[eachAttribute.id];
1766
+ var existingBackgroundImage = existingData &&
1767
+ !Array.isArray(existingData) &&
1768
+ existingData.backgroundImage
1769
+ ? existingData.backgroundImage
1770
+ : null;
1771
+ if (imageFile) {
1772
+ // New file selected or reselected - store it normally (removes _unselected flag)
1773
+ updateMethod.handleOnChangeSelect(eachAttribute.id, __assign(__assign({}, currentCanvasData), { backgroundImage: {
1774
+ fileName: imageFile.name,
1775
+ file: imageFile,
1776
+ } }));
1777
+ }
1778
+ else {
1779
+ // imageFile is null - this happens when:
1780
+ // 1. User unselects image (clicks image in grid to toggle) - should preserve File
1781
+ // 2. User clicks "Clear All" - should clear File
1782
+ //
1783
+ // We can't distinguish these cases from here, so we preserve the File with flags
1784
+ // The cleanup in handleSubmitObjectDataType will clear it if still unselected/cleared
1785
+ if (existingBackgroundImage && existingBackgroundImage.file) {
1786
+ updateMethod.handleOnChangeSelect(eachAttribute.id, __assign(__assign({}, currentCanvasData), { backgroundImage: {
1787
+ fileName: existingBackgroundImage.fileName,
1788
+ file: existingBackgroundImage.file,
1789
+ _unselected: true, // Flag to indicate it was unselected
1790
+ _cleared: true, // Flag to indicate it was cleared (via Clear All or unselect)
1791
+ } }));
1792
+ }
1793
+ else {
1794
+ // No existing file to preserve
1795
+ updateMethod.handleOnChangeSelect(eachAttribute.id, __assign(__assign({}, currentCanvasData), { backgroundImage: null }));
1796
+ }
1797
+ }
1798
+ }
1799
+ // If enableImageUpload is false, background image is not tracked
1559
1800
  } }));
1560
1801
  break;
1561
1802
  case "ganttchart":
1562
- inputList[groupId].push(react_1.default.createElement(ganttChart_1.GanttChart, { id: eachAttribute.id, title: label, label: label, labelExtra: labelExtra, infoElement: (cellInput === null || cellInput === void 0 ? void 0 : cellInput.active) ? undefined : infoElement, tasks: (_29 = clonedSelectedData[eachAttribute.id]) !== null && _29 !== void 0 ? _29 : [], onTaskChange: function (tasks) {
1803
+ inputList[groupId].push(react_1.default.createElement(ganttChart_1.GanttChart, { id: eachAttribute.id, title: label, label: label, labelExtra: labelExtra, infoElement: (cellInput === null || cellInput === void 0 ? void 0 : cellInput.active) ? undefined : infoElement, tasks: (_37 = clonedSelectedData[eachAttribute.id]) !== null && _37 !== void 0 ? _37 : [], onTaskChange: function (tasks) {
1563
1804
  updateMethod.handleOnChangeSelect(eachAttribute.id, tasks);
1564
1805
  }, mode: "write", chartOnly: true }));
1565
1806
  break;