@zeedhi/common 1.100.0 → 1.101.0

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,4 +1,4 @@
1
- import { AccessorManager, Event, KeyMap, Metadata, Accessor, I18n, FormatterParserProvider, Validation, Mask, DatasourceFactory, MethodNotAssignedError, Loader, Config, dayjs, Utils, DateHelper, Router, InstanceNotFoundError, ViewService, MemoryDatasource, URL as URL$1, Http, Cookie, VersionService } from '@zeedhi/core';
1
+ import { AccessorManager, Event, KeyMap, MethodNotAssignedError, Metadata, Accessor, I18n, FormatterParserProvider, Validation, Mask, DatasourceFactory, Loader, Config, dayjs, Utils, DateHelper, Router, InstanceNotFoundError, ViewService, MemoryDatasource, URL as URL$1, Http, Cookie, VersionService } from '@zeedhi/core';
2
2
  import merge from 'lodash.merge';
3
3
  import cloneDeep from 'lodash.clonedeep';
4
4
  import debounce from 'lodash.debounce';
@@ -112,7 +112,7 @@ class Component {
112
112
  if (this.viewFocus) {
113
113
  return this.viewFocus();
114
114
  }
115
- throw new Error('viewFocus method not assigned');
115
+ throw new MethodNotAssignedError('viewFocus');
116
116
  }
117
117
  /**
118
118
  * Retrieves initial value for the attribute and if it is an accessor,
@@ -1403,6 +1403,18 @@ class Carousel extends ComponentRender {
1403
1403
  this.nextButton = this.changeDefaultButtonName(this.nextButton);
1404
1404
  this.createAccessors();
1405
1405
  }
1406
+ setViewUpdate(viewFn) {
1407
+ this.viewUpdate = viewFn;
1408
+ }
1409
+ /**
1410
+ * Updates the Carousel rendered elements
1411
+ */
1412
+ update() {
1413
+ if (!this.viewUpdate) {
1414
+ throw new MethodNotAssignedError('viewUpdate');
1415
+ }
1416
+ this.viewUpdate();
1417
+ }
1406
1418
  /**
1407
1419
  * After the transitionDuration time, set isSliding to false
1408
1420
  */
@@ -1789,7 +1801,7 @@ class Form extends ComponentRender {
1789
1801
  if (this.viewResetValidation) {
1790
1802
  return this.viewResetValidation();
1791
1803
  }
1792
- throw new Error('viewResetValidation method not assigned');
1804
+ throw new MethodNotAssignedError('viewResetValidation');
1793
1805
  }
1794
1806
  }
1795
1807
 
@@ -1889,6 +1901,10 @@ class Input extends ComponentRender {
1889
1901
  * Input validations.
1890
1902
  */
1891
1903
  this.validations = {};
1904
+ /**
1905
+ * Defines if the input should be automatically registered in the closest parent Form
1906
+ */
1907
+ this.autoRegister = true;
1892
1908
  /**
1893
1909
  * Parsed field rules.
1894
1910
  */
@@ -1924,8 +1940,9 @@ class Input extends ComponentRender {
1924
1940
  this.storePath = this.getInitValue('storePath', props.storePath, this.storePath);
1925
1941
  this.value = this.getInitValue('value', props.value, this.value);
1926
1942
  this.validations = this.getInitValue('validations', props.validations, this.validations);
1943
+ this.autoRegister = this.getInitValue('autoRegister', props.autoRegister, this.autoRegister);
1927
1944
  this.parseValidations(props.validations || {});
1928
- if (this.formParent) {
1945
+ if (this.autoRegister && this.formParent) {
1929
1946
  this.formParent.registerInput(this);
1930
1947
  }
1931
1948
  this.createAccessors();
@@ -1959,7 +1976,7 @@ class Input extends ComponentRender {
1959
1976
  if (this.viewResetValidation) {
1960
1977
  return this.viewResetValidation();
1961
1978
  }
1962
- throw new Error('viewResetValidation method not assigned');
1979
+ throw new MethodNotAssignedError('viewResetValidation');
1963
1980
  }
1964
1981
  /**
1965
1982
  * Adds parsed validations based on field validations.
@@ -5816,7 +5833,7 @@ class GridColumn extends Column {
5816
5833
  FormatterParserProvider.registerFormatter('column_ZdSelect', ({ column, value, row, componentProps, }) => {
5817
5834
  if (value === null || value === undefined)
5818
5835
  return '';
5819
- const { dataText, formatterDataText, dataTextSeparator, dataValue, } = componentProps;
5836
+ const { dataText, formatterDataText, dataTextSeparator, dataValue, dataTextDiscrete, } = componentProps;
5820
5837
  let currentRow = row;
5821
5838
  if (dataValue) {
5822
5839
  const dataTextColumns = Array.isArray(dataText) ? dataText : [dataText];
@@ -5837,7 +5854,7 @@ FormatterParserProvider.registerFormatter('column_ZdSelect', ({ column, value, r
5837
5854
  }
5838
5855
  if (!Object.keys(currentRow).length)
5839
5856
  return typeof value === 'object' ? '' : value;
5840
- const textColumn = formatterDataText || dataText;
5857
+ const textColumn = formatterDataText || dataTextDiscrete || dataText;
5841
5858
  if (!textColumn)
5842
5859
  return value;
5843
5860
  if (typeof textColumn === 'string') {
@@ -6433,6 +6450,7 @@ class Grid extends Iterable {
6433
6450
  props.children = newChildren;
6434
6451
  props.name = instanceName;
6435
6452
  props.allowDuplicate = true;
6453
+ props.autoRegister = false;
6436
6454
  let instance = null;
6437
6455
  try {
6438
6456
  instance = this.updateActionInstance(instanceName, props);
@@ -6455,8 +6473,15 @@ class Grid extends Iterable {
6455
6473
  }
6456
6474
  return { props, instance };
6457
6475
  }
6476
+ filterObject(obj, callback) {
6477
+ return Object.fromEntries(Object.entries(obj).filter(([key, value]) => callback(key, value)));
6478
+ }
6479
+ deleteAccessorProps(newComponent) {
6480
+ const filteredProps = this.filterObject(newComponent, (_key, value) => !Accessor.isAccessorDefinition(value));
6481
+ return filteredProps;
6482
+ }
6458
6483
  updateActionInstance(instanceName, newComponent) {
6459
- const updatedComponent = Object.assign({}, newComponent);
6484
+ const updatedComponent = this.deleteAccessorProps(newComponent);
6460
6485
  delete updatedComponent.datasource;
6461
6486
  delete updatedComponent.events;
6462
6487
  const instance = Metadata.updateInstance(instanceName, updatedComponent);
@@ -6537,6 +6562,18 @@ class NotEditingError extends Error {
6537
6562
  }
6538
6563
  }
6539
6564
 
6565
+ class GridEditableController {
6566
+ constructor(grid) {
6567
+ this.grid = grid;
6568
+ }
6569
+ get hasAddedRows() {
6570
+ return this.grid.getAddedRows().length > 0;
6571
+ }
6572
+ isAddedRow({ row }) {
6573
+ return this.grid.isAdded(row);
6574
+ }
6575
+ }
6576
+
6540
6577
  /**
6541
6578
  * Base class for Grid component
6542
6579
  */
@@ -6578,12 +6615,16 @@ class GridEditable extends Grid {
6578
6615
  },
6579
6616
  };
6580
6617
  this.viewEnterEdit = null;
6618
+ this.showCancelColumn = false;
6581
6619
  this.newRowIdentifier = '__added_row';
6620
+ this.createGridController();
6582
6621
  this.doubleClickEdit = this.getInitValue('doubleClickEdit', props.doubleClickEdit, this.doubleClickEdit);
6583
6622
  this.canEditRow = this.getInitValue('canEditRow', props.canEditRow, this.canEditRow);
6584
6623
  this.editingNewRows = this.getInitValue('editingNewRows', props.editingNewRows, this.editingNewRows);
6585
6624
  this.singleEdit = this.getInitValue('singleEdit', props.singleEdit, this.singleEdit);
6625
+ this.showCancelColumn = this.getInitValue('showCancelColumn', props.showCancelColumn, this.showCancelColumn);
6586
6626
  this.createAccessors();
6627
+ this.addCancelColumn();
6587
6628
  }
6588
6629
  setViewEnterEdit(viewEnterEdit) {
6589
6630
  this.viewEnterEdit = viewEnterEdit;
@@ -6603,6 +6644,46 @@ class GridEditable extends Grid {
6603
6644
  getColumns(columns) {
6604
6645
  return columns.map((column) => new GridColumnEditable(column));
6605
6646
  }
6647
+ addCancelColumn() {
6648
+ if (!this.showCancelColumn)
6649
+ return;
6650
+ const deleteColumn = this.instantiateCancelColumn();
6651
+ this.columns.push(deleteColumn);
6652
+ }
6653
+ getCancelColumnProps() {
6654
+ return {
6655
+ name: `cancel_action_${this.name}`,
6656
+ type: 'action',
6657
+ align: 'center',
6658
+ actionFixed: true,
6659
+ isVisible: `{{GridEditableController_${this.name}.hasAddedRows}}`,
6660
+ children: [
6661
+ {
6662
+ name: 'cancel_btn',
6663
+ component: 'ZdButton',
6664
+ icon: true,
6665
+ iconName: 'clear',
6666
+ small: true,
6667
+ conditions: {
6668
+ isVisible: `{{GridEditableController_${this.name}.isAddedRow}}`,
6669
+ },
6670
+ events: {
6671
+ click: ({ row }) => {
6672
+ const { uniqueKey } = this.datasource;
6673
+ this.cancelAddedRow(row[uniqueKey]);
6674
+ },
6675
+ },
6676
+ },
6677
+ ],
6678
+ };
6679
+ }
6680
+ instantiateCancelColumn() {
6681
+ return new GridColumnEditable(this.getCancelColumnProps());
6682
+ }
6683
+ createGridController() {
6684
+ const controller = new GridEditableController(this);
6685
+ Loader.addController(`GridEditableController_${this.name}`, controller);
6686
+ }
6606
6687
  /**
6607
6688
  * Changes column order
6608
6689
  * @async
@@ -6647,6 +6728,22 @@ class GridEditable extends Grid {
6647
6728
  }
6648
6729
  this.cellClickEvent(row, column, event, element);
6649
6730
  }
6731
+ /**
6732
+ * Dispatches cellDoubleClick event
6733
+ * @param row Grid row
6734
+ * @param column Grid column
6735
+ * @param event DOM event
6736
+ * @param element DOM Element
6737
+ */
6738
+ cellDoubleClick(row, column, event, element, canEdit = true) {
6739
+ if (column.editable && canEdit) {
6740
+ this.preventRowDoubleClick = true;
6741
+ this.datasource.currentRow = row;
6742
+ this.inlineEdit(row, column, event, element);
6743
+ return;
6744
+ }
6745
+ this.cellDoubleClickEvent(row, column, event, element);
6746
+ }
6650
6747
  /**
6651
6748
  * Enables editing mode
6652
6749
  * @param row Grid row
@@ -6667,6 +6764,11 @@ class GridEditable extends Grid {
6667
6764
  event, element, row, column, component: this,
6668
6765
  });
6669
6766
  }
6767
+ cellDoubleClickEvent(row, column, event, element) {
6768
+ this.preventRowDoubleClick = this.callEvent('cellDoubleClick', {
6769
+ event, element, row, column, component: this,
6770
+ });
6771
+ }
6670
6772
  /**
6671
6773
  * Dispatches select/unselect event
6672
6774
  * @param row Grid row
@@ -6752,32 +6854,39 @@ class GridEditable extends Grid {
6752
6854
  }
6753
6855
  } });
6754
6856
  this.updateOriginalRow(key, row);
6755
- return Object.assign(Object.assign({}, componentProps), { name: compName, parent: this, align: column.align, showLabel: false, showHelper: false, dense: true, value: colValue, events: newEvents, autofill: false, allowDuplicate: true });
6857
+ return Object.assign(Object.assign({}, componentProps), { name: compName, parent: this, align: column.align, showLabel: false, showHelper: false, dense: true, value: colValue, events: newEvents, autofill: false, allowDuplicate: true, autoRegister: false });
6756
6858
  }
6859
+ /**
6860
+ * Pushes lookup values into the column's datasource
6861
+ * If the row[column.name] has a selected value, pushes it
6862
+ */
6757
6863
  checkLookupData(column, row, componentProps) {
6758
- if (row[column.name] && column.lookupData && componentProps.datasource) {
6759
- componentProps.datasource.data = componentProps.datasource.data || [];
6760
- const colValue = row[column.name];
6761
- if (Array.isArray(colValue)) {
6762
- colValue.forEach((item) => {
6763
- const value = typeof item === 'object' ? item[componentProps.dataValue] : item;
6764
- if (column.lookupData[value]) {
6765
- componentProps.datasource.data.push(column.lookupData[value]);
6766
- }
6767
- });
6768
- return;
6769
- }
6770
- if (colValue && typeof colValue === 'object'
6771
- && Object.prototype.hasOwnProperty.call(colValue, componentProps.dataValue)) {
6772
- const value = colValue[componentProps.dataValue];
6864
+ if (!row[column.name] || !column.lookupData || !componentProps.datasource)
6865
+ return;
6866
+ componentProps.datasource.data = componentProps.datasource.data || [];
6867
+ // prevent pushing lookup values when using accessor in data
6868
+ if (!Array.isArray(componentProps.datasource.data))
6869
+ return;
6870
+ const colValue = row[column.name];
6871
+ if (Array.isArray(colValue)) {
6872
+ colValue.forEach((item) => {
6873
+ const value = typeof item === 'object' ? item[componentProps.dataValue] : item;
6773
6874
  if (column.lookupData[value]) {
6774
6875
  componentProps.datasource.data.push(column.lookupData[value]);
6775
6876
  }
6776
- return;
6777
- }
6778
- if (column.lookupData[colValue]) {
6779
- componentProps.datasource.data.push(column.lookupData[colValue]);
6877
+ });
6878
+ return;
6879
+ }
6880
+ if (colValue && typeof colValue === 'object'
6881
+ && Object.prototype.hasOwnProperty.call(colValue, componentProps.dataValue)) {
6882
+ const value = colValue[componentProps.dataValue];
6883
+ if (column.lookupData[value]) {
6884
+ componentProps.datasource.data.push(column.lookupData[value]);
6780
6885
  }
6886
+ return;
6887
+ }
6888
+ if (column.lookupData[colValue]) {
6889
+ componentProps.datasource.data.push(column.lookupData[colValue]);
6781
6890
  }
6782
6891
  }
6783
6892
  checkCompValidity(component) {
@@ -6805,17 +6914,24 @@ class GridEditable extends Grid {
6805
6914
  if (component)
6806
6915
  column.checkOutValues(component, row, newRow[key]);
6807
6916
  this.editedRows = Object.assign(Object.assign({}, this.editedRows), newRow);
6917
+ if (this.isAdded(row)) {
6918
+ this.addedRows = Object.assign(Object.assign({}, this.addedRows), newRow);
6919
+ }
6808
6920
  }
6809
6921
  else if (this.editedRows[key]) {
6810
6922
  const rows = Object.assign({}, this.editedRows);
6811
- delete rows[key][columnName];
6812
- delete rows[key][`${columnName}_original`];
6923
+ const newRow = rows[key];
6924
+ delete newRow[columnName];
6925
+ delete newRow[`${columnName}_original`];
6813
6926
  if (component)
6814
- column.checkOutValues(component, row, rows[key]);
6815
- if (Object.keys(rows[key]).length === 1 && rows[key].originalRow) {
6927
+ column.checkOutValues(component, row, newRow);
6928
+ if (Object.keys(newRow).length === 1 && newRow.originalRow) {
6816
6929
  delete rows[key];
6817
6930
  }
6818
6931
  this.editedRows = rows;
6932
+ if (this.isAdded(row)) {
6933
+ this.addedRows = Object.assign(Object.assign({}, this.addedRows), { [key]: newRow });
6934
+ }
6819
6935
  }
6820
6936
  }
6821
6937
  updateOriginalRow(key, row) {
@@ -6833,6 +6949,14 @@ class GridEditable extends Grid {
6833
6949
  return this.editedRows[key]
6834
6950
  && this.editedRows[key][column.name] !== this.editedRows[key][`${column.name}_original`];
6835
6951
  }
6952
+ /**
6953
+ * Checks if row is an added row
6954
+ * @param row Row
6955
+ */
6956
+ isAdded(row) {
6957
+ const key = row[this.datasource.uniqueKey];
6958
+ return !!this.addedRows[key];
6959
+ }
6836
6960
  /**
6837
6961
  * Checks if column is valid
6838
6962
  * @param column Column
@@ -6870,6 +6994,27 @@ class GridEditable extends Grid {
6870
6994
  this.invalidComponents = {};
6871
6995
  });
6872
6996
  }
6997
+ /**
6998
+ * cancelAddedRow
6999
+ */
7000
+ cancelAddedRow(key) {
7001
+ return __awaiter(this, void 0, void 0, function* () {
7002
+ const cloneEditedRows = Object.assign({}, this.editedRows);
7003
+ const cloneAddedRows = Object.assign({}, this.addedRows);
7004
+ delete cloneEditedRows[key];
7005
+ delete cloneAddedRows[key];
7006
+ this.editedRows = cloneEditedRows;
7007
+ this.addedRows = cloneAddedRows;
7008
+ let { data } = this.datasource;
7009
+ if (this.datasource instanceof MemoryDatasource) {
7010
+ data = this.datasource.allData;
7011
+ }
7012
+ const { uniqueKey } = this.datasource;
7013
+ const index = data.findIndex((row) => row[uniqueKey] === key);
7014
+ data.splice(index, 1);
7015
+ return this.datasource.updateData(data);
7016
+ });
7017
+ }
6873
7018
  cancelAddedRows() {
6874
7019
  return __awaiter(this, void 0, void 0, function* () {
6875
7020
  const { data } = this.datasource;
@@ -6932,6 +7077,24 @@ class GridEditable extends Grid {
6932
7077
  });
6933
7078
  return editedRows;
6934
7079
  }
7080
+ /**
7081
+ * getAddedRows
7082
+ */
7083
+ getAddedRows() {
7084
+ const addedRows = [];
7085
+ Object.keys(this.addedRows).forEach((key) => {
7086
+ const row = Object.assign(Object.assign({}, this.addedRows[key].originalRow), this.addedRows[key]);
7087
+ delete row.originalRow;
7088
+ delete row[this.newRowIdentifier];
7089
+ Object.keys(row).forEach((attr) => {
7090
+ if (Object.prototype.hasOwnProperty.call(row, `${attr}_original`)) {
7091
+ delete row[`${attr}_original`];
7092
+ }
7093
+ });
7094
+ addedRows.push(row);
7095
+ });
7096
+ return addedRows;
7097
+ }
6935
7098
  /**
6936
7099
  * Checks whether the grid is valid or not
6937
7100
  * @param revalidate Defines if the fields should be revalidated
@@ -7122,7 +7285,7 @@ class GridEditable extends Grid {
7122
7285
  */
7123
7286
  enterEdit(rowKey, columnName) {
7124
7287
  if (!this.viewEnterEdit) {
7125
- throw new Error('viewEnterEdit method not assigned');
7288
+ throw new MethodNotAssignedError('viewEnterEdit');
7126
7289
  }
7127
7290
  this.viewEnterEdit(rowKey, columnName);
7128
7291
  }
@@ -11357,6 +11520,18 @@ class Modal extends Component {
11357
11520
  this.isVisible = false;
11358
11521
  ViewService.nextTick(() => this.callEvent('onHide', { component: this }));
11359
11522
  }
11523
+ /**
11524
+ * transitionStart event
11525
+ */
11526
+ transitionStart(event) {
11527
+ this.callEvent('onTransitionStart', { event, component: this });
11528
+ }
11529
+ /**
11530
+ * transitionEnd event
11531
+ */
11532
+ transitionEnd(event) {
11533
+ this.callEvent('onTransitionEnd', { event, component: this });
11534
+ }
11360
11535
  }
11361
11536
 
11362
11537
  /**
@@ -14775,36 +14950,43 @@ class TreeGridEditable extends TreeGrid {
14775
14950
  }
14776
14951
  } });
14777
14952
  this.updateOriginalRow(key, row);
14778
- return Object.assign(Object.assign({}, componentProps), { name: compName, parent: this, align: column.align, showLabel: false, showHelper: false, dense: true, value: colValue, events: newEvents, autofill: false, allowDuplicate: true });
14953
+ return Object.assign(Object.assign({}, componentProps), { name: compName, parent: this, align: column.align, showLabel: false, showHelper: false, dense: true, value: colValue, events: newEvents, autofill: false, allowDuplicate: true, autoRegister: false });
14779
14954
  }
14780
14955
  updateOriginalRow(key, row) {
14781
14956
  if (this.editedRows[key] !== undefined)
14782
14957
  this.editedRows[key].originalRow = omit(row, 'originalRow');
14783
14958
  }
14959
+ /**
14960
+ * Pushes lookup values into the column's datasource
14961
+ * If the row[column.name] has a selected value, pushes it
14962
+ */
14784
14963
  checkLookupData(column, row, componentProps) {
14785
- if (row[column.name] && column.lookupData && componentProps.datasource) {
14786
- componentProps.datasource.data = componentProps.datasource.data || [];
14787
- const colValue = row[column.name];
14788
- if (Array.isArray(colValue)) {
14789
- colValue.forEach((item) => {
14790
- const value = typeof item === 'object' ? item[componentProps.dataValue] : item;
14791
- if (column.lookupData[value]) {
14792
- componentProps.datasource.data.push(column.lookupData[value]);
14793
- }
14794
- });
14795
- return;
14796
- }
14797
- if (colValue && typeof colValue === 'object'
14798
- && Object.prototype.hasOwnProperty.call(colValue, componentProps.dataValue)) {
14799
- const value = colValue[componentProps.dataValue];
14964
+ if (!row[column.name] || !column.lookupData || !componentProps.datasource)
14965
+ return;
14966
+ componentProps.datasource.data = componentProps.datasource.data || [];
14967
+ // prevent pushing lookup values when using accessor in data
14968
+ if (!Array.isArray(componentProps.datasource.data))
14969
+ return;
14970
+ const colValue = row[column.name];
14971
+ if (Array.isArray(colValue)) {
14972
+ colValue.forEach((item) => {
14973
+ const value = typeof item === 'object' ? item[componentProps.dataValue] : item;
14800
14974
  if (column.lookupData[value]) {
14801
14975
  componentProps.datasource.data.push(column.lookupData[value]);
14802
14976
  }
14803
- return;
14804
- }
14805
- if (column.lookupData[colValue]) {
14806
- componentProps.datasource.data.push(column.lookupData[colValue]);
14977
+ });
14978
+ return;
14979
+ }
14980
+ if (colValue && typeof colValue === 'object'
14981
+ && Object.prototype.hasOwnProperty.call(colValue, componentProps.dataValue)) {
14982
+ const value = colValue[componentProps.dataValue];
14983
+ if (column.lookupData[value]) {
14984
+ componentProps.datasource.data.push(column.lookupData[value]);
14807
14985
  }
14986
+ return;
14987
+ }
14988
+ if (column.lookupData[colValue]) {
14989
+ componentProps.datasource.data.push(column.lookupData[colValue]);
14808
14990
  }
14809
14991
  }
14810
14992
  checkCompValidity(component) {
@@ -15059,7 +15241,7 @@ class TreeGridEditable extends TreeGrid {
15059
15241
  */
15060
15242
  enterEdit(rowKey, columnName) {
15061
15243
  if (!this.viewEnterEdit) {
15062
- throw new Error('viewEnterEdit method not assigned');
15244
+ throw new MethodNotAssignedError('viewEnterEdit');
15063
15245
  }
15064
15246
  this.viewEnterEdit(rowKey, columnName);
15065
15247
  }
@@ -119,7 +119,7 @@
119
119
  if (this.viewFocus) {
120
120
  return this.viewFocus();
121
121
  }
122
- throw new Error('viewFocus method not assigned');
122
+ throw new core.MethodNotAssignedError('viewFocus');
123
123
  }
124
124
  /**
125
125
  * Retrieves initial value for the attribute and if it is an accessor,
@@ -1410,6 +1410,18 @@
1410
1410
  this.nextButton = this.changeDefaultButtonName(this.nextButton);
1411
1411
  this.createAccessors();
1412
1412
  }
1413
+ setViewUpdate(viewFn) {
1414
+ this.viewUpdate = viewFn;
1415
+ }
1416
+ /**
1417
+ * Updates the Carousel rendered elements
1418
+ */
1419
+ update() {
1420
+ if (!this.viewUpdate) {
1421
+ throw new core.MethodNotAssignedError('viewUpdate');
1422
+ }
1423
+ this.viewUpdate();
1424
+ }
1413
1425
  /**
1414
1426
  * After the transitionDuration time, set isSliding to false
1415
1427
  */
@@ -1796,7 +1808,7 @@
1796
1808
  if (this.viewResetValidation) {
1797
1809
  return this.viewResetValidation();
1798
1810
  }
1799
- throw new Error('viewResetValidation method not assigned');
1811
+ throw new core.MethodNotAssignedError('viewResetValidation');
1800
1812
  }
1801
1813
  }
1802
1814
 
@@ -1896,6 +1908,10 @@
1896
1908
  * Input validations.
1897
1909
  */
1898
1910
  this.validations = {};
1911
+ /**
1912
+ * Defines if the input should be automatically registered in the closest parent Form
1913
+ */
1914
+ this.autoRegister = true;
1899
1915
  /**
1900
1916
  * Parsed field rules.
1901
1917
  */
@@ -1931,8 +1947,9 @@
1931
1947
  this.storePath = this.getInitValue('storePath', props.storePath, this.storePath);
1932
1948
  this.value = this.getInitValue('value', props.value, this.value);
1933
1949
  this.validations = this.getInitValue('validations', props.validations, this.validations);
1950
+ this.autoRegister = this.getInitValue('autoRegister', props.autoRegister, this.autoRegister);
1934
1951
  this.parseValidations(props.validations || {});
1935
- if (this.formParent) {
1952
+ if (this.autoRegister && this.formParent) {
1936
1953
  this.formParent.registerInput(this);
1937
1954
  }
1938
1955
  this.createAccessors();
@@ -1966,7 +1983,7 @@
1966
1983
  if (this.viewResetValidation) {
1967
1984
  return this.viewResetValidation();
1968
1985
  }
1969
- throw new Error('viewResetValidation method not assigned');
1986
+ throw new core.MethodNotAssignedError('viewResetValidation');
1970
1987
  }
1971
1988
  /**
1972
1989
  * Adds parsed validations based on field validations.
@@ -5823,7 +5840,7 @@
5823
5840
  core.FormatterParserProvider.registerFormatter('column_ZdSelect', ({ column, value, row, componentProps, }) => {
5824
5841
  if (value === null || value === undefined)
5825
5842
  return '';
5826
- const { dataText, formatterDataText, dataTextSeparator, dataValue, } = componentProps;
5843
+ const { dataText, formatterDataText, dataTextSeparator, dataValue, dataTextDiscrete, } = componentProps;
5827
5844
  let currentRow = row;
5828
5845
  if (dataValue) {
5829
5846
  const dataTextColumns = Array.isArray(dataText) ? dataText : [dataText];
@@ -5844,7 +5861,7 @@
5844
5861
  }
5845
5862
  if (!Object.keys(currentRow).length)
5846
5863
  return typeof value === 'object' ? '' : value;
5847
- const textColumn = formatterDataText || dataText;
5864
+ const textColumn = formatterDataText || dataTextDiscrete || dataText;
5848
5865
  if (!textColumn)
5849
5866
  return value;
5850
5867
  if (typeof textColumn === 'string') {
@@ -6440,6 +6457,7 @@
6440
6457
  props.children = newChildren;
6441
6458
  props.name = instanceName;
6442
6459
  props.allowDuplicate = true;
6460
+ props.autoRegister = false;
6443
6461
  let instance = null;
6444
6462
  try {
6445
6463
  instance = this.updateActionInstance(instanceName, props);
@@ -6462,8 +6480,15 @@
6462
6480
  }
6463
6481
  return { props, instance };
6464
6482
  }
6483
+ filterObject(obj, callback) {
6484
+ return Object.fromEntries(Object.entries(obj).filter(([key, value]) => callback(key, value)));
6485
+ }
6486
+ deleteAccessorProps(newComponent) {
6487
+ const filteredProps = this.filterObject(newComponent, (_key, value) => !core.Accessor.isAccessorDefinition(value));
6488
+ return filteredProps;
6489
+ }
6465
6490
  updateActionInstance(instanceName, newComponent) {
6466
- const updatedComponent = Object.assign({}, newComponent);
6491
+ const updatedComponent = this.deleteAccessorProps(newComponent);
6467
6492
  delete updatedComponent.datasource;
6468
6493
  delete updatedComponent.events;
6469
6494
  const instance = core.Metadata.updateInstance(instanceName, updatedComponent);
@@ -6544,6 +6569,18 @@
6544
6569
  }
6545
6570
  }
6546
6571
 
6572
+ class GridEditableController {
6573
+ constructor(grid) {
6574
+ this.grid = grid;
6575
+ }
6576
+ get hasAddedRows() {
6577
+ return this.grid.getAddedRows().length > 0;
6578
+ }
6579
+ isAddedRow({ row }) {
6580
+ return this.grid.isAdded(row);
6581
+ }
6582
+ }
6583
+
6547
6584
  /**
6548
6585
  * Base class for Grid component
6549
6586
  */
@@ -6585,12 +6622,16 @@
6585
6622
  },
6586
6623
  };
6587
6624
  this.viewEnterEdit = null;
6625
+ this.showCancelColumn = false;
6588
6626
  this.newRowIdentifier = '__added_row';
6627
+ this.createGridController();
6589
6628
  this.doubleClickEdit = this.getInitValue('doubleClickEdit', props.doubleClickEdit, this.doubleClickEdit);
6590
6629
  this.canEditRow = this.getInitValue('canEditRow', props.canEditRow, this.canEditRow);
6591
6630
  this.editingNewRows = this.getInitValue('editingNewRows', props.editingNewRows, this.editingNewRows);
6592
6631
  this.singleEdit = this.getInitValue('singleEdit', props.singleEdit, this.singleEdit);
6632
+ this.showCancelColumn = this.getInitValue('showCancelColumn', props.showCancelColumn, this.showCancelColumn);
6593
6633
  this.createAccessors();
6634
+ this.addCancelColumn();
6594
6635
  }
6595
6636
  setViewEnterEdit(viewEnterEdit) {
6596
6637
  this.viewEnterEdit = viewEnterEdit;
@@ -6610,6 +6651,46 @@
6610
6651
  getColumns(columns) {
6611
6652
  return columns.map((column) => new GridColumnEditable(column));
6612
6653
  }
6654
+ addCancelColumn() {
6655
+ if (!this.showCancelColumn)
6656
+ return;
6657
+ const deleteColumn = this.instantiateCancelColumn();
6658
+ this.columns.push(deleteColumn);
6659
+ }
6660
+ getCancelColumnProps() {
6661
+ return {
6662
+ name: `cancel_action_${this.name}`,
6663
+ type: 'action',
6664
+ align: 'center',
6665
+ actionFixed: true,
6666
+ isVisible: `{{GridEditableController_${this.name}.hasAddedRows}}`,
6667
+ children: [
6668
+ {
6669
+ name: 'cancel_btn',
6670
+ component: 'ZdButton',
6671
+ icon: true,
6672
+ iconName: 'clear',
6673
+ small: true,
6674
+ conditions: {
6675
+ isVisible: `{{GridEditableController_${this.name}.isAddedRow}}`,
6676
+ },
6677
+ events: {
6678
+ click: ({ row }) => {
6679
+ const { uniqueKey } = this.datasource;
6680
+ this.cancelAddedRow(row[uniqueKey]);
6681
+ },
6682
+ },
6683
+ },
6684
+ ],
6685
+ };
6686
+ }
6687
+ instantiateCancelColumn() {
6688
+ return new GridColumnEditable(this.getCancelColumnProps());
6689
+ }
6690
+ createGridController() {
6691
+ const controller = new GridEditableController(this);
6692
+ core.Loader.addController(`GridEditableController_${this.name}`, controller);
6693
+ }
6613
6694
  /**
6614
6695
  * Changes column order
6615
6696
  * @async
@@ -6654,6 +6735,22 @@
6654
6735
  }
6655
6736
  this.cellClickEvent(row, column, event, element);
6656
6737
  }
6738
+ /**
6739
+ * Dispatches cellDoubleClick event
6740
+ * @param row Grid row
6741
+ * @param column Grid column
6742
+ * @param event DOM event
6743
+ * @param element DOM Element
6744
+ */
6745
+ cellDoubleClick(row, column, event, element, canEdit = true) {
6746
+ if (column.editable && canEdit) {
6747
+ this.preventRowDoubleClick = true;
6748
+ this.datasource.currentRow = row;
6749
+ this.inlineEdit(row, column, event, element);
6750
+ return;
6751
+ }
6752
+ this.cellDoubleClickEvent(row, column, event, element);
6753
+ }
6657
6754
  /**
6658
6755
  * Enables editing mode
6659
6756
  * @param row Grid row
@@ -6674,6 +6771,11 @@
6674
6771
  event, element, row, column, component: this,
6675
6772
  });
6676
6773
  }
6774
+ cellDoubleClickEvent(row, column, event, element) {
6775
+ this.preventRowDoubleClick = this.callEvent('cellDoubleClick', {
6776
+ event, element, row, column, component: this,
6777
+ });
6778
+ }
6677
6779
  /**
6678
6780
  * Dispatches select/unselect event
6679
6781
  * @param row Grid row
@@ -6759,32 +6861,39 @@
6759
6861
  }
6760
6862
  } });
6761
6863
  this.updateOriginalRow(key, row);
6762
- return Object.assign(Object.assign({}, componentProps), { name: compName, parent: this, align: column.align, showLabel: false, showHelper: false, dense: true, value: colValue, events: newEvents, autofill: false, allowDuplicate: true });
6864
+ return Object.assign(Object.assign({}, componentProps), { name: compName, parent: this, align: column.align, showLabel: false, showHelper: false, dense: true, value: colValue, events: newEvents, autofill: false, allowDuplicate: true, autoRegister: false });
6763
6865
  }
6866
+ /**
6867
+ * Pushes lookup values into the column's datasource
6868
+ * If the row[column.name] has a selected value, pushes it
6869
+ */
6764
6870
  checkLookupData(column, row, componentProps) {
6765
- if (row[column.name] && column.lookupData && componentProps.datasource) {
6766
- componentProps.datasource.data = componentProps.datasource.data || [];
6767
- const colValue = row[column.name];
6768
- if (Array.isArray(colValue)) {
6769
- colValue.forEach((item) => {
6770
- const value = typeof item === 'object' ? item[componentProps.dataValue] : item;
6771
- if (column.lookupData[value]) {
6772
- componentProps.datasource.data.push(column.lookupData[value]);
6773
- }
6774
- });
6775
- return;
6776
- }
6777
- if (colValue && typeof colValue === 'object'
6778
- && Object.prototype.hasOwnProperty.call(colValue, componentProps.dataValue)) {
6779
- const value = colValue[componentProps.dataValue];
6871
+ if (!row[column.name] || !column.lookupData || !componentProps.datasource)
6872
+ return;
6873
+ componentProps.datasource.data = componentProps.datasource.data || [];
6874
+ // prevent pushing lookup values when using accessor in data
6875
+ if (!Array.isArray(componentProps.datasource.data))
6876
+ return;
6877
+ const colValue = row[column.name];
6878
+ if (Array.isArray(colValue)) {
6879
+ colValue.forEach((item) => {
6880
+ const value = typeof item === 'object' ? item[componentProps.dataValue] : item;
6780
6881
  if (column.lookupData[value]) {
6781
6882
  componentProps.datasource.data.push(column.lookupData[value]);
6782
6883
  }
6783
- return;
6784
- }
6785
- if (column.lookupData[colValue]) {
6786
- componentProps.datasource.data.push(column.lookupData[colValue]);
6884
+ });
6885
+ return;
6886
+ }
6887
+ if (colValue && typeof colValue === 'object'
6888
+ && Object.prototype.hasOwnProperty.call(colValue, componentProps.dataValue)) {
6889
+ const value = colValue[componentProps.dataValue];
6890
+ if (column.lookupData[value]) {
6891
+ componentProps.datasource.data.push(column.lookupData[value]);
6787
6892
  }
6893
+ return;
6894
+ }
6895
+ if (column.lookupData[colValue]) {
6896
+ componentProps.datasource.data.push(column.lookupData[colValue]);
6788
6897
  }
6789
6898
  }
6790
6899
  checkCompValidity(component) {
@@ -6812,17 +6921,24 @@
6812
6921
  if (component)
6813
6922
  column.checkOutValues(component, row, newRow[key]);
6814
6923
  this.editedRows = Object.assign(Object.assign({}, this.editedRows), newRow);
6924
+ if (this.isAdded(row)) {
6925
+ this.addedRows = Object.assign(Object.assign({}, this.addedRows), newRow);
6926
+ }
6815
6927
  }
6816
6928
  else if (this.editedRows[key]) {
6817
6929
  const rows = Object.assign({}, this.editedRows);
6818
- delete rows[key][columnName];
6819
- delete rows[key][`${columnName}_original`];
6930
+ const newRow = rows[key];
6931
+ delete newRow[columnName];
6932
+ delete newRow[`${columnName}_original`];
6820
6933
  if (component)
6821
- column.checkOutValues(component, row, rows[key]);
6822
- if (Object.keys(rows[key]).length === 1 && rows[key].originalRow) {
6934
+ column.checkOutValues(component, row, newRow);
6935
+ if (Object.keys(newRow).length === 1 && newRow.originalRow) {
6823
6936
  delete rows[key];
6824
6937
  }
6825
6938
  this.editedRows = rows;
6939
+ if (this.isAdded(row)) {
6940
+ this.addedRows = Object.assign(Object.assign({}, this.addedRows), { [key]: newRow });
6941
+ }
6826
6942
  }
6827
6943
  }
6828
6944
  updateOriginalRow(key, row) {
@@ -6840,6 +6956,14 @@
6840
6956
  return this.editedRows[key]
6841
6957
  && this.editedRows[key][column.name] !== this.editedRows[key][`${column.name}_original`];
6842
6958
  }
6959
+ /**
6960
+ * Checks if row is an added row
6961
+ * @param row Row
6962
+ */
6963
+ isAdded(row) {
6964
+ const key = row[this.datasource.uniqueKey];
6965
+ return !!this.addedRows[key];
6966
+ }
6843
6967
  /**
6844
6968
  * Checks if column is valid
6845
6969
  * @param column Column
@@ -6877,6 +7001,27 @@
6877
7001
  this.invalidComponents = {};
6878
7002
  });
6879
7003
  }
7004
+ /**
7005
+ * cancelAddedRow
7006
+ */
7007
+ cancelAddedRow(key) {
7008
+ return __awaiter(this, void 0, void 0, function* () {
7009
+ const cloneEditedRows = Object.assign({}, this.editedRows);
7010
+ const cloneAddedRows = Object.assign({}, this.addedRows);
7011
+ delete cloneEditedRows[key];
7012
+ delete cloneAddedRows[key];
7013
+ this.editedRows = cloneEditedRows;
7014
+ this.addedRows = cloneAddedRows;
7015
+ let { data } = this.datasource;
7016
+ if (this.datasource instanceof core.MemoryDatasource) {
7017
+ data = this.datasource.allData;
7018
+ }
7019
+ const { uniqueKey } = this.datasource;
7020
+ const index = data.findIndex((row) => row[uniqueKey] === key);
7021
+ data.splice(index, 1);
7022
+ return this.datasource.updateData(data);
7023
+ });
7024
+ }
6880
7025
  cancelAddedRows() {
6881
7026
  return __awaiter(this, void 0, void 0, function* () {
6882
7027
  const { data } = this.datasource;
@@ -6939,6 +7084,24 @@
6939
7084
  });
6940
7085
  return editedRows;
6941
7086
  }
7087
+ /**
7088
+ * getAddedRows
7089
+ */
7090
+ getAddedRows() {
7091
+ const addedRows = [];
7092
+ Object.keys(this.addedRows).forEach((key) => {
7093
+ const row = Object.assign(Object.assign({}, this.addedRows[key].originalRow), this.addedRows[key]);
7094
+ delete row.originalRow;
7095
+ delete row[this.newRowIdentifier];
7096
+ Object.keys(row).forEach((attr) => {
7097
+ if (Object.prototype.hasOwnProperty.call(row, `${attr}_original`)) {
7098
+ delete row[`${attr}_original`];
7099
+ }
7100
+ });
7101
+ addedRows.push(row);
7102
+ });
7103
+ return addedRows;
7104
+ }
6942
7105
  /**
6943
7106
  * Checks whether the grid is valid or not
6944
7107
  * @param revalidate Defines if the fields should be revalidated
@@ -7129,7 +7292,7 @@
7129
7292
  */
7130
7293
  enterEdit(rowKey, columnName) {
7131
7294
  if (!this.viewEnterEdit) {
7132
- throw new Error('viewEnterEdit method not assigned');
7295
+ throw new core.MethodNotAssignedError('viewEnterEdit');
7133
7296
  }
7134
7297
  this.viewEnterEdit(rowKey, columnName);
7135
7298
  }
@@ -11364,6 +11527,18 @@
11364
11527
  this.isVisible = false;
11365
11528
  core.ViewService.nextTick(() => this.callEvent('onHide', { component: this }));
11366
11529
  }
11530
+ /**
11531
+ * transitionStart event
11532
+ */
11533
+ transitionStart(event) {
11534
+ this.callEvent('onTransitionStart', { event, component: this });
11535
+ }
11536
+ /**
11537
+ * transitionEnd event
11538
+ */
11539
+ transitionEnd(event) {
11540
+ this.callEvent('onTransitionEnd', { event, component: this });
11541
+ }
11367
11542
  }
11368
11543
 
11369
11544
  /**
@@ -14782,36 +14957,43 @@
14782
14957
  }
14783
14958
  } });
14784
14959
  this.updateOriginalRow(key, row);
14785
- return Object.assign(Object.assign({}, componentProps), { name: compName, parent: this, align: column.align, showLabel: false, showHelper: false, dense: true, value: colValue, events: newEvents, autofill: false, allowDuplicate: true });
14960
+ return Object.assign(Object.assign({}, componentProps), { name: compName, parent: this, align: column.align, showLabel: false, showHelper: false, dense: true, value: colValue, events: newEvents, autofill: false, allowDuplicate: true, autoRegister: false });
14786
14961
  }
14787
14962
  updateOriginalRow(key, row) {
14788
14963
  if (this.editedRows[key] !== undefined)
14789
14964
  this.editedRows[key].originalRow = omit__default["default"](row, 'originalRow');
14790
14965
  }
14966
+ /**
14967
+ * Pushes lookup values into the column's datasource
14968
+ * If the row[column.name] has a selected value, pushes it
14969
+ */
14791
14970
  checkLookupData(column, row, componentProps) {
14792
- if (row[column.name] && column.lookupData && componentProps.datasource) {
14793
- componentProps.datasource.data = componentProps.datasource.data || [];
14794
- const colValue = row[column.name];
14795
- if (Array.isArray(colValue)) {
14796
- colValue.forEach((item) => {
14797
- const value = typeof item === 'object' ? item[componentProps.dataValue] : item;
14798
- if (column.lookupData[value]) {
14799
- componentProps.datasource.data.push(column.lookupData[value]);
14800
- }
14801
- });
14802
- return;
14803
- }
14804
- if (colValue && typeof colValue === 'object'
14805
- && Object.prototype.hasOwnProperty.call(colValue, componentProps.dataValue)) {
14806
- const value = colValue[componentProps.dataValue];
14971
+ if (!row[column.name] || !column.lookupData || !componentProps.datasource)
14972
+ return;
14973
+ componentProps.datasource.data = componentProps.datasource.data || [];
14974
+ // prevent pushing lookup values when using accessor in data
14975
+ if (!Array.isArray(componentProps.datasource.data))
14976
+ return;
14977
+ const colValue = row[column.name];
14978
+ if (Array.isArray(colValue)) {
14979
+ colValue.forEach((item) => {
14980
+ const value = typeof item === 'object' ? item[componentProps.dataValue] : item;
14807
14981
  if (column.lookupData[value]) {
14808
14982
  componentProps.datasource.data.push(column.lookupData[value]);
14809
14983
  }
14810
- return;
14811
- }
14812
- if (column.lookupData[colValue]) {
14813
- componentProps.datasource.data.push(column.lookupData[colValue]);
14984
+ });
14985
+ return;
14986
+ }
14987
+ if (colValue && typeof colValue === 'object'
14988
+ && Object.prototype.hasOwnProperty.call(colValue, componentProps.dataValue)) {
14989
+ const value = colValue[componentProps.dataValue];
14990
+ if (column.lookupData[value]) {
14991
+ componentProps.datasource.data.push(column.lookupData[value]);
14814
14992
  }
14993
+ return;
14994
+ }
14995
+ if (column.lookupData[colValue]) {
14996
+ componentProps.datasource.data.push(column.lookupData[colValue]);
14815
14997
  }
14816
14998
  }
14817
14999
  checkCompValidity(component) {
@@ -15066,7 +15248,7 @@
15066
15248
  */
15067
15249
  enterEdit(rowKey, columnName) {
15068
15250
  if (!this.viewEnterEdit) {
15069
- throw new Error('viewEnterEdit method not assigned');
15251
+ throw new core.MethodNotAssignedError('viewEnterEdit');
15070
15252
  }
15071
15253
  this.viewEnterEdit(rowKey, columnName);
15072
15254
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/common",
3
- "version": "1.100.0",
3
+ "version": "1.101.0",
4
4
  "description": "Zeedhi Common",
5
5
  "author": "Zeedhi <zeedhi@teknisa.com>",
6
6
  "license": "ISC",
@@ -43,5 +43,5 @@
43
43
  "lodash.times": "4.3.*",
44
44
  "mockdate": "3.0.*"
45
45
  },
46
- "gitHead": "f387e52dc26f20fbd8dfa61b3881a096f32c68ad"
46
+ "gitHead": "04d65b589020380fe76f9dbbbed3e4106b3f20fe"
47
47
  }
@@ -131,11 +131,17 @@ export declare class Carousel extends ComponentRender implements ICarousel {
131
131
  * Carousel's left side button
132
132
  */
133
133
  prevButton: IButton;
134
+ viewUpdate?: () => void;
134
135
  /**
135
136
  * Creates a new Carousel
136
137
  * @param props Carousel properties
137
138
  */
138
139
  constructor(props: ICarousel);
140
+ setViewUpdate(viewFn: () => void): void;
141
+ /**
142
+ * Updates the Carousel rendered elements
143
+ */
144
+ update(): void;
139
145
  /**
140
146
  * After the transitionDuration time, set isSliding to false
141
147
  */
@@ -0,0 +1,8 @@
1
+ import { IDictionary } from '@zeedhi/core';
2
+ import { GridEditable } from './grid-editable';
3
+ export declare class GridEditableController {
4
+ private grid;
5
+ constructor(grid: GridEditable);
6
+ get hasAddedRows(): boolean;
7
+ isAddedRow({ row }: IDictionary): boolean;
8
+ }
@@ -47,6 +47,7 @@ export declare class GridEditable extends Grid implements IGridEditable {
47
47
  protected cancelEditedRowsKeyMapping: IKeyMap;
48
48
  protected viewEnterEdit: ((rowKey: string, columnName: string) => void) | null;
49
49
  setViewEnterEdit(viewEnterEdit: (rowKey: string, columnName: string) => void): void;
50
+ showCancelColumn: boolean;
50
51
  constructor(props: IGridEditable);
51
52
  onMounted(element: any): void;
52
53
  onBeforeDestroy(): void;
@@ -55,6 +56,10 @@ export declare class GridEditable extends Grid implements IGridEditable {
55
56
  * @param columns Grid columns parameter
56
57
  */
57
58
  protected getColumns(columns: IGridColumnEditable[]): GridColumnEditable[];
59
+ protected addCancelColumn(): void;
60
+ protected getCancelColumnProps(): IGridColumnEditable;
61
+ protected instantiateCancelColumn(): GridColumnEditable;
62
+ protected createGridController(): void;
58
63
  /**
59
64
  * Changes column order
60
65
  * @async
@@ -76,6 +81,14 @@ export declare class GridEditable extends Grid implements IGridEditable {
76
81
  * @param element DOM Element
77
82
  */
78
83
  cellClick(row: IDictionary<any>, column: GridColumnEditable, event: Event, element: any, canEdit?: boolean): void;
84
+ /**
85
+ * Dispatches cellDoubleClick event
86
+ * @param row Grid row
87
+ * @param column Grid column
88
+ * @param event DOM event
89
+ * @param element DOM Element
90
+ */
91
+ cellDoubleClick(row: IDictionary<any>, column: GridColumnEditable, event: Event, element: any, canEdit?: boolean): void;
79
92
  /**
80
93
  * Enables editing mode
81
94
  * @param row Grid row
@@ -85,6 +98,7 @@ export declare class GridEditable extends Grid implements IGridEditable {
85
98
  */
86
99
  inlineEdit(row: IDictionary, column: GridColumnEditable, event: Event, element: any): void;
87
100
  cellClickEvent(row: IDictionary<any>, column: GridColumnEditable, event: Event, element: any): void;
101
+ cellDoubleClickEvent(row: IDictionary<any>, column: GridColumnEditable, event: Event, element: any): void;
88
102
  /**
89
103
  * Dispatches select/unselect event
90
104
  * @param row Grid row
@@ -119,7 +133,12 @@ export declare class GridEditable extends Grid implements IGridEditable {
119
133
  events: any;
120
134
  autofill: boolean;
121
135
  allowDuplicate: boolean;
136
+ autoRegister: boolean;
122
137
  };
138
+ /**
139
+ * Pushes lookup values into the column's datasource
140
+ * If the row[column.name] has a selected value, pushes it
141
+ */
123
142
  private checkLookupData;
124
143
  private checkCompValidity;
125
144
  /**
@@ -133,6 +152,11 @@ export declare class GridEditable extends Grid implements IGridEditable {
133
152
  * @param row Row
134
153
  */
135
154
  isEdited(column: IGridColumnEditable, row: IDictionary): boolean;
155
+ /**
156
+ * Checks if row is an added row
157
+ * @param row Row
158
+ */
159
+ isAdded(row: IDictionary): boolean;
136
160
  /**
137
161
  * Checks if column is valid
138
162
  * @param column Column
@@ -144,6 +168,10 @@ export declare class GridEditable extends Grid implements IGridEditable {
144
168
  * Cancels all edited rows and enable grid components
145
169
  */
146
170
  cancelEditedRows(): Promise<void>;
171
+ /**
172
+ * cancelAddedRow
173
+ */
174
+ cancelAddedRow(key: string | number): Promise<any>;
147
175
  private cancelAddedRows;
148
176
  private addDataRow;
149
177
  /**
@@ -158,6 +186,10 @@ export declare class GridEditable extends Grid implements IGridEditable {
158
186
  * @throws Will throw when it finds an invalid row
159
187
  */
160
188
  getEditedRows(revalidate?: boolean, silent?: boolean): IDictionary<any>[];
189
+ /**
190
+ * getAddedRows
191
+ */
192
+ getAddedRows(): IDictionary<any>[];
161
193
  /**
162
194
  * Checks whether the grid is valid or not
163
195
  * @param revalidate Defines if the fields should be revalidated
@@ -225,6 +225,8 @@ export declare class Grid extends Iterable implements IGrid {
225
225
  props: IComponent;
226
226
  instance: Component | null;
227
227
  };
228
+ private filterObject;
229
+ private deleteAccessorProps;
228
230
  protected updateActionInstance(instanceName: string, newComponent: IComponent): Component;
229
231
  getActionComponent(actionComponent: IComponent, column: GridColumn, row: IDictionary, parentPath?: string): IComponent;
230
232
  protected changeDefaultSlotNames(slot: IComponentRender[]): any;
@@ -70,4 +70,5 @@ export interface IGridEditable extends IGrid {
70
70
  row: IDictionary<any>;
71
71
  component: GridEditable;
72
72
  }) => boolean;
73
+ showCancelColumn?: boolean;
73
74
  }
@@ -99,6 +99,10 @@ export declare class Input extends ComponentRender implements IInput {
99
99
  * Input validations.
100
100
  */
101
101
  validations: IDictionary<IDictionary<string | number>>;
102
+ /**
103
+ * Defines if the input should be automatically registered in the closest parent Form
104
+ */
105
+ autoRegister: boolean;
102
106
  /**
103
107
  * Optional validation method assigned by view layer.
104
108
  */
@@ -35,4 +35,5 @@ export interface IInput extends IComponentRender {
35
35
  storePath?: string;
36
36
  validations?: IDictionary<IDictionary<string | number>>;
37
37
  value?: any;
38
+ autoRegister?: boolean;
38
39
  }
@@ -6,6 +6,8 @@ export declare type IModalEvent = IEventParam<Modal>;
6
6
  export interface IModalEvents<T = IEventParam<any>> extends IComponentEvents<T> {
7
7
  onShow?: EventDef<T>;
8
8
  onHide?: EventDef<T>;
9
+ onTransitionStart?: EventDef<T>;
10
+ onTransitionEnd?: EventDef<T>;
9
11
  }
10
12
  export interface IModalGrid {
11
13
  cols?: number | string;
@@ -50,4 +50,12 @@ export declare class Modal extends Component implements IModal {
50
50
  * Closes modal
51
51
  */
52
52
  hide(): void;
53
+ /**
54
+ * transitionStart event
55
+ */
56
+ transitionStart(event: Event): void;
57
+ /**
58
+ * transitionEnd event
59
+ */
60
+ transitionEnd(event: Event): void;
53
61
  }
@@ -110,8 +110,13 @@ export declare class TreeGridEditable extends TreeGrid implements ITreeGridEdita
110
110
  events: any;
111
111
  autofill: boolean;
112
112
  allowDuplicate: boolean;
113
+ autoRegister: boolean;
113
114
  };
114
115
  private updateOriginalRow;
116
+ /**
117
+ * Pushes lookup values into the column's datasource
118
+ * If the row[column.name] has a selected value, pushes it
119
+ */
115
120
  private checkLookupData;
116
121
  private checkCompValidity;
117
122
  /**