aio-table 14.0.0 → 14.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 (4) hide show
  1. package/index.css +4 -3
  2. package/index.d.ts +21 -19
  3. package/index.js +91 -152
  4. package/package.json +1 -1
package/index.css CHANGED
@@ -163,9 +163,9 @@
163
163
  background: #f8f8f8;
164
164
  z-index: 100;
165
165
  box-sizing: border-box;
166
- min-height: 36px;
167
- gap: 6px;
168
- padding: 6px;
166
+ height:3em;
167
+ gap: 0.4em;
168
+ padding: 0.4em;
169
169
  }
170
170
 
171
171
  .aio-table-toolbar-content {
@@ -219,6 +219,7 @@
219
219
  flex: 1;
220
220
  height: 100%;
221
221
  box-sizing: border-box;
222
+ border:none;
222
223
  }
223
224
 
224
225
  .aio-table-search .aio-input {
package/index.d.ts CHANGED
@@ -93,6 +93,13 @@ export type I_table_column<T> = {
93
93
  pattern?: string;
94
94
  affix?: string;
95
95
  prefix?: string;
96
+ cellAttrs?: (p: {
97
+ row: T;
98
+ column: I_table_column<T>;
99
+ value: any;
100
+ rowIndex: number;
101
+ }) => any;
102
+ titleAttrs?: (column: I_table_column<T>) => any;
96
103
  };
97
104
  export type I_table_filter_saved = {
98
105
  name: string;
@@ -125,25 +132,18 @@ export type I_table<T> = {
125
132
  columns?: I_table_column<T>[];
126
133
  excel?: string | ((value: any[]) => any[]);
127
134
  headerAttrs?: any;
128
- onAdd?: () => Promise<T | undefined>;
129
- onRemove?: (p: {
130
- row: T;
131
- rowIndex?: number;
132
- }) => Promise<boolean>;
133
135
  onChangePaging?: (newPaging: I_table_paging) => void;
134
136
  onChangeSort?: (sorts: I_table_sort<T>[]) => Promise<boolean>;
135
- onSwap?: true | ((newValue: T[], startRow: T, endRow: T) => void);
137
+ onSwap?: (newValue: T[], startRow: T, endRow: T) => void;
136
138
  onSearch?: true | ((searchValue: string) => void);
137
139
  paging?: I_table_paging;
138
140
  removeText?: string;
139
- rowOption?: {
140
- before?: I_rowOption<T, ReactNode>;
141
- after?: I_rowOption<T, ReactNode>;
142
- attrs?: I_rowOption<T, {
143
- [attrs: string]: any;
144
- }>;
145
- template?: I_rowOption<T, ReactNode>;
146
- };
141
+ rowAttrs?: I_rowOption<T, {
142
+ [attrs: string]: any;
143
+ }>;
144
+ rowBefore?: I_rowOption<T, ReactNode>;
145
+ rowAfter?: I_rowOption<T, ReactNode>;
146
+ rowTemplate?: I_rowOption<T, ReactNode>;
147
147
  rowsTemplate?: (rows: T[]) => ReactNode;
148
148
  toolbar?: ReactNode | (() => ReactNode);
149
149
  toolbarAttrs?: any;
@@ -196,8 +196,11 @@ export type I_table_sort<T> = {
196
196
  active?: boolean;
197
197
  dir?: 'dec' | 'inc';
198
198
  title?: ReactNode;
199
- sortId: string;
200
- getValue?: (row: T) => any;
199
+ sortId?: string;
200
+ getValue?: (row: T, dir: 'inc' | 'dec') => any;
201
+ isDate?: boolean;
202
+ columnId?: string;
203
+ order?: number;
201
204
  };
202
205
  export declare const useSort: <T>(p: {
203
206
  fa?: boolean;
@@ -212,8 +215,8 @@ export declare const useSort: <T>(p: {
212
215
  getSortedRows: (rows: T[]) => T[];
213
216
  changeSort: (sortId: string, changeObject: Partial<I_table_sort<T>>) => void;
214
217
  changeSorts: (sorts: I_table_sort<T>[]) => Promise<void>;
215
- renderSortArrow: (option: I_table_sort<T> | false, inline?: boolean) => import("react/jsx-runtime").JSX.Element;
216
- getSortByColumn: (column: I_table_column<T>) => I_table_sort<T> | false;
218
+ renderSortArrow: (option: false | I_table_sort<T>, inline?: boolean) => import("react/jsx-runtime").JSX.Element;
219
+ getSortByColumn: (column: I_table_column<T>) => false | I_table_sort<T>;
217
220
  };
218
221
  export type I_table_paging = {
219
222
  serverSide?: boolean;
@@ -227,4 +230,3 @@ export type I_pagingHook<T> = {
227
230
  getPagedRows: (rows: T[]) => T[];
228
231
  changePaging: (obj: Partial<I_table_paging>) => void;
229
232
  };
230
- export declare function sortRows<T>(rows: T[], sorts: I_table_sort<T>[]): T[];
package/index.js CHANGED
@@ -57,7 +57,11 @@ const AIOTable = (props) => {
57
57
  }
58
58
  }
59
59
  }
60
- return Object.assign(Object.assign({}, column), col);
60
+ const res = Object.assign(Object.assign({}, column), col);
61
+ if (res.value === undefined) {
62
+ res.value = `row.${column.id}`;
63
+ }
64
+ return res;
61
65
  };
62
66
  const getColumns = () => {
63
67
  let { columns = [] } = props;
@@ -91,25 +95,6 @@ const AIOTable = (props) => {
91
95
  props.onChangeColumns(newColumns);
92
96
  }
93
97
  }, 'aio-table-title');
94
- const getGetValue = (sort, column) => {
95
- if (sort.getValue) {
96
- return sort.getValue;
97
- }
98
- return (row) => {
99
- const { type = 'text' } = column;
100
- const cellValue = tableHook.getCellValue({ row, column, rowIndex: 0 });
101
- if (type === 'date' || type === 'jalaliDate') {
102
- const DATE = new AIODate();
103
- try {
104
- return DATE.getTime(cellValue);
105
- }
106
- catch (_a) {
107
- return 0;
108
- }
109
- }
110
- return cellValue;
111
- };
112
- };
113
98
  const getSorts = (columns) => {
114
99
  let sorts = [];
115
100
  for (let i = 0; i < columns.length; i++) {
@@ -120,11 +105,26 @@ const AIOTable = (props) => {
120
105
  if (!sort) {
121
106
  continue;
122
107
  }
123
- let { active = false, dir = 'dec', sortId } = sort;
124
- let sortItem = { dir, title: sort.title || column.title, sortId, active, getValue: getGetValue(sort, column) };
108
+ const { type = 'text' } = column;
109
+ let { active = false, dir = 'dec', sortId, order = Infinity } = sort;
110
+ let sortItem = {
111
+ isDate: type === 'date' || type === 'jalaliDate',
112
+ sortId, active, dir, columnId,
113
+ title: sort.title || column.title, order,
114
+ getValue: (row, dir) => {
115
+ if (sort.getValue) {
116
+ return sort.getValue(row, dir);
117
+ }
118
+ const cellValue = tableHook.getCellValue({ row, column, rowIndex: 0 });
119
+ if (column.type === 'number' && typeof cellValue !== 'number') {
120
+ return dir === 'inc' ? Infinity : -Infinity;
121
+ }
122
+ return cellValue;
123
+ }
124
+ };
125
125
  sorts.push(sortItem);
126
126
  }
127
- return sorts;
127
+ return UT.SortArray(sorts, [{ getValue: (o) => o.order, dir: 'inc' }]);
128
128
  };
129
129
  const sortHook = useSort({
130
130
  fa: props.fa,
@@ -141,28 +141,6 @@ const AIOTable = (props) => {
141
141
  pagingHook.changePaging(props.paging);
142
142
  }
143
143
  }, [JSON.stringify(props.paging)]);
144
- function add() {
145
- return __awaiter(this, void 0, void 0, function* () {
146
- if (!props.onAdd) {
147
- return;
148
- }
149
- const res = yield props.onAdd();
150
- if (res && props.onChange) {
151
- props.onChange([res, ...props.value]);
152
- }
153
- });
154
- }
155
- function remove(row, index) {
156
- return __awaiter(this, void 0, void 0, function* () {
157
- if (!props.onRemove) {
158
- return;
159
- }
160
- const res = yield props.onRemove({ row, rowIndex: index });
161
- if (res === true && props.onChange) {
162
- props.onChange(props.value.filter((o) => o._id !== row._id));
163
- }
164
- });
165
- }
166
144
  function exportToExcel() {
167
145
  let list = [];
168
146
  if (typeof props.excel === 'function') {
@@ -230,11 +208,11 @@ const AIOTable = (props) => {
230
208
  props.onSearch(searchValue);
231
209
  }
232
210
  }
233
- let ROWS = getRows();
234
211
  const { columns, searchColumns, excelColumns, filterColumns, toggleColumns } = useMemo(() => getColumns(), [props.columns]);
212
+ let ROWS = getRows();
235
213
  const context = {
236
214
  rootProps: props, excelColumns, filterColumns, tableHook, sortHook, ROWS, toggleColumns, pagingHook,
237
- add, remove, search, exportToExcel, DragColumns, popup, columns
215
+ search, exportToExcel, DragColumns, popup, columns
238
216
  };
239
217
  return (_jsxs(Provider, { value: context, children: [_jsx(AIOTableComponent, Object.assign({}, props)), popup.render()] }));
240
218
  };
@@ -250,27 +228,50 @@ const AIOTableComponent = (props) => {
250
228
  };
251
229
  const TableRows = () => {
252
230
  let { ROWS, rootProps } = useProvider();
253
- let { rowOption = {}, rowsTemplate, placeholder = 'there is not any items' } = rootProps;
254
- const { before: rowBefore = () => null, after: rowAfter = () => null, template: rowTemplate, } = rowOption;
231
+ let { rowBefore = () => null, rowAfter = () => null, rowTemplate, rowsTemplate, placeholder = 'there is not any items' } = rootProps;
255
232
  let rows = ROWS.pagedRows || [];
256
233
  let content;
257
234
  if (rowsTemplate) {
258
235
  content = rowsTemplate(rows);
259
236
  }
260
237
  else if (rows.length) {
261
- content = rows.map((o, i) => {
262
- let { id = 'ailr' + Math.round(Math.random() * 10000000) } = o;
263
- o._id = o._id === undefined ? id : o._id;
264
- const rowDetail = { row: o, rowIndex: i };
265
- let Row;
266
- if (rowTemplate) {
267
- Row = rowTemplate(rowDetail);
268
- }
269
- else {
270
- Row = _jsx(TableRow, { rowDetail: rowDetail }, o._id);
271
- }
272
- return (_jsxs(Fragment, { children: [rowBefore(rowDetail), Row, rowAfter(rowDetail)] }, o._id));
273
- });
238
+ if (rootProps.onSwap) {
239
+ content = (_jsx(UT.DragAndDrop, { data: rows, getId: (o) => {
240
+ let { id = 'ailr' + Math.round(Math.random() * 10000000) } = o;
241
+ o._id = o._id === undefined ? id : o._id;
242
+ return o._id;
243
+ }, getContent: (o, { index, id }) => {
244
+ o._id = o._id === undefined ? id : o._id;
245
+ const rowDetail = { row: o, rowIndex: index };
246
+ let Row;
247
+ if (rowTemplate) {
248
+ Row = rowTemplate(rowDetail);
249
+ }
250
+ else {
251
+ Row = _jsx(TableRow, { rowDetail: rowDetail }, o._id);
252
+ }
253
+ return (_jsxs(Fragment, { children: [rowBefore(rowDetail), Row, rowAfter(rowDetail)] }, o._id));
254
+ }, onChange: (newRows) => {
255
+ if (rootProps.onChange) {
256
+ rootProps.onChange(newRows);
257
+ }
258
+ } }));
259
+ }
260
+ else {
261
+ content = rows.map((o, i) => {
262
+ let { id = 'ailr' + Math.round(Math.random() * 10000000) } = o;
263
+ o._id = o._id === undefined ? id : o._id;
264
+ const rowDetail = { row: o, rowIndex: i };
265
+ let Row;
266
+ if (rowTemplate) {
267
+ Row = rowTemplate(rowDetail);
268
+ }
269
+ else {
270
+ Row = _jsx(TableRow, { rowDetail: rowDetail }, o._id);
271
+ }
272
+ return (_jsxs(Fragment, { children: [rowBefore(rowDetail), Row, rowAfter(rowDetail)] }, o._id));
273
+ });
274
+ }
274
275
  }
275
276
  else if (placeholder) {
276
277
  content = _jsx("div", { style: { width: '100%', textAlign: 'center', padding: 12, boxSizing: 'border-box' }, children: placeholder });
@@ -282,12 +283,12 @@ const TableRows = () => {
282
283
  return _jsx("div", { className: 'aio-table-rows', style: { gap: gap[1] }, children: content });
283
284
  };
284
285
  const TableToolbar = ({ filterHook }) => {
285
- let { add, exportToExcel, search, rootProps, excelColumns, toggleColumns, sortHook, columns } = useProvider();
286
- let { toolbarAttrs, toolbar, onAdd, onSearch, value, onChangeColumns, fa, filter, inlineSort } = rootProps;
286
+ let { exportToExcel, search, rootProps, excelColumns, toggleColumns, sortHook, columns } = useProvider();
287
+ let { toolbarAttrs, toolbar, onSearch, value, onChangeColumns, fa, filter, inlineSort } = rootProps;
287
288
  const columnsRef = useRef(columns);
288
289
  columnsRef.current = columns;
289
290
  toolbarAttrs = UT.AddToAttrs(toolbarAttrs, { className: 'aio-table-toolbar' });
290
- if (!onAdd && !toolbar && !onSearch && !sortHook.sorts.length && !excelColumns.length && !toggleColumns.length && !filter) {
291
+ if (!toolbar && !onSearch && !sortHook.sorts.length && !excelColumns.length && !toggleColumns.length && !filter) {
291
292
  return null;
292
293
  }
293
294
  function getAddText() {
@@ -317,18 +318,17 @@ const TableToolbar = ({ filterHook }) => {
317
318
  show: () => true,
318
319
  justify: () => false,
319
320
  close: () => false
320
- } }), !!onAdd && _jsx("div", { className: 'aio-table-toolbar-button aio-table-add-button', onClick: () => add(), children: getAddText() })] })));
321
+ } })] })));
321
322
  };
322
323
  const TableHeader = () => {
323
324
  let { rootProps, columns } = useProvider();
324
- let { headerAttrs, onRemove, gap = [] } = rootProps;
325
+ let { headerAttrs, gap = [] } = rootProps;
325
326
  headerAttrs = UT.AddToAttrs(headerAttrs, { className: 'aio-table-header', style: { gap: gap[0] } });
326
327
  let Titles = columns.map((column, i) => {
327
328
  const columnId = column.id;
328
329
  return _jsx(TableTitle, { column: column, isLast: i === columns.length - 1, colIndex: i }, columnId);
329
330
  });
330
- let RemoveTitle = !onRemove ? null : _jsx("div", { className: 'aio-table-remove-title' });
331
- return _jsxs("div", Object.assign({}, headerAttrs, { children: [Titles, RemoveTitle] }));
331
+ return _jsx("div", Object.assign({}, headerAttrs, { children: Titles }));
332
332
  };
333
333
  const TableTitle = (p) => {
334
334
  const { column, colIndex } = p;
@@ -344,7 +344,7 @@ const TableRow = (props) => {
344
344
  const { rowDetail } = props;
345
345
  const { row, rowIndex } = rowDetail;
346
346
  const rowId = row._id;
347
- let { remove, rootProps, tableHook, columns } = useProvider();
347
+ let { rootProps, tableHook, columns } = useProvider();
348
348
  function getCells() {
349
349
  return columns.map((column) => {
350
350
  const { show = true } = column;
@@ -356,14 +356,12 @@ const TableRow = (props) => {
356
356
  return (_jsx(TableCell, { row: row, rowIndex: rowIndex, column: column }, key));
357
357
  });
358
358
  }
359
- let { onRemove } = rootProps;
360
- return (_jsx(_Fragment, { children: _jsxs("div", Object.assign({}, tableHook.getRowAttrs({ row, rowIndex }), { children: [getCells(), onRemove ? _jsx("button", { className: 'aio-table-remove', onClick: () => remove(row, rowIndex), children: new UT.GetSvg('em').getIcon('mdiClose', 0.8) }) : null] }), rowId) }));
359
+ return (_jsx("div", Object.assign({}, tableHook.getRowAttrs({ row, rowIndex }), { children: getCells() }), rowId));
361
360
  };
362
361
  const TableCell = (props) => {
363
362
  var _a, _b;
364
363
  let { row, column, rowIndex } = props;
365
- const { tableHook, rootProps } = useProvider();
366
- const { templates } = rootProps;
364
+ const { tableHook } = useProvider();
367
365
  const { type = 'text', id } = column;
368
366
  let cellValue = tableHook.getCellValue({ row, rowIndex, column });
369
367
  if (type === 'date') {
@@ -417,18 +415,6 @@ const TableCell = (props) => {
417
415
  return (_jsx(Fragment, { children: _jsxs("div", Object.assign({}, tableHook.getCellAttrs({ row, column, rowIndex }), { children: [before !== undefined && _jsx("div", { className: "aio-table-cell-before", children: before }), _jsx("div", { className: `aio-table-cell-value${subtext !== undefined ? ' has-subtext' : ''}`, "data-subtext": subtext, children: content }), after !== undefined && _jsx("div", { className: "aio-table-cell-after", children: after })] })) }, rowId + ' ' + colId));
418
416
  };
419
417
  const useTable = (getProps, getPaging) => {
420
- const DragRows = UT.useDrag((dragIndex, dropIndex, reOrder) => {
421
- const { onSwap, onChange, value: rows } = getProps();
422
- const newRows = reOrder(rows, dragIndex, dropIndex);
423
- const from = rows[dragIndex];
424
- const to = rows[dropIndex];
425
- if (typeof onSwap === 'function') {
426
- onSwap(newRows, from, to);
427
- }
428
- else if (onChange) {
429
- onChange(newRows);
430
- }
431
- }, 'aio-table-row');
432
418
  const fixIndexByPaging = (rowIndex) => {
433
419
  const paging = getPaging();
434
420
  if (paging) {
@@ -531,7 +517,9 @@ const useTable = (getProps, getPaging) => {
531
517
  const { row, rowIndex, column } = p;
532
518
  const { cellAttrs } = getProps();
533
519
  const cellValue = getCellValue({ row, column, rowIndex });
534
- const attrs = cellAttrs ? cellAttrs({ row, rowIndex: fixIndexByPaging(rowIndex), column, value: cellValue }) : {};
520
+ const propsCellAttrs = cellAttrs ? cellAttrs({ row, rowIndex: fixIndexByPaging(rowIndex), column, value: cellValue }) : {};
521
+ const columnCellAttrs = column.cellAttrs ? column.cellAttrs({ row, rowIndex: fixIndexByPaging(rowIndex), column, value: cellValue }) : {};
522
+ const attrs = Object.assign(Object.assign({}, propsCellAttrs), columnCellAttrs);
535
523
  const { justify, width, minWidth } = column;
536
524
  const className = `aio-table-cell` + (justify ? ` aio-table-cell-justify` : '');
537
525
  let isNumber = false;
@@ -550,19 +538,20 @@ const useTable = (getProps, getPaging) => {
550
538
  const getTitleAttrs = (column) => {
551
539
  const { justify, width, minWidth, title } = column;
552
540
  const { titleAttrs } = getProps();
553
- const attrs = titleAttrs ? titleAttrs(column) : {};
541
+ const propsTitleAttrs = titleAttrs ? titleAttrs(column) : {};
542
+ const columnTitleAttrs = column.titleAttrs ? column.titleAttrs(column) : {};
543
+ const attrs = Object.assign(Object.assign({}, propsTitleAttrs), columnTitleAttrs);
554
544
  const className = `aio-table-title` + (justify ? ` aio-table-title-justify` : '');
555
545
  const style = { width, minWidth, flex: width ? undefined : 1 };
556
546
  return UT.AddToAttrs(attrs, { className, style, attrs: { title: typeof title === 'string' ? title : undefined } });
557
547
  };
558
548
  const getRowAttrs = (p) => {
559
549
  const { row, rowIndex } = p;
560
- const { rowOption = {}, onSwap, gap = [] } = getProps();
561
- const { attrs: rowAttrs } = rowOption;
550
+ const { onSwap, gap = [], rowAttrs } = getProps();
562
551
  const attrs = rowAttrs ? rowAttrs({ row, rowIndex }) : {};
563
552
  let obj = UT.AddToAttrs(attrs, { className: ['aio-table-row', rowIndex % 2 === 0 ? 'aio-table-row-odd' : 'aio-table-row-even'], style: { gap: gap[0] } });
564
553
  if (onSwap) {
565
- obj = Object.assign(Object.assign(Object.assign({}, obj), DragRows.getDragAttrs(rowIndex)), DragRows.getDropAttrs(rowIndex));
554
+ obj = Object.assign({}, obj);
566
555
  }
567
556
  return obj;
568
557
  };
@@ -571,6 +560,10 @@ const useTable = (getProps, getPaging) => {
571
560
  export const useSort = (p) => {
572
561
  let [sorts, setSorts] = useState(p.sorts);
573
562
  const isInitSortExecutedRef = useRef(false);
563
+ const getActiveSorts = (sorts) => {
564
+ let activeSorts = (sorts || []).filter((sort) => sort.active !== false);
565
+ return activeSorts.map((o) => ({ getValue: o.getValue, dir: o.dir }));
566
+ };
574
567
  const getSortedRows = (rows) => {
575
568
  if (isInitSortExecutedRef.current) {
576
569
  return rows;
@@ -578,44 +571,17 @@ export const useSort = (p) => {
578
571
  if (p.onChangeSort) {
579
572
  return rows;
580
573
  }
581
- let activeSorts = sorts.filter((sort) => sort.active !== false);
574
+ let activeSorts = getActiveSorts(sorts);
582
575
  if (!activeSorts.length || !rows.length) {
583
576
  return rows;
584
577
  }
585
578
  isInitSortExecutedRef.current = true;
586
- let sortedRows = sortRows(rows, activeSorts);
579
+ let sortedRows = UT.SortArray(rows, activeSorts);
587
580
  if (p.onChangeRows) {
588
581
  p.onChangeRows(sortedRows);
589
582
  }
590
583
  return sortedRows;
591
584
  };
592
- const sortRows = (rows, sorts) => {
593
- if (!rows) {
594
- return [];
595
- }
596
- if (!sorts || !sorts.length) {
597
- return rows;
598
- }
599
- return rows.sort((a, b) => {
600
- for (let i = 0; i < sorts.length; i++) {
601
- let { dir, getValue } = sorts[i];
602
- if (!getValue) {
603
- return 0;
604
- }
605
- let aValue = getValue(a), bValue = getValue(b);
606
- if (aValue < bValue) {
607
- return -1 * (dir === 'dec' ? -1 : 1);
608
- }
609
- if (aValue > bValue) {
610
- return 1 * (dir === 'dec' ? -1 : 1);
611
- }
612
- if (i === sorts.length - 1) {
613
- return 0;
614
- }
615
- }
616
- return 0;
617
- });
618
- };
619
585
  const changeSort = (sortId, changeObject) => {
620
586
  let newSorts = sorts.map((sort) => {
621
587
  if (sort.sortId === sortId) {
@@ -628,16 +594,16 @@ export const useSort = (p) => {
628
594
  };
629
595
  const changeSorts = (sorts) => __awaiter(void 0, void 0, void 0, function* () {
630
596
  if (p.onChangeSort) {
631
- let res = yield p.onChangeSort(sorts);
597
+ let res = yield p.onChangeSort(sorts.filter((o) => !!o.active));
632
598
  if (res !== false) {
633
599
  setSorts(sorts);
634
600
  }
635
601
  }
636
602
  else {
637
603
  setSorts(sorts);
638
- let activeSorts = sorts.filter((sort) => sort.active !== false);
604
+ const activeSorts = getActiveSorts(sorts);
639
605
  if (activeSorts.length && !!p.onChangeRows) {
640
- p.onChangeRows(sortRows(p.rows, activeSorts));
606
+ p.onChangeRows(UT.SortArray(p.rows, activeSorts));
641
607
  }
642
608
  }
643
609
  });
@@ -694,7 +660,7 @@ export const useSort = (p) => {
694
660
  return (_jsx(AISelect, { caret: false, options: sorts, justify: true, option: {
695
661
  text: (option) => option.title, checked: (option) => !!option.active, close: () => false, value: (option) => option.sortId,
696
662
  after: (option) => renderSortArrow(option),
697
- onClick: (option) => changeSort(option.sortId, { active: !option.active })
663
+ onClick: (option) => changeSort(option.sortId || '', { active: !option.active })
698
664
  }, popover: {
699
665
  header: { title: p.fa ? 'مرتب سازی' : 'Sort', onClose: false },
700
666
  headerAttrs: { className: 'aio-sort-header' },
@@ -765,7 +731,7 @@ const usePaging = (p) => {
765
731
  if (!sizes.length) {
766
732
  return null;
767
733
  }
768
- return (_jsx(AISelect, { attrs: { className: 'aio-paging-button aio-paging-size' }, value: size, options: sizes, option: { text: 'option', value: 'option' }, justify: true, onChange: (value) => changePaging({ size: value }), popover: { fitHorizontal: true } }));
734
+ return (_jsx(AISelect, { attrs: { className: 'aio-paging-button aio-paging-size' }, value: size, options: sizes, option: { text: (o) => o, value: (o) => o }, justify: true, onChange: (value) => changePaging({ size: value }), popover: { fitHorizontal: true } }));
769
735
  }
770
736
  const render = () => {
771
737
  const paging = getPaging(p.paging);
@@ -1222,30 +1188,3 @@ const useFilterData = (popup, trans) => {
1222
1188
  };
1223
1189
  return { getSaves, getData, save, removeSave, removeFilterItem, changeColumnsFilterItem, activeName, activeSave, addColumnsFilterItem };
1224
1190
  };
1225
- export function sortRows(rows, sorts) {
1226
- if (!rows) {
1227
- return [];
1228
- }
1229
- if (!sorts || !sorts.length) {
1230
- return rows;
1231
- }
1232
- return rows.sort((a, b) => {
1233
- for (let i = 0; i < sorts.length; i++) {
1234
- let { dir, getValue } = sorts[i];
1235
- if (!getValue) {
1236
- return 0;
1237
- }
1238
- let aValue = getValue(a), bValue = getValue(b);
1239
- if (aValue < bValue) {
1240
- return -1 * (dir === 'dec' ? -1 : 1);
1241
- }
1242
- if (aValue > bValue) {
1243
- return 1 * (dir === 'dec' ? -1 : 1);
1244
- }
1245
- if (i === sorts.length - 1) {
1246
- return 0;
1247
- }
1248
- }
1249
- return 0;
1250
- });
1251
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aio-table",
3
- "version": "14.0.0",
3
+ "version": "14.0.2",
4
4
  "description": "all in one table. tree mode , simple mode , tree mode, gantt mode , groupby mode, freeze mode.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",