aio-table 2.0.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +792 -1
  2. package/index.css +178 -103
  3. package/index.js +1613 -741
  4. package/package.json +2 -1
package/index.js CHANGED
@@ -11,17 +11,17 @@ exports.default = void 0;
11
11
 
12
12
  var _react = _interopRequireWildcard(require("react"));
13
13
 
14
- var _rDropdownButton = _interopRequireDefault(require("r-dropdown-button"));
14
+ var _aioButton = _interopRequireDefault(require("aio-button"));
15
15
 
16
16
  var _react2 = require("@mdi/react");
17
17
 
18
18
  var _js = require("@mdi/js");
19
19
 
20
- var _rRangeSlider = _interopRequireDefault(require("r-range-slider"));
20
+ var _jquery = _interopRequireDefault(require("jquery"));
21
21
 
22
- require("./index.css");
22
+ var _rRangeSlider = _interopRequireDefault(require("./r-range-slider"));
23
23
 
24
- var _jquery = _interopRequireDefault(require("jquery"));
24
+ require("./index.css");
25
25
 
26
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
27
 
@@ -29,10 +29,10 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
29
29
 
30
30
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
31
31
 
32
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
33
-
34
32
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
35
33
 
34
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
35
+
36
36
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
37
37
 
38
38
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -57,7 +57,7 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
57
57
 
58
58
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
59
59
 
60
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
60
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
61
61
 
62
62
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
63
63
 
@@ -65,61 +65,111 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
65
65
 
66
66
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
67
67
 
68
- var RTableContext = /*#__PURE__*/(0, _react.createContext)();
68
+ var AioTableContext = /*#__PURE__*/(0, _react.createContext)();
69
69
 
70
- var RTable = /*#__PURE__*/function (_Component) {
71
- _inherits(RTable, _Component);
70
+ var AIOTable = /*#__PURE__*/function (_Component) {
71
+ _inherits(AIOTable, _Component);
72
72
 
73
- var _super = _createSuper(RTable);
73
+ var _super = _createSuper(AIOTable);
74
74
 
75
- function RTable(props) {
75
+ function AIOTable(props) {
76
76
  var _this;
77
77
 
78
- _classCallCheck(this, RTable);
78
+ _classCallCheck(this, AIOTable);
79
79
 
80
80
  _this = _super.call(this, props);
81
81
  _this.touch = false;
82
82
  _this.dom = /*#__PURE__*/(0, _react.createRef)();
83
83
  var _this$props = _this.props,
84
84
  id = _this$props.id,
85
- dataset = _this$props.dataset,
86
- freezeSize = _this$props.freezeSize;
87
- _this.dataset = dataset;
88
- var openDictionary = {};
85
+ freezeSize = _this$props.freezeSize,
86
+ sorts = _this$props.sorts,
87
+ paging = _this$props.paging,
88
+ columns = _this$props.columns;
89
+ var openDictionary = {},
90
+ groupDictionary = {};
89
91
 
90
92
  if (id !== undefined) {
91
- openDictionary = localStorage.getItem('r table ' + id);
93
+ openDictionary = localStorage.getItem('aio table ' + id);
92
94
 
93
95
  if (openDictionary === null || openDictionary === undefined) {
94
- localStorage.setItem('r table ' + id, '{}');
96
+ localStorage.setItem('aio table ' + id, '{}');
95
97
  openDictionary = {};
96
98
  } else {
97
99
  openDictionary = JSON.parse(openDictionary);
98
100
  }
101
+
102
+ groupDictionary = localStorage.getItem('aio table group' + id);
103
+
104
+ if (groupDictionary === null || groupDictionary === undefined) {
105
+ localStorage.setItem('aio table group' + id, '{}');
106
+ groupDictionary = {};
107
+ } else {
108
+ groupDictionary = JSON.parse(groupDictionary);
109
+ }
99
110
  }
100
111
 
101
- _this.activeTableIndex = 0;
112
+ (0, _jquery.default)(window).bind('click', function (e) {
113
+ var focused = _this.state.focused;
114
+
115
+ if (focused === false) {
116
+ return;
117
+ }
118
+
119
+ var target = (0, _jquery.default)(e.target);
120
+
121
+ if (target.parents('.aio-table-cell').length !== 0 || target.hasClass('aio-table-cell')) {
122
+ return;
123
+ }
124
+
125
+ _this.setState({
126
+ focused: false
127
+ });
128
+ });
102
129
  _this.state = {
103
130
  openDictionary: openDictionary,
104
131
  filterDictionary: {},
105
132
  groupsOpen: {},
106
- freezeSize: freezeSize
133
+ freezeSize: freezeSize,
134
+ groupDictionary: groupDictionary,
135
+ sorts: sorts,
136
+ paging: paging,
137
+ columns: columns,
138
+ focused: false,
139
+ toggleAllState: true,
140
+ searchText: ''
107
141
  };
108
142
  return _this;
109
143
  }
110
144
 
111
- _createClass(RTable, [{
145
+ _createClass(AIOTable, [{
112
146
  key: "onScroll",
113
147
  value: function onScroll(e, index) {
148
+ var _this2 = this;
149
+
114
150
  if (!this.freezeMode) {
115
151
  return;
116
152
  }
117
153
 
154
+ if (this.activeTableIndex === undefined) {
155
+ return;
156
+ }
157
+
118
158
  if (index !== this.activeTableIndex) {
159
+ this.onMouseEnter(index);
160
+ clearTimeout(this.timeo);
161
+ this.timeo = setTimeout(function () {
162
+ return _this2.bindScroll();
163
+ }, 40);
119
164
  return;
120
165
  }
121
166
 
122
- var units = (0, _jquery.default)(this.dom.current).find('.r-table-unit');
167
+ this.bindScroll();
168
+ }
169
+ }, {
170
+ key: "bindScroll",
171
+ value: function bindScroll() {
172
+ var units = (0, _jquery.default)(this.dom.current).find('.aio-table-unit');
123
173
  var scrollTop = units.eq(this.activeTableIndex).scrollTop();
124
174
  units.eq(this.deactiveTableIndex).scrollTop(scrollTop);
125
175
  }
@@ -129,49 +179,20 @@ var RTable = /*#__PURE__*/function (_Component) {
129
179
  this.activeTableIndex = index;
130
180
  this.deactiveTableIndex = index === 0 ? 1 : 0;
131
181
  }
132
- }, {
133
- key: "getValueByField",
134
- value: function getValueByField(obj, field) {
135
- var fieldString = typeof field === 'function' ? field(obj) : field;
136
-
137
- if (!fieldString || typeof fieldString !== 'string') {
138
- console.error('Grid.getValueByField() receive invalid field');
139
- return undefined;
140
- }
141
-
142
- var fields = fieldString.split('.');
143
- var value = obj[fields[0]];
144
-
145
- if (value === undefined) {
146
- return;
147
- }
148
-
149
- for (var i = 1; i < fields.length; i++) {
150
- value = value[fields[i]];
151
-
152
- if (value === undefined || value === null) {
153
- return;
154
- }
155
- }
156
-
157
- return value;
158
- }
159
182
  }, {
160
183
  key: "getGap",
161
184
  value: function getGap() {
162
- var cellGap = this.props.cellGap;
163
185
  return /*#__PURE__*/_react.default.createElement("div", {
164
- className: "r-table-gap",
186
+ className: "aio-table-gap",
165
187
  style: {
166
- width: cellGap
188
+ width: this.props.cellGap
167
189
  }
168
190
  });
169
191
  }
170
192
  }, {
171
193
  key: "getClient",
172
194
  value: function getClient(e) {
173
- var touch = this.context.touch;
174
- return touch ? [e.changedTouches[0].clientX, e.changedTouches[0].clientY] : [e.clientX, e.clientY];
195
+ return this.context.touch ? [e.changedTouches[0].clientX, e.changedTouches[0].clientY] : [e.clientX, e.clientY];
175
196
  }
176
197
  }, {
177
198
  key: "resizeDown",
@@ -200,7 +221,7 @@ var RTable = /*#__PURE__*/function (_Component) {
200
221
  }
201
222
 
202
223
  this.resizeDetails.newWidth = newWidth;
203
- (0, _jquery.default)('#r-table-first-split').css({
224
+ (0, _jquery.default)('#aio-table-first-split').css({
204
225
  width: newWidth
205
226
  });
206
227
  }
@@ -214,95 +235,144 @@ var RTable = /*#__PURE__*/function (_Component) {
214
235
  freezeSize: this.resizeDetails.newWidth
215
236
  });
216
237
  }
238
+ }, {
239
+ key: "getBodyStyle",
240
+ value: function getBodyStyle(Toolbar) {
241
+ var paging = this.state.paging;
242
+ var padding = this.props.padding;
243
+ var def = padding,
244
+ top = 0;
245
+
246
+ if (paging) {
247
+ def += 36;
248
+ }
249
+
250
+ if (Toolbar !== null) {
251
+ def += 36;
252
+ top += 36;
253
+ }
254
+
255
+ return {
256
+ height: "calc(100% - ".concat(def, "px)"),
257
+ top: top
258
+ };
259
+ }
217
260
  }, {
218
261
  key: "getTable",
219
- value: function getTable() {
220
- var _this2 = this;
262
+ value: function getTable(Toolbar) {
263
+ var _this3 = this;
221
264
 
222
265
  var rows = this.getRows();
266
+ this.rows = rows;
223
267
 
224
268
  if (!this.freezeMode) {
225
269
  return /*#__PURE__*/_react.default.createElement("div", {
226
- className: 'r-table-body'
270
+ className: 'aio-table-body',
271
+ style: this.getBodyStyle(Toolbar)
227
272
  }, /*#__PURE__*/_react.default.createElement(RTableUnit, {
228
273
  rows: rows,
229
- columns: this.visibleColumns
274
+ columns: this.visibleColumns,
275
+ type: "cells"
230
276
  }));
231
277
  } else {
232
278
  var freezeSize = this.state.freezeSize;
233
279
  return /*#__PURE__*/_react.default.createElement("div", {
234
- className: 'r-table-body'
280
+ className: 'aio-table-body',
281
+ style: this.getBodyStyle(Toolbar)
235
282
  }, /*#__PURE__*/_react.default.createElement(RTableUnit, {
236
283
  key: 0,
237
- id: "r-table-first-split",
284
+ id: "aio-table-first-split",
238
285
  rows: rows,
239
286
  columns: this.freezeColumns,
240
287
  index: 0,
241
- type: "freeze",
288
+ type: "freezeCells",
242
289
  style: {
243
290
  width: freezeSize
244
291
  }
245
292
  }), /*#__PURE__*/_react.default.createElement("div", {
246
- className: "r-table-splitter",
293
+ className: "aio-table-splitter",
247
294
  onMouseDown: function onMouseDown(e) {
248
- return _this2.resizeDown(e);
295
+ return _this3.resizeDown(e);
249
296
  },
250
297
  onTouchStart: function onTouchStart(e) {
251
- return _this2.resizeDown(e);
298
+ return _this3.resizeDown(e);
252
299
  }
253
300
  }), true && /*#__PURE__*/_react.default.createElement(RTableUnit, {
254
301
  key: 1,
255
- id: "r-table-second-split",
302
+ id: "aio-table-second-split",
256
303
  rows: rows,
257
304
  columns: this.unFreezeColumns,
258
305
  index: 1,
259
- type: "unFreeze"
306
+ type: "unFreezeCells"
260
307
  }));
261
308
  }
262
309
  }
263
310
  }, {
264
311
  key: "convertFlat",
265
- value: function convertFlat(model) {
266
- var _this3 = this;
267
-
312
+ value: function convertFlat(model, getId, getParentId, childsField) {
268
313
  var convertModelRecursive = function convertModelRecursive(array, parentId, parentObject) {
269
314
  for (var i = 0; i < array.length; i++) {
270
315
  var row = array[i];
316
+ var rowParentId = getParentId(row);
271
317
 
272
- if (row._parentId === undefined) {
273
- row._parentId = _this3.getValueByField(row, _this3.dataset.parentId);
274
- _this3.perf++;
275
- }
276
-
277
- if (row._parentId !== parentId) {
318
+ if (rowParentId !== parentId) {
278
319
  continue;
279
320
  }
280
321
 
281
- var rowId = _this3.getValueByField(row, _this3.dataset.id);
282
-
283
- row._childs = [];
322
+ var rowId = getId(row);
323
+ row[childsField] = [];
284
324
  parentObject.push(row);
285
-
286
- var newArray = _toConsumableArray(array);
287
-
288
- newArray.splice(i, 1);
289
325
  array.splice(i, 1);
290
326
  i--;
291
- convertModelRecursive(newArray, rowId, row._childs);
327
+ convertModelRecursive(_toConsumableArray(array), rowId, row[childsField]);
292
328
  }
293
329
  };
294
330
 
295
- this.dataset.childs = '_childs';
296
331
  var result = [];
297
332
  convertModelRecursive(_toConsumableArray(model), undefined, result);
298
333
  return result;
299
334
  }
335
+ }, {
336
+ key: "sort",
337
+ value: function sort(model) {
338
+ var _this4 = this;
339
+
340
+ var newModel = model.sort(function (a, b) {
341
+ for (var i = 0; i < _this4.sorts.length; i++) {
342
+ var _this4$sorts$i = _this4.sorts[i],
343
+ getValue = _this4$sorts$i.getValue,
344
+ type = _this4$sorts$i.type;
345
+ var aValue = getValue(a),
346
+ bValue = getValue(b);
347
+
348
+ if (aValue < bValue) {
349
+ return -1 * (type === 'dec' ? -1 : 1);
350
+ }
351
+
352
+ if (aValue > bValue) {
353
+ return 1 * (type === 'dec' ? -1 : 1);
354
+ }
355
+
356
+ if (i !== _this4.sorts.length - 1) {
357
+ continue;
358
+ }
359
+
360
+ return 0;
361
+ }
362
+
363
+ return 0;
364
+ });
365
+ return newModel;
366
+ }
300
367
  }, {
301
368
  key: "getRows",
302
369
  value: function getRows() {
303
370
  var _this$props2 = this.props,
304
371
  model = _this$props2.model,
305
- flat = _this$props2.flat;
372
+ getRowId = _this$props2.getRowId,
373
+ getRowParentId = _this$props2.getRowParentId,
374
+ onChangeSort = _this$props2.onChangeSort;
375
+ var paging = this.state.paging;
306
376
 
307
377
  if (!model) {
308
378
  return false;
@@ -312,65 +382,100 @@ var RTable = /*#__PURE__*/function (_Component) {
312
382
  this.rowRenderIndex = 0;
313
383
  this.rowRealIndex = 0;
314
384
  this.perf = 0;
315
- var convertedModel = flat ? this.convertFlat(_toConsumableArray(model)) : _toConsumableArray(model);
316
- var pagedModel = this.getModelByPaging(convertedModel);
317
- var groupedModel = this.getModelByGroup(pagedModel);
318
- this.getRowsReq(groupedModel, rows, 0, []);
319
- return rows;
385
+ var convertedModel = getRowParentId ? this.convertFlat(_toConsumableArray(model), getRowId, getRowParentId, '_childs') : _toConsumableArray(model);
386
+
387
+ if (this.sorts.length && !onChangeSort) {
388
+ convertedModel = this.sort(convertedModel);
389
+ }
390
+
391
+ this.getRowsReq(convertedModel, rows, 0, []);
392
+ var roots = [];
393
+
394
+ for (var _i = 0; _i < rows.length; _i++) {
395
+ var row = rows[_i];
396
+
397
+ if (row.row._show === false) {
398
+ continue;
399
+ }
400
+
401
+ if (row.row._level === 0) {
402
+ roots.push([]);
403
+ }
404
+
405
+ roots[roots.length - 1].push(row);
406
+ }
407
+
408
+ if (paging) {
409
+ roots = this.getRowsByPaging(roots);
410
+ }
411
+
412
+ if (this.groups.length) {
413
+ roots = this.getModelByGroup(roots);
414
+ }
415
+
416
+ var Rows = [];
417
+
418
+ for (var i = 0; i < roots.length; i++) {
419
+ Rows = Rows.concat(roots[i]);
420
+ }
421
+
422
+ return Rows;
320
423
  }
321
424
  }, {
322
- key: "getModelByPaging",
323
- value: function getModelByPaging(model) {
324
- var paging = this.props.paging;
425
+ key: "getRowsByPaging",
426
+ value: function getRowsByPaging(roots) {
427
+ var paging = this.state.paging;
428
+ var length = paging.onChange ? paging.count : roots.length;
429
+ paging.pages = Math.ceil(length / paging.size);
325
430
 
326
- if (!paging || paging.outSide) {
327
- return model;
431
+ if (paging.number > Math.ceil(length / paging.size)) {
432
+ paging.number = Math.ceil(length / paging.size);
433
+
434
+ if (paging.number < 1) {
435
+ paging.number = 1;
436
+ }
328
437
  }
329
438
 
330
- var length = paging.length === undefined ? model.length : paging.length;
331
- paging.pages = Math.ceil(length / paging.size);
332
- var start = 0;
333
- var end = model.length;
439
+ if (paging.onChange) {
440
+ return roots;
441
+ } //اگر پیجینگ آنچنج داشت تغییری در ردیف ها نده و اجازه بده تغییرات در آنچنج روی مدل ورودی انجام شود
442
+
334
443
 
335
- if (paging.number > Math.ceil(model.length / paging.size)) {
336
- paging.number = Math.ceil(model.length / paging.size);
444
+ var start = (paging.number - 1) * paging.size;
445
+ var end = start + paging.size;
446
+
447
+ if (end > length) {
448
+ end = length;
337
449
  }
338
450
 
339
- start = (paging.number - 1) * paging.size;
340
- end = start + paging.size;
341
451
  this.rowRealIndex = start;
342
- return model.slice(start, end);
452
+ return roots.slice(start, end);
343
453
  }
344
454
  }, {
345
455
  key: "getModelByGroup",
346
- value: function getModelByGroup(model) {
347
- var _this4 = this;
348
-
349
- if (!this.groupByMode) {
350
- return model;
351
- }
352
-
456
+ value: function getModelByGroup(roots) {
353
457
  var groupsOpen = this.state.groupsOpen;
354
458
  var groups = this.groups;
355
459
 
356
- function msf(obj, _level) {
357
- var _parentField = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
358
-
460
+ function msf(obj, _level, parents) {
359
461
  if (Array.isArray(obj)) {
360
462
  groupedRows = groupedRows.concat(obj);
361
463
  } else {
362
464
  for (var prop in obj) {
363
- groupsOpen[_parentField + prop] = groupsOpen[_parentField + prop] === undefined ? true : groupsOpen[_parentField + prop];
465
+ var newParents = parents.concat(prop);
466
+
467
+ var _groupId = newParents.toString();
468
+
469
+ groupsOpen[_groupId] = groupsOpen[_groupId] === undefined ? true : groupsOpen[_groupId];
364
470
  groupedRows.push({
365
- _groupField: prop,
366
- _groupText: prop,
471
+ _groupValue: prop,
472
+ _groupId: _groupId,
367
473
  _level: _level,
368
- _opened: groupsOpen[_parentField + prop],
369
- _parentField: _parentField
474
+ _opened: groupsOpen[_groupId]
370
475
  });
371
476
 
372
- if (groupsOpen[_parentField + prop]) {
373
- msf(obj[prop], _level + 1, _parentField + prop);
477
+ if (groupsOpen[_groupId]) {
478
+ msf(obj[prop], _level + 1, newParents);
374
479
  }
375
480
  }
376
481
  }
@@ -379,14 +484,10 @@ var RTable = /*#__PURE__*/function (_Component) {
379
484
  var newModel = {};
380
485
 
381
486
  var _loop = function _loop(i) {
382
- var row = model[i];
487
+ var root = roots[i];
383
488
  obj = newModel;
384
489
  var values = groups.map(function (group) {
385
- if (typeof group.field === 'function') {
386
- return group.field(row);
387
- } else {
388
- return _this4.getValueByField(row, group.field);
389
- }
490
+ return group.getValue(root[0].row);
390
491
  });
391
492
 
392
493
  for (var j = 0; j < values.length; j++) {
@@ -394,7 +495,7 @@ var RTable = /*#__PURE__*/function (_Component) {
394
495
 
395
496
  if (j === values.length - 1) {
396
497
  obj[value] = obj[value] || [];
397
- obj[value].push(row);
498
+ obj[value].push(root);
398
499
  } else {
399
500
  obj[value] = obj[value] || {};
400
501
  obj = obj[value];
@@ -402,7 +503,7 @@ var RTable = /*#__PURE__*/function (_Component) {
402
503
  }
403
504
  };
404
505
 
405
- for (var i = 0; i < model.length; i++) {
506
+ for (var i = 0; i < roots.length; i++) {
406
507
  var obj;
407
508
 
408
509
  _loop(i);
@@ -410,18 +511,33 @@ var RTable = /*#__PURE__*/function (_Component) {
410
511
 
411
512
  var groupedRows = [];
412
513
  var _level = 0;
413
- msf(newModel, _level);
514
+ msf(newModel, _level, []);
414
515
  return groupedRows;
415
516
  }
416
517
  }, {
417
518
  key: "getRowsReq",
418
519
  value: function getRowsReq(model, rows, _level, parents) {
419
520
  var openDictionary = this.state.openDictionary;
521
+ var _this$props3 = this.props,
522
+ getRowId = _this$props3.getRowId,
523
+ getRowChilds = _this$props3.getRowChilds,
524
+ getRowVisible = _this$props3.getRowVisible,
525
+ getRowParentId = _this$props3.getRowParentId;
526
+
527
+ if (getRowParentId) {
528
+ getRowChilds = function getRowChilds(row) {
529
+ return row._childs;
530
+ };
531
+ }
420
532
 
421
533
  for (var i = 0; i < model.length; i++) {
422
534
  var row = model[i];
423
535
 
424
- if (row._groupField) {
536
+ if (getRowVisible && getRowVisible(row) === false) {
537
+ continue;
538
+ }
539
+
540
+ if (row._groupId) {
425
541
  rows.push(row);
426
542
  continue;
427
543
  }
@@ -439,11 +555,11 @@ var RTable = /*#__PURE__*/function (_Component) {
439
555
  return parents;
440
556
  };
441
557
 
442
- if (this.dataset && this.dataset.id) {
443
- var id = this.getValueByField(row, this.dataset.id);
558
+ if (getRowId) {
559
+ var id = getRowId(row);
444
560
 
445
561
  if (id === undefined) {
446
- console.error('RTable => id of row is not defined, please check getId props of RTable');
562
+ console.error('AIOTable => id of row is not defined, please check getRowId props of AIOTable');
447
563
  }
448
564
 
449
565
  openDictionary[id] = openDictionary[id] === false ? false : true;
@@ -456,18 +572,18 @@ var RTable = /*#__PURE__*/function (_Component) {
456
572
  row._childsLength = 0;
457
573
  var childs = [];
458
574
 
459
- if (this.dataset && this.dataset.childs) {
460
- childs = this.getValueByField(row, this.dataset.childs) || [];
575
+ if (getRowChilds) {
576
+ childs = getRowChilds(row) || [];
461
577
  row._childsLength = childs.length;
462
578
  }
463
579
 
464
580
  var Row = this.getRow(row);
465
- rows.push(Row);
581
+ rows.push({ ...Row,
582
+ row: row
583
+ });
466
584
 
467
- if (row._opened) {
468
- if (row._childsLength) {
469
- this.getRowsReq(childs, rows, _level + 1, parents.concat(row));
470
- }
585
+ if (row._opened && row._childsLength) {
586
+ this.getRowsReq(childs, rows, _level + 1, parents.concat(row));
471
587
  } else {
472
588
  this.rowRealIndex += row._childsLength;
473
589
  }
@@ -476,6 +592,10 @@ var RTable = /*#__PURE__*/function (_Component) {
476
592
  }, {
477
593
  key: "getFilterResult_and",
478
594
  value: function getFilterResult_and(filters, value) {
595
+ if (value === undefined) {
596
+ return false;
597
+ }
598
+
479
599
  for (var i = 0; i < filters.length; i++) {
480
600
  var filterItem = filters[i];
481
601
 
@@ -483,19 +603,19 @@ var RTable = /*#__PURE__*/function (_Component) {
483
603
  continue;
484
604
  }
485
605
 
486
- if (filterItem.operator === 'contain' && value.indexOf(filterItem.value) === -1) {
606
+ if (filterItem.operator === 'contain' && value.toString().toLowerCase().indexOf(filterItem.value.toString().toLowerCase()) === -1) {
487
607
  return false;
488
608
  }
489
609
 
490
- if (filterItem.operator === 'notContain' && value.indexOf(filterItem.value) !== -1) {
610
+ if (filterItem.operator === 'notContain' && value.toString().toLowerCase().indexOf(filterItem.value.toString().toLowerCase()) !== -1) {
491
611
  return false;
492
612
  }
493
613
 
494
- if (filterItem.operator === 'equal' && value !== filterItem.value) {
614
+ if (filterItem.operator === 'equal' && value.toString().toLowerCase() !== filterItem.value.toString().toLowerCase()) {
495
615
  return false;
496
616
  }
497
617
 
498
- if (filterItem.operator === 'notEqual' && value === filterItem.value) {
618
+ if (filterItem.operator === 'notEqual' && value.toString().toLowerCase() === filterItem.value.toString().toLowerCase()) {
499
619
  return false;
500
620
  }
501
621
 
@@ -513,6 +633,10 @@ var RTable = /*#__PURE__*/function (_Component) {
513
633
  }, {
514
634
  key: "getFilterResult_or",
515
635
  value: function getFilterResult_or(filters, value) {
636
+ if (value === undefined) {
637
+ return false;
638
+ }
639
+
516
640
  for (var i = 0; i < filters.length; i++) {
517
641
  var filterItem = filters[i];
518
642
 
@@ -520,27 +644,27 @@ var RTable = /*#__PURE__*/function (_Component) {
520
644
  return true;
521
645
  }
522
646
 
523
- if (filterItem.operator === 'contain' && value.indexOf(filterItem.value) !== -1) {
647
+ if (filterItem.operator === 'contain' && value.toString().toLowerCase().indexOf(filterItem.value.toString().toLowerCase()) !== -1) {
524
648
  return true;
525
649
  }
526
650
 
527
- if (filterItem.operator === 'notContain' && value.indexOf(filterItem.value) === -1) {
651
+ if (filterItem.operator === 'notContain' && value.toString().toLowerCase().indexOf(filterItem.value.toString().toLowerCase()) === -1) {
528
652
  return true;
529
653
  }
530
654
 
531
- if (filterItem.operator === 'equal' && value === filterItem.value) {
655
+ if (filterItem.operator === 'equal' && value.toString().toLowerCase() === filterItem.value.toString().toLowerCase()) {
532
656
  return true;
533
657
  }
534
658
 
535
- if (filterItem.operator === 'notEqual' && value !== filterItem.value) {
659
+ if (filterItem.operator === 'notEqual' && value.toString().toLowerCase() !== filterItem.value.toString().toLowerCase()) {
536
660
  return true;
537
661
  }
538
662
 
539
- if (filterItem.operator === 'greater' && value > filterItem.value) {
663
+ if (filterItem.operator === 'greater' && parseFloat(value) > parseFloat(filterItem.value)) {
540
664
  return true;
541
665
  }
542
666
 
543
- if (filterItem.operator === 'less' && value < filterItem.value) {
667
+ if (filterItem.operator === 'less' && parseFloat(value) < parseFloat(filterItem.value)) {
544
668
  return true;
545
669
  }
546
670
  }
@@ -551,10 +675,6 @@ var RTable = /*#__PURE__*/function (_Component) {
551
675
  key: "getFilterResult",
552
676
  value: function getFilterResult(column, value) {
553
677
  var filterDictionary = this.state.filterDictionary;
554
- filterDictionary[column._index] = filterDictionary[column._index] || {
555
- items: [],
556
- booleanType: 'or'
557
- };
558
678
  var filters = filterDictionary[column._index].items;
559
679
 
560
680
  if (filters.length) {
@@ -567,34 +687,38 @@ var RTable = /*#__PURE__*/function (_Component) {
567
687
  }, {
568
688
  key: "getRow",
569
689
  value: function getRow(row) {
690
+ var onChangeFilter = this.props.onChangeFilter;
691
+ var filterDictionary = this.state.filterDictionary;
570
692
  row._values = {};
571
- var show = true;
572
- var lastFreezedColumn;
573
- var lastColumn;
574
- var isThereAutoColumn = false;
575
- var cells = [];
576
- var freezeCells = [];
577
- var unFreezeCells = [];
693
+ var show = true,
694
+ lastColumn,
695
+ isThereAutoColumn = false,
696
+ cells = [],
697
+ freezeCells = [],
698
+ unFreezeCells = [];
578
699
 
579
700
  for (var i = 0; i < this.visibleColumns.length; i++) {
580
701
  var column = this.visibleColumns[i],
581
702
  value = void 0;
582
703
 
583
- if (typeof column.field === 'function') {
584
- value = column.field(row);
585
- } else {
586
- value = column.field ? this.getValueByField(row, column.field) : undefined;
704
+ try {
705
+ value = typeof column.getValue === 'function' ? column.getValue(row) : undefined;
706
+ } catch {
707
+ value = undefined;
587
708
  }
588
709
 
589
710
  row._values[column._index] = value;
711
+ filterDictionary[column._index] = filterDictionary[column._index] || {
712
+ items: [],
713
+ booleanType: 'or'
714
+ };
590
715
 
591
- if (show) {
716
+ if (show && !onChangeFilter) {
592
717
  show = show && this.getFilterResult(column, value);
593
718
  }
594
719
 
595
720
  var obj = {
596
721
  key: row._index + ',' + column._index,
597
- row: row,
598
722
  column: column,
599
723
  value: value,
600
724
  freeze: column.freeze
@@ -604,7 +728,6 @@ var RTable = /*#__PURE__*/function (_Component) {
604
728
  if (column.freeze) {
605
729
  column._renderIndex = freezeCells.length;
606
730
  freezeCells.push(obj);
607
- lastFreezedColumn = column;
608
731
  } else {
609
732
  column._renderIndex = unFreezeCells.length;
610
733
  lastColumn = column;
@@ -625,20 +748,18 @@ var RTable = /*#__PURE__*/function (_Component) {
625
748
  }
626
749
  }
627
750
 
751
+ row._show = show;
752
+
628
753
  if (show) {
629
754
  var parents = row._getParents();
630
755
 
631
- for (var _i = 0; _i < parents.length; _i++) {
632
- if (parents[_i].show === false) {
633
- parents[_i].show = 'relativeFilter';
756
+ for (var _i2 = 0; _i2 < parents.length; _i2++) {
757
+ if (parents[_i2]._show === false) {
758
+ parents[_i2]._show = 'relativeFilter';
634
759
  }
635
760
  }
636
761
  }
637
762
 
638
- if (lastFreezedColumn) {
639
- lastFreezedColumn.width = 'auto';
640
- }
641
-
642
763
  if (!isThereAutoColumn && lastColumn) {
643
764
  lastColumn.width = 'auto';
644
765
  }
@@ -646,86 +767,306 @@ var RTable = /*#__PURE__*/function (_Component) {
646
767
  return {
647
768
  cells: cells,
648
769
  freezeCells: freezeCells,
649
- unFreezeCells: unFreezeCells,
650
- show: show
770
+ unFreezeCells: unFreezeCells
771
+ };
772
+ }
773
+ }, {
774
+ key: "getRowById",
775
+ value: function getRowById(id) {
776
+ for (var i = 0; i < this.rows.length; i++) {
777
+ var row = this.rows[i];
778
+
779
+ if (!row.row) {
780
+ continue;
781
+ }
782
+
783
+ if (row.row._id === id) {
784
+ return row;
785
+ }
786
+ }
787
+ }
788
+ }, {
789
+ key: "toggleAll",
790
+ value: function toggleAll() {
791
+ var _this$state = this.state,
792
+ openDictionary = _this$state.openDictionary,
793
+ groupsOpen = _this$state.groupsOpen,
794
+ toggleAllState = _this$state.toggleAllState;
795
+ var _this$props4 = this.props,
796
+ id = _this$props4.id,
797
+ getRowId = _this$props4.getRowId;
798
+
799
+ if (getRowId) {
800
+ for (var prop in openDictionary) {
801
+ var row = this.getRowById(prop);
802
+
803
+ if (row && row.row && row.row._show === 'relativeFilter') {
804
+ continue;
805
+ }
806
+
807
+ openDictionary[prop] = toggleAllState;
808
+ }
809
+ } else {
810
+ for (var i = 0; i < this.rows.length; i++) {
811
+ var _row = this.rows[i];
812
+
813
+ if (!_row.row) {
814
+ continue;
815
+ }
816
+
817
+ if (_row.row._show === 'relativeFilter') {
818
+ continue;
819
+ }
820
+
821
+ _row.row._opened = toggleAllState;
822
+ }
823
+ }
824
+
825
+ for (var _prop in groupsOpen) {
826
+ groupsOpen[_prop] = toggleAllState;
827
+ }
828
+
829
+ localStorage.setItem('aio table ' + id, JSON.stringify(openDictionary));
830
+ var obj = {
831
+ openDictionary: openDictionary,
832
+ groupsOpen: groupsOpen,
833
+ toggleAllState: !toggleAllState
651
834
  };
835
+ this.setState(obj);
652
836
  }
653
837
  }, {
654
- key: "setColumnWidth",
655
- value: function setColumnWidth(column) {
656
- if (column.template === 'checkbox' && !column.width) {
657
- column.width = '48px';
838
+ key: "showColumnRelativeGroups",
839
+ value: function showColumnRelativeGroups(column) {
840
+ var groups = this.props.groups;
841
+ var groupDictionary = this.state.groupDictionary;
842
+
843
+ if (!groups) {
844
+ return true;
658
845
  }
659
846
 
660
- if (typeof column.width !== 'string') {
661
- column.width = 'auto';
847
+ if (!groups.length) {
848
+ return true;
662
849
  }
663
850
 
664
- if (column.width !== 'auto' && column.width.indexOf('px') === -1) {
665
- column.width = 'auto';
851
+ if (!column.groupName) {
852
+ return true;
666
853
  }
854
+
855
+ return groupDictionary[column.groupName] !== true;
667
856
  }
668
857
  }, {
669
858
  key: "updateColumns",
670
859
  value: function updateColumns() {
671
860
  var _this5 = this;
672
861
 
673
- var _this$props3 = this.props,
674
- columns = _this$props3.columns,
675
- onChange = _this$props3.onChange,
676
- _this$props3$freezeMo = _this$props3.freezeMode,
677
- freezeMode = _this$props3$freezeMo === void 0 ? true : _this$props3$freezeMo,
678
- _this$props3$groupByM = _this$props3.groupByMode,
679
- groupByMode = _this$props3$groupByM === void 0 ? true : _this$props3$groupByM;
862
+ var _this$props5 = this.props,
863
+ _this$props5$freezeMo = _this$props5.freezeMode,
864
+ freezeMode = _this$props5$freezeMo === void 0 ? true : _this$props5$freezeMo,
865
+ translate = _this$props5.translate,
866
+ groups = _this$props5.groups,
867
+ cardTemplate = _this$props5.cardTemplate,
868
+ onChangeSort = _this$props5.onChangeSort,
869
+ _this$props5$toggleAl = _this$props5.toggleAll,
870
+ toggleAll = _this$props5$toggleAl === void 0 ? false : _this$props5$toggleAl,
871
+ id = _this$props5.id;
872
+ var _this$state2 = this.state,
873
+ groupDictionary = _this$state2.groupDictionary,
874
+ sorts = _this$state2.sorts,
875
+ columns = _this$state2.columns;
680
876
  this.groups = [];
877
+ this.sorts = [];
681
878
  this.freezeMode = false;
682
- this.groupByMode = false;
683
879
  this.visibleColumns = [];
684
880
  this.freezeColumns = [];
685
881
  this.unFreezeColumns = [];
686
882
  this.toolbar = {
687
- show: false,
688
- toggle: [],
689
- freeze: [],
690
- groupBy: [],
883
+ show: toggleAll,
884
+ toggle: [{
885
+ text: translate('Show Columns')
886
+ }],
887
+ toggleAll: toggleAll ? this.toggleAll.bind(this) : false,
888
+ freeze: [{
889
+ text: translate('Freeze')
890
+ }],
891
+ groupBy: [{
892
+ text: translate('Group By')
893
+ }],
894
+ sort: [{
895
+ text: translate('Sort')
896
+ }],
691
897
  searchColumnIndex: false
692
898
  };
693
899
 
694
900
  var _loop2 = function _loop2(i) {
695
- var column = columns[i];
696
-
697
- _this5.setColumnWidth(column);
901
+ var sort = sorts[i];
902
+ var getValue = sort.getValue,
903
+ _sort$type = sort.type,
904
+ type = _sort$type === void 0 ? 'inc' : _sort$type,
905
+ title = sort.title,
906
+ _sort$active = sort.active,
907
+ active = _sort$active === void 0 ? true : _sort$active,
908
+ _sort$toggle = sort.toggle,
909
+ toggle = _sort$toggle === void 0 ? true : _sort$toggle;
910
+
911
+ if (!title) {
912
+ console.error('aio table => missing sort title property');
913
+ return "continue";
914
+ }
698
915
 
699
- column._index = i;
916
+ if (typeof getValue !== 'function') {
917
+ console.error('aio table => sort getValue property is not a function');
918
+ return "continue";
919
+ }
700
920
 
701
- if (groupByMode) {
702
- if (column.groupBy) {
703
- _this5.groups.push({
704
- field: column.field,
705
- text: column.title
706
- });
921
+ if (active === true) {
922
+ _this5.sorts.push({
923
+ getValue: getValue,
924
+ type: type
925
+ });
926
+ }
707
927
 
708
- _this5.groupByMode = true;
709
- }
928
+ if (toggle) {
929
+ _this5.toolbar.show = true;
710
930
 
711
- if (column.toggleGroupBy) {
712
- _this5.toolbar.show = true;
713
-
714
- _this5.toolbar.groupBy.push({
715
- field: column.field,
716
- text: column.title,
717
- checked: column.groupBy === true,
718
- onClick: function onClick() {
719
- column.groupBy = !column.groupBy;
720
- onChange({
721
- columns: columns
931
+ _this5.toolbar.sort.push({
932
+ text: title,
933
+ checked: active === true,
934
+ after: /*#__PURE__*/_react.default.createElement("div", {
935
+ style: {
936
+ width: '30px',
937
+ display: 'flex',
938
+ justifyContent: 'flex-end'
939
+ }
940
+ }, /*#__PURE__*/_react.default.createElement(_react2.Icon, {
941
+ path: type === 'dec' ? _js.mdiArrowDown : _js.mdiArrowUp,
942
+ size: 0.8,
943
+ onClick: function onClick(e) {
944
+ e.stopPropagation();
945
+ sort.type = sort.type === 'dec' ? 'inc' : 'dec';
946
+
947
+ _this5.setState({
948
+ sorts: sorts
722
949
  });
950
+
951
+ if (onChangeSort) {
952
+ onChangeSort(sorts.filter(function (o) {
953
+ return o.active !== false;
954
+ }));
955
+ }
723
956
  }
724
- });
957
+ })),
958
+ onClick: function onClick() {
959
+ sort.active = !active;
960
+
961
+ _this5.setState({
962
+ sorts: sorts
963
+ });
964
+
965
+ if (onChangeSort) {
966
+ onChangeSort(sorts.filter(function (o) {
967
+ return o.active !== false;
968
+ }));
969
+ }
970
+ }
971
+ });
972
+ }
973
+ };
974
+
975
+ for (var i = 0; i < sorts.length; i++) {
976
+ var _ret = _loop2(i);
977
+
978
+ if (_ret === "continue") continue;
979
+ }
980
+
981
+ var _loop3 = function _loop3(_i3) {
982
+ var group = groups[_i3];
983
+ var title = group.title,
984
+ _group$active = group.active,
985
+ active = _group$active === void 0 ? true : _group$active,
986
+ _group$toggle = group.toggle,
987
+ toggle = _group$toggle === void 0 ? true : _group$toggle,
988
+ getValue = group.getValue;
989
+
990
+ if (!title) {
991
+ console.error('aio table => missing group title property');
992
+ return "continue";
993
+ }
994
+
995
+ if (typeof getValue !== 'function') {
996
+ console.error('aio table => group getValue property is not a function');
997
+ return "continue";
998
+ }
999
+
1000
+ groupDictionary[title] = groupDictionary[title] === undefined ? active : groupDictionary[title];
1001
+
1002
+ if (groupDictionary[title]) {
1003
+ _this5.groups.push(group);
1004
+ }
1005
+
1006
+ if (toggle) {
1007
+ _this5.toolbar.show = true;
1008
+
1009
+ _this5.toolbar.groupBy.push({
1010
+ text: title,
1011
+ checked: groupDictionary[title],
1012
+ onClick: function onClick() {
1013
+ groupDictionary[title] = !groupDictionary[title];
1014
+
1015
+ if (id) {
1016
+ localStorage.setItem('aio table group' + id, JSON.stringify(groupDictionary));
1017
+ }
1018
+
1019
+ _this5.setState({
1020
+ groupDictionary: groupDictionary
1021
+ });
1022
+ }
1023
+ });
1024
+ }
1025
+ };
1026
+
1027
+ for (var _i3 = 0; _i3 < groups.length; _i3++) {
1028
+ var _ret2 = _loop3(_i3);
1029
+
1030
+ if (_ret2 === "continue") continue;
1031
+ }
1032
+
1033
+ if (cardTemplate) {
1034
+ return;
1035
+ }
1036
+
1037
+ var _loop4 = function _loop4(_i4) {
1038
+ var column = columns[_i4];
1039
+ var show = void 0;
1040
+
1041
+ if (column.storageKey && column.toggleShow) {
1042
+ var storageStr = localStorage.getItem('aio-table-column-storage-' + column.storageKey);
1043
+
1044
+ if (!storageStr || storageStr === null) {
1045
+ column._storageObj = {};
1046
+ localStorage.setItem('aio-table-column-storage-' + column.storageKey, JSON.stringify(column._storageObj));
1047
+ } else {
1048
+ column._storageObj = JSON.parse(storageStr);
1049
+ }
1050
+
1051
+ if (column._storageObj.show !== undefined) {
1052
+ show = column._storageObj.show;
1053
+ } else {
1054
+ show = column.show;
1055
+ }
1056
+
1057
+ if (column._storageObj.width !== undefined) {
1058
+ column.width = column._storageObj.width;
1059
+ } else {
1060
+ column.width = column.width || 'auto';
725
1061
  }
1062
+ } else {
1063
+ show = column.show;
1064
+ column.width = column.width || 'auto';
726
1065
  }
727
1066
 
728
- if (column.show !== false && column.groupBy !== true) {
1067
+ column._index = _i4;
1068
+
1069
+ if (show !== false && _this5.showColumnRelativeGroups(column)) {
729
1070
  _this5.visibleColumns.push(column);
730
1071
 
731
1072
  if (freezeMode) {
@@ -746,7 +1087,8 @@ var RTable = /*#__PURE__*/function (_Component) {
746
1087
  onClick: function onClick() {
747
1088
  column.freeze = column.freeze === true ? true : false;
748
1089
  column.freeze = !column.freeze;
749
- onChange({
1090
+
1091
+ _this5.setState({
750
1092
  columns: columns
751
1093
  });
752
1094
  }
@@ -760,11 +1102,20 @@ var RTable = /*#__PURE__*/function (_Component) {
760
1102
 
761
1103
  _this5.toolbar.toggle.push({
762
1104
  text: column.title,
763
- checked: column.show !== false,
1105
+ checked: show !== false,
764
1106
  onClick: function onClick() {
765
1107
  column.show = column.show === false ? false : true;
766
- column.show = !column.show;
767
- onChange({
1108
+
1109
+ if (column.storageKey) {
1110
+ column._storageObj.show = column._storageObj.show === false ? false : column._storageObj.show;
1111
+ column._storageObj.show = !column._storageObj.show;
1112
+ column.show = column._storageObj.show;
1113
+ localStorage.setItem('aio-table-column-storage-' + column.storageKey, JSON.stringify(column._storageObj));
1114
+ } else {
1115
+ column.show = !column.show;
1116
+ }
1117
+
1118
+ _this5.setState({
768
1119
  columns: columns
769
1120
  });
770
1121
  }
@@ -772,12 +1123,13 @@ var RTable = /*#__PURE__*/function (_Component) {
772
1123
  }
773
1124
 
774
1125
  if (column.search) {
1126
+ _this5.toolbar.show = true;
775
1127
  _this5.toolbar.searchColumnIndex = column._index;
776
1128
  }
777
1129
  };
778
1130
 
779
- for (var i = 0; i < columns.length; i++) {
780
- _loop2(i);
1131
+ for (var _i4 = 0; _i4 < columns.length; _i4++) {
1132
+ _loop4(_i4);
781
1133
  }
782
1134
 
783
1135
  if (this.freezeColumns.length === 0 || this.unFreezeColumns.length === 0) {
@@ -787,24 +1139,27 @@ var RTable = /*#__PURE__*/function (_Component) {
787
1139
  }, {
788
1140
  key: "getPaging",
789
1141
  value: function getPaging() {
790
- var _this$props4 = this.props,
791
- paging = _this$props4.paging,
792
- rtl = _this$props4.rtl,
793
- translate = _this$props4.translate;
1142
+ var _this6 = this;
1143
+
1144
+ var paging = this.state.paging;
794
1145
 
795
1146
  if (!paging) {
796
1147
  return null;
797
1148
  }
798
1149
 
1150
+ var _this$props6 = this.props,
1151
+ rtl = _this$props6.rtl,
1152
+ translate = _this$props6.translate;
799
1153
  var number = paging.number,
800
1154
  _paging$sizes = paging.sizes,
801
- sizes = _paging$sizes === void 0 ? [1, 5, 10, 20, 30] : _paging$sizes,
1155
+ sizes = _paging$sizes === void 0 ? [1, 5, 10, 20, 30, 40, 50, 60, 70, 80] : _paging$sizes,
802
1156
  size = paging.size,
803
- _paging$onChange = paging.onChange,
804
- _onChange = _paging$onChange === void 0 ? function () {} : _paging$onChange,
805
- pages = paging.pages;
1157
+ _paging$pages = paging.pages,
1158
+ pages = _paging$pages === void 0 ? 1 : _paging$pages;
806
1159
 
807
1160
  var changePage = function changePage(type) {
1161
+ var _paging$pages2 = paging.pages,
1162
+ pages = _paging$pages2 === void 0 ? 1 : _paging$pages2;
808
1163
  var newNumber;
809
1164
 
810
1165
  if (type === 'prev') {
@@ -829,18 +1184,24 @@ var RTable = /*#__PURE__*/function (_Component) {
829
1184
  return;
830
1185
  }
831
1186
 
832
- _onChange({
833
- number: newNumber
1187
+ paging.number = newNumber;
1188
+
1189
+ _this6.setState({
1190
+ paging: paging
834
1191
  });
1192
+
1193
+ if (paging.onChange) {
1194
+ paging.onChange(paging);
1195
+ }
835
1196
  };
836
1197
 
837
1198
  return /*#__PURE__*/_react.default.createElement("div", {
838
- className: "r-table-paging",
1199
+ className: "aio-table-paging",
839
1200
  style: {
840
1201
  direction: 'ltr'
841
1202
  }
842
1203
  }, /*#__PURE__*/_react.default.createElement("div", {
843
- className: "r-table-paging-button",
1204
+ className: "aio-table-paging-button",
844
1205
  onClick: function onClick() {
845
1206
  return changePage(rtl ? 'last' : 'first');
846
1207
  },
@@ -849,7 +1210,7 @@ var RTable = /*#__PURE__*/function (_Component) {
849
1210
  path: _js.mdiChevronDoubleLeft,
850
1211
  size: .8
851
1212
  })), /*#__PURE__*/_react.default.createElement("div", {
852
- className: "r-table-paging-button",
1213
+ className: "aio-table-paging-button",
853
1214
  onClick: function onClick() {
854
1215
  return changePage(rtl ? 'next' : 'prev');
855
1216
  },
@@ -858,9 +1219,9 @@ var RTable = /*#__PURE__*/function (_Component) {
858
1219
  path: _js.mdiChevronLeft,
859
1220
  size: .8
860
1221
  })), /*#__PURE__*/_react.default.createElement("div", {
861
- className: "r-table-paging-number"
1222
+ className: "aio-table-paging-number"
862
1223
  }, number + ' / ' + pages), /*#__PURE__*/_react.default.createElement("div", {
863
- className: "r-table-paging-button",
1224
+ className: "aio-table-paging-button",
864
1225
  onClick: function onClick() {
865
1226
  return changePage(rtl ? 'prev' : 'next');
866
1227
  },
@@ -869,7 +1230,7 @@ var RTable = /*#__PURE__*/function (_Component) {
869
1230
  path: _js.mdiChevronRight,
870
1231
  size: .8
871
1232
  })), /*#__PURE__*/_react.default.createElement("div", {
872
- className: "r-table-paging-button",
1233
+ className: "aio-table-paging-button",
873
1234
  onClick: function onClick() {
874
1235
  return changePage(rtl ? 'first' : 'last');
875
1236
  },
@@ -878,12 +1239,18 @@ var RTable = /*#__PURE__*/function (_Component) {
878
1239
  path: _js.mdiChevronDoubleRight,
879
1240
  size: .8
880
1241
  })), /*#__PURE__*/_react.default.createElement("select", {
881
- className: "r-table-paging-button",
1242
+ className: "aio-table-paging-button",
882
1243
  value: size,
883
1244
  onChange: function onChange(e) {
884
- return _onChange({
885
- size: parseInt(e.target.value)
1245
+ paging.size = parseInt(e.target.value);
1246
+
1247
+ _this6.setState({
1248
+ paging: paging
886
1249
  });
1250
+
1251
+ if (paging.onChange) {
1252
+ paging.onChange(paging);
1253
+ }
887
1254
  },
888
1255
  title: translate('Rows Count Per Page')
889
1256
  }, sizes.map(function (s, i) {
@@ -940,7 +1307,7 @@ var RTable = /*#__PURE__*/function (_Component) {
940
1307
  display: 'flex',
941
1308
  alignItems: 'center',
942
1309
  justifyContent: 'center',
943
- background: '#fff'
1310
+ background: 'transparent'
944
1311
  }
945
1312
  }, items);
946
1313
  }
@@ -948,81 +1315,173 @@ var RTable = /*#__PURE__*/function (_Component) {
948
1315
  key: "getLoading",
949
1316
  value: function getLoading() {
950
1317
  return /*#__PURE__*/_react.default.createElement("div", {
951
- className: "r-table-loading"
1318
+ className: "aio-table-loading"
952
1319
  }, this.cubes2({
953
1320
  thickness: [6, 40]
954
1321
  }));
955
1322
  }
956
1323
  }, {
957
- key: "render",
958
- value: function render() {
959
- var _this6 = this;
960
-
961
- var _this$props5 = this.props,
962
- columns = _this$props5.columns,
963
- rowHeight = _this$props5.rowHeight,
964
- headerHeight = _this$props5.headerHeight,
965
- toolbarHeight = _this$props5.toolbarHeight,
966
- rowGap = _this$props5.rowGap,
967
- className = _this$props5.className,
968
- columnGap = _this$props5.columnGap,
969
- rtl = _this$props5.rtl;
1324
+ key: "onChangeFilter",
1325
+ value: function onChangeFilter(obj) {
1326
+ var onChangeFilter = this.props.onChangeFilter;
1327
+ var columns = this.state.columns;
1328
+ var filters = [];
1329
+
1330
+ for (var prop in obj) {
1331
+ if (obj[prop].items.length) {
1332
+ filters.push({
1333
+ column: columns[prop],
1334
+ ...obj[prop]
1335
+ });
1336
+ }
1337
+ }
1338
+
1339
+ onChangeFilter(filters);
1340
+ }
1341
+ }, {
1342
+ key: "toggleRow",
1343
+ value: function toggleRow(row) {
1344
+ var openDictionary = this.state.openDictionary;
1345
+ var id = this.props.id;
1346
+
1347
+ if (row._show === 'relativeFilter') {
1348
+ return;
1349
+ }
1350
+
1351
+ if (row._id !== undefined) {
1352
+ openDictionary[row._id] = !openDictionary[row._id];
1353
+
1354
+ if (id !== undefined) {
1355
+ localStorage.setItem('aio table ' + id, JSON.stringify(openDictionary));
1356
+ }
1357
+
1358
+ this.setState({
1359
+ openDictionary: openDictionary
1360
+ });
1361
+ } else {
1362
+ row._opened = !row._opened;
1363
+ this.setState({});
1364
+ }
1365
+ }
1366
+ }, {
1367
+ key: "render",
1368
+ value: function render() {
1369
+ var _this7 = this;
1370
+
1371
+ if (JSON.stringify(this.props.columns) !== JSON.stringify(this.state.columns)) {
1372
+ this.setState({
1373
+ columns: this.props.columns
1374
+ }); //return null;
1375
+ }
1376
+
1377
+ if (JSON.stringify(this.props.paging) !== JSON.stringify(this.state.paging)) {
1378
+ this.setState({
1379
+ paging: this.props.paging
1380
+ }); //return null;
1381
+ }
1382
+
1383
+ var _this$props7 = this.props,
1384
+ rowHeight = _this$props7.rowHeight,
1385
+ headerHeight = _this$props7.headerHeight,
1386
+ toolbarHeight = _this$props7.toolbarHeight,
1387
+ rowGap = _this$props7.rowGap,
1388
+ className = _this$props7.className,
1389
+ columnGap = _this$props7.columnGap,
1390
+ rtl = _this$props7.rtl,
1391
+ style = _this$props7.style,
1392
+ _this$props7$attrs = _this$props7.attrs,
1393
+ attrs = _this$props7$attrs === void 0 ? {} : _this$props7$attrs,
1394
+ cardTemplate = _this$props7.cardTemplate,
1395
+ onChangeFilter = _this$props7.onChangeFilter,
1396
+ onSwap = _this$props7.onSwap,
1397
+ padding = _this$props7.padding;
1398
+ var columns = this.state.columns;
970
1399
  this.rh = rowHeight;
971
1400
  this.hh = headerHeight;
972
1401
  this.th = toolbarHeight;
973
1402
  this.rg = rowGap;
974
1403
  this.cg = columnGap;
975
1404
  this.updateColumns();
976
- var table = columns ? this.getTable() : '';
1405
+ var Toolbar = this.toolbar.show ? /*#__PURE__*/_react.default.createElement(RTableToolbar, this.toolbar) : null;
1406
+ var table = columns ? this.getTable(Toolbar) : '';
1407
+ var Paging = this.getPaging();
977
1408
  var context = { ...this.props,
978
1409
  ...this.state,
979
1410
  touch: this.touch,
1411
+ onDrag: function onDrag(obj) {
1412
+ return _this7.dragStart = obj;
1413
+ },
1414
+ onDrop: function onDrop(obj) {
1415
+ if (!_this7.dragStart) {
1416
+ return;
1417
+ }
1418
+
1419
+ if (_this7.dragStart._level !== obj._level) {
1420
+ return;
1421
+ }
1422
+
1423
+ if (_this7.dragStart._level === 0) {
1424
+ onSwap(_this7.dragStart, obj);
1425
+ } else {
1426
+ var startParents = _this7.dragStart._getParents().map(function (o) {
1427
+ return o._index;
1428
+ }).toString();
1429
+
1430
+ var endParents = obj._getParents().map(function (o) {
1431
+ return o._index;
1432
+ }).toString();
1433
+
1434
+ if (startParents !== endParents) {
1435
+ return;
1436
+ }
1437
+
1438
+ onSwap(_this7.dragStart, obj);
1439
+ }
1440
+ },
1441
+ onChangeFilter: onChangeFilter ? this.onChangeFilter.bind(this) : undefined,
980
1442
  SetState: function SetState(obj) {
981
- return _this6.setState(obj);
1443
+ return _this7.setState(obj);
982
1444
  },
983
1445
  cubes2: this.cubes2.bind(this),
1446
+ toggleRow: this.toggleRow.bind(this),
984
1447
  getGap: this.getGap.bind(this),
985
- getValueByField: this.getValueByField.bind(this),
986
1448
  onScroll: this.onScroll.bind(this),
987
1449
  onMouseEnter: this.onMouseEnter.bind(this),
988
1450
  getClient: this.getClient.bind(this),
989
1451
  getLoading: this.getLoading.bind(this),
990
1452
  groups: this.groups
991
1453
  };
992
- return /*#__PURE__*/_react.default.createElement(RTableContext.Provider, {
1454
+ return /*#__PURE__*/_react.default.createElement(AioTableContext.Provider, {
993
1455
  value: context
994
- }, /*#__PURE__*/_react.default.createElement("div", {
995
- className: 'r-table' + (className ? ' ' + className : '') + (rtl ? ' rtl' : ''),
1456
+ }, /*#__PURE__*/_react.default.createElement("div", _extends({
1457
+ className: 'aio-table' + (className ? ' ' + className : '') + (rtl ? ' rtl' : ''),
996
1458
  tabIndex: 0,
997
- ref: this.dom
998
- }, /*#__PURE__*/_react.default.createElement(RTableToolbar, this.toolbar), this.visibleColumns.length === 0 && this.getLoading(), table, /*#__PURE__*/_react.default.createElement("div", {
999
- style: {
1000
- height: rowGap
1001
- }
1002
- }), /*#__PURE__*/_react.default.createElement("div", {
1003
- style: {
1004
- flex: 1,
1005
- background: '#fff'
1459
+ ref: this.dom,
1460
+ style: { ...style,
1461
+ padding: padding
1006
1462
  }
1007
- }), this.getPaging()));
1463
+ }, attrs), Toolbar, !cardTemplate && this.visibleColumns.length === 0 && this.getLoading(), table, Paging));
1008
1464
  }
1009
1465
  }]);
1010
1466
 
1011
- return RTable;
1467
+ return AIOTable;
1012
1468
  }(_react.Component);
1013
1469
 
1014
- exports.default = RTable;
1015
- RTable.defaultProps = {
1470
+ exports.default = AIOTable;
1471
+ AIOTable.defaultProps = {
1016
1472
  columns: [],
1017
1473
  headerHeight: 36,
1018
1474
  rowHeight: 36,
1019
1475
  toolbarHeight: 36,
1020
1476
  rowGap: 6,
1477
+ padding: 12,
1021
1478
  indent: 20,
1022
1479
  translate: function translate(text) {
1023
1480
  return text;
1024
1481
  },
1025
- freezeSize: 300
1482
+ freezeSize: 300,
1483
+ sorts: [],
1484
+ groups: []
1026
1485
  };
1027
1486
 
1028
1487
  var RTableToolbar = /*#__PURE__*/function (_Component2) {
@@ -1031,21 +1490,9 @@ var RTableToolbar = /*#__PURE__*/function (_Component2) {
1031
1490
  var _super2 = _createSuper(RTableToolbar);
1032
1491
 
1033
1492
  function RTableToolbar() {
1034
- var _this7;
1035
-
1036
1493
  _classCallCheck(this, RTableToolbar);
1037
1494
 
1038
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1039
- args[_key] = arguments[_key];
1040
- }
1041
-
1042
- _this7 = _super2.call.apply(_super2, [this].concat(args));
1043
-
1044
- _defineProperty(_assertThisInitialized(_this7), "state", {
1045
- searchText: ''
1046
- });
1047
-
1048
- return _this7;
1495
+ return _super2.apply(this, arguments);
1049
1496
  }
1050
1497
 
1051
1498
  _createClass(RTableToolbar, [{
@@ -1053,8 +1500,10 @@ var RTableToolbar = /*#__PURE__*/function (_Component2) {
1053
1500
  value: function changeSearch(value) {
1054
1501
  var _this8 = this;
1055
1502
 
1503
+ var time = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
1504
+ var SetState = this.context.SetState;
1056
1505
  clearTimeout(this.searchTimeout);
1057
- this.setState({
1506
+ SetState({
1058
1507
  searchText: value
1059
1508
  });
1060
1509
  this.searchTimeout = setTimeout(function () {
@@ -1072,7 +1521,7 @@ var RTableToolbar = /*#__PURE__*/function (_Component2) {
1072
1521
  SetState({
1073
1522
  filterDictionary: filterDictionary
1074
1523
  });
1075
- }, 1000);
1524
+ }, time);
1076
1525
  }
1077
1526
  }, {
1078
1527
  key: "render",
@@ -1080,70 +1529,105 @@ var RTableToolbar = /*#__PURE__*/function (_Component2) {
1080
1529
  var _this9 = this;
1081
1530
 
1082
1531
  var _this$context = this.context,
1532
+ searchText = _this$context.searchText,
1083
1533
  translate = _this$context.translate,
1084
- rtl = _this$context.rtl;
1085
- var searchText = this.state.searchText;
1086
- var _this$props6 = this.props,
1087
- show = _this$props6.show,
1088
- toggle = _this$props6.toggle,
1089
- freeze = _this$props6.freeze,
1090
- groupBy = _this$props6.groupBy,
1091
- searchColumnIndex = _this$props6.searchColumnIndex;
1092
-
1093
- if (!show) {
1094
- return null;
1095
- }
1096
-
1534
+ rtl = _this$context.rtl,
1535
+ toggleAllState = _this$context.toggleAllState,
1536
+ padding = _this$context.padding;
1537
+ var _this$props8 = this.props,
1538
+ toggle = _this$props8.toggle,
1539
+ freeze = _this$props8.freeze,
1540
+ groupBy = _this$props8.groupBy,
1541
+ sort = _this$props8.sort,
1542
+ searchColumnIndex = _this$props8.searchColumnIndex,
1543
+ toggleAll = _this$props8.toggleAll;
1097
1544
  var buttonProps = {
1545
+ type: 'select',
1546
+ caret: false,
1098
1547
  rtl: rtl,
1099
- className: 'r-table-toolbar-dropdown',
1548
+ className: 'aio-table-toolbar-button',
1100
1549
  animate: true
1101
1550
  };
1102
1551
  return /*#__PURE__*/_react.default.createElement("div", {
1103
- className: "r-table-toolbar"
1104
- }, groupBy.length !== 0 && /*#__PURE__*/_react.default.createElement(_rDropdownButton.default, _extends({
1552
+ className: "aio-table-toolbar",
1553
+ style: {
1554
+ marginBottom: padding
1555
+ }
1556
+ }, toggleAll !== false && /*#__PURE__*/_react.default.createElement(_aioButton.default, _extends({
1105
1557
  key: 0
1106
1558
  }, buttonProps, {
1107
- items: groupBy,
1559
+ title: translate('Toggle All'),
1560
+ onClick: function onClick() {
1561
+ return toggleAll();
1562
+ },
1563
+ text: /*#__PURE__*/_react.default.createElement(_react2.Icon, {
1564
+ path: !toggleAllState ? _js.mdiCollapseAll : _js.mdiExpandAll,
1565
+ size: 0.7
1566
+ })
1567
+ })), searchColumnIndex !== false && /*#__PURE__*/_react.default.createElement("div", {
1568
+ key: 1,
1569
+ className: "aio-table-search"
1570
+ }, /*#__PURE__*/_react.default.createElement("input", {
1571
+ className: "aio-table-search-input",
1572
+ type: "text",
1573
+ value: searchText,
1574
+ placeholder: translate('Search'),
1575
+ onChange: function onChange(e) {
1576
+ return _this9.changeSearch(e.target.value);
1577
+ }
1578
+ }), /*#__PURE__*/_react.default.createElement(_react2.Icon, {
1579
+ className: "aio-table-search-icon",
1580
+ path: searchText ? _js.mdiClose : _js.mdiMagnify,
1581
+ size: 0.8,
1582
+ onClick: function onClick() {
1583
+ if (!searchText) {
1584
+ return;
1585
+ }
1586
+
1587
+ _this9.changeSearch('', 0);
1588
+ }
1589
+ })), searchColumnIndex === false && /*#__PURE__*/_react.default.createElement("div", {
1590
+ style: {
1591
+ flex: 1
1592
+ }
1593
+ }), groupBy.length > 1 && /*#__PURE__*/_react.default.createElement(_aioButton.default, _extends({
1594
+ key: 2
1595
+ }, buttonProps, {
1596
+ options: groupBy,
1108
1597
  title: translate('Group By'),
1109
- icon: /*#__PURE__*/_react.default.createElement(_react2.Icon, {
1598
+ text: /*#__PURE__*/_react.default.createElement(_react2.Icon, {
1110
1599
  path: _js.mdiFileTree,
1111
1600
  size: 0.7,
1112
1601
  horizontal: rtl === true
1113
1602
  })
1114
- })), toggle.length !== 0 && /*#__PURE__*/_react.default.createElement(_rDropdownButton.default, _extends({
1115
- key: 1
1603
+ })), sort.length > 1 && /*#__PURE__*/_react.default.createElement(_aioButton.default, _extends({
1604
+ key: 3
1116
1605
  }, buttonProps, {
1117
- icon: /*#__PURE__*/_react.default.createElement(_react2.Icon, {
1606
+ options: sort,
1607
+ title: translate('Sort'),
1608
+ text: /*#__PURE__*/_react.default.createElement(_react2.Icon, {
1609
+ path: _js.mdiSort,
1610
+ size: 0.7
1611
+ })
1612
+ })), toggle.length > 1 && /*#__PURE__*/_react.default.createElement(_aioButton.default, _extends({
1613
+ key: 4
1614
+ }, buttonProps, {
1615
+ text: /*#__PURE__*/_react.default.createElement(_react2.Icon, {
1118
1616
  path: _js.mdiEye,
1119
1617
  size: 0.7
1120
1618
  }),
1121
- items: toggle,
1619
+ options: toggle,
1122
1620
  title: translate('Show Columns')
1123
- })), freeze.length !== 0 && /*#__PURE__*/_react.default.createElement(_rDropdownButton.default, _extends({
1124
- key: 2
1621
+ })), freeze.length > 1 && /*#__PURE__*/_react.default.createElement(_aioButton.default, _extends({
1622
+ key: 5
1125
1623
  }, buttonProps, {
1126
- icon: /*#__PURE__*/_react.default.createElement(_react2.Icon, {
1624
+ text: /*#__PURE__*/_react.default.createElement(_react2.Icon, {
1127
1625
  path: _js.mdiAlignHorizontalLeft,
1128
1626
  size: 0.7,
1129
1627
  horizontal: rtl === true
1130
1628
  }),
1131
- items: freeze,
1629
+ options: freeze,
1132
1630
  title: translate('Freeze Columns')
1133
- })), searchColumnIndex !== false && /*#__PURE__*/_react.default.createElement("div", {
1134
- key: 3,
1135
- className: "r-table-search"
1136
- }, /*#__PURE__*/_react.default.createElement("input", {
1137
- className: "r-table-search-input",
1138
- type: "text",
1139
- value: searchText,
1140
- onChange: function onChange(e) {
1141
- return _this9.changeSearch(e.target.value);
1142
- }
1143
- }), /*#__PURE__*/_react.default.createElement(_react2.Icon, {
1144
- className: "r-table-search-icon",
1145
- path: _js.mdiMagnify,
1146
- size: 0.8
1147
1631
  })));
1148
1632
  }
1149
1633
  }]);
@@ -1151,7 +1635,7 @@ var RTableToolbar = /*#__PURE__*/function (_Component2) {
1151
1635
  return RTableToolbar;
1152
1636
  }(_react.Component);
1153
1637
 
1154
- _defineProperty(RTableToolbar, "contextType", RTableContext);
1638
+ _defineProperty(RTableToolbar, "contextType", AioTableContext);
1155
1639
 
1156
1640
  var RTableUnit = /*#__PURE__*/function (_Component3) {
1157
1641
  _inherits(RTableUnit, _Component3);
@@ -1171,22 +1655,24 @@ var RTableUnit = /*#__PURE__*/function (_Component3) {
1171
1655
  _createClass(RTableUnit, [{
1172
1656
  key: "getNoData",
1173
1657
  value: function getNoData() {
1174
- var rowHeight = this.context.rowHeight;
1658
+ var _this$context2 = this.context,
1659
+ rowHeight = _this$context2.rowHeight,
1660
+ translate = _this$context2.translate;
1175
1661
  return /*#__PURE__*/_react.default.createElement("div", {
1176
- className: "r-table-nodata",
1662
+ className: "aio-table-nodata",
1177
1663
  style: { ...this.getFullCellStyle(),
1178
1664
  height: rowHeight
1179
1665
  }
1180
- }, "\u062F\u06CC\u062A\u0627\u06CC\u06CC \u0645\u0648\u062C\u0648\u062F \u0646\u06CC\u0633\u062A");
1666
+ }, translate('No Data'));
1181
1667
  }
1182
1668
  }, {
1183
1669
  key: "getGroupToggleIcon",
1184
1670
  value: function getGroupToggleIcon(row) {
1185
- var _this$context2 = this.context,
1186
- rtl = _this$context2.rtl,
1187
- SetState = _this$context2.SetState,
1188
- groupsOpen = _this$context2.groupsOpen,
1189
- getGap = _this$context2.getGap;
1671
+ var _this$context3 = this.context,
1672
+ rtl = _this$context3.rtl,
1673
+ SetState = _this$context3.SetState,
1674
+ groupsOpen = _this$context3.groupsOpen,
1675
+ getGap = _this$context3.getGap;
1190
1676
  var icon;
1191
1677
 
1192
1678
  if (row._opened) {
@@ -1202,12 +1688,11 @@ var RTableUnit = /*#__PURE__*/function (_Component3) {
1202
1688
  });
1203
1689
  }
1204
1690
 
1205
- return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
1206
- className: "r-table-toggle",
1691
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
1692
+ className: "aio-table-toggle",
1207
1693
  onClick: function onClick() {
1208
- var _groupField = row._groupField,
1209
- _parentField = row._parentField;
1210
- groupsOpen[_parentField + _groupField] = !groupsOpen[_parentField + _groupField];
1694
+ var _groupId = row._groupId;
1695
+ groupsOpen[_groupId] = !groupsOpen[_groupId];
1211
1696
  SetState({
1212
1697
  groupsOpen: groupsOpen
1213
1698
  });
@@ -1226,19 +1711,24 @@ var RTableUnit = /*#__PURE__*/function (_Component3) {
1226
1711
  }, {
1227
1712
  key: "getStyle",
1228
1713
  value: function getStyle() {
1229
- var _this$context3 = this.context,
1230
- rowGap = _this$context3.rowGap,
1231
- columnGap = _this$context3.columnGap;
1232
- var _this$props7 = this.props,
1233
- columns = _this$props7.columns,
1234
- index = _this$props7.index,
1235
- style = _this$props7.style;
1714
+ var _this$context4 = this.context,
1715
+ rowGap = _this$context4.rowGap,
1716
+ columnGap = _this$context4.columnGap;
1717
+ var _this$props9 = this.props,
1718
+ columns = _this$props9.columns,
1719
+ style = _this$props9.style;
1236
1720
  var gridTemplateColumns = '';
1237
1721
  this.gridTemplateColumns = [];
1238
1722
 
1239
1723
  for (var i = 0; i < columns.length; i++) {
1240
1724
  var _columns$i$width = columns[i].width,
1241
1725
  width = _columns$i$width === void 0 ? 'auto' : _columns$i$width;
1726
+ width = width.toString();
1727
+
1728
+ if (width !== 'auto' && width.indexOf('px') === -1) {
1729
+ width += 'px';
1730
+ }
1731
+
1242
1732
  this.gridTemplateColumns.push(width);
1243
1733
  gridTemplateColumns += width + (i < columns.length - 1 ? ' ' : '');
1244
1734
  }
@@ -1263,13 +1753,15 @@ var RTableUnit = /*#__PURE__*/function (_Component3) {
1263
1753
  }, {
1264
1754
  key: "getGanttTitle",
1265
1755
  value: function getGanttTitle(column) {
1266
- var _this$context4 = this.context,
1267
- headerHeight = _this$context4.headerHeight,
1268
- columnGap = _this$context4.columnGap;
1269
- var keys = column.keys,
1270
- padding = column.padding;
1756
+ var _this$context5 = this.context,
1757
+ headerHeight = _this$context5.headerHeight,
1758
+ columnGap = _this$context5.columnGap;
1759
+ var getKeys = column.getKeys,
1760
+ _column$padding = column.padding,
1761
+ padding = _column$padding === void 0 ? '36px' : _column$padding;
1762
+ var keys = getKeys();
1271
1763
  return /*#__PURE__*/_react.default.createElement("div", {
1272
- className: "r-table-title r-table-title-gantt",
1764
+ className: "aio-table-title aio-table-title-gantt",
1273
1765
  style: {
1274
1766
  padding: "0 ".concat(padding),
1275
1767
  height: headerHeight,
@@ -1281,20 +1773,24 @@ var RTableUnit = /*#__PURE__*/function (_Component3) {
1281
1773
  }, /*#__PURE__*/_react.default.createElement(_rRangeSlider.default, {
1282
1774
  start: 0,
1283
1775
  end: keys.length - 1,
1284
- label: {
1285
- step: 1,
1286
- edit: function edit(value) {
1287
- return keys[value];
1288
- },
1289
- style: {
1776
+ labelStep: 1,
1777
+ editLabel: function editLabel(value) {
1778
+ return keys[value];
1779
+ },
1780
+ labelStyle: function labelStyle() {
1781
+ return {
1290
1782
  top: 0
1291
- }
1783
+ };
1292
1784
  },
1293
- pointStyle: {
1294
- display: 'none'
1785
+ pointStyle: function pointStyle() {
1786
+ return {
1787
+ display: 'none'
1788
+ };
1295
1789
  },
1296
- lineStyle: {
1297
- display: 'none'
1790
+ lineStyle: function lineStyle() {
1791
+ return {
1792
+ display: 'none'
1793
+ };
1298
1794
  }
1299
1795
  }));
1300
1796
  }
@@ -1307,24 +1803,12 @@ var RTableUnit = /*#__PURE__*/function (_Component3) {
1307
1803
  return this.getGanttTitle(column);
1308
1804
  }
1309
1805
 
1310
- var _this$context5 = this.context,
1311
- onChange = _this$context5.onChange,
1312
- columns = _this$context5.columns,
1313
- headerHeight = _this$context5.headerHeight,
1314
- columnGap = _this$context5.columnGap,
1315
- touch = _this$context5.touch;
1316
-
1317
- if (column.template === 'checkbox') {
1318
- if (column.checkAll) {
1319
- column.title = /*#__PURE__*/_react.default.createElement(_react2.Icon, {
1320
- path: _js.mdiCheckboxMarkedOutline,
1321
- size: 1
1322
- });
1323
- }
1324
-
1325
- column.center = true;
1326
- }
1327
-
1806
+ var _this$context6 = this.context,
1807
+ SetState = _this$context6.SetState,
1808
+ columns = _this$context6.columns,
1809
+ headerHeight = _this$context6.headerHeight,
1810
+ columnGap = _this$context6.columnGap,
1811
+ touch = _this$context6.touch;
1328
1812
  var props = {
1329
1813
  style: {
1330
1814
  height: headerHeight,
@@ -1334,20 +1818,23 @@ var RTableUnit = /*#__PURE__*/function (_Component3) {
1334
1818
  },
1335
1819
  key: column._index + 'title',
1336
1820
  draggable: false,
1337
- className: 'r-table-title'
1821
+ className: 'aio-table-title'
1338
1822
  };
1339
1823
 
1340
1824
  var resizeProps = _defineProperty({
1341
- className: 'r-table-resize',
1825
+ className: 'aio-table-resize',
1826
+ style: {
1827
+ cursor: column.resizable ? 'col-resize' : 'default'
1828
+ },
1342
1829
  draggable: false
1343
1830
  }, touch ? 'onTouchStart' : 'onMouseDown', function (e) {
1344
- return _this12.resizeDown(e, column);
1831
+ return column.resizable ? _this12.resizeDown(e, column) : undefined;
1345
1832
  });
1346
1833
 
1347
1834
  var titleProps = {
1348
- className: 'r-table-title-text',
1835
+ className: 'aio-table-title-text',
1349
1836
  style: {
1350
- justifyContent: column.center ? 'center' : undefined,
1837
+ justifyContent: column.titleJustify !== false ? 'center' : undefined,
1351
1838
  cursor: column.movable === false ? undefined : 'move'
1352
1839
  },
1353
1840
  draggable: column.movable !== false,
@@ -1363,19 +1850,16 @@ var RTableUnit = /*#__PURE__*/function (_Component3) {
1363
1850
  return;
1364
1851
  }
1365
1852
 
1366
- if (_this12.startColumnSwap === _this12.endColumnSwap) {
1853
+ if (_this12.startColumnSwap === undefined || _this12.startColumnSwap === _this12.endColumnSwap) {
1367
1854
  return;
1368
1855
  }
1369
1856
 
1370
1857
  var temp = columns[_this12.startColumnSwap];
1371
1858
  columns[_this12.startColumnSwap] = columns[_this12.endColumnSwap];
1372
1859
  columns[_this12.endColumnSwap] = temp;
1373
-
1374
- if (onChange) {
1375
- onChange({
1376
- columns: columns
1377
- });
1378
- }
1860
+ SetState({
1861
+ columns: columns
1862
+ });
1379
1863
  }
1380
1864
  };
1381
1865
  return /*#__PURE__*/_react.default.createElement("div", props, /*#__PURE__*/_react.default.createElement(RTableFilter, {
@@ -1385,9 +1869,9 @@ var RTableUnit = /*#__PURE__*/function (_Component3) {
1385
1869
  }, {
1386
1870
  key: "resizeDown",
1387
1871
  value: function resizeDown(e, column) {
1388
- var _this$context6 = this.context,
1389
- touch = _this$context6.touch,
1390
- getClient = _this$context6.getClient;
1872
+ var _this$context7 = this.context,
1873
+ touch = _this$context7.touch,
1874
+ getClient = _this$context7.getClient;
1391
1875
  (0, _jquery.default)(window).bind(touch ? 'touchmove' : 'mousemove', _jquery.default.proxy(this.resizeMove, this));
1392
1876
  (0, _jquery.default)(window).bind(touch ? 'touchend' : 'mouseup', _jquery.default.proxy(this.resizeUp, this));
1393
1877
  this.resizeDetails = {
@@ -1401,9 +1885,9 @@ var RTableUnit = /*#__PURE__*/function (_Component3) {
1401
1885
  }, {
1402
1886
  key: "resizeMove",
1403
1887
  value: function resizeMove(e) {
1404
- var _this$context7 = this.context,
1405
- rtl = _this$context7.rtl,
1406
- getClient = _this$context7.getClient;
1888
+ var _this$context8 = this.context,
1889
+ rtl = _this$context8.rtl,
1890
+ getClient = _this$context8.getClient;
1407
1891
  var Client = getClient(e);
1408
1892
  var _this$resizeDetails2 = this.resizeDetails,
1409
1893
  client = _this$resizeDetails2.client,
@@ -1430,29 +1914,48 @@ var RTableUnit = /*#__PURE__*/function (_Component3) {
1430
1914
  var touch = this.context.touch;
1431
1915
  (0, _jquery.default)(window).unbind(touch ? 'touchmove' : 'mousemove', this.resizeMove);
1432
1916
  (0, _jquery.default)(window).unbind(touch ? 'touchend' : 'mouseup', this.resizeUp);
1433
- var _this$context8 = this.context,
1434
- columns = _this$context8.columns,
1435
- _this$context8$onChan = _this$context8.onChange,
1436
- onChange = _this$context8$onChan === void 0 ? function () {} : _this$context8$onChan;
1917
+ var _this$context9 = this.context,
1918
+ columns = _this$context9.columns,
1919
+ SetState = _this$context9.SetState;
1437
1920
  var _this$resizeDetails3 = this.resizeDetails,
1438
1921
  index = _this$resizeDetails3.index,
1439
1922
  newWidth = _this$resizeDetails3.newWidth;
1440
- columns[index].width = newWidth;
1441
- onChange({
1923
+ var column = columns[index];
1924
+ column.width = newWidth;
1925
+
1926
+ if (column.storageKey) {
1927
+ column._storageObj.width = newWidth;
1928
+ localStorage.setItem('aio-table-column-storage-' + column.storageKey, JSON.stringify(column._storageObj));
1929
+ }
1930
+
1931
+ SetState({
1442
1932
  columns: columns
1443
1933
  });
1444
1934
  }
1445
1935
  }, {
1446
1936
  key: "keyDown",
1447
1937
  value: function keyDown(e) {
1448
- if ([37, 38, 39, 40].indexOf(e.keyCode) === -1) {
1449
- return;
1450
- }
1938
+ var SetState = this.context.SetState;
1451
1939
 
1940
+ if (e.keyCode === 27) {
1941
+ (0, _jquery.default)('.aio-table-input').blur();
1942
+ SetState({
1943
+ focused: false
1944
+ });
1945
+ } else if ([37, 38, 39, 40].indexOf(e.keyCode) !== -1) {
1946
+ this.arrow(e);
1947
+ }
1948
+ }
1949
+ }, {
1950
+ key: "arrow",
1951
+ value: function arrow(e) {
1452
1952
  var container = (0, _jquery.default)(this.dom.current);
1453
- var rtl = this.context.rtl;
1953
+ var _this$context10 = this.context,
1954
+ rtl = _this$context10.rtl,
1955
+ focused = _this$context10.focused,
1956
+ SetState = _this$context10.SetState;
1454
1957
  var columns = this.props.columns;
1455
- var inputs = container.find('.r-table-input');
1958
+ var inputs = container.find('.aio-table-input');
1456
1959
 
1457
1960
  if (inputs.length === 0) {
1458
1961
  return;
@@ -1460,12 +1963,24 @@ var RTableUnit = /*#__PURE__*/function (_Component3) {
1460
1963
 
1461
1964
  var focusedInput = inputs.filter(':focus');
1462
1965
 
1463
- if (focusedInput.length === 0) {
1464
- inputs.eq(0).focus().select();
1966
+ if (focused === false) {
1967
+ var inputCells = (0, _jquery.default)('.aio-table-cell-input');
1968
+
1969
+ if (inputCells.length) {
1970
+ var cell = inputCells.eq(0);
1971
+ var cellId = cell.attr('cellid');
1972
+ SetState({
1973
+ focused: cellId
1974
+ });
1975
+ setTimeout(function () {
1976
+ (0, _jquery.default)('.aio-table-cell-input[cellid=' + cellId + '] .aio-table-input').focus().select();
1977
+ }, 10);
1978
+ }
1979
+
1465
1980
  return;
1466
1981
  }
1467
1982
 
1468
- var _this$getCellIndex = this.getCellIndex(focusedInput.parents('.r-table-cell')),
1983
+ var _this$getCellIndex = this.getCellIndex(focusedInput.parents('.aio-table-cell')),
1469
1984
  rowIndex = _this$getCellIndex.rowIndex,
1470
1985
  colIndex = _this$getCellIndex.colIndex;
1471
1986
 
@@ -1520,29 +2035,50 @@ var RTableUnit = /*#__PURE__*/function (_Component3) {
1520
2035
  };
1521
2036
  }
1522
2037
  }, {
1523
- key: "render",
1524
- value: function render() {
2038
+ key: "card",
2039
+ value: function card() {
1525
2040
  var _this13 = this;
1526
2041
 
1527
- var _this$context9 = this.context,
1528
- indent = _this$context9.indent,
1529
- _onMouseEnter = _this$context9.onMouseEnter,
1530
- _onScroll = _this$context9.onScroll,
1531
- rowHeight = _this$context9.rowHeight,
1532
- groups = _this$context9.groups,
1533
- getLoading = _this$context9.getLoading;
1534
- var _this$props8 = this.props,
1535
- rows = _this$props8.rows,
1536
- id = _this$props8.id,
1537
- index = _this$props8.index,
1538
- type = _this$props8.type;
2042
+ var _this$context11 = this.context,
2043
+ indent = _this$context11.indent,
2044
+ _onMouseEnter = _this$context11.onMouseEnter,
2045
+ _onScroll = _this$context11.onScroll,
2046
+ rowHeight = _this$context11.rowHeight,
2047
+ _this$context11$cardG = _this$context11.cardGap,
2048
+ cardGap = _this$context11$cardG === void 0 ? 0 : _this$context11$cardG,
2049
+ getLoading = _this$context11.getLoading,
2050
+ cardTemplate = _this$context11.cardTemplate,
2051
+ _this$context11$cardR = _this$context11.cardRowCount,
2052
+ cardRowCount = _this$context11$cardR === void 0 ? 1 : _this$context11$cardR,
2053
+ rowGap = _this$context11.rowGap,
2054
+ columnGap = _this$context11.columnGap,
2055
+ toggleRow = _this$context11.toggleRow;
2056
+ var _this$props10 = this.props,
2057
+ rows = _this$props10.rows,
2058
+ id = _this$props10.id,
2059
+ index = _this$props10.index;
2060
+ var groupStyle = {
2061
+ gridColumnStart: 1,
2062
+ gridColumnEnd: cardRowCount + 1,
2063
+ height: rowHeight
2064
+ };
2065
+
2066
+ if (cardRowCount === 'auto') {
2067
+ groupStyle.gridColumnStart = undefined;
2068
+ groupStyle.gridColumnEnd = undefined;
2069
+ }
2070
+
1539
2071
  return /*#__PURE__*/_react.default.createElement("div", {
1540
2072
  id: id,
1541
2073
  tabIndex: 0,
1542
- className: "r-table-unit",
2074
+ className: "aio-table-unit",
1543
2075
  onKeyDown: this.keyDown.bind(this),
1544
- style: this.getStyle(),
1545
2076
  ref: this.dom,
2077
+ style: {
2078
+ gridRowGap: rowGap,
2079
+ gridColumnGap: columnGap,
2080
+ gridTemplateColumns: cardRowCount === 'auto' ? undefined : "repeat(".concat(cardRowCount, ",auto)")
2081
+ },
1546
2082
  onMouseEnter: function onMouseEnter() {
1547
2083
  return _onMouseEnter(index);
1548
2084
  },
@@ -1552,49 +2088,95 @@ var RTableUnit = /*#__PURE__*/function (_Component3) {
1552
2088
  onScroll: function onScroll(e) {
1553
2089
  return _onScroll(e, index);
1554
2090
  }
1555
- }, this.getTitles(), rows && rows.length !== 0 && rows.filter(function (row) {
1556
- return row.show !== false;
1557
- }).map(function (row, i) {
1558
- if (row._groupField) {
2091
+ }, rows && rows.length !== 0 && rows.map(function (row, i) {
2092
+ if (row._groupId) {
1559
2093
  var width = indent * row._level;
1560
2094
  return /*#__PURE__*/_react.default.createElement("div", {
1561
- className: "r-table-group",
2095
+ className: "aio-table-group",
1562
2096
  key: 'group' + i + '-' + index,
1563
- style: { ..._this13.getFullCellStyle(),
1564
- height: rowHeight
1565
- }
1566
- }, index !== 1 && /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
2097
+ style: groupStyle
2098
+ }, index !== 1 && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
1567
2099
  style: {
1568
- width: width
2100
+ width: width,
2101
+ flexShrink: 0
1569
2102
  }
1570
- }), _this13.getGroupToggleIcon(row), row._groupText));
2103
+ }), _this13.getGroupToggleIcon(row), /*#__PURE__*/_react.default.createElement("div", {
2104
+ className: "aio-table-group-text"
2105
+ }, row._groupValue)));
1571
2106
  }
1572
2107
 
1573
- if (type === 'freeze') {
1574
- return row.freezeCells.map(function (r, j) {
1575
- return /*#__PURE__*/_react.default.createElement(RTableCell, _extends({
1576
- key: i + '-' + j + '-' + index
1577
- }, r, {
1578
- relativeFilter: row.show === 'relativeFilter'
1579
- }));
1580
- });
1581
- }
2108
+ return /*#__PURE__*/_react.default.createElement("div", {
2109
+ key: i + '-' + index,
2110
+ className: "aio-table-card"
2111
+ }, cardTemplate(row.row, function () {
2112
+ return toggleRow(row.row);
2113
+ }));
2114
+ }), rows && rows.length === 0 && this.getNoData(), !rows && getLoading());
2115
+ }
2116
+ }, {
2117
+ key: "render",
2118
+ value: function render() {
2119
+ var _this14 = this;
1582
2120
 
1583
- if (type === 'unFreeze') {
1584
- return row.unFreezeCells.map(function (r, j) {
1585
- return /*#__PURE__*/_react.default.createElement(RTableCell, _extends({
1586
- key: i + '-' + j + '-' + index
1587
- }, r, {
1588
- relativeFilter: row.show === 'relativeFilter'
1589
- }));
1590
- });
2121
+ if (this.context.cardTemplate) {
2122
+ return this.card();
2123
+ }
2124
+
2125
+ var _this$context12 = this.context,
2126
+ indent = _this$context12.indent,
2127
+ _onMouseEnter2 = _this$context12.onMouseEnter,
2128
+ _onScroll2 = _this$context12.onScroll,
2129
+ rowHeight = _this$context12.rowHeight,
2130
+ groups = _this$context12.groups,
2131
+ getLoading = _this$context12.getLoading,
2132
+ cardTemplate = _this$context12.cardTemplate;
2133
+ var _this$props11 = this.props,
2134
+ rows = _this$props11.rows,
2135
+ id = _this$props11.id,
2136
+ index = _this$props11.index,
2137
+ type = _this$props11.type;
2138
+ return /*#__PURE__*/_react.default.createElement("div", {
2139
+ id: id,
2140
+ tabIndex: 0,
2141
+ className: "aio-table-unit",
2142
+ onKeyDown: this.keyDown.bind(this),
2143
+ style: this.getStyle(),
2144
+ ref: this.dom,
2145
+ onMouseEnter: function onMouseEnter() {
2146
+ return _onMouseEnter2(index);
2147
+ },
2148
+ onMouseDown: function onMouseDown() {
2149
+ return _onMouseEnter2(index);
2150
+ },
2151
+ onScroll: function onScroll(e) {
2152
+ return _onScroll2(e, index);
2153
+ }
2154
+ }, this.getTitles(), rows && rows.length !== 0 && rows.map(function (row, i) {
2155
+ if (row._groupId) {
2156
+ var width = indent * row._level;
2157
+ return /*#__PURE__*/_react.default.createElement("div", {
2158
+ className: "aio-table-group",
2159
+ key: 'group' + i + '-' + index,
2160
+ style: { ..._this14.getFullCellStyle(),
2161
+ height: rowHeight
2162
+ }
2163
+ }, index !== 1 && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
2164
+ style: {
2165
+ width: width,
2166
+ flexShrink: 0
2167
+ }
2168
+ }), _this14.getGroupToggleIcon(row), /*#__PURE__*/_react.default.createElement("div", {
2169
+ className: "aio-table-group-text"
2170
+ }, row._groupValue)));
1591
2171
  }
1592
2172
 
1593
- return row.cells.map(function (r, j) {
1594
- return /*#__PURE__*/_react.default.createElement(RTableCell, _extends({
1595
- key: i + '-' + j + '-' + index
2173
+ return row[type].map(function (r, j) {
2174
+ var id = i + '-' + j + '-' + index;
2175
+ return /*#__PURE__*/_react.default.createElement(AIOTableCell, _extends({
2176
+ key: id,
2177
+ cellId: id
1596
2178
  }, r, {
1597
- relativeFilter: row.show === 'relativeFilter'
2179
+ row: row.row
1598
2180
  }));
1599
2181
  });
1600
2182
  }), rows && rows.length === 0 && this.getNoData(), !rows && getLoading());
@@ -1604,69 +2186,74 @@ var RTableUnit = /*#__PURE__*/function (_Component3) {
1604
2186
  return RTableUnit;
1605
2187
  }(_react.Component);
1606
2188
 
1607
- _defineProperty(RTableUnit, "contextType", RTableContext);
2189
+ _defineProperty(RTableUnit, "contextType", AioTableContext);
1608
2190
 
1609
- var RTableCell = /*#__PURE__*/function (_Component4) {
1610
- _inherits(RTableCell, _Component4);
2191
+ var AIOTableCell = /*#__PURE__*/function (_Component4) {
2192
+ _inherits(AIOTableCell, _Component4);
1611
2193
 
1612
- var _super4 = _createSuper(RTableCell);
2194
+ var _super4 = _createSuper(AIOTableCell);
1613
2195
 
1614
- function RTableCell(props) {
1615
- var _this14;
2196
+ function AIOTableCell(props) {
2197
+ var _this15;
1616
2198
 
1617
- _classCallCheck(this, RTableCell);
2199
+ _classCallCheck(this, AIOTableCell);
1618
2200
 
1619
- _this14 = _super4.call(this, props);
1620
- _this14.dom = /*#__PURE__*/(0, _react.createRef)();
1621
- var value = _this14.props.value;
1622
- _this14.state = {
2201
+ _this15 = _super4.call(this, props);
2202
+ _this15.dom = /*#__PURE__*/(0, _react.createRef)();
2203
+ var value = _this15.props.value;
2204
+ _this15.state = {
1623
2205
  value: value,
1624
2206
  error: false,
1625
2207
  prevValue: value
1626
2208
  };
1627
- return _this14;
2209
+ return _this15;
1628
2210
  }
1629
2211
 
1630
- _createClass(RTableCell, [{
1631
- key: "getPrev",
1632
- value: function getPrev(row, column) {
1633
- if (!column.prev) {
2212
+ _createClass(AIOTableCell, [{
2213
+ key: "getBefore",
2214
+ value: function getBefore(row, column) {
2215
+ if (!column.before) {
1634
2216
  return '';
1635
2217
  }
1636
2218
 
1637
- var prev = typeof column.prev === 'function' ? column.prev(row, column) : column.prev;
1638
- return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
1639
- className: "r-table-icon"
1640
- }, prev), this.context.getGap());
2219
+ var before = typeof column.before === 'function' ? column.before(row, column) : column.before;
2220
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
2221
+ className: "aio-table-icon"
2222
+ }, before), this.context.getGap());
1641
2223
  }
1642
2224
  }, {
1643
- key: "getNext",
1644
- value: function getNext(row, column) {
1645
- if (!column.next) {
2225
+ key: "getAfter",
2226
+ value: function getAfter(row, column) {
2227
+ if (!column.after) {
1646
2228
  return '';
1647
2229
  }
1648
2230
 
1649
- var next = typeof column.next === 'function' ? column.next(row, column) : column.next;
1650
- return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, this.context.getGap(), /*#__PURE__*/_react.default.createElement("div", {
1651
- className: "r-table-icon"
1652
- }, next));
2231
+ var after = typeof column.after === 'function' ? column.after(row, column) : column.after;
2232
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
2233
+ style: {
2234
+ flex: 1
2235
+ }
2236
+ }), /*#__PURE__*/_react.default.createElement("div", {
2237
+ className: "aio-table-icon"
2238
+ }, after));
1653
2239
  }
1654
2240
  }, {
1655
2241
  key: "getStyle",
1656
2242
  value: function getStyle(column) {
2243
+ var _column$padding2 = column.padding,
2244
+ padding = _column$padding2 === void 0 ? '36px' : _column$padding2,
2245
+ template = column.template,
2246
+ _column$minWidth = column.minWidth,
2247
+ minWidth = _column$minWidth === void 0 ? '30px' : _column$minWidth;
1657
2248
  var rowHeight = this.context.rowHeight;
1658
- var _column$minWidth = column.minWidth,
1659
- minWidth = _column$minWidth === void 0 ? '30px' : _column$minWidth,
1660
- justify = column.justify;
1661
2249
  var style = {
1662
2250
  height: rowHeight,
1663
- overflow: column.template ? undefined : 'hidden',
1664
- minWidth: minWidth,
1665
- justifyContent: justify ? 'center' : undefined
2251
+ overflow: template ? undefined : 'hidden',
2252
+ minWidth: minWidth
1666
2253
  };
1667
2254
 
1668
2255
  if (column.template === 'gantt') {
1669
- style.padding = "0 ".concat(column.padding || '36px');
2256
+ style.padding = "0 ".concat(padding);
1670
2257
  }
1671
2258
 
1672
2259
  return style;
@@ -1674,23 +2261,26 @@ var RTableCell = /*#__PURE__*/function (_Component4) {
1674
2261
  }, {
1675
2262
  key: "getClassName",
1676
2263
  value: function getClassName(row, column) {
1677
- var relativeFilter = this.props.relativeFilter;
1678
- var className = 'r-table-cell';
2264
+ var className = 'aio-table-cell';
2265
+
2266
+ if (column.template) {
2267
+ className += ' aio-table-cell-template';
2268
+ }
1679
2269
 
1680
2270
  if (column.template === 'gantt') {
1681
- className += ' r-table-cell-gantt';
2271
+ className += ' aio-table-cell-gantt';
1682
2272
  }
1683
2273
 
1684
2274
  if (column.className) {
1685
2275
  className += ' ' + column.className;
1686
2276
  }
1687
2277
 
1688
- if (column.input) {
1689
- className += ' r-table-cell-input';
2278
+ if (column.inlineEdit) {
2279
+ className += ' aio-table-cell-input';
1690
2280
  }
1691
2281
 
1692
- if (relativeFilter) {
1693
- className += ' r-table-relative-filter';
2282
+ if (row._show === 'relativeFilter') {
2283
+ className += ' aio-table-relative-filter';
1694
2284
  }
1695
2285
 
1696
2286
  return className;
@@ -1698,13 +2288,9 @@ var RTableCell = /*#__PURE__*/function (_Component4) {
1698
2288
  }, {
1699
2289
  key: "getToggleIcon",
1700
2290
  value: function getToggleIcon(row) {
1701
- var _this$context10 = this.context,
1702
- rtl = _this$context10.rtl,
1703
- onChange = _this$context10.onChange,
1704
- model = _this$context10.model,
1705
- id = _this$context10.id,
1706
- openDictionary = _this$context10.openDictionary,
1707
- SetState = _this$context10.SetState;
2291
+ var _this$context13 = this.context,
2292
+ rtl = _this$context13.rtl,
2293
+ toggleRow = _this$context13.toggleRow;
1708
2294
  var icon;
1709
2295
 
1710
2296
  if (!row._childsLength) {
@@ -1725,71 +2311,40 @@ var RTableCell = /*#__PURE__*/function (_Component4) {
1725
2311
  });
1726
2312
  }
1727
2313
 
1728
- return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
1729
- className: "r-table-toggle",
2314
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
2315
+ className: "aio-table-toggle",
1730
2316
  onClick: function onClick() {
1731
- if (row._id !== undefined) {
1732
- openDictionary[row._id] = !openDictionary[row._id];
1733
-
1734
- if (id !== undefined) {
1735
- localStorage.setItem('r table ' + id, JSON.stringify(openDictionary));
1736
- }
1737
-
1738
- SetState({
1739
- openDictionary: openDictionary
1740
- });
1741
- } else {
1742
- row._opened = !row._opened;
1743
- onChange({
1744
- model: model
1745
- });
1746
- }
2317
+ return toggleRow(row);
1747
2318
  }
1748
2319
  }, icon), this.context.getGap());
1749
2320
  }
1750
- }, {
1751
- key: "getCheckbox",
1752
- value: function getCheckbox(row, column) {
1753
- var _index = column._index,
1754
- _column$onChange = column.onChange,
1755
- onChange = _column$onChange === void 0 ? function () {} : _column$onChange,
1756
- _column$disabled = column.disabled,
1757
- disabled = _column$disabled === void 0 ? function () {
1758
- return false;
1759
- } : _column$disabled;
1760
- row._values[_index] = row._values[_index] === true ? true : false;
1761
- var value = row._values[_index];
1762
- var isDisabled = disabled(row);
1763
- return /*#__PURE__*/_react.default.createElement("div", {
1764
- className: 'r-table-checkbox' + (isDisabled ? ' disabled' : ''),
1765
- onClick: function onClick() {
1766
- if (!isDisabled) {
1767
- onChange(row, !value);
1768
- }
1769
- }
1770
- }, /*#__PURE__*/_react.default.createElement(_react2.Icon, {
1771
- path: value ? _js.mdiCheckboxMarkedOutline : _js.mdiCheckboxBlankOutline,
1772
- size: 1
1773
- }));
1774
- }
1775
2321
  }, {
1776
2322
  key: "getContent",
1777
2323
  value: function getContent(row, column, value) {
2324
+ var focused = this.context.focused;
1778
2325
  var content = '';
2326
+ var template = typeof column.template === 'function' ? column.template(row, column) : column.template;
1779
2327
 
1780
- if (column.template === 'checkbox') {
1781
- content = this.getCheckbox(row, column);
1782
- } else if (column.template === 'gantt') {
1783
- var _this$context11 = this.context,
1784
- getValueByField = _this$context11.getValueByField,
1785
- rtl = _this$context11.rtl;
1786
- var keys = column.keys,
1787
- _column$color = column.color,
1788
- color = _column$color === void 0 ? '#69bedb' : _column$color,
1789
- _column$progressColor = column.progressColor,
1790
- progressColor = _column$progressColor === void 0 ? '#1891be' : _column$progressColor,
1791
- _column$flags = column.flags,
1792
- flags = _column$flags === void 0 ? [] : _column$flags,
2328
+ if (template === 'slider') {
2329
+ content = /*#__PURE__*/_react.default.createElement(AIOSlider, {
2330
+ row: row,
2331
+ column: column
2332
+ });
2333
+ } else if (template === 'gantt') {
2334
+ var rtl = this.context.rtl;
2335
+ var getKeys = column.getKeys,
2336
+ _column$getColor = column.getColor,
2337
+ getColor = _column$getColor === void 0 ? function () {
2338
+ return '#fff';
2339
+ } : _column$getColor,
2340
+ _column$getBackground = column.getBackgroundColor,
2341
+ getBackgroundColor = _column$getBackground === void 0 ? function () {
2342
+ return '#69bedb';
2343
+ } : _column$getBackground,
2344
+ _column$getFlags = column.getFlags,
2345
+ getFlags = _column$getFlags === void 0 ? function () {
2346
+ return [];
2347
+ } : _column$getFlags,
1793
2348
  _column$getProgress = column.getProgress,
1794
2349
  getProgress = _column$getProgress === void 0 ? function () {
1795
2350
  return false;
@@ -1797,73 +2352,115 @@ var RTableCell = /*#__PURE__*/function (_Component4) {
1797
2352
  _column$getText = column.getText,
1798
2353
  getText = _column$getText === void 0 ? function () {
1799
2354
  return false;
1800
- } : _column$getText;
2355
+ } : _column$getText,
2356
+ getStart = column.getStart,
2357
+ getEnd = column.getEnd;
2358
+
2359
+ if (typeof getStart !== 'function') {
2360
+ console.error('aio table => gantt column => column getStart property is not a function');
2361
+ return '';
2362
+ }
2363
+
2364
+ if (typeof getEnd !== 'function') {
2365
+ console.error('aio table => gantt column => column getEnd property is not a function');
2366
+ return '';
2367
+ }
2368
+
2369
+ if (typeof getKeys !== 'function') {
2370
+ console.error('aio table => gantt column => column getKeys property is not a function');
2371
+ return '';
2372
+ }
2373
+
2374
+ var keys = getKeys();
2375
+
2376
+ if (!Array.isArray(keys)) {
2377
+ console.error('aio table => gantt column => column getKeys property must return an array of strings');
2378
+ return '';
2379
+ }
2380
+
2381
+ var color = getColor(row);
2382
+ var backgroundColor = getBackgroundColor(row);
1801
2383
  var progress = getProgress(row);
1802
2384
  var text = getText(row);
1803
- var startIndex = keys.indexOf(getValueByField(row, column.startField));
1804
- var endIndex = keys.indexOf(getValueByField(row, column.endField));
1805
- var background = progress === false ? color : "linear-gradient(to ".concat(rtl ? 'left' : 'right', ",").concat(progressColor, " 0%,").concat(progressColor, " ").concat(progress, "% ,").concat(color, " ").concat(progress, "%,").concat(color, " 100%)");
2385
+ var startIndex = keys.indexOf(getStart(row));
2386
+ var endIndex = keys.indexOf(getEnd(row));
2387
+ var background = progress === false ? color : "linear-gradient(to ".concat(rtl ? 'left' : 'right', ",rgba(0,0,0,.1) 0%,rgba(0,0,0,.1) ").concat(progress, "% ,transparent ").concat(progress, "%,transparent 100%)");
2388
+ var flags = getFlags();
1806
2389
  content = /*#__PURE__*/_react.default.createElement(_rRangeSlider.default, {
1807
2390
  start: 0,
1808
- editValue: function editValue(_ref) {
1809
- var value = _ref.value;
2391
+ editValue: function editValue(value) {
1810
2392
  return keys[value];
1811
2393
  },
1812
2394
  end: keys.length - 1,
1813
- points: [{
1814
- value: startIndex
1815
- }, {
1816
- value: endIndex,
1817
- fillStyle: {
1818
- background: background
1819
- },
1820
- text: text === false ? undefined : text
1821
- }],
1822
- pin: {
1823
- step: 1,
1824
- style: {
2395
+ points: [startIndex, endIndex],
2396
+ fillStyle: function fillStyle(index) {
2397
+ if (index === 1) {
2398
+ return {
2399
+ background: backgroundColor,
2400
+ backgroundImage: background
2401
+ };
2402
+ }
2403
+ },
2404
+ getText: function getText(index) {
2405
+ if (index === 1 && text) {
2406
+ return text;
2407
+ }
2408
+ },
2409
+ textStyle: function textStyle() {
2410
+ return {
2411
+ color: color
2412
+ };
2413
+ },
2414
+ scaleStep: 1,
2415
+ scaleStyle: function scaleStyle(value) {
2416
+ var flag = flags.filter(function (o) {
2417
+ return keys.indexOf(o.value) === value;
2418
+ })[0];
2419
+
2420
+ if (flag) {
2421
+ return {
2422
+ background: flag.color,
2423
+ height: '100%',
2424
+ top: 0,
2425
+ zIndex: 100
2426
+ };
2427
+ }
2428
+
2429
+ return {
1825
2430
  height: '100%',
1826
2431
  top: 0,
1827
2432
  opacity: .4
1828
- },
1829
- items: flags.map(function (_ref2) {
1830
- var index = _ref2.index,
1831
- value = _ref2.value,
1832
- _ref2$color = _ref2.color,
1833
- color = _ref2$color === void 0 ? 'red' : _ref2$color;
1834
- var flag = index !== undefined ? index : keys.indexOf(value);
1835
- return {
1836
- value: flag,
1837
- style: {
1838
- background: color,
1839
- height: '100%',
1840
- top: 0
1841
- }
1842
- };
1843
- })
2433
+ };
1844
2434
  },
1845
- lineStyle: {
1846
- opacity: .4
2435
+ lineStyle: function lineStyle() {
2436
+ return {
2437
+ opacity: .4
2438
+ };
1847
2439
  }
1848
2440
  });
1849
- } else if (column.template) {
1850
- content = /*#__PURE__*/_react.default.createElement("div", {
1851
- style: {
1852
- flex: 1,
1853
- alignItems: 'center'
1854
- }
1855
- }, column.template(row, column));
1856
- } else if (column.input) {
2441
+ } else if (template && column.inlineEdit) {
2442
+ if (!focused) {
2443
+ content = template;
2444
+ } else {
2445
+ content = this.getInput(row, column);
2446
+ }
2447
+ } else if (template) {
2448
+ content = template;
2449
+ } else if (column.inlineEdit) {
1857
2450
  content = this.getInput(row, column);
1858
- } else if (column.field) {
1859
- content = /*#__PURE__*/_react.default.createElement("div", {
1860
- style: {
1861
- flex: 1
1862
- }
1863
- }, value);
2451
+ } else if (column.getValue) {
2452
+ content = value;
1864
2453
  }
1865
2454
 
1866
2455
  if (column.subText) {
2456
+ var subText;
2457
+
2458
+ try {
2459
+ subText = column.subText(row);
2460
+ } catch {
2461
+ subText = '';
2462
+ }
2463
+
1867
2464
  return /*#__PURE__*/_react.default.createElement("div", {
1868
2465
  style: {
1869
2466
  flex: 1,
@@ -1889,7 +2486,7 @@ var RTableCell = /*#__PURE__*/function (_Component4) {
1889
2486
  flex: 1,
1890
2487
  position: 'relative'
1891
2488
  }
1892
- }, column.subText(row)));
2489
+ }, subText));
1893
2490
  }
1894
2491
 
1895
2492
  return content;
@@ -1897,87 +2494,107 @@ var RTableCell = /*#__PURE__*/function (_Component4) {
1897
2494
  }, {
1898
2495
  key: "getInput",
1899
2496
  value: function getInput(row, column) {
1900
- var _this15 = this;
2497
+ var _this16 = this;
1901
2498
 
1902
- var type = column.input.type;
2499
+ var type = column.inlineEdit.type;
1903
2500
  var value = this.state.value;
1904
- var props = { ...column.input,
1905
- className: 'r-table-input',
2501
+ var _column$inlineEdit$di = column.inlineEdit.disabled,
2502
+ disabled = _column$inlineEdit$di === void 0 ? function () {
2503
+ return false;
2504
+ } : _column$inlineEdit$di;
2505
+ var props = { ...column.inlineEdit,
2506
+ className: 'aio-table-input',
1906
2507
  rowindex: row._renderIndex,
1907
2508
  colindex: column._renderIndex,
1908
- value: value
2509
+ value: value === null ? '' : value,
2510
+ disabled: disabled(row)
1909
2511
  };
1910
2512
 
1911
2513
  if (type === 'text' || type === 'number') {
1912
2514
  return /*#__PURE__*/_react.default.createElement("div", {
1913
- className: "r-table-input-container"
2515
+ className: 'aio-table-input-container'
1914
2516
  }, /*#__PURE__*/_react.default.createElement("input", _extends({}, props, {
2517
+ style: {
2518
+ textAlign: column.justify ? 'center' : undefined
2519
+ },
1915
2520
  onChange: function onChange(e) {
1916
- return _this15.setState({
2521
+ return _this16.setState({
1917
2522
  value: e.target.value
1918
2523
  });
1919
2524
  },
1920
2525
  onBlur: async function onBlur(e) {
1921
- _this15.setState({
2526
+ _this16.setState({
1922
2527
  loading: true
1923
2528
  });
1924
2529
 
1925
- var error = await column.input.onChange(value, row);
2530
+ var error = await column.inlineEdit.onChange(row, type === 'number' ? parseFloat(value) : value);
1926
2531
 
1927
- _this15.setState({
2532
+ _this16.setState({
1928
2533
  loading: false
1929
2534
  });
1930
2535
 
1931
2536
  if (typeof error === 'string') {
1932
- _this15.setState({
2537
+ _this16.setState({
1933
2538
  error: error
1934
2539
  });
1935
2540
  }
1936
2541
  }
1937
2542
  })), /*#__PURE__*/_react.default.createElement("div", {
1938
- className: "r-table-input-border"
2543
+ className: "aio-table-input-border"
1939
2544
  }));
1940
2545
  }
1941
2546
 
1942
2547
  if (type === 'select') {
2548
+ if (!column.inlineEdit.options) {
2549
+ console.error('aio table => missing options property of column inlineEdit with type="select"');
2550
+ return '';
2551
+ }
2552
+
2553
+ if (!Array.isArray(column.inlineEdit.options)) {
2554
+ 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!!!');
2555
+ return '';
2556
+ }
2557
+
1943
2558
  return /*#__PURE__*/_react.default.createElement("div", {
1944
- className: "r-table-input-container"
2559
+ className: "aio-table-input-container"
1945
2560
  }, /*#__PURE__*/_react.default.createElement("select", _extends({}, props, {
1946
2561
  onFocus: function onFocus() {
1947
- return _this15.focus = true;
2562
+ return _this16.focus = true;
1948
2563
  },
1949
2564
  onBlur: function onBlur() {
1950
- return _this15.focus = false;
2565
+ return _this16.focus = false;
1951
2566
  },
1952
2567
  onChange: async function onChange(e) {
1953
2568
  var value = e.target.value;
1954
2569
 
1955
- _this15.setState({
2570
+ _this16.setState({
1956
2571
  loading: true,
1957
2572
  value: value
1958
2573
  });
1959
2574
 
1960
- var error = await column.input.onChange(e.target.value, row);
2575
+ var error = await column.inlineEdit.onChange(row, e.target.value);
1961
2576
 
1962
- _this15.setState({
2577
+ _this16.setState({
1963
2578
  loading: false
1964
2579
  });
1965
2580
 
1966
2581
  if (typeof error === 'string') {
1967
- _this15.setState({
2582
+ _this16.setState({
1968
2583
  error: error
1969
2584
  });
1970
2585
  }
1971
2586
  }
1972
- }), column.input.options.map(function (o) {
2587
+ }), column.inlineEdit.options.map(function (o, i) {
1973
2588
  return /*#__PURE__*/_react.default.createElement("option", {
2589
+ key: i,
1974
2590
  value: o.value
1975
2591
  }, o.text);
1976
2592
  })), /*#__PURE__*/_react.default.createElement("div", {
1977
- className: "r-table-input-border"
2593
+ className: "aio-table-input-border"
1978
2594
  }));
1979
2595
  }
1980
2596
 
2597
+ console.error('aio table => missing type property of column input');
1981
2598
  return '';
1982
2599
  }
1983
2600
  }, {
@@ -1985,23 +2602,28 @@ var RTableCell = /*#__PURE__*/function (_Component4) {
1985
2602
  value: function componentDidUpdate() {
1986
2603
  var column = this.props.column;
1987
2604
 
1988
- if (column.input && column.input.type === 'select' && this.focus) {
1989
- (0, _jquery.default)(this.dom.current).find('.r-table-input').focus();
2605
+ if (column.inlineEdit && column.inlineEdit.type === 'select' && this.focus) {
2606
+ (0, _jquery.default)(this.dom.current).find('.aio-table-input').focus();
1990
2607
  }
1991
2608
  }
1992
2609
  }, {
1993
2610
  key: "render",
1994
2611
  value: function render() {
1995
- var _this16 = this;
2612
+ var _this17 = this;
1996
2613
 
1997
- var _this$context12 = this.context,
1998
- indent = _this$context12.indent,
1999
- onChange = _this$context12.onChange,
2000
- cubes2 = _this$context12.cubes2;
2001
- var _this$props9 = this.props,
2002
- row = _this$props9.row,
2003
- column = _this$props9.column,
2004
- value = _this$props9.value;
2614
+ var _this$context14 = this.context,
2615
+ indent = _this$context14.indent,
2616
+ cubes2 = _this$context14.cubes2,
2617
+ focused = _this$context14.focused,
2618
+ SetState = _this$context14.SetState,
2619
+ onDrag = _this$context14.onDrag,
2620
+ _onDrop = _this$context14.onDrop,
2621
+ onSwap = _this$context14.onSwap;
2622
+ var _this$props12 = this.props,
2623
+ row = _this$props12.row,
2624
+ column = _this$props12.column,
2625
+ value = _this$props12.value,
2626
+ cellId = _this$props12.cellId;
2005
2627
 
2006
2628
  if (this.state.prevValue !== value) {
2007
2629
  this.setState({
@@ -2010,13 +2632,13 @@ var RTableCell = /*#__PURE__*/function (_Component4) {
2010
2632
  });
2011
2633
  }
2012
2634
 
2013
- var _this$state = this.state,
2014
- error = _this$state.error,
2015
- loading = _this$state.loading;
2635
+ var _this$state3 = this.state,
2636
+ error = _this$state3.error,
2637
+ loading = _this$state3.loading;
2016
2638
  var content = this.getContent(row, column, value);
2017
- var prev = this.getPrev(row, column);
2018
- var next = this.getNext(row, column);
2019
- var showToggleIcon = column.treeMode && (row._id !== undefined || onChange);
2639
+ var before = this.getBefore(row, column);
2640
+ var after = this.getAfter(row, column);
2641
+ var showToggleIcon = column.treeMode;
2020
2642
  var cell;
2021
2643
 
2022
2644
  if (loading) {
@@ -2025,27 +2647,35 @@ var RTableCell = /*#__PURE__*/function (_Component4) {
2025
2647
 
2026
2648
  if (error) {
2027
2649
  cell = /*#__PURE__*/_react.default.createElement("div", {
2028
- className: "r-table-error",
2650
+ className: "aio-table-error",
2029
2651
  onClick: function onClick() {
2030
- _this16.setState({
2031
- value: _this16.props.value,
2652
+ _this17.setState({
2653
+ value: _this17.props.value,
2032
2654
  error: false
2033
2655
  });
2034
2656
  }
2035
2657
  }, error);
2036
2658
  } else {
2037
- cell = /*#__PURE__*/_react.default.createElement(_react.Fragment, null, column.treeMode && /*#__PURE__*/_react.default.createElement("div", {
2038
- className: "r-table-indent",
2659
+ var style = {
2660
+ justifyContent: column.justify !== false && !column.treeMode ? 'center' : undefined
2661
+ };
2662
+ cell = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, column.treeMode && /*#__PURE__*/_react.default.createElement("div", {
2663
+ className: "aio-table-indent",
2039
2664
  style: {
2040
2665
  width: row._level * indent
2041
2666
  }
2042
- }), showToggleIcon && this.getToggleIcon(row), prev, content, next);
2667
+ }), showToggleIcon && this.getToggleIcon(row), before, /*#__PURE__*/_react.default.createElement("div", {
2668
+ className: "aio-table-content",
2669
+ style: style
2670
+ }, content), after);
2043
2671
  }
2044
2672
 
2045
2673
  return /*#__PURE__*/_react.default.createElement("div", {
2046
2674
  key: row._index + '-' + column._index,
2047
2675
  tabIndex: 0,
2048
2676
  ref: this.dom,
2677
+ cellid: cellId,
2678
+ title: typeof content === 'string' ? content : '',
2049
2679
  rowindex: row._renderIndex,
2050
2680
  colindex: column._renderIndex,
2051
2681
  childindex: row._childIndex,
@@ -2055,41 +2685,255 @@ var RTableCell = /*#__PURE__*/function (_Component4) {
2055
2685
  childslength: row._childsLength,
2056
2686
  style: this.getStyle(column),
2057
2687
  className: this.getClassName(row, column),
2058
- onClick: function onClick(e) {}
2688
+ draggable: typeof onSwap === 'function' && column.swap,
2689
+ onDragOver: function onDragOver(e) {
2690
+ return e.preventDefault();
2691
+ },
2692
+ onDragStart: function onDragStart() {
2693
+ return onDrag(row);
2694
+ },
2695
+ onDrop: function onDrop() {
2696
+ return _onDrop(row);
2697
+ },
2698
+ onClick: function onClick(e) {
2699
+ if (column.inlineEdit) {
2700
+ if (focused !== cellId) {
2701
+ SetState({
2702
+ focused: cellId
2703
+ });
2704
+ setTimeout(function () {
2705
+ return (0, _jquery.default)('.aio-table-input:focus').select();
2706
+ }, 10);
2707
+ }
2708
+ }
2709
+ }
2059
2710
  }, cell);
2060
2711
  }
2061
2712
  }]);
2062
2713
 
2063
- return RTableCell;
2714
+ return AIOTableCell;
2064
2715
  }(_react.Component);
2065
2716
 
2066
- _defineProperty(RTableCell, "contextType", RTableContext);
2717
+ _defineProperty(AIOTableCell, "contextType", AioTableContext);
2067
2718
 
2068
- var RTableFilter = /*#__PURE__*/function (_Component5) {
2069
- _inherits(RTableFilter, _Component5);
2719
+ var AIOSlider = /*#__PURE__*/function (_Component5) {
2720
+ _inherits(AIOSlider, _Component5);
2721
+
2722
+ var _super5 = _createSuper(AIOSlider);
2723
+
2724
+ function AIOSlider(props) {
2725
+ var _this18;
2070
2726
 
2071
- var _super5 = _createSuper(RTableFilter);
2727
+ _classCallCheck(this, AIOSlider);
2728
+
2729
+ _this18 = _super5.call(this, props);
2730
+ var _this18$props = _this18.props,
2731
+ column = _this18$props.column,
2732
+ row = _this18$props.row;
2733
+ var getValue = column.getValue;
2734
+ var value = getValue(row);
2735
+
2736
+ if (!Array.isArray(value)) {
2737
+ value = [value];
2738
+ }
2739
+
2740
+ _this18.state = {
2741
+ value: value
2742
+ };
2743
+ _this18.updateMode = 'outside';
2744
+ return _this18;
2745
+ }
2746
+
2747
+ _createClass(AIOSlider, [{
2748
+ key: "getBackground",
2749
+ value: function getBackground(length, i, color) {
2750
+ if (length === 1 && i === 0) {
2751
+ return color;
2752
+ }
2753
+
2754
+ if (length > 1 && i > 0 && i < length) {
2755
+ return color;
2756
+ }
2757
+
2758
+ return 'transparent';
2759
+ }
2760
+ }, {
2761
+ key: "render",
2762
+ value: function render() {
2763
+ var _this19 = this;
2764
+
2765
+ var _this$props13 = this.props,
2766
+ column = _this$props13.column,
2767
+ row = _this$props13.row;
2768
+ var getValue = column.getValue,
2769
+ _column$getStart = column.getStart,
2770
+ getStart = _column$getStart === void 0 ? function () {
2771
+ return 0;
2772
+ } : _column$getStart,
2773
+ _column$getEnd = column.getEnd,
2774
+ getEnd = _column$getEnd === void 0 ? function () {
2775
+ return 100;
2776
+ } : _column$getEnd,
2777
+ _column$getColor2 = column.getColor,
2778
+ getColor = _column$getColor2 === void 0 ? function () {
2779
+ return 'dodgerblue';
2780
+ } : _column$getColor2,
2781
+ onChange = column.onChange,
2782
+ _column$getMin = column.getMin,
2783
+ getMin = _column$getMin === void 0 ? function () {} : _column$getMin,
2784
+ _column$getMax = column.getMax,
2785
+ getMax = _column$getMax === void 0 ? function () {} : _column$getMax,
2786
+ _column$editValue = column.editValue,
2787
+ editValue = _column$editValue === void 0 ? function (value) {
2788
+ return value;
2789
+ } : _column$editValue,
2790
+ _column$getStep = column.getStep,
2791
+ getStep = _column$getStep === void 0 ? function () {} : _column$getStep;
2792
+ var value = this.state.value;
2793
+ var Value = getValue(row);
2794
+
2795
+ if (Value === false) {
2796
+ return null;
2797
+ }
2798
+
2799
+ if (!Array.isArray(Value)) {
2800
+ Value = [Value];
2801
+ }
2802
+
2803
+ if (this.updateMode === 'onChange') {
2804
+ this.updateMode = 'outside';
2805
+ this.setState({
2806
+ value: Value
2807
+ });
2808
+ return null;
2809
+ } else if (this.updateMode === 'outside' && JSON.stringify(Value) !== JSON.stringify(value)) {
2810
+ this.setState({
2811
+ value: Value
2812
+ });
2813
+ return null;
2814
+ }
2815
+
2816
+ var start = getStart(row);
2817
+ var end = getEnd(row);
2818
+ var color = getColor(row);
2819
+ var min = getMin(row);
2820
+ var max = getMax(row);
2821
+ var step = getStep(row);
2822
+ var pinItems = [];
2823
+
2824
+ if (min !== undefined) {
2825
+ pinItems.push({
2826
+ value: min,
2827
+ style: {
2828
+ height: 10
2829
+ }
2830
+ });
2831
+ }
2832
+
2833
+ if (max !== undefined) {
2834
+ pinItems.push({
2835
+ value: max,
2836
+ style: {
2837
+ height: 10
2838
+ }
2839
+ });
2840
+ }
2841
+
2842
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, value.length > 1 && /*#__PURE__*/_react.default.createElement("div", {
2843
+ className: "aio-table-slider-value"
2844
+ }, editValue(value[0])), /*#__PURE__*/_react.default.createElement(_rRangeSlider.default, {
2845
+ start: start,
2846
+ end: end,
2847
+ min: min,
2848
+ max: max,
2849
+ step: step,
2850
+ showValue: false,
2851
+ points: value.map(function (o, i) {
2852
+ return {
2853
+ value: o,
2854
+ fillStyle: {
2855
+ height: '6px',
2856
+ borderRadius: '24px',
2857
+ background: _this19.getBackground(value.length, i, color)
2858
+ }
2859
+ };
2860
+ }),
2861
+ pointStyle: {
2862
+ opacity: 0,
2863
+ height: 24,
2864
+ width: 24
2865
+ },
2866
+ lineStyle: {
2867
+ height: 6,
2868
+ borderRadius: '24px',
2869
+ boxShadow: 'inset 0px 1px 3px 0px rgba(0,0,0,.1)',
2870
+ background: '#d5d5d5'
2871
+ },
2872
+ editable: typeof onChange === 'function',
2873
+ onchange: function onchange(_ref) {
2874
+ var points = _ref.points;
2875
+
2876
+ if (!onChange) {
2877
+ return;
2878
+ }
2879
+
2880
+ _this19.updateMode = 'onChange';
2881
+ onChange(row, points.length > 1 ? points.map(function (p) {
2882
+ return p.value;
2883
+ }) : points[0].value);
2884
+ },
2885
+ pin: pinItems.length === 0 ? undefined : {
2886
+ items: pinItems
2887
+ },
2888
+ ondrag: function ondrag(_ref2) {
2889
+ var points = _ref2.points;
2890
+ _this19.updateMode = 'onDrag';
2891
+
2892
+ _this19.setState({
2893
+ value: points.map(function (p) {
2894
+ return p.value;
2895
+ })
2896
+ });
2897
+ }
2898
+ }), /*#__PURE__*/_react.default.createElement("div", {
2899
+ className: "aio-table-slider-value"
2900
+ }, editValue(value.length > 1 ? value[1] : value[0])));
2901
+ }
2902
+ }]);
2903
+
2904
+ return AIOSlider;
2905
+ }(_react.Component);
2906
+
2907
+ var RTableFilter = /*#__PURE__*/function (_Component6) {
2908
+ _inherits(RTableFilter, _Component6);
2909
+
2910
+ var _super6 = _createSuper(RTableFilter);
2072
2911
 
2073
2912
  function RTableFilter() {
2074
2913
  _classCallCheck(this, RTableFilter);
2075
2914
 
2076
- return _super5.apply(this, arguments);
2915
+ return _super6.apply(this, arguments);
2077
2916
  }
2078
2917
 
2079
2918
  _createClass(RTableFilter, [{
2080
2919
  key: "render",
2081
2920
  value: function render() {
2082
- var _this$context13 = this.context,
2083
- filterDictionary = _this$context13.filterDictionary,
2084
- rtl = _this$context13.rtl;
2921
+ var _this$context15 = this.context,
2922
+ filterDictionary = _this$context15.filterDictionary,
2923
+ rtl = _this$context15.rtl;
2085
2924
  var column = this.props.column;
2086
2925
 
2087
2926
  if (!column.filter || column.search) {
2088
2927
  return null;
2089
2928
  }
2090
2929
 
2930
+ if (!filterDictionary[column._index]) {
2931
+ return null;
2932
+ }
2933
+
2091
2934
  var filters = filterDictionary[column._index].items;
2092
2935
  var icon = filters.length ? /*#__PURE__*/_react.default.createElement(_react2.Icon, {
2936
+ className: "has-filter",
2093
2937
  path: _js.mdiFilterMenu,
2094
2938
  size: 0.7
2095
2939
  }) : /*#__PURE__*/_react.default.createElement(_react2.Icon, {
@@ -2097,11 +2941,13 @@ var RTableFilter = /*#__PURE__*/function (_Component5) {
2097
2941
  size: 0.7
2098
2942
  });
2099
2943
  return /*#__PURE__*/_react.default.createElement("div", {
2100
- className: "r-table-filter-icon"
2101
- }, /*#__PURE__*/_react.default.createElement(_rDropdownButton.default, {
2944
+ className: "aio-table-filter-icon"
2945
+ }, /*#__PURE__*/_react.default.createElement(_aioButton.default, {
2946
+ type: "button",
2102
2947
  rtl: rtl,
2948
+ openRelatedTo: ".aio-table",
2103
2949
  text: icon,
2104
- items: function items() {
2950
+ popOver: function popOver() {
2105
2951
  return /*#__PURE__*/_react.default.createElement(RTableFilterPopup, {
2106
2952
  column: column
2107
2953
  });
@@ -2113,25 +2959,26 @@ var RTableFilter = /*#__PURE__*/function (_Component5) {
2113
2959
  return RTableFilter;
2114
2960
  }(_react.Component);
2115
2961
 
2116
- _defineProperty(RTableFilter, "contextType", RTableContext);
2962
+ _defineProperty(RTableFilter, "contextType", AioTableContext);
2117
2963
 
2118
- var RTableFilterPopup = /*#__PURE__*/function (_Component6) {
2119
- _inherits(RTableFilterPopup, _Component6);
2964
+ var RTableFilterPopup = /*#__PURE__*/function (_Component7) {
2965
+ _inherits(RTableFilterPopup, _Component7);
2120
2966
 
2121
- var _super6 = _createSuper(RTableFilterPopup);
2967
+ var _super7 = _createSuper(RTableFilterPopup);
2122
2968
 
2123
2969
  function RTableFilterPopup() {
2124
2970
  _classCallCheck(this, RTableFilterPopup);
2125
2971
 
2126
- return _super6.apply(this, arguments);
2972
+ return _super7.apply(this, arguments);
2127
2973
  }
2128
2974
 
2129
2975
  _createClass(RTableFilterPopup, [{
2130
2976
  key: "add",
2131
2977
  value: function add() {
2132
- var _this$context14 = this.context,
2133
- filterDictionary = _this$context14.filterDictionary,
2134
- SetState = _this$context14.SetState;
2978
+ var _this$context16 = this.context,
2979
+ filterDictionary = _this$context16.filterDictionary,
2980
+ SetState = _this$context16.SetState,
2981
+ onChangeFilter = _this$context16.onChangeFilter;
2135
2982
  var column = this.props.column;
2136
2983
 
2137
2984
  filterDictionary[column._index].items.push({
@@ -2139,6 +2986,10 @@ var RTableFilterPopup = /*#__PURE__*/function (_Component6) {
2139
2986
  value: ''
2140
2987
  });
2141
2988
 
2989
+ if (onChangeFilter) {
2990
+ onChangeFilter(filterDictionary);
2991
+ }
2992
+
2142
2993
  SetState({
2143
2994
  filterDictionary: filterDictionary
2144
2995
  });
@@ -2146,13 +2997,13 @@ var RTableFilterPopup = /*#__PURE__*/function (_Component6) {
2146
2997
  }, {
2147
2998
  key: "render",
2148
2999
  value: function render() {
2149
- var _this17 = this;
3000
+ var _this20 = this;
2150
3001
 
2151
3002
  var column = this.props.column;
2152
- var _this$context15 = this.context,
2153
- filterDictionary = _this$context15.filterDictionary,
2154
- SetState = _this$context15.SetState,
2155
- translate = _this$context15.translate;
3003
+ var _this$context17 = this.context,
3004
+ filterDictionary = _this$context17.filterDictionary,
3005
+ SetState = _this$context17.SetState,
3006
+ translate = _this$context17.translate;
2156
3007
  var filters = filterDictionary[column._index].items;
2157
3008
  var booleanType = filterDictionary[column._index].booleanType;
2158
3009
  var filterItems = filters.map(function (filter, i) {
@@ -2163,7 +3014,7 @@ var RTableFilterPopup = /*#__PURE__*/function (_Component6) {
2163
3014
  column: column,
2164
3015
  index: i
2165
3016
  }), i < filters.length - 1 && /*#__PURE__*/_react.default.createElement("div", {
2166
- className: "r-table-boolean",
3017
+ className: "aio-table-boolean",
2167
3018
  onClick: function onClick() {
2168
3019
  var newBooleanType = booleanType === 'or' ? 'and' : 'or';
2169
3020
  filterDictionary[column._index].booleanType = newBooleanType;
@@ -2174,13 +3025,16 @@ var RTableFilterPopup = /*#__PURE__*/function (_Component6) {
2174
3025
  }, translate(booleanType)));
2175
3026
  });
2176
3027
  return /*#__PURE__*/_react.default.createElement("div", {
2177
- className: "r-table-filter-popup"
3028
+ className: "aio-table-filter-popup",
3029
+ style: {
3030
+ minWidth: 250
3031
+ }
2178
3032
  }, filterItems, /*#__PURE__*/_react.default.createElement("div", {
2179
- className: "r-table-filter-footer"
3033
+ className: "aio-table-filter-footer"
2180
3034
  }, /*#__PURE__*/_react.default.createElement("button", {
2181
- className: "r-table-filter-add",
3035
+ className: "aio-table-filter-add",
2182
3036
  onClick: function onClick() {
2183
- return _this17.add();
3037
+ return _this20.add();
2184
3038
  }
2185
3039
  }, translate('Add'))));
2186
3040
  }
@@ -2189,37 +3043,42 @@ var RTableFilterPopup = /*#__PURE__*/function (_Component6) {
2189
3043
  return RTableFilterPopup;
2190
3044
  }(_react.Component);
2191
3045
 
2192
- _defineProperty(RTableFilterPopup, "contextType", RTableContext);
3046
+ _defineProperty(RTableFilterPopup, "contextType", AioTableContext);
2193
3047
 
2194
- var RTableFilterItem = /*#__PURE__*/function (_Component7) {
2195
- _inherits(RTableFilterItem, _Component7);
3048
+ var RTableFilterItem = /*#__PURE__*/function (_Component8) {
3049
+ _inherits(RTableFilterItem, _Component8);
2196
3050
 
2197
- var _super7 = _createSuper(RTableFilterItem);
3051
+ var _super8 = _createSuper(RTableFilterItem);
2198
3052
 
2199
3053
  function RTableFilterItem(props) {
2200
- var _this18;
3054
+ var _this21;
2201
3055
 
2202
3056
  _classCallCheck(this, RTableFilterItem);
2203
3057
 
2204
- _this18 = _super7.call(this, props);
2205
- var filter = _this18.props.filter;
2206
- _this18.state = {
3058
+ _this21 = _super8.call(this, props);
3059
+ var filter = _this21.props.filter;
3060
+ _this21.state = {
2207
3061
  value: filter.value,
2208
3062
  prevValue: filter.value
2209
3063
  };
2210
- return _this18;
3064
+ return _this21;
2211
3065
  }
2212
3066
 
2213
3067
  _createClass(RTableFilterItem, [{
2214
3068
  key: "remove",
2215
3069
  value: function remove(index) {
2216
- var _this$context16 = this.context,
2217
- filterDictionary = _this$context16.filterDictionary,
2218
- SetState = _this$context16.SetState;
3070
+ var _this$context18 = this.context,
3071
+ filterDictionary = _this$context18.filterDictionary,
3072
+ SetState = _this$context18.SetState,
3073
+ onChangeFilter = _this$context18.onChangeFilter;
2219
3074
  var column = this.props.column;
2220
3075
 
2221
3076
  filterDictionary[column._index].items.splice(index, 1);
2222
3077
 
3078
+ if (onChangeFilter) {
3079
+ onChangeFilter(filterDictionary);
3080
+ }
3081
+
2223
3082
  SetState({
2224
3083
  filterDictionary: filterDictionary
2225
3084
  });
@@ -2227,20 +3086,26 @@ var RTableFilterItem = /*#__PURE__*/function (_Component7) {
2227
3086
  }, {
2228
3087
  key: "changeValue",
2229
3088
  value: function changeValue(value) {
2230
- var _this19 = this;
3089
+ var _this22 = this;
2231
3090
 
3091
+ var onChangeFilter = this.context.onChangeFilter;
2232
3092
  clearTimeout(this.timeout);
2233
3093
  this.setState({
2234
3094
  value: value
2235
3095
  });
2236
3096
  this.timeout = setTimeout(function () {
2237
- var _this19$context = _this19.context,
2238
- SetState = _this19$context.SetState,
2239
- filterDictionary = _this19$context.filterDictionary;
2240
- var _this19$props = _this19.props,
2241
- column = _this19$props.column,
2242
- index = _this19$props.index;
3097
+ var _this22$context = _this22.context,
3098
+ SetState = _this22$context.SetState,
3099
+ filterDictionary = _this22$context.filterDictionary;
3100
+ var _this22$props = _this22.props,
3101
+ column = _this22$props.column,
3102
+ index = _this22$props.index;
2243
3103
  filterDictionary[column._index].items[index].value = value;
3104
+
3105
+ if (onChangeFilter) {
3106
+ onChangeFilter(filterDictionary);
3107
+ }
3108
+
2244
3109
  SetState({
2245
3110
  filterDictionary: filterDictionary
2246
3111
  });
@@ -2249,16 +3114,17 @@ var RTableFilterItem = /*#__PURE__*/function (_Component7) {
2249
3114
  }, {
2250
3115
  key: "render",
2251
3116
  value: function render() {
2252
- var _this20 = this;
2253
-
2254
- var _this$context17 = this.context,
2255
- filterDictionary = _this$context17.filterDictionary,
2256
- SetState = _this$context17.SetState,
2257
- translate = _this$context17.translate;
2258
- var _this$props10 = this.props,
2259
- filter = _this$props10.filter,
2260
- column = _this$props10.column,
2261
- index = _this$props10.index;
3117
+ var _this23 = this;
3118
+
3119
+ var _this$context19 = this.context,
3120
+ filterDictionary = _this$context19.filterDictionary,
3121
+ SetState = _this$context19.SetState,
3122
+ translate = _this$context19.translate,
3123
+ onChangeFilter = _this$context19.onChangeFilter;
3124
+ var _this$props14 = this.props,
3125
+ filter = _this$props14.filter,
3126
+ column = _this$props14.column,
3127
+ index = _this$props14.index;
2262
3128
 
2263
3129
  if (this.state.prevValue !== filter.value) {
2264
3130
  this.setState({
@@ -2269,13 +3135,19 @@ var RTableFilterItem = /*#__PURE__*/function (_Component7) {
2269
3135
  }
2270
3136
 
2271
3137
  var value = this.state.value;
2272
- var type = column.filter.type;
3138
+ var _column$filter$type = column.filter.type,
3139
+ type = _column$filter$type === void 0 ? 'text' : _column$filter$type;
2273
3140
  return /*#__PURE__*/_react.default.createElement("div", {
2274
- className: "r-table-filter-item"
3141
+ className: "aio-table-filter-item"
2275
3142
  }, /*#__PURE__*/_react.default.createElement("select", {
2276
3143
  value: filter.operator,
2277
3144
  onChange: function onChange(e) {
2278
3145
  filterDictionary[column._index].items[index].operator = e.target.value;
3146
+
3147
+ if (onChangeFilter) {
3148
+ onChangeFilter(filterDictionary);
3149
+ }
3150
+
2279
3151
  SetState({
2280
3152
  filterDictionary: filterDictionary
2281
3153
  });
@@ -2300,16 +3172,16 @@ var RTableFilterItem = /*#__PURE__*/function (_Component7) {
2300
3172
  type: type,
2301
3173
  value: value,
2302
3174
  onChange: function onChange(e) {
2303
- return _this20.changeValue(e.target.value);
3175
+ return _this23.changeValue(e.target.value);
2304
3176
  }
2305
3177
  }), /*#__PURE__*/_react.default.createElement("div", {
2306
3178
  style: {
2307
3179
  width: '6px'
2308
3180
  }
2309
3181
  }), /*#__PURE__*/_react.default.createElement("div", {
2310
- className: "r-table-filter-remove",
3182
+ className: "aio-table-filter-remove",
2311
3183
  onClick: function onClick() {
2312
- return _this20.remove(index);
3184
+ return _this23.remove(index);
2313
3185
  }
2314
3186
  }, /*#__PURE__*/_react.default.createElement(_react2.Icon, {
2315
3187
  path: _js.mdiClose,
@@ -2321,4 +3193,4 @@ var RTableFilterItem = /*#__PURE__*/function (_Component7) {
2321
3193
  return RTableFilterItem;
2322
3194
  }(_react.Component);
2323
3195
 
2324
- _defineProperty(RTableFilterItem, "contextType", RTableContext);
3196
+ _defineProperty(RTableFilterItem, "contextType", AioTableContext);