blixify-ui-web 0.4.217 → 0.4.218

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/data/dataTemplate/index.tsx"],"names":[],"mappings":"AAkCA,OAAO,KAQN,MAAM,OAAO,CAAC;AAuEf,OAAO,EACL,iBAAiB,EAKlB,MAAM,kBAAkB,CAAC;AAoB1B,eAAO,MAAM,YAAY,mFAw4QvB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/data/dataTemplate/index.tsx"],"names":[],"mappings":"AAkCA,OAAO,KAQN,MAAM,OAAO,CAAC;AAuEf,OAAO,EACL,iBAAiB,EAKlB,MAAM,kBAAkB,CAAC;AAoB1B,eAAO,MAAM,YAAY,mFAu+QvB,CAAC"}
@@ -1644,10 +1644,30 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
1644
1644
  if (!(selectedField instanceof File ||
1645
1645
  eachImage.type === "signature")) return [3 /*break*/, 8];
1646
1646
  imageValue = selectedField;
1647
- if (eachImage.type === "signature" &&
1648
- selectedField &&
1649
- typeof selectedField === "string") {
1650
- imageValue = (0, blobModule_1.handleDataURLtoBlob)(selectedField);
1647
+ // For signatures, handle the case where it might be undefined, null, or empty
1648
+ if (eachImage.type === "signature") {
1649
+ // If it's undefined or null, return empty string (no signature)
1650
+ if (!selectedField || selectedField === null) {
1651
+ return [2 /*return*/, ""];
1652
+ }
1653
+ // If it's a string, check if it's a data URL or token
1654
+ if (typeof selectedField === "string") {
1655
+ // Check if it's a data URL (new signature) or a token (existing signature from database)
1656
+ // Data URLs start with "data:image", tokens don't
1657
+ if (selectedField.startsWith("data:image")) {
1658
+ // New signature - convert data URL to blob for upload
1659
+ imageValue = (0, blobModule_1.handleDataURLtoBlob)(selectedField);
1660
+ }
1661
+ else if (selectedField && selectedField !== "") {
1662
+ // Existing signature token from database - return as-is, don't re-upload
1663
+ // Only return if it's a non-empty string (valid token)
1664
+ return [2 /*return*/, selectedField];
1665
+ }
1666
+ else {
1667
+ // Empty string - no signature, return empty
1668
+ return [2 /*return*/, ""];
1669
+ }
1670
+ }
1651
1671
  }
1652
1672
  imageCollectionName = (_a = eachImage.imageCollectionName) !== null && _a !== void 0 ? _a : "";
1653
1673
  if (objectId) {
@@ -3227,10 +3247,75 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
3227
3247
  }
3228
3248
  };
3229
3249
  var handleSignatureComplete = function (dataURL, id) {
3230
- var _a = handleOnChangeData(), data = _a.data, model = _a.model;
3231
- var clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId);
3232
- clonedData[id] = dataURL;
3233
- handleUpdateChangeData(clonedData);
3250
+ var model = handleOnChangeData().model;
3251
+ // Helper function to determine if we should preserve the existing token
3252
+ var shouldPreserveToken = function (currentValue, newDataURL) {
3253
+ // If newDataURL is empty but there's an existing token, preserve it
3254
+ // This happens when:
3255
+ // 1. Signature validation passes but user didn't draw a new signature
3256
+ // 2. User cleared the signature but didn't draw anything new
3257
+ return ((!newDataURL || newDataURL === "") &&
3258
+ currentValue &&
3259
+ currentValue !== "" &&
3260
+ // Only preserve if it's a token (not a data URL)
3261
+ typeof currentValue === "string" &&
3262
+ !currentValue.startsWith("data:image"));
3263
+ };
3264
+ // Handle modal and batch update cases through handleUpdateChangeData
3265
+ if (modalVisible && selectedObjectStructureId) {
3266
+ // For modal case, update selectedObjectData
3267
+ setSelectedObjectData(function (prevObjectData) {
3268
+ var clonedData = (0, updateModule_1.handleClonedDataAttribute)(prevObjectData, model, props.devSettings.server, false, remainId);
3269
+ // Preserve token if dataURL is empty and there's an existing token
3270
+ if (shouldPreserveToken(clonedData[id], dataURL)) {
3271
+ // Don't overwrite - keep the existing token
3272
+ }
3273
+ else {
3274
+ clonedData[id] = dataURL;
3275
+ }
3276
+ return clonedData;
3277
+ });
3278
+ }
3279
+ else if (batchUpdateModal && batchUpdateData.columnId) {
3280
+ // For batch update case, update batchUpdateData
3281
+ var selectedModel = structure.find(function (eachModel) { return eachModel.id === batchUpdateData.columnId; });
3282
+ if (selectedModel && selectedModel.id === id) {
3283
+ setBatchUpdateData(function (prevBatchData) {
3284
+ var _a;
3285
+ var currentValue = (_a = prevBatchData.columnData) === null || _a === void 0 ? void 0 : _a[id];
3286
+ var newColumnData = __assign({}, prevBatchData.columnData);
3287
+ // Preserve token if dataURL is empty and there's an existing token
3288
+ if (shouldPreserveToken(currentValue, dataURL)) {
3289
+ // Don't overwrite - keep the existing token
3290
+ newColumnData[id] = currentValue;
3291
+ }
3292
+ else {
3293
+ newColumnData[id] = dataURL;
3294
+ }
3295
+ return __assign(__assign({}, prevBatchData), { columnData: newColumnData });
3296
+ });
3297
+ }
3298
+ }
3299
+ else {
3300
+ // Normal case: Use functional update to ensure we're working with the latest state
3301
+ // This prevents the issue where handleClonedDataAttribute copies stale state
3302
+ setSelectedData(function (prevSelectedData) {
3303
+ var clonedData = (0, updateModule_1.handleClonedDataAttribute)(prevSelectedData, model, props.devSettings.server, false, remainId);
3304
+ // If dataURL is empty but there's an existing token, preserve it
3305
+ // This happens when signature validation passes but user didn't draw a new signature
3306
+ // or when user cleared but didn't draw anything new
3307
+ if (shouldPreserveToken(clonedData[id], dataURL)) {
3308
+ // Don't overwrite - keep the existing token (clonedData[id] remains unchanged)
3309
+ }
3310
+ else {
3311
+ // New signature or explicitly clearing - update the value
3312
+ clonedData[id] = dataURL;
3313
+ }
3314
+ return clonedData;
3315
+ });
3316
+ }
3317
+ // Note: Can't check state immediately after setState - it's async
3318
+ // But we can verify it worked by checking in the next render or at submission
3234
3319
  };
3235
3320
  var handleOnChangeAddress = function (id, address) {
3236
3321
  var _a = handleOnChangeData(), data = _a.data, model = _a.model;