es-grid-template 1.1.5 → 1.1.6

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.
@@ -1,91 +1,27 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import React, { Fragment, useMemo } from 'react';
2
+ import React, { Fragment } from 'react';
3
3
  import { GridStyle } from "../GridStyle";
4
4
  import TableGrid from "../TableGrid";
5
- import { renderContent } from "../hooks/useColumns";
5
+ // import type {ColumnsTable} from "../type";
6
+
7
+ // import {renderContent} from "../hooks/useColumns";
8
+
6
9
  const Grid = props => {
7
10
  const {
8
- t,
9
- columns,
10
11
  height,
11
- tableRef,
12
- components,
13
12
  style,
14
- format,
15
- getRowKey,
16
- triggerChangeColumns,
17
13
  ...rest
18
14
  } = props;
19
- const transformColumns = React.useCallback(cols => {
20
- // @ts-ignore
21
- return cols.map(column => {
22
- if (!column?.field && !column?.key) {
23
- return column;
24
- }
25
-
26
- // Xử lý đệ quy cho children
27
- if (column.children?.length) {
28
- return {
29
- ...column,
30
- children: transformColumns(column.children)
31
- };
32
- }
33
- const transformedColumn = {
34
- ...column,
35
- dataIndex: column.field ?? column.dataIndex,
36
- title: t ? t(column.headerText ?? column.title) : column.headerText ?? column.title,
37
- ellipsis: column.ellipsis !== false,
38
- align: column.textAlign ?? column.align,
39
- fixed: column.frozen ? column.frozen.toLowerCase() : column.fixed
40
- };
41
- // @ts-ignore
42
- if (["index", "#"].includes(transformedColumn.dataIndex)) {
43
- return {
44
- ...transformedColumn,
45
- render: (_, __, rowIndex) => rowIndex + 1
46
- };
47
- }
48
-
49
- // if (transformedColumn.dataIndex === "command") {
50
- // return {
51
- // ...transformedColumn,
52
- // onCell: () => ({ className: "ui-rc-cell-command" }),
53
- // render: () => (
54
- // <div className="ui-rc-cell-command__content">
55
- // {column.commandItems?.map((item, index) =>
56
- // item.visible !== false ? <Command key={`command-${index}`} item={item} onClick={(e) => e.preventDefault()} /> : null
57
- // )}
58
- // </div>
59
- // ),
60
- // };
61
- // }
62
-
63
- return {
64
- ...transformedColumn,
65
- render: (value, record, rowIndex) => renderContent(column, value, record, rowIndex, format)
66
- };
67
- });
68
- }, [format, t]);
69
- const mergedColumns = useMemo(() => transformColumns(columns ?? []), [transformColumns, columns]);
70
15
  return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(GridStyle, {
71
16
  heightTable: height,
72
17
  style: {
73
18
  position: 'relative'
74
19
  }
75
20
  }, /*#__PURE__*/React.createElement(TableGrid, _extends({}, rest, {
76
- t: t,
77
- tableRef: tableRef,
78
- components: {
79
- ...components
80
- },
81
- format: format,
82
- columns: mergedColumns,
83
21
  style: {
84
22
  ...style,
85
23
  minHeight: height
86
- },
87
- getRowKey: getRowKey,
88
- triggerChangeColumns: triggerChangeColumns
24
+ }
89
25
  }))));
90
26
  };
91
27
  export default Grid;
@@ -41,7 +41,8 @@ const GridEdit = props => {
41
41
  } = props;
42
42
 
43
43
  // const forceUpdate = useForceUpdate();
44
- const [updateKey, setUpdateKey] = useState(0);
44
+ // const [updateKey, setUpdateKey] = useState(0);
45
+
45
46
  const isSelecting = useRef(false);
46
47
  const startCell = useRef(null);
47
48
  const isSelectingRow = useRef(false);
@@ -133,17 +134,25 @@ const GridEdit = props => {
133
134
  }
134
135
  setSelectedCells(newSelectedCells);
135
136
  };
136
- const handleClickColHeader = (column, indexColumn) => {
137
- const newSelectedCells = new Set();
138
- for (let r = Math.min(dataSource.length, 0); r <= Math.max(dataSource.length - 1, 0); r++) {
139
- for (let c = Math.min(indexColumn, indexColumn); c <= Math.max(indexColumn, indexColumn); c++) {
140
- newSelectedCells.add(`${r}-${c}`);
141
- }
142
- }
143
- setSelectedCells(new Set(newSelectedCells));
144
- // forceUpdate();
145
- setUpdateKey(prev => prev + 1); // Cập nhật key để trigger re-render
146
- };
137
+
138
+ // const handleClickColHeader = (column: ColumnTable, indexColumn: number) => {
139
+ //
140
+ // const newSelectedCells = new Set();
141
+ //
142
+ // for (let r = Math.min(dataSource.length, 0); r <= Math.max(dataSource.length - 1, 0); r++) {
143
+ // for (let c = Math.min(indexColumn, indexColumn); c <= Math.max(indexColumn, indexColumn); c++) {
144
+ // newSelectedCells.add(`${r}-${c}`)
145
+ // }
146
+ // }
147
+ //
148
+ // // console.log('newSelectedCells', newSelectedCells)
149
+ // // setSelectedCells(newSelectedCells)
150
+ //
151
+ // setSelectedCells(new Set(newSelectedCells));
152
+ // // forceUpdate();
153
+ // setUpdateKey((prev) => prev + 1); // Cập nhật key để trigger re-render
154
+ // }
155
+
147
156
  const handleMouseDownColIndex = (row, col, e) => {
148
157
  if (e.button === 2) {
149
158
  e.stopPropagation();
@@ -317,6 +326,7 @@ const GridEdit = props => {
317
326
  // }
318
327
  };
319
328
  const onSubmit = formData => {
329
+ console.log('onSubmit', formData);
320
330
  try {
321
331
  // const record = (await form.validateFields()) as RecordType;
322
332
  const row = {
@@ -370,6 +380,8 @@ const GridEdit = props => {
370
380
  option,
371
381
  field
372
382
  } = args;
383
+
384
+ // console.log('newState', newState)
373
385
  //
374
386
  // console.log('getValues()', getValues())
375
387
 
@@ -393,6 +405,7 @@ const GridEdit = props => {
393
405
  };
394
406
  if (onCellChange) {
395
407
  if (onCellChange.length > 1) {
408
+ console.log('onCellChange Callback');
396
409
  onCellChange({
397
410
  field,
398
411
  indexCol: 1,
@@ -406,6 +419,7 @@ const GridEdit = props => {
406
419
  sumValue: []
407
420
  }, handleChangeCallback);
408
421
  } else {
422
+ console.log('onCellChange');
409
423
  onCellChange({
410
424
  field,
411
425
  indexCol: 1,
@@ -424,6 +438,7 @@ const GridEdit = props => {
424
438
  console.log('aaaaaa blur');
425
439
  }
426
440
  if (prevState && newState && prevState !== newState && type === 'enter') {
441
+ console.log('enter');
427
442
  onSubmit(record);
428
443
  }
429
444
  };
@@ -707,12 +722,12 @@ const GridEdit = props => {
707
722
  editing: isEditing(record),
708
723
  tabIndex: (rowIndex ?? 0) * columns.length + colIndex
709
724
  }),
710
- onHeaderCell: data => ({
711
- ...col.onHeaderCell(),
712
- onClick: () => {
713
- handleClickColHeader(data, colIndex);
714
- }
715
- }),
725
+ // onHeaderCell: (data) => ({
726
+ // ...col.onHeaderCell(),
727
+ // onClick: () => {
728
+ // handleClickColHeader(data as ColumnTable, colIndex)
729
+ // }
730
+ // }),
716
731
  render: (value, record, rowIndex) => {
717
732
  return /*#__PURE__*/React.createElement("div", {
718
733
  className: classNames('ui-rc_cell-content', {
@@ -748,8 +763,9 @@ const GridEdit = props => {
748
763
  }, /*#__PURE__*/React.createElement("form", {
749
764
  onSubmit: handleSubmit(onSubmit)
750
765
  }, /*#__PURE__*/React.createElement(TableGrid, _extends({}, rest, {
751
- t: t,
752
- key: updateKey,
766
+ t: t
767
+ // key={updateKey}
768
+ ,
753
769
  tableRef: tableRef,
754
770
  dataSource: dataSource,
755
771
  components: {
@@ -773,8 +789,7 @@ const GridEdit = props => {
773
789
  ...style,
774
790
  minHeight: height
775
791
  },
776
- rowHoverable: false,
777
- getRowKey: getRowKey
792
+ rowHoverable: false
778
793
  }))))), /*#__PURE__*/React.createElement(Toaster, {
779
794
  position: toast,
780
795
  toastOptions: {
@@ -1,4 +1,4 @@
1
- import type { ReactElement, ReactNode } from "react";
1
+ import type { Key, ReactElement, ReactNode } from "react";
2
2
  import type React from "react";
3
3
  import type { IOperator } from "./hooks";
4
4
  import type { TypeFilter, TableProps as RcTableProps, TableColumnType as RcColumnType, EditType } from "rc-master-ui";
@@ -9,7 +9,6 @@ import type { FieldNames, FilterFunc } from "rc-select/es/Select";
9
9
  import type { ColorPickerProps } from "antd";
10
10
  export type IColumnType = "number" | "time" | "date" | "week" | "month" | "file" | "quarter" | "year" | "datetime" | "string" | "boolean" | "checkbox" | "color" | null | undefined;
11
11
  export type AnyObject = Record<PropertyKey, any>;
12
- export type Key = React.Key;
13
12
  export type SelectMode = 'checkbox' | 'radio' | undefined;
14
13
  export type ITextAlign = 'center' | 'left' | 'right';
15
14
  export type Frozen = 'left' | 'right' | 'Left' | 'Right';
@@ -87,6 +86,7 @@ export type ColumnType<RecordType> = Omit<RcColumnType<RecordType>, 'headerTempl
87
86
  maxWidth?: string | number;
88
87
  format?: IFormat;
89
88
  allowFiltering?: boolean;
89
+ allowSorter?: boolean;
90
90
  operator?: FilterOperator;
91
91
  hideOperator?: boolean;
92
92
  placeholder?: string;
@@ -161,6 +161,7 @@ export interface TableProps<RecordType> extends Omit<RcTableProps<RecordType>, '
161
161
  onFilterClick?: (column: ColumnTable<RecordType>, callback: (key: string, data: any) => void) => void;
162
162
  loading?: boolean;
163
163
  allowResizing?: boolean;
164
+ showToolbar?: boolean;
164
165
  onDataChange?: (data: RecordType[]) => void;
165
166
  summary?: boolean | ((data: readonly RecordType[]) => React.ReactNode);
166
167
  }
@@ -177,7 +178,7 @@ export interface CommandItem {
177
178
  title: string;
178
179
  color?: 'blue' | 'purple' | 'cyan' | 'green' | 'magenta' | 'pink' | 'red' | 'orange' | 'yellow' | 'volcano' | 'geekblue' | 'lime' | 'gold';
179
180
  tooltip?: string;
180
- icon?: any;
181
+ icon?: ReactNode | ReactElement | (() => ReactNode | ReactElement);
181
182
  template?: ReactNode | ReactElement | (() => ReactNode | ReactElement);
182
183
  client?: boolean;
183
184
  confirmDialog?: boolean;
@@ -211,7 +212,6 @@ export type SourceFilter = {
211
212
  loadOptions?: (search: string, callback: (newOptions: any[]) => void) => void;
212
213
  };
213
214
  export type RowSelection<RecordType> = Omit<TableRowSelection<RecordType>, 'type' | 'columnWidth' | 'hideSelectAll' | 'defaultSelectedRowKeys'>;
214
- export type RowSelectMethod = 'all' | 'none' | 'invert' | 'single' | 'multiple';
215
215
  export type SelectionSettings = Omit<TableRowSelection, 'type' | 'onChange' | 'onSelect' | 'onSelectAll' | 'onSelectNone' | 'onSelectMultiple'> & {
216
216
  mode?: 'checkbox' | 'radio';
217
217
  type?: 'single' | 'multiple';
@@ -65,6 +65,7 @@ const InternalTable = props => {
65
65
  onFilterClick,
66
66
  editAble,
67
67
  rowKey,
68
+ format,
68
69
  onDataChange,
69
70
  sortMultiple,
70
71
  ...rest
@@ -124,27 +125,23 @@ const InternalTable = props => {
124
125
  setSelectedKeys,
125
126
  selectedKeys,
126
127
  confirm,
127
- // close,
128
+ close,
128
129
  setOperatorKey,
129
130
  operatorKey,
130
131
  visible,
131
132
  searchValue,
132
133
  setSearchValue
133
134
  }) => {
134
- const type = (0, _hooks.getTypeFilter)(column);
135
- // const operatorOptions = !type || type === 'Text' ? stringOperator : numberOperator
136
- // const operatorOptions = type === 'Checkbox' || type === 'Dropdown' || type === 'DropTree' || ty
137
- const operatorOptions = type === ('Checkbox' || 'Dropdown' || 'DropTree' || 'CheckboxDropdown') ? _hooks.booleanOperator : !type || type === 'Text' ? _hooks.stringOperator : _hooks.numberOperator;
138
135
  return /*#__PURE__*/_react.default.createElement("div", {
139
136
  style: {
140
137
  padding: 8,
141
138
  minWidth: 275
142
139
  },
143
140
  onKeyDown: e => e.stopPropagation()
144
- }, column?.showOperator !== false && column?.typeFilter !== 'DateRange' && column?.typeFilter !== 'NumberRange' && /*#__PURE__*/_react.default.createElement("div", {
141
+ }, (column?.showOperator !== false || column?.typeFilter !== 'DateRange' && column?.typeFilter !== 'NumberRange') && /*#__PURE__*/_react.default.createElement("div", {
145
142
  className: 'mb-1'
146
143
  }, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Select, {
147
- options: (0, _hooks.translateOption)(operatorOptions, t),
144
+ options: (0, _hooks.translateOption)(_hooks.numberOperator, t),
148
145
  style: {
149
146
  width: '100%',
150
147
  marginBottom: 8
@@ -175,17 +172,13 @@ const InternalTable = props => {
175
172
  style: {
176
173
  width: 90
177
174
  }
178
- }, t ? t('Filter') : 'Filter'), /*#__PURE__*/_react.default.createElement(_antd.Button, {
175
+ }, "Filter"), /*#__PURE__*/_react.default.createElement(_antd.Button, {
179
176
  type: "link",
180
177
  size: "small",
181
178
  onClick: () => {
182
- // setSearchValue('')
183
- setSelectedKeys([]);
184
- confirm();
185
- // handleSearch()
186
- // close()
179
+ close();
187
180
  }
188
- }, t ? t("Clear") : 'Clear')));
181
+ }, "close")));
189
182
  },
190
183
  filterIcon: filtered => /*#__PURE__*/_react.default.createElement(_becoxyIcons.FilterFill, {
191
184
  fontSize: 12,
@@ -203,7 +196,7 @@ const InternalTable = props => {
203
196
  }
204
197
  }
205
198
  }
206
- }), [buddhistLocale, dataSourceFilter, onFilterCallback, onFilterClick, t]);
199
+ }), [onFilterCallback, onFilterClick, _useColumns.renderFilter, t]);
207
200
  const handleResize = indexPath => (e, {
208
201
  size
209
202
  }) => {
@@ -257,7 +250,7 @@ const InternalTable = props => {
257
250
  key: col.field ?? col.dataIndex ?? col.key,
258
251
  title: t ? t(col.headerText ?? col.title) : col.headerText ?? col.title,
259
252
  ellipsis: col.ellipsis !== false,
260
- align: col.textAlign ?? col.align ?? col.type === 'number' ? 'right' : undefined,
253
+ align: col.textAlign ?? col.align,
261
254
  fixed: col.frozen ? col.frozen.toLowerCase() : col.fixed
262
255
  };
263
256
  if (col.children) {
@@ -266,31 +259,52 @@ const InternalTable = props => {
266
259
  children: transformColumns(col.children, currentPath)
267
260
  };
268
261
  }
269
- if (col.dataIndex === 'index' || col.field === 'index' || col.dataIndex === '#' || col.field === '#' || col.allowFiltering === false || col.field === 'command') {
262
+
263
+ // @ts-ignore
264
+ if (["index", "#"].includes(transformedColumn.dataIndex)) {
270
265
  return {
271
- ...transformedColumn
266
+ ...transformedColumn,
267
+ render: (_, __, rowIndex) => rowIndex + 1
268
+ };
269
+ }
270
+ if (col.field === 'command') {
271
+ return {
272
+ ...transformedColumn,
273
+ onCell: () => ({
274
+ className: col.field === 'command' ? "ui-rc-cell-command" : ''
275
+ }),
276
+ onHeaderCell: () => ({
277
+ width: col.width,
278
+ onResize: handleResize(currentPath)
279
+ })
272
280
  };
273
281
  }
274
282
  return {
275
- ...getColumnSearchProps(col),
283
+ ...(col.allowFiltering === false ? {} : {
284
+ ...getColumnSearchProps(col)
285
+ }),
276
286
  ...transformedColumn,
277
287
  onFilter: value => {
278
288
  return value;
279
289
  },
280
- sorter: {
290
+ sorter: col.sorter === false ? undefined : {
281
291
  compare: a => a,
282
292
  multiple: sortMultiple ? index : undefined
283
293
  },
284
294
  onHeaderCell: () => ({
285
295
  width: col.width,
286
296
  onResize: handleResize(currentPath)
287
- })
297
+ }),
298
+ render: (value, record, rowIndex) => (0, _useColumns.renderContent)(col, value, record, rowIndex, format)
288
299
  };
289
300
  });
290
- }, [getColumnSearchProps, sortMultiple, t]);
301
+ }, [getColumnSearchProps]);
291
302
  const mergedColumns = _react.default.useMemo(() => {
292
303
  return transformColumns(columns);
293
304
  }, [transformColumns, columns]);
305
+
306
+ // console.log('mergedColumns', mergedColumns)
307
+
294
308
  const triggerChangeColumns = newColumns => {
295
309
  setColumns(newColumns);
296
310
  };
@@ -309,6 +323,7 @@ const InternalTable = props => {
309
323
  cell: allowResizing ? ResizableTitle : undefined
310
324
  }
311
325
  },
326
+ format: format,
312
327
  columns: mergedColumns
313
328
  // columns={columns}
314
329
  ,
@@ -6,7 +6,6 @@ type GridProps<T> = GridTableProps<T> & {
6
6
  triggerChangeColumns?: (columns: ColumnsTable<T>, type: string) => void;
7
7
  triggerChangeData?: () => void;
8
8
  tableRef: any;
9
- getRowKey: any;
10
9
  };
11
10
  declare const TableGrid: <RecordType extends object>(props: GridProps<RecordType>) => React.JSX.Element;
12
11
  export default TableGrid;
@@ -23,21 +23,6 @@ var _ColumnsChoose = require("./ColumnsChoose");
23
23
  var _useMergedState = _interopRequireDefault(require("rc-util/lib/hooks/useMergedState"));
24
24
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
25
25
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
26
- // import type {CheckboxProps} from "rc-master-ui";
27
-
28
- // import { conductCheck } from 'rc-tree/lib/utils/conductUtil';
29
- // import { devUseWarning } from '../../_util/warning';
30
- // import { arrAdd, arrDel } from 'rc-tree/lib/util';
31
-
32
- // import {useMergedState} from "rc-util";
33
-
34
- // import {convertDataToEntities} from "rc-tree/lib/utils/treeUtil";
35
- // import type {DataNode} from "rc-tree/lib/interface";
36
- // import {devUseWarning} from "antd/es/_util/warning";
37
- // import type {GetCheckDisabled} from "rc-tree/es/interface";
38
- // import useLazyKVMap from "antd/es/table/hooks/useLazyKVMap";
39
- // import useMultipleSelect from "rc-master-ui/es/_util/hooks/useMultipleSelect";
40
-
41
26
  const convertFilters = filters => {
42
27
  const result = [];
43
28
  filters.forEach(({
@@ -105,21 +90,6 @@ const useStyle = (0, _antdStyle.createStyles)(({
105
90
  // type OnChange = NonNullable<TableProps<any>['onChange']>;
106
91
 
107
92
  const EMPTY_LIST = [];
108
-
109
- // const flattenData = <RecordType extends AnyObject = AnyObject>(
110
- // childrenColumnName: keyof RecordType,
111
- // data?: RecordType[],
112
- // ): RecordType[] => {
113
- // let list: RecordType[] = [];
114
- // (data || []).forEach((record) => {
115
- // list.push(record);
116
- // if (record && typeof record === 'object' && childrenColumnName in record) {
117
- // list = [...list, ...flattenData<RecordType>(childrenColumnName, record[childrenColumnName])];
118
- // }
119
- // });
120
- // return list;
121
- // };
122
-
123
93
  const TableGrid = props => {
124
94
  const {
125
95
  columns,
@@ -142,7 +112,7 @@ const TableGrid = props => {
142
112
  selectionSettings,
143
113
  rowSelection,
144
114
  rowSelected,
145
- rowKey,
115
+ rowKey = 'id',
146
116
  pagination,
147
117
  scroll,
148
118
  onFilterClick,
@@ -150,7 +120,7 @@ const TableGrid = props => {
150
120
  loading,
151
121
  triggerChangeColumns,
152
122
  summary,
153
- getRowKey,
123
+ showToolbar,
154
124
  onSorter,
155
125
  ...rest
156
126
  } = props;
@@ -160,13 +130,11 @@ const TableGrid = props => {
160
130
  const {
161
131
  mode,
162
132
  type,
163
- // checkboxOnly,
133
+ checkboxOnly,
164
134
  hideSelectAll,
165
135
  columnWidth,
166
136
  selectedRowKeys,
167
137
  defaultSelectedRowKeys
168
- // getCheckboxProps,
169
- // checkStrictly = true
170
138
  } = selectionSettings || {};
171
139
  const clickRef = (0, _react.useRef)(null);
172
140
  const menuRef = (0, _react.useRef)(null);
@@ -181,10 +149,15 @@ const TableGrid = props => {
181
149
  viewportHeight
182
150
  });
183
151
 
152
+ // const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>(defaultSelected);
153
+
184
154
  // ========================= Keys =========================
185
155
  const [mergedSelectedKeys, setMergedSelectedKeys] = (0, _useMergedState.default)(selectedRowKeys || defaultSelectedRowKeys || EMPTY_LIST, {
186
156
  value: selectedRowKeys
187
157
  });
158
+
159
+ // Reset if rowSelection reset
160
+
188
161
  _react.default.useEffect(() => {
189
162
  if (!selectionSettings) {
190
163
  setMergedSelectedKeys(EMPTY_LIST);
@@ -257,6 +230,18 @@ const TableGrid = props => {
257
230
  });
258
231
  }
259
232
  };
233
+ const handleRowClick = () => () => {
234
+ if (checkboxOnly !== true) {
235
+ if (type === 'single') {}
236
+ }
237
+ if (clickRef.current) return;
238
+
239
+ // @ts-ignore
240
+ clickRef.current = setTimeout(() => {
241
+ // console.log("Single Click:", record);
242
+ clickRef.current = null;
243
+ }, 250);
244
+ };
260
245
  const handleRowDoubleClick = (record, index) => e => {
261
246
  if (clickRef.current) {
262
247
  clearTimeout(clickRef.current);
@@ -285,10 +270,9 @@ const TableGrid = props => {
285
270
  rowData: selectedRow
286
271
  });
287
272
  } else {
288
- // @ts-ignore
289
273
  setMergedSelectedKeys(keys);
290
274
  rowSelected?.({
291
- selected: [selectedRow],
275
+ selected: selectedRows,
292
276
  type: 'rowSelected',
293
277
  rowData: selectedRow
294
278
  });
@@ -297,8 +281,6 @@ const TableGrid = props => {
297
281
  };
298
282
  const handleChange = sorter => {
299
283
  onSorter?.(sorter);
300
- // setFilteredInfo(filters);
301
- // setSortedInfo(sorter as Sorts);
302
284
  };
303
285
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_antd.ConfigProvider, {
304
286
  theme: {
@@ -328,7 +310,7 @@ const TableGrid = props => {
328
310
  // className={styles.customTable}
329
311
  ,
330
312
  className: (0, _classnames.default)(className, {
331
- 'table-none-column-select': mode === undefined && type !== 'multiple'
313
+ 'table-none-column-select': selectionSettings?.mode === undefined && selectionSettings?.type !== 'multiple'
332
314
  }, styles.customTable),
333
315
  bordered: true,
334
316
  virtual: virtual,
@@ -342,18 +324,17 @@ const TableGrid = props => {
342
324
  onRow: (data, index) => {
343
325
  return {
344
326
  onDoubleClick: handleRowDoubleClick(data, index),
345
- // onClick: handleRowClick(data, index),
327
+ // onClick: handleRowClick,
328
+ onClick: handleRowClick(),
346
329
  onContextMenu: onContextMenu(data)
347
330
  };
348
331
  },
349
332
  rowSelection: {
350
333
  ...selectionSettings,
351
- type: mode === 'checkbox' || type === 'multiple' ? 'checkbox' : "radio",
334
+ type: selectionSettings?.mode === 'checkbox' || type === 'multiple' ? 'checkbox' : "radio",
352
335
  columnWidth: !mode ? 0.0000001 : columnWidth ?? 50,
353
336
  onChange: onSelectChange,
354
337
  // selectedRowKeys: mode === 'checkbox' && type === 'single' ? selectedRowKeys : undefined,
355
- // selectedRowKeys: mode === 'checkbox' && type === 'single' ? mergedSelectedKeys : undefined,
356
-
357
338
  selectedRowKeys: mergedSelectedKeys,
358
339
  defaultSelectedRowKeys: selectionSettings?.defaultSelectedRowKeys,
359
340
  preserveSelectedRowKeys: true,
@@ -404,43 +385,48 @@ const TableGrid = props => {
404
385
  onFilter?.(convertFilters(val));
405
386
  },
406
387
  onChange: (paging, filters, sorter) => handleChange(sorter),
407
- title: () => {
408
- return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", null, title?.(dataSource)), (toolbarItems || showColumnChoose !== false) && /*#__PURE__*/_react.default.createElement("div", {
388
+ title: showToolbar === false ? undefined : () => {
389
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", null, title?.(dataSource)), /*#__PURE__*/_react.default.createElement("div", {
409
390
  style: {
410
391
  display: 'flex',
411
- justifyContent: 'space-between'
392
+ justifyContent: 'space-between',
393
+ alignItems: 'center'
412
394
  }
413
- }, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Toolbar, {
395
+ }, toolbarItems && toolbarItems?.length > 0 && /*#__PURE__*/_react.default.createElement(_rcMasterUi.Toolbar
396
+ // @ts-ignore
397
+ , {
414
398
  style: {
415
- width: '100%'
399
+ width: pagination && pagination.onChange && pagination?.position && pagination?.position[0] === 'topRight' ? `calc(100% - 650px` : `calc(100% - 50px`
416
400
  },
417
401
  items: toolbarItems ?? [],
418
- mode: 'responsive'
419
- // mode={'scroll'}
420
- // onClick={(val: any) => {
421
- // }}
422
- }), showColumnChoose && /*#__PURE__*/_react.default.createElement(_ColumnsChoose.ColumnsChoose, {
402
+ mode: 'scroll'
403
+ }), /*#__PURE__*/_react.default.createElement("div", {
404
+ style: {
405
+ display: 'flex',
406
+ justifyContent: 'space-between',
407
+ alignItems: 'center'
408
+ }
409
+ }, pagination && pagination.onChange && pagination?.position && pagination?.position[0] === 'topRight' && /*#__PURE__*/_react.default.createElement(_pagination.default, (0, _extends2.default)({
410
+ showSizeChanger: true,
411
+ responsive: true,
412
+ size: 'small',
413
+ rootClassName: 'top-pagination'
414
+ // @ts-ignore
415
+ ,
416
+ showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
417
+ }, pagination)), showColumnChoose && /*#__PURE__*/_react.default.createElement(_ColumnsChoose.ColumnsChoose, {
423
418
  columns: columns,
424
419
  t: t,
425
420
  triggerChangeColumns: triggerChangeColumns
426
- }), /*#__PURE__*/_react.default.createElement("div", null)));
427
- }
428
-
429
- // rowClassName={(record) => (selectionSettings?.getCheckboxProps(record).disabled ? "row-disabled" : "")}
430
- ,
431
- rowClassName: record => {
432
- const originalOnCell = selectionSettings?.getCheckboxProps?.(record) || {};
433
- return originalOnCell.disabled ? 'row-disabled' : '';
421
+ }))));
434
422
  }
435
- }, rest)), pagination && pagination.onChange && /*#__PURE__*/_react.default.createElement(_pagination.default
423
+ }, rest)), pagination && pagination.onChange && !pagination.position && /*#__PURE__*/_react.default.createElement(_pagination.default
436
424
  // style={{padding: '0.75rem 1rem'}}
437
425
  , (0, _extends2.default)({
438
426
  showSizeChanger: true,
439
427
  responsive: true,
440
- size: 'small'
441
- // @ts-ignore
442
- ,
443
- showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
428
+ size: 'small',
429
+ showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} items`
444
430
  }, pagination))));
445
431
  };
446
432
  var _default = exports.default = TableGrid;