@apia/execution 5.0.1 → 5.0.6

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.
Files changed (94) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/main/Execution/Entity/index.d.ts +1 -1
  3. package/dist/main/Execution/Entity/index.js +5 -3
  4. package/dist/main/Execution/Entity/index.js.map +1 -1
  5. package/dist/main/Execution/EntityFlowModals/confirmFlow.js +33 -6
  6. package/dist/main/Execution/EntityFlowModals/confirmFlow.js.map +1 -1
  7. package/dist/main/Execution/FlowModals/FlowModal.d.ts +1 -0
  8. package/dist/main/Execution/FlowModals/FlowModal.js.map +1 -1
  9. package/dist/main/Execution/FlowModals/confirmFlow.js +15 -3
  10. package/dist/main/Execution/FlowModals/confirmFlow.js.map +1 -1
  11. package/dist/main/Execution/FormsExecution/Field.js +5 -1
  12. package/dist/main/Execution/FormsExecution/Field.js.map +1 -1
  13. package/dist/main/Execution/FormsExecution/FieldWithAttribute.d.ts +3 -2
  14. package/dist/main/Execution/FormsExecution/FieldWithAttribute.js +13 -3
  15. package/dist/main/Execution/FormsExecution/FieldWithAttribute.js.map +1 -1
  16. package/dist/main/Execution/FormsExecution/Form.js +3 -1
  17. package/dist/main/Execution/FormsExecution/Form.js.map +1 -1
  18. package/dist/main/Execution/FormsExecution/TranslatableField/index.js +2 -0
  19. package/dist/main/Execution/FormsExecution/TranslatableField/index.js.map +1 -1
  20. package/dist/main/Execution/FormsExecution/WithProperties.js +1 -1
  21. package/dist/main/Execution/FormsExecution/WithProperties.js.map +1 -1
  22. package/dist/main/Execution/FormsExecution/constants/props/booleanProps.js +1 -0
  23. package/dist/main/Execution/FormsExecution/constants/props/booleanProps.js.map +1 -1
  24. package/dist/main/Execution/FormsExecution/events/setAjaxFormResponse.js +76 -23
  25. package/dist/main/Execution/FormsExecution/events/setAjaxFormResponse.js.map +1 -1
  26. package/dist/main/Execution/FormsExecution/fields/Captcha/index.js +2 -0
  27. package/dist/main/Execution/FormsExecution/fields/Captcha/index.js.map +1 -1
  28. package/dist/main/Execution/FormsExecution/fields/Editor/index.d.ts +2 -0
  29. package/dist/main/Execution/FormsExecution/fields/Editor/index.js +15 -0
  30. package/dist/main/Execution/FormsExecution/fields/Editor/index.js.map +1 -1
  31. package/dist/main/Execution/FormsExecution/fields/File/index.js +2 -2
  32. package/dist/main/Execution/FormsExecution/fields/File/index.js.map +1 -1
  33. package/dist/main/Execution/FormsExecution/fields/Grid/GridFooterHandler.d.ts +2 -0
  34. package/dist/main/Execution/FormsExecution/fields/Grid/GridFooterHandler.js +16 -12
  35. package/dist/main/Execution/FormsExecution/fields/Grid/GridFooterHandler.js.map +1 -1
  36. package/dist/main/Execution/FormsExecution/fields/Grid/index.d.ts +11 -3
  37. package/dist/main/Execution/FormsExecution/fields/Grid/index.js +163 -53
  38. package/dist/main/Execution/FormsExecution/fields/Grid/index.js.map +1 -1
  39. package/dist/main/Execution/FormsExecution/fields/Grid/types.d.ts +6 -1
  40. package/dist/main/Execution/FormsExecution/fields/GridPaginated/index.d.ts +11 -1
  41. package/dist/main/Execution/FormsExecution/fields/GridPaginated/index.js +82 -33
  42. package/dist/main/Execution/FormsExecution/fields/GridPaginated/index.js.map +1 -1
  43. package/dist/main/Execution/FormsExecution/fields/Input/index.js +6 -2
  44. package/dist/main/Execution/FormsExecution/fields/Input/index.js.map +1 -1
  45. package/dist/main/Execution/FormsExecution/fields/ModalInput/index.js +28 -12
  46. package/dist/main/Execution/FormsExecution/fields/ModalInput/index.js.map +1 -1
  47. package/dist/main/Execution/FormsExecution/fields/Multiple/index.js +1 -1
  48. package/dist/main/Execution/FormsExecution/fields/Multiple/index.js.map +1 -1
  49. package/dist/main/Execution/Signature/SignatureController.d.ts +110 -8
  50. package/dist/main/Execution/Signature/SignatureController.js +252 -9
  51. package/dist/main/Execution/Signature/SignatureController.js.map +1 -1
  52. package/dist/main/Execution/Signature/TProvider.d.ts +14 -0
  53. package/dist/main/Execution/Signature/TProvider.d.ts.map +1 -0
  54. package/dist/main/Execution/Signature/TProviderStatus.d.ts +13 -0
  55. package/dist/main/Execution/Signature/TProviderStatus.d.ts.map +1 -0
  56. package/dist/main/Execution/Uploader/FormsUploader.d.ts +21 -0
  57. package/dist/main/Execution/Uploader/FormsUploader.js +31 -5
  58. package/dist/main/Execution/Uploader/FormsUploader.js.map +1 -1
  59. package/dist/main/Execution/Uploader/UploaderApi.d.ts +2 -0
  60. package/dist/main/Execution/Uploader/UploaderApi.js +19 -0
  61. package/dist/main/Execution/Uploader/UploaderApi.js.map +1 -1
  62. package/dist/main/Execution/index.d.ts +12 -3
  63. package/dist/main/Execution/index.js +64 -39
  64. package/dist/main/Execution/index.js.map +1 -1
  65. package/dist/main/Execution/types.d.ts +1 -0
  66. package/dist/main/Execution/types.js.map +1 -1
  67. package/dist/main/InitialData/types/TApiaField.d.ts +2 -0
  68. package/dist/main/InitialData/types/fields/TApiaFieldProperties.d.ts +1 -0
  69. package/dist/programming/ApiaFieldWithAttribute.d.ts +3 -3
  70. package/dist/programming/ApiaFieldWithAttribute.js +3 -3
  71. package/dist/programming/ApiaFieldWithAttribute.js.map +1 -1
  72. package/dist/programming/constants/BooleanProps.js +1 -0
  73. package/dist/programming/constants/BooleanProps.js.map +1 -1
  74. package/dist/programming/fields/CheckField.d.ts +2 -2
  75. package/dist/programming/fields/CheckField.js +2 -2
  76. package/dist/programming/fields/CheckField.js.map +1 -1
  77. package/dist/programming/fields/FileUploaderField.d.ts +1 -1
  78. package/dist/programming/fields/FileUploaderField.js +3 -3
  79. package/dist/programming/fields/FileUploaderField.js.map +1 -1
  80. package/dist/programming/fields/InputField.d.ts +2 -2
  81. package/dist/programming/fields/InputField.js +10 -3
  82. package/dist/programming/fields/InputField.js.map +1 -1
  83. package/dist/programming/fields/ModalInput.d.ts +1 -1
  84. package/dist/programming/fields/ModalInput.js +3 -3
  85. package/dist/programming/fields/ModalInput.js.map +1 -1
  86. package/dist/programming/fields/MultipleField.d.ts +2 -2
  87. package/dist/programming/fields/MultipleField.js +12 -5
  88. package/dist/programming/fields/MultipleField.js.map +1 -1
  89. package/dist/programming/fields/TreeField.d.ts +1 -1
  90. package/dist/programming/fields/TreeField.js +1 -1
  91. package/dist/programming/fields/TreeField.js.map +1 -1
  92. package/dist/util/xml/parseXml.js +3 -0
  93. package/dist/util/xml/parseXml.js.map +1 -1
  94. package/package.json +7 -7
@@ -6,7 +6,7 @@ import { Field } from '../../Field.js';
6
6
  import { parseFakeJSON } from '../../../../../util/other/parseFakeJSON.js';
7
7
  import { GridFooterHandler } from './GridFooterHandler.js';
8
8
  import { GridCell } from './GridCell.js';
9
- import { Mutex, arrayOrArray } from '@apia/util';
9
+ import { Mutex, arrayOrArray, isTrue } from '@apia/util';
10
10
  import { AdditionalCell } from './AdditionalCell.js';
11
11
  import { setAjaxFormResponse } from '../../events/setAjaxFormResponse.js';
12
12
  import { File } from '../File/index.js';
@@ -32,6 +32,18 @@ async function inlineTimeout(cb, _t) {
32
32
  setTimeout(cb, _t);
33
33
  return Promise.resolve(true);
34
34
  }
35
+ const restoreBodyRows = (controller, rows) => {
36
+ rows.forEach((row) => {
37
+ row.setTable(controller);
38
+ row.setContainer(controller.body);
39
+ });
40
+ controller.body.setState("rows", rows);
41
+ };
42
+ const getGridStatesRowCount = (states, includeFirstRow) => Math.max(
43
+ includeFirstRow && states.length > 0 ? 1 : 0,
44
+ 0,
45
+ ...states.map((fieldStates) => fieldStates.length)
46
+ );
35
47
  class Grid extends Field {
36
48
  constructor(definition) {
37
49
  const parsedDefinition = Grid.parseGridDefinition(definition);
@@ -68,23 +80,27 @@ class Grid extends Field {
68
80
  __publicField(this, "tableController");
69
81
  const fieldsArray = arrayOrArray(field);
70
82
  this.initialStates = fieldsArray.map(
71
- (current) => current.fieldValue || current.row ? arrayOrArray(current.fieldValue || current.row) : void 0
72
- ).filter(Boolean);
83
+ (current) => arrayOrArray(current.fieldValue || current.row)
84
+ );
73
85
  this.fieldsDefinitions = fieldsArray.map(
74
86
  ({ fieldValue, properties: properties2, ...current }) => {
75
87
  return { ...current, properties: parseFakeJSON(properties2) };
76
88
  }
77
89
  );
78
90
  this.state.header = arrayOrArray(parsedDefinition.gridHeader.col).map(
79
- (c) => ({
80
- fldId: c.fldId,
81
- label: c.colTitle,
82
- title: c.title,
83
- width: c.colWidth || this.resolveHeaderWidth(c),
84
- hidden: false,
85
- required: false,
86
- fldType: c.fldType
87
- })
91
+ (c) => {
92
+ const defaultWidth = this.resolveHeaderWidth(c);
93
+ return {
94
+ fldId: c.fldId,
95
+ label: c.colTitle,
96
+ title: c.title,
97
+ width: c.colWidth || defaultWidth,
98
+ defaultWidth,
99
+ hidden: false,
100
+ required: false,
101
+ fldType: c.fldType
102
+ };
103
+ }
88
104
  );
89
105
  this.state.isLoading = false;
90
106
  this.state.isMaximized = false;
@@ -92,6 +108,11 @@ class Grid extends Field {
92
108
  get controller() {
93
109
  return this.tableController;
94
110
  }
111
+ get isSmallGridMode() {
112
+ const execution = this.getForm()?.execution;
113
+ const dataGridConfig = (execution?.environment ? getWindow(execution) : globalThis.window)?.config?.execution?.components?.dataGrid;
114
+ return dataGridConfig?.gridView === "small";
115
+ }
95
116
  get currentPage() {
96
117
  return this.properties.currentPage;
97
118
  }
@@ -102,7 +123,13 @@ class Grid extends Field {
102
123
  * Returns the final index of the current page
103
124
  */
104
125
  get finalIndex() {
105
- return (this.controller.body.rows.at(-1)?.cells.find((c) => c instanceof GridCell)).getField().definition.index;
126
+ let lastGridCell;
127
+ for (let rowIndex = this.controller.body.rows.length - 1; rowIndex >= 0 && !lastGridCell; rowIndex--) {
128
+ lastGridCell = this.controller.body.rows[rowIndex].cells.find(
129
+ (cell) => cell instanceof GridCell
130
+ );
131
+ }
132
+ return lastGridCell?.getField().definition.index ?? this.startIndex + this.controller.body.rows.length - 1;
106
133
  }
107
134
  get footerController() {
108
135
  return this._footerController;
@@ -116,6 +143,16 @@ class Grid extends Field {
116
143
  get length() {
117
144
  return this.tableController.body.rows.length;
118
145
  }
146
+ get hasReachedMaxRows() {
147
+ const maxRows = Number(this.properties.maxRows);
148
+ if (!Number.isFinite(maxRows) || maxRows <= 0)
149
+ return false;
150
+ const declaredRows = Number(
151
+ this.definition.rowCount
152
+ );
153
+ const rowsCount = this.isPaged && Number.isFinite(declaredRows) ? Math.max(declaredRows, this.startIndex + this.length) : this.length;
154
+ return rowsCount >= maxRows;
155
+ }
119
156
  get minIndex() {
120
157
  return Number.isFinite(this.properties.pageSize) ? (this.properties.currentPage - 1) * this.properties.pageSize : 0;
121
158
  }
@@ -176,10 +213,49 @@ class Grid extends Field {
176
213
  ].join("__");
177
214
  }
178
215
  resolveHeaderWidth(c) {
216
+ const narrowWidth = this.isSmallGridMode ? "180px" : "150px";
217
+ const defaultWidth = this.isSmallGridMode ? "220px" : "230px";
179
218
  if (c.fldType === "3") {
180
- return "150px";
219
+ return narrowWidth;
220
+ }
221
+ return defaultWidth;
222
+ }
223
+ shouldShowAdditionalColumn() {
224
+ return this.isSmallGridMode || this.properties.gridForm || !this.properties.hideDelButton && !this.properties.readonly && !this.properties.inputAsText && !this.getForm().definition.readOnly && !this.getForm().definition.readonly && getWindow(this.getForm().execution)?.config?.execution?.components?.dataGrid?.showDeleteButton;
225
+ }
226
+ hasPercentageColumnWidths() {
227
+ return this.header.some(
228
+ (col) => String(col.width || "").trim().endsWith("%")
229
+ );
230
+ }
231
+ parsePercentWidth(width) {
232
+ const normalizedWidth = String(width ?? "").trim();
233
+ if (!normalizedWidth.endsWith("%"))
234
+ return null;
235
+ const parsed = Number.parseFloat(normalizedWidth);
236
+ return Number.isFinite(parsed) ? parsed : null;
237
+ }
238
+ getHeaderWidthContext(hiddenColumns) {
239
+ const visibleColumns = this.header.filter(
240
+ (col) => !hiddenColumns.has(col.fldId)
241
+ );
242
+ const totalPercent = visibleColumns.reduce(
243
+ (total, col) => total + (this.parsePercentWidth(col.width) ?? 0),
244
+ 0
245
+ );
246
+ return { totalPercent };
247
+ }
248
+ normalizeHeaderWidth(width, widthContext) {
249
+ const normalizedWidth = String(width ?? 200).trim();
250
+ const percentWidth = this.parsePercentWidth(normalizedWidth);
251
+ if (percentWidth !== null && widthContext?.totalPercent) {
252
+ const percentShare = percentWidth / widthContext.totalPercent;
253
+ return `${percentShare * 100}%`;
181
254
  }
182
- return "230px";
255
+ if (normalizedWidth.endsWith("%") || normalizedWidth.endsWith("px")) {
256
+ return normalizedWidth;
257
+ }
258
+ return `${normalizedWidth}px`;
183
259
  }
184
260
  getGridActionFromEventName(eventName) {
185
261
  switch (eventName) {
@@ -194,8 +270,11 @@ class Grid extends Field {
194
270
  }
195
271
  }
196
272
  fireServerEvent(eventName, params) {
273
+ const focusedCell = this.controller.getFocusedCell();
197
274
  return super.fireServerEvent(eventName, {
198
275
  gridAction: this.getGridActionFromEventName(eventName),
276
+ gridFocusedRow: focusedCell?.getRow()?.getIndex() === void 0 ? void 0 : focusedCell.getRow().getIndex() + this.startIndex,
277
+ gridFocusedColumn: focusedCell?.getState("colName"),
199
278
  ...params
200
279
  });
201
280
  }
@@ -219,8 +298,8 @@ class Grid extends Field {
219
298
  const xml = Grid.parseGridDefinition(response.data.gridXml);
220
299
  const fieldsArray = arrayOrArray(xml.field);
221
300
  this.newRowStates = fieldsArray.map(
222
- (current) => current.fieldValue || current.row ? arrayOrArray(current.fieldValue || current.row) : void 0
223
- ).filter(Boolean);
301
+ (current) => arrayOrArray(current.fieldValue || current.row)
302
+ );
224
303
  } else {
225
304
  throw new Error(
226
305
  !getWindow(this.form.execution).SERVER_MODE ? "Something went wrong on the add row action." : ""
@@ -230,7 +309,7 @@ class Grid extends Field {
230
309
  true,
231
310
  this.fieldsDefinitions.map((c, i) => ({
232
311
  ...c,
233
- ...this.newRowStates[i][0]
312
+ ...this.newRowStates[i]?.[0]
234
313
  }))
235
314
  );
236
315
  return await (this.hasServerAjaxEventsOfType("gridAdd") ? inlineCaller : inlineTimeout)(async () => {
@@ -283,7 +362,7 @@ class Grid extends Field {
283
362
  setAjaxFormResponse(this.form.execution, parseXml(evs));
284
363
  }
285
364
  if (!(await res)?.data?.success) {
286
- this.tableController.body.setState("rows", currentRows);
365
+ restoreBodyRows(this.tableController, currentRows);
287
366
  this.tableController.setState("selection", currentSelection);
288
367
  return false;
289
368
  }
@@ -293,7 +372,7 @@ class Grid extends Field {
293
372
  /**
294
373
  * @param index Si se pasa, se borran el o los índices provistos. Sino, se borran las filas seleccionadas, si es que hay alguna.
295
374
  */
296
- async deleteRows(index) {
375
+ async deleteRows(index, options) {
297
376
  return this.asyncAction(async () => {
298
377
  if (void 0 === index) {
299
378
  index = [...this.controller.getState("selection")].map((c) => {
@@ -306,7 +385,8 @@ class Grid extends Field {
306
385
  if (this.hasServerNoAjaxEventsOfType("gridDelete")) {
307
386
  await this.fireServerEvent("gridDelete", {
308
387
  gridAction: "delete",
309
- rowId: deletingIndices
388
+ rowId: deletingIndices,
389
+ ...options
310
390
  });
311
391
  } else {
312
392
  let minIndex = Infinity;
@@ -320,7 +400,8 @@ class Grid extends Field {
320
400
  postData: {
321
401
  gridAction: "delete",
322
402
  rowId: deletingIndices,
323
- fireEvents: this.hasServerAjaxEventsOfType("gridDelete")
403
+ fireEvents: this.hasServerAjaxEventsOfType("gridDelete"),
404
+ ...options
324
405
  }
325
406
  });
326
407
  const currentRows = [...this.tableController.body.rows];
@@ -328,7 +409,7 @@ class Grid extends Field {
328
409
  this.tableController.getState("selection")
329
410
  );
330
411
  deletingIndices.forEach(
331
- (c) => this.controller.body.getRowByIndex(c).remove()
412
+ (c) => this.controller.body.getRowByIndex(c)?.remove()
332
413
  );
333
414
  for (let i = minIndex; i < this.controller.body.rows.length; i++) {
334
415
  this.controller.body.getRowByIndex(i).cells.forEach((c) => {
@@ -350,9 +431,9 @@ class Grid extends Field {
350
431
  if (evs) {
351
432
  setAjaxFormResponse(this.form.execution, parseXml(evs));
352
433
  }
353
- const scriptResult = await this.fireScriptEvent("gridAdd");
434
+ const scriptResult = await this.fireScriptEvent("gridDelete");
354
435
  if (!scriptResult || !(await res)?.data?.success) {
355
- this.tableController.body.setState("rows", currentRows);
436
+ restoreBodyRows(this.tableController, currentRows);
356
437
  this.tableController.setState("selection", currentSelection);
357
438
  return false;
358
439
  }
@@ -472,7 +553,10 @@ class Grid extends Field {
472
553
  for (let i = 0; i < this.tableController.head.rows[0]?.cells.length || 0; i++) {
473
554
  for (const row of this.tableController.head.rows) {
474
555
  const cell = row.cells[i];
475
- if (cell instanceof HeaderCell && cell.getState("isHidden")) {
556
+ const fieldDefinition = this.fieldsDefinitions.find(
557
+ (definition) => definition.id === cell.getState("colName")
558
+ );
559
+ if (cell instanceof HeaderCell && (fieldDefinition?.properties.visibilityHidden || fieldDefinition?.properties.displayNone || fieldDefinition?.fieldType === "hidden")) {
476
560
  shownColumns.delete(cell.getState("colName"));
477
561
  break;
478
562
  }
@@ -502,10 +586,14 @@ class Grid extends Field {
502
586
  );
503
587
  this._footerController = new GridFooterHandler(this);
504
588
  this.controller.on("columnSort", (col) => {
505
- this.sortColumn(col.getState("properties").col.fldId);
589
+ const column = col.getState("properties")?.col;
590
+ if (column) {
591
+ this.sortColumn(column.fldId);
592
+ }
506
593
  });
507
594
  const headerRow = new Row("header");
508
- if (this.properties.gridForm || !this.properties.hideDelButton && !this.properties.readonly && !this.properties.inputAsText && !this.getForm().definition.readOnly && !this.getForm().definition.readonly && getWindow(this.getForm().execution)?.config?.execution?.components?.dataGrid?.showDeleteButton)
595
+ const hasAdditionalColumn = this.shouldShowAdditionalColumn();
596
+ if (hasAdditionalColumn)
509
597
  headerRow.addCell(
510
598
  new AdditionalCell(
511
599
  this,
@@ -519,26 +607,28 @@ class Grid extends Field {
519
607
  hiddenColumns.add(c.fldId);
520
608
  });
521
609
  for (const def of this.fieldsDefinitions) {
522
- if (!def.properties.visibilityHidden && def.fieldType !== "hidden") {
610
+ if (!def.properties.visibilityHidden && !def.properties.displayNone && def.fieldType !== "hidden") {
523
611
  hiddenColumns.delete(def.id);
524
612
  }
525
613
  }
526
- for (let index = 0; index < this.initialStates[0]?.length || 0; index++) {
614
+ const initialRowsCount = getGridStatesRowCount(
615
+ this.initialStates,
616
+ isTrue(this.getProperty("includeFirstRow"))
617
+ );
618
+ for (let index = 0; index < initialRowsCount; index++) {
527
619
  await this.addRowFromDefinitions(
528
620
  false,
529
621
  this.fieldsDefinitions.map((c, i) => {
530
622
  return {
531
623
  ...c,
532
- ...this.initialStates[i][index]
624
+ ...this.initialStates[i]?.[index]
533
625
  };
534
626
  })
535
627
  );
536
628
  }
629
+ const widthContext = this.getHeaderWidthContext(hiddenColumns);
537
630
  this.header.forEach((col, i) => {
538
- let width = String(col.width || 200);
539
- if (!width.endsWith("px")) {
540
- width = `${width}px`;
541
- }
631
+ const width = this.normalizeHeaderWidth(col.width, widthContext);
542
632
  headerRow.addCell(
543
633
  new HeaderCell(this, {
544
634
  colName: col.fldId || String(i),
@@ -621,7 +711,7 @@ class Grid extends Field {
621
711
  );
622
712
  if (this.hasServerNoAjaxEventsOfType("gridSort")) {
623
713
  await this.fireServerEvent("gridSort", {
624
- gridAction: "down",
714
+ gridAction: "up",
625
715
  rowId: indices
626
716
  });
627
717
  } else {
@@ -666,6 +756,8 @@ class Grid extends Field {
666
756
  this.calculateMustShowAdditionalColumn();
667
757
  }
668
758
  async validate() {
759
+ if (this.properties.displayNone)
760
+ return true;
669
761
  let isValid = true;
670
762
  let firstInvalid = null;
671
763
  for await (const row of this.tableController.body.rows) {
@@ -683,13 +775,17 @@ class Grid extends Field {
683
775
  return isValid || firstInvalid;
684
776
  }
685
777
  async actualRefreshAction() {
778
+ const previousVisibilityHidden = this.properties.visibilityHidden;
686
779
  const res = await this.runAction({
687
780
  postData: {
688
781
  gridAction: "refresh"
689
782
  }
690
783
  });
691
784
  if (res?.data?.gridXml) {
692
- await this.rebuildGrid(res.data.gridXml, { recreateRows: true });
785
+ await this.rebuildGrid(res.data.gridXml, {
786
+ recreateRows: true,
787
+ previousVisibilityHidden
788
+ });
693
789
  } else {
694
790
  throw new Error("The server didn't return a valid XML response.");
695
791
  }
@@ -704,7 +800,7 @@ class Grid extends Field {
704
800
  this.getForm().addFieldToRender(current.id, index);
705
801
  return {
706
802
  ...current,
707
- ...this.initialStates[columnIndex][0]
803
+ ...this.initialStates[columnIndex]?.[0]
708
804
  };
709
805
  });
710
806
  }
@@ -712,7 +808,7 @@ class Grid extends Field {
712
808
  cells: [],
713
809
  isSelectable: true
714
810
  });
715
- if (this.properties.gridForm || !this.properties.hideDelButton && !this.properties.readonly && !this.properties.inputAsText && !this.getForm().definition.readOnly && !this.getForm().definition.readonly && getWindow(this.getForm().execution)?.config?.execution?.components?.dataGrid?.showDeleteButton)
811
+ if (this.isSmallGridMode || this.properties.gridForm || !this.properties.hideDelButton && !this.properties.readonly && !this.properties.inputAsText && !this.getForm().definition.readOnly && !this.getForm().definition.readonly && getWindow(this.getForm().execution)?.config?.execution?.components?.dataGrid?.showDeleteButton)
716
812
  newRow.addCell(
717
813
  new AdditionalCell(
718
814
  this,
@@ -748,12 +844,6 @@ class Grid extends Field {
748
844
  this.managedFieldsNames.add(newField.properties.name);
749
845
  if (!(newField instanceof Hidden)) {
750
846
  this.cache.set(index, newField.definition.id, newField);
751
- let width = String(
752
- this.header.find((c) => c.fldId === field.id)?.width || 250
753
- );
754
- if (!width.endsWith("px")) {
755
- width = `${width}px`;
756
- }
757
847
  newRow.addCell(
758
848
  new GridCell({
759
849
  colName: newField.definition.id,
@@ -790,7 +880,7 @@ class Grid extends Field {
790
880
  }
791
881
  calculateMustShowAdditionalColumn() {
792
882
  const { hideDelButton, shownDeleteButtons, shownEditionButtons, gridForm } = this.properties;
793
- const mustShowAdditionalColumn = !hideDelButton && [...shownDeleteButtons.values()].some((c) => c !== false) || !!gridForm && [...shownEditionButtons.values()].some((c) => c !== false);
883
+ const mustShowAdditionalColumn = this.isSmallGridMode || !hideDelButton && [...shownDeleteButtons.values()].some((c) => c !== false) || !!gridForm && [...shownEditionButtons.values()].some((c) => c !== false);
794
884
  this.controller.toggleColumnVisibility(
795
885
  "additional",
796
886
  mustShowAdditionalColumn
@@ -801,21 +891,39 @@ class Grid extends Field {
801
891
  }
802
892
  async rebuildGrid(xmlString, options) {
803
893
  const xml = Grid.parseGridDefinition(xmlString);
894
+ const preserveColumnVisibilities = options?.previousVisibilityHidden !== void 0 && xml.properties.visibilityHidden !== void 0 && isTrue(xml.properties.visibilityHidden) !== isTrue(options.previousVisibilityHidden);
804
895
  const fieldsArray = arrayOrArray(xml.field);
805
896
  const statesArray = fieldsArray.map(
806
897
  (field) => arrayOrArray(field.fieldValue || field.row)
807
898
  );
808
- const rowCount = statesArray[0]?.length || 0;
899
+ const rowCount = getGridStatesRowCount(
900
+ statesArray,
901
+ isTrue(
902
+ xml.properties.includeFirstRow ?? this.getProperty("includeFirstRow")
903
+ )
904
+ );
809
905
  this.properties.pages = xml.pages || this.properties.pages;
810
906
  this.properties.currentPage = xml.curPage || this.properties.currentPage;
811
907
  this.properties.visibilityHidden = xml.properties.visibilityHidden ?? this.properties.visibilityHidden;
908
+ this.properties.displayNone = xml.properties.displayNone ?? this.properties.displayNone;
909
+ if (xml.properties.readonly !== void 0) {
910
+ this.setProperty("readonly", isTrue(xml.properties.readonly));
911
+ }
812
912
  if (options?.recreateRows) {
813
913
  this.cache.clear();
814
914
  this.controller.clearSelection();
815
915
  this.controller.body.clear();
816
916
  this.fieldsDefinitions = fieldsArray.map(
817
917
  ({ fieldValue, properties, ...current }) => {
818
- return { ...current, properties: parseFakeJSON(properties) };
918
+ const parsedProperties = parseFakeJSON(properties);
919
+ const previousDefinition = this.fieldsDefinitions.find(
920
+ (definition) => definition.id === current.id
921
+ );
922
+ if (preserveColumnVisibilities && previousDefinition) {
923
+ parsedProperties.visibilityHidden = previousDefinition.properties.visibilityHidden;
924
+ parsedProperties.displayNone = previousDefinition.properties.displayNone;
925
+ }
926
+ return { ...current, properties: parsedProperties };
819
927
  }
820
928
  );
821
929
  for (let i = 0; i < rowCount; i++) {
@@ -830,7 +938,7 @@ class Grid extends Field {
830
938
  ...field,
831
939
  index: i,
832
940
  fieldValue: {
833
- ...statesArray[columnIndex][i]
941
+ ...statesArray[columnIndex]?.[i]
834
942
  }
835
943
  };
836
944
  });
@@ -850,7 +958,7 @@ class Grid extends Field {
850
958
  ...field,
851
959
  index: i,
852
960
  fieldValue: {
853
- ...statesArray[columnIndex][i]
961
+ ...statesArray[columnIndex]?.[i]
854
962
  }
855
963
  };
856
964
  });
@@ -889,7 +997,7 @@ class Grid extends Field {
889
997
  } else if (field instanceof ModalInput) {
890
998
  field.setValue(
891
999
  {
892
- showValue: state.qry_show_value || "",
1000
+ showValue: state.qry_show_value ?? state.value ?? "",
893
1001
  storeValue: state.value || ""
894
1002
  },
895
1003
  { force: true }
@@ -947,13 +1055,15 @@ class Grid extends Field {
947
1055
  toggleMaximize() {
948
1056
  this.state.isMaximized = !this.state.isMaximized;
949
1057
  this.getForm().execution.environment.localStorage.setItem(
950
- `${this.definition.id}__isMaximized`,
1058
+ this.getMaximizedStorageKey(),
951
1059
  String(this.state.isMaximized)
952
1060
  );
953
1061
  }
954
1062
  clearMaximizeState() {
955
1063
  this.state.isMaximized = false;
956
- localStorage.removeItem(this.getMaximizedStorageKey());
1064
+ this.getForm().execution.environment.localStorage.removeItem(
1065
+ this.getMaximizedStorageKey()
1066
+ );
957
1067
  }
958
1068
  }
959
1069