blixify-ui-web 1.2.259 → 1.2.261

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":"AAqCA,OAAO,KASN,MAAM,OAAO,CAAC;AAkHf,OAAO,EACL,iBAAiB,EAIlB,MAAM,kBAAkB,CAAC;AAkI1B,eAAO,MAAM,qBAAqB,OAAO,CAAC;AA6C1C,eAAO,MAAM,yBAAyB,UAAW,GAAG,YAYnD,CAAC;AAEF,eAAO,MAAM,YAAY,mFA+ogBvB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/data/dataTemplate/index.tsx"],"names":[],"mappings":"AAqCA,OAAO,KASN,MAAM,OAAO,CAAC;AAmHf,OAAO,EACL,iBAAiB,EAIlB,MAAM,kBAAkB,CAAC;AAkI1B,eAAO,MAAM,qBAAqB,OAAO,CAAC;AA6C1C,eAAO,MAAM,yBAAyB,UAAW,GAAG,YAYnD,CAAC;AAEF,eAAO,MAAM,YAAY,mFA0sgBvB,CAAC"}
@@ -69,17 +69,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
69
69
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
70
70
  }
71
71
  };
72
- var __rest = (this && this.__rest) || function (s, e) {
73
- var t = {};
74
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
75
- t[p] = s[p];
76
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
77
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
78
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
79
- t[p[i]] = s[p[i]];
80
- }
81
- return t;
82
- };
83
72
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
84
73
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
85
74
  if (ar || !(i in from)) {
@@ -744,6 +733,17 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
744
733
  // Intentionally separate from previousSelectedData, which advances on every
745
734
  // edit and therefore cannot serve as a stable submit baseline.
746
735
  var loadedSelectedData = (0, react_1.useRef)(null);
736
+ // INFO: the form edits a saved record — opened on one (not "new") and, for a
737
+ // deterministic-id upsert form (bareUpsertPartialUpdate), one that was found.
738
+ // A record not found yet is new: its defaults still prefill. Read at the time
739
+ // it is called — the ref is set as the record loads, and after its first save.
740
+ var handleIsSavedRecord = function () {
741
+ var _a;
742
+ return !!props.id &&
743
+ props.id !== "new" &&
744
+ (!((_a = props.bareSettings) === null || _a === void 0 ? void 0 : _a.bareUpsertPartialUpdate) ||
745
+ !!loadedSelectedData.current);
746
+ };
747
747
  // INFO: untouched DB doc for the current read record
748
748
  var rawReadData = (0, react_1.useRef)(null);
749
749
  // INFO: live-stream SSE client — created on mount when bareSocketName is set
@@ -3581,12 +3581,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
3581
3581
  // instead. That covers a read still in flight when the columns changed too:
3582
3582
  // it lands built from the old ones, and is rebuilt the same way. Hiding or
3583
3583
  // resizing a column changes nothing a cell shows.
3584
- var columnSignature = JSON.stringify(structure
3585
- .map(function (_a) {
3586
- var hide = _a.hide, width = _a.width, eachColumn = __rest(_a, ["hide", "width"]);
3587
- return eachColumn;
3588
- })
3589
- .sort(function (a, b) { return String(a.id).localeCompare(String(b.id)); }));
3584
+ var columnSignature = (0, utils_1.handleGetColumnSignature)(structure);
3590
3585
  // INFO: the columns the rows on screen were built from, and those a rebuild
3591
3586
  // under way is building them from
3592
3587
  var displaySignatureRef = (0, react_1.useRef)(columnSignature);
@@ -4702,13 +4697,15 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
4702
4697
  }
4703
4698
  });
4704
4699
  }); };
4705
- var handleUploadImage = function (id, data) { return __awaiter(void 0, void 0, void 0, function () {
4700
+ // INFO: isUpdate — the record already exists, so an emptied field is saved
4701
+ // empty rather than prefilled with its default (handleCastDataAttribute)
4702
+ var handleUploadImage = function (id, data, isUpdate) { return __awaiter(void 0, void 0, void 0, function () {
4706
4703
  var clonedSelectedData, objectAttribute, _i, objectAttribute_1, eachObject, listObjectAttribute, _a, listObjectAttribute_1, eachObject;
4707
4704
  var _b, _c, _d, _e;
4708
4705
  return __generator(this, function (_f) {
4709
4706
  switch (_f.label) {
4710
4707
  case 0:
4711
- clonedSelectedData = (0, updateModule_1.handleClonedDataAttribute)(data !== null && data !== void 0 ? data : selectedData, structure, props.devSettings.server, true, showId);
4708
+ clonedSelectedData = (0, updateModule_1.handleClonedDataAttribute)(data !== null && data !== void 0 ? data : selectedData, structure, props.devSettings.server, true, showId, isUpdate);
4712
4709
  return [4 /*yield*/, handleParseMarkdownField(id, clonedSelectedData, structure, modalFormInputRefs)];
4713
4710
  case 1:
4714
4711
  //INFO: Parse & Upload Data "Markdown attributes with delayed images"
@@ -5995,7 +5992,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
5995
5992
  });
5996
5993
  }); };
5997
5994
  var handleSubmitData = function (type, rowId, columnId, data, offlineId, isOfflineUpdate, isDraft) { return __awaiter(void 0, void 0, void 0, function () {
5998
- var selectedId, id, createSelectedData_1, uniqueDataStructure, uniqueColumnId, res, offlineDataResp, offlineData, clonedForOffline, tempData, selectedIndex_3, err_19, isUniqueIdFieldCreate, isExistingDoc, newRecordData_1, changedAttributeIds, baseDraftValue, hasBaseDraftChange, offlineDataResp, clonedForOffline, tempData, selectedIndex_4, offlineData, err_20, dataToSubmit_2, changedAttributeIds, baseDraftValue, hasBaseDraftChange, operationType, currentRow, wentToServer, dataId, err_21, offlineDataResp, offlineData, clonedForOffline, tempData, selectedIndex_5, _a;
5995
+ var selectedId, id, handleIsSavedSubmit, createSelectedData_1, uniqueDataStructure, uniqueColumnId, res, offlineDataResp, offlineData, clonedForOffline, tempData, selectedIndex_3, err_19, isUniqueIdFieldCreate, isExistingDoc, newRecordData_1, changedAttributeIds, baseDraftValue, hasBaseDraftChange, offlineDataResp, clonedForOffline, tempData, selectedIndex_4, offlineData, err_20, dataToSubmit_2, changedAttributeIds, baseDraftValue, hasBaseDraftChange, operationType, currentRow, wentToServer, dataId, err_21, offlineDataResp, offlineData, clonedForOffline, tempData, selectedIndex_5, _a;
5999
5996
  var _b, _c, _d, _e;
6000
5997
  var _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
6001
5998
  return __generator(this, function (_z) {
@@ -6003,6 +6000,16 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
6003
6000
  case 0:
6004
6001
  selectedId = "";
6005
6002
  id = "";
6003
+ handleIsSavedSubmit = function () {
6004
+ var _a;
6005
+ if (type === "update")
6006
+ return true;
6007
+ if (offlineId)
6008
+ return !!isOfflineUpdate;
6009
+ return (selectedId !== "new" &&
6010
+ (!((_a = props.bareSettings) === null || _a === void 0 ? void 0 : _a.bareUpsertPartialUpdate) ||
6011
+ !!loadedSelectedData.current));
6012
+ };
6006
6013
  _z.label = 1;
6007
6014
  case 1:
6008
6015
  _z.trys.push([1, 39, , 45]);
@@ -6033,7 +6040,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
6033
6040
  !offlineId)) return [3 /*break*/, 2];
6034
6041
  createSelectedData_1 = selectedData;
6035
6042
  return [3 /*break*/, 4];
6036
- case 2: return [4 /*yield*/, handleUploadImage(id, data)];
6043
+ case 2: return [4 /*yield*/, handleUploadImage(id, data, handleIsSavedSubmit())];
6037
6044
  case 3:
6038
6045
  createSelectedData_1 = _z.sent();
6039
6046
  _z.label = 4;
@@ -6239,7 +6246,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
6239
6246
  return [4 /*yield*/, indexedDb_1.indexedDb.getValue("local", props.collectionId)];
6240
6247
  case 19:
6241
6248
  offlineDataResp = _z.sent();
6242
- clonedForOffline = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId);
6249
+ clonedForOffline = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId, handleIsSavedSubmit());
6243
6250
  tempData = (0, updateModule_1.handleParseOfflineWrite)(clonedForOffline, structure);
6244
6251
  tempData[serverId] = selectedId;
6245
6252
  // INFO: Remove non-serializable keys that IDB's structured clone can't handle
@@ -6454,7 +6461,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
6454
6461
  case 41:
6455
6462
  offlineDataResp = _z.sent();
6456
6463
  offlineData = (_y = offlineDataResp === null || offlineDataResp === void 0 ? void 0 : offlineDataResp.data) !== null && _y !== void 0 ? _y : [];
6457
- clonedForOffline = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId);
6464
+ clonedForOffline = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId, handleIsSavedSubmit());
6458
6465
  tempData = (0, updateModule_1.handleParseOfflineWrite)(clonedForOffline, structure);
6459
6466
  if (!tempData[serverId])
6460
6467
  tempData[serverId] = id;
@@ -6604,7 +6611,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
6604
6611
  // re-sent on every subsequent save (harmless but wasteful), and the
6605
6612
  // "skip write if nothing changed" short-circuit would never trigger.
6606
6613
  if ((_c = props.bareSettings) === null || _c === void 0 ? void 0 : _c.bareUpsertPartialUpdate) {
6607
- loadedSelectedData.current = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId);
6614
+ loadedSelectedData.current = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId, true);
6608
6615
  // INFO: Reset dirty tracking after successful save — the new baseline
6609
6616
  // is the saved state, so all fields start "clean" again.
6610
6617
  dirtyFieldsRef.current.clear();
@@ -6667,7 +6674,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
6667
6674
  // Usually the component navigates away, but in case it doesn't (e.g. custom onComplete
6668
6675
  // that stays on the same page), ensure clean state for subsequent interactions.
6669
6676
  if ((_g = props.bareSettings) === null || _g === void 0 ? void 0 : _g.bareUpsertPartialUpdate) {
6670
- loadedSelectedData.current = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId);
6677
+ loadedSelectedData.current = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId, true);
6671
6678
  dirtyFieldsRef.current.clear();
6672
6679
  }
6673
6680
  if (props.onComplete) {
@@ -6876,6 +6883,11 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
6876
6883
  }
6877
6884
  });
6878
6885
  }); };
6886
+ // INFO: isUpdate — the data being changed belongs to records that already
6887
+ // exist, so a field emptied while editing is not prefilled with its default
6888
+ // again. An object or list item is a new entry (keeps its prefill); a batch
6889
+ // update edits saved records; the main form edits one when it was opened on
6890
+ // a record rather than "new".
6879
6891
  var handleOnChangeData = function () {
6880
6892
  var _a;
6881
6893
  if (modalVisible && selectedObjectStructureId) {
@@ -6885,18 +6897,21 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
6885
6897
  return {
6886
6898
  data: selectedObjectData,
6887
6899
  model: (_a = filterObjectModel === null || filterObjectModel === void 0 ? void 0 : filterObjectModel.objectData) !== null && _a !== void 0 ? _a : [],
6900
+ isUpdate: false,
6888
6901
  };
6889
6902
  }
6890
6903
  else if (batchUpdateModal && batchUpdateData.columnId) {
6891
6904
  return {
6892
6905
  data: batchUpdateData.columnData,
6893
6906
  model: structure,
6907
+ isUpdate: true,
6894
6908
  };
6895
6909
  }
6896
6910
  else {
6897
6911
  return {
6898
6912
  data: selectedData,
6899
6913
  model: structure,
6914
+ isUpdate: handleIsSavedRecord(),
6900
6915
  };
6901
6916
  }
6902
6917
  };
@@ -6910,7 +6925,9 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
6910
6925
  if (selectedModel) {
6911
6926
  //INFO: [UPDATE] Update data via batch modal
6912
6927
  var clonedData = JSON.parse(JSON.stringify(data));
6913
- (0, updateModule_1.handleCastDataAttribute)(selectedModel, data, clonedData, dbModule, true);
6928
+ (0, updateModule_1.handleCastDataAttribute)(selectedModel, data, clonedData, dbModule, true,
6929
+ // INFO: a batch update edits saved records — no default prefill
6930
+ true);
6914
6931
  setBatchUpdateData({
6915
6932
  columnId: batchUpdateData.columnId,
6916
6933
  columnData: (_a = {},
@@ -6925,16 +6942,16 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
6925
6942
  }
6926
6943
  };
6927
6944
  var handleOnChangeFile = function (e) {
6928
- var _a = handleOnChangeData(), data = _a.data, model = _a.model;
6929
- var clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId);
6945
+ var _a = handleOnChangeData(), data = _a.data, model = _a.model, isUpdate = _a.isUpdate;
6946
+ var clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId, isUpdate);
6930
6947
  clonedData[e.target.id] =
6931
6948
  e.target.files.length > 0 ? e.target.files[0] : undefined;
6932
6949
  handleUpdateChangeData(clonedData);
6933
6950
  };
6934
6951
  var handleOnChangeFiles = function (id, value, action) {
6935
6952
  var _a, _b;
6936
- var _c = handleOnChangeData(), data = _c.data, model = _c.model;
6937
- var clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId);
6953
+ var _c = handleOnChangeData(), data = _c.data, model = _c.model, isUpdate = _c.isUpdate;
6954
+ var clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId, isUpdate);
6938
6955
  var previousData = clonedData[id] && clonedData[id]["data"] ? clonedData[id]["data"] : [];
6939
6956
  var previousUploadData = clonedData[id] && clonedData[id]["upload"]
6940
6957
  ? clonedData[id]["upload"]
@@ -7001,7 +7018,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
7001
7018
  }
7002
7019
  };
7003
7020
  var handleSignatureComplete = function (dataURL, id) {
7004
- var model = handleOnChangeData().model;
7021
+ var _a = handleOnChangeData(), model = _a.model, isUpdate = _a.isUpdate;
7005
7022
  // Helper function to determine if we should preserve the existing token
7006
7023
  var shouldPreserveToken = function (currentValue, newDataURL) {
7007
7024
  // If newDataURL is empty but there's an existing token, preserve it
@@ -7019,7 +7036,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
7019
7036
  if (modalVisible && selectedObjectStructureId) {
7020
7037
  // For modal case, update selectedObjectData
7021
7038
  setSelectedObjectData(function (prevObjectData) {
7022
- var clonedData = (0, updateModule_1.handleClonedDataAttribute)(prevObjectData, model, props.devSettings.server, false, remainId);
7039
+ var clonedData = (0, updateModule_1.handleClonedDataAttribute)(prevObjectData, model, props.devSettings.server, false, remainId, isUpdate);
7023
7040
  // Preserve token if dataURL is empty and there's an existing token
7024
7041
  if (shouldPreserveToken(clonedData[id], dataURL)) {
7025
7042
  // Don't overwrite - keep the existing token
@@ -7054,7 +7071,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
7054
7071
  // Normal case: Use functional update to ensure we're working with the latest state
7055
7072
  // This prevents the issue where handleClonedDataAttribute copies stale state
7056
7073
  setSelectedData(function (prevSelectedData) {
7057
- var clonedData = (0, updateModule_1.handleClonedDataAttribute)(prevSelectedData, model, props.devSettings.server, false, remainId);
7074
+ var clonedData = (0, updateModule_1.handleClonedDataAttribute)(prevSelectedData, model, props.devSettings.server, false, remainId, isUpdate);
7058
7075
  // If dataURL is empty but there's an existing token, preserve it
7059
7076
  // This happens when signature validation passes but user didn't draw a new signature
7060
7077
  // or when user cleared but didn't draw anything new
@@ -7072,24 +7089,24 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
7072
7089
  // But we can verify it worked by checking in the next render or at submission
7073
7090
  };
7074
7091
  var handleOnChangeAddress = function (id, address) {
7075
- var _a = handleOnChangeData(), data = _a.data, model = _a.model;
7076
- var clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId);
7092
+ var _a = handleOnChangeData(), data = _a.data, model = _a.model, isUpdate = _a.isUpdate;
7093
+ var clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId, isUpdate);
7077
7094
  clonedData[id] = address;
7078
7095
  handleUpdateChangeData(clonedData);
7079
7096
  };
7080
7097
  var handleOnChangeText = function (e) {
7081
- var _a = handleOnChangeData(), data = _a.data, model = _a.model;
7098
+ var _a = handleOnChangeData(), data = _a.data, model = _a.model, isUpdate = _a.isUpdate;
7082
7099
  data[e.target.id] = e.target.value;
7083
- var clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId);
7100
+ var clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId, isUpdate);
7084
7101
  handleUpdateChangeData(clonedData);
7085
7102
  };
7086
7103
  var handleOnChangeSelect = function (id, value) { return __awaiter(void 0, void 0, void 0, function () {
7087
- var _a, data, model, clonedData, refetchReference, currentSchema, allowedWatchedColumnTypes_1, watchedColumns, _i, watchedColumns_1, eachWatched, dependency, referenceRQ, valueRes, err_24;
7104
+ var _a, data, model, isUpdate, clonedData, refetchReference, currentSchema, allowedWatchedColumnTypes_1, watchedColumns, _i, watchedColumns_1, eachWatched, dependency, referenceRQ, valueRes, err_24;
7088
7105
  return __generator(this, function (_b) {
7089
7106
  switch (_b.label) {
7090
7107
  case 0:
7091
- _a = handleOnChangeData(), data = _a.data, model = _a.model;
7092
- clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId);
7108
+ _a = handleOnChangeData(), data = _a.data, model = _a.model, isUpdate = _a.isUpdate;
7109
+ clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId, isUpdate);
7093
7110
  refetchReference = false;
7094
7111
  if (!((Array.isArray(value) && value.includes("creation")) ||
7095
7112
  value === "creation")) return [3 /*break*/, 1];
@@ -7161,14 +7178,14 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
7161
7178
  });
7162
7179
  }); };
7163
7180
  var handleOnChangeDate = function (id, value) {
7164
- var _a = handleOnChangeData(), data = _a.data, model = _a.model;
7165
- var clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId);
7181
+ var _a = handleOnChangeData(), data = _a.data, model = _a.model, isUpdate = _a.isUpdate;
7182
+ var clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId, isUpdate);
7166
7183
  clonedData[id] = value;
7167
7184
  handleUpdateChangeData(clonedData);
7168
7185
  };
7169
7186
  var handleOnChangeMarkdown = function (id, value) {
7170
- var _a = handleOnChangeData(), data = _a.data, model = _a.model;
7171
- var clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId);
7187
+ var _a = handleOnChangeData(), data = _a.data, model = _a.model, isUpdate = _a.isUpdate;
7188
+ var clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId, isUpdate);
7172
7189
  clonedData[id] = value;
7173
7190
  handleUpdateChangeData(clonedData);
7174
7191
  };
@@ -9628,6 +9645,8 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
9628
9645
  id: props.id,
9629
9646
  isObject: isObject,
9630
9647
  isObjectList: isObjectList,
9648
+ // INFO: a saved record shows its empty fields empty, not prefilled
9649
+ isUpdate: handleIsSavedRecord(),
9631
9650
  lib: {
9632
9651
  axios: (_a = props.lib) === null || _a === void 0 ? void 0 : _a.axios,
9633
9652
  Transition: (_b = props === null || props === void 0 ? void 0 : props.lib) === null || _b === void 0 ? void 0 : _b.Transition,