@apia/execution 4.0.103 → 4.0.104

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.
package/dist/index.d.ts CHANGED
@@ -1112,10 +1112,10 @@ declare class ApiaFieldWithAttribute<T = string | boolean> extends ApiaField {
1112
1112
  #private;
1113
1113
  constructor(execution: Execution, field: FieldWithAttribute);
1114
1114
  get attribute(): ApiaAttribute;
1115
- clearValue(): void;
1115
+ clearValue(): Promise<boolean>;
1116
1116
  getValue(): any;
1117
- setValue(v: T): void;
1118
- protected _setValue(v: T, options: SetValueOptions): void;
1117
+ setValue(v: T): Promise<boolean>;
1118
+ protected _setValue(v: T, options: SetValueOptions): Promise<boolean>;
1119
1119
  getLabel(): string | null | void;
1120
1120
  getProperty<K extends keyof TApiaFieldWithAttributeProperties>(name: TApiaFieldWithAttributeProperties[K]): unknown;
1121
1121
  }
@@ -1141,18 +1141,18 @@ declare class InputField extends ApiaFieldWithAttribute {
1141
1141
  #private;
1142
1142
  constructor(execution: Execution, field: Input);
1143
1143
  getObjectValue(): number | string | boolean | null;
1144
- setValue(v: string): void;
1144
+ setValue(v: string): Promise<boolean>;
1145
1145
  }
1146
1146
 
1147
1147
  declare class TreeField extends ApiaFieldWithAttribute<string | number | (string | number)[]> {
1148
1148
  #private;
1149
1149
  constructor(execution: Execution, field: Tree);
1150
- setValue(v: string | number | (string | number)[]): void;
1150
+ setValue(v: string | number | (string | number)[]): Promise<boolean>;
1151
1151
  }
1152
1152
 
1153
1153
  declare class CheckField extends ApiaFieldWithAttribute {
1154
- clearValue(): void;
1155
- setValue(value: string | boolean | number): void;
1154
+ clearValue(): Promise<boolean>;
1155
+ setValue(value: string | boolean | number): Promise<boolean>;
1156
1156
  }
1157
1157
 
1158
1158
  type TOptionsMap$1 = Map<string, PossibleValue>;
@@ -1174,10 +1174,10 @@ declare class MultipleField extends ApiaFieldWithAttribute<string[]> {
1174
1174
  #private;
1175
1175
  constructor(execution: Execution, field: Multiple);
1176
1176
  addOption(optionValue: string | number, showValue: string, allowRepeatedValue: boolean): void;
1177
- setValue(value: string[]): void;
1177
+ setValue(value: string[]): Promise<boolean>;
1178
1178
  clearOptions(): void;
1179
1179
  getSelectedOption(asObject: boolean): TOptionsMap | PossibleValue[] | null;
1180
- getOptions(): SelectPossibleValue[];
1180
+ getOptions(asObject: boolean): TOptionsMap | PossibleValue[] | null;
1181
1181
  setOptions(optionsArray: PossibleValue[]): void;
1182
1182
  removeOption(optionValue: string | number): void;
1183
1183
  }
@@ -1226,16 +1226,15 @@ declare class TextField extends ApiaField implements ITextField {
1226
1226
  declare class GridField extends ApiaField {
1227
1227
  #private;
1228
1228
  constructor(execution: Execution, field: Grid);
1229
- addRow(): GridField;
1230
- addRowAndWait(): Promise<IApiaField[]>;
1229
+ addRow(): Promise<IApiaField[]>;
1231
1230
  clearGrid(): void;
1232
1231
  clearPage(): void;
1233
- clearRow(index: number): GridField;
1232
+ clearRow(index: number): Promise<void>;
1234
1233
  closeForm(): GridField;
1235
- deleteAllRows(): GridField;
1236
- deleteGrid(): void;
1234
+ deleteAllRows(): Promise<void>;
1235
+ deleteGrid(): Promise<void>;
1237
1236
  deletePage(): void;
1238
- deleteRow(index: number): GridField;
1237
+ deleteRow(index: number): Promise<void>;
1239
1238
  editRow(index: number): void;
1240
1239
  getSelectedIndexes(useAbsoluteIndex?: boolean): number[];
1241
1240
  getAllColumns(): (IApiaField<Readonly<{
@@ -1847,8 +1846,8 @@ declare class FileUploaderField extends ApiaFieldWithAttribute {
1847
1846
  #private;
1848
1847
  constructor(execution: Execution, field: File$1);
1849
1848
  onChange(cb: (newValue: unknown) => unknown): void;
1850
- setValue(): null;
1851
- downloadDocument(): FileUploaderField;
1849
+ setValue(): Promise<boolean>;
1850
+ downloadDocument(): Promise<void>;
1852
1851
  getValue(): string;
1853
1852
  }
1854
1853
 
@@ -1859,8 +1858,8 @@ declare class ModalInputField extends ApiaFieldWithAttribute {
1859
1858
  #private;
1860
1859
  constructor(execution: Execution, field: ModalInput);
1861
1860
  getObjectValue(): any | null;
1862
- setValue(v: any): void;
1863
- setValueFromInputWrite(value: string): ModalInputField;
1861
+ setValue(v: any): Promise<boolean>;
1862
+ setValueFromInputWrite(value: string): Promise<void>;
1864
1863
  }
1865
1864
 
1866
1865
  type TCreateNewField = (execution: Execution, field: Field | FieldWithAttribute | CustomComponent) => IApiaField | null;
@@ -3346,6 +3345,7 @@ declare class Grid extends Field<GridProps, GridDefinition, GridState> {
3346
3345
  protected readonly _footerController: GridFooterHandler;
3347
3346
  protected readonly tableController: TableController;
3348
3347
  get controller(): TableController;
3348
+ protected get isSmallGridMode(): boolean;
3349
3349
  get currentPage(): number;
3350
3350
  get editionModalHandler(): GridEditionModal | null;
3351
3351
  /**
package/dist/index.js CHANGED
@@ -307,6 +307,8 @@ const jsonDecode = (string) => {
307
307
  return eval(`(${str})`);
308
308
  };
309
309
  const parseBool = (val) => {
310
+ if (typeof val === "boolean")
311
+ return val;
310
312
  if (typeof val === "string") {
311
313
  if (/^(?:true|T|t|1|1,00)$/i.test(val))
312
314
  return true;
@@ -3000,12 +3002,20 @@ class Grid extends Field {
3000
3002
  this.state.isLoading = false;
3001
3003
  this.state.isMaximized = false;
3002
3004
  this.controller.on("columnClick", (col) => {
3003
- this.sortColumn(col.getState("properties").col.fldId);
3005
+ const column = col.getState("properties")?.col;
3006
+ if (column) {
3007
+ this.sortColumn(column.fldId);
3008
+ }
3004
3009
  });
3005
3010
  }
3006
3011
  get controller() {
3007
3012
  return this.tableController;
3008
3013
  }
3014
+ get isSmallGridMode() {
3015
+ const execution = this.getForm()?.execution;
3016
+ const dataGridConfig = (execution?.environment ? getWindow(execution) : globalThis.window)?.config?.execution?.components?.dataGrid;
3017
+ return dataGridConfig?.gridView === "small";
3018
+ }
3009
3019
  get currentPage() {
3010
3020
  return this.properties.currentPage;
3011
3021
  }
@@ -3090,10 +3100,12 @@ class Grid extends Field {
3090
3100
  ].join("__");
3091
3101
  }
3092
3102
  resolveHeaderWidth(c) {
3103
+ const defaultWidth = this.isSmallGridMode ? "180px" : "150px";
3104
+ const wideWidth = this.isSmallGridMode ? "220px" : "200px";
3093
3105
  if (c.fldType === "9" || c.fldType === "1" && c.dataType === "D" || c.fldType === "1" && c.hasQuery) {
3094
- return "200px";
3106
+ return wideWidth;
3095
3107
  }
3096
- return "150px";
3108
+ return defaultWidth;
3097
3109
  }
3098
3110
  getGridActionFromEventName(eventName) {
3099
3111
  switch (eventName) {
@@ -3405,7 +3417,7 @@ class Grid extends Field {
3405
3417
  await super.init(form);
3406
3418
  this.state.isMaximized = localStorage.getItem(this.getMaximizedStorageKey()) === "true";
3407
3419
  const headerRow = new Row("header");
3408
- 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)
3420
+ 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)
3409
3421
  headerRow.addCell(
3410
3422
  new AdditionalCell(
3411
3423
  this,
@@ -3609,7 +3621,7 @@ class Grid extends Field {
3609
3621
  });
3610
3622
  }
3611
3623
  const newRow = new Row(String(this.rowId++));
3612
- 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)
3624
+ 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)
3613
3625
  newRow.addCell(
3614
3626
  new AdditionalCell(
3615
3627
  this,
@@ -3687,7 +3699,7 @@ class Grid extends Field {
3687
3699
  }
3688
3700
  calculateMustShowAdditionalColumn() {
3689
3701
  const { hideDelButton, shownDeleteButtons, shownEditionButtons, gridForm } = this.properties;
3690
- const mustShowAdditionalColumn = !hideDelButton && [...shownDeleteButtons.values()].some((c) => c !== false) || !!gridForm && [...shownEditionButtons.values()].some((c) => c !== false);
3702
+ const mustShowAdditionalColumn = this.isSmallGridMode || !hideDelButton && [...shownDeleteButtons.values()].some((c) => c !== false) || !!gridForm && [...shownEditionButtons.values()].some((c) => c !== false);
3691
3703
  this.controller.toggleColumnVisibility(
3692
3704
  "additional",
3693
3705
  mustShowAdditionalColumn
@@ -4952,16 +4964,16 @@ class ApiaFieldWithAttribute extends ApiaField {
4952
4964
  return new ApiaAttribute(__privateGet$g(this, _field$c).attribute);
4953
4965
  }
4954
4966
  clearValue() {
4955
- __privateGet$g(this, _field$c).setValue("");
4967
+ return __privateGet$g(this, _field$c).setValue("");
4956
4968
  }
4957
4969
  getValue() {
4958
4970
  return __privateGet$g(this, _field$c).getValue();
4959
4971
  }
4960
4972
  setValue(v) {
4961
- __privateGet$g(this, _field$c).setValue(v);
4973
+ return __privateGet$g(this, _field$c).setValue(v);
4962
4974
  }
4963
4975
  _setValue(v, options) {
4964
- __privateGet$g(this, _field$c).setValue(v, options);
4976
+ return __privateGet$g(this, _field$c).setValue(v, options);
4965
4977
  }
4966
4978
  getLabel() {
4967
4979
  return __privateGet$g(this, _field$c).attribute.title;
@@ -5104,9 +5116,9 @@ class InputField extends ApiaFieldWithAttribute {
5104
5116
  }
5105
5117
  setValue(v) {
5106
5118
  if (__privateGet$e(this, _field$a).attribute.valueType === "D") {
5107
- __privateGet$e(this, _field$a).setValue(v, { format: "d/m/Y" });
5119
+ return __privateGet$e(this, _field$a).setValue(v, { format: "d/m/Y" });
5108
5120
  } else {
5109
- __privateGet$e(this, _field$a).setValue(v);
5121
+ return __privateGet$e(this, _field$a).setValue(v);
5110
5122
  }
5111
5123
  }
5112
5124
  }
@@ -5138,14 +5150,14 @@ class TreeField extends ApiaFieldWithAttribute {
5138
5150
  __privateSet$d(this, _field$9, field);
5139
5151
  }
5140
5152
  setValue(v) {
5141
- __privateGet$d(this, _field$9).setValue(arrayOrArray(v));
5153
+ return __privateGet$d(this, _field$9).setValue(arrayOrArray(v));
5142
5154
  }
5143
5155
  }
5144
5156
  _field$9 = new WeakMap();
5145
5157
 
5146
5158
  class CheckField extends ApiaFieldWithAttribute {
5147
5159
  clearValue() {
5148
- this.setValue(false);
5160
+ return this.setValue(false);
5149
5161
  }
5150
5162
  setValue(value) {
5151
5163
  let val;
@@ -5157,7 +5169,7 @@ class CheckField extends ApiaFieldWithAttribute {
5157
5169
  "Apia JSApi Error: The function setValue for a Checkbox field only accepts boolean or string type for value parameter."
5158
5170
  );
5159
5171
  }
5160
- super.setValue(val);
5172
+ return super.setValue(val);
5161
5173
  }
5162
5174
  }
5163
5175
 
@@ -5254,7 +5266,7 @@ var __accessCheck$b = (obj, member, msg) => {
5254
5266
  };
5255
5267
  var __privateGet$b = (obj, member, getter) => {
5256
5268
  __accessCheck$b(obj, member, "read from private field");
5257
- return member.get(obj);
5269
+ return getter ? getter.call(obj) : member.get(obj);
5258
5270
  };
5259
5271
  var __privateAdd$b = (obj, member, value) => {
5260
5272
  if (member.has(obj))
@@ -5292,8 +5304,9 @@ class MultipleField extends ApiaFieldWithAttribute {
5292
5304
  }
5293
5305
  setValue(value) {
5294
5306
  if (__privateGet$b(this, _field$7).definition.id) {
5295
- __privateGet$b(this, _field$7).setValue(value);
5307
+ return __privateGet$b(this, _field$7).setValue(value);
5296
5308
  }
5309
+ return Promise.resolve(false);
5297
5310
  }
5298
5311
  clearOptions() {
5299
5312
  if (__privateGet$b(this, _field$7).definition.id) {
@@ -5318,8 +5331,17 @@ class MultipleField extends ApiaFieldWithAttribute {
5318
5331
  }
5319
5332
  return null;
5320
5333
  }
5321
- getOptions() {
5322
- return arrayOrArray(__privateGet$b(this, _field$7).properties.possibleValue);
5334
+ getOptions(asObject) {
5335
+ if (__privateGet$b(this, _field$7).definition.id) {
5336
+ const options = arrayOrArray(__privateGet$b(this, _field$7).properties.possibleValue);
5337
+ const obj = /* @__PURE__ */ new Map();
5338
+ if (asObject) {
5339
+ options.forEach((c) => obj.set(String(c.value), c));
5340
+ return obj;
5341
+ }
5342
+ return options;
5343
+ }
5344
+ return null;
5323
5345
  }
5324
5346
  setOptions(optionsArray) {
5325
5347
  if (__privateGet$b(this, _field$7).definition.id) {
@@ -5619,34 +5641,27 @@ var __privateSet$6 = (obj, member, value, setter) => {
5619
5641
  member.set(obj, value);
5620
5642
  return value;
5621
5643
  };
5622
- var __privateMethod = (obj, member, method) => {
5623
- __accessCheck$6(obj, member, "access private method");
5624
- return method;
5625
- };
5626
- var _execution$2, _field$2, _mutex, _pendingAction, _enqueueAction, enqueueAction_fn;
5644
+ var _execution$2, _field$2, _mutex;
5627
5645
  class GridField extends ApiaField {
5628
5646
  constructor(execution, field) {
5629
5647
  super(execution, field);
5630
- __privateAdd$6(this, _enqueueAction);
5631
5648
  __privateAdd$6(this, _execution$2, void 0);
5632
5649
  __privateAdd$6(this, _field$2, void 0);
5633
5650
  __privateAdd$6(this, _mutex, new Mutex());
5634
- __privateAdd$6(this, _pendingAction, Promise.resolve());
5635
5651
  __privateSet$6(this, _execution$2, execution);
5636
5652
  __privateSet$6(this, _field$2, field);
5637
5653
  }
5638
- addRow() {
5639
- __privateMethod(this, _enqueueAction, enqueueAction_fn).call(this, async () => {
5640
- await this.addRowAndWait();
5641
- });
5642
- return this;
5643
- }
5644
- async addRowAndWait() {
5645
- const result = await __privateGet$6(this, _field$2).addRow();
5646
- if (result) {
5647
- return this.getRow(__privateGet$6(this, _field$2).finalIndex);
5654
+ async addRow() {
5655
+ try {
5656
+ await __privateGet$6(this, _mutex).acquire();
5657
+ const result = await __privateGet$6(this, _field$2).addRow();
5658
+ if (result) {
5659
+ return this.getRow(__privateGet$6(this, _field$2).finalIndex);
5660
+ }
5661
+ return [];
5662
+ } finally {
5663
+ __privateGet$6(this, _mutex).release();
5648
5664
  }
5649
- return [];
5650
5665
  }
5651
5666
  clearGrid() {
5652
5667
  throw new Error("Method deprecated");
@@ -5654,8 +5669,9 @@ class GridField extends ApiaField {
5654
5669
  clearPage() {
5655
5670
  throw new Error("Method deprecated");
5656
5671
  }
5657
- clearRow(index) {
5658
- __privateMethod(this, _enqueueAction, enqueueAction_fn).call(this, async () => {
5672
+ async clearRow(index) {
5673
+ try {
5674
+ await __privateGet$6(this, _mutex).acquire();
5659
5675
  const row = __privateGet$6(this, _field$2).getRowByFieldIndex(index);
5660
5676
  if (!row) {
5661
5677
  throw new Error(`Row ${index} not found`);
@@ -5664,30 +5680,35 @@ class GridField extends ApiaField {
5664
5680
  if (c instanceof FieldWithAttribute)
5665
5681
  c.state.value = "";
5666
5682
  });
5667
- });
5668
- return this;
5683
+ } finally {
5684
+ __privateGet$6(this, _mutex).release();
5685
+ }
5669
5686
  }
5670
5687
  closeForm() {
5671
5688
  __privateGet$6(this, _field$2).closeEditionModal();
5672
5689
  return this;
5673
5690
  }
5674
- deleteAllRows() {
5675
- __privateMethod(this, _enqueueAction, enqueueAction_fn).call(this, async () => {
5691
+ async deleteAllRows() {
5692
+ try {
5693
+ await __privateGet$6(this, _mutex).acquire();
5676
5694
  await __privateGet$6(this, _field$2).deleteAllRows();
5677
- });
5678
- return this;
5695
+ } finally {
5696
+ __privateGet$6(this, _mutex).release();
5697
+ }
5679
5698
  }
5680
- deleteGrid() {
5699
+ async deleteGrid() {
5681
5700
  throw new Error("Method deprecated");
5682
5701
  }
5683
5702
  deletePage() {
5684
5703
  throw new Error("Method deprecated");
5685
5704
  }
5686
- deleteRow(index) {
5687
- __privateMethod(this, _enqueueAction, enqueueAction_fn).call(this, async () => {
5688
- await __privateGet$6(this, _field$2).deleteRows(index);
5689
- });
5690
- return this;
5705
+ async deleteRow(index) {
5706
+ try {
5707
+ await __privateGet$6(this, _mutex).acquire();
5708
+ __privateGet$6(this, _field$2).deleteRows(index);
5709
+ } finally {
5710
+ __privateGet$6(this, _mutex).release();
5711
+ }
5691
5712
  }
5692
5713
  editRow(index) {
5693
5714
  getWindow(__privateGet$6(this, _execution$2)).dispatchEvent(
@@ -5774,20 +5795,6 @@ class GridField extends ApiaField {
5774
5795
  _execution$2 = new WeakMap();
5775
5796
  _field$2 = new WeakMap();
5776
5797
  _mutex = new WeakMap();
5777
- _pendingAction = new WeakMap();
5778
- _enqueueAction = new WeakSet();
5779
- enqueueAction_fn = function(action) {
5780
- __privateSet$6(this, _pendingAction, __privateGet$6(this, _pendingAction).then(async () => {
5781
- await __privateGet$6(this, _mutex).acquire();
5782
- try {
5783
- return await action();
5784
- } finally {
5785
- __privateGet$6(this, _mutex).release();
5786
- }
5787
- }).catch((error) => {
5788
- console.error(error);
5789
- }));
5790
- };
5791
5798
 
5792
5799
  class CaptchaField extends ApiaField {
5793
5800
  }
@@ -5834,13 +5841,10 @@ class FileUploaderField extends ApiaFieldWithAttribute {
5834
5841
  `Apia JSApi Error: The Field ${__privateGet$5(this, _field$1).definition.fieldType} does not support this function`
5835
5842
  );
5836
5843
  }
5837
- return null;
5844
+ return Promise.resolve(false);
5838
5845
  }
5839
5846
  downloadDocument() {
5840
- void __privateGet$5(this, _field$1).downloadDocument().catch((error) => {
5841
- console.error(error);
5842
- });
5843
- return this;
5847
+ return __privateGet$5(this, _field$1).downloadDocument();
5844
5848
  }
5845
5849
  getValue() {
5846
5850
  return __privateGet$5(this, _field$1).uploader?.filesArray?.[0]?.docName ?? "";
@@ -5880,13 +5884,10 @@ class ModalInputField extends ApiaFieldWithAttribute {
5880
5884
  return __privateGet$4(this, _field).getValue();
5881
5885
  }
5882
5886
  setValue(v) {
5883
- __privateGet$4(this, _field).setValue(v);
5887
+ return __privateGet$4(this, _field).setValue(v);
5884
5888
  }
5885
5889
  setValueFromInputWrite(value) {
5886
- void __privateGet$4(this, _field).setValueFromInputWrite(value).catch((error) => {
5887
- console.error(error);
5888
- });
5889
- return this;
5890
+ return __privateGet$4(this, _field).setValueFromInputWrite(value);
5890
5891
  }
5891
5892
  }
5892
5893
  _field = new WeakMap();