@zeedhi/common 1.100.1 → 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
 
@@ -1964,7 +1976,7 @@ class Input extends ComponentRender {
1964
1976
  if (this.viewResetValidation) {
1965
1977
  return this.viewResetValidation();
1966
1978
  }
1967
- throw new Error('viewResetValidation method not assigned');
1979
+ throw new MethodNotAssignedError('viewResetValidation');
1968
1980
  }
1969
1981
  /**
1970
1982
  * Adds parsed validations based on field validations.
@@ -6550,6 +6562,18 @@ class NotEditingError extends Error {
6550
6562
  }
6551
6563
  }
6552
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
+
6553
6577
  /**
6554
6578
  * Base class for Grid component
6555
6579
  */
@@ -6591,12 +6615,16 @@ class GridEditable extends Grid {
6591
6615
  },
6592
6616
  };
6593
6617
  this.viewEnterEdit = null;
6618
+ this.showCancelColumn = false;
6594
6619
  this.newRowIdentifier = '__added_row';
6620
+ this.createGridController();
6595
6621
  this.doubleClickEdit = this.getInitValue('doubleClickEdit', props.doubleClickEdit, this.doubleClickEdit);
6596
6622
  this.canEditRow = this.getInitValue('canEditRow', props.canEditRow, this.canEditRow);
6597
6623
  this.editingNewRows = this.getInitValue('editingNewRows', props.editingNewRows, this.editingNewRows);
6598
6624
  this.singleEdit = this.getInitValue('singleEdit', props.singleEdit, this.singleEdit);
6625
+ this.showCancelColumn = this.getInitValue('showCancelColumn', props.showCancelColumn, this.showCancelColumn);
6599
6626
  this.createAccessors();
6627
+ this.addCancelColumn();
6600
6628
  }
6601
6629
  setViewEnterEdit(viewEnterEdit) {
6602
6630
  this.viewEnterEdit = viewEnterEdit;
@@ -6616,6 +6644,46 @@ class GridEditable extends Grid {
6616
6644
  getColumns(columns) {
6617
6645
  return columns.map((column) => new GridColumnEditable(column));
6618
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
+ }
6619
6687
  /**
6620
6688
  * Changes column order
6621
6689
  * @async
@@ -6846,17 +6914,24 @@ class GridEditable extends Grid {
6846
6914
  if (component)
6847
6915
  column.checkOutValues(component, row, newRow[key]);
6848
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
+ }
6849
6920
  }
6850
6921
  else if (this.editedRows[key]) {
6851
6922
  const rows = Object.assign({}, this.editedRows);
6852
- delete rows[key][columnName];
6853
- delete rows[key][`${columnName}_original`];
6923
+ const newRow = rows[key];
6924
+ delete newRow[columnName];
6925
+ delete newRow[`${columnName}_original`];
6854
6926
  if (component)
6855
- column.checkOutValues(component, row, rows[key]);
6856
- 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) {
6857
6929
  delete rows[key];
6858
6930
  }
6859
6931
  this.editedRows = rows;
6932
+ if (this.isAdded(row)) {
6933
+ this.addedRows = Object.assign(Object.assign({}, this.addedRows), { [key]: newRow });
6934
+ }
6860
6935
  }
6861
6936
  }
6862
6937
  updateOriginalRow(key, row) {
@@ -6874,6 +6949,14 @@ class GridEditable extends Grid {
6874
6949
  return this.editedRows[key]
6875
6950
  && this.editedRows[key][column.name] !== this.editedRows[key][`${column.name}_original`];
6876
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
+ }
6877
6960
  /**
6878
6961
  * Checks if column is valid
6879
6962
  * @param column Column
@@ -6911,6 +6994,27 @@ class GridEditable extends Grid {
6911
6994
  this.invalidComponents = {};
6912
6995
  });
6913
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
+ }
6914
7018
  cancelAddedRows() {
6915
7019
  return __awaiter(this, void 0, void 0, function* () {
6916
7020
  const { data } = this.datasource;
@@ -6973,6 +7077,24 @@ class GridEditable extends Grid {
6973
7077
  });
6974
7078
  return editedRows;
6975
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
+ }
6976
7098
  /**
6977
7099
  * Checks whether the grid is valid or not
6978
7100
  * @param revalidate Defines if the fields should be revalidated
@@ -7163,7 +7285,7 @@ class GridEditable extends Grid {
7163
7285
  */
7164
7286
  enterEdit(rowKey, columnName) {
7165
7287
  if (!this.viewEnterEdit) {
7166
- throw new Error('viewEnterEdit method not assigned');
7288
+ throw new MethodNotAssignedError('viewEnterEdit');
7167
7289
  }
7168
7290
  this.viewEnterEdit(rowKey, columnName);
7169
7291
  }
@@ -11398,6 +11520,18 @@ class Modal extends Component {
11398
11520
  this.isVisible = false;
11399
11521
  ViewService.nextTick(() => this.callEvent('onHide', { component: this }));
11400
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
+ }
11401
11535
  }
11402
11536
 
11403
11537
  /**
@@ -15107,7 +15241,7 @@ class TreeGridEditable extends TreeGrid {
15107
15241
  */
15108
15242
  enterEdit(rowKey, columnName) {
15109
15243
  if (!this.viewEnterEdit) {
15110
- throw new Error('viewEnterEdit method not assigned');
15244
+ throw new MethodNotAssignedError('viewEnterEdit');
15111
15245
  }
15112
15246
  this.viewEnterEdit(rowKey, columnName);
15113
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
 
@@ -1971,7 +1983,7 @@
1971
1983
  if (this.viewResetValidation) {
1972
1984
  return this.viewResetValidation();
1973
1985
  }
1974
- throw new Error('viewResetValidation method not assigned');
1986
+ throw new core.MethodNotAssignedError('viewResetValidation');
1975
1987
  }
1976
1988
  /**
1977
1989
  * Adds parsed validations based on field validations.
@@ -6557,6 +6569,18 @@
6557
6569
  }
6558
6570
  }
6559
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
+
6560
6584
  /**
6561
6585
  * Base class for Grid component
6562
6586
  */
@@ -6598,12 +6622,16 @@
6598
6622
  },
6599
6623
  };
6600
6624
  this.viewEnterEdit = null;
6625
+ this.showCancelColumn = false;
6601
6626
  this.newRowIdentifier = '__added_row';
6627
+ this.createGridController();
6602
6628
  this.doubleClickEdit = this.getInitValue('doubleClickEdit', props.doubleClickEdit, this.doubleClickEdit);
6603
6629
  this.canEditRow = this.getInitValue('canEditRow', props.canEditRow, this.canEditRow);
6604
6630
  this.editingNewRows = this.getInitValue('editingNewRows', props.editingNewRows, this.editingNewRows);
6605
6631
  this.singleEdit = this.getInitValue('singleEdit', props.singleEdit, this.singleEdit);
6632
+ this.showCancelColumn = this.getInitValue('showCancelColumn', props.showCancelColumn, this.showCancelColumn);
6606
6633
  this.createAccessors();
6634
+ this.addCancelColumn();
6607
6635
  }
6608
6636
  setViewEnterEdit(viewEnterEdit) {
6609
6637
  this.viewEnterEdit = viewEnterEdit;
@@ -6623,6 +6651,46 @@
6623
6651
  getColumns(columns) {
6624
6652
  return columns.map((column) => new GridColumnEditable(column));
6625
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
+ }
6626
6694
  /**
6627
6695
  * Changes column order
6628
6696
  * @async
@@ -6853,17 +6921,24 @@
6853
6921
  if (component)
6854
6922
  column.checkOutValues(component, row, newRow[key]);
6855
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
+ }
6856
6927
  }
6857
6928
  else if (this.editedRows[key]) {
6858
6929
  const rows = Object.assign({}, this.editedRows);
6859
- delete rows[key][columnName];
6860
- delete rows[key][`${columnName}_original`];
6930
+ const newRow = rows[key];
6931
+ delete newRow[columnName];
6932
+ delete newRow[`${columnName}_original`];
6861
6933
  if (component)
6862
- column.checkOutValues(component, row, rows[key]);
6863
- 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) {
6864
6936
  delete rows[key];
6865
6937
  }
6866
6938
  this.editedRows = rows;
6939
+ if (this.isAdded(row)) {
6940
+ this.addedRows = Object.assign(Object.assign({}, this.addedRows), { [key]: newRow });
6941
+ }
6867
6942
  }
6868
6943
  }
6869
6944
  updateOriginalRow(key, row) {
@@ -6881,6 +6956,14 @@
6881
6956
  return this.editedRows[key]
6882
6957
  && this.editedRows[key][column.name] !== this.editedRows[key][`${column.name}_original`];
6883
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
+ }
6884
6967
  /**
6885
6968
  * Checks if column is valid
6886
6969
  * @param column Column
@@ -6918,6 +7001,27 @@
6918
7001
  this.invalidComponents = {};
6919
7002
  });
6920
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
+ }
6921
7025
  cancelAddedRows() {
6922
7026
  return __awaiter(this, void 0, void 0, function* () {
6923
7027
  const { data } = this.datasource;
@@ -6980,6 +7084,24 @@
6980
7084
  });
6981
7085
  return editedRows;
6982
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
+ }
6983
7105
  /**
6984
7106
  * Checks whether the grid is valid or not
6985
7107
  * @param revalidate Defines if the fields should be revalidated
@@ -7170,7 +7292,7 @@
7170
7292
  */
7171
7293
  enterEdit(rowKey, columnName) {
7172
7294
  if (!this.viewEnterEdit) {
7173
- throw new Error('viewEnterEdit method not assigned');
7295
+ throw new core.MethodNotAssignedError('viewEnterEdit');
7174
7296
  }
7175
7297
  this.viewEnterEdit(rowKey, columnName);
7176
7298
  }
@@ -11405,6 +11527,18 @@
11405
11527
  this.isVisible = false;
11406
11528
  core.ViewService.nextTick(() => this.callEvent('onHide', { component: this }));
11407
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
+ }
11408
11542
  }
11409
11543
 
11410
11544
  /**
@@ -15114,7 +15248,7 @@
15114
15248
  */
15115
15249
  enterEdit(rowKey, columnName) {
15116
15250
  if (!this.viewEnterEdit) {
15117
- throw new Error('viewEnterEdit method not assigned');
15251
+ throw new core.MethodNotAssignedError('viewEnterEdit');
15118
15252
  }
15119
15253
  this.viewEnterEdit(rowKey, columnName);
15120
15254
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/common",
3
- "version": "1.100.1",
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": "1209ae3b06d2feb2b969f42ec7100f68ac8c55e0"
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
@@ -147,6 +152,11 @@ export declare class GridEditable extends Grid implements IGridEditable {
147
152
  * @param row Row
148
153
  */
149
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;
150
160
  /**
151
161
  * Checks if column is valid
152
162
  * @param column Column
@@ -158,6 +168,10 @@ export declare class GridEditable extends Grid implements IGridEditable {
158
168
  * Cancels all edited rows and enable grid components
159
169
  */
160
170
  cancelEditedRows(): Promise<void>;
171
+ /**
172
+ * cancelAddedRow
173
+ */
174
+ cancelAddedRow(key: string | number): Promise<any>;
161
175
  private cancelAddedRows;
162
176
  private addDataRow;
163
177
  /**
@@ -172,6 +186,10 @@ export declare class GridEditable extends Grid implements IGridEditable {
172
186
  * @throws Will throw when it finds an invalid row
173
187
  */
174
188
  getEditedRows(revalidate?: boolean, silent?: boolean): IDictionary<any>[];
189
+ /**
190
+ * getAddedRows
191
+ */
192
+ getAddedRows(): IDictionary<any>[];
175
193
  /**
176
194
  * Checks whether the grid is valid or not
177
195
  * @param revalidate Defines if the fields should be revalidated
@@ -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
  }
@@ -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
  }