aio-table 7.0.1 → 7.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.css +195 -516
  2. package/index.js +1096 -3672
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -3,16 +3,24 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = exports.AIOTableFilterPopup = void 0;
6
+ exports.default = void 0;
7
7
 
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
 
10
- var _aioButton = _interopRequireDefault(require("aio-button"));
10
+ var _react2 = require("@mdi/react");
11
11
 
12
- var _jquery = _interopRequireDefault(require("jquery"));
12
+ var _js = require("@mdi/js");
13
13
 
14
14
  var _rRangeSlider = _interopRequireDefault(require("r-range-slider"));
15
15
 
16
+ var _aioButton = _interopRequireDefault(require("aio-button"));
17
+
18
+ var _aioValidation = _interopRequireDefault(require("aio-validation"));
19
+
20
+ var _aioTable = _interopRequireDefault(require("./aio-table/aio-table"));
21
+
22
+ var _reactVirtualDom = _interopRequireDefault(require("react-virtual-dom"));
23
+
16
24
  require("./index.css");
17
25
 
18
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -21,3858 +29,1274 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
21
29
 
22
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; }
23
31
 
24
- 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; }
25
-
26
32
  function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
27
33
 
28
- var AioTableContext = /*#__PURE__*/(0, _react.createContext)();
29
-
30
- class AIOTable extends _react.Component {
34
+ class AIOForm extends _react.Component {
31
35
  constructor(props) {
32
36
  super(props);
33
- this.fn = new ATFN({
34
- getProps: () => this.props,
35
- getState: () => this.state,
36
- setState: (obj, caller) => this.SetState(obj, caller),
37
- getContext: () => this.context
38
- });
39
- let touch = ('ontouchstart' in document.documentElement);
40
- this.dom = /*#__PURE__*/(0, _react.createRef)();
41
- var {
42
- freezeSize,
43
- paging,
44
- columns,
45
- groups = []
37
+ let {
38
+ model,
39
+ theme = {}
46
40
  } = this.props;
47
- let cardRowCount = this.fn.getCardRowCount();
48
- let openDictionary = this.fn.getOpenDictionary();
49
- let copiedColumns = [...columns];
50
41
  this.state = {
51
- touch,
52
- openDictionary,
53
- cardRowCount,
54
- groups,
55
- groupsOpen: {},
56
- searchText: '',
57
- freezeSize,
58
- startIndex: 0,
59
- //make imutable to prevent change of props.paging because that will compaire with next input props.paging
60
- paging: paging ? { ...paging
61
- } : false,
62
- prevPaging: JSON.stringify(paging),
63
- columns: copiedColumns,
64
- prevColumns: JSON.stringify(copiedColumns),
65
- focused: false,
66
- toggleAllState: true
42
+ initialModel: JSON.stringify(model),
43
+ model,
44
+ theme
67
45
  };
68
46
  }
69
47
 
70
- resizeDown(e) {
71
- var {
72
- touch
73
- } = this.state;
74
- (0, _jquery.default)(window).bind(touch ? 'touchmove' : 'mousemove', _jquery.default.proxy(this.resizeMove, this));
75
- (0, _jquery.default)(window).bind(touch ? 'touchend' : 'mouseup', _jquery.default.proxy(this.resizeUp, this));
76
- this.resizeDetails = {
77
- client: this.fn.getClient(e),
78
- width: this.state.freezeSize
79
- };
48
+ getModel() {
49
+ return this.props.onSubmit ? this.state.model : this.props.model;
80
50
  }
81
51
 
82
- resizeMove(e) {
83
- var {
84
- rtl
85
- } = this.props;
86
- var Client = this.fn.getClient(e);
87
- var {
88
- client,
89
- width
90
- } = this.resizeDetails;
91
- var offset = Client[0] - client[0];
92
- let newWidth = width + offset * (rtl ? -1 : 1);
93
-
94
- if (newWidth < 10) {
95
- newWidth = 10;
52
+ getValue(field, def, props = this.props) {
53
+ let model = this.getModel(),
54
+ {
55
+ data = {}
56
+ } = this.props,
57
+ a;
58
+
59
+ if (typeof field === 'string' && field.indexOf('calc ') === 0) {
60
+ try {
61
+ a = eval(field.slice(5, field.length));
62
+ } catch {
63
+ a = def;
64
+ }
65
+ } else {
66
+ a = field;
96
67
  }
97
68
 
98
- this.resizeDetails.newWidth = newWidth;
99
- (0, _jquery.default)('#aio-table-first-split').css({
100
- width: newWidth
101
- });
69
+ return a;
102
70
  }
103
71
 
104
- resizeUp() {
105
- var {
106
- touch
107
- } = this.state;
108
- (0, _jquery.default)(window).unbind(touch ? 'touchmove' : 'mousemove', this.resizeMove);
109
- (0, _jquery.default)(window).unbind(touch ? 'touchend' : 'mouseup', this.resizeUp);
110
- this.setState({
111
- freezeSize: this.resizeDetails.newWidth
112
- });
72
+ setValue(field, value, model = this.getModel()) {
73
+ eval(`model.${field} = value`);
74
+ return model;
113
75
  }
114
76
 
115
- getTable({
116
- sorts,
117
- freezeColumns,
118
- unFreezeColumns,
119
- columns
120
- }) {
121
- let {
122
- freezeSize
123
- } = this.state;
77
+ onChange(input, value) {
124
78
  let {
125
- cardTemplate
79
+ onChange,
80
+ onSubmit
126
81
  } = this.props;
127
- let freezeMode = freezeColumns.length !== 0 && unFreezeColumns.length !== 0;
128
- let rows = this.getRows(sorts, freezeMode);
129
- this.rows = rows;
130
- return /*#__PURE__*/_react.default.createElement("div", {
131
- className: 'aio-table-body'
132
- }, !freezeMode && columns.length !== 0 && /*#__PURE__*/_react.default.createElement(AIOTableUnit, {
133
- rows: rows,
134
- columns: columns,
135
- type: "cells"
136
- }), freezeMode && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(AIOTableUnit, {
137
- key: 0,
138
- id: "aio-table-first-split",
139
- rows: rows,
140
- columns: freezeColumns,
141
- tableIndex: 0,
142
- type: "freezeCells",
143
- style: {
144
- width: freezeSize
145
- }
146
- }), /*#__PURE__*/_react.default.createElement("div", {
147
- className: "aio-table-splitter",
148
- onMouseDown: e => this.resizeDown(e),
149
- onTouchStart: e => this.resizeDown(e)
150
- }), /*#__PURE__*/_react.default.createElement(AIOTableUnit, {
151
- key: 1,
152
- id: "aio-table-second-split",
153
- rows: rows,
154
- columns: unFreezeColumns,
155
- tableIndex: 1,
156
- type: "unFreezeCells"
157
- })), cardTemplate && /*#__PURE__*/_react.default.createElement(AIOTableUnit, {
158
- rows: rows
159
- }));
160
- }
161
82
 
162
- getRows(sorts, freezeMode) {
163
- var {
164
- model
165
- } = this.props;
83
+ if (onSubmit) {
84
+ this.setState({
85
+ model: this.setValue(input.field, value)
86
+ });
87
+ } else {
88
+ if (input.onChange) {
89
+ return input.onChange(value);
90
+ }
166
91
 
167
- if (!model) {
168
- return false;
92
+ onChange(this.setValue(input.field, value));
169
93
  }
94
+ }
170
95
 
96
+ getInputTheme(input) {
171
97
  let {
172
- groups
98
+ theme: stateTheme = {}
173
99
  } = this.state;
174
- this.index = {
175
- render: 0,
176
- real: 0
100
+ let {
101
+ theme: inputTheme = {}
102
+ } = input;
103
+ return { ...stateTheme,
104
+ ...inputTheme
177
105
  };
178
- let rows;
179
- rows = this.fn.getRowsNested([...model], '_childs');
180
- rows = this.fn.getRowsBySort(rows, sorts.filter(({
181
- active = true
182
- }) => active));
183
- rows = this.fn.getRows(rows, freezeMode);
184
- rows = this.fn.getRootsByPaging(rows, this.index);
185
- rows = this.fn.getRootsByGroup(rows, groups.filter(({
186
- active = true
187
- }) => active));
188
- return this.fn.getRowsByRoots(rows);
189
106
  }
190
107
 
191
- handleIncomingProps() {
192
- let {
193
- paging
194
- } = this.props;
195
- let {
196
- prevPaging
197
- } = this.state;
198
- let p = JSON.stringify(paging);
108
+ getInput_text({
109
+ className,
110
+ value,
111
+ onChange,
112
+ options,
113
+ disabled,
114
+ style,
115
+ placeholder
116
+ }, input) {
117
+ let props = { ...input.attrs,
118
+ autoHeight: input.autoHeight,
119
+ type: input.type,
120
+ value,
121
+ className,
122
+ onChange,
123
+ options,
124
+ disabled,
125
+ style,
126
+ placeholder,
127
+ options
128
+ };
129
+ return /*#__PURE__*/_react.default.createElement(Text, props);
130
+ }
199
131
 
200
- if (p !== prevPaging) {
201
- setTimeout(() => this.setState({
202
- paging: { ...paging
203
- },
204
- prevPaging: p
205
- }), 0);
206
- }
132
+ getInput_number(obj, input) {
133
+ return this.getInput_text(obj, input);
207
134
  }
208
135
 
209
- getCellAttrs(row, column) {
210
- let {
211
- cellAttrs = {}
212
- } = column;
213
- return (typeof cellAttrs === 'function' ? cellAttrs(row) : cellAttrs) || {};
136
+ getInput_password(obj, input) {
137
+ return this.getInput_text(obj, input);
214
138
  }
215
139
 
216
- SetState(obj, caller) {
217
- this.setState(obj);
140
+ getInput_textarea(obj, input) {
141
+ return this.getInput_text(obj, input);
218
142
  }
219
143
 
220
- render() {
221
- this.handleIncomingProps();
222
- var {
223
- rowHeight,
224
- headerHeight,
225
- toolbarHeight,
226
- rowGap,
144
+ getInput_checkbox({
145
+ className,
146
+ onChange,
147
+ value,
148
+ disabled,
149
+ style,
150
+ text,
151
+ subtext,
152
+ theme
153
+ }, input) {
154
+ let props = {
155
+ disabled,
156
+ style,
157
+ value,
158
+ subtext: input.subText,
159
+ text,
160
+ subtext,
161
+ onChange: value => onChange(!value),
227
162
  className,
228
- columnGap,
229
- rtl,
163
+ iconSize: theme.checkIconSize,
164
+ iconColor: theme.checkIconColor
165
+ };
166
+ return /*#__PURE__*/_react.default.createElement(_aioButton.default, _extends({}, props, {
167
+ type: "checkbox"
168
+ }));
169
+ }
170
+
171
+ getInput_checklist({
172
+ className,
173
+ options: Options,
174
+ disabled,
175
+ style,
176
+ theme
177
+ }, input) {
178
+ let options = Options.map(o => {
179
+ let model = this.getModel(),
180
+ value = this.getValue('calc model.' + o.field),
181
+ text = o.text;
182
+ return {
183
+ text,
184
+ value,
185
+ onChange: (val, obj) => {
186
+ this.onChange({
187
+ field: o.field,
188
+ onChange: o.onChange
189
+ }, !val);
190
+ },
191
+ ...o
192
+ };
193
+ });
194
+ let {
195
+ input: inputTheme = {}
196
+ } = theme;
197
+ let props = {
198
+ options,
199
+ disabled,
230
200
  style,
231
- attrs = {},
232
- cardTemplate,
233
- onSwap,
234
- translate
235
- } = this.props;
236
- var {
237
- paging
238
- } = this.state;
239
- this.rh = rowHeight;
240
- this.hh = headerHeight;
241
- this.th = toolbarHeight;
242
- this.rg = rowGap;
243
- this.cg = columnGap;
244
- let details = this.fn.getDetails();
245
- var context = { ...this.props,
246
- ...this.state,
247
- details,
248
- onDrag: obj => this.dragStart = obj,
249
- onDrop: obj => {
250
- if (!this.dragStart) {
251
- return;
252
- }
201
+ optionSubtext: input.optionSubtext,
202
+ className,
203
+ options,
204
+ optionClassName: '"aio-form-input"',
205
+ optionStyle: () => {
206
+ return {
207
+ width: input.optionWidth || 'fit-content',
208
+ height: inputTheme.height,
209
+ padding: inputTheme.padding,
210
+ background: 'none'
211
+ };
212
+ },
213
+ optionIconSize: theme.checkIconSize,
214
+ optionIconColor: theme.checkIconColor
215
+ };
216
+ return /*#__PURE__*/_react.default.createElement(_aioButton.default, _extends({}, props, {
217
+ type: "checklist"
218
+ }));
219
+ }
253
220
 
254
- if (this.dragStart._level !== obj._level) {
255
- return;
256
- }
221
+ getInput_radio({
222
+ value,
223
+ onChange,
224
+ options,
225
+ disabled,
226
+ style,
227
+ className,
228
+ theme
229
+ }, input) {
230
+ let {
231
+ input: inputTheme = {}
232
+ } = theme;
233
+ let props = {
234
+ options,
235
+ value,
236
+ onChange,
237
+ disabled,
238
+ style,
239
+ optionSubtext: input.optionSubtext,
240
+ optionText: input.optionText,
241
+ optionValue: input.optionValue,
242
+ className,
243
+ optionClassName: '"aio-form-input"',
244
+ optionStyle: () => {
245
+ return {
246
+ width: input.optionWidth || 'fit-content',
247
+ height: inputTheme.height,
248
+ padding: inputTheme.padding,
249
+ background: 'none'
250
+ };
251
+ },
252
+ optionIconSize: theme.checkIconSize,
253
+ optionIconColor: theme.checkIconColor
254
+ };
255
+ return /*#__PURE__*/_react.default.createElement(_aioButton.default, _extends({}, props, {
256
+ type: "radio"
257
+ }));
258
+ }
257
259
 
258
- if (this.dragStart._level === 0) {
259
- onSwap(this.dragStart, obj);
260
- } else {
261
- let startParents = this.dragStart._getParents().map(o => o._index).toString();
260
+ getInput_slider({
261
+ className,
262
+ value,
263
+ onChange,
264
+ disabled,
265
+ style,
266
+ start,
267
+ end
268
+ }, input) {
269
+ let editValue;
262
270
 
263
- let endParents = obj._getParents().map(o => o._index).toString();
271
+ if (typeof input.editValue === 'string') {
272
+ let str = input.editValue;
264
273
 
265
- if (startParents !== endParents) {
266
- return;
267
- }
274
+ if (str.indexOf('calc ') === 0) {
275
+ str = str.slice(5, str.length);
276
+ }
268
277
 
269
- onSwap(this.dragStart, obj);
278
+ editValue = value => {
279
+ let res;
280
+
281
+ try {
282
+ eval(`res = ${str}`);
283
+ } catch {
284
+ res = value;
270
285
  }
271
- },
272
- SetState: this.SetState.bind(this),
273
- onScroll: index => this.fn.onScroll(this.dom, index),
274
- getCellAttrs: this.getCellAttrs.bind(this),
275
- fn: this.fn,
276
- rows: this.rows
286
+
287
+ return res;
288
+ };
289
+ } else {
290
+ editValue = input.editValue;
291
+ }
292
+
293
+ let props = {
294
+ className,
295
+ value,
296
+ onChange,
297
+ start,
298
+ end,
299
+ step: input.step,
300
+ disabled,
301
+ style,
302
+ editValue
277
303
  };
278
- this.context = context;
279
- let table = this.getTable(details);
280
- return /*#__PURE__*/_react.default.createElement(AioTableContext.Provider, {
281
- value: context
282
- }, /*#__PURE__*/_react.default.createElement("div", _extends({
283
- className: 'aio-table' + (className ? ' ' + className : '') + (rtl ? ' rtl' : ''),
284
- tabIndex: 0,
285
- ref: this.dom,
286
- style: { ...style
287
- }
288
- }, attrs), /*#__PURE__*/_react.default.createElement(AIOTableToolbar, details), table, paging && /*#__PURE__*/_react.default.createElement(AIOTablePaging, {
289
- rtl: rtl,
290
- translate: translate,
291
- paging: paging,
292
- onChange: obj => {
293
- this.setState({
294
- paging: obj
295
- });
296
-
297
- if (paging.onChange) {
298
- paging.onChange(obj);
304
+ return /*#__PURE__*/_react.default.createElement(AIOFormSlider, props);
305
+ }
306
+
307
+ getInput_select({
308
+ className,
309
+ value,
310
+ onChange,
311
+ options,
312
+ disabled,
313
+ style
314
+ }, input) {
315
+ let props = {
316
+ options,
317
+ value,
318
+ onChange,
319
+ className,
320
+ search: input.search,
321
+ disabled,
322
+ style,
323
+ optionText: input.optionText,
324
+ optionValue: input.optionValue,
325
+ optionBefore: input.optionBefore,
326
+ optionAfter: input.optionAfter,
327
+ text: input.text,
328
+ before: input.before,
329
+ optionSubtext: input.optionSubtext
330
+ };
331
+ return /*#__PURE__*/_react.default.createElement(_aioButton.default, _extends({}, props, {
332
+ type: "select",
333
+ popupWidth: "fit",
334
+ popupAttrs: {
335
+ style: {
336
+ maxHeight: 400
299
337
  }
300
338
  }
301
- }), this.fn.getLoading(true)));
339
+ }));
302
340
  }
303
341
 
304
- }
342
+ getInput_multiselect({
343
+ className,
344
+ value,
345
+ onChange,
346
+ options,
347
+ disabled,
348
+ style,
349
+ text,
350
+ subtext,
351
+ theme
352
+ }, input) {
353
+ let props = {
354
+ className,
355
+ value,
356
+ onChange,
357
+ options,
358
+ text,
359
+ subtext,
360
+ disabled,
361
+ search: input.search,
362
+ style,
363
+ popupWidth: 'fit',
364
+ optionText: input.optionText,
365
+ optionValue: input.optionValue,
366
+ optionBefore: input.optionBefore,
367
+ optionAfter: input.optionAfter,
368
+ text: input.text,
369
+ before: input.before,
370
+ optionSubtext: input.optionSubtext,
371
+ optionIconSize: theme.checkIconSize,
372
+ optionIconColor: theme.checkIconColor
373
+ };
374
+ return /*#__PURE__*/_react.default.createElement(_aioButton.default, _extends({}, props, {
375
+ type: "multiselect",
376
+ popupAttrs: {
377
+ style: {
378
+ maxHeight: 400
379
+ }
380
+ }
381
+ }));
382
+ }
305
383
 
306
- exports.default = AIOTable;
307
- AIOTable.defaultProps = {
308
- columns: [],
309
- toolbarHeight: 36,
310
- rowGap: 6,
311
- indent: 16,
312
- translate: text => text,
313
- freezeSize: 300,
314
- groups: []
315
- };
316
-
317
- class AIOTableToolbar extends _react.Component {
318
- constructor(...args) {
319
- super(...args);
320
-
321
- _defineProperty(this, "state", {
322
- searchText: ''
323
- });
384
+ getInput_table({
385
+ className,
386
+ value,
387
+ onChange,
388
+ disabled,
389
+ style
390
+ }, input) {
391
+ let props = {
392
+ attrs: input.attrs,
393
+ className,
394
+ value,
395
+ onChange,
396
+ columns: input.columns,
397
+ addable: input.addable,
398
+ rowNumber: input.rowNumber,
399
+ disabled,
400
+ style
401
+ };
402
+ return /*#__PURE__*/_react.default.createElement(AIOFormTable, _extends({}, props, {
403
+ getValue: this.getValue.bind(this)
404
+ }));
324
405
  }
325
406
 
326
- changeSearch(value, time = 1000) {
327
- clearTimeout(this.searchTimeout);
328
- this.setState({
329
- searchText: value
330
- });
331
- this.searchTimeout = setTimeout(() => this.context.SetState({
332
- searchText: value
333
- }), time);
407
+ getInput_splitter(obj, input) {
408
+ return /*#__PURE__*/_react.default.createElement("div", {
409
+ style: {
410
+ height: 48,
411
+ width: '100%',
412
+ display: 'flex',
413
+ alignItems: 'center'
414
+ }
415
+ }, /*#__PURE__*/_react.default.createElement("div", {
416
+ style: {
417
+ height: 0,
418
+ flex: 1,
419
+ borderBottom: '1px solid #bbb'
420
+ }
421
+ }), /*#__PURE__*/_react.default.createElement("div", {
422
+ style: {
423
+ padding: '0 6px',
424
+ color: '#aaa'
425
+ }
426
+ }, "msf"), /*#__PURE__*/_react.default.createElement("div", {
427
+ style: {
428
+ height: 0,
429
+ flex: 1,
430
+ borderBottom: '1px solid #bbb'
431
+ }
432
+ }));
334
433
  }
335
434
 
336
- getSearch() {
337
- let {
338
- translate
339
- } = this.context;
340
- let {
341
- search
342
- } = this.props;
343
- let {
344
- searchText
345
- } = this.state;
435
+ sortByRows(inputs) {
436
+ let res = {};
437
+ let result = [];
346
438
 
347
- if (!search) {
348
- return /*#__PURE__*/_react.default.createElement("div", {
349
- style: {
350
- flex: 1
351
- },
352
- key: "search"
353
- });
354
- }
439
+ for (let i = 0; i < inputs.length; i++) {
440
+ let {
441
+ type,
442
+ show
443
+ } = inputs[i];
355
444
 
356
- return /*#__PURE__*/_react.default.createElement("div", {
357
- className: "aio-table-search",
358
- key: "search"
359
- }, /*#__PURE__*/_react.default.createElement("input", {
360
- className: "aio-table-search-input",
361
- type: "text",
362
- value: searchText,
363
- placeholder: translate('Search'),
364
- onChange: e => this.changeSearch(e.target.value)
365
- }), aioTableGetSvg(searchText ? 'close' : 'magnify', {
366
- onClick: () => {
367
- if (!searchText) {
368
- return;
369
- }
445
+ if (!type) {
446
+ continue;
447
+ }
370
448
 
371
- this.changeSearch('', 0);
449
+ if (this.getValue(show, true) === false) {
450
+ continue;
372
451
  }
373
- }));
374
- }
375
452
 
376
- render() {
377
- let {
378
- fn,
379
- rows,
380
- translate,
381
- rtl,
382
- toggleAllState,
383
- toolbarItems = [],
384
- SetState,
385
- toolbarAttrs = {},
386
- toggleAll,
387
- groups
388
- } = this.context;
389
- let {
390
- toggleOptions,
391
- freezeOptions,
392
- groupOptions,
393
- excelColumns,
394
- sortOptions
395
- } = this.props;
396
- let buttonProps = {
397
- type: 'select',
398
- rtl,
399
- caret: false,
400
- className: 'aio-table-toolbar-button',
401
- animate: true,
402
- popupAttrs: {
403
- style: {
404
- maxHeight: 500
405
- }
453
+ inputs[i]._index = i;
454
+
455
+ if (type === 'group') {
456
+ let a = 'a' + Math.random();
457
+ res[a] = [inputs[i]];
458
+ result.push(res[a]);
459
+ continue;
406
460
  }
407
- };
408
- let Sort, Toggle, Group, Freeze, Excel, ToggleAll;
409
-
410
- if (sortOptions.length) {
411
- let title = translate('Sort');
412
- let props = { ...buttonProps,
413
- options: sortOptions,
414
- title,
415
- key: 'sort',
416
- text: aioTableGetSvg('sort'),
417
- popupHeader: /*#__PURE__*/_react.default.createElement("div", {
418
- className: "aio-table-popup-header"
419
- }, title)
420
- };
421
- Sort = /*#__PURE__*/_react.default.createElement(_aioButton.default, props);
422
- }
423
461
 
424
- if (toggleOptions.length) {
425
- let title = translate('Show Columns');
426
- let props = { ...buttonProps,
427
- options: toggleOptions,
428
- title,
429
- key: 'toggle',
430
- text: aioTableGetSvg('eye'),
431
- popupHeader: /*#__PURE__*/_react.default.createElement("div", {
432
- className: "aio-table-popup-header"
433
- }, title)
434
- };
435
- Toggle = /*#__PURE__*/_react.default.createElement(_aioButton.default, props);
436
- }
462
+ let {
463
+ rowKey
464
+ } = inputs[i];
437
465
 
438
- if (groupOptions.length) {
439
- let title = translate('Group By');
440
- let props = { ...buttonProps,
441
- options: groupOptions,
442
- title,
443
- key: 'group',
444
- text: aioTableGetSvg('group', {
445
- flip: rtl === true
446
- }),
447
- popupHeader: /*#__PURE__*/_react.default.createElement("div", {
448
- className: "aio-table-popup-header"
449
- }, title),
450
- onSwap: (start, end, swap) => SetState({
451
- groups: swap(groups, start, end)
452
- })
453
- };
454
- Group = /*#__PURE__*/_react.default.createElement(_aioButton.default, props);
455
- }
466
+ if (!rowKey) {
467
+ rowKey = 'a' + Math.random();
468
+ }
456
469
 
457
- if (freezeOptions.length) {
458
- let title = translate('Freeze');
459
- let props = { ...buttonProps,
460
- options: freezeOptions,
461
- title,
462
- key: 'freeze',
463
- text: aioTableGetSvg('freeze'),
464
- popupHeader: /*#__PURE__*/_react.default.createElement("div", {
465
- className: "aio-table-popup-header"
466
- }, title)
467
- };
468
- Freeze = /*#__PURE__*/_react.default.createElement(_aioButton.default, props);
469
- }
470
+ if (!res[rowKey]) {
471
+ res[rowKey] = [];
472
+ result.push(res[rowKey]);
473
+ }
470
474
 
471
- if (toggleAll) {
472
- let title = translate('Toggle All');
473
- let props = { ...buttonProps,
474
- title,
475
- key: 'toggleAll',
476
- type: 'button',
477
- text: !toggleAllState ? aioTableGetSvg('toggleAllMinus') : aioTableGetSvg('toggleAllPlus'),
478
- onclick: () => SetState(fn.getStateByToggleAll(rows))
479
- };
480
- ToggleAll = /*#__PURE__*/_react.default.createElement(_aioButton.default, props);
475
+ res[rowKey].push(inputs[i]);
481
476
  }
482
477
 
483
- if (excelColumns.length) {
484
- let title = translate('Export To Excel');
485
- let props = { ...buttonProps,
486
- title,
487
- key: 'excel',
488
- type: 'button',
489
- text: aioTableGetSvg('excel'),
490
- onClick: () => fn.exportToExcel(excelColumns, rows)
491
- };
492
- Excel = /*#__PURE__*/_react.default.createElement(_aioButton.default, props);
493
- }
478
+ return result;
479
+ }
494
480
 
495
- return /*#__PURE__*/_react.default.createElement("div", {
496
- className: 'aio-table-toolbar' + (toolbarAttrs.className ? ' ' + toolbarAttrs.className : ''),
497
- style: { ...toolbarAttrs.style
498
- }
499
- }, ToggleAll, Excel, toolbarItems.map((o, i) => /*#__PURE__*/_react.default.createElement(_aioButton.default, _extends({
500
- type: "button",
501
- rtl: rtl,
502
- className: "aio-table-toolbar-button",
503
- animate: true
504
- }, o, {
505
- key: 'ti' + i
506
- }))), this.getSearch(), Group, Sort, Toggle, Freeze);
481
+ getFix(input, rtl, type) {
482
+ let fix_props = this.props[type + 'Attrs'] || {};
483
+ let fix_input = input[type + 'Attrs'] || {};
484
+ let attrs = { ...fix_props,
485
+ ...fix_input
486
+ };
487
+ let {
488
+ onClick = () => {}
489
+ } = attrs;
490
+ return /*#__PURE__*/_react.default.createElement("div", _extends({}, attrs, {
491
+ onClick: () => onClick(input),
492
+ className: `aio-form-${type}` + (rtl ? ' rtl' : '') + (attrs.className ? ' ' + attrs.className : '')
493
+ }), input[type]);
507
494
  }
508
495
 
509
- }
496
+ getInput(input) {
497
+ let {
498
+ rtl
499
+ } = this.props;
500
+ let {
501
+ label,
502
+ affix,
503
+ prefix,
504
+ prefixAttrs = {}
505
+ } = input;
506
+ let theme = this.getInputTheme(input);
507
+ let value = this.getValue('calc model.' + input.field);
508
+ let options = this.getValue(input.options, []);
509
+ let disabled = this.getValue(input.disabled, false);
510
+ let text = this.getValue(input.text);
511
+ let start = this.getValue(input.start, 0);
512
+ let end = this.getValue(input.end, 100);
513
+ let subtext = this.getValue(input.subtext);
514
+ let placeholder = this.getValue(input.placeholder, false);
515
+
516
+ let onChange = value => this.onChange(input, value);
517
+
518
+ let style = theme.input;
519
+ let className = `aio-form-input aio-form-input-${input.type}` + (disabled ? ' disabled' : '') + (input.className ? ' ' + input.className : '') + (affix ? ' has-affix' : '') + (prefix ? ' has-prefix' : '') + (rtl ? ' rtl' : ' ltr');
520
+ let error = this.getError(input, value, options);
521
+ let props = {
522
+ value,
523
+ options,
524
+ disabled,
525
+ onChange,
526
+ className,
527
+ style,
528
+ placeholder,
529
+ text,
530
+ subtext,
531
+ start,
532
+ end,
533
+ theme
534
+ };
535
+ let {
536
+ label: themeLabel = {}
537
+ } = theme;
510
538
 
511
- _defineProperty(AIOTableToolbar, "contextType", AioTableContext);
539
+ if (themeLabel.inline) {
540
+ return {
541
+ className: 'aio-form-item',
542
+ style: {
543
+ overflow: 'visible',
544
+ marginBottom: theme.rowGap
545
+ },
546
+ row: [{
547
+ align: 'v',
548
+ size: themeLabel.width,
549
+ show: label !== undefined,
550
+ html: label,
551
+ style: { ...themeLabel,
552
+ width: 'fit-content'
553
+ }
554
+ }, {
555
+ size: 6
556
+ }, {
557
+ flex: 1,
558
+ style: {
559
+ overflow: 'visible'
560
+ },
561
+ column: [{
562
+ row: [{
563
+ show: !!input.prefix,
564
+ html: () => this.getFix(input, rtl, 'prefix')
565
+ }, {
566
+ flex: 1,
567
+ html: () => this['getInput_' + input.type](props, input)
568
+ }, {
569
+ show: !!input.affix,
570
+ html: () => this.getFix(input, rtl, 'affix')
571
+ }]
572
+ }, {
573
+ align: 'v',
574
+ show: error !== '',
575
+ html: error,
576
+ className: 'aio-form-error'
577
+ }]
578
+ }]
579
+ };
580
+ } else {
581
+ return {
582
+ className: 'aio-form-item',
583
+ style: {
584
+ overflow: 'visible',
585
+ marginBottom: theme.rowGap
586
+ },
587
+ column: [{
588
+ size: themeLabel.height || 24,
589
+ show: label !== undefined,
590
+ align: 'v',
591
+ html: label,
592
+ style: { ...themeLabel,
593
+ width: 'fit-content',
594
+ height: 'fit-content'
595
+ }
596
+ }, {
597
+ row: [{
598
+ show: !!input.prefix,
599
+ html: () => this.getFix(input, rtl, 'prefix')
600
+ }, {
601
+ flex: 1,
602
+ html: () => this['getInput_' + input.type](props, input)
603
+ }, {
604
+ show: !!input.affix,
605
+ html: () => this.getFix(input, rtl, 'affix')
606
+ }]
607
+ }, {
608
+ size: 24,
609
+ show: error !== '',
610
+ html: error,
611
+ className: 'aio-form-error'
612
+ }]
613
+ };
614
+ }
615
+ }
512
616
 
513
- class AIOTablePaging extends _react.Component {
514
- getPageNumber(type) {
617
+ getInputs(inputs) {
515
618
  let {
516
- paging
619
+ onSwap
517
620
  } = this.props;
518
621
  let {
519
- pages = 1,
520
- number
521
- } = paging;
522
- let newNumber;
523
-
524
- if (type === 'prev') {
525
- newNumber = number - 1;
526
- } else if (type === 'next') {
527
- newNumber = number + 1;
528
- } else if (type === 'first') {
529
- newNumber = 1;
530
- } else if (type === 'last') {
531
- newNumber = pages;
532
- }
622
+ theme
623
+ } = this.state;
624
+ return this.sortByRows(inputs).map((input, i) => {
625
+ return {
626
+ swapId: onSwap ? input._index.toString() : undefined,
627
+ swapHandleClassName: 'aio-form-label',
628
+ gap: theme.columnGap || 12,
629
+ row: input.map(o => {
630
+ return { ...this.getInput(o),
631
+ flex: o.rowWidth ? undefined : 1,
632
+ size: o.rowWidth,
633
+ align: 'v'
634
+ };
635
+ })
636
+ };
637
+ });
638
+ }
639
+
640
+ getError(o, value, options) {
641
+ let {
642
+ validations = []
643
+ } = o;
644
+ let lang = 'en';
533
645
 
534
- if (newNumber < 1) {
535
- newNumber = 1;
646
+ if (!validations.length) {
647
+ return '';
536
648
  }
537
649
 
538
- if (newNumber > pages) {
539
- newNumber = pages;
650
+ let a = {
651
+ value,
652
+ title: o.label,
653
+ lang,
654
+ validations: validations.map(a => {
655
+ return [a[0], this.getValue(a[1], ''), a[2]];
656
+ })
657
+ };
658
+ let error = (0, _aioValidation.default)(a);
659
+
660
+ if (!this.isThereError && error) {
661
+ this.isThereError = true;
540
662
  }
541
663
 
542
- return newNumber;
664
+ return error;
543
665
  }
544
666
 
545
- changePage(type) {
667
+ async reset() {
546
668
  let {
547
- paging,
669
+ onSubmit,
548
670
  onChange
549
671
  } = this.props;
550
672
  let {
551
- number
552
- } = paging;
553
- let newNumber = this.getPageNumber(type);
673
+ initialModel
674
+ } = this.state;
554
675
 
555
- if (newNumber === number) {
556
- return;
676
+ if (onSubmit) {
677
+ this.setState({
678
+ model: JSON.parse(initialModel)
679
+ });
680
+ } else if (onChange) {
681
+ await onChange(JSON.parse(initialModel));
557
682
  }
558
-
559
- onChange({ ...paging,
560
- number: newNumber
561
- });
562
683
  }
563
684
 
564
685
  render() {
565
- var {
566
- paging,
567
- onChange,
686
+ let {
687
+ inputs,
688
+ header,
568
689
  rtl,
569
- translate = str => str
690
+ onSubmit,
691
+ submitText = 'Submit',
692
+ closeText = 'Close',
693
+ resetText = 'Reset',
694
+ onClose,
695
+ footerAttrs,
696
+ reset
570
697
  } = this.props;
571
- var {
572
- number,
573
- sizes = [1, 5, 10, 20, 30, 40, 50, 60, 70, 80],
574
- size,
575
- pages = 1
576
- } = paging;
577
- return /*#__PURE__*/_react.default.createElement("div", {
578
- className: "aio-table-paging",
579
- style: {
580
- direction: 'ltr'
698
+ this.isThereError = false;
699
+ let column = this.getInputs(inputs);
700
+ return /*#__PURE__*/_react.default.createElement(_reactVirtualDom.default, {
701
+ layout: {
702
+ className: 'aio-form',
703
+ column: [{
704
+ show: header !== undefined,
705
+ html: /*#__PURE__*/_react.default.createElement(AIOFormHeader, _extends({}, header, {
706
+ rtl: rtl
707
+ }))
708
+ }, {
709
+ className: 'aio-form-body',
710
+ scroll: 'v',
711
+ flex: 1,
712
+ column
713
+ }, {
714
+ show: onSubmit !== undefined || reset === true || onClose !== undefined,
715
+ html: () => /*#__PURE__*/_react.default.createElement(AIOFormFooter, {
716
+ isThereError: this.isThereError,
717
+ onClose: onClose,
718
+ onSubmit: onSubmit ? () => onSubmit({ ...this.state.model
719
+ }) : undefined,
720
+ closeText: closeText,
721
+ submitText: submitText,
722
+ resetText: resetText,
723
+ footerAttrs: footerAttrs,
724
+ onReset: reset ? () => this.reset() : undefined
725
+ })
726
+ }]
581
727
  }
582
- }, /*#__PURE__*/_react.default.createElement("div", {
583
- className: "aio-table-paging-button",
584
- onClick: () => this.changePage(rtl ? 'last' : 'first'),
585
- title: translate(rtl ? 'Last Page' : 'First Page')
586
- }, aioTableGetSvg('doubleChevronRight', {
587
- flip: true
588
- })), /*#__PURE__*/_react.default.createElement("div", {
589
- className: "aio-table-paging-button",
590
- onClick: () => this.changePage(rtl ? 'next' : 'prev'),
591
- title: translate(rtl ? 'Next Page' : 'Previous Page')
592
- }, aioTableGetSvg('chevronRight', {
593
- flip: true
594
- })), /*#__PURE__*/_react.default.createElement("div", {
595
- className: "aio-table-paging-number"
596
- }, rtl ? pages + ' / ' + number : number + ' / ' + pages), /*#__PURE__*/_react.default.createElement("div", {
597
- className: "aio-table-paging-button",
598
- onClick: () => this.changePage(rtl ? 'prev' : 'next'),
599
- title: translate(rtl ? 'Previous Page' : 'Next Page')
600
- }, aioTableGetSvg('chevronRight')), /*#__PURE__*/_react.default.createElement("div", {
601
- className: "aio-table-paging-button",
602
- onClick: () => this.changePage(rtl ? 'first' : 'last'),
603
- title: translate(rtl ? 'First Page' : 'Last Page')
604
- }, aioTableGetSvg('doubleChevronRight')), /*#__PURE__*/_react.default.createElement("select", {
605
- className: "aio-table-paging-button",
606
- value: size,
607
- onChange: e => onChange({ ...paging,
608
- size: parseInt(e.target.value)
609
- }),
610
- title: translate('Rows Count Per Page')
611
- }, sizes.map((s, i) => /*#__PURE__*/_react.default.createElement("option", {
612
- key: i,
613
- value: s
614
- }, s))));
728
+ });
615
729
  }
616
730
 
617
731
  }
618
732
 
619
- class AIOTableUnit extends _react.Component {
620
- constructor(props) {
621
- super(props);
622
- this.dom = /*#__PURE__*/(0, _react.createRef)();
623
- }
733
+ exports.default = AIOForm;
624
734
 
625
- getCardStyle() {
735
+ class AIOFormHeader extends _react.Component {
736
+ render() {
626
737
  let {
627
- columnGap,
628
- rowGap
629
- } = this.context;
630
- return {
631
- gridColumnGap: columnGap,
632
- gridRowGap: rowGap
633
- };
738
+ title,
739
+ subtitle,
740
+ onClose,
741
+ attrs = {},
742
+ print,
743
+ onBack,
744
+ justify,
745
+ onForward,
746
+ rtl
747
+ } = this.props;
748
+ return /*#__PURE__*/_react.default.createElement(_reactVirtualDom.default, {
749
+ layout: {
750
+ className: 'aio-form-header' + (attrs.className ? ' ' + attrs.className : ''),
751
+ style: attrs.style,
752
+ align: 'v',
753
+ row: [{
754
+ show: onBack !== undefined,
755
+ html: /*#__PURE__*/_react.default.createElement(_react2.Icon, {
756
+ path: rtl ? _js.mdiChevronRight : _js.mdiChevronLeft,
757
+ size: 0.9
758
+ }),
759
+ align: 'vh',
760
+ size: 36,
761
+ attrs: {
762
+ onClick: onBack
763
+ }
764
+ }, {
765
+ show: justify === true,
766
+ flex: 1
767
+ }, {
768
+ column: [{
769
+ html: title,
770
+ className: 'aio-form-title',
771
+ align: 'v'
772
+ }, {
773
+ show: subtitle !== undefined,
774
+ html: subtitle,
775
+ className: 'aio-form-subtitle',
776
+ align: 'v'
777
+ }]
778
+ }, {
779
+ flex: 1
780
+ }, {
781
+ show: onForward !== undefined,
782
+ html: /*#__PURE__*/_react.default.createElement(_react2.Icon, {
783
+ path: rtl ? _js.mdiChevronLeft : _js.mdiChevronRight,
784
+ size: 0.9
785
+ }),
786
+ align: 'vh',
787
+ size: 36,
788
+ attrs: {
789
+ onClick: onForward
790
+ }
791
+ }, {
792
+ show: print !== undefined,
793
+ html: /*#__PURE__*/_react.default.createElement(_react2.Icon, {
794
+ path: _js.mdiPrinter,
795
+ size: 0.9
796
+ }),
797
+ align: 'vh',
798
+ size: 36
799
+ }, {
800
+ show: onClose !== undefined,
801
+ html: /*#__PURE__*/_react.default.createElement(_react2.Icon, {
802
+ path: _js.mdiClose,
803
+ size: 0.8
804
+ }),
805
+ align: 'vh',
806
+ size: 36,
807
+ attrs: {
808
+ onClick: onClose
809
+ }
810
+ }]
811
+ }
812
+ });
634
813
  }
635
814
 
636
- getStyle() {
637
- if (this.context.cardTemplate) {
638
- return this.getCardStyle();
639
- }
815
+ }
640
816
 
641
- return this.getGridStyle();
817
+ class AIOFormFooter extends _react.Component {
818
+ render() {
819
+ let {
820
+ onClose,
821
+ onSubmit,
822
+ closeText,
823
+ submitText,
824
+ footerAttrs = {},
825
+ onReset,
826
+ resetText,
827
+ isThereError
828
+ } = this.props;
829
+ return /*#__PURE__*/_react.default.createElement(_reactVirtualDom.default, {
830
+ layout: {
831
+ align: 'v',
832
+ className: 'aio-form-footer',
833
+ row: [{
834
+ show: onClose !== undefined,
835
+ html: () => /*#__PURE__*/_react.default.createElement("button", {
836
+ className: "aio-form-footer-button aio-form-close-button",
837
+ onClick: () => onClose()
838
+ }, closeText)
839
+ }, {
840
+ size: 12,
841
+ show: onSubmit !== undefined
842
+ }, {
843
+ show: onSubmit !== undefined,
844
+ html: () => /*#__PURE__*/_react.default.createElement("button", {
845
+ className: "aio-form-footer-button aio-form-submit-button",
846
+ disabled: isThereError,
847
+ onClick: () => onSubmit()
848
+ }, submitText)
849
+ }, {
850
+ size: 12,
851
+ show: onSubmit !== undefined
852
+ }, {
853
+ show: onReset !== undefined,
854
+ html: () => /*#__PURE__*/_react.default.createElement("button", {
855
+ className: "aio-form-footer-button aio-form-reset-button",
856
+ onClick: () => onReset()
857
+ }, resetText)
858
+ }]
859
+ }
860
+ });
642
861
  }
643
862
 
644
- getGridStyle() {
645
- var {
646
- rowGap,
647
- columnGap
648
- } = this.context;
649
- var {
650
- columns,
651
- style
652
- } = this.props;
653
- var gridTemplateColumns = '';
654
- this.gridTemplateColumns = [];
863
+ }
655
864
 
656
- for (let i = 0; i < columns.length; i++) {
657
- let {
658
- width = 'auto'
659
- } = columns[i];
660
- width = width.toString();
865
+ function Text(obj) {
866
+ let [value, setValue] = (0, _react.useState)(obj.value),
867
+ [prevValue, setPrevValue] = (0, _react.useState)(obj.value),
868
+ [timer, setTimer] = (0, _react.useState)();
869
+ let [error, setError] = (0, _react.useState)(false);
870
+ let dom = (0, _react.useRef)(null);
661
871
 
662
- if (width !== 'auto' && width.indexOf('px') === -1) {
663
- width += 'px';
664
- }
872
+ if (obj.value !== prevValue) {
873
+ setTimeout(() => {
874
+ setValue(obj.value);
875
+ setPrevValue(obj.value);
876
+ }, 0);
877
+ }
665
878
 
666
- this.gridTemplateColumns.push(width);
667
- gridTemplateColumns += width + (i < columns.length - 1 ? ' ' : '');
879
+ function onChange(e) {
880
+ let value = e.target.value;
881
+
882
+ if (obj.type === 'number') {
883
+ if (value) {
884
+ value = +value;
885
+ }
668
886
  }
669
887
 
670
- return {
671
- gridTemplateColumns,
672
- gridRowGap: rowGap,
673
- gridColumnGap: columnGap,
674
- ...style
675
- };
888
+ setValue(value);
889
+ clearTimeout(timer);
890
+ setTimer(setTimeout(() => {
891
+ obj.onChange(value);
892
+ }, 800));
676
893
  }
677
894
 
678
- setStyle(gridTemplateColumns) {
679
- (0, _jquery.default)(this.dom.current).css({
680
- gridTemplateColumns: gridTemplateColumns.join(' ')
681
- });
682
- }
895
+ (0, _react.useEffect)(() => {
896
+ if (obj.type === 'textarea' && obj.autoHeight) {
897
+ let scrollHeight = dom.current.scrollHeight + 'px';
898
+ dom.current.style.height = scrollHeight;
899
+ dom.current.style.overflow = 'hidden';
900
+ dom.current.style.resize = 'none';
901
+ }
902
+ });
903
+ let props = { ...obj,
904
+ value,
905
+ onChange: e => onChange(e),
906
+ ref: dom
907
+ };
908
+ let uid = 'a' + Math.random();
909
+
910
+ if (error !== false) {
911
+ return /*#__PURE__*/_react.default.createElement("div", {
912
+ className: "aio-form-inline-error aio-form-input",
913
+ onClick: () => setError(false)
914
+ }, error);
915
+ }
916
+
917
+ return obj.type === 'textarea' ? /*#__PURE__*/_react.default.createElement("textarea", props) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("input", _extends({}, props, {
918
+ list: uid
919
+ })), Array.isArray(obj.options) && obj.options.length !== 0 && /*#__PURE__*/_react.default.createElement("datalist", {
920
+ id: uid
921
+ }, obj.options.map((o, i) => /*#__PURE__*/_react.default.createElement("option", {
922
+ key: i,
923
+ value: o.text
924
+ }))));
925
+ }
683
926
 
684
- getTitles() {
685
- var {
686
- columns
927
+ class AIOFormSlider extends _react.Component {
928
+ render() {
929
+ let {
930
+ className,
931
+ start,
932
+ end,
933
+ step,
934
+ value,
935
+ onChange,
936
+ disabled,
937
+ style,
938
+ editValue
687
939
  } = this.props;
688
- return columns.map((column, i) => {
689
- return /*#__PURE__*/_react.default.createElement(AIOTableTitle, {
690
- isLast: i === columns.length - 1,
691
- key: 'title' + i,
692
- column: column,
693
- gridTemplateColumns: this.gridTemplateColumns,
694
- setStyle: this.setStyle.bind(this),
695
- onDragStart: index => this.startColumnSwap = index,
696
- onDragOver: (e, index) => {
697
- e.preventDefault();
698
- this.endColumnSwap = index;
699
- },
700
- onDrop: column => {
701
- let {
702
- SetState,
703
- columns
704
- } = this.context;
705
-
706
- if (column.movable === false) {
707
- return;
708
- }
709
940
 
710
- if (this.startColumnSwap === undefined || this.startColumnSwap === this.endColumnSwap) {
711
- return;
941
+ if (!Array.isArray(value)) {
942
+ value = [value];
943
+ }
944
+
945
+ let props = {
946
+ attrs: {
947
+ className,
948
+ style
949
+ },
950
+ start,
951
+ end,
952
+ step,
953
+ points: value,
954
+ onChange: disabled ? undefined : points => points.length === 1 ? onChange(points[0]) : onChange([points[0], points[1]]),
955
+ showValue: true,
956
+ editValue,
957
+ fillStyle: index => {
958
+ if (value.length === 1) {
959
+ if (index === 1) {
960
+ return {
961
+ background: 'none'
962
+ };
963
+ }
964
+ } else {
965
+ if (index === 0 || index === value.length) {
966
+ return {
967
+ background: 'none'
968
+ };
712
969
  }
970
+ }
713
971
 
714
- let startColumn = columns[this.startColumnSwap];
715
- let endColumn = columns[this.endColumnSwap];
716
- let newColumns = columns.map((c, j) => {
717
- if (j === this.startColumnSwap) {
718
- return endColumn;
719
- }
972
+ return {
973
+ background: 'dodgerblue'
974
+ };
975
+ },
976
+ valueStyle: () => {
977
+ return {
978
+ height: 20,
979
+ display: 'flex',
980
+ minWidth: 12,
981
+ padding: '0 3px',
982
+ justifyContent: 'center',
983
+ alignItems: 'center',
984
+ top: 'calc(50% - 10px)'
985
+ };
986
+ },
987
+ pointStyle: () => {
988
+ return {
989
+ display: 'none'
990
+ };
991
+ }
992
+ };
993
+ return /*#__PURE__*/_react.default.createElement(_rRangeSlider.default, props);
994
+ }
720
995
 
721
- if (j === this.endColumnSwap) {
722
- return startColumn;
723
- }
996
+ }
724
997
 
725
- return c;
726
- });
727
- SetState({
728
- columns: newColumns
729
- });
998
+ class AIOFormTable extends _react.Component {
999
+ setValueByField(obj, field, value) {
1000
+ field = field.replaceAll('[', '.');
1001
+ field = field.replaceAll(']', '');
1002
+ var fields = field.split('.');
1003
+ var node = obj;
1004
+
1005
+ for (let i = 0; i < fields.length - 1; i++) {
1006
+ if (node[fields[i]] === undefined) {
1007
+ if (isNaN(parseFloat(fields[i + 1]))) {
1008
+ node[fields[i]] = {};
1009
+ } else {
1010
+ node[fields[i]] = [];
730
1011
  }
731
- });
732
- });
733
- }
734
1012
 
735
- keyDown(e) {
736
- var {
737
- SetState
738
- } = this.context;
739
-
740
- if (e.keyCode === 27) {
741
- (0, _jquery.default)('.aio-table-input').blur();
742
- SetState({
743
- focused: false
744
- }, 'keyDown');
745
- } else if ([37, 38, 39, 40].indexOf(e.keyCode) !== -1) {
746
- this.arrow(e);
1013
+ node = node[fields[i]];
1014
+ } else {
1015
+ node = node[fields[i]];
1016
+ }
747
1017
  }
1018
+
1019
+ node[fields[fields.length - 1]] = value;
1020
+ return obj;
748
1021
  }
749
1022
 
750
- arrow(e) {
751
- var container = (0, _jquery.default)(this.dom.current);
752
- var {
753
- rtl,
754
- focused,
755
- SetState
756
- } = this.context;
757
- var {
758
- columns
1023
+ add() {
1024
+ let {
1025
+ columns = [],
1026
+ onChange,
1027
+ value = []
759
1028
  } = this.props;
760
- let inputs = container.find('.aio-table-input');
761
1029
 
762
- if (inputs.length === 0) {
1030
+ if (!columns.length) {
763
1031
  return;
764
1032
  }
765
1033
 
766
- let focusedInput = inputs.filter(':focus');
1034
+ let obj = {};
767
1035
 
768
- if (focused === false) {
769
- let inputCells = (0, _jquery.default)('.aio-table-cell-input');
1036
+ for (let i = 0; i < columns.length; i++) {
1037
+ let {
1038
+ field,
1039
+ type
1040
+ } = columns[i];
770
1041
 
771
- if (inputCells.length) {
772
- let cell = inputCells.eq(0);
773
- SetState({
774
- focused: cell.attr('data-cell-id')
775
- });
776
- setTimeout(() => {
777
- cell.find('.aio-table-input').focus().select();
778
- }, 10);
1042
+ if (!field) {
1043
+ continue;
779
1044
  }
780
1045
 
781
- return;
782
- }
783
-
784
- let [rowIndex, colIndex] = this.getCellIndex(focusedInput.parents('.aio-table-cell'));
785
- console.log(rowIndex, colIndex);
1046
+ if (typeof field === 'string' && field.indexOf('calc ') === 0) {
1047
+ continue;
1048
+ }
786
1049
 
787
- if (e.keyCode === 40 || e.keyCode === 38) {
788
- let sign = e.keyCode === 40 ? 1 : -1;
789
- e.preventDefault();
790
- rowIndex += sign;
791
- let next = inputs.filter(`[data-row-index=${rowIndex}][data-col-index=${colIndex}]`);
1050
+ let val;
792
1051
 
793
- while (rowIndex < this.renderIndex && rowIndex > 0 && next.length === 0) {
794
- rowIndex += sign;
795
- next = inputs.filter(`[data-row-index=${rowIndex}][data-col-index=${colIndex}]`);
796
- }
1052
+ if (type === 'text') {
1053
+ val = '';
1054
+ } else if (type === 'number') {
1055
+ val = 0;
1056
+ } else if (type === 'select') {
1057
+ let options = this.getColumnOptions(columns[i]);
797
1058
 
798
- if (next.length) {
799
- next.focus();
800
- setTimeout(() => next.select(), 5);
801
- }
802
- } else if (e.keyCode === 39 || e.keyCode === 37) {
803
- e.preventDefault();
804
- let sign = (e.keyCode === 37 ? -1 : 1) * (rtl ? -1 : 1);
805
- colIndex += sign;
806
- let next = inputs.filter(`[data-row-index=${rowIndex}][data-col-index=${colIndex}]`);
807
-
808
- while (colIndex > 0 && colIndex < columns.length && next.length === 0) {
809
- colIndex += sign;
810
- next = inputs.filter(`[data-row-index=${rowIndex}][data-col-index=${colIndex}]`);
1059
+ try {
1060
+ val = options[0].value;
1061
+ } catch {
1062
+ val = '';
1063
+ }
1064
+ } else if (type === 'checkbox') {
1065
+ val = false;
811
1066
  }
812
1067
 
813
- if (next.length) {
814
- next.focus();
815
- setTimeout(() => next.select(), 5);
816
- }
1068
+ this.setValueByField(obj, field, val);
817
1069
  }
818
- }
819
1070
 
820
- getCellIndex(cell) {
821
- return [parseInt(cell.attr('data-row-index')), parseInt(cell.attr('data-col-index'))];
1071
+ value.push(obj);
1072
+ onChange(value);
822
1073
  }
823
1074
 
824
- card(props) {
825
- var {
826
- rowHeight,
827
- fn,
828
- cardTemplate,
829
- cardRowCount,
830
- search,
831
- searchText,
832
- indent
833
- } = this.context;
834
- var {
835
- tableIndex,
836
- columns
1075
+ getToolbarItems() {
1076
+ let {
1077
+ item,
1078
+ addable = true,
1079
+ disabled
837
1080
  } = this.props;
838
- var groupStyle = {
839
- gridColumnStart: 1,
840
- gridColumnEnd: cardRowCount + 1,
841
- height: rowHeight
842
- };
843
1081
 
844
- if (cardRowCount === 'auto') {
845
- groupStyle.gridColumnStart = undefined;
846
- groupStyle.gridColumnEnd = undefined;
1082
+ if (disabled) {
1083
+ return;
847
1084
  }
848
1085
 
849
- let rows;
850
-
851
- if (search) {
852
- rows = this.props.rows.filter(o => {
853
- if (searchText === '') {
854
- return true;
855
- }
1086
+ let toolbarItems = [];
856
1087
 
857
- try {
858
- return search(o.row, searchText);
859
- } catch {
860
- return false;
1088
+ if (addable) {
1089
+ toolbarItems.push({
1090
+ text: '+',
1091
+ type: 'button',
1092
+ onClick: () => this.add(),
1093
+ className: 'aio-form-input aio-form-input-table-add',
1094
+ style: {
1095
+ background: 'none',
1096
+ color: 'inherit',
1097
+ padding: 0,
1098
+ width: '100%'
861
1099
  }
862
1100
  });
863
- } else {
864
- rows = this.props.rows;
865
1101
  }
866
1102
 
867
- return /*#__PURE__*/_react.default.createElement("div", _extends({}, props, {
868
- style: { ...props.style,
869
- gridTemplateColumns: cardRowCount === 'auto' ? undefined : `repeat(${cardRowCount},auto)`
870
- }
871
- }), rows && rows.length !== 0 && rows.map((row, rowIndex) => {
872
- if (row._groupId) {
873
- return /*#__PURE__*/_react.default.createElement(AIOTableGroup, {
874
- row,
875
- rowIndex,
876
- tableIndex
877
- });
878
- }
879
-
880
- return /*#__PURE__*/_react.default.createElement("div", {
881
- key: rowIndex + '-' + tableIndex,
882
- className: "aio-table-card"
883
- }, row.row._level !== 0 && /*#__PURE__*/_react.default.createElement("div", {
884
- style: {
885
- width: row.row._level * indent,
886
- border: '1px solid',
887
- height: '100%',
888
- position: 'relative'
889
- }
890
- }, /*#__PURE__*/_react.default.createElement("svg", {
891
- style: {
892
- background: 'yellow',
893
- width: '100%',
894
- positon: 'absolute',
895
- height: '100%'
896
- }
897
- })), cardTemplate(row.row, () => fn.toggleRow(row.row)));
898
- }), rows && rows.length === 0 && fn.getNoData(columns), !rows && fn.getLoading());
1103
+ return toolbarItems;
899
1104
  }
900
1105
 
901
- getPropValue(row, column, prop) {
902
- return typeof prop === 'function' ? prop(row, column) : prop;
1106
+ getColumnOptions(column) {
1107
+ let {
1108
+ getValue
1109
+ } = this.props;
1110
+ return getValue(column.options, []);
903
1111
  }
904
1112
 
905
- render() {
906
- var {
907
- onScroll,
908
- onSwap,
909
- onDrop,
910
- onDrag,
911
- fn,
912
- focused,
913
- SetState,
914
- striped,
915
- getCellAttrs
916
- } = this.context;
917
- var {
918
- rows,
919
- id,
920
- tableIndex,
921
- type,
922
- columns
1113
+ getColumns() {
1114
+ let {
1115
+ onChange,
1116
+ addable = true,
1117
+ disabled,
1118
+ columns,
1119
+ value,
1120
+ rowNumber
923
1121
  } = this.props;
924
- let props = {
925
- id,
926
- tabIndex: 0,
927
- className: 'aio-table-unit',
928
- style: this.getStyle(),
929
- ref: this.dom,
930
- onKeyDown: this.keyDown.bind(this),
931
- onScroll: e => onScroll(tableIndex)
932
- };
1122
+ let result = columns.map(column => {
1123
+ let a = { ...column,
1124
+ cellAttrs: {
1125
+ className: 'aio-form-input'
1126
+ },
1127
+ titleAttrs: {
1128
+ className: 'aio-form-input'
1129
+ },
1130
+ getValue: column.field.indexOf('calc ') === 0 ? row => {
1131
+ let a;
1132
+ column.disabled = true;
1133
+
1134
+ try {
1135
+ a = eval(column.field.slice(5, column.field.length));
1136
+ } catch {
1137
+ a = '';
1138
+ }
933
1139
 
934
- if (this.context.cardTemplate) {
935
- return this.card(props);
936
- }
1140
+ return a;
1141
+ } : column.field
1142
+ };
1143
+
1144
+ if (column.type === 'select') {
1145
+ let options = this.getColumnOptions(column);
937
1146
 
938
- this.renderIndex = -1;
939
- return /*#__PURE__*/_react.default.createElement("div", props, this.getTitles(), rows && rows.length !== 0 && rows.map((o, i) => {
940
- if (o._groupId) {
941
- return /*#__PURE__*/_react.default.createElement(AIOTableGroup, {
942
- tableIndex,
943
- row: o,
944
- columns: columns,
945
- key: 'group' + i + '-' + tableIndex
946
- });
1147
+ a.template = (row, column, value) => {
1148
+ let option = options.filter(o => o.value === value)[0];
1149
+ return option ? option.text : '';
1150
+ };
947
1151
  }
948
1152
 
949
- this.renderIndex++;
950
- return o[type].map(({
951
- value,
952
- column
953
- }, j) => {
954
- let row = o.row;
955
- let cellId = i + '-' + j + '-' + tableIndex;
956
- let inlineEdit = this.getPropValue(row, column, column.inlineEdit);
957
- let attrs = getCellAttrs(row, column);
958
- return /*#__PURE__*/_react.default.createElement(AIOTableCell, {
959
- key: cellId,
960
- attrs: {
961
- 'data-row-index': this.renderIndex,
962
- 'data-col-index': column.renderIndex,
963
- 'data-real-row-index': row._index,
964
- 'data-real-col-index': column.realIndex,
965
- 'data-child-index': row._childIndex,
966
- 'data-childs-length': row._childsLength,
967
- 'data-lavel': row._level,
968
- 'data-cell-id': cellId,
969
- tabIndex: 0,
970
- draggable: typeof onSwap === 'function' && column.swap,
971
- onDrop: () => onDrop(row),
972
- onDragOver: e => e.preventDefault(),
973
- onDragStart: () => onDrag(row),
974
- onClick: () => {
975
- var {
976
- focused,
977
- SetState
978
- } = this.context;
979
-
980
- if (attrs.onClick) {
981
- attrs.onClick(row);
982
- }
983
-
984
- if (!inlineEdit || focused === cellId) {
985
- return;
986
- }
987
-
988
- if (focused === false) {
989
- setTimeout(() => fn.handleOutsideClick(), 5);
990
- }
991
-
992
- SetState({
993
- focused: cellId
994
- }, 'cellonClick');
995
- setTimeout(() => (0, _jquery.default)('.aio-table-input:focus').select(), 10);
1153
+ if (column.type === 'checkbox') {
1154
+ let options = this.getColumnOptions(column) || [{
1155
+ text: 'True',
1156
+ value: true
1157
+ }, {
1158
+ text: 'False',
1159
+ value: false
1160
+ }];
1161
+
1162
+ a.template = (row, column, value) => {
1163
+ let option = options.filter(o => o.value === value)[0];
1164
+ return option ? option.text : '';
1165
+ };
1166
+ }
1167
+
1168
+ if (['text', 'number', 'select', 'checkbox'].indexOf(column.type) !== -1 && !disabled) {
1169
+ a.inlineEdit = {
1170
+ type: column.type,
1171
+ disabled: column.disabled,
1172
+ onChange: (row, val) => {
1173
+ if (!value[row._index]) {
1174
+ value[row._index] = {};
996
1175
  }
1176
+
1177
+ this.setValueByField(value[row._index], column.field, val);
1178
+ onChange(value);
997
1179
  },
998
- striped: this.renderIndex % 2 === 0 && striped,
999
- value: value,
1000
- column: column,
1001
- row: row,
1002
- inlineEdit: inlineEdit,
1003
- before: this.getPropValue(row, column, column.before),
1004
- after: this.getPropValue(row, column, column.after),
1005
- justify: column.justify !== false && !column.treeMode
1006
- });
1007
- });
1008
- }), rows && rows.length === 0 && fn.getNoData(columns), !rows && fn.getLoading());
1009
- }
1180
+ disabled: () => disabled
1181
+ };
1010
1182
 
1011
- }
1183
+ if (column.type === 'select') {
1184
+ a.inlineEdit.options = this.getColumnOptions(column);
1185
+ }
1012
1186
 
1013
- _defineProperty(AIOTableUnit, "contextType", AioTableContext);
1187
+ a.inlineEdit.disabled = row => {
1188
+ if (column.disabled) {
1189
+ return true;
1190
+ }
1014
1191
 
1015
- class AIOTableTitle extends _react.Component {
1016
- constructor(props) {
1017
- super(props);
1018
- this.dom = /*#__PURE__*/(0, _react.createRef)();
1019
- }
1192
+ return false;
1193
+ };
1194
+ }
1020
1195
 
1021
- getStyle(style) {
1022
- let {
1023
- headerHeight,
1024
- columnGap
1025
- } = this.context;
1026
- return {
1027
- height: headerHeight,
1028
- top: 0,
1029
- borderLeft: columnGap ? 'none' : undefined,
1030
- borderRight: columnGap ? 'none' : undefined,
1031
- ...style
1032
- };
1033
- }
1196
+ return a;
1197
+ });
1034
1198
 
1035
- mouseDown(e, column) {
1036
- if (!column.resizable) {
1037
- return;
1199
+ if (rowNumber) {
1200
+ result.splice(0, 0, {
1201
+ title: '#',
1202
+ width: 48,
1203
+ getValue: ({
1204
+ _index
1205
+ }) => _index + 1,
1206
+ cellAttrs: {
1207
+ className: 'aio-form-input'
1208
+ },
1209
+ titleAttrs: {
1210
+ className: 'aio-form-input'
1211
+ }
1212
+ });
1038
1213
  }
1039
1214
 
1040
- this.resizeDown(e, column);
1041
- }
1042
-
1043
- resizeDown(e, column) {
1044
- var {
1045
- touch,
1046
- fn
1047
- } = this.context;
1048
- var {
1049
- gridTemplateColumns
1050
- } = this.props;
1051
- this.resized = false;
1052
- (0, _jquery.default)(window).bind(touch ? 'touchmove' : 'mousemove', _jquery.default.proxy(this.resizeMove, this));
1053
- (0, _jquery.default)(window).bind(touch ? 'touchend' : 'mouseup', _jquery.default.proxy(this.resizeUp, this));
1054
- this.resizeDetails = {
1055
- client: fn.getClient(e),
1056
- width: parseInt(gridTemplateColumns[column.renderIndex]),
1057
- column
1058
- };
1059
- }
1060
-
1061
- resizeMove(e) {
1062
- this.resized = true;
1063
- var {
1064
- rtl,
1065
- fn
1066
- } = this.context;
1067
- var {
1068
- setStyle,
1069
- gridTemplateColumns
1070
- } = this.props;
1071
- var Client = fn.getClient(e);
1072
- var {
1073
- client,
1074
- width,
1075
- column
1076
- } = this.resizeDetails;
1077
- var offset = Client[0] - client[0];
1078
- let newWidth = width + offset * (rtl ? -1 : 1);
1079
-
1080
- if (newWidth < parseInt(column.minWidth || 36)) {
1081
- newWidth = parseInt(column.minWidth || 36);
1215
+ if (addable && !disabled) {
1216
+ result.push({
1217
+ title: '',
1218
+ width: 36,
1219
+ cellAttrs: {
1220
+ className: 'aio-form-input'
1221
+ },
1222
+ titleAttrs: {
1223
+ className: 'aio-form-input'
1224
+ },
1225
+ template: row => {
1226
+ return /*#__PURE__*/_react.default.createElement("div", {
1227
+ onClick: () => {
1228
+ let {
1229
+ value
1230
+ } = this.props;
1231
+ value.splice(row._index, 1);
1232
+ onChange(value);
1233
+ }
1234
+ }, "X");
1235
+ }
1236
+ });
1082
1237
  }
1083
1238
 
1084
- this.resizeDetails.newWidth = newWidth + 'px';
1085
- gridTemplateColumns[column.renderIndex] = this.resizeDetails.newWidth;
1086
- setStyle(gridTemplateColumns);
1239
+ return result;
1087
1240
  }
1088
1241
 
1089
- resizeUp() {
1090
- (0, _jquery.default)(window).unbind(touch ? 'touchmove' : 'mousemove', this.resizeMove);
1091
- (0, _jquery.default)(window).unbind(touch ? 'touchend' : 'mouseup', this.resizeUp);
1092
-
1093
- if (!this.resized) {
1094
- return;
1095
- }
1096
-
1097
- var {
1098
- touch,
1099
- columns,
1100
- SetState
1101
- } = this.context;
1102
- var {
1103
- newWidth
1104
- } = this.resizeDetails;
1242
+ render() {
1105
1243
  let {
1106
- column
1244
+ value = [],
1245
+ disabled,
1246
+ className,
1247
+ style,
1248
+ attrs
1107
1249
  } = this.props;
1108
- column = { ...column,
1109
- width: newWidth
1250
+ let model;
1251
+ let input = {
1252
+ height: 28
1110
1253
  };
1111
1254
 
1112
- if (column.storageKey) {
1113
- column = { ...column,
1114
- _storageObj: { ...column._storageObj,
1115
- width: newWidth
1116
- }
1117
- };
1118
- localStorage.setItem('aio-table-column-storage-' + column.storageKey, JSON.stringify(column._storageObj));
1255
+ try {
1256
+ model = JSON.parse(JSON.stringify(value));
1257
+ } catch {
1258
+ model = [];
1119
1259
  }
1120
1260
 
1121
- columns = columns.map((c, i) => i === column.realIndex ? column : c);
1122
- SetState({
1123
- columns
1124
- });
1125
- }
1126
-
1127
- getGanttTitle(column) {
1128
- var {
1129
- headerHeight,
1130
- columnGap
1131
- } = this.context;
1132
- var {
1133
- template
1134
- } = column;
1135
- let {
1136
- padding = 36
1137
- } = template;
1138
- var keys = template.getKeys();
1139
- return /*#__PURE__*/_react.default.createElement("div", {
1140
- className: "aio-table-title aio-table-title-gantt",
1141
- style: {
1142
- padding: `0 ${+padding}px`,
1143
- height: headerHeight,
1144
- top: 0,
1145
- borderLeft: columnGap ? 'none' : undefined,
1146
- borderRight: columnGap ? 'none' : undefined
1147
- },
1148
- key: column.realIndex + 'title'
1149
- }, /*#__PURE__*/_react.default.createElement(_rRangeSlider.default, {
1150
- start: 0,
1151
- end: keys.length - 1,
1152
- labelStep: 1,
1153
- editLabel: value => keys[value],
1154
- labelStyle: () => {
1155
- return {
1156
- top: 0
1157
- };
1158
- },
1159
- pointStyle: () => {
1160
- return {
1161
- display: 'none'
1162
- };
1163
- },
1164
- lineStyle: () => {
1165
- return {
1166
- display: 'none'
1167
- };
1261
+ if (!model.length) {
1262
+ if (disabled) {
1263
+ return null;
1168
1264
  }
1169
- }));
1170
- }
1171
1265
 
1172
- render() {
1173
- let {
1174
- column,
1175
- onDragStart,
1176
- onDragOver,
1177
- onDrop,
1178
- isLast
1179
- } = this.props;
1180
- let {
1181
- rtl
1182
- } = this.context;
1183
-
1184
- if (column.template && column.template.type === 'gantt') {
1185
- return this.getGanttTitle(column);
1266
+ return /*#__PURE__*/_react.default.createElement("div", {
1267
+ className: "aio-form-table-add aio-form-input",
1268
+ onClick: () => this.add()
1269
+ }, "+");
1186
1270
  }
1187
1271
 
1188
- let title = typeof column.title === 'function' ? column.title() : column.title;
1189
- let attrs = { ...this.context.titleAttrs,
1190
- ...column.titleAttrs
1191
- };
1192
- let dataUniqId = 'aiotabletitle' + Math.round(Math.random() * 10000000);
1193
- return /*#__PURE__*/_react.default.createElement("div", {
1194
- ref: this.dom,
1195
- "data-uniq-id": dataUniqId,
1196
- style: this.getStyle(attrs.style),
1197
- draggable: false,
1198
- className: 'aio-table-title' + (attrs.className ? ' ' + attrs.className : '') + (isLast ? ' last-child' : '') + (rtl ? ' rtl' : ' ltr')
1199
- }, /*#__PURE__*/_react.default.createElement(AIOTableFilter, {
1200
- column: column,
1201
- dataUniqId: dataUniqId
1202
- }), /*#__PURE__*/_react.default.createElement("div", {
1203
- className: "aio-table-title-text",
1204
- style: {
1205
- justifyContent: column.titleJustify !== false ? 'center' : undefined,
1206
- cursor: column.movable === false ? undefined : 'move'
1272
+ let columns = this.getColumns();
1273
+ let props = {
1274
+ getCellStyle: () => {
1275
+ return style;
1207
1276
  },
1208
- draggable: column.movable !== false,
1209
- onDragStart: () => onDragStart(column.realIndex),
1210
- onDragOver: e => onDragOver(e, column.realIndex),
1211
- onDrop: () => onDrop(column)
1212
- }, title), column.width !== 'auto' && /*#__PURE__*/_react.default.createElement("div", {
1213
- className: "aio-table-resize",
1214
- style: {
1215
- cursor: column.resizable ? 'col-resize' : 'default'
1277
+ titleStyle: style,
1278
+ disabled,
1279
+ className,
1280
+ columns,
1281
+ toolbarItems: this.getToolbarItems(),
1282
+ columns,
1283
+ model: value,
1284
+ style: attrs ? attrs.style : undefined
1285
+ };
1286
+ return /*#__PURE__*/_react.default.createElement(_aioTable.default, {
1287
+ columns: props.columns,
1288
+ model: props.model,
1289
+ rowGap: 0,
1290
+ toolbarItems: props.toolbarItems,
1291
+ toolbarAttrs: {
1292
+ className: 'aio-form-input',
1293
+ style: {
1294
+ border: 'none',
1295
+ display: disabled ? 'none' : undefined
1296
+ }
1216
1297
  },
1217
- draggable: false,
1218
- onTouchStart: e => this.mouseDown(e, column),
1219
- onMouseDown: e => this.mouseDown(e, column)
1220
- }));
1298
+ style: props.style
1299
+ });
1221
1300
  }
1222
1301
 
1223
- }
1224
-
1225
- _defineProperty(AIOTableTitle, "contextType", AioTableContext);
1226
-
1227
- class AIOTableGroup extends _react.Component {
1228
- getStyle() {
1229
- let {
1230
- rowHeight,
1231
- fn
1232
- } = this.context;
1233
- let {
1234
- columns
1235
- } = this.props;
1236
- return { ...fn.getFullCellStyle(columns),
1237
- height: rowHeight
1238
- };
1239
- }
1240
-
1241
- getIcon(row) {
1242
- let {
1243
- rtl
1244
- } = this.context;
1245
-
1246
- if (row._opened) {
1247
- return aioTableGetSvg('chevronDown', {
1248
- box: '2 1 20 20'
1249
- });
1250
- }
1251
-
1252
- return aioTableGetSvg('chevronRight', {
1253
- flip: rtl === true
1254
- });
1255
- }
1256
-
1257
- click(row) {
1258
- let {
1259
- SetState,
1260
- groupsOpen
1261
- } = this.context;
1262
- var {
1263
- _groupId
1264
- } = row;
1265
- groupsOpen[_groupId] = !groupsOpen[_groupId];
1266
- SetState({
1267
- groupsOpen
1268
- });
1269
- }
1270
-
1271
- render() {
1272
- let {
1273
- indent
1274
- } = this.context;
1275
- let {
1276
- row,
1277
- tableIndex
1278
- } = this.props;
1279
- return /*#__PURE__*/_react.default.createElement("div", {
1280
- className: "aio-table-group",
1281
- style: this.getStyle()
1282
- }, tableIndex !== 1 && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
1283
- style: {
1284
- width: indent * row._level,
1285
- flexShrink: 0
1286
- }
1287
- }), /*#__PURE__*/_react.default.createElement("div", {
1288
- className: "aio-table-toggle",
1289
- onClick: () => this.click(row)
1290
- }, this.getIcon(row)), /*#__PURE__*/_react.default.createElement("div", {
1291
- className: "aio-table-cell-gap"
1292
- }), /*#__PURE__*/_react.default.createElement("div", {
1293
- className: "aio-table-group-text"
1294
- }, row._groupValue)));
1295
- }
1296
-
1297
- }
1298
-
1299
- _defineProperty(AIOTableGroup, "contextType", AioTableContext);
1300
-
1301
- class AIOTableCell extends _react.Component {
1302
- constructor(props) {
1303
- super(props);
1304
- this.dom = /*#__PURE__*/(0, _react.createRef)();
1305
- var {
1306
- value
1307
- } = this.props;
1308
- this.state = {
1309
- value,
1310
- error: false,
1311
- prevValue: value
1312
- };
1313
- }
1314
-
1315
- getStyle(column, row) {
1316
- var {
1317
- template,
1318
- minWidth = '30px'
1319
- } = column;
1320
- var {
1321
- rowHeight,
1322
- getCellAttrs
1323
- } = this.context;
1324
- let {
1325
- striped
1326
- } = this.props;
1327
- var style = {
1328
- height: rowHeight,
1329
- overflow: template ? undefined : 'hidden',
1330
- minWidth
1331
- };
1332
-
1333
- if (column.template && column.template.type === 'gantt') {
1334
- style.padding = 0;
1335
- }
1336
-
1337
- if (typeof striped === 'string') {
1338
- style.background = striped;
1339
- } else if (Array.isArray(striped)) {
1340
- style.background = striped[0];
1341
- style.color = striped[1];
1342
- }
1343
-
1344
- let attrs = getCellAttrs(row, column);
1345
- return { ...style,
1346
- ...attrs.style
1347
- };
1348
- }
1349
-
1350
- getClassName(row, column) {
1351
- let {
1352
- getCellAttrs
1353
- } = this.context;
1354
- var className = 'aio-table-cell';
1355
- let {
1356
- striped
1357
- } = this.props;
1358
- let attrs = getCellAttrs(row, column);
1359
-
1360
- if (striped === true) {
1361
- className += ' striped';
1362
- }
1363
-
1364
- if (column.selectable !== false) {
1365
- className += ' aio-table-cell-selectable';
1366
- }
1367
-
1368
- if (column.template && column.template.type === 'gantt') {
1369
- className += ' aio-table-cell-gantt';
1370
- }
1371
-
1372
- if (attrs.className) {
1373
- className += ' ' + attrs.className;
1374
- }
1375
-
1376
- if (column.inlineEdit) {
1377
- className += ' aio-table-cell-input';
1378
- }
1379
-
1380
- if (row._show === 'relativeFilter') {
1381
- className += ' aio-table-relative-filter';
1382
- }
1383
-
1384
- if (row._show === false) {
1385
- className += ' aio-table-cell-hidden';
1386
- }
1387
-
1388
- if (row._isFirstChild) {
1389
- className += ' first-child';
1390
- }
1391
-
1392
- if (row._isLastChild) {
1393
- className += ' last-child';
1394
- }
1395
-
1396
- return className;
1397
- }
1398
-
1399
- getToggleIcon(row) {
1400
- let {
1401
- rtl,
1402
- fn
1403
- } = this.context;
1404
- let icon;
1405
-
1406
- if (row._opened) {
1407
- icon = aioTableGetSvg('chevronDown');
1408
- } else {
1409
- icon = aioTableGetSvg('chevronRight', {
1410
- flip: rtl === true
1411
- });
1412
- }
1413
-
1414
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
1415
- className: "aio-table-toggle",
1416
- onClick: () => fn.toggleRow(row),
1417
- style: {
1418
- opacity: row._childsLength ? 1 : 0
1419
- }
1420
- }, icon), /*#__PURE__*/_react.default.createElement("div", {
1421
- className: "aio-table-cell-gap"
1422
- }));
1423
- }
1424
-
1425
- splitNumber(num) {
1426
- if (!num) {
1427
- return num;
1428
- }
1429
-
1430
- let str = num.toString();
1431
- let dotIndex = str.indexOf('.');
1432
-
1433
- if (dotIndex !== -1) {
1434
- str = str.slice(0, dotIndex);
1435
- }
1436
-
1437
- let res = '';
1438
- let index = 0;
1439
-
1440
- for (let i = str.length - 1; i >= 0; i--) {
1441
- res = str[i] + res;
1442
-
1443
- if (index === 2) {
1444
- index = 0;
1445
-
1446
- if (i > 0) {
1447
- res = ',' + res;
1448
- }
1449
- } else {
1450
- index++;
1451
- }
1452
- }
1453
-
1454
- return res;
1455
- }
1456
-
1457
- getContentByTemplate(row, column, value) {
1458
- let {
1459
- fn
1460
- } = this.context;
1461
- let template = typeof column.template === 'function' ? column.template(row, column) : column.template;
1462
-
1463
- if (!template) {
1464
- return value;
1465
- }
1466
-
1467
- if (template.type === 'slider') {
1468
- return fn.getSliderCell(template, value);
1469
- }
1470
-
1471
- if (template.type === 'checkbox') {
1472
- return fn.getCheckboxCell(template, value, row);
1473
- }
1474
-
1475
- if (template.type === 'options') {
1476
- return fn.getOptionsCell(template, row);
1477
- }
1478
-
1479
- if (template.type === 'split') {
1480
- let newValue = this.splitNumber(value);
1481
-
1482
- if (template.editValue) {
1483
- newValue = template.editValue(newValue);
1484
- }
1485
-
1486
- return newValue;
1487
- }
1488
-
1489
- if (template.type === 'gantt') {
1490
- return fn.getGanttCell(row, template);
1491
- }
1492
-
1493
- return template;
1494
- }
1495
-
1496
- getContent(row, column, value) {
1497
- let {
1498
- focused
1499
- } = this.context;
1500
- let {
1501
- inlineEdit
1502
- } = this.props;
1503
- let template = this.getContentByTemplate(row, column, value);
1504
- var content = '';
1505
-
1506
- if (inlineEdit && focused) {
1507
- content = this.getInput(row, column);
1508
- } else {
1509
- content = template;
1510
- }
1511
-
1512
- if (column.subText) {
1513
- let subText;
1514
-
1515
- try {
1516
- subText = column.subText(row);
1517
- } catch {
1518
- subText = '';
1519
- }
1520
-
1521
- return /*#__PURE__*/_react.default.createElement("div", {
1522
- className: "aio-table-cell-has-subtext"
1523
- }, /*#__PURE__*/_react.default.createElement("div", {
1524
- style: {
1525
- flex: 1
1526
- }
1527
- }), /*#__PURE__*/_react.default.createElement("div", {
1528
- className: "aio-table-cell-uptext"
1529
- }, content), /*#__PURE__*/_react.default.createElement("div", {
1530
- className: "aio-table-cell-subtext"
1531
- }, subText), /*#__PURE__*/_react.default.createElement("div", {
1532
- style: {
1533
- flex: 1
1534
- }
1535
- }));
1536
- }
1537
-
1538
- return content;
1539
- }
1540
-
1541
- async changeCell(value) {
1542
- let {
1543
- row,
1544
- column,
1545
- inlineEdit
1546
- } = this.props;
1547
- let {
1548
- fn
1549
- } = this.context;
1550
- let res;
1551
- this.setState({
1552
- loading: true
1553
- });
1554
-
1555
- if (inlineEdit.onChange) {
1556
- res = await inlineEdit.onChange(row, value);
1557
- } else if (typeof column.getValue === 'string') {
1558
- res = await this.context.onChange(fn.setCellValue(row, column.getValue, value));
1559
- }
1560
-
1561
- this.setState({
1562
- loading: false
1563
- });
1564
- return res;
1565
- }
1566
-
1567
- getInput(row, column) {
1568
- let {
1569
- fn
1570
- } = this.context;
1571
- let {
1572
- attrs,
1573
- inlineEdit
1574
- } = this.props;
1575
- let {
1576
- type,
1577
- getValue,
1578
- disabled = () => false,
1579
- options
1580
- } = inlineEdit;
1581
- let {
1582
- value
1583
- } = this.state;
1584
-
1585
- if (getValue) {
1586
- value = fn.getCellValue(row, getValue);
1587
- }
1588
-
1589
- if (disabled(row)) {
1590
- if (typeof value === 'boolean') {
1591
- return JSON.stringify(value);
1592
- }
1593
-
1594
- return value;
1595
- }
1596
-
1597
- let props = { ...inlineEdit,
1598
- className: 'aio-table-input',
1599
- 'data-row-index': attrs['data-row-index'],
1600
- 'data-col-index': attrs['data-col-index'],
1601
- value: value === null || value === undefined ? '' : value
1602
- };
1603
-
1604
- if (type === 'text' || type === 'number') {
1605
- return /*#__PURE__*/_react.default.createElement("div", {
1606
- className: 'aio-table-input-container'
1607
- }, /*#__PURE__*/_react.default.createElement("input", _extends({}, props, {
1608
- style: {
1609
- textAlign: column.justify || type === 'number' ? 'center' : undefined
1610
- },
1611
- onChange: e => this.setState({
1612
- value: e.target.value
1613
- }),
1614
- onBlur: async e => {
1615
- let {
1616
- value
1617
- } = this.state;
1618
-
1619
- if (value === this.props.value) {
1620
- return;
1621
- }
1622
-
1623
- let newValue = value;
1624
-
1625
- if (type === 'number') {
1626
- newValue = parseFloat(newValue);
1627
-
1628
- if (isNaN(newValue)) {
1629
- newValue = 0;
1630
- }
1631
- }
1632
-
1633
- let res = await this.changeCell(newValue);
1634
-
1635
- if (typeof res === 'string') {
1636
- this.setState({
1637
- error: res
1638
- });
1639
- } else {
1640
- this.setState({
1641
- value: this.props.value
1642
- });
1643
- }
1644
- }
1645
- })), /*#__PURE__*/_react.default.createElement("div", {
1646
- className: "aio-table-input-border"
1647
- }));
1648
- }
1649
-
1650
- if (type === 'select') {
1651
- if (!options) {
1652
- console.error('aio table => missing options property of column inlineEdit with type="select"');
1653
- return '';
1654
- }
1655
-
1656
- if (!Array.isArray(options)) {
1657
- 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!!!');
1658
- return '';
1659
- }
1660
-
1661
- return /*#__PURE__*/_react.default.createElement("div", {
1662
- className: "aio-table-input-container"
1663
- }, /*#__PURE__*/_react.default.createElement("select", _extends({}, props, {
1664
- onFocus: () => this.focus = true,
1665
- onBlur: () => this.focus = false,
1666
- onChange: async e => {
1667
- let value = e.target.value;
1668
-
1669
- if (value === 'true') {
1670
- value = true;
1671
- }
1672
-
1673
- if (value === 'false') {
1674
- value = false;
1675
- }
1676
-
1677
- this.setState({
1678
- value
1679
- });
1680
- let res = await this.changeCell(value);
1681
-
1682
- if (typeof res === 'string') {
1683
- this.setState({
1684
- error: res
1685
- });
1686
- } else if (res === false) {
1687
- this.setState({
1688
- value: this.props.value
1689
- });
1690
- }
1691
- }
1692
- }), options.map((o, i) => /*#__PURE__*/_react.default.createElement("option", {
1693
- key: i,
1694
- value: o.value
1695
- }, o.text))), /*#__PURE__*/_react.default.createElement("div", {
1696
- className: "aio-table-input-border"
1697
- }));
1698
- }
1699
-
1700
- if (type === 'checkbox') {
1701
- return /*#__PURE__*/_react.default.createElement("div", {
1702
- className: 'aio-table-input-container',
1703
- tabIndex: 0,
1704
- onKeyDown: async e => {
1705
- if (e.keyCode === 13) {
1706
- value = value === true ? true : false;
1707
- await this.changeCell(!value);
1708
- }
1709
- }
1710
- }, /*#__PURE__*/_react.default.createElement("input", _extends({}, props, {
1711
- onFocus: () => this.focus = true,
1712
- onBlur: () => this.focus = false,
1713
- checked: value === true ? true : false,
1714
- onChange: async e => {
1715
- let value = e.target.checked;
1716
- this.setState({
1717
- loading: true
1718
- });
1719
- await this.changeCell(value);
1720
- this.setState({
1721
- loading: false
1722
- });
1723
- }
1724
- })), /*#__PURE__*/_react.default.createElement("div", {
1725
- className: "aio-table-input-border"
1726
- }));
1727
- }
1728
-
1729
- console.error('aio table => missing type property of column input');
1730
- return '';
1731
- }
1732
-
1733
- componentDidUpdate() {
1734
- let {
1735
- inlineEdit
1736
- } = this.props;
1737
-
1738
- if (inlineEdit && this.focus) {
1739
- if (inlineEdit.type === 'select' || inlineEdit.type === 'checkbox') {
1740
- (0, _jquery.default)(this.dom.current).find('.aio-table-input').focus();
1741
- }
1742
- }
1743
- }
1744
-
1745
- getProps(row, column, content) {
1746
- let attrs = this.context.getCellAttrs(row, column);
1747
- let title = typeof content === 'string' ? content : undefined;
1748
- return {
1749
- ref: this.dom,
1750
- title,
1751
- ...attrs,
1752
- style: this.getStyle(column, row),
1753
- className: this.getClassName(row, column)
1754
- };
1755
- }
1756
-
1757
- render() {
1758
- let {
1759
- indent,
1760
- fn
1761
- } = this.context;
1762
- let {
1763
- row,
1764
- column,
1765
- value,
1766
- before,
1767
- after,
1768
- justify,
1769
- attrs
1770
- } = this.props;
1771
-
1772
- if (this.state.prevValue !== value) {
1773
- setTimeout(() => this.setState({
1774
- value,
1775
- prevValue: value
1776
- }), 0);
1777
- }
1778
-
1779
- let {
1780
- error,
1781
- loading
1782
- } = this.state;
1783
- let content = this.getContent(row, column, value);
1784
-
1785
- if (column.affix) {
1786
- content = content + ' ' + column.affix;
1787
- }
1788
-
1789
- let cell;
1790
-
1791
- if (loading) {
1792
- return fn.cubes2();
1793
- }
1794
-
1795
- if (error) {
1796
- cell = /*#__PURE__*/_react.default.createElement("div", {
1797
- className: "aio-table-error",
1798
- onClick: () => {
1799
- this.setState({
1800
- value: this.props.value,
1801
- error: false
1802
- });
1803
- }
1804
- }, error);
1805
- } else {
1806
- cell = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, column.treeMode && /*#__PURE__*/_react.default.createElement("div", {
1807
- style: {
1808
- width: row._level * indent,
1809
- flexShrink: 0
1810
- }
1811
- }), column.treeMode && this.getToggleIcon(row), before !== undefined && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
1812
- className: "aio-table-icon"
1813
- }, before), /*#__PURE__*/_react.default.createElement("div", {
1814
- className: "aio-table-cell-gap"
1815
- })), content !== undefined && /*#__PURE__*/_react.default.createElement("div", {
1816
- className: "aio-table-cell-content",
1817
- style: {
1818
- justifyContent: justify ? 'center' : undefined
1819
- }
1820
- }, content), after !== undefined && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
1821
- style: {
1822
- flex: 1
1823
- }
1824
- }), /*#__PURE__*/_react.default.createElement("div", {
1825
- className: "aio-table-icon"
1826
- }, after)));
1827
- }
1828
-
1829
- return /*#__PURE__*/_react.default.createElement("div", _extends({}, attrs, this.getProps(row, column, content)), cell);
1830
- }
1831
-
1832
- }
1833
-
1834
- _defineProperty(AIOTableCell, "contextType", AioTableContext);
1835
-
1836
- class AIOTableFilter extends _react.Component {
1837
- constructor(...args) {
1838
- super(...args);
1839
-
1840
- _defineProperty(this, "dom", /*#__PURE__*/(0, _react.createRef)());
1841
- }
1842
-
1843
- async change(obj) {
1844
- let {
1845
- SetState,
1846
- columns
1847
- } = this.context;
1848
- let {
1849
- column
1850
- } = this.props;
1851
- column = { ...column,
1852
- filter: { ...column.filter,
1853
- ...obj
1854
- }
1855
- };
1856
- let approve = true;
1857
-
1858
- if (column.filter.onChange) {
1859
- let loading = (0, _jquery.default)(this.dom.current).parents('.aio-table').find('.aio-table-main-loading');
1860
- loading.css({
1861
- display: 'flex'
1862
- });
1863
- approve = await newFilter.onChange(column.filter);
1864
- loading.css({
1865
- display: 'none'
1866
- });
1867
- }
1868
-
1869
- if (approve !== false) {
1870
- SetState({
1871
- columns: columns.map(o => o.realIndex === column.realIndex ? column : o)
1872
- });
1873
- }
1874
- }
1875
-
1876
- render() {
1877
- var {
1878
- rtl,
1879
- translate
1880
- } = this.context;
1881
- var {
1882
- column
1883
- } = this.props;
1884
-
1885
- if (!column.filter || column.search) {
1886
- return null;
1887
- }
1888
-
1889
- let {
1890
- items = [],
1891
- booleanType = 'or',
1892
- type = 'text'
1893
- } = column.filter;
1894
- let icon = items.length ? aioTableGetSvg('filterActive', {
1895
- className: 'has-filter'
1896
- }) : aioTableGetSvg('filter');
1897
- return /*#__PURE__*/_react.default.createElement("div", {
1898
- className: "aio-table-filter-icon",
1899
- ref: this.dom,
1900
- onClick: () => {
1901
- (0, _jquery.default)('.aio-table-title').css({
1902
- zIndex: 100
1903
- });
1904
- (0, _jquery.default)(`[data-uniq-id = ${this.props.dataUniqId}]`).css({
1905
- zIndex: 1000
1906
- });
1907
- }
1908
- }, /*#__PURE__*/_react.default.createElement(_aioButton.default, {
1909
- type: "button",
1910
- rtl: rtl,
1911
- caret: false,
1912
- openRelatedTo: ".aio-table",
1913
- text: icon,
1914
- popOver: () => {
1915
- return /*#__PURE__*/_react.default.createElement(AIOTableFilterPopup, {
1916
- translate,
1917
- type,
1918
- items,
1919
- booleanType,
1920
- onChange: obj => this.change(obj)
1921
- });
1922
- }
1923
- }));
1924
- }
1925
-
1926
- }
1927
-
1928
- _defineProperty(AIOTableFilter, "contextType", AioTableContext);
1929
-
1930
- class AIOTableFilterPopup extends _react.Component {
1931
- render() {
1932
- var {
1933
- type,
1934
- items,
1935
- booleanType,
1936
- onChange,
1937
- translate = str => str
1938
- } = this.props;
1939
- var filterItems = items.map((item, i) => {
1940
- return /*#__PURE__*/_react.default.createElement(_react.Fragment, {
1941
- key: i
1942
- }, /*#__PURE__*/_react.default.createElement(AIOTableFilterItem, {
1943
- item: item,
1944
- type: type,
1945
- onChange: (key, value) => onChange({
1946
- items: items.map((o, index) => {
1947
- if (i === index) {
1948
- return { ...o,
1949
- [key]: value
1950
- };
1951
- }
1952
-
1953
- return o;
1954
- })
1955
- }),
1956
- onRemove: () => onChange({
1957
- items: items.filter((o, index) => index !== i)
1958
- }),
1959
- translate: translate
1960
- }), i < items.length - 1 && /*#__PURE__*/_react.default.createElement("div", {
1961
- className: "aio-table-boolean",
1962
- onClick: () => onChange({
1963
- booleanType: booleanType === 'or' ? 'and' : 'or'
1964
- })
1965
- }, translate(booleanType)));
1966
- });
1967
- return /*#__PURE__*/_react.default.createElement("div", {
1968
- className: "aio-table-filter-popup",
1969
- style: {
1970
- minWidth: 250
1971
- }
1972
- }, filterItems, /*#__PURE__*/_react.default.createElement("div", {
1973
- className: "aio-table-filter-footer"
1974
- }, /*#__PURE__*/_react.default.createElement("button", {
1975
- className: "aio-table-filter-add",
1976
- onClick: () => onChange({
1977
- items: items.concat({
1978
- operator: 'contain',
1979
- value: '',
1980
- type
1981
- })
1982
- })
1983
- }, translate('Add'))));
1984
- }
1985
-
1986
- }
1987
-
1988
- exports.AIOTableFilterPopup = AIOTableFilterPopup;
1989
-
1990
- class AIOTableFilterItem extends _react.Component {
1991
- constructor(props) {
1992
- super(props);
1993
- var {
1994
- item
1995
- } = this.props;
1996
- this.state = {
1997
- value: item.value,
1998
- prevValue: item.value
1999
- };
2000
- }
2001
-
2002
- changeValue(value) {
2003
- clearTimeout(this.timeout);
2004
- this.setState({
2005
- value
2006
- });
2007
- this.timeout = setTimeout(() => {
2008
- var {
2009
- onChange
2010
- } = this.props;
2011
- onChange('value', value);
2012
- }, 1000);
2013
- }
2014
-
2015
- getOptions(type, translate) {
2016
- let options = [];
2017
-
2018
- if (type !== 'number' && type !== 'date') {
2019
- options.push( /*#__PURE__*/_react.default.createElement("option", {
2020
- key: "contain",
2021
- value: "contain"
2022
- }, translate('Contain')));
2023
- options.push( /*#__PURE__*/_react.default.createElement("option", {
2024
- key: "notContain",
2025
- value: "notContain"
2026
- }, translate('Not Contain')));
2027
- }
2028
-
2029
- options.push( /*#__PURE__*/_react.default.createElement("option", {
2030
- key: "equal",
2031
- value: "equal"
2032
- }, translate('Equal')));
2033
- options.push( /*#__PURE__*/_react.default.createElement("option", {
2034
- key: "notEqual",
2035
- value: "notEqual"
2036
- }, translate('Not Equal')));
2037
-
2038
- if (type !== 'text') {
2039
- options.push( /*#__PURE__*/_react.default.createElement("option", {
2040
- key: "greater",
2041
- value: "greater"
2042
- }, translate('Greater')));
2043
- options.push( /*#__PURE__*/_react.default.createElement("option", {
2044
- key: "less",
2045
- value: "less"
2046
- }, translate('Less')));
2047
- }
2048
-
2049
- return options;
2050
- }
2051
-
2052
- render() {
2053
- var {
2054
- item,
2055
- type,
2056
- onChange,
2057
- onRemove,
2058
- translate
2059
- } = this.props;
2060
-
2061
- if (this.state.prevValue !== item.value) {
2062
- setTimeout(() => this.setState({
2063
- value: item.value,
2064
- prevValue: item.value
2065
- }), 0);
2066
- }
2067
-
2068
- var {
2069
- value
2070
- } = this.state;
2071
- return /*#__PURE__*/_react.default.createElement("div", {
2072
- className: "aio-table-filter-item"
2073
- }, /*#__PURE__*/_react.default.createElement("select", {
2074
- value: item.operator,
2075
- onChange: e => onChange('operator', e.target.value)
2076
- }, this.getOptions(type, translate)), /*#__PURE__*/_react.default.createElement("div", {
2077
- style: {
2078
- width: '6px'
2079
- }
2080
- }), /*#__PURE__*/_react.default.createElement("input", {
2081
- type: type === 'date' ? 'text' : type,
2082
- value: value,
2083
- onChange: e => this.changeValue(e.target.value)
2084
- }), /*#__PURE__*/_react.default.createElement("div", {
2085
- style: {
2086
- width: '6px'
2087
- }
2088
- }), /*#__PURE__*/_react.default.createElement("div", {
2089
- className: "aio-table-filter-remove",
2090
- onClick: () => onRemove()
2091
- }, aioTableGetSvg('close')));
2092
- }
2093
-
2094
- }
2095
-
2096
- function ATFN({
2097
- getProps,
2098
- getState,
2099
- setState,
2100
- getContext
2101
- }) {
2102
- let $$ = {
2103
- fixPersianAndArabicNumbers(str) {
2104
- var persianNumbers = [/۰/g, /۱/g, /۲/g, /۳/g, /۴/g, /۵/g, /۶/g, /۷/g, /۸/g, /۹/g],
2105
- arabicNumbers = [/٠/g, /١/g, /٢/g, /٣/g, /٤/g, /٥/g, /٦/g, /٧/g, /٨/g, /٩/g];
2106
-
2107
- if (typeof str === 'string') {
2108
- for (var i = 0; i < 10; i++) {
2109
- str = str.replace(persianNumbers[i], i).replace(arabicNumbers[i], i);
2110
- }
2111
- }
2112
-
2113
- return str;
2114
- },
2115
-
2116
- getJSON(columns, rows) {
2117
- let result = [];
2118
-
2119
- for (let i = 0; i < rows.length; i++) {
2120
- if (!rows[i].row) {
2121
- continue;
2122
- }
2123
-
2124
- let row = rows[i].row;
2125
- let obj = {};
2126
-
2127
- for (let j = 0; j < columns.length; j++) {
2128
- let {
2129
- title,
2130
- realIndex
2131
- } = columns[j];
2132
- let res = row._values[realIndex];
2133
- obj[title] = res !== undefined ? $$.fixPersianAndArabicNumbers(res) : "";
2134
- }
2135
-
2136
- result.push(obj);
2137
- }
2138
-
2139
- return result;
2140
- },
2141
-
2142
- exportToExcel(columns, rows) {
2143
- let {
2144
- translate
2145
- } = getProps();
2146
- let name = window.prompt(translate('Inter Excel File Name')); // if (name === false || name === undefined || name === null) { return; }
2147
-
2148
- if (!name || name === null || !name.length) return;
2149
- var data = $$.getJSON(columns, rows);
2150
- var arrData = typeof data != "object" ? JSON.parse(data) : data;
2151
- var CSV = ""; // CSV += 'title';
2152
-
2153
- CSV += '\r\n\n';
2154
-
2155
- if (true) {
2156
- let row = "";
2157
-
2158
- for (let index in arrData[0]) {
2159
- row += index + ",";
2160
- }
2161
-
2162
- row = row.slice(0, -1);
2163
- CSV += row + "\r\n";
2164
- }
2165
-
2166
- for (var i = 0; i < arrData.length; i++) {
2167
- let row = "";
2168
-
2169
- for (let index in arrData[i]) {
2170
- row += '"' + arrData[i][index] + '",';
2171
- }
2172
-
2173
- row.slice(0, row.length - 1);
2174
- CSV += row + "\r\n";
2175
- }
2176
-
2177
- if (CSV === "") {
2178
- alert("Invalid data");
2179
- return;
2180
- }
2181
-
2182
- var fileName = name.replace(/ /g, "_");
2183
- var universalBOM = "\uFEFF";
2184
- var uri = "data:text/csv;charset=utf-8," + encodeURIComponent(universalBOM + CSV);
2185
- var link = document.createElement("a");
2186
- link.href = uri;
2187
- link.style = "visibility:hidden";
2188
- link.download = fileName + ".csv";
2189
- document.body.appendChild(link);
2190
- link.click();
2191
- document.body.removeChild(link);
2192
- },
2193
-
2194
- getSliderCell(template, val) {
2195
- let {
2196
- colors = ['#eee', 'dodgerblue'],
2197
- start = 0,
2198
- end = 100,
2199
- value = val,
2200
- editValue = value => value
2201
- } = template;
2202
- let {
2203
- rowHeight,
2204
- rtl
2205
- } = getProps();
2206
- let [clr1 = '#eee', clr2 = 'dodgerblue'] = colors;
2207
- let points = Array.isArray(value) ? value : [value];
2208
-
2209
- if (points.length > 2) {
2210
- points = [points[0], points[1]];
2211
- }
2212
-
2213
- return /*#__PURE__*/_react.default.createElement("div", {
2214
- className: "aio-table-slider"
2215
- }, points.length === 2 && /*#__PURE__*/_react.default.createElement("div", {
2216
- style: {
2217
- display: 'flex',
2218
- alignItems: 'center',
2219
- padding: '0 3px'
2220
- }
2221
- }, editValue(points[0])), /*#__PURE__*/_react.default.createElement(_rRangeSlider.default, {
2222
- style: {
2223
- height: rowHeight
2224
- },
2225
- direction: rtl ? 'left' : 'right',
2226
- start: start,
2227
- end: end,
2228
- step: 0.1,
2229
- pointStyle: () => {
2230
- return {
2231
- display: 'none'
2232
- };
2233
- },
2234
- lineStyle: () => {
2235
- return {
2236
- height: 5,
2237
- borderRadius: 6,
2238
- background: clr1
2239
- };
2240
- },
2241
- fillStyle: (index, obj) => {
2242
- if (index === (points.length === 2 ? 1 : 0)) {
2243
- return {
2244
- height: 5,
2245
- background: clr2,
2246
- borderRadius: 6
2247
- };
2248
- }
2249
- },
2250
- points: points
2251
- }), /*#__PURE__*/_react.default.createElement("div", {
2252
- style: {
2253
- display: 'flex',
2254
- alignItems: 'center',
2255
- padding: '0 3px'
2256
- }
2257
- }, editValue(points[points.length - 1])));
2258
- },
2259
-
2260
- getOptionsCell({
2261
- options
2262
- }, row) {
2263
- return /*#__PURE__*/_react.default.createElement(_aioButton.default, {
2264
- type: "select",
2265
- caret: false,
2266
- className: "aio-table-options",
2267
- text: aioTableGetSvg('dots'),
2268
- options: options.map(({
2269
- text,
2270
- icon,
2271
- onClick
2272
- }) => {
2273
- return {
2274
- text,
2275
- before: icon,
2276
- onClick: () => onClick(row)
2277
- };
2278
- })
2279
- });
2280
- },
2281
-
2282
- getCheckboxCell(template, value, row) {
2283
- let {
2284
- color,
2285
- onChange,
2286
- size = 24
2287
- } = template;
2288
- let style = {
2289
- width: size,
2290
- height: size
2291
- };
2292
-
2293
- if (!!value) {
2294
- return /*#__PURE__*/_react.default.createElement("svg", {
2295
- style: style,
2296
- viewBox: `0,0,24,24`,
2297
- className: "aio-table-checkbox checked",
2298
- onClick: () => onChange(row, false)
2299
- }, /*#__PURE__*/_react.default.createElement("path", {
2300
- fill: color,
2301
- d: "M10,17L5,12L6.41,10.58L10,14.17L17.59,6.58L19,8M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3Z"
2302
- }));
2303
- } else {
2304
- return /*#__PURE__*/_react.default.createElement("svg", {
2305
- style: style,
2306
- viewBox: `0,0,24,24`,
2307
- className: "aio-table-checkbox",
2308
- onClick: () => onChange(row, true)
2309
- }, /*#__PURE__*/_react.default.createElement("path", {
2310
- fill: color,
2311
- "ng-attr-fill": "{{icon.color}}",
2312
- "ng-attr-d": "{{icon.data}}",
2313
- d: "M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3M19,5V19H5V5H19Z"
2314
- }));
2315
- }
2316
- },
2317
-
2318
- getGanttCell(row, template) {
2319
- let {
2320
- rtl
2321
- } = getProps();
2322
- let {
2323
- getKeys,
2324
- getColor = () => '#fff',
2325
- getBackgroundColor = () => '#69bedb',
2326
- getFlags = () => [],
2327
- getProgress = () => false,
2328
- getText = () => false,
2329
- getStart,
2330
- getEnd,
2331
- padding = 36
2332
- } = template;
2333
- let keys = getKeys();
2334
-
2335
- if (!Array.isArray(keys)) {
2336
- console.error('aio table => gantt column => column getKeys property must return an array of strings');
2337
- return '';
2338
- }
2339
-
2340
- let color = $$.getCellValue(row, getColor);
2341
- let backgroundColor = $$.getCellValue(row, getBackgroundColor);
2342
- let progress = $$.getCellValue(row, getProgress);
2343
- let text = $$.getCellValue(row, getText);
2344
- let startIndex = keys.indexOf($$.getCellValue(row, getStart));
2345
- let endIndex = keys.indexOf($$.getCellValue(row, getEnd));
2346
- let background = progress === false ? color : `linear-gradient(to ${rtl ? 'left' : 'right'},rgba(0,0,0,.2) 0%,rgba(0,0,0,.2) ${progress}% ,transparent ${progress}%,transparent 100%)`;
2347
- let flags = getFlags();
2348
- return /*#__PURE__*/_react.default.createElement(_rRangeSlider.default, {
2349
- attrs: {
2350
- style: {
2351
- padding: `0 ${+padding}px`
2352
- }
2353
- },
2354
- start: 0,
2355
- editValue: value => keys[value],
2356
- end: keys.length - 1,
2357
- points: [startIndex, endIndex],
2358
- fillStyle: index => {
2359
- if (index === 1) {
2360
- return {
2361
- background: backgroundColor,
2362
- backgroundImage: background
2363
- };
2364
- }
2365
- },
2366
- getText: index => {
2367
- if (index === 1 && text) {
2368
- return text;
2369
- }
2370
- },
2371
- textStyle: () => {
2372
- return {
2373
- color
2374
- };
2375
- },
2376
- scaleStep: 1,
2377
- scaleStyle: value => {
2378
- let flag = flags.filter(o => keys.indexOf(o.value) === value)[0];
2379
-
2380
- if (flag) {
2381
- return {
2382
- background: flag.color,
2383
- height: '100%',
2384
- top: 0,
2385
- zIndex: 100
2386
- };
2387
- }
2388
-
2389
- return {
2390
- height: '100%',
2391
- top: 0,
2392
- opacity: .4
2393
- };
2394
- },
2395
- lineStyle: () => {
2396
- return {
2397
- opacity: .4
2398
- };
2399
- }
2400
- });
2401
- },
2402
-
2403
- handleOutsideClick() {
2404
- (0, _jquery.default)(window).unbind('click', $$.outSideClick);
2405
- (0, _jquery.default)(window).bind('click', $$.outSideClick);
2406
- },
2407
-
2408
- outSideClick(e) {
2409
- let {
2410
- focused
2411
- } = getState();
2412
-
2413
- if (focused === false) {
2414
- return;
2415
- }
2416
-
2417
- let target = (0, _jquery.default)(e.target);
2418
-
2419
- if (target.hasClass('aio-table-cell')) {
2420
- return;
2421
- }
2422
-
2423
- if (target.parents('.aio-table-input-container').length) {
2424
- return;
2425
- }
2426
-
2427
- if (target.parents('.aio-table-cell-content').length) {
2428
- return;
2429
- }
2430
-
2431
- if (target.parents('.aio-table-cell').length) {
2432
- return;
2433
- }
2434
-
2435
- (0, _jquery.default)(window).unbind('click', $$.outSideClick);
2436
- setState({
2437
- focused: false
2438
- }, 'outsideClick');
2439
- },
2440
-
2441
- getCardRowCount() {
2442
- var {
2443
- cardRowCount = 1
2444
- } = getProps();
2445
-
2446
- if (typeof cardRowCount !== 'object') {
2447
- return cardRowCount;
2448
- }
2449
-
2450
- let result,
2451
- matched = false;
2452
-
2453
- for (let prop in cardRowCount) {
2454
- let count = cardRowCount[prop];
2455
- let a = window.matchMedia(`(max-width: ${prop}px)`);
2456
-
2457
- if (a.matches && !matched) {
2458
- matched = true;
2459
- result = count;
2460
- }
2461
-
2462
- a.addListener(() => setState({
2463
- cardRowCount: count
2464
- }));
2465
- }
2466
-
2467
- return result;
2468
- },
2469
-
2470
- async onScroll(dom, index) {
2471
- let {
2472
- onScrollEnd
2473
- } = getProps();
2474
-
2475
- if (onScrollEnd) {
2476
- if (index === undefined || index === 0) {
2477
- let table = (0, _jquery.default)(dom.current).find('.aio-table-unit');
2478
- let scrollTop = table.scrollTop();
2479
- let scrollHeight = table[0].scrollHeight;
2480
- let height = table.height();
2481
-
2482
- if (scrollTop + height === scrollHeight) {
2483
- let {
2484
- startIndex
2485
- } = getState();
2486
- let {
2487
- scrollLoadLength,
2488
- scrollTotalLength
2489
- } = getProps();
2490
- let from = startIndex + scrollLoadLength;
2491
-
2492
- if (from > scrollTotalLength) {
2493
- return;
2494
- }
2495
-
2496
- let to = from + scrollLoadLength;
2497
-
2498
- if (to > scrollTotalLength) {
2499
- to = scrollTotalLength;
2500
- }
2501
-
2502
- let a = (0, _jquery.default)(dom.current).find('.aio-table-main-loading');
2503
- a.css({
2504
- display: 'flex'
2505
- });
2506
- let res = await onScrollEnd(from, to);
2507
- a.css({
2508
- display: 'none'
2509
- });
2510
-
2511
- if (res !== false) {
2512
- setState({
2513
- startIndex: from
2514
- });
2515
- }
2516
- }
2517
- }
2518
- }
2519
-
2520
- if (index === undefined) {
2521
- return;
2522
- }
2523
-
2524
- if (!$$['scroll' + index]) {
2525
- let otherIndex = Number(!index);
2526
- $$['scroll' + otherIndex] = true;
2527
- let c = (0, _jquery.default)(dom.current);
2528
- var units = [c.find('#aio-table-first-split'), c.find('#aio-table-second-split')];
2529
- var scrollTop = units[index].scrollTop();
2530
- units[otherIndex].scrollTop(scrollTop);
2531
- }
2532
-
2533
- $$['scroll' + index] = false;
2534
- },
2535
-
2536
- getOpenDictionary() {
2537
- let {
2538
- id
2539
- } = getProps();
2540
-
2541
- if (id === undefined) {
2542
- return {};
2543
- }
2544
-
2545
- let openDictionary = localStorage.getItem('aio table ' + id);
2546
-
2547
- if (openDictionary === null || openDictionary === undefined) {
2548
- localStorage.setItem('aio table ' + id, '{}');
2549
- return {};
2550
- } else {
2551
- return JSON.parse(openDictionary);
2552
- }
2553
- },
2554
-
2555
- getDateNumber(value) {
2556
- let splitter;
2557
-
2558
- for (let i = 0; i < value.length; i++) {
2559
- if (isNaN(parseInt(value[i]))) {
2560
- splitter = value[i];
2561
- break;
2562
- }
2563
- }
2564
-
2565
- let [year, month = '01', day = '01'] = value.split(splitter);
2566
- let list = [year, month, day];
2567
- return parseInt(list.map(o => o.length === 1 ? '0' + o : o).join(''));
2568
- },
2569
-
2570
- setCellValue: (row, getValue, value) => {
2571
- //row is used in eval
2572
- let {
2573
- model
2574
- } = getProps();
2575
- let evalText;
2576
-
2577
- if (typeof value === 'string') {
2578
- evalText = `row.${getValue} = "${value}"`;
2579
- } else {
2580
- evalText = 'row.' + getValue + ' = ' + JSON.stringify(value);
2581
- }
2582
-
2583
- eval(evalText);
2584
- return model;
2585
- },
2586
- getCellValue: (row, getValue) => {
2587
- try {
2588
- if (typeof getValue === 'function') {
2589
- return getValue(row);
2590
- }
2591
-
2592
- if (typeof getValue === 'string') {
2593
- let result;
2594
- eval('result = row.' + getValue);
2595
- return result;
2596
- }
2597
-
2598
- return;
2599
- } catch {
2600
- return;
2601
- }
2602
- },
2603
-
2604
- async onChangeSort(obj, colIndex) {
2605
- let {
2606
- columns
2607
- } = getState();
2608
- columns = [...columns];
2609
- let column = { ...columns[colIndex]
2610
- };
2611
- column.sort = { ...column.sort,
2612
- ...obj
2613
- };
2614
- let newColumns = columns.map((o, i) => i === colIndex ? column : o);
2615
- let approve = true;
2616
-
2617
- if (column.sort.onChange) {
2618
- let {
2619
- active = true,
2620
- dir = 'inc'
2621
- } = column.sort;
2622
- approve = await column.sort.onChange({
2623
- active,
2624
- dir
2625
- });
2626
- }
2627
-
2628
- if (approve !== false) {
2629
- setState({
2630
- columns: newColumns
2631
- });
2632
- }
2633
- },
2634
-
2635
- getSorts({
2636
- column,
2637
- sorts,
2638
- sortOptions,
2639
- columnTitle,
2640
- colIndex
2641
- }) {
2642
- let {
2643
- sort
2644
- } = column;
2645
- let {
2646
- title = columnTitle || '',
2647
- getValue = column.getValue,
2648
- type,
2649
- active = true,
2650
- toggle = true,
2651
- dir = 'inc',
2652
- onChange
2653
- } = sort;
2654
-
2655
- if (type === 'date') {
2656
- getValue = row => {
2657
- let {
2658
- sort
2659
- } = column;
2660
- let {
2661
- getValue = column.getValue
2662
- } = sort;
2663
- let value = $$.getCellValue(row, getValue);
2664
-
2665
- if (typeof value !== 'string') {
2666
- return 0;
2667
- }
2668
-
2669
- return $$.getDateNumber(value);
2670
- };
2671
- }
2672
-
2673
- sorts.push({
2674
- title,
2675
- dir,
2676
- active,
2677
- toggle,
2678
- getValue,
2679
- type,
2680
- onChange
2681
- });
2682
-
2683
- if (toggle) {
2684
- sortOptions.push({
2685
- text: title,
2686
- checked: !!active,
2687
- onClick: () => $$.onChangeSort({
2688
- active: !active
2689
- }, colIndex),
2690
- after: /*#__PURE__*/_react.default.createElement("div", {
2691
- style: {
2692
- width: '30px',
2693
- display: 'flex',
2694
- justifyContent: 'flex-end'
2695
- }
2696
- }, aioTableGetSvg(dir === 'dec' ? 'arrowDown' : 'arrowUp', {
2697
- onClick: e => {
2698
- e.stopPropagation();
2699
- $$.onChangeSort({
2700
- dir: dir === 'dec' ? 'inc' : 'dec'
2701
- }, colIndex);
2702
- }
2703
- }))
2704
- });
2705
- }
2706
- },
2707
-
2708
- getToggles(obj) {
2709
- let {
2710
- column,
2711
- toggleOptions,
2712
- colIndex,
2713
- columnTitle
2714
- } = obj;
2715
- let {
2716
- columns
2717
- } = getState();
2718
- toggleOptions.push({
2719
- text: columnTitle,
2720
- checked: column.show !== false,
2721
- onClick: () => {
2722
- //change columns imutable(prevent change columns directly)
2723
- let column = { ...obj.column,
2724
- show: !obj.column.show
2725
- };
2726
-
2727
- if (column.storageKey) {
2728
- column = { ...column,
2729
- _storageObj: { ...column._storageObj,
2730
- show: column.show
2731
- }
2732
- };
2733
- localStorage.setItem('aio-table-column-storage-' + column.storageKey, JSON.stringify(column._storageObj));
2734
- }
2735
-
2736
- setState({
2737
- columns: columns.map((o, i) => i === column.realIndex ? column : o)
2738
- });
2739
- }
2740
- });
2741
- },
2742
-
2743
- getFreezes({
2744
- column,
2745
- colIndex,
2746
- columnTitle,
2747
- freezeOptions,
2748
- freezeColumns,
2749
- unFreezeColumns
2750
- }) {
2751
- (column.freeze ? freezeColumns : unFreezeColumns).push(column);
2752
-
2753
- if (!column.toggleFreeze) {
2754
- return;
2755
- }
2756
-
2757
- freezeOptions.push({
2758
- text: columnTitle,
2759
- checked: column.freeze === true,
2760
- onClick: () => {
2761
- let {
2762
- columns
2763
- } = getState();
2764
- columns = [...columns];
2765
- let column = { ...columns[colIndex]
2766
- };
2767
- column.freeze = !column.freeze;
2768
- setState({
2769
- columns: columns.map((o, i) => i === colIndex ? column : o)
2770
- });
2771
- }
2772
- });
2773
- },
2774
-
2775
- updateColumnByStorage(column) {
2776
- let {
2777
- storageKey,
2778
- _readStorage
2779
- } = column;
2780
-
2781
- if (storageKey && !_readStorage) {
2782
- column._readStorage = true;
2783
- let storageStr = localStorage.getItem('aio-table-column-storage-' + column.storageKey);
2784
- let storageObj;
2785
-
2786
- if (!storageStr || storageStr === null) {
2787
- storageObj = {};
2788
- localStorage.setItem('aio-table-column-storage-' + column.storageKey, '{}');
2789
- } else {
2790
- storageObj = JSON.parse(storageStr);
2791
- }
2792
-
2793
- if (storageObj.show !== undefined) {
2794
- column.show = storageObj.show;
2795
- }
2796
-
2797
- if (storageObj.width !== undefined) {
2798
- column.width = storageObj.width;
2799
- }
2800
-
2801
- column._storageObj = storageObj;
2802
- }
2803
- },
2804
-
2805
- getDetails() {
2806
- let {
2807
- columns,
2808
- groups
2809
- } = getState();
2810
- columns = [...columns];
2811
- let sorts = [];
2812
- let freezeColumns = [],
2813
- unFreezeColumns = [],
2814
- freezeOptions = [],
2815
- sortOptions = [],
2816
- toggleOptions = [],
2817
- groupOptions = [];
2818
- let excelColumns = [],
2819
- visibleColumns = [],
2820
- search = false;
2821
- let groupTitles = groups.map(o => o.title);
2822
- let renderIndex = 0;
2823
-
2824
- for (let i = 0; i < columns.length; i++) {
2825
- columns[i].realIndex = i;
2826
-
2827
- if (columns[i].sort === true) {
2828
- columns[i].sort = {};
2829
- }
2830
-
2831
- if (columns[i].filter === true) {
2832
- columns[i].filter = {
2833
- items: [],
2834
- booleanType: 'or',
2835
- type: 'text'
2836
- };
2837
- }
2838
-
2839
- if (columns[i].group === true) {
2840
- columns[i].group = {};
2841
- }
2842
-
2843
- columns[i].width = columns[i].width || 'auto';
2844
- let column = { ...columns[i]
2845
- };
2846
- column.realIndex = i;
2847
- $$.updateColumnByStorage(column);
2848
- let {
2849
- title: columnTitle,
2850
- show = true,
2851
- sort,
2852
- toggleShow,
2853
- excel
2854
- } = column;
2855
- columnTitle = typeof columnTitle === 'function' ? columnTitle() : columnTitle;
2856
- column.show = typeof show === 'function' ? show() : show;
2857
-
2858
- if (column.search) {
2859
- search = true;
2860
- }
2861
-
2862
- if (column.group && groupTitles.indexOf(columnTitle) === -1) {
2863
- let {
2864
- title = columnTitle,
2865
- active = true,
2866
- toggle = true,
2867
- storageKey = column.storageKey,
2868
- getValue = column.getValue
2869
- } = column.group;
2870
- groups.push({
2871
- title,
2872
- active,
2873
- toggle,
2874
- storageKey,
2875
- getValue
2876
- });
2877
- }
2878
-
2879
- if (column.show) {
2880
- column.renderIndex = renderIndex;
2881
- columns[i].renderIndex = renderIndex;
2882
- renderIndex++;
2883
- visibleColumns.push(column);
2884
-
2885
- if (excel) {
2886
- excelColumns.push(column);
2887
- }
2888
-
2889
- if (sort) {
2890
- $$.getSorts({
2891
- column,
2892
- columnTitle,
2893
- sorts,
2894
- sortOptions,
2895
- colIndex: i
2896
- });
2897
- }
2898
-
2899
- $$.getFreezes({
2900
- column,
2901
- colIndex: i,
2902
- columnTitle,
2903
- freezeOptions,
2904
- freezeColumns,
2905
- unFreezeColumns
2906
- });
2907
- }
2908
-
2909
- if (toggleShow) {
2910
- $$.getToggles({
2911
- column,
2912
- columnTitle,
2913
- toggleOptions,
2914
- colIndex: i
2915
- });
2916
- }
2917
- }
2918
-
2919
- $$.getGroups(groupOptions);
2920
- return {
2921
- sorts,
2922
- sortOptions,
2923
- freezeColumns,
2924
- unFreezeColumns,
2925
- freezeOptions,
2926
- toggleOptions,
2927
- groupOptions,
2928
- excelColumns,
2929
- columns: visibleColumns,
2930
- search
2931
- };
2932
- },
2933
-
2934
- getGroups(groupOptions) {
2935
- var {
2936
- groups
2937
- } = getState();
2938
-
2939
- for (let i = 0; i < groups.length; i++) {
2940
- let group = groups[i];
2941
- let {
2942
- title,
2943
- active = true,
2944
- toggle = true,
2945
- storageKey,
2946
- _readStorage
2947
- } = group;
2948
-
2949
- if (storageKey && !_readStorage) {
2950
- group._readStorage = true;
2951
- let storageActive = localStorage.getItem('aio table group' + storageKey);
2952
-
2953
- if (storageActive === null) {
2954
- storageActive = true;
2955
- localStorage.setItem('aio table group' + storageKey, JSON.stringify(storageAtive));
2956
- } else {
2957
- storageActive = JSON.parse(storageActive);
2958
- }
2959
-
2960
- active = storageActive;
2961
- }
2962
-
2963
- group.active = active;
2964
-
2965
- if (toggle) {
2966
- groupOptions.push({
2967
- text: title,
2968
- checked: active === true,
2969
- onClick: () => {
2970
- let {
2971
- groups
2972
- } = getState();
2973
- let group = groups[i];
2974
- group.active = !group.active;
2975
-
2976
- if (storageKey) {
2977
- localStorage.setItem('aio table group' + storageKey, JSON.stringify(group.active));
2978
- }
2979
-
2980
- setState({
2981
- groups
2982
- });
2983
- }
2984
- });
2985
- }
2986
- }
2987
- },
2988
-
2989
- isContain(text, subtext) {
2990
- return text.toString().toLowerCase().indexOf(subtext.toString().toLowerCase()) !== -1;
2991
- },
2992
-
2993
- isEqual(a, b) {
2994
- return a.toString().toLowerCase() === b.toString().toLowerCase();
2995
- },
2996
-
2997
- isGreater(a, b, type) {
2998
- if (type === 'date') {
2999
- return $$.getDateNumber(a) > $$.getDateNumber(b);
3000
- }
3001
-
3002
- return parseFloat(a) > parseFloat(b);
3003
- },
3004
-
3005
- isLess(a, b, type) {
3006
- if (type === 'date') {
3007
- return $$.getDateNumber(a) < $$.getDateNumber(b);
3008
- }
3009
-
3010
- return parseFloat(a) < parseFloat(b);
3011
- },
3012
-
3013
- getFilterResult_and(filters, val) {
3014
- if (val === undefined) {
3015
- return false;
3016
- }
3017
-
3018
- for (let i = 0; i < filters.length; i++) {
3019
- let {
3020
- operator: o,
3021
- value: v,
3022
- type
3023
- } = filters[i];
3024
-
3025
- if (v === '' || v === undefined) {
3026
- continue;
3027
- }
3028
-
3029
- if (o === 'contain') {
3030
- if (!$$.isContain(val, v)) {
3031
- return false;
3032
- }
3033
-
3034
- continue;
3035
- }
3036
-
3037
- if (o === 'notContain') {
3038
- if ($$.isContain(val, v)) {
3039
- return false;
3040
- }
3041
-
3042
- continue;
3043
- }
3044
-
3045
- if (o === 'equal') {
3046
- if (!$$.isEqual(val, v)) {
3047
- return false;
3048
- }
3049
-
3050
- continue;
3051
- }
3052
-
3053
- if (o === 'notEqual') {
3054
- if ($$.isEqual(val, v)) {
3055
- return false;
3056
- }
3057
-
3058
- continue;
3059
- }
3060
-
3061
- if (o === 'greater') {
3062
- if (!$$.isGreater(val, v, type)) {
3063
- return false;
3064
- }
3065
-
3066
- continue;
3067
- }
3068
-
3069
- if (o === 'less') {
3070
- if (!$$.isLess(val, v, type)) {
3071
- return false;
3072
- }
3073
-
3074
- continue;
3075
- }
3076
- }
3077
-
3078
- return true;
3079
- },
3080
-
3081
- getFilterResult_or(filters, val) {
3082
- if (val === undefined) {
3083
- return false;
3084
- }
3085
-
3086
- for (let i = 0; i < filters.length; i++) {
3087
- let {
3088
- operator: o,
3089
- value: v,
3090
- type
3091
- } = filters[i];
3092
-
3093
- if (v === '' || v === undefined) {
3094
- return true;
3095
- }
3096
-
3097
- if (o === 'contain') {
3098
- if ($$.isContain(val, v)) {
3099
- return true;
3100
- }
3101
-
3102
- continue;
3103
- }
3104
-
3105
- if (o === 'notContain') {
3106
- if (!$$.isContain(val, v)) {
3107
- return true;
3108
- }
3109
-
3110
- continue;
3111
- }
3112
-
3113
- if (o === 'equal') {
3114
- if ($$.isEqual(val, v)) {
3115
- return true;
3116
- }
3117
-
3118
- continue;
3119
- }
3120
-
3121
- if (o === 'notEqual') {
3122
- if (!$$.isEqual(val, v)) {
3123
- return true;
3124
- }
3125
-
3126
- continue;
3127
- }
3128
-
3129
- if (o === 'greater') {
3130
- if ($$.isGreater(val, v, type)) {
3131
- return true;
3132
- }
3133
-
3134
- continue;
3135
- }
3136
-
3137
- if (o === 'less') {
3138
- if ($$.isLess(val, v, type)) {
3139
- return true;
3140
- }
3141
-
3142
- continue;
3143
- }
3144
- }
3145
-
3146
- return false;
3147
- },
3148
-
3149
- getFilterResult(column, value) {
3150
- let {
3151
- items = [],
3152
- booleanType = 'or'
3153
- } = column.filter;
3154
-
3155
- if (items.length) {
3156
- return $$['getFilterResult_' + booleanType](items, value);
3157
- }
3158
-
3159
- return true;
3160
- },
3161
-
3162
- cubes2(obj = {}) {
3163
- var {
3164
- count = 5,
3165
- thickness = [5, 16],
3166
- delay = 0.1,
3167
- borderRadius = 0,
3168
- colors = ['dodgerblue'],
3169
- duration = 1,
3170
- gap = 3
3171
- } = obj;
3172
- let Thickness = Array.isArray(thickness) ? thickness : [thickness, thickness];
3173
-
3174
- let getStyle1 = i => {
3175
- return {
3176
- width: Thickness[0],
3177
- height: Thickness[1],
3178
- background: colors[i % colors.length],
3179
- margin: `0 ${gap / 2}px`,
3180
- animation: `${duration}s loadingScaleY infinite ease-in-out ${i * delay}s`,
3181
- borderRadius: borderRadius + 'px'
3182
- };
3183
- };
3184
-
3185
- let items = [];
3186
-
3187
- for (var i = 0; i < count; i++) {
3188
- items.push( /*#__PURE__*/_react.default.createElement("div", {
3189
- key: i,
3190
- style: getStyle1(i)
3191
- }));
3192
- }
3193
-
3194
- return /*#__PURE__*/_react.default.createElement("div", {
3195
- className: "rect",
3196
- style: {
3197
- width: '100%',
3198
- display: 'flex',
3199
- alignItems: 'center',
3200
- justifyContent: 'center',
3201
- background: 'transparent'
3202
- }
3203
- }, items);
3204
- },
3205
-
3206
- getLoading(isMain) {
3207
- if (isMain) {
3208
- return /*#__PURE__*/_react.default.createElement("div", {
3209
- className: "aio-table-loading aio-table-main-loading",
3210
- style: {
3211
- display: 'none'
3212
- }
3213
- }, $$.cubes2({
3214
- thickness: [6, 40]
3215
- }));
3216
- }
3217
-
3218
- return /*#__PURE__*/_react.default.createElement("div", {
3219
- className: "aio-table-loading"
3220
- }, $$.cubes2({
3221
- thickness: [6, 40]
3222
- }));
3223
- },
3224
-
3225
- toggleRow(row) {
3226
- var {
3227
- openDictionary
3228
- } = getState();
3229
- var {
3230
- id
3231
- } = getProps();
3232
-
3233
- if (row._show === 'relativeFilter') {
3234
- return;
3235
- }
3236
-
3237
- openDictionary[row._id] = !openDictionary[row._id];
3238
-
3239
- if (id !== undefined) {
3240
- localStorage.setItem('aio table ' + id, JSON.stringify(openDictionary));
3241
- }
3242
-
3243
- setState({
3244
- openDictionary
3245
- });
3246
- },
3247
-
3248
- getRow(row) {
3249
- let {
3250
- searchText
3251
- } = getState();
3252
- let {
3253
- columns
3254
- } = getContext().details;
3255
- row._values = {};
3256
- let searchShow;
3257
- let show = true,
3258
- lastColumn,
3259
- isThereAutoColumn = false,
3260
- cells = [],
3261
- freezeCells = [],
3262
- unFreezeCells = [];
3263
-
3264
- for (let i = 0; i < columns.length; i++) {
3265
- let column = columns[i];
3266
- let value = $$.getCellValue(row, column.getValue);
3267
- row._values[column.realIndex] = value;
3268
-
3269
- if (show && column.search && searchText) {
3270
- if (searchShow === undefined) {
3271
- searchShow = false;
3272
- }
3273
-
3274
- searchShow = searchShow || JSON.stringify(value).toLowerCase().indexOf(searchText.toLowerCase()) !== -1;
3275
- }
3276
-
3277
- if (show && column.filter && !column.filter.onChange) {
3278
- show = show && $$.getFilterResult(column, value);
3279
- }
3280
-
3281
- let obj = {
3282
- key: row._index + ',' + column.realIndex,
3283
- column,
3284
- value,
3285
- freeze: column.freeze
3286
- };
3287
-
3288
- if ($$.freezeMode) {
3289
- if (column.freeze) {
3290
- freezeCells.push(obj);
3291
- } else {
3292
- lastColumn = column;
3293
- unFreezeCells.push(obj);
3294
-
3295
- if (column.width === 'auto') {
3296
- isThereAutoColumn = true;
3297
- }
3298
- }
3299
- } else {
3300
- cells.push(obj);
3301
- lastColumn = column;
3302
-
3303
- if (column.width === 'auto') {
3304
- isThereAutoColumn = true;
3305
- }
3306
- }
3307
- }
3308
-
3309
- row._show = show && searchShow !== false;
3310
-
3311
- if (show) {
3312
- let parents = row._getParents();
3313
-
3314
- for (let i = 0; i < parents.length; i++) {
3315
- if (parents[i]._show === false) {
3316
- parents[i]._show = 'relativeFilter';
3317
- }
3318
- }
3319
- }
3320
-
3321
- if (!isThereAutoColumn && lastColumn) {
3322
- lastColumn.width = 'auto';
3323
- }
3324
-
3325
- return {
3326
- cells,
3327
- freezeCells,
3328
- unFreezeCells
3329
- };
3330
- },
3331
-
3332
- getRowById(id, rows) {
3333
- for (let i = 0; i < rows.length; i++) {
3334
- let row = rows[i];
3335
-
3336
- if (!row.row) {
3337
- continue;
3338
- }
3339
-
3340
- if (row.row._id === id) {
3341
- return row;
3342
- }
3343
- }
3344
- },
3345
-
3346
- getStateByToggleAll(rows) {
3347
- var {
3348
- openDictionary,
3349
- groupsOpen,
3350
- toggleAllState
3351
- } = getState();
3352
- var {
3353
- id
3354
- } = getProps();
3355
-
3356
- for (let prop in openDictionary) {
3357
- let row = $$.getRowById(prop, rows);
3358
-
3359
- if (row && row.row && row.row._show === 'relativeFilter') {
3360
- continue;
3361
- }
3362
-
3363
- openDictionary[prop] = toggleAllState;
3364
- }
3365
-
3366
- for (let prop in groupsOpen) {
3367
- groupsOpen[prop] = toggleAllState;
3368
- }
3369
-
3370
- if (id !== undefined) {
3371
- localStorage.setItem('aio table ' + id, JSON.stringify(openDictionary));
3372
- }
3373
-
3374
- return {
3375
- openDictionary,
3376
- groupsOpen,
3377
- toggleAllState: !toggleAllState
3378
- };
3379
- },
3380
-
3381
- getClient(e) {
3382
- return getState().touch ? [e.changedTouches[0].clientX, e.changedTouches[0].clientY] : [e.clientX, e.clientY];
3383
- },
3384
-
3385
- getRowsReq(model, rows, _level, parents, nestedIndex) {
3386
- var {
3387
- openDictionary
3388
- } = getState();
3389
- var {
3390
- getRowId,
3391
- getRowChilds,
3392
- getRowVisible,
3393
- getRowParentId
3394
- } = getProps();
3395
-
3396
- if (getRowParentId) {
3397
- getRowChilds = row => row._childs;
3398
- }
3399
-
3400
- for (let i = 0; i < model.length; i++) {
3401
- let row = model[i];
3402
-
3403
- if (getRowVisible && getRowVisible(row) === false) {
3404
- continue;
3405
- }
3406
-
3407
- if (row._groupId) {
3408
- rows.push(row);
3409
- continue;
3410
- }
3411
-
3412
- row._index = $$.realIndex;
3413
- $$.realIndex++;
3414
- row._childIndex = i;
3415
- let NI = nestedIndex.concat(i);
3416
- row._nestedIndex = NI;
3417
- row._level = _level;
3418
- row._isFirstChild = i === 0;
3419
- row._isLastChild = i === model.length - 1;
3420
-
3421
- row._getParents = () => parents;
3422
-
3423
- if (row._id === undefined) {
3424
- let id = getRowId ? getRowId(row) : 'row' + Math.random();
3425
-
3426
- if (id === undefined) {
3427
- console.error('AIOTable => id of row is not defined, please check getRowId props of AIOTable');
3428
- }
3429
-
3430
- row._id = id;
3431
- }
3432
-
3433
- openDictionary[row._id] = openDictionary[row._id] === false ? false : true;
3434
- row._opened = openDictionary[row._id];
3435
- row._childsLength = 0;
3436
- let childs = [];
3437
-
3438
- if (getRowChilds) {
3439
- childs = $$.getCellValue(row, getRowChilds) || [];
3440
- row._childsLength = childs.length;
3441
- }
3442
-
3443
- let Row = $$.getRow(row);
3444
-
3445
- if (row._level === 0) {
3446
- rows.push([]);
3447
- }
3448
-
3449
- rows[rows.length - 1].push({ ...Row,
3450
- row
3451
- });
3452
-
3453
- if (row._opened && row._childsLength) {
3454
- $$.getRowsReq(childs, rows, _level + 1, parents.concat(row), NI);
3455
- } else {
3456
- $$.realIndex += row._childsLength;
3457
- }
3458
- }
3459
- },
3460
-
3461
- getRowsNested(model, childsField) {
3462
- let {
3463
- getRowId,
3464
- getRowParentId
3465
- } = getProps();
3466
-
3467
- if (!getRowParentId) {
3468
- return model;
3469
- }
3470
-
3471
- var convertModelRecursive = (array, parentId, parentObject) => {
3472
- for (let i = 0; i < array.length; i++) {
3473
- let row = array[i];
3474
- let rowParentId = getRowParentId(row);
3475
-
3476
- if (rowParentId !== parentId) {
3477
- continue;
3478
- }
3479
-
3480
- let rowId = getRowId(row);
3481
- row[childsField] = [];
3482
- parentObject.push(row);
3483
- array.splice(i, 1);
3484
- i--;
3485
- convertModelRecursive([...array], rowId, row[childsField]);
3486
- }
3487
- };
3488
-
3489
- var result = [];
3490
- convertModelRecursive([...model], undefined, result);
3491
- return result;
3492
- },
3493
-
3494
- getRowsBySort(rows, sorts) {
3495
- if (!sorts.length) {
3496
- return rows;
3497
- }
3498
-
3499
- return rows.sort((a, b) => {
3500
- for (let i = 0; i < sorts.length; i++) {
3501
- let {
3502
- getValue,
3503
- dir,
3504
- onChange
3505
- } = sorts[i];
3506
-
3507
- if (onChange) {
3508
- continue;
3509
- }
3510
-
3511
- let aValue = $$.getCellValue(a, getValue),
3512
- bValue = $$.getCellValue(b, getValue);
3513
-
3514
- if (aValue < bValue) {
3515
- return -1 * (dir === 'dec' ? -1 : 1);
3516
- }
3517
-
3518
- if (aValue > bValue) {
3519
- return 1 * (dir === 'dec' ? -1 : 1);
3520
- }
3521
-
3522
- if (i === sorts.length - 1) {
3523
- return 0;
3524
- }
3525
- }
3526
-
3527
- return 0;
3528
- });
3529
- },
3530
-
3531
- getRows(model, freezeMode) {
3532
- let rows = [];
3533
- $$.realIndex = 0;
3534
- $$.freezeMode = freezeMode;
3535
- $$.getRowsReq(model, rows, 0, [], []);
3536
- let result = [];
3537
-
3538
- for (let i = 0; i < rows.length; i++) {
3539
- let list = rows[i];
3540
-
3541
- if (list[0].row._show === false) {
3542
- continue;
3543
- }
3544
-
3545
- let arr = list.filter(o => o.row._show !== false);
3546
-
3547
- if (arr.length) {
3548
- result.push(arr);
3549
- }
3550
- }
3551
-
3552
- return result;
3553
- },
3554
-
3555
- getRootsByPaging(roots, index) {
3556
- let {
3557
- paging
3558
- } = getState();
3559
-
3560
- if (!paging) {
3561
- return roots;
3562
- }
3563
-
3564
- var length = paging.onChange ? paging.count : roots.length;
3565
- paging.pages = Math.ceil(length / paging.size);
3566
-
3567
- if (paging.number > paging.pages) {
3568
- paging.number = paging.pages;
3569
- }
3570
-
3571
- if (paging.number < 1) {
3572
- paging.number = 1;
3573
- }
3574
-
3575
- if (paging.onChange) {
3576
- return roots;
3577
- } //اگر پیجینگ آنچنج داشت تغییری در ردیف ها نده و اجازه بده تغییرات در آنچنج روی مدل ورودی انجام شود
3578
-
3579
-
3580
- let start = (paging.number - 1) * paging.size;
3581
- let end = start + paging.size;
3582
-
3583
- if (end > length) {
3584
- end = length;
3585
- }
3586
-
3587
- index.real = start;
3588
- return roots.slice(start, end);
3589
- },
3590
-
3591
- getRootsByGroup(roots, groups) {
3592
- if (!groups.length) {
3593
- return roots;
3594
- }
3595
-
3596
- var {
3597
- groupsOpen
3598
- } = getState();
3599
-
3600
- function msf(obj, _level, parents) {
3601
- if (Array.isArray(obj)) {
3602
- groupedRows = groupedRows.concat(obj);
3603
- } else {
3604
- for (var prop in obj) {
3605
- let newParents = parents.concat(prop);
3606
-
3607
- let _groupId = newParents.toString();
3608
-
3609
- groupsOpen[_groupId] = groupsOpen[_groupId] === undefined ? true : groupsOpen[_groupId];
3610
- groupedRows.push({
3611
- _groupValue: prop,
3612
- _groupId,
3613
- _level,
3614
- _opened: groupsOpen[_groupId]
3615
- });
3616
-
3617
- if (groupsOpen[_groupId]) {
3618
- msf(obj[prop], _level + 1, newParents);
3619
- }
3620
- }
3621
- }
3622
- }
3623
-
3624
- var newModel = {};
3625
-
3626
- for (let i = 0; i < roots.length; i++) {
3627
- let root = roots[i];
3628
- var obj = newModel;
3629
- let values = groups.map(group => $$.getCellValue(root[0].row, group.getValue, group.field));
3630
-
3631
- for (let j = 0; j < values.length; j++) {
3632
- let value = values[j];
3633
-
3634
- if (j === values.length - 1) {
3635
- obj[value] = obj[value] || [];
3636
- obj[value].push(root);
3637
- } else {
3638
- obj[value] = obj[value] || {};
3639
- obj = obj[value];
3640
- }
3641
- }
3642
- }
3643
-
3644
- var groupedRows = [];
3645
- var _level = 0;
3646
- msf(newModel, _level, []);
3647
- return groupedRows;
3648
- },
3649
-
3650
- getRowsByRoots(rows) {
3651
- var result = [];
3652
-
3653
- for (var i = 0; i < rows.length; i++) {
3654
- result = result.concat(rows[i]);
3655
- }
3656
-
3657
- return result;
3658
- },
3659
-
3660
- getFullCellStyle(columns) {
3661
- if (!columns) {
3662
- return {
3663
- gridColumnStart: 1,
3664
- gridColumnEnd: 2
3665
- };
3666
- }
3667
-
3668
- return {
3669
- gridColumnStart: 1,
3670
- gridColumnEnd: columns.length + 1
3671
- };
3672
- },
3673
-
3674
- getNoData(columns) {
3675
- var {
3676
- rowHeight,
3677
- translate
3678
- } = getProps();
3679
- return /*#__PURE__*/_react.default.createElement("div", {
3680
- className: "aio-table-nodata",
3681
- style: { ...$$.getFullCellStyle(columns),
3682
- height: rowHeight
3683
- }
3684
- }, translate('No Data'));
3685
- }
3686
-
3687
- };
3688
- return {
3689
- exportToExcel: $$.exportToExcel,
3690
- getDetails: $$.getDetails,
3691
- getSliderCell: $$.getSliderCell,
3692
- getOptionsCell: $$.getOptionsCell,
3693
- getGanttCell: $$.getGanttCell,
3694
- getCheckboxCell: $$.getCheckboxCell,
3695
- handleOutsideClick: $$.handleOutsideClick,
3696
- onScroll: $$.onScroll,
3697
- getCardRowCount: $$.getCardRowCount,
3698
- getOpenDictionary: $$.getOpenDictionary,
3699
- getRowsBySort: $$.getRowsBySort,
3700
- getGroups: $$.getGroups,
3701
- getRootsByGroup: $$.getRootsByGroup,
3702
- setColumnByStorage: $$.setColumnByStorage,
3703
- getFilterResult: $$.getFilterResult,
3704
- getLoading: $$.getLoading,
3705
- cubes2: $$.cubes2,
3706
- getRow: $$.getRow,
3707
- getRowById: $$.getRowById,
3708
- getClient: $$.getClient,
3709
- getStateByToggleAll: $$.getStateByToggleAll,
3710
- getRootsByPaging: $$.getRootsByPaging,
3711
- getRowsReq: $$.getRowsReq,
3712
- getRowsNested: $$.getRowsNested,
3713
- getRows: $$.getRows,
3714
- getRootsByRows: $$.getRootsByRows,
3715
- getRowsByRoots: $$.getRowsByRoots,
3716
- toggleRow: $$.toggleRow,
3717
- getFullCellStyle: $$.getFullCellStyle,
3718
- getNoData: $$.getNoData,
3719
- getSortsFromColumns: $$.getSortsFromColumns,
3720
- getCellValue: $$.getCellValue,
3721
- setCellValue: $$.setCellValue
3722
- };
3723
- }
3724
-
3725
- function aioTableGetSvg(type, conf = {}) {
3726
- let {
3727
- className,
3728
- flip,
3729
- onClick,
3730
- box = '0 0 24 24'
3731
- } = conf;
3732
- let style1 = {
3733
- width: '1.05rem',
3734
- height: '1.05rem'
3735
- };
3736
- style1.background = '';
3737
-
3738
- if (flip) {
3739
- style1.transform = 'scaleX(-1)';
3740
- style1.transformOrigin = 'center center';
3741
- }
3742
-
3743
- let style2 = {
3744
- fill: 'currentcolor'
3745
- };
3746
- let Attrs = {
3747
- viewBox: box,
3748
- role: "presentation",
3749
- style: style1
3750
- };
3751
-
3752
- if (className) {
3753
- Attrs.className = className;
3754
- }
3755
-
3756
- if (onClick) {
3757
- Attrs.onClick = onClick;
3758
- }
3759
-
3760
- if (type === 'eye') {
3761
- return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3762
- d: "M12,9A3,3 0 0,0 9,12A3,3 0 0,0 12,15A3,3 0 0,0 15,12A3,3 0 0,0 12,9M12,17A5,5 0 0,1 7,12A5,5 0 0,1 12,7A5,5 0 0,1 17,12A5,5 0 0,1 12,17M12,4.5C7,4.5 2.73,7.61 1,12C2.73,16.39 7,19.5 12,19.5C17,19.5 21.27,16.39 23,12C21.27,7.61 17,4.5 12,4.5Z",
3763
- style: style2
3764
- }));
3765
- }
3766
-
3767
- if (type === 'magnify') {
3768
- return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3769
- d: "M9.5,3A6.5,6.5 0 0,1 16,9.5C16,11.11 15.41,12.59 14.44,13.73L14.71,14H15.5L20.5,19L19,20.5L14,15.5V14.71L13.73,14.44C12.59,15.41 11.11,16 9.5,16A6.5,6.5 0 0,1 3,9.5A6.5,6.5 0 0,1 9.5,3M9.5,5C7,5 5,7 5,9.5C5,12 7,14 9.5,14C12,14 14,12 14,9.5C14,7 12,5 9.5,5Z",
3770
- style: style2
3771
- }));
3772
- }
3773
-
3774
- if (type === 'close') {
3775
- return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3776
- d: "M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z",
3777
- style: style2
3778
- }));
3779
- }
3780
-
3781
- if (type === 'toggleAllPlus') {
3782
- return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3783
- d: "M18,8H8V18H6V8A2,2 0 0,1 8,6H18V8M14,2H4A2,2 0 0,0 2,4V14H4V4H14V2M22,12V20A2,2 0 0,1 20,22H12A2,2 0 0,1 10,20V12A2,2 0 0,1 12,10H20A2,2 0 0,1 22,12M20,15H17V12H15V15H12V17H15V20H17V17H20V15Z",
3784
- style: style2
3785
- }));
3786
- }
3787
-
3788
- if (type === 'toggleAllMinus') {
3789
- return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3790
- d: "M14,4H4V14H2V4A2,2 0 0,1 4,2H14V4M18,6H8A2,2 0 0,0 6,8V18H8V8H18V6M22,12V20A2,2 0 0,1 20,22H12A2,2 0 0,1 10,20V12A2,2 0 0,1 12,10H20A2,2 0 0,1 22,12M20,15H12V17H20V15Z",
3791
- style: style2
3792
- }));
3793
- }
3794
-
3795
- if (type === 'excel') {
3796
- return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3797
- d: "M21.17 3.25Q21.5 3.25 21.76 3.5 22 3.74 22 4.08V19.92Q22 20.26 21.76 20.5 21.5 20.75 21.17 20.75H7.83Q7.5 20.75 7.24 20.5 7 20.26 7 19.92V17H2.83Q2.5 17 2.24 16.76 2 16.5 2 16.17V7.83Q2 7.5 2.24 7.24 2.5 7 2.83 7H7V4.08Q7 3.74 7.24 3.5 7.5 3.25 7.83 3.25M7 13.06L8.18 15.28H9.97L8 12.06L9.93 8.89H8.22L7.13 10.9L7.09 10.96L7.06 11.03Q6.8 10.5 6.5 9.96 6.25 9.43 5.97 8.89H4.16L6.05 12.08L4 15.28H5.78M13.88 19.5V17H8.25V19.5M13.88 15.75V12.63H12V15.75M13.88 11.38V8.25H12V11.38M13.88 7V4.5H8.25V7M20.75 19.5V17H15.13V19.5M20.75 15.75V12.63H15.13V15.75M20.75 11.38V8.25H15.13V11.38M20.75 7V4.5H15.13V7Z",
3798
- style: style2
3799
- }));
3800
- }
3801
-
3802
- if (type === 'sort') {
3803
- return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3804
- d: "M18 21L14 17H17V7H14L18 3L22 7H19V17H22M2 19V17H12V19M2 13V11H9V13M2 7V5H6V7H2Z",
3805
- style: style2
3806
- }));
3807
- }
3808
-
3809
- if (type === 'group') {
3810
- return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3811
- d: "M3,3H9V7H3V3M15,10H21V14H15V10M15,17H21V21H15V17M13,13H7V18H13V20H7L5,20V9H7V11H13V13Z",
3812
- style: style2
3813
- }));
3814
- }
3815
-
3816
- if (type === 'freeze') {
3817
- return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3818
- d: "M4 22H2V2H4V22M22 7H6V10H22V7M16 14H6V17H16V14Z",
3819
- style: style2
3820
- }));
3821
- }
3822
-
3823
- if (type === 'filter') {
3824
- return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3825
- d: "M14,12V19.88C14.04,20.18 13.94,20.5 13.71,20.71C13.32,21.1 12.69,21.1 12.3,20.71L10.29,18.7C10.06,18.47 9.96,18.16 10,17.87V12H9.97L4.21,4.62C3.87,4.19 3.95,3.56 4.38,3.22C4.57,3.08 4.78,3 5,3V3H19V3C19.22,3 19.43,3.08 19.62,3.22C20.05,3.56 20.13,4.19 19.79,4.62L14.03,12H14Z",
3826
- style: style2
3827
- }));
3828
- }
3829
-
3830
- if (type === 'filterActive') {
3831
- return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3832
- d: "M11 11L16.76 3.62A1 1 0 0 0 16.59 2.22A1 1 0 0 0 16 2H2A1 1 0 0 0 1.38 2.22A1 1 0 0 0 1.21 3.62L7 11V16.87A1 1 0 0 0 7.29 17.7L9.29 19.7A1 1 0 0 0 10.7 19.7A1 1 0 0 0 11 18.87V11M13 16L18 21L23 16Z",
3833
- style: style2
3834
- }));
3835
- }
3836
-
3837
- if (type === 'dots') {
3838
- return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3839
- d: "M16,12A2,2 0 0,1 18,10A2,2 0 0,1 20,12A2,2 0 0,1 18,14A2,2 0 0,1 16,12M10,12A2,2 0 0,1 12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12M4,12A2,2 0 0,1 6,10A2,2 0 0,1 8,12A2,2 0 0,1 6,14A2,2 0 0,1 4,12Z",
3840
- style: style2
3841
- }));
3842
- }
3843
-
3844
- if (type === 'chevronDown') {
3845
- return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3846
- d: "M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z",
3847
- style: style2
3848
- }));
3849
- }
3850
-
3851
- if (type === 'chevronRight') {
3852
- return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3853
- d: "M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z",
3854
- style: style2
3855
- }));
3856
- }
3857
-
3858
- if (type === 'doubleChevronRight') {
3859
- return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3860
- d: "M5.59,7.41L7,6L13,12L7,18L5.59,16.59L10.17,12L5.59,7.41M11.59,7.41L13,6L19,12L13,18L11.59,16.59L16.17,12L11.59,7.41Z",
3861
- style: style2
3862
- }));
3863
- }
3864
-
3865
- if (type === 'arrowUp') {
3866
- return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3867
- d: "M13,20H11V8L5.5,13.5L4.08,12.08L12,4.16L19.92,12.08L18.5,13.5L13,8V20Z",
3868
- style: style2
3869
- }));
3870
- }
3871
-
3872
- if (type === 'arrowDown') {
3873
- return /*#__PURE__*/_react.default.createElement("svg", Attrs, /*#__PURE__*/_react.default.createElement("path", {
3874
- d: "M11,4H13V16L18.5,10.5L19.92,11.92L12,19.84L4.08,11.92L5.5,10.5L11,16V4Z",
3875
- style: style2
3876
- }));
3877
- }
3878
1302
  }