aio-table 6.1.5 → 6.3.1

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 +28 -58
  2. package/index.js +642 -324
  3. package/package.json +1 -4
package/index.js CHANGED
@@ -9,10 +9,6 @@ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _aioButton = _interopRequireDefault(require("aio-button"));
11
11
 
12
- var _react2 = require("@mdi/react");
13
-
14
- var _js = require("@mdi/js");
15
-
16
12
  var _jquery = _interopRequireDefault(require("jquery"));
17
13
 
18
14
  var _rRangeSlider = _interopRequireDefault(require("r-range-slider"));
@@ -61,9 +57,20 @@ class AIOTable extends _react.Component {
61
57
  filterDictionary: {},
62
58
  groupsOpen: {},
63
59
  searchText: '',
60
+ addedSorts: [],
64
61
  freezeSize,
65
62
  groupDictionary,
66
- 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
+ }),
67
74
  //make imutable to prevent change of props.paging because that will compaire with next input props.paging
68
75
  paging: paging ? { ...paging
69
76
  } : false,
@@ -71,8 +78,34 @@ class AIOTable extends _react.Component {
71
78
  columns: copiedColumns,
72
79
  prevColumns: JSON.stringify(copiedColumns),
73
80
  focused: false,
74
- 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
+ }
75
107
  };
108
+ console.log('in table', this.state.sorts);
76
109
  }
77
110
 
78
111
  copyJson(j) {
@@ -97,15 +130,6 @@ class AIOTable extends _react.Component {
97
130
  return a(j);
98
131
  }
99
132
 
100
- getGap() {
101
- return /*#__PURE__*/_react.default.createElement("div", {
102
- className: "aio-table-gap",
103
- style: {
104
- width: this.props.cellGap
105
- }
106
- });
107
- }
108
-
109
133
  resizeDown(e) {
110
134
  var {
111
135
  touch
@@ -339,7 +363,7 @@ class AIOTable extends _react.Component {
339
363
  setTimeout(() => this.setState({
340
364
  paging: { ...paging
341
365
  },
342
- prevPaging: JSON.stringify(paging)
366
+ prevPaging: p
343
367
  }), 0);
344
368
  }
345
369
  }
@@ -372,7 +396,7 @@ class AIOTable extends _react.Component {
372
396
  this.rg = rowGap;
373
397
  this.cg = columnGap;
374
398
  this.updateColumns();
375
- 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;
376
400
  var table = columns ? this.getTable(Toolbar) : '';
377
401
  var context = { ...this.props,
378
402
  ...this.state,
@@ -402,7 +426,6 @@ class AIOTable extends _react.Component {
402
426
  },
403
427
  onChangeFilter: onChangeFilter ? this.onChangeFilter.bind(this) : undefined,
404
428
  SetState: obj => this.setState(obj),
405
- getGap: this.getGap.bind(this),
406
429
  onScroll: index => this.fn.onScroll(this.dom, index),
407
430
  groups: this.groups,
408
431
  fn: this.fn,
@@ -430,7 +453,7 @@ class AIOTable extends _react.Component {
430
453
  paging.onChange(obj);
431
454
  }
432
455
  }
433
- })));
456
+ }), this.fn.getLoading(true)));
434
457
  }
435
458
 
436
459
  }
@@ -450,7 +473,7 @@ AIOTable.defaultProps = {
450
473
  groups: []
451
474
  };
452
475
 
453
- class RTableToolbar extends _react.Component {
476
+ class AIOTableToolbar extends _react.Component {
454
477
  constructor(...args) {
455
478
  super(...args);
456
479
 
@@ -527,10 +550,7 @@ class RTableToolbar extends _react.Component {
527
550
  value: searchText,
528
551
  placeholder: translate('Search'),
529
552
  onChange: e => this.changeSearch(e.target.value)
530
- }), /*#__PURE__*/_react.default.createElement(_react2.Icon, {
531
- className: "aio-table-search-icon",
532
- path: searchText ? _js.mdiClose : _js.mdiMagnify,
533
- size: 0.8,
553
+ }), aioTableGetSvg(searchText ? 'close' : 'magnify', {
534
554
  onClick: () => {
535
555
  if (!searchText) {
536
556
  return;
@@ -581,10 +601,7 @@ class RTableToolbar extends _react.Component {
581
601
  type: "button",
582
602
  title: translate('Toggle All'),
583
603
  onClick: () => toggleAll(),
584
- text: /*#__PURE__*/_react.default.createElement(_react2.Icon, {
585
- path: !toggleAllState ? _js.mdiCollapseAll : _js.mdiExpandAll,
586
- size: iconSize
587
- })
604
+ text: !toggleAllState ? aioTableGetSvg('toggleAllMinus') : aioTableGetSvg('toggleAllPlus')
588
605
  })), excelColumns.length > 0 && /*#__PURE__*/_react.default.createElement(_aioButton.default, _extends({
589
606
  key: "excel"
590
607
  }, buttonProps, {
@@ -593,10 +610,7 @@ class RTableToolbar extends _react.Component {
593
610
  onClick: () => {
594
611
  fn.exportToExcel(excelColumns, rows);
595
612
  },
596
- text: /*#__PURE__*/_react.default.createElement(_react2.Icon, {
597
- path: _js.mdiMicrosoftExcel,
598
- size: iconSize
599
- })
613
+ text: aioTableGetSvg('excel')
600
614
  })), toolbarItems.map((o, i) => /*#__PURE__*/_react.default.createElement(_aioButton.default, _extends({
601
615
  type: "button",
602
616
  rtl: rtl,
@@ -609,10 +623,8 @@ class RTableToolbar extends _react.Component {
609
623
  }, buttonProps, {
610
624
  options: groupBy,
611
625
  title: translate('Group By'),
612
- text: /*#__PURE__*/_react.default.createElement(_react2.Icon, {
613
- path: _js.mdiFileTree,
614
- size: iconSize,
615
- horizontal: rtl === true
626
+ text: aioTableGetSvg('group', {
627
+ flip: rtl === true
616
628
  }),
617
629
  onSwap: (start, end, swap) => {
618
630
  let {
@@ -627,10 +639,7 @@ class RTableToolbar extends _react.Component {
627
639
  }, buttonProps, {
628
640
  options: sort,
629
641
  title: translate('Sort'),
630
- text: /*#__PURE__*/_react.default.createElement(_react2.Icon, {
631
- path: _js.mdiSort,
632
- size: iconSize
633
- }),
642
+ text: aioTableGetSvg('sort'),
634
643
  onSwap: (start, end, swap) => {
635
644
  let {
636
645
  sorts
@@ -642,10 +651,7 @@ class RTableToolbar extends _react.Component {
642
651
  })), toggle.length > 1 && /*#__PURE__*/_react.default.createElement(_aioButton.default, _extends({
643
652
  key: "toggle"
644
653
  }, buttonProps, {
645
- text: /*#__PURE__*/_react.default.createElement(_react2.Icon, {
646
- path: _js.mdiEye,
647
- size: iconSize
648
- }),
654
+ text: aioTableGetSvg('eye'),
649
655
  options: toggle,
650
656
  title: translate('Show Columns'),
651
657
  popupStyle: {
@@ -654,10 +660,8 @@ class RTableToolbar extends _react.Component {
654
660
  })), freeze.length > 1 && /*#__PURE__*/_react.default.createElement(_aioButton.default, _extends({
655
661
  key: "freeze"
656
662
  }, buttonProps, {
657
- text: /*#__PURE__*/_react.default.createElement(_react2.Icon, {
658
- path: _js.mdiAlignHorizontalLeft,
659
- size: iconSize,
660
- horizontal: rtl === true
663
+ text: aioTableGetSvg('freeze', {
664
+ flip: rtl === true
661
665
  }),
662
666
  options: freeze,
663
667
  title: translate('Freeze Columns')
@@ -666,7 +670,7 @@ class RTableToolbar extends _react.Component {
666
670
 
667
671
  }
668
672
 
669
- _defineProperty(RTableToolbar, "contextType", AioTableContext);
673
+ _defineProperty(AIOTableToolbar, "contextType", AioTableContext);
670
674
 
671
675
  class AIOTablePaging extends _react.Component {
672
676
  getPageNumber(type) {
@@ -741,33 +745,25 @@ class AIOTablePaging extends _react.Component {
741
745
  className: "aio-table-paging-button",
742
746
  onClick: () => this.changePage(rtl ? 'last' : 'first'),
743
747
  title: translate(rtl ? 'Last Page' : 'First Page')
744
- }, /*#__PURE__*/_react.default.createElement(_react2.Icon, {
745
- path: _js.mdiChevronDoubleLeft,
746
- size: .8
748
+ }, aioTableGetSvg('doubleChevronRight', {
749
+ flip: true
747
750
  })), /*#__PURE__*/_react.default.createElement("div", {
748
751
  className: "aio-table-paging-button",
749
752
  onClick: () => this.changePage(rtl ? 'next' : 'prev'),
750
753
  title: translate(rtl ? 'Next Page' : 'Previous Page')
751
- }, /*#__PURE__*/_react.default.createElement(_react2.Icon, {
752
- path: _js.mdiChevronLeft,
753
- size: .8
754
+ }, aioTableGetSvg('chevronRight', {
755
+ flip: true
754
756
  })), /*#__PURE__*/_react.default.createElement("div", {
755
757
  className: "aio-table-paging-number"
756
758
  }, rtl ? pages + ' / ' + number : number + ' / ' + pages), /*#__PURE__*/_react.default.createElement("div", {
757
759
  className: "aio-table-paging-button",
758
760
  onClick: () => this.changePage(rtl ? 'prev' : 'next'),
759
761
  title: translate(rtl ? 'Previous Page' : 'Next Page')
760
- }, /*#__PURE__*/_react.default.createElement(_react2.Icon, {
761
- path: _js.mdiChevronRight,
762
- size: .8
763
- })), /*#__PURE__*/_react.default.createElement("div", {
762
+ }, aioTableGetSvg('chevronRight')), /*#__PURE__*/_react.default.createElement("div", {
764
763
  className: "aio-table-paging-button",
765
764
  onClick: () => this.changePage(rtl ? 'first' : 'last'),
766
765
  title: translate(rtl ? 'First Page' : 'Last Page')
767
- }, /*#__PURE__*/_react.default.createElement(_react2.Icon, {
768
- path: _js.mdiChevronDoubleRight,
769
- size: .8
770
- })), /*#__PURE__*/_react.default.createElement("select", {
766
+ }, aioTableGetSvg('doubleChevronRight')), /*#__PURE__*/_react.default.createElement("select", {
771
767
  className: "aio-table-paging-button",
772
768
  value: size,
773
769
  onChange: e => onChange({ ...paging,
@@ -880,7 +876,8 @@ class AIOTableUnit extends _react.Component {
880
876
 
881
877
  keyDown(e) {
882
878
  var {
883
- SetState
879
+ SetState,
880
+ focused
884
881
  } = this.context;
885
882
 
886
883
  if (e.keyCode === 27) {
@@ -916,12 +913,11 @@ class AIOTableUnit extends _react.Component {
916
913
 
917
914
  if (inputCells.length) {
918
915
  let cell = inputCells.eq(0);
919
- let cellId = cell.attr('cellid');
920
916
  SetState({
921
- focused: cellId
917
+ focused: cell.attr('data-cell-id')
922
918
  });
923
919
  setTimeout(() => {
924
- (0, _jquery.default)('.aio-table-cell-input[cellid=' + cellId + '] .aio-table-input').focus().select();
920
+ cell.find('.aio-table-input').focus().select();
925
921
  }, 10);
926
922
  }
927
923
 
@@ -929,16 +925,17 @@ class AIOTableUnit extends _react.Component {
929
925
  }
930
926
 
931
927
  let [rowIndex, colIndex] = this.getCellIndex(focusedInput.parents('.aio-table-cell'));
928
+ console.log(rowIndex, colIndex);
932
929
 
933
930
  if (e.keyCode === 40 || e.keyCode === 38) {
934
931
  let sign = e.keyCode === 40 ? 1 : -1;
935
932
  e.preventDefault();
936
933
  rowIndex += sign;
937
- let next = inputs.filter(`[rowindex=${rowIndex}][colindex=${colIndex}]`);
934
+ let next = inputs.filter(`[data-row-index=${rowIndex}][data-col-index=${colIndex}]`);
938
935
 
939
936
  while (rowIndex < this.renderIndex && rowIndex > 0 && next.length === 0) {
940
937
  rowIndex += sign;
941
- next = inputs.filter(`[rowindex=${rowIndex}][colindex=${colIndex}]`);
938
+ next = inputs.filter(`[data-row-index=${rowIndex}][data-col-index=${colIndex}]`);
942
939
  }
943
940
 
944
941
  if (next.length) {
@@ -949,11 +946,11 @@ class AIOTableUnit extends _react.Component {
949
946
  e.preventDefault();
950
947
  let sign = (e.keyCode === 37 ? -1 : 1) * (rtl ? -1 : 1);
951
948
  colIndex += sign;
952
- let next = inputs.filter(`[rowindex=${rowIndex}][colindex=${colIndex}]`);
949
+ let next = inputs.filter(`[data-row-index=${rowIndex}][data-col-index=${colIndex}]`);
953
950
 
954
951
  while (colIndex > 0 && colIndex < columns.length && next.length === 0) {
955
952
  colIndex += sign;
956
- next = inputs.filter(`[rowindex=${rowIndex}][colindex=${colIndex}]`);
953
+ next = inputs.filter(`[data-row-index=${rowIndex}][data-col-index=${colIndex}]`);
957
954
  }
958
955
 
959
956
  if (next.length) {
@@ -964,7 +961,7 @@ class AIOTableUnit extends _react.Component {
964
961
  }
965
962
 
966
963
  getCellIndex(cell) {
967
- return [parseInt(cell.attr('rowindex')), parseInt(cell.attr('colindex'))];
964
+ return [parseInt(cell.attr('data-row-index')), parseInt(cell.attr('data-col-index'))];
968
965
  }
969
966
 
970
967
  card(props) {
@@ -994,7 +991,17 @@ class AIOTableUnit extends _react.Component {
994
991
  let rows;
995
992
 
996
993
  if (search) {
997
- rows = this.props.rows.filter(o => search(o.row, searchText));
994
+ rows = this.props.rows.filter(o => {
995
+ if (searchText === '') {
996
+ return true;
997
+ }
998
+
999
+ try {
1000
+ return search(o.row, searchText);
1001
+ } catch {
1002
+ return false;
1003
+ }
1004
+ });
998
1005
  } else {
999
1006
  rows = this.props.rows;
1000
1007
  }
@@ -1019,10 +1026,20 @@ class AIOTableUnit extends _react.Component {
1019
1026
  }), rows && rows.length === 0 && fn.getNoData(columns), !rows && fn.getLoading());
1020
1027
  }
1021
1028
 
1029
+ getPropValue(row, column, prop) {
1030
+ return typeof prop === 'function' ? prop(row, column) : prop;
1031
+ }
1032
+
1022
1033
  render() {
1023
1034
  var {
1024
1035
  onScroll,
1025
- fn
1036
+ onSwap,
1037
+ onDrop,
1038
+ onDrag,
1039
+ fn,
1040
+ focused,
1041
+ SetState,
1042
+ striped
1026
1043
  } = this.context;
1027
1044
  var {
1028
1045
  rows,
@@ -1046,23 +1063,61 @@ class AIOTableUnit extends _react.Component {
1046
1063
  }
1047
1064
 
1048
1065
  this.renderIndex = -1;
1049
- return /*#__PURE__*/_react.default.createElement("div", props, this.getTitles(), rows && rows.length !== 0 && rows.map((row, i) => {
1050
- if (row._groupId) {
1066
+ return /*#__PURE__*/_react.default.createElement("div", props, this.getTitles(), rows && rows.length !== 0 && rows.map((o, i) => {
1067
+ if (o._groupId) {
1051
1068
  return /*#__PURE__*/_react.default.createElement(AIOTableGroup, {
1052
1069
  tableIndex,
1053
- row,
1070
+ row: o,
1054
1071
  columns,
1055
1072
  key: 'group' + i + '-' + tableIndex
1056
1073
  });
1057
1074
  }
1058
1075
 
1059
1076
  this.renderIndex++;
1060
- return row[type].map((r, j) => /*#__PURE__*/_react.default.createElement(AIOTableCell, _extends({
1061
- cellId: i + '-' + j + '-' + tableIndex,
1062
- renderIndex: this.renderIndex
1063
- }, r, {
1064
- row: row.row
1065
- })));
1077
+ return o[type].map(({
1078
+ value,
1079
+ column
1080
+ }, j) => {
1081
+ let row = o.row;
1082
+ let cellId = i + '-' + j + '-' + tableIndex;
1083
+ let inlineEdit = this.getPropValue(row, column, column.inlineEdit);
1084
+ return /*#__PURE__*/_react.default.createElement(AIOTableCell, {
1085
+ key: cellId,
1086
+ attrs: {
1087
+ 'data-row-index': this.renderIndex,
1088
+ 'data-col-index': column._renderIndex,
1089
+ 'data-real-row-index': row._index,
1090
+ 'data-real-col-index': column._index,
1091
+ 'data-child-index': row._childIndex,
1092
+ 'data-childs-length': row._childsLength,
1093
+ 'data-lavel': row._level,
1094
+ 'data-cell-id': cellId,
1095
+ tabIndex: 0,
1096
+ draggable: typeof onSwap === 'function' && column.swap,
1097
+ onDrop: () => onDrop(row),
1098
+ onDragOver: e => e.preventDefault(),
1099
+ onDragStart: () => onDrag(row),
1100
+ onClick: () => {
1101
+ if (!inlineEdit || focused === cellId) {
1102
+ return;
1103
+ }
1104
+
1105
+ SetState({
1106
+ focused: cellId
1107
+ });
1108
+ setTimeout(() => (0, _jquery.default)('.aio-table-input:focus').select(), 10);
1109
+ }
1110
+ },
1111
+ striped: this.renderIndex % 2 === 0 && striped,
1112
+ value: value,
1113
+ column: column,
1114
+ row: row,
1115
+ inlineEdit: inlineEdit,
1116
+ before: this.getPropValue(row, column, column.before),
1117
+ after: this.getPropValue(row, column, column.after),
1118
+ justify: column.justify !== false && !column.treeMode
1119
+ });
1120
+ });
1066
1121
  }), rows && rows.length === 0 && fn.getNoData(columns), !rows && fn.getLoading());
1067
1122
  }
1068
1123
 
@@ -1288,16 +1343,13 @@ class AIOTableGroup extends _react.Component {
1288
1343
  } = this.context;
1289
1344
 
1290
1345
  if (row._opened) {
1291
- return /*#__PURE__*/_react.default.createElement(_react2.Icon, {
1292
- path: _js.mdiChevronDown,
1293
- size: 1
1346
+ return aioTableGetSvg('chevronDown', {
1347
+ box: '2 1 20 20'
1294
1348
  });
1295
1349
  }
1296
1350
 
1297
- return /*#__PURE__*/_react.default.createElement(_react2.Icon, {
1298
- path: _js.mdiChevronRight,
1299
- size: 1,
1300
- horizontal: rtl === true
1351
+ return aioTableGetSvg('chevronRight', {
1352
+ flip: rtl === true
1301
1353
  });
1302
1354
  }
1303
1355
 
@@ -1317,8 +1369,7 @@ class AIOTableGroup extends _react.Component {
1317
1369
 
1318
1370
  render() {
1319
1371
  let {
1320
- indent,
1321
- getGap
1372
+ indent
1322
1373
  } = this.context;
1323
1374
  let {
1324
1375
  row,
@@ -1336,7 +1387,9 @@ class AIOTableGroup extends _react.Component {
1336
1387
  }), /*#__PURE__*/_react.default.createElement("div", {
1337
1388
  className: "aio-table-toggle",
1338
1389
  onClick: () => this.click(row)
1339
- }, this.getIcon(row)), getGap(), /*#__PURE__*/_react.default.createElement("div", {
1390
+ }, this.getIcon(row)), /*#__PURE__*/_react.default.createElement("div", {
1391
+ className: "aio-table-cell-gap"
1392
+ }), /*#__PURE__*/_react.default.createElement("div", {
1340
1393
  className: "aio-table-group-text"
1341
1394
  }, row._groupValue)));
1342
1395
  }
@@ -1359,32 +1412,6 @@ class AIOTableCell extends _react.Component {
1359
1412
  };
1360
1413
  }
1361
1414
 
1362
- getBefore(row, column) {
1363
- if (!column.before) {
1364
- return '';
1365
- }
1366
-
1367
- var before = typeof column.before === 'function' ? column.before(row, column) : column.before;
1368
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
1369
- className: "aio-table-icon"
1370
- }, before), this.context.getGap());
1371
- }
1372
-
1373
- getAfter(row, column) {
1374
- if (!column.after) {
1375
- return '';
1376
- }
1377
-
1378
- var after = typeof column.after === 'function' ? column.after(row, column) : column.after;
1379
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
1380
- style: {
1381
- flex: 1
1382
- }
1383
- }), /*#__PURE__*/_react.default.createElement("div", {
1384
- className: "aio-table-icon"
1385
- }, after));
1386
- }
1387
-
1388
1415
  getStyle(column, row) {
1389
1416
  var {
1390
1417
  padding = '36px',
@@ -1393,7 +1420,6 @@ class AIOTableCell extends _react.Component {
1393
1420
  } = column;
1394
1421
  var {
1395
1422
  rowHeight,
1396
- striped,
1397
1423
  getCellStyle = () => {
1398
1424
  return {};
1399
1425
  }
@@ -1404,17 +1430,6 @@ class AIOTableCell extends _react.Component {
1404
1430
  minWidth
1405
1431
  };
1406
1432
 
1407
- if (row._index % 2 === 0) {
1408
- if (typeof striped === 'string') {
1409
- style.background = striped;
1410
- }
1411
-
1412
- if (Array.isArray(striped)) {
1413
- style.background = striped[0];
1414
- style.color = striped[1];
1415
- }
1416
- }
1417
-
1418
1433
  if (column.template === 'gantt') {
1419
1434
  style.padding = `0 ${padding}`;
1420
1435
  }
@@ -1429,12 +1444,9 @@ class AIOTableCell extends _react.Component {
1429
1444
  var className = 'aio-table-cell';
1430
1445
  let {
1431
1446
  striped
1432
- } = this.context;
1433
- let {
1434
- renderIndex
1435
1447
  } = this.props;
1436
1448
 
1437
- if (renderIndex % 2 === 0 && striped === true) {
1449
+ if (striped) {
1438
1450
  className += ' striped';
1439
1451
  }
1440
1452
 
@@ -1442,11 +1454,7 @@ class AIOTableCell extends _react.Component {
1442
1454
  className += ' aio-table-cell-selectable';
1443
1455
  }
1444
1456
 
1445
- if (column.template) {
1446
- className += ' aio-table-cell-template';
1447
- }
1448
-
1449
- if (column.template === 'gantt') {
1457
+ if (column.template && column.template.type === 'gantt') {
1450
1458
  className += ' aio-table-cell-gantt';
1451
1459
  }
1452
1460
 
@@ -1466,6 +1474,14 @@ class AIOTableCell extends _react.Component {
1466
1474
  className += ' aio-table-cell-hidden';
1467
1475
  }
1468
1476
 
1477
+ if (row._isFirstChild) {
1478
+ className += ' first-child';
1479
+ }
1480
+
1481
+ if (row._isLastChild) {
1482
+ className += ' last-child';
1483
+ }
1484
+
1469
1485
  return className;
1470
1486
  }
1471
1487
 
@@ -1477,27 +1493,21 @@ class AIOTableCell extends _react.Component {
1477
1493
  let icon;
1478
1494
 
1479
1495
  if (!row._childsLength) {
1480
- icon = /*#__PURE__*/_react.default.createElement(_react2.Icon, {
1481
- path: '',
1482
- size: 1
1483
- });
1496
+ icon = '';
1484
1497
  } else if (row._opened) {
1485
- icon = /*#__PURE__*/_react.default.createElement(_react2.Icon, {
1486
- path: _js.mdiChevronDown,
1487
- size: 1
1488
- });
1498
+ icon = aioTableGetSvg('chevronDown');
1489
1499
  } else {
1490
- icon = /*#__PURE__*/_react.default.createElement(_react2.Icon, {
1491
- path: _js.mdiChevronRight,
1492
- size: 1,
1493
- horizontal: rtl === true
1500
+ icon = aioTableGetSvg('chevronRight', {
1501
+ flip: rtl === true
1494
1502
  });
1495
1503
  }
1496
1504
 
1497
1505
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
1498
1506
  className: "aio-table-toggle",
1499
1507
  onClick: () => fn.toggleRow(row)
1500
- }, icon), this.context.getGap());
1508
+ }, icon), /*#__PURE__*/_react.default.createElement("div", {
1509
+ className: "aio-table-cell-gap"
1510
+ }));
1501
1511
  }
1502
1512
 
1503
1513
  getContent(row, column, value) {
@@ -1505,6 +1515,9 @@ class AIOTableCell extends _react.Component {
1505
1515
  focused,
1506
1516
  fn
1507
1517
  } = this.context;
1518
+ let {
1519
+ inlineEdit
1520
+ } = this.props;
1508
1521
  var content = '';
1509
1522
  let template = typeof column.template === 'function' ? column.template(row, column) : column.template;
1510
1523
 
@@ -1512,19 +1525,15 @@ class AIOTableCell extends _react.Component {
1512
1525
  content = fn.getSliderCell(template);
1513
1526
  } else if (template && template.type === 'options') {
1514
1527
  content = fn.getOptionsCell(template);
1515
- } else if (template === 'gantt') {
1516
- content = fn.getGanttCell(row, column);
1517
- } else if (template && this.inlineEdit) {
1518
- if (!focused) {
1519
- content = template;
1520
- } else {
1521
- content = this.getInput(row, column);
1522
- }
1528
+ } else if (template && template.type === 'gantt') {
1529
+ content = fn.getGanttCell(row, template);
1530
+ } else if (template && inlineEdit) {
1531
+ content = focused ? this.getInput(row, column) : template;
1523
1532
  } else if (template) {
1524
1533
  content = template;
1525
- } else if (this.inlineEdit) {
1534
+ } else if (inlineEdit) {
1526
1535
  content = this.getInput(row, column);
1527
- } else if (column.getValue) {
1536
+ } else {
1528
1537
  content = value;
1529
1538
  }
1530
1539
 
@@ -1549,21 +1558,52 @@ class AIOTableCell extends _react.Component {
1549
1558
  return content;
1550
1559
  }
1551
1560
 
1561
+ async changeCell(value) {
1562
+ let {
1563
+ row,
1564
+ column,
1565
+ inlineEdit
1566
+ } = this.props;
1567
+ let {
1568
+ setCellValue
1569
+ } = this.context;
1570
+ let res;
1571
+ this.setState({
1572
+ loading: true
1573
+ });
1574
+
1575
+ if (inlineEdit.onChange) {
1576
+ res = await inlineEdit.onChange(row, value);
1577
+ } else {
1578
+ res = await this.context.onChange(setCellValue(row, column.field, value));
1579
+ }
1580
+
1581
+ this.setState({
1582
+ loading: false
1583
+ });
1584
+ return res;
1585
+ }
1586
+
1552
1587
  getInput(row, column) {
1553
1588
  let {
1554
- type,
1555
- getValue,
1556
- disabled = () => false
1557
- } = this.inlineEdit;
1589
+ getCellValue
1590
+ } = this.context;
1558
1591
  let {
1559
- renderIndex
1592
+ attrs,
1593
+ inlineEdit
1560
1594
  } = this.props;
1595
+ let {
1596
+ type,
1597
+ getValue,
1598
+ disabled = () => false,
1599
+ options
1600
+ } = inlineEdit;
1561
1601
  let {
1562
1602
  value
1563
1603
  } = this.state;
1564
1604
 
1565
1605
  if (getValue) {
1566
- value = getValue(row);
1606
+ value = getCellValue(row, getValue, column.field);
1567
1607
  }
1568
1608
 
1569
1609
  if (disabled(row)) {
@@ -1574,10 +1614,10 @@ class AIOTableCell extends _react.Component {
1574
1614
  return value;
1575
1615
  }
1576
1616
 
1577
- let props = { ...this.inlineEdit,
1617
+ let props = { ...inlineEdit,
1578
1618
  className: 'aio-table-input',
1579
- rowindex: renderIndex,
1580
- colindex: column._renderIndex,
1619
+ 'data-row-index': attrs['data-row-index'],
1620
+ 'data-col-index': attrs['data-col-index'],
1581
1621
  value: value === null || value === undefined ? '' : value
1582
1622
  };
1583
1623
 
@@ -1592,23 +1632,31 @@ class AIOTableCell extends _react.Component {
1592
1632
  value: e.target.value
1593
1633
  }),
1594
1634
  onBlur: async e => {
1635
+ let {
1636
+ value
1637
+ } = this.state;
1638
+
1595
1639
  if (value === this.props.value) {
1596
1640
  return;
1597
1641
  }
1598
1642
 
1599
- this.setState({
1600
- loading: true
1601
- });
1602
- let res = await this.inlineEdit.onChange(row, type === 'number' ? parseFloat(value) : value);
1603
- this.setState({
1604
- loading: false
1605
- });
1643
+ let newValue = value;
1644
+
1645
+ if (type === 'number') {
1646
+ newValue = parseFloat(newValue);
1647
+
1648
+ if (isNaN(newValue)) {
1649
+ newValue = 0;
1650
+ }
1651
+ }
1652
+
1653
+ let res = await this.changeCell(newValue);
1606
1654
 
1607
1655
  if (typeof res === 'string') {
1608
1656
  this.setState({
1609
1657
  error: res
1610
1658
  });
1611
- } else if (res === false) {
1659
+ } else {
1612
1660
  this.setState({
1613
1661
  value: this.props.value
1614
1662
  });
@@ -1620,12 +1668,12 @@ class AIOTableCell extends _react.Component {
1620
1668
  }
1621
1669
 
1622
1670
  if (type === 'select') {
1623
- if (!this.inlineEdit.options) {
1671
+ if (!options) {
1624
1672
  console.error('aio table => missing options property of column inlineEdit with type="select"');
1625
1673
  return '';
1626
1674
  }
1627
1675
 
1628
- if (!Array.isArray(this.inlineEdit.options)) {
1676
+ if (!Array.isArray(options)) {
1629
1677
  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!!!');
1630
1678
  return '';
1631
1679
  }
@@ -1647,13 +1695,9 @@ class AIOTableCell extends _react.Component {
1647
1695
  }
1648
1696
 
1649
1697
  this.setState({
1650
- loading: true,
1651
1698
  value
1652
1699
  });
1653
- let res = await this.inlineEdit.onChange(row, value);
1654
- this.setState({
1655
- loading: false
1656
- });
1700
+ let res = await this.changeCell(value);
1657
1701
 
1658
1702
  if (typeof res === 'string') {
1659
1703
  this.setState({
@@ -1665,7 +1709,7 @@ class AIOTableCell extends _react.Component {
1665
1709
  });
1666
1710
  }
1667
1711
  }
1668
- }), this.inlineEdit.options.map((o, i) => /*#__PURE__*/_react.default.createElement("option", {
1712
+ }), options.map((o, i) => /*#__PURE__*/_react.default.createElement("option", {
1669
1713
  key: i,
1670
1714
  value: o.value
1671
1715
  }, o.text))), /*#__PURE__*/_react.default.createElement("div", {
@@ -1673,34 +1717,75 @@ class AIOTableCell extends _react.Component {
1673
1717
  }));
1674
1718
  }
1675
1719
 
1720
+ if (type === 'checkbox') {
1721
+ return /*#__PURE__*/_react.default.createElement("div", {
1722
+ className: 'aio-table-input-container',
1723
+ tabIndex: 0,
1724
+ onKeyDown: async e => {
1725
+ if (e.keyCode === 13) {
1726
+ value = value === true ? true : false;
1727
+ await this.changeCell(!value);
1728
+ }
1729
+ }
1730
+ }, /*#__PURE__*/_react.default.createElement("input", _extends({}, props, {
1731
+ onFocus: () => this.focus = true,
1732
+ onBlur: () => this.focus = false,
1733
+ checked: value === true ? true : false,
1734
+ onChange: async e => {
1735
+ let value = e.target.checked;
1736
+ this.setState({
1737
+ loading: true
1738
+ });
1739
+ await this.changeCell(value);
1740
+ this.setState({
1741
+ loading: false
1742
+ });
1743
+ }
1744
+ })), /*#__PURE__*/_react.default.createElement("div", {
1745
+ className: "aio-table-input-border"
1746
+ }));
1747
+ }
1748
+
1676
1749
  console.error('aio table => missing type property of column input');
1677
1750
  return '';
1678
1751
  }
1679
1752
 
1680
1753
  componentDidUpdate() {
1681
- if (this.inlineEdit && this.inlineEdit.type === 'select' && this.focus) {
1682
- (0, _jquery.default)(this.dom.current).find('.aio-table-input').focus();
1754
+ let {
1755
+ inlineEdit
1756
+ } = this.props;
1757
+
1758
+ if (inlineEdit && this.focus) {
1759
+ if (inlineEdit.type === 'select' || inlineEdit.type === 'checkbox') {
1760
+ (0, _jquery.default)(this.dom.current).find('.aio-table-input').focus();
1761
+ }
1683
1762
  }
1684
1763
  }
1685
1764
 
1765
+ getProps(row, column, content) {
1766
+ let title = column.getTooltip ? column.getTooltip(row) : typeof content === 'string' ? content : undefined;
1767
+ return {
1768
+ ref: this.dom,
1769
+ title,
1770
+ style: this.getStyle(column, row),
1771
+ className: this.getClassName(row, column)
1772
+ };
1773
+ }
1774
+
1686
1775
  render() {
1687
1776
  let {
1688
1777
  indent,
1689
- fn,
1690
- focused,
1691
- SetState,
1692
- onDrag,
1693
- onDrop,
1694
- onSwap
1778
+ fn
1695
1779
  } = this.context;
1696
1780
  let {
1697
1781
  row,
1698
1782
  column,
1699
1783
  value,
1700
- cellId,
1701
- renderIndex
1784
+ before,
1785
+ after,
1786
+ justify,
1787
+ attrs
1702
1788
  } = this.props;
1703
- this.inlineEdit = typeof column.inlineEdit === 'function' ? column.inlineEdit(row, column) : column.inlineEdit;
1704
1789
 
1705
1790
  if (this.state.prevValue !== value) {
1706
1791
  setTimeout(() => this.setState({
@@ -1714,9 +1799,6 @@ class AIOTableCell extends _react.Component {
1714
1799
  loading
1715
1800
  } = this.state;
1716
1801
  let content = this.getContent(row, column, value);
1717
- let before = this.getBefore(row, column);
1718
- let after = this.getAfter(row, column);
1719
- let showToggleIcon = column.treeMode;
1720
1802
  let cell;
1721
1803
 
1722
1804
  if (loading) {
@@ -1734,51 +1816,30 @@ class AIOTableCell extends _react.Component {
1734
1816
  }
1735
1817
  }, error);
1736
1818
  } else {
1737
- let style = {
1738
- justifyContent: column.justify !== false && !column.treeMode ? 'center' : undefined
1739
- };
1740
1819
  cell = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, column.treeMode && /*#__PURE__*/_react.default.createElement("div", {
1741
- className: "aio-table-indent",
1742
1820
  style: {
1743
- width: row._level * indent
1821
+ width: row._level * indent,
1822
+ flexShrink: 0
1823
+ }
1824
+ }), column.treeMode && this.getToggleIcon(row), before !== undefined && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
1825
+ className: "aio-table-icon"
1826
+ }, before), /*#__PURE__*/_react.default.createElement("div", {
1827
+ className: "aio-table-cell-gap"
1828
+ })), content !== undefined && /*#__PURE__*/_react.default.createElement("div", {
1829
+ className: "aio-table-cell-content",
1830
+ style: {
1831
+ justifyContent: justify ? 'center' : undefined
1744
1832
  }
1745
- }), showToggleIcon && this.getToggleIcon(row), before, /*#__PURE__*/_react.default.createElement("div", {
1746
- className: "aio-table-content",
1747
- style: style
1748
- }, content), after);
1833
+ }, content), after !== undefined && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
1834
+ style: {
1835
+ flex: 1
1836
+ }
1837
+ }), /*#__PURE__*/_react.default.createElement("div", {
1838
+ className: "aio-table-icon"
1839
+ }, after)));
1749
1840
  }
1750
1841
 
1751
- return /*#__PURE__*/_react.default.createElement("div", {
1752
- key: cellId,
1753
- tabIndex: 0,
1754
- ref: this.dom,
1755
- cellid: cellId,
1756
- title: typeof content === 'string' ? content : '',
1757
- "data-evenodd": row._index % 2 === 0 ? 'even' : 'odd',
1758
- rowindex: renderIndex,
1759
- colindex: column._renderIndex,
1760
- childindex: row._childIndex,
1761
- level: row._level,
1762
- isfirstchild: row._isFirstChild ? 1 : 0,
1763
- islastchild: row._isLastChild ? 1 : 0,
1764
- childslength: row._childsLength,
1765
- style: this.getStyle(column, row),
1766
- className: this.getClassName(row, column),
1767
- draggable: typeof onSwap === 'function' && column.swap,
1768
- onDragOver: e => e.preventDefault(),
1769
- onDragStart: () => onDrag(row),
1770
- onDrop: () => onDrop(row),
1771
- onClick: e => {
1772
- if (this.inlineEdit) {
1773
- if (focused !== cellId) {
1774
- SetState({
1775
- focused: cellId
1776
- });
1777
- setTimeout(() => (0, _jquery.default)('.aio-table-input:focus').select(), 10);
1778
- }
1779
- }
1780
- }
1781
- }, cell);
1842
+ return /*#__PURE__*/_react.default.createElement("div", _extends({}, attrs, this.getProps(row, column, content)), cell);
1782
1843
  }
1783
1844
 
1784
1845
  }
@@ -1833,14 +1894,9 @@ class AIOTableFilter extends _react.Component {
1833
1894
  let {
1834
1895
  type
1835
1896
  } = column.filter;
1836
- let icon = items.length ? /*#__PURE__*/_react.default.createElement(_react2.Icon, {
1837
- className: "has-filter",
1838
- path: _js.mdiFilterMenu,
1839
- size: 0.7
1840
- }) : /*#__PURE__*/_react.default.createElement(_react2.Icon, {
1841
- path: _js.mdiFilter,
1842
- size: 0.7
1843
- });
1897
+ let icon = items.length ? aioTableGetSvg('filterActive', {
1898
+ className: 'has-filter'
1899
+ }) : aioTableGetSvg('filter');
1844
1900
  return /*#__PURE__*/_react.default.createElement("div", {
1845
1901
  className: "aio-table-filter-icon"
1846
1902
  }, /*#__PURE__*/_react.default.createElement(_aioButton.default, {
@@ -2024,10 +2080,7 @@ class AIOTableFilterItem extends _react.Component {
2024
2080
  }), /*#__PURE__*/_react.default.createElement("div", {
2025
2081
  className: "aio-table-filter-remove",
2026
2082
  onClick: () => onRemove()
2027
- }, /*#__PURE__*/_react.default.createElement(_react2.Icon, {
2028
- path: _js.mdiClose,
2029
- size: 0.7
2030
- })));
2083
+ }, aioTableGetSvg('close')));
2031
2084
  }
2032
2085
 
2033
2086
  }
@@ -2083,7 +2136,7 @@ function ATFN({
2083
2136
  } = getProps();
2084
2137
  let name = window.prompt(translate('Inter Excel File Name')); // if (name === false || name === undefined || name === null) { return; }
2085
2138
 
2086
- if (!name.length) return;
2139
+ if (!name || name === null || !name.length) return;
2087
2140
  var data = $$.getJSON(columns, rows);
2088
2141
  var arrData = typeof data != "object" ? JSON.parse(data) : data;
2089
2142
  var CSV = ""; // CSV += 'title';
@@ -2137,7 +2190,8 @@ function ATFN({
2137
2190
  editValue = value => value
2138
2191
  }) {
2139
2192
  let {
2140
- rowHeight
2193
+ rowHeight,
2194
+ rtl
2141
2195
  } = getProps();
2142
2196
  let [clr1 = '#eee', clr2 = 'dodgerblue'] = colors;
2143
2197
  let points = Array.isArray(value) ? value : [value];
@@ -2158,6 +2212,7 @@ function ATFN({
2158
2212
  style: {
2159
2213
  height: rowHeight
2160
2214
  },
2215
+ direction: rtl ? 'left' : 'right',
2161
2216
  start: start,
2162
2217
  end: end,
2163
2218
  step: 0.1,
@@ -2199,10 +2254,7 @@ function ATFN({
2199
2254
  type: "select",
2200
2255
  caret: false,
2201
2256
  className: "aio-table-options",
2202
- text: /*#__PURE__*/_react.default.createElement(_react2.Icon, {
2203
- path: _js.mdiDotsHorizontal,
2204
- size: 0.7
2205
- }),
2257
+ text: aioTableGetSvg('dots'),
2206
2258
  options: options.map(({
2207
2259
  text,
2208
2260
  icon,
@@ -2221,7 +2273,7 @@ function ATFN({
2221
2273
  });
2222
2274
  },
2223
2275
 
2224
- getGanttCell(row, column) {
2276
+ getGanttCell(row, template) {
2225
2277
  let {
2226
2278
  rtl
2227
2279
  } = getProps();
@@ -2234,7 +2286,7 @@ function ATFN({
2234
2286
  getText = () => false,
2235
2287
  getStart,
2236
2288
  getEnd
2237
- } = column;
2289
+ } = template;
2238
2290
 
2239
2291
  if (typeof getStart !== 'function') {
2240
2292
  console.error('aio table => gantt column => column getStart property is not a function');
@@ -2367,7 +2419,56 @@ function ATFN({
2367
2419
  return result;
2368
2420
  },
2369
2421
 
2370
- onScroll(dom, index) {
2422
+ async onScroll(dom, index) {
2423
+ let {
2424
+ onScrollEnd
2425
+ } = getProps();
2426
+
2427
+ if (onScrollEnd) {
2428
+ if (index === undefined || index === 0) {
2429
+ let table = (0, _jquery.default)(dom.current).find('.aio-table-unit');
2430
+ let scrollTop = table.scrollTop();
2431
+ let scrollHeight = table[0].scrollHeight;
2432
+ let height = table.height();
2433
+
2434
+ if (scrollTop + height === scrollHeight) {
2435
+ let {
2436
+ startIndex
2437
+ } = getState();
2438
+ let {
2439
+ scrollLoadLength,
2440
+ scrollTotalLength
2441
+ } = getProps();
2442
+ let from = startIndex + scrollLoadLength;
2443
+
2444
+ if (from > scrollTotalLength) {
2445
+ return;
2446
+ }
2447
+
2448
+ let to = from + scrollLoadLength;
2449
+
2450
+ if (to > scrollTotalLength) {
2451
+ to = scrollTotalLength;
2452
+ }
2453
+
2454
+ let a = (0, _jquery.default)(dom.current).find('.aio-table-main-loading');
2455
+ a.css({
2456
+ display: 'flex'
2457
+ });
2458
+ let res = await onScrollEnd(from, to);
2459
+ a.css({
2460
+ display: 'none'
2461
+ });
2462
+
2463
+ if (res !== false) {
2464
+ setState({
2465
+ startIndex: from
2466
+ });
2467
+ }
2468
+ }
2469
+ }
2470
+ }
2471
+
2371
2472
  if (index === undefined) {
2372
2473
  return;
2373
2474
  }
@@ -2442,19 +2543,91 @@ function ATFN({
2442
2543
  onChangeSort
2443
2544
  } = getProps();
2444
2545
  let {
2445
- sorts
2546
+ sorts,
2547
+ columns = [],
2548
+ getCellValue
2446
2549
  } = getState();
2550
+ let sortTitles = sorts.map(o => o.title);
2551
+
2552
+ for (let i = 0; i < columns.length; i++) {
2553
+ if (!columns[i].sort) {
2554
+ continue;
2555
+ }
2556
+
2557
+ if (sortTitles.indexOf(columns[i].title) !== -1) {
2558
+ continue;
2559
+ }
2560
+
2561
+ columns[i]._addedToSorts = true;
2562
+ let column = columns[i];
2563
+
2564
+ if (column.sort === true) {
2565
+ column.sort = {};
2566
+ }
2567
+
2568
+ let {
2569
+ sort
2570
+ } = columns[i];
2571
+ let a = sort.title || column.title || '';
2572
+ let title = typeof a === 'function' ? a() : a;
2573
+ let getValue = sort.getValue || column.getValue;
2574
+ let field = sort.field || column.field;
2575
+ let {
2576
+ toggle = true,
2577
+ dir = 'inc',
2578
+ active = true,
2579
+ type
2580
+ } = sort;
2581
+ sorts.push({
2582
+ title,
2583
+ dir,
2584
+ active,
2585
+ toggle,
2586
+ getValue,
2587
+ type,
2588
+ field
2589
+ });
2590
+ }
2591
+
2592
+ let Sorts = sorts.map(o => {
2593
+ return { ...o,
2594
+ onChangeDir: () => {
2595
+ o.dir = o.dir === 'dec' ? 'inc' : 'dec';
2596
+ setState({
2597
+ sorts
2598
+ });
2599
+
2600
+ if (onChangeSort) {
2601
+ onChangeSort(Sorts.filter(o => o.active !== false));
2602
+ }
2603
+ },
2604
+ onChangeActive: () => {
2605
+ o.active = o.active === undefined ? true : o.active;
2606
+ o.active = !o.active;
2607
+ setState({
2608
+ sorts
2609
+ });
2610
+
2611
+ if (onChangeSort) {
2612
+ onChangeSort(Sorts.filter(o => o.active !== false));
2613
+ }
2614
+ }
2615
+ };
2616
+ });
2447
2617
  let result = [];
2448
2618
 
2449
- for (let i = 0; i < sorts.length; i++) {
2450
- let sort = sorts[i];
2619
+ for (let i = 0; i < Sorts.length; i++) {
2620
+ let sort = Sorts[i];
2451
2621
  let {
2452
2622
  getValue,
2453
- type = 'inc',
2623
+ dir = 'inc',
2454
2624
  title,
2455
2625
  active = true,
2456
2626
  toggle = true,
2457
- isDate
2627
+ type,
2628
+ onChangeDir,
2629
+ onChangeActive,
2630
+ field
2458
2631
  } = sort;
2459
2632
 
2460
2633
  if (!title) {
@@ -2462,15 +2635,10 @@ function ATFN({
2462
2635
  continue;
2463
2636
  }
2464
2637
 
2465
- if (typeof getValue !== 'function') {
2466
- console.error('aio table => sort getValue property is not a function');
2467
- continue;
2468
- }
2469
-
2470
2638
  if (active === true) {
2471
- if (isDate) {
2639
+ if (type === 'date') {
2472
2640
  let newGetValue = row => {
2473
- let value = getValue(row);
2641
+ let value = getCellValue(row, getValue, field);
2474
2642
 
2475
2643
  if (typeof value !== 'string') {
2476
2644
  return 0;
@@ -2481,12 +2649,12 @@ function ATFN({
2481
2649
 
2482
2650
  result.push({
2483
2651
  getValue: row => newGetValue(row),
2484
- type
2652
+ dir
2485
2653
  });
2486
2654
  } else {
2487
2655
  result.push({
2488
2656
  getValue,
2489
- type
2657
+ dir
2490
2658
  });
2491
2659
  }
2492
2660
  }
@@ -2502,31 +2670,13 @@ function ATFN({
2502
2670
  display: 'flex',
2503
2671
  justifyContent: 'flex-end'
2504
2672
  }
2505
- }, /*#__PURE__*/_react.default.createElement(_react2.Icon, {
2506
- path: type === 'dec' ? _js.mdiArrowDown : _js.mdiArrowUp,
2507
- size: 0.8,
2673
+ }, aioTableGetSvg(dir === 'dec' ? 'arrowDown' : 'arrowUp', {
2508
2674
  onClick: e => {
2509
2675
  e.stopPropagation();
2510
- sort.type = sort.type === 'dec' ? 'inc' : 'dec';
2511
- setState({
2512
- sorts
2513
- });
2514
-
2515
- if (onChangeSort) {
2516
- onChangeSort(sorts.filter(o => o.active !== false));
2517
- }
2676
+ onChangeDir();
2518
2677
  }
2519
2678
  })),
2520
- onClick: () => {
2521
- sort.active = !active;
2522
- setState({
2523
- sorts
2524
- });
2525
-
2526
- if (onChangeSort) {
2527
- onChangeSort(sorts.filter(o => o.active !== false));
2528
- }
2529
- }
2679
+ onClick: () => onChangeActive()
2530
2680
  });
2531
2681
  }
2532
2682
  }
@@ -2549,8 +2699,7 @@ function ATFN({
2549
2699
  let {
2550
2700
  title,
2551
2701
  active = true,
2552
- toggle = true,
2553
- getValue
2702
+ toggle = true
2554
2703
  } = group;
2555
2704
 
2556
2705
  if (!title) {
@@ -2558,11 +2707,6 @@ function ATFN({
2558
2707
  continue;
2559
2708
  }
2560
2709
 
2561
- if (typeof getValue !== 'function') {
2562
- console.error('aio table => group getValue property is not a function');
2563
- continue;
2564
- }
2565
-
2566
2710
  groupDictionary[title] = groupDictionary[title] === undefined ? active : groupDictionary[title];
2567
2711
 
2568
2712
  if (groupDictionary[title]) {
@@ -2664,10 +2808,10 @@ function ATFN({
2664
2808
  } = getState();
2665
2809
  let column = columns[index];
2666
2810
  let {
2667
- title,
2668
2811
  show,
2669
2812
  storageKey
2670
2813
  } = column;
2814
+ let title = typeof column.title === 'function' ? column.title() : column.title;
2671
2815
  toolbar.show = true;
2672
2816
  toolbar.toggle.push({
2673
2817
  text: title,
@@ -2927,7 +3071,18 @@ function ATFN({
2927
3071
  }, items);
2928
3072
  },
2929
3073
 
2930
- getLoading() {
3074
+ getLoading(isMain) {
3075
+ if (isMain) {
3076
+ return /*#__PURE__*/_react.default.createElement("div", {
3077
+ className: "aio-table-loading aio-table-main-loading",
3078
+ style: {
3079
+ display: 'none'
3080
+ }
3081
+ }, $$.cubes2({
3082
+ thickness: [6, 40]
3083
+ }));
3084
+ }
3085
+
2931
3086
  return /*#__PURE__*/_react.default.createElement("div", {
2932
3087
  className: "aio-table-loading"
2933
3088
  }, $$.cubes2({
@@ -2994,7 +3149,8 @@ function ATFN({
2994
3149
  } = getProps();
2995
3150
  let {
2996
3151
  filterDictionary,
2997
- searchText
3152
+ searchText,
3153
+ getCellValue
2998
3154
  } = getState();
2999
3155
  row._values = {};
3000
3156
  let show = true,
@@ -3006,14 +3162,7 @@ function ATFN({
3006
3162
 
3007
3163
  for (let i = 0; i < columns.length; i++) {
3008
3164
  let column = columns[i],
3009
- value;
3010
-
3011
- try {
3012
- value = typeof column.getValue === 'function' ? column.getValue(row) : undefined;
3013
- } catch {
3014
- value = undefined;
3015
- }
3016
-
3165
+ value = getCellValue(row, column.getValue, column.field);
3017
3166
  row._values[column._index] = value;
3018
3167
  filterDictionary[column._index] = filterDictionary[column._index] || {
3019
3168
  items: [],
@@ -3021,7 +3170,15 @@ function ATFN({
3021
3170
  };
3022
3171
 
3023
3172
  if (show && search) {
3024
- show = search(row, searchText);
3173
+ if (searchText === '') {
3174
+ show = true;
3175
+ } else {
3176
+ try {
3177
+ show = search(row, searchText);
3178
+ } catch {
3179
+ show = false;
3180
+ }
3181
+ }
3025
3182
  }
3026
3183
 
3027
3184
  if (show && !onChangeFilter) {
@@ -3268,6 +3425,10 @@ function ATFN({
3268
3425
  },
3269
3426
 
3270
3427
  getRowsBySort(rows, sorts) {
3428
+ let {
3429
+ getCellValue
3430
+ } = getState();
3431
+
3271
3432
  if (!sorts.length) {
3272
3433
  return rows;
3273
3434
  }
@@ -3280,17 +3441,18 @@ function ATFN({
3280
3441
  for (let i = 0; i < sorts.length; i++) {
3281
3442
  let {
3282
3443
  getValue,
3283
- type
3444
+ dir,
3445
+ field
3284
3446
  } = sorts[i];
3285
- let aValue = getValue(a),
3286
- bValue = getValue(b);
3447
+ let aValue = getCellValue(a, getValue, field),
3448
+ bValue = getCellValue(b, getValue, field);
3287
3449
 
3288
3450
  if (aValue < bValue) {
3289
- return -1 * (type === 'dec' ? -1 : 1);
3451
+ return -1 * (dir === 'dec' ? -1 : 1);
3290
3452
  }
3291
3453
 
3292
3454
  if (aValue > bValue) {
3293
- return 1 * (type === 'dec' ? -1 : 1);
3455
+ return 1 * (dir === 'dec' ? -1 : 1);
3294
3456
  }
3295
3457
 
3296
3458
  if (i !== sorts.length - 1) {
@@ -3370,7 +3532,8 @@ function ATFN({
3370
3532
  }
3371
3533
 
3372
3534
  var {
3373
- groupsOpen
3535
+ groupsOpen,
3536
+ getCellValue
3374
3537
  } = getState();
3375
3538
 
3376
3539
  function msf(obj, _level, parents) {
@@ -3402,7 +3565,7 @@ function ATFN({
3402
3565
  for (let i = 0; i < roots.length; i++) {
3403
3566
  let root = roots[i];
3404
3567
  var obj = newModel;
3405
- let values = groups.map(group => group.getValue(root[0].row));
3568
+ let values = groups.map(group => getCellValue(root[0].row, group.getValue, group.field));
3406
3569
 
3407
3570
  for (let j = 0; j < values.length; j++) {
3408
3571
  let value = values[j];
@@ -3497,4 +3660,159 @@ function ATFN({
3497
3660
  getFullCellStyle: $$.getFullCellStyle,
3498
3661
  getNoData: $$.getNoData
3499
3662
  };
3663
+ }
3664
+
3665
+ function aioTableGetSvg(type, conf = {}) {
3666
+ let {
3667
+ className,
3668
+ flip,
3669
+ onClick,
3670
+ box = '0 0 24 24'
3671
+ } = conf;
3672
+ let style1 = {
3673
+ width: '1.05rem',
3674
+ height: '1.05rem'
3675
+ };
3676
+ style1.background = '';
3677
+
3678
+ if (flip) {
3679
+ style1.transform = 'scaleX(-1)';
3680
+ style1.transformOrigin = 'center center';
3681
+ }
3682
+
3683
+ let style2 = {
3684
+ fill: 'currentcolor'
3685
+ };
3686
+ let Attrs = {
3687
+ viewBox: box,
3688
+ role: "presentation",
3689
+ style: style1
3690
+ };
3691
+
3692
+ if (className) {
3693
+ Attrs.className = className;
3694
+ }
3695
+
3696
+ if (onClick) {
3697
+ Attrs.onClick = onClick;
3698
+ }
3699
+
3700
+ if (type === 'eye') {
3701
+ return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3702
+ d: "M12,9A3,3 0 0,0 9,12A3,3 0 0,0 12,15A3,3 0 0,0 15,12A3,3 0 0,0 12,9M12,17A5,5 0 0,1 7,12A5,5 0 0,1 12,7A5,5 0 0,1 17,12A5,5 0 0,1 12,17M12,4.5C7,4.5 2.73,7.61 1,12C2.73,16.39 7,19.5 12,19.5C17,19.5 21.27,16.39 23,12C21.27,7.61 17,4.5 12,4.5Z",
3703
+ style: style2
3704
+ }));
3705
+ }
3706
+
3707
+ if (type === 'magnify') {
3708
+ return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3709
+ d: "M9.5,3A6.5,6.5 0 0,1 16,9.5C16,11.11 15.41,12.59 14.44,13.73L14.71,14H15.5L20.5,19L19,20.5L14,15.5V14.71L13.73,14.44C12.59,15.41 11.11,16 9.5,16A6.5,6.5 0 0,1 3,9.5A6.5,6.5 0 0,1 9.5,3M9.5,5C7,5 5,7 5,9.5C5,12 7,14 9.5,14C12,14 14,12 14,9.5C14,7 12,5 9.5,5Z",
3710
+ style: style2
3711
+ }));
3712
+ }
3713
+
3714
+ if (type === 'close') {
3715
+ return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3716
+ d: "M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z",
3717
+ style: style2
3718
+ }));
3719
+ }
3720
+
3721
+ if (type === 'toggleAllPlus') {
3722
+ return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3723
+ d: "M18,8H8V18H6V8A2,2 0 0,1 8,6H18V8M14,2H4A2,2 0 0,0 2,4V14H4V4H14V2M22,12V20A2,2 0 0,1 20,22H12A2,2 0 0,1 10,20V12A2,2 0 0,1 12,10H20A2,2 0 0,1 22,12M20,15H17V12H15V15H12V17H15V20H17V17H20V15Z",
3724
+ style: style2
3725
+ }));
3726
+ }
3727
+
3728
+ if (type === 'toggleAllMinus') {
3729
+ return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3730
+ d: "M14,4H4V14H2V4A2,2 0 0,1 4,2H14V4M18,6H8A2,2 0 0,0 6,8V18H8V8H18V6M22,12V20A2,2 0 0,1 20,22H12A2,2 0 0,1 10,20V12A2,2 0 0,1 12,10H20A2,2 0 0,1 22,12M20,15H12V17H20V15Z",
3731
+ style: style2
3732
+ }));
3733
+ }
3734
+
3735
+ if (type === 'excel') {
3736
+ return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3737
+ d: "M21.17 3.25Q21.5 3.25 21.76 3.5 22 3.74 22 4.08V19.92Q22 20.26 21.76 20.5 21.5 20.75 21.17 20.75H7.83Q7.5 20.75 7.24 20.5 7 20.26 7 19.92V17H2.83Q2.5 17 2.24 16.76 2 16.5 2 16.17V7.83Q2 7.5 2.24 7.24 2.5 7 2.83 7H7V4.08Q7 3.74 7.24 3.5 7.5 3.25 7.83 3.25M7 13.06L8.18 15.28H9.97L8 12.06L9.93 8.89H8.22L7.13 10.9L7.09 10.96L7.06 11.03Q6.8 10.5 6.5 9.96 6.25 9.43 5.97 8.89H4.16L6.05 12.08L4 15.28H5.78M13.88 19.5V17H8.25V19.5M13.88 15.75V12.63H12V15.75M13.88 11.38V8.25H12V11.38M13.88 7V4.5H8.25V7M20.75 19.5V17H15.13V19.5M20.75 15.75V12.63H15.13V15.75M20.75 11.38V8.25H15.13V11.38M20.75 7V4.5H15.13V7Z",
3738
+ style: style2
3739
+ }));
3740
+ }
3741
+
3742
+ if (type === 'sort') {
3743
+ return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3744
+ d: "M18 21L14 17H17V7H14L18 3L22 7H19V17H22M2 19V17H12V19M2 13V11H9V13M2 7V5H6V7H2Z",
3745
+ style: style2
3746
+ }));
3747
+ }
3748
+
3749
+ if (type === 'group') {
3750
+ return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3751
+ d: "M3,3H9V7H3V3M15,10H21V14H15V10M15,17H21V21H15V17M13,13H7V18H13V20H7L5,20V9H7V11H13V13Z",
3752
+ style: style2
3753
+ }));
3754
+ }
3755
+
3756
+ if (type === 'freeze') {
3757
+ return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3758
+ d: "M4 22H2V2H4V22M22 7H6V10H22V7M16 14H6V17H16V14Z",
3759
+ style: style2
3760
+ }));
3761
+ }
3762
+
3763
+ if (type === 'filter') {
3764
+ return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3765
+ d: "M14,12V19.88C14.04,20.18 13.94,20.5 13.71,20.71C13.32,21.1 12.69,21.1 12.3,20.71L10.29,18.7C10.06,18.47 9.96,18.16 10,17.87V12H9.97L4.21,4.62C3.87,4.19 3.95,3.56 4.38,3.22C4.57,3.08 4.78,3 5,3V3H19V3C19.22,3 19.43,3.08 19.62,3.22C20.05,3.56 20.13,4.19 19.79,4.62L14.03,12H14Z",
3766
+ style: style2
3767
+ }));
3768
+ }
3769
+
3770
+ if (type === 'filterActive') {
3771
+ return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3772
+ d: "M11 11L16.76 3.62A1 1 0 0 0 16.59 2.22A1 1 0 0 0 16 2H2A1 1 0 0 0 1.38 2.22A1 1 0 0 0 1.21 3.62L7 11V16.87A1 1 0 0 0 7.29 17.7L9.29 19.7A1 1 0 0 0 10.7 19.7A1 1 0 0 0 11 18.87V11M13 16L18 21L23 16Z",
3773
+ style: style2
3774
+ }));
3775
+ }
3776
+
3777
+ if (type === 'dots') {
3778
+ return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3779
+ d: "M16,12A2,2 0 0,1 18,10A2,2 0 0,1 20,12A2,2 0 0,1 18,14A2,2 0 0,1 16,12M10,12A2,2 0 0,1 12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12M4,12A2,2 0 0,1 6,10A2,2 0 0,1 8,12A2,2 0 0,1 6,14A2,2 0 0,1 4,12Z",
3780
+ style: style2
3781
+ }));
3782
+ }
3783
+
3784
+ if (type === 'chevronDown') {
3785
+ return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3786
+ d: "M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z",
3787
+ style: style2
3788
+ }));
3789
+ }
3790
+
3791
+ if (type === 'chevronRight') {
3792
+ return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3793
+ d: "M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z",
3794
+ style: style2
3795
+ }));
3796
+ }
3797
+
3798
+ if (type === 'doubleChevronRight') {
3799
+ return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3800
+ d: "M5.59,7.41L7,6L13,12L7,18L5.59,16.59L10.17,12L5.59,7.41M11.59,7.41L13,6L19,12L13,18L11.59,16.59L16.17,12L11.59,7.41Z",
3801
+ style: style2
3802
+ }));
3803
+ }
3804
+
3805
+ if (type === 'arrowUp') {
3806
+ return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3807
+ d: "M13,20H11V8L5.5,13.5L4.08,12.08L12,4.16L19.92,12.08L18.5,13.5L13,8V20Z",
3808
+ style: style2
3809
+ }));
3810
+ }
3811
+
3812
+ if (type === 'arrowDown') {
3813
+ return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3814
+ d: "M11,4H13V16L18.5,10.5L19.92,11.92L12,19.84L4.08,11.92L5.5,10.5L11,16V4Z",
3815
+ style: style2
3816
+ }));
3817
+ }
3500
3818
  }