aio-table 6.2.0 → 6.3.2

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 (3) hide show
  1. package/index.css +31 -58
  2. package/index.js +392 -308
  3. package/package.json +1 -1
package/index.css CHANGED
@@ -45,11 +45,28 @@
45
45
  box-sizing:border-box;
46
46
  position: -webkit-sticky;
47
47
  background: #fff;
48
- z-index:100;
48
+ height:36px;
49
49
  border-bottom:1px solid #ddd;
50
- border-left:1px solid #ddd;
50
+ z-index:100;
51
51
  box-shadow: 1px 4px 6px -2px rgba(0,0,0,0.1);
52
52
  }
53
+ .aio-table-title:after{
54
+ content:'';
55
+ width:1px;
56
+ height:100%;
57
+ top:0;
58
+ background:#ddd;
59
+ position:absolute;
60
+ }
61
+ .aio-table-title.ltr:after{
62
+ left:calc(100% - 1px);
63
+ }
64
+ .aio-table-title.rtl:after{
65
+ right:calc(100% - 1px);
66
+ }
67
+ .aio-table-title.last-child:after{
68
+ display:none;
69
+ }
53
70
  .aio-table.rtl .aio-table-title{
54
71
  box-shadow: -1px 4px 6px -2px rgba(0,0,0,0.1);
55
72
  }
@@ -67,17 +84,6 @@
67
84
  opacity:1;
68
85
  cursor:col-resize;
69
86
  }
70
- .aio-table.rtl .aio-table-title{
71
- border-left:none;
72
- border-right:1px solid #ddd;
73
- }
74
- .aio-table-title:first-child{
75
- border-left:none;
76
- border-right:none;
77
- }
78
- .aio-table-indent{
79
- flex-shrink:0;
80
- }
81
87
  .aio-table-cell{
82
88
  display:flex;
83
89
  align-items: center;
@@ -88,6 +94,10 @@
88
94
  white-space:nowrap;
89
95
  text-overflow:ellipsis;
90
96
  background:#fff;
97
+ height:36px;
98
+ }
99
+ .aio-table-cell.last-child{
100
+ border:none;
91
101
  }
92
102
  .aio-table-cell-selectable{
93
103
  user-select: text;
@@ -96,8 +106,10 @@
96
106
  .aio-table-cell-hidden{
97
107
  display:none;
98
108
  }
99
- .aio-table-content{
109
+ .aio-table-cell-content{
100
110
  width:100%;
111
+ height:100%;
112
+ align-items: center;
101
113
  overflow:hidden;
102
114
  display: flex;
103
115
  }
@@ -202,7 +214,7 @@ select.aio-table-paging-button{
202
214
  flex-shrink:0;
203
215
  cursor:pointer;
204
216
  }
205
- .aio-table-gap{
217
+ .aio-table-cell-gap{
206
218
  width:6px;
207
219
  flex-shrink:0;
208
220
  }
@@ -329,7 +341,7 @@ select.aio-table-paging-button{
329
341
  .aio-table-group{
330
342
  display:flex;
331
343
  padding:0 12px;
332
- height:24px;
344
+ height:36px;
333
345
  align-items: center;
334
346
  white-space:nowrap;
335
347
  background:#fff;
@@ -358,9 +370,10 @@ select.aio-table-paging-button{
358
370
  }
359
371
  }
360
372
  .aio-table-toolbar-button{
361
- background:dodgerblue;
362
- color:#fff;
373
+ background:#fff;
374
+ color:inherit;
363
375
  height:30px;
376
+ border-radius:36px;
364
377
  width:30px;
365
378
  margin:0 3px;
366
379
  }
@@ -456,46 +469,6 @@ select.aio-table-paging-button{
456
469
  user-select: text;
457
470
  -webkit-user-select: text;
458
471
  }
459
-
460
- .r-layout-item{
461
- overflow:auto;
462
- display:flex;
463
- position: relative;
464
- flex-grow:0;
465
- flex-shrink: 0;
466
- }
467
- .r-layout-parent{
468
- position:relative;
469
- display:flex;
470
- flex-grow:0;
471
- flex-shrink: 0;
472
- overflow:auto;
473
- }
474
- .r-layout-html{
475
- position: absolute;
476
- width:100%;
477
- height:100%;
478
- left:0;
479
- top:0;
480
- overflow:hidden;
481
- }
482
- .r-layout-gap{
483
- flex-shrink:0;
484
- }
485
- .r-layout-gap:last-child{
486
- display:none;
487
- }
488
-
489
- @media screen and (max-width: 768px) {
490
- .r-layout-hide-in-small {
491
- display: none !important;
492
- }
493
- }
494
- @media screen and (min-width: 768px) {
495
- .r-layout-hide-in-large {
496
- display: none !important;
497
- }
498
- }
499
472
  /* custom scrollbar */
500
473
  .aio-table-unit::-webkit-scrollbar {
501
474
  width: 10px !important;
package/index.js CHANGED
@@ -57,9 +57,20 @@ class AIOTable extends _react.Component {
57
57
  filterDictionary: {},
58
58
  groupsOpen: {},
59
59
  searchText: '',
60
+ addedSorts: [],
60
61
  freezeSize,
61
62
  groupDictionary,
62
- sorts,
63
+ startIndex: 0,
64
+ //بخاطر شرایط خاص سورتس باید کاملا از پروپس ورودی ایموتیبل شود//
65
+ sorts: sorts.map(o => {
66
+ let res = {};
67
+
68
+ for (let prop in o) {
69
+ res[prop] = o[prop];
70
+ }
71
+
72
+ return res;
73
+ }),
63
74
  //make imutable to prevent change of props.paging because that will compaire with next input props.paging
64
75
  paging: paging ? { ...paging
65
76
  } : false,
@@ -67,8 +78,34 @@ class AIOTable extends _react.Component {
67
78
  columns: copiedColumns,
68
79
  prevColumns: JSON.stringify(copiedColumns),
69
80
  focused: false,
70
- toggleAllState: true
81
+ toggleAllState: true,
82
+ getCellValue: (row, getValue, field) => {
83
+ try {
84
+ if (typeof getValue === 'function') {
85
+ return getValue(row);
86
+ }
87
+
88
+ if (field) {
89
+ let result;
90
+ eval('result = row.' + field);
91
+ return result;
92
+ }
93
+
94
+ return;
95
+ } catch {
96
+ return;
97
+ }
98
+ },
99
+ setCellValue: (row, field, value) => {
100
+ //row is used in eval
101
+ let {
102
+ model
103
+ } = this.props;
104
+ eval('row.' + field + ' = ' + value);
105
+ return model;
106
+ }
71
107
  };
108
+ console.log('in table', this.state.sorts);
72
109
  }
73
110
 
74
111
  copyJson(j) {
@@ -93,15 +130,6 @@ class AIOTable extends _react.Component {
93
130
  return a(j);
94
131
  }
95
132
 
96
- getGap() {
97
- return /*#__PURE__*/_react.default.createElement("div", {
98
- className: "aio-table-gap",
99
- style: {
100
- width: this.props.cellGap
101
- }
102
- });
103
- }
104
-
105
133
  resizeDown(e) {
106
134
  var {
107
135
  touch
@@ -335,7 +363,7 @@ class AIOTable extends _react.Component {
335
363
  setTimeout(() => this.setState({
336
364
  paging: { ...paging
337
365
  },
338
- prevPaging: JSON.stringify(paging)
366
+ prevPaging: p
339
367
  }), 0);
340
368
  }
341
369
  }
@@ -368,7 +396,7 @@ class AIOTable extends _react.Component {
368
396
  this.rg = rowGap;
369
397
  this.cg = columnGap;
370
398
  this.updateColumns();
371
- var Toolbar = this.toolbar.show ? /*#__PURE__*/_react.default.createElement(RTableToolbar, this.toolbar) : null;
399
+ var Toolbar = this.toolbar.show ? /*#__PURE__*/_react.default.createElement(AIOTableToolbar, this.toolbar) : null;
372
400
  var table = columns ? this.getTable(Toolbar) : '';
373
401
  var context = { ...this.props,
374
402
  ...this.state,
@@ -398,7 +426,6 @@ class AIOTable extends _react.Component {
398
426
  },
399
427
  onChangeFilter: onChangeFilter ? this.onChangeFilter.bind(this) : undefined,
400
428
  SetState: obj => this.setState(obj),
401
- getGap: this.getGap.bind(this),
402
429
  onScroll: index => this.fn.onScroll(this.dom, index),
403
430
  groups: this.groups,
404
431
  fn: this.fn,
@@ -426,7 +453,7 @@ class AIOTable extends _react.Component {
426
453
  paging.onChange(obj);
427
454
  }
428
455
  }
429
- })));
456
+ }), this.fn.getLoading(true)));
430
457
  }
431
458
 
432
459
  }
@@ -434,8 +461,6 @@ class AIOTable extends _react.Component {
434
461
  exports.default = AIOTable;
435
462
  AIOTable.defaultProps = {
436
463
  columns: [],
437
- headerHeight: 36,
438
- rowHeight: 36,
439
464
  toolbarHeight: 36,
440
465
  rowGap: 6,
441
466
  padding: 12,
@@ -446,7 +471,7 @@ AIOTable.defaultProps = {
446
471
  groups: []
447
472
  };
448
473
 
449
- class RTableToolbar extends _react.Component {
474
+ class AIOTableToolbar extends _react.Component {
450
475
  constructor(...args) {
451
476
  super(...args);
452
477
 
@@ -643,7 +668,7 @@ class RTableToolbar extends _react.Component {
643
668
 
644
669
  }
645
670
 
646
- _defineProperty(RTableToolbar, "contextType", AioTableContext);
671
+ _defineProperty(AIOTableToolbar, "contextType", AioTableContext);
647
672
 
648
673
  class AIOTablePaging extends _react.Component {
649
674
  getPageNumber(type) {
@@ -803,6 +828,7 @@ class AIOTableUnit extends _react.Component {
803
828
  } = this.props;
804
829
  return columns.map((column, i) => {
805
830
  return /*#__PURE__*/_react.default.createElement(AIOTableTitle, {
831
+ isLast: i === columns.length - 1,
806
832
  key: 'title' + i,
807
833
  column: column,
808
834
  gridTemplateColumns: this.gridTemplateColumns,
@@ -849,7 +875,8 @@ class AIOTableUnit extends _react.Component {
849
875
 
850
876
  keyDown(e) {
851
877
  var {
852
- SetState
878
+ SetState,
879
+ focused
853
880
  } = this.context;
854
881
 
855
882
  if (e.keyCode === 27) {
@@ -885,12 +912,11 @@ class AIOTableUnit extends _react.Component {
885
912
 
886
913
  if (inputCells.length) {
887
914
  let cell = inputCells.eq(0);
888
- let cellId = cell.attr('cellid');
889
915
  SetState({
890
- focused: cellId
916
+ focused: cell.attr('data-cell-id')
891
917
  });
892
918
  setTimeout(() => {
893
- (0, _jquery.default)('.aio-table-cell-input[cellid=' + cellId + '] .aio-table-input').focus().select();
919
+ cell.find('.aio-table-input').focus().select();
894
920
  }, 10);
895
921
  }
896
922
 
@@ -898,16 +924,17 @@ class AIOTableUnit extends _react.Component {
898
924
  }
899
925
 
900
926
  let [rowIndex, colIndex] = this.getCellIndex(focusedInput.parents('.aio-table-cell'));
927
+ console.log(rowIndex, colIndex);
901
928
 
902
929
  if (e.keyCode === 40 || e.keyCode === 38) {
903
930
  let sign = e.keyCode === 40 ? 1 : -1;
904
931
  e.preventDefault();
905
932
  rowIndex += sign;
906
- let next = inputs.filter(`[rowindex=${rowIndex}][colindex=${colIndex}]`);
933
+ let next = inputs.filter(`[data-row-index=${rowIndex}][data-col-index=${colIndex}]`);
907
934
 
908
935
  while (rowIndex < this.renderIndex && rowIndex > 0 && next.length === 0) {
909
936
  rowIndex += sign;
910
- next = inputs.filter(`[rowindex=${rowIndex}][colindex=${colIndex}]`);
937
+ next = inputs.filter(`[data-row-index=${rowIndex}][data-col-index=${colIndex}]`);
911
938
  }
912
939
 
913
940
  if (next.length) {
@@ -918,11 +945,11 @@ class AIOTableUnit extends _react.Component {
918
945
  e.preventDefault();
919
946
  let sign = (e.keyCode === 37 ? -1 : 1) * (rtl ? -1 : 1);
920
947
  colIndex += sign;
921
- let next = inputs.filter(`[rowindex=${rowIndex}][colindex=${colIndex}]`);
948
+ let next = inputs.filter(`[data-row-index=${rowIndex}][data-col-index=${colIndex}]`);
922
949
 
923
950
  while (colIndex > 0 && colIndex < columns.length && next.length === 0) {
924
951
  colIndex += sign;
925
- next = inputs.filter(`[rowindex=${rowIndex}][colindex=${colIndex}]`);
952
+ next = inputs.filter(`[data-row-index=${rowIndex}][data-col-index=${colIndex}]`);
926
953
  }
927
954
 
928
955
  if (next.length) {
@@ -933,7 +960,7 @@ class AIOTableUnit extends _react.Component {
933
960
  }
934
961
 
935
962
  getCellIndex(cell) {
936
- return [parseInt(cell.attr('rowindex')), parseInt(cell.attr('colindex'))];
963
+ return [parseInt(cell.attr('data-row-index')), parseInt(cell.attr('data-col-index'))];
937
964
  }
938
965
 
939
966
  card(props) {
@@ -963,7 +990,17 @@ class AIOTableUnit extends _react.Component {
963
990
  let rows;
964
991
 
965
992
  if (search) {
966
- rows = this.props.rows.filter(o => search(o.row, searchText));
993
+ rows = this.props.rows.filter(o => {
994
+ if (searchText === '') {
995
+ return true;
996
+ }
997
+
998
+ try {
999
+ return search(o.row, searchText);
1000
+ } catch {
1001
+ return false;
1002
+ }
1003
+ });
967
1004
  } else {
968
1005
  rows = this.props.rows;
969
1006
  }
@@ -988,10 +1025,20 @@ class AIOTableUnit extends _react.Component {
988
1025
  }), rows && rows.length === 0 && fn.getNoData(columns), !rows && fn.getLoading());
989
1026
  }
990
1027
 
1028
+ getPropValue(row, column, prop) {
1029
+ return typeof prop === 'function' ? prop(row, column) : prop;
1030
+ }
1031
+
991
1032
  render() {
992
1033
  var {
993
1034
  onScroll,
994
- fn
1035
+ onSwap,
1036
+ onDrop,
1037
+ onDrag,
1038
+ fn,
1039
+ focused,
1040
+ SetState,
1041
+ striped
995
1042
  } = this.context;
996
1043
  var {
997
1044
  rows,
@@ -1015,24 +1062,60 @@ class AIOTableUnit extends _react.Component {
1015
1062
  }
1016
1063
 
1017
1064
  this.renderIndex = -1;
1018
- return /*#__PURE__*/_react.default.createElement("div", props, this.getTitles(), rows && rows.length !== 0 && rows.map((row, i) => {
1019
- if (row._groupId) {
1065
+ return /*#__PURE__*/_react.default.createElement("div", props, this.getTitles(), rows && rows.length !== 0 && rows.map((o, i) => {
1066
+ if (o._groupId) {
1020
1067
  return /*#__PURE__*/_react.default.createElement(AIOTableGroup, {
1021
1068
  tableIndex,
1022
- row,
1069
+ row: o,
1023
1070
  columns,
1024
1071
  key: 'group' + i + '-' + tableIndex
1025
1072
  });
1026
1073
  }
1027
1074
 
1028
1075
  this.renderIndex++;
1029
- return row[type].map((r, j) => {
1030
- return /*#__PURE__*/_react.default.createElement(AIOTableCell, _extends({
1031
- cellId: i + '-' + j + '-' + tableIndex,
1032
- renderIndex: this.renderIndex
1033
- }, r, {
1034
- row: row.row
1035
- }));
1076
+ return o[type].map(({
1077
+ value,
1078
+ column
1079
+ }, j) => {
1080
+ let row = o.row;
1081
+ let cellId = i + '-' + j + '-' + tableIndex;
1082
+ let inlineEdit = this.getPropValue(row, column, column.inlineEdit);
1083
+ return /*#__PURE__*/_react.default.createElement(AIOTableCell, {
1084
+ key: cellId,
1085
+ attrs: {
1086
+ 'data-row-index': this.renderIndex,
1087
+ 'data-col-index': column._renderIndex,
1088
+ 'data-real-row-index': row._index,
1089
+ 'data-real-col-index': column._index,
1090
+ 'data-child-index': row._childIndex,
1091
+ 'data-childs-length': row._childsLength,
1092
+ 'data-lavel': row._level,
1093
+ 'data-cell-id': cellId,
1094
+ tabIndex: 0,
1095
+ draggable: typeof onSwap === 'function' && column.swap,
1096
+ onDrop: () => onDrop(row),
1097
+ onDragOver: e => e.preventDefault(),
1098
+ onDragStart: () => onDrag(row),
1099
+ onClick: () => {
1100
+ if (!inlineEdit || focused === cellId) {
1101
+ return;
1102
+ }
1103
+
1104
+ SetState({
1105
+ focused: cellId
1106
+ });
1107
+ setTimeout(() => (0, _jquery.default)('.aio-table-input:focus').select(), 10);
1108
+ }
1109
+ },
1110
+ striped: this.renderIndex % 2 === 0 && striped,
1111
+ value: value,
1112
+ column: column,
1113
+ row: row,
1114
+ inlineEdit: inlineEdit,
1115
+ before: this.getPropValue(row, column, column.before),
1116
+ after: this.getPropValue(row, column, column.after),
1117
+ justify: column.justify !== false && !column.treeMode
1118
+ });
1036
1119
  });
1037
1120
  }), rows && rows.length === 0 && fn.getNoData(columns), !rows && fn.getLoading());
1038
1121
  }
@@ -1203,8 +1286,12 @@ class AIOTableTitle extends _react.Component {
1203
1286
  column,
1204
1287
  onDragStart,
1205
1288
  onDragOver,
1206
- onDrop
1289
+ onDrop,
1290
+ isLast
1207
1291
  } = this.props;
1292
+ let {
1293
+ rtl
1294
+ } = this.context;
1208
1295
 
1209
1296
  if (column.template === 'gantt') {
1210
1297
  return this.getGanttTitle(column);
@@ -1214,7 +1301,7 @@ class AIOTableTitle extends _react.Component {
1214
1301
  return /*#__PURE__*/_react.default.createElement("div", {
1215
1302
  style: this.getStyle(),
1216
1303
  draggable: false,
1217
- className: "aio-table-title"
1304
+ className: 'aio-table-title' + (column.titleClassName ? ' ' + column.titleClassName : '') + (isLast ? ' last-child' : '') + (rtl ? ' rtl' : ' ltr')
1218
1305
  }, /*#__PURE__*/_react.default.createElement(AIOTableFilter, {
1219
1306
  column: column
1220
1307
  }), /*#__PURE__*/_react.default.createElement("div", {
@@ -1285,8 +1372,7 @@ class AIOTableGroup extends _react.Component {
1285
1372
 
1286
1373
  render() {
1287
1374
  let {
1288
- indent,
1289
- getGap
1375
+ indent
1290
1376
  } = this.context;
1291
1377
  let {
1292
1378
  row,
@@ -1304,7 +1390,9 @@ class AIOTableGroup extends _react.Component {
1304
1390
  }), /*#__PURE__*/_react.default.createElement("div", {
1305
1391
  className: "aio-table-toggle",
1306
1392
  onClick: () => this.click(row)
1307
- }, this.getIcon(row)), getGap(), /*#__PURE__*/_react.default.createElement("div", {
1393
+ }, this.getIcon(row)), /*#__PURE__*/_react.default.createElement("div", {
1394
+ className: "aio-table-cell-gap"
1395
+ }), /*#__PURE__*/_react.default.createElement("div", {
1308
1396
  className: "aio-table-group-text"
1309
1397
  }, row._groupValue)));
1310
1398
  }
@@ -1327,32 +1415,6 @@ class AIOTableCell extends _react.Component {
1327
1415
  };
1328
1416
  }
1329
1417
 
1330
- getBefore(row, column) {
1331
- if (!column.before) {
1332
- return '';
1333
- }
1334
-
1335
- var before = typeof column.before === 'function' ? column.before(row, column) : column.before;
1336
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
1337
- className: "aio-table-icon"
1338
- }, before), this.context.getGap());
1339
- }
1340
-
1341
- getAfter(row, column) {
1342
- if (!column.after) {
1343
- return '';
1344
- }
1345
-
1346
- var after = typeof column.after === 'function' ? column.after(row, column) : column.after;
1347
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
1348
- style: {
1349
- flex: 1
1350
- }
1351
- }), /*#__PURE__*/_react.default.createElement("div", {
1352
- className: "aio-table-icon"
1353
- }, after));
1354
- }
1355
-
1356
1418
  getStyle(column, row) {
1357
1419
  var {
1358
1420
  padding = '36px',
@@ -1361,7 +1423,6 @@ class AIOTableCell extends _react.Component {
1361
1423
  } = column;
1362
1424
  var {
1363
1425
  rowHeight,
1364
- striped,
1365
1426
  getCellStyle = () => {
1366
1427
  return {};
1367
1428
  }
@@ -1372,17 +1433,6 @@ class AIOTableCell extends _react.Component {
1372
1433
  minWidth
1373
1434
  };
1374
1435
 
1375
- if (row._index % 2 === 0) {
1376
- if (typeof striped === 'string') {
1377
- style.background = striped;
1378
- }
1379
-
1380
- if (Array.isArray(striped)) {
1381
- style.background = striped[0];
1382
- style.color = striped[1];
1383
- }
1384
- }
1385
-
1386
1436
  if (column.template === 'gantt') {
1387
1437
  style.padding = `0 ${padding}`;
1388
1438
  }
@@ -1397,12 +1447,9 @@ class AIOTableCell extends _react.Component {
1397
1447
  var className = 'aio-table-cell';
1398
1448
  let {
1399
1449
  striped
1400
- } = this.context;
1401
- let {
1402
- renderIndex
1403
1450
  } = this.props;
1404
1451
 
1405
- if (renderIndex % 2 === 0 && striped === true) {
1452
+ if (striped) {
1406
1453
  className += ' striped';
1407
1454
  }
1408
1455
 
@@ -1410,11 +1457,7 @@ class AIOTableCell extends _react.Component {
1410
1457
  className += ' aio-table-cell-selectable';
1411
1458
  }
1412
1459
 
1413
- if (column.template) {
1414
- className += ' aio-table-cell-template';
1415
- }
1416
-
1417
- if (column.template === 'gantt') {
1460
+ if (column.template && column.template.type === 'gantt') {
1418
1461
  className += ' aio-table-cell-gantt';
1419
1462
  }
1420
1463
 
@@ -1434,6 +1477,14 @@ class AIOTableCell extends _react.Component {
1434
1477
  className += ' aio-table-cell-hidden';
1435
1478
  }
1436
1479
 
1480
+ if (row._isFirstChild) {
1481
+ className += ' first-child';
1482
+ }
1483
+
1484
+ if (row._isLastChild) {
1485
+ className += ' last-child';
1486
+ }
1487
+
1437
1488
  return className;
1438
1489
  }
1439
1490
 
@@ -1457,7 +1508,9 @@ class AIOTableCell extends _react.Component {
1457
1508
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
1458
1509
  className: "aio-table-toggle",
1459
1510
  onClick: () => fn.toggleRow(row)
1460
- }, icon), this.context.getGap());
1511
+ }, icon), /*#__PURE__*/_react.default.createElement("div", {
1512
+ className: "aio-table-cell-gap"
1513
+ }));
1461
1514
  }
1462
1515
 
1463
1516
  getContent(row, column, value) {
@@ -1465,6 +1518,9 @@ class AIOTableCell extends _react.Component {
1465
1518
  focused,
1466
1519
  fn
1467
1520
  } = this.context;
1521
+ let {
1522
+ inlineEdit
1523
+ } = this.props;
1468
1524
  var content = '';
1469
1525
  let template = typeof column.template === 'function' ? column.template(row, column) : column.template;
1470
1526
 
@@ -1472,19 +1528,15 @@ class AIOTableCell extends _react.Component {
1472
1528
  content = fn.getSliderCell(template);
1473
1529
  } else if (template && template.type === 'options') {
1474
1530
  content = fn.getOptionsCell(template);
1475
- } else if (template === 'gantt') {
1476
- content = fn.getGanttCell(row, column);
1477
- } else if (template && this.inlineEdit) {
1478
- if (!focused) {
1479
- content = template;
1480
- } else {
1481
- content = this.getInput(row, column);
1482
- }
1531
+ } else if (template && template.type === 'gantt') {
1532
+ content = fn.getGanttCell(row, template);
1533
+ } else if (template && inlineEdit) {
1534
+ content = focused ? this.getInput(row, column) : template;
1483
1535
  } else if (template) {
1484
1536
  content = template;
1485
- } else if (this.inlineEdit) {
1537
+ } else if (inlineEdit) {
1486
1538
  content = this.getInput(row, column);
1487
- } else if (column.getValue) {
1539
+ } else {
1488
1540
  content = value;
1489
1541
  }
1490
1542
 
@@ -1509,21 +1561,52 @@ class AIOTableCell extends _react.Component {
1509
1561
  return content;
1510
1562
  }
1511
1563
 
1564
+ async changeCell(value) {
1565
+ let {
1566
+ row,
1567
+ column,
1568
+ inlineEdit
1569
+ } = this.props;
1570
+ let {
1571
+ setCellValue
1572
+ } = this.context;
1573
+ let res;
1574
+ this.setState({
1575
+ loading: true
1576
+ });
1577
+
1578
+ if (inlineEdit.onChange) {
1579
+ res = await inlineEdit.onChange(row, value);
1580
+ } else {
1581
+ res = await this.context.onChange(setCellValue(row, column.field, value));
1582
+ }
1583
+
1584
+ this.setState({
1585
+ loading: false
1586
+ });
1587
+ return res;
1588
+ }
1589
+
1512
1590
  getInput(row, column) {
1513
1591
  let {
1514
- type,
1515
- getValue,
1516
- disabled = () => false
1517
- } = this.inlineEdit;
1592
+ getCellValue
1593
+ } = this.context;
1518
1594
  let {
1519
- renderIndex
1595
+ attrs,
1596
+ inlineEdit
1520
1597
  } = this.props;
1598
+ let {
1599
+ type,
1600
+ getValue,
1601
+ disabled = () => false,
1602
+ options
1603
+ } = inlineEdit;
1521
1604
  let {
1522
1605
  value
1523
1606
  } = this.state;
1524
1607
 
1525
1608
  if (getValue) {
1526
- value = getValue(row);
1609
+ value = getCellValue(row, getValue, column.field);
1527
1610
  }
1528
1611
 
1529
1612
  if (disabled(row)) {
@@ -1534,10 +1617,10 @@ class AIOTableCell extends _react.Component {
1534
1617
  return value;
1535
1618
  }
1536
1619
 
1537
- let props = { ...this.inlineEdit,
1620
+ let props = { ...inlineEdit,
1538
1621
  className: 'aio-table-input',
1539
- rowindex: renderIndex,
1540
- colindex: column._renderIndex,
1622
+ 'data-row-index': attrs['data-row-index'],
1623
+ 'data-col-index': attrs['data-col-index'],
1541
1624
  value: value === null || value === undefined ? '' : value
1542
1625
  };
1543
1626
 
@@ -1552,26 +1635,30 @@ class AIOTableCell extends _react.Component {
1552
1635
  value: e.target.value
1553
1636
  }),
1554
1637
  onBlur: async e => {
1638
+ let {
1639
+ value
1640
+ } = this.state;
1641
+
1555
1642
  if (value === this.props.value) {
1556
1643
  return;
1557
1644
  }
1558
1645
 
1559
- this.setState({
1560
- loading: true
1561
- });
1562
- let res = await this.inlineEdit.onChange(row, type === 'number' ? parseFloat(value) : value);
1563
- this.setState({
1564
- loading: false
1565
- });
1646
+ let newValue = value;
1647
+
1648
+ if (type === 'number') {
1649
+ newValue = parseFloat(newValue);
1650
+
1651
+ if (isNaN(newValue)) {
1652
+ newValue = 0;
1653
+ }
1654
+ }
1655
+
1656
+ let res = await this.changeCell(newValue);
1566
1657
 
1567
1658
  if (typeof res === 'string') {
1568
1659
  this.setState({
1569
1660
  error: res
1570
1661
  });
1571
- } else if (res === false) {
1572
- this.setState({
1573
- value: this.props.value
1574
- });
1575
1662
  } else {
1576
1663
  this.setState({
1577
1664
  value: this.props.value
@@ -1584,12 +1671,12 @@ class AIOTableCell extends _react.Component {
1584
1671
  }
1585
1672
 
1586
1673
  if (type === 'select') {
1587
- if (!this.inlineEdit.options) {
1674
+ if (!options) {
1588
1675
  console.error('aio table => missing options property of column inlineEdit with type="select"');
1589
1676
  return '';
1590
1677
  }
1591
1678
 
1592
- if (!Array.isArray(this.inlineEdit.options)) {
1679
+ if (!Array.isArray(options)) {
1593
1680
  console.error('aio table => options property of column inlineEdit with type="select" must be an array of objects . each object must have text and value property!!!');
1594
1681
  return '';
1595
1682
  }
@@ -1611,13 +1698,9 @@ class AIOTableCell extends _react.Component {
1611
1698
  }
1612
1699
 
1613
1700
  this.setState({
1614
- loading: true,
1615
1701
  value
1616
1702
  });
1617
- let res = await this.inlineEdit.onChange(row, value);
1618
- this.setState({
1619
- loading: false
1620
- });
1703
+ let res = await this.changeCell(value);
1621
1704
 
1622
1705
  if (typeof res === 'string') {
1623
1706
  this.setState({
@@ -1629,7 +1712,7 @@ class AIOTableCell extends _react.Component {
1629
1712
  });
1630
1713
  }
1631
1714
  }
1632
- }), this.inlineEdit.options.map((o, i) => /*#__PURE__*/_react.default.createElement("option", {
1715
+ }), options.map((o, i) => /*#__PURE__*/_react.default.createElement("option", {
1633
1716
  key: i,
1634
1717
  value: o.value
1635
1718
  }, o.text))), /*#__PURE__*/_react.default.createElement("div", {
@@ -1637,40 +1720,75 @@ class AIOTableCell extends _react.Component {
1637
1720
  }));
1638
1721
  }
1639
1722
 
1723
+ if (type === 'checkbox') {
1724
+ return /*#__PURE__*/_react.default.createElement("div", {
1725
+ className: 'aio-table-input-container',
1726
+ tabIndex: 0,
1727
+ onKeyDown: async e => {
1728
+ if (e.keyCode === 13) {
1729
+ value = value === true ? true : false;
1730
+ await this.changeCell(!value);
1731
+ }
1732
+ }
1733
+ }, /*#__PURE__*/_react.default.createElement("input", _extends({}, props, {
1734
+ onFocus: () => this.focus = true,
1735
+ onBlur: () => this.focus = false,
1736
+ checked: value === true ? true : false,
1737
+ onChange: async e => {
1738
+ let value = e.target.checked;
1739
+ this.setState({
1740
+ loading: true
1741
+ });
1742
+ await this.changeCell(value);
1743
+ this.setState({
1744
+ loading: false
1745
+ });
1746
+ }
1747
+ })), /*#__PURE__*/_react.default.createElement("div", {
1748
+ className: "aio-table-input-border"
1749
+ }));
1750
+ }
1751
+
1640
1752
  console.error('aio table => missing type property of column input');
1641
1753
  return '';
1642
1754
  }
1643
1755
 
1644
1756
  componentDidUpdate() {
1645
- if (this.inlineEdit && this.inlineEdit.type === 'select' && this.focus) {
1646
- (0, _jquery.default)(this.dom.current).find('.aio-table-input').focus();
1757
+ let {
1758
+ inlineEdit
1759
+ } = this.props;
1760
+
1761
+ if (inlineEdit && this.focus) {
1762
+ if (inlineEdit.type === 'select' || inlineEdit.type === 'checkbox') {
1763
+ (0, _jquery.default)(this.dom.current).find('.aio-table-input').focus();
1764
+ }
1647
1765
  }
1648
1766
  }
1649
1767
 
1768
+ getProps(row, column, content) {
1769
+ let title = column.getTooltip ? column.getTooltip(row) : typeof content === 'string' ? content : undefined;
1770
+ return {
1771
+ ref: this.dom,
1772
+ title,
1773
+ style: this.getStyle(column, row),
1774
+ className: this.getClassName(row, column)
1775
+ };
1776
+ }
1777
+
1650
1778
  render() {
1651
1779
  let {
1652
1780
  indent,
1653
- fn,
1654
- focused,
1655
- SetState,
1656
- onDrag,
1657
- onDrop,
1658
- onSwap
1781
+ fn
1659
1782
  } = this.context;
1660
1783
  let {
1661
1784
  row,
1662
1785
  column,
1663
1786
  value,
1664
- cellId,
1665
- renderIndex
1787
+ before,
1788
+ after,
1789
+ justify,
1790
+ attrs
1666
1791
  } = this.props;
1667
- this.inlineEdit = typeof column.inlineEdit === 'function' ? column.inlineEdit(row, column) : column.inlineEdit;
1668
-
1669
- if (column.title === 'تعداد' && row._index === 0) {
1670
- console.log('aio table cell render value', value);
1671
- console.log('aio table cell render state.value', this.state.value);
1672
- console.log('aio table cell render this.state.prevValue', this.state.prevValue);
1673
- }
1674
1792
 
1675
1793
  if (this.state.prevValue !== value) {
1676
1794
  setTimeout(() => this.setState({
@@ -1684,9 +1802,6 @@ class AIOTableCell extends _react.Component {
1684
1802
  loading
1685
1803
  } = this.state;
1686
1804
  let content = this.getContent(row, column, value);
1687
- let before = this.getBefore(row, column);
1688
- let after = this.getAfter(row, column);
1689
- let showToggleIcon = column.treeMode;
1690
1805
  let cell;
1691
1806
 
1692
1807
  if (loading) {
@@ -1704,51 +1819,30 @@ class AIOTableCell extends _react.Component {
1704
1819
  }
1705
1820
  }, error);
1706
1821
  } else {
1707
- let style = {
1708
- justifyContent: column.justify !== false && !column.treeMode ? 'center' : undefined
1709
- };
1710
1822
  cell = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, column.treeMode && /*#__PURE__*/_react.default.createElement("div", {
1711
- className: "aio-table-indent",
1712
1823
  style: {
1713
- width: row._level * indent
1824
+ width: row._level * indent,
1825
+ flexShrink: 0
1826
+ }
1827
+ }), column.treeMode && this.getToggleIcon(row), before !== undefined && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
1828
+ className: "aio-table-icon"
1829
+ }, before), /*#__PURE__*/_react.default.createElement("div", {
1830
+ className: "aio-table-cell-gap"
1831
+ })), content !== undefined && /*#__PURE__*/_react.default.createElement("div", {
1832
+ className: "aio-table-cell-content",
1833
+ style: {
1834
+ justifyContent: justify ? 'center' : undefined
1714
1835
  }
1715
- }), showToggleIcon && this.getToggleIcon(row), before, /*#__PURE__*/_react.default.createElement("div", {
1716
- className: "aio-table-content",
1717
- style: style
1718
- }, content), after);
1836
+ }, content), after !== undefined && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
1837
+ style: {
1838
+ flex: 1
1839
+ }
1840
+ }), /*#__PURE__*/_react.default.createElement("div", {
1841
+ className: "aio-table-icon"
1842
+ }, after)));
1719
1843
  }
1720
1844
 
1721
- return /*#__PURE__*/_react.default.createElement("div", {
1722
- key: cellId,
1723
- tabIndex: 0,
1724
- ref: this.dom,
1725
- cellid: cellId,
1726
- title: typeof content === 'string' ? content : '',
1727
- "data-evenodd": row._index % 2 === 0 ? 'even' : 'odd',
1728
- rowindex: renderIndex,
1729
- colindex: column._renderIndex,
1730
- childindex: row._childIndex,
1731
- level: row._level,
1732
- isfirstchild: row._isFirstChild ? 1 : 0,
1733
- islastchild: row._isLastChild ? 1 : 0,
1734
- childslength: row._childsLength,
1735
- style: this.getStyle(column, row),
1736
- className: this.getClassName(row, column),
1737
- draggable: typeof onSwap === 'function' && column.swap,
1738
- onDragOver: e => e.preventDefault(),
1739
- onDragStart: () => onDrag(row),
1740
- onDrop: () => onDrop(row),
1741
- onClick: e => {
1742
- if (this.inlineEdit) {
1743
- if (focused !== cellId) {
1744
- SetState({
1745
- focused: cellId
1746
- });
1747
- setTimeout(() => (0, _jquery.default)('.aio-table-input:focus').select(), 10);
1748
- }
1749
- }
1750
- }
1751
- }, cell);
1845
+ return /*#__PURE__*/_react.default.createElement("div", _extends({}, attrs, this.getProps(row, column, content)), cell);
1752
1846
  }
1753
1847
 
1754
1848
  }
@@ -2045,7 +2139,7 @@ function ATFN({
2045
2139
  } = getProps();
2046
2140
  let name = window.prompt(translate('Inter Excel File Name')); // if (name === false || name === undefined || name === null) { return; }
2047
2141
 
2048
- if (!name.length) return;
2142
+ if (!name || name === null || !name.length) return;
2049
2143
  var data = $$.getJSON(columns, rows);
2050
2144
  var arrData = typeof data != "object" ? JSON.parse(data) : data;
2051
2145
  var CSV = ""; // CSV += 'title';
@@ -2182,7 +2276,7 @@ function ATFN({
2182
2276
  });
2183
2277
  },
2184
2278
 
2185
- getGanttCell(row, column) {
2279
+ getGanttCell(row, template) {
2186
2280
  let {
2187
2281
  rtl
2188
2282
  } = getProps();
@@ -2195,7 +2289,7 @@ function ATFN({
2195
2289
  getText = () => false,
2196
2290
  getStart,
2197
2291
  getEnd
2198
- } = column;
2292
+ } = template;
2199
2293
 
2200
2294
  if (typeof getStart !== 'function') {
2201
2295
  console.error('aio table => gantt column => column getStart property is not a function');
@@ -2328,7 +2422,56 @@ function ATFN({
2328
2422
  return result;
2329
2423
  },
2330
2424
 
2331
- onScroll(dom, index) {
2425
+ async onScroll(dom, index) {
2426
+ let {
2427
+ onScrollEnd
2428
+ } = getProps();
2429
+
2430
+ if (onScrollEnd) {
2431
+ if (index === undefined || index === 0) {
2432
+ let table = (0, _jquery.default)(dom.current).find('.aio-table-unit');
2433
+ let scrollTop = table.scrollTop();
2434
+ let scrollHeight = table[0].scrollHeight;
2435
+ let height = table.height();
2436
+
2437
+ if (scrollTop + height === scrollHeight) {
2438
+ let {
2439
+ startIndex
2440
+ } = getState();
2441
+ let {
2442
+ scrollLoadLength,
2443
+ scrollTotalLength
2444
+ } = getProps();
2445
+ let from = startIndex + scrollLoadLength;
2446
+
2447
+ if (from > scrollTotalLength) {
2448
+ return;
2449
+ }
2450
+
2451
+ let to = from + scrollLoadLength;
2452
+
2453
+ if (to > scrollTotalLength) {
2454
+ to = scrollTotalLength;
2455
+ }
2456
+
2457
+ let a = (0, _jquery.default)(dom.current).find('.aio-table-main-loading');
2458
+ a.css({
2459
+ display: 'flex'
2460
+ });
2461
+ let res = await onScrollEnd(from, to);
2462
+ a.css({
2463
+ display: 'none'
2464
+ });
2465
+
2466
+ if (res !== false) {
2467
+ setState({
2468
+ startIndex: from
2469
+ });
2470
+ }
2471
+ }
2472
+ }
2473
+ }
2474
+
2332
2475
  if (index === undefined) {
2333
2476
  return;
2334
2477
  }
@@ -2398,98 +2541,27 @@ function ATFN({
2398
2541
  return parseInt(list.map(o => o.length === 1 ? '0' + o : o).join(''));
2399
2542
  },
2400
2543
 
2401
- // getSorts(toolbar){
2402
- // let {onChangeSort} = getProps();
2403
- // let {sorts,columns = []} = getState();
2404
- // let Sorts = sorts.map((o)=>{
2405
- // return {
2406
- // ...o,
2407
- // onChangeDir:()=>{
2408
- // o.dir = o.dir === 'dec'?'inc':'dec';
2409
- // setState({sorts});
2410
- // if(onChangeSort){onChangeSort(Sorts.filter((o)=>o.active !== false))}
2411
- // },
2412
- // onChangeActive:()=>{
2413
- // o.active = o.active === undefined?true:o.active;
2414
- // o.active = !o.active;
2415
- // setState({sorts});
2416
- // if(onChangeSort){onChangeSort(Sorts.filter((o)=>o.active !== false))}
2417
- // }
2418
- // }
2419
- // })
2420
- // for(let i = 0; i < columns.length; i++){
2421
- // if(!columns[i].sort || columns[i]._addedTosorts){continue}
2422
- // let column = columns[i];
2423
- // let {sort,getValue} = columns[i];
2424
- // let title = sort.title || column.title || '';
2425
- // let {toggle = true,dir = 'inc',active = true,type} = sort;
2426
- // Sorts.push({
2427
- // title,dir,active,toggle,getValue,type,
2428
- // onChangeDir:()=>{
2429
- // sort.dir = sort.dir === 'dec'?'inc':'dec';
2430
- // setState({columns});
2431
- // if(onChangeSort){onChangeSort(Sorts.filter((o)=>o.active !== false))}
2432
- // },
2433
- // onChangeActive:()=>{
2434
- // sort.active = sort.active === undefined?true:sort.active;
2435
- // sort.active = !sort.active;
2436
- // setState({columns});
2437
- // if(onChangeSort){onChangeSort(Sorts.filter((o)=>o.active !== false))}
2438
- // }
2439
- // })
2440
- // }
2441
- // let result = [];
2442
- // for(let i = 0; i < Sorts.length; i++){
2443
- // let sort = Sorts[i];
2444
- // let {getValue,dir = 'inc',title,active = true,toggle = true,type,onChangeDir,onChangeActive} = sort;
2445
- // if(!title){console.error('aio table => missing sort title property'); continue;}
2446
- // if(typeof getValue !== 'function'){console.error('aio table => sort getValue property is not a function'); continue;}
2447
- // if(active === true){
2448
- // if(type === 'date'){
2449
- // let newGetValue = (row)=>{
2450
- // let value = getValue(row);
2451
- // if(typeof value !== 'string'){return 0}
2452
- // return $$.getDateNumber(value)
2453
- // }
2454
- // result.push({getValue:(row)=>newGetValue(row),dir});
2455
- // }
2456
- // else{
2457
- // result.push({getValue,dir});
2458
- // }
2459
- // }
2460
- // if(toggle){
2461
- // toolbar.show = true;
2462
- // toolbar.sort.push({
2463
- // text:title,checked:active === true,
2464
- // after:(
2465
- // <div style={{width:'30px',display:'flex',justifyContent:'flex-end'}}>
2466
- // <Icon
2467
- // size={0.8} path={dir === 'dec'?mdiArrowDown:mdiArrowUp}
2468
- // onClick={(e)=>{e.stopPropagation(); onChangeDir()}}
2469
- // />
2470
- // </div>
2471
- // ),
2472
- // onClick:()=>onChangeActive()
2473
- // })
2474
- // }
2475
- // }
2476
- // return result;
2477
- // },
2478
2544
  getSorts(toolbar) {
2479
2545
  let {
2480
2546
  onChangeSort
2481
2547
  } = getProps();
2482
2548
  let {
2483
2549
  sorts,
2484
- columns = []
2550
+ columns = [],
2551
+ getCellValue
2485
2552
  } = getState();
2553
+ let sortTitles = sorts.map(o => o.title);
2486
2554
 
2487
2555
  for (let i = 0; i < columns.length; i++) {
2488
- if (!columns[i].sort || columns[i]._addedTosorts) {
2556
+ if (!columns[i].sort) {
2489
2557
  continue;
2490
2558
  }
2491
2559
 
2492
- columns[i]._addedTosorts = true;
2560
+ if (sortTitles.indexOf(columns[i].title) !== -1) {
2561
+ continue;
2562
+ }
2563
+
2564
+ columns[i]._addedToSorts = true;
2493
2565
  let column = columns[i];
2494
2566
 
2495
2567
  if (column.sort === true) {
@@ -2499,8 +2571,10 @@ function ATFN({
2499
2571
  let {
2500
2572
  sort
2501
2573
  } = columns[i];
2502
- let title = sort.title || column.title || '';
2574
+ let a = sort.title || column.title || '';
2575
+ let title = typeof a === 'function' ? a() : a;
2503
2576
  let getValue = sort.getValue || column.getValue;
2577
+ let field = sort.field || column.field;
2504
2578
  let {
2505
2579
  toggle = true,
2506
2580
  dir = 'inc',
@@ -2513,7 +2587,8 @@ function ATFN({
2513
2587
  active,
2514
2588
  toggle,
2515
2589
  getValue,
2516
- type
2590
+ type,
2591
+ field
2517
2592
  });
2518
2593
  }
2519
2594
 
@@ -2554,7 +2629,8 @@ function ATFN({
2554
2629
  toggle = true,
2555
2630
  type,
2556
2631
  onChangeDir,
2557
- onChangeActive
2632
+ onChangeActive,
2633
+ field
2558
2634
  } = sort;
2559
2635
 
2560
2636
  if (!title) {
@@ -2562,15 +2638,10 @@ function ATFN({
2562
2638
  continue;
2563
2639
  }
2564
2640
 
2565
- if (typeof getValue !== 'function') {
2566
- console.error('aio table => sort getValue property is not a function');
2567
- continue;
2568
- }
2569
-
2570
2641
  if (active === true) {
2571
2642
  if (type === 'date') {
2572
2643
  let newGetValue = row => {
2573
- let value = getValue(row);
2644
+ let value = getCellValue(row, getValue, field);
2574
2645
 
2575
2646
  if (typeof value !== 'string') {
2576
2647
  return 0;
@@ -2631,8 +2702,7 @@ function ATFN({
2631
2702
  let {
2632
2703
  title,
2633
2704
  active = true,
2634
- toggle = true,
2635
- getValue
2705
+ toggle = true
2636
2706
  } = group;
2637
2707
 
2638
2708
  if (!title) {
@@ -2640,11 +2710,6 @@ function ATFN({
2640
2710
  continue;
2641
2711
  }
2642
2712
 
2643
- if (typeof getValue !== 'function') {
2644
- console.error('aio table => group getValue property is not a function');
2645
- continue;
2646
- }
2647
-
2648
2713
  groupDictionary[title] = groupDictionary[title] === undefined ? active : groupDictionary[title];
2649
2714
 
2650
2715
  if (groupDictionary[title]) {
@@ -2746,10 +2811,10 @@ function ATFN({
2746
2811
  } = getState();
2747
2812
  let column = columns[index];
2748
2813
  let {
2749
- title,
2750
2814
  show,
2751
2815
  storageKey
2752
2816
  } = column;
2817
+ let title = typeof column.title === 'function' ? column.title() : column.title;
2753
2818
  toolbar.show = true;
2754
2819
  toolbar.toggle.push({
2755
2820
  text: title,
@@ -3009,7 +3074,18 @@ function ATFN({
3009
3074
  }, items);
3010
3075
  },
3011
3076
 
3012
- getLoading() {
3077
+ getLoading(isMain) {
3078
+ if (isMain) {
3079
+ return /*#__PURE__*/_react.default.createElement("div", {
3080
+ className: "aio-table-loading aio-table-main-loading",
3081
+ style: {
3082
+ display: 'none'
3083
+ }
3084
+ }, $$.cubes2({
3085
+ thickness: [6, 40]
3086
+ }));
3087
+ }
3088
+
3013
3089
  return /*#__PURE__*/_react.default.createElement("div", {
3014
3090
  className: "aio-table-loading"
3015
3091
  }, $$.cubes2({
@@ -3076,7 +3152,8 @@ function ATFN({
3076
3152
  } = getProps();
3077
3153
  let {
3078
3154
  filterDictionary,
3079
- searchText
3155
+ searchText,
3156
+ getCellValue
3080
3157
  } = getState();
3081
3158
  row._values = {};
3082
3159
  let show = true,
@@ -3088,14 +3165,7 @@ function ATFN({
3088
3165
 
3089
3166
  for (let i = 0; i < columns.length; i++) {
3090
3167
  let column = columns[i],
3091
- value;
3092
-
3093
- try {
3094
- value = typeof column.getValue === 'function' ? column.getValue(row) : undefined;
3095
- } catch {
3096
- value = undefined;
3097
- }
3098
-
3168
+ value = getCellValue(row, column.getValue, column.field);
3099
3169
  row._values[column._index] = value;
3100
3170
  filterDictionary[column._index] = filterDictionary[column._index] || {
3101
3171
  items: [],
@@ -3103,7 +3173,15 @@ function ATFN({
3103
3173
  };
3104
3174
 
3105
3175
  if (show && search) {
3106
- show = search(row, searchText);
3176
+ if (searchText === '') {
3177
+ show = true;
3178
+ } else {
3179
+ try {
3180
+ show = search(row, searchText);
3181
+ } catch {
3182
+ show = false;
3183
+ }
3184
+ }
3107
3185
  }
3108
3186
 
3109
3187
  if (show && !onChangeFilter) {
@@ -3350,6 +3428,10 @@ function ATFN({
3350
3428
  },
3351
3429
 
3352
3430
  getRowsBySort(rows, sorts) {
3431
+ let {
3432
+ getCellValue
3433
+ } = getState();
3434
+
3353
3435
  if (!sorts.length) {
3354
3436
  return rows;
3355
3437
  }
@@ -3362,10 +3444,11 @@ function ATFN({
3362
3444
  for (let i = 0; i < sorts.length; i++) {
3363
3445
  let {
3364
3446
  getValue,
3365
- dir
3447
+ dir,
3448
+ field
3366
3449
  } = sorts[i];
3367
- let aValue = getValue(a),
3368
- bValue = getValue(b);
3450
+ let aValue = getCellValue(a, getValue, field),
3451
+ bValue = getCellValue(b, getValue, field);
3369
3452
 
3370
3453
  if (aValue < bValue) {
3371
3454
  return -1 * (dir === 'dec' ? -1 : 1);
@@ -3452,7 +3535,8 @@ function ATFN({
3452
3535
  }
3453
3536
 
3454
3537
  var {
3455
- groupsOpen
3538
+ groupsOpen,
3539
+ getCellValue
3456
3540
  } = getState();
3457
3541
 
3458
3542
  function msf(obj, _level, parents) {
@@ -3484,7 +3568,7 @@ function ATFN({
3484
3568
  for (let i = 0; i < roots.length; i++) {
3485
3569
  let root = roots[i];
3486
3570
  var obj = newModel;
3487
- let values = groups.map(group => group.getValue(root[0].row));
3571
+ let values = groups.map(group => getCellValue(root[0].row, group.getValue, group.field));
3488
3572
 
3489
3573
  for (let j = 0; j < values.length; j++) {
3490
3574
  let value = values[j];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aio-table",
3
- "version": "6.2.0",
3
+ "version": "6.3.2",
4
4
  "description": "all in one table. tree mode , simple mode , tree mode, gantt mode , groupby mode, freeze mode.",
5
5
  "main": "index.js",
6
6
  "scripts": {