es-grid-template 1.8.58 → 1.8.60

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,326 +1,7 @@
1
- // import React, {Fragment, useMemo, useState} from "react"
2
- //
3
- // import styled from "styled-components"
4
- // import {Button, Input, Popover, Tooltip} from "antd";
5
- // import {SettingOutlined} from "@ant-design/icons";
6
- // import {
7
- // getVisibleColumnKeys,
8
- // updateColumns
9
- // } from "./hooks";
10
- //
11
- // // import type {TableColumnsType} from "rc-master-ui";
12
- // import Tree from "rc-master-ui/es/tree";
13
- // import SearchOutlined from "@ant-design/icons/SearchOutlined";
14
- // import type {ColumnsTable} from "./type";
15
- // import useMergedState from "rc-util/lib/hooks/useMergedState";
16
- //
17
- //
18
- // const BoxAction = styled.div`
19
- // border-top: 1px solid #c4c4c4;
20
- // padding-top: .75rem;
21
- // display: flex;
22
- // justify-content: end;
23
- // gap: 10px;
24
- //
25
- // .btn-action {
26
- // background: none !important;
27
- // border: none !important;
28
- // &.btn-action-submit {
29
- // color: #df4318;
30
- // &:disabled {
31
- // background-color: #f0f0f0 !important;
32
- // }
33
- // &:hover {
34
- // color: #df4318 !important;
35
- // }
36
- // }
37
- //
38
- // &:hover {
39
- // background-color: #f0f0f0 !important;
40
- // }
41
- // }
42
- // `
43
- //
44
- // export type IColumnsChoose<RecordType> = {
45
- // columns: ColumnsTable<RecordType>
46
- // columnsGroup?: string[]
47
- // triggerChangeColumns?: (columns: ColumnsTable<RecordType>, type: string) => void
48
- // t?: any
49
- //
50
- // }
51
- //
52
- //
53
- // export const ColumnsChoose = <RecordType extends object>(props: IColumnsChoose<RecordType>) => {
54
- // const {
55
- // columns: propsColumns,
56
- // triggerChangeColumns,
57
- // t,
58
- // columnsGroup,
59
- // } = props
60
- //
61
- // // const dataList: { key: React.Key; title: string }[] = [];
62
- //
63
- // // const defaultColumns = useMemo(() => {
64
- // // return propsColumns.filter((it) => it.key || it.dataIndex && it.showColumnChoose !== false)
65
- // // }, [propsColumns])
66
- //
67
- //
68
- // // const columnsChooseRef: any = useRef()
69
- // // const searchRef: any = useRef()
70
- //
71
- //
72
- //
73
- // // const [columns, setColumns] = useState<TableColumnsType>([])
74
- //
75
- // // const [selectedKeys, setSelectedKeys] = useState<string[]>([]);
76
- //
77
- // // const [isManualUpdate, setIsManualUpdate] = useState(false);
78
- //
79
- //
80
- // // useEffect(() => {
81
- // //
82
- // // const defaultColumns = propsColumns.filter((it) => it.key || it.dataIndex && it.showInColumnChoose !== false)
83
- // // setColumns(defaultColumns as TableColumnsType)
84
- // //
85
- // // }, [propsColumns])
86
- //
87
- // const columns = useMemo(() => {
88
- //
89
- // // return propsColumns.filter((it) => (it.key || it.dataIndex) && it.showInColumnChoose !== false && !columnsGroup?.includes(it.field as string))
90
- // return propsColumns.filter((it) => (it.key || it.dataIndex) && it.showInColumnChoose !== false)
91
- // // setColumns(defaultColumns as TableColumnsType)
92
- // }, [columnsGroup, propsColumns])
93
- //
94
- //
95
- // // useEffect(() => {
96
- // //
97
- // // const defaultColumns = propsColumns.filter((it) => it.key || it.dataIndex && it.showInColumnChoose !== false)
98
- // //
99
- // // const defaultSelectedKeys = getVisibleColumnKeys(defaultColumns)
100
- // //
101
- // // if (!isManualUpdate) {
102
- // // setSelectedKeys(defaultSelectedKeys)
103
- // // }
104
- // // setIsManualUpdate(false);
105
- // //
106
- // //
107
- // // }, [isManualUpdate, propsColumns])
108
- //
109
- // const defaultSelectedKeys = React.useMemo(() => {
110
- //
111
- // const rs = propsColumns.filter((it) => (it.key || it.dataIndex) && it.showInColumnChoose !== false && !columnsGroup?.includes(it.field as string))
112
- // return getVisibleColumnKeys(rs)
113
- //
114
- // }, [columnsGroup, propsColumns])
115
- //
116
- // const [mergedSelectedKeys, setMergedSelectedKeys] = useMergedState(
117
- // defaultSelectedKeys || [],
118
- // {
119
- // value: defaultSelectedKeys,
120
- // },
121
- // );
122
- //
123
- // //
124
- // // const defaultSelectedKeys = useMemo(() => {
125
- // //
126
- // // return getVisibleColumnKeys(propsColumns)
127
- // //
128
- // // }, [propsColumns])
129
- //
130
- //
131
- // const [clicked, setClicked] = useState(false);
132
- // const [autoExpandParent, setAutoExpandParent] = useState(true);
133
- //
134
- //
135
- // // const treeData = useMemo(() => {
136
- // // const loop = (data: TreeDataNode[]): TreeDataNode[] =>
137
- // // data.map((item) => {
138
- // // const strTitle = item.title as string;
139
- // // const index = strTitle.indexOf(searchValue);
140
- // // const beforeStr = strTitle.substring(0, index);
141
- // // const afterStr = strTitle.slice(index + searchValue.length);
142
- // // const title =
143
- // // index > -1 ? (
144
- // // <span key={item.key}>
145
- // // {beforeStr}
146
- // // <span className="site-tree-search-value">{searchValue}</span>
147
- // // {afterStr}
148
- // // </span>
149
- // // ) : (
150
- // // <span key={item.key}>{strTitle}</span>
151
- // // );
152
- // // if (item.children) {
153
- // // return { title, key: item.key, children: loop(item.children) };
154
- // // }
155
- // //
156
- // // return {
157
- // // title,
158
- // // key: item.key,
159
- // // };
160
- // // });
161
- // //
162
- // // // return loop(defaultData);
163
- // // return loop(columns as any);
164
- // // }, [searchValue, columns]);
165
- //
166
- //
167
- // const hide = () => {
168
- // setClicked(false)
169
- // }
170
- //
171
- // const handleClickChange = (open: boolean) => {
172
- // setClicked(open)
173
- // }
174
- //
175
- // const onExpand = () => {
176
- // // setExpandedKeys(newExpandedKeys)
177
- // setAutoExpandParent(false)
178
- // }
179
- //
180
- // // const getParentKey = (key: React.Key, tree: TreeDataNode[]): React.Key => {
181
- // // let parentKey: React.Key
182
- // // for (let i = 0; i < tree.length; i++) {
183
- // // const node = tree[i]
184
- // // if (node.children) {
185
- // // if (node.children.some((item) => item.key === key)) {
186
- // // parentKey = node.key
187
- // // } else if (getParentKey(key, node.children)) {
188
- // // parentKey = getParentKey(key, node.children)
189
- // // }
190
- // // }
191
- // // }
192
- // // return parentKey!
193
- // // }
194
- //
195
- // // const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
196
- // const onChange = () => {
197
- // // const { value } = e.target
198
- // // const newExpandedKeys = dataList
199
- // // .map((item) => {
200
- // // if (item.title.indexOf(value) > -1) {
201
- // // return getParentKey(item.key, defaultData)
202
- // // }
203
- // // return null
204
- // // })
205
- // // .filter((item, i, self): item is React.Key => !!(item && self.indexOf(item) === i))
206
- // // setExpandedKeys(newExpandedKeys)
207
- //
208
- // // setSearchValue(value)
209
- // setAutoExpandParent(true)
210
- // };
211
- //
212
- // const onCheck = (keys: string[]) => {
213
- //
214
- // // setSelectedKeys(keys)
215
- // setMergedSelectedKeys(keys)
216
- // // setIsManualUpdate(true)
217
- //
218
- // }
219
- //
220
- // const handleAccept = () => {
221
- //
222
- //
223
- // // const rs1 = updateColumns(propsColumns, selectedKeys)
224
- // const rs1 = updateColumns(propsColumns, mergedSelectedKeys)
225
- //
226
- //
227
- // triggerChangeColumns?.(rs1, 'columnChoose')
228
- //
229
- // hide()
230
- //
231
- // }
232
- //
233
- // const handleCancel = () => {
234
- // // setSelectedKeys(defaultSelectedKeys)
235
- // hide()
236
- // }
237
- //
238
- //
239
- // return (
240
- // <Fragment>
241
- // <Popover
242
- // placement={'bottomLeft'}
243
- // content={
244
- // <div style={{minWidth: 250}}>
245
- // <Input style={{ marginBottom: 8 }} placeholder={t ? t("Search") : 'Search'} prefix={<SearchOutlined />} onChange={onChange} />
246
- //
247
- // <Tree
248
- // onExpand={onExpand}
249
- // // expandedKeys={expandedKeys}
250
- // autoExpandParent={autoExpandParent}
251
- // // treeData={treeData}
252
- // treeData={columns}
253
- // defaultExpandAll={true}
254
- // checkable={true}
255
- // // onSelect={(keys, info) => {
256
- // // const key = info.node.key
257
- // //
258
- // // const find = findItemByKey(columns, 'key', key)
259
- // //
260
- // // // const tmpColumn
261
- // //
262
- // // // if (selectedKeys.includes(key as string)) {
263
- // // // const rssss = findKeyPath(columns, key as string)
264
- // // // const rs = selectedKeys.filter(item => !rssss.includes(item));
265
- // // //
266
- // // // setSelectedKeys(rs)
267
- // // // } else {
268
- // //
269
- // // // const rs = [...selectedKeys, keys[0]]
270
- // //
271
- // // // setSelectedKeys(keys)
272
- // // // }
273
- // // }}
274
- // onCheck={(keys) => onCheck(keys as string[])}
275
- //
276
- //
277
- // multiple={true}
278
- // // checkedKeys={selectedKeys}
279
- //
280
- // defaultCheckedKeys={mergedSelectedKeys}
281
- // // defaultCheckedKeys={defaultSelectedKeys}
282
- // // selectedKeys={[]}
283
- //
284
- // height={window.innerHeight - 200}
285
- //
286
- // />
287
- //
288
- //
289
- // <BoxAction className={'px-1'}>
290
- // <Button
291
- // // className={classnames('btn-action btn-action-submit', {
292
- // // // disable: !columns.find((item) => item.visible !== false || item.visible)
293
- // // })}
294
- // onClick={handleAccept}
295
- // // disabled={!columns.find((item) => item.visible !== false || item.visible)}
296
- // >
297
- // {t ? t('OK') : 'OK'}
298
- // {/*{'OK'}*/}
299
- // </Button>
300
- //
301
- // {/*<Button className={'btn-action btn-action-cancel'} onClick={hide} >{('Cancel') }</Button>*/}
302
- // <Button className={'btn-action btn-action-cancel'} onClick={handleCancel} >{t ? t('Cancel') : 'Cancel' }</Button>
303
- // </BoxAction>
304
- // </div>
305
- // }
306
- // trigger="click"
307
- // open={clicked}
308
- // onOpenChange={handleClickChange}
309
- // arrow={false}
310
- // >
311
- // <Tooltip arrow={false} title={'Cài đặt'} >
312
- // <SettingOutlined size={16} color={'#555555'} style={{fontSize: 16, color: '#555555'}} />
313
- // </Tooltip>
314
- //
315
- // </Popover>
316
- // </Fragment>
317
- // )
318
- // }
319
-
320
1
  import React, { Fragment, useEffect, useMemo, useState } from "react";
321
2
  import styled from "styled-components";
322
3
  import { Button, Input, Popover, Tooltip } from "antd";
323
- import { SettingOutlined } from "@ant-design/icons";
4
+ import { Settings } from "becoxy-icons";
324
5
  import { getVisibleColumnKeys, updateColumns } from "./hooks";
325
6
 
326
7
  // import type {TableColumnsType} from "rc-master-ui";
@@ -543,5 +224,7 @@ export const ColumnsChoose = props => {
543
224
  }, /*#__PURE__*/React.createElement(Tooltip, {
544
225
  arrow: false,
545
226
  title: 'Cài đặt'
546
- }, /*#__PURE__*/React.createElement(SettingOutlined, null))));
227
+ }, /*#__PURE__*/React.createElement(Settings, {
228
+ fontSize: 16
229
+ }))));
547
230
  };
@@ -2,9 +2,10 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import React, { createContext, Fragment, useCallback, useContext, useState } from 'react';
3
3
  import 'react-resizable/css/styles.css';
4
4
  import customParseFormat from 'dayjs/plugin/customParseFormat';
5
- import { addRowIdArray, booleanOperator, convertFilters, convertFlatColumn, filterDataByColumns4, findItemByKey, findItemPath, flattenArray, getAllRowKey, getFormat, getTypeFilter, groupArrayByColumns, isNullOrUndefined, numberOperator, removeColumns, removeInvisibleColumns, stringOperator, translateOption, unFlattenData, updateArrayByKey, updateColumnsByGroup,
5
+ import { addRowIdArray, booleanOperator, convertFilters, convertFlatColumn, filterDataByColumns4, findItemByKey, findItemPath, flattenArray, getAllRowKey, getFormat, getTypeFilter, groupArrayByColumns, isNullOrUndefined, numberOperator, removeColumns, removeInvisibleColumns, stringOperator, sumByField, translateOption, unFlattenData, updateArrayByKey, updateColumnsByGroup,
6
6
  // updateData,
7
7
  updateOrInsert } from "./hooks";
8
+ import ReactDOMServer from 'react-dom/server';
8
9
  import dayjs from "dayjs";
9
10
  import 'dayjs/locale/es';
10
11
  import 'dayjs/locale/vi';
@@ -243,30 +244,22 @@ const InternalTable = props => {
243
244
  active: -1,
244
245
  over: -1
245
246
  });
246
- const [tooltipContent, setTooltipContent] = useState('');
247
+ // const [tooltipContent, setTooltipContent] = useState<any>('')
248
+
247
249
  const [filterStates, setFilterState] = React.useState(null);
248
250
  const [isFullScreen, setIsFullScreen] = React.useState(false);
251
+ const [isOpenTooltip, setIsOpenTooltip] = React.useState(false);
249
252
  const mergedData = React.useMemo(() => {
250
- if (groupAble && groupSetting && groupSetting.client !== false) {
253
+ if (groupSetting && groupSetting.client !== false) {
251
254
  return groupArrayByColumns(dataSource, groupColumns);
252
255
  }
253
256
  return addRowIdArray(dataSource);
254
- }, [dataSource, groupAble, groupColumns, groupSetting]);
257
+ }, [dataSource, groupColumns, groupSetting?.client]);
255
258
 
256
259
  // ========================= Keys =========================
257
260
  const [mergedFilterKeys, setMergedFilterKeys] = useMergedState(getAllRowKey(mergedData), {
258
261
  value: undefined
259
262
  });
260
- //
261
- // const originData = React.useMemo(() => {
262
- //
263
- // if (groupAble && groupSetting && groupSetting.client !== false) {
264
- // return groupArrayByColumns(dataSource, groupColumns)
265
- // }
266
- // return addRowIdArray(dataSource)
267
- //
268
- // }, [dataSource, groupAble, groupColumns, groupSetting])
269
-
270
263
  const [columns, setColumns] = React.useState([]);
271
264
  React.useEffect(() => {
272
265
  const totalHeight = propsHeight;
@@ -445,7 +438,7 @@ const InternalTable = props => {
445
438
  wrapSettings: wrapSettings
446
439
  })),
447
440
  // ellipsis: editAble || column.ellipsis !== false && wrapSettings && wrapSettings.wrapMode !== 'Content' && wrapSettings.wrapMode !== 'Both',
448
- ellipsis: column.ellipsis !== false && wrapSettings && wrapSettings.wrapMode !== 'Content' && wrapSettings.wrapMode !== 'Both',
441
+ ellipsis: column.ellipsis !== false || wrapSettings && wrapSettings.wrapMode !== 'Content' && wrapSettings.wrapMode !== 'Both',
449
442
  // ellipsis: false,
450
443
  // ellipsis: column.ellipsis !== false,
451
444
 
@@ -561,6 +554,10 @@ const InternalTable = props => {
561
554
  ${wrapSettings && wrapSettings.wrapMode === 'Content' ? 'ui-rc-table-cell-ellipsis' : ''}`
562
555
  }),
563
556
  onCell: (data, index) => {
557
+ const tooltipContent = isOpenTooltip === false ? '' : column?.tooltipDescription ? typeof column.tooltipDescription === 'function' ? column.tooltipDescription({
558
+ value: data[column.field ?? ''],
559
+ record: data
560
+ }) : column.tooltipDescription : column.template && typeof column.template !== 'function' ? column.template : data[column.field ?? ''];
564
561
  return {
565
562
  id: `${column.field}`,
566
563
  colSpan: groupColumns && data.children && column.field === firstNonGroupColumn?.field ? 2 : groupColumns && data.children && nonGroupColumns[1].field === column.field ? 0 : 1,
@@ -571,7 +568,23 @@ const InternalTable = props => {
571
568
  'cell-group-fixed': groupColumns && data.children && column.field === firstNonGroupColumn?.field
572
569
  }),
573
570
  // 'data-tooltip-id': "tooltip-cell-content"
574
- 'data-tooltip-id': `${id}-tooltip-cell-content`
571
+ 'data-tooltip-id': `${id}-tooltip-cell-content`,
572
+ "data-tooltip-html": ReactDOMServer.renderToStaticMarkup( /*#__PURE__*/React.createElement(React.Fragment, null, tooltipContent)),
573
+ onMouseEnter: e => {
574
+ if (e.target.firstChild?.clientWidth <= e.target.firstChild?.scrollWidth) {
575
+ if (e.target.firstChild?.clientWidth < e.target.firstChild?.scrollWidth) {
576
+ setIsOpenTooltip(true);
577
+ } else {
578
+ setIsOpenTooltip(false);
579
+ }
580
+ } else {
581
+ if (e.target.clientWidth < e.target.scrollWidth) {
582
+ setIsOpenTooltip(true);
583
+ } else {
584
+ setIsOpenTooltip(false);
585
+ }
586
+ }
587
+ }
575
588
  };
576
589
  },
577
590
  render: (value, record, rowIndex) => {
@@ -593,6 +606,10 @@ const InternalTable = props => {
593
606
  }
594
607
  return /*#__PURE__*/React.createElement("span", null, currentGroupColumn?.headerText, ": ", renderContent(currentGroupColumn, record[record.field], record, rowIndex, colIndex, false, cellFormat));
595
608
  }
609
+ if (groupAble && record.children && column.sumGroup === true && column.type === 'number') {
610
+ const sumValue = sumByField(filterDataByColumns4(record.children, [], []), column?.field);
611
+ return /*#__PURE__*/React.createElement(React.Fragment, null, sumValue);
612
+ }
596
613
  return renderContent(column, value, record, rowIndex, colIndex, false, cellFormat);
597
614
  },
598
615
  // defaultSortOrder: 'ascend',
@@ -914,10 +931,7 @@ const InternalTable = props => {
914
931
  const handleFullScreen = () => {
915
932
  setIsFullScreen(!isFullScreen);
916
933
  };
917
-
918
- // const TableComponent = infiniteScroll ? InfiniteTable : (groupAble ? Group : editAble ? GridEdit : Grid)
919
- const TableComponent = groupAble ? Group : Grid;
920
- return /*#__PURE__*/React.createElement(Fragment, null, true && /*#__PURE__*/React.createElement(DndContext, {
934
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(DndContext, {
921
935
  sensors: sensors,
922
936
  modifiers: [restrictToHorizontalAxis],
923
937
  onDragEnd: onDragEnd,
@@ -928,7 +942,7 @@ const InternalTable = props => {
928
942
  strategy: horizontalListSortingStrategy
929
943
  }, /*#__PURE__*/React.createElement(DragIndexContext.Provider, {
930
944
  value: dragIndex
931
- }, /*#__PURE__*/React.createElement(TableComponent, _extends({}, rest, {
945
+ }, /*#__PURE__*/React.createElement(Group, _extends({}, rest, {
932
946
  t: t,
933
947
  id: id,
934
948
  locale: locale,
@@ -956,34 +970,23 @@ const InternalTable = props => {
956
970
  groupColumns: groupColumns,
957
971
  commandClick: triggerCommandClick,
958
972
  summary: summary,
959
- pagination: pagination
960
- // scroll={{ y: 300 - 41 - 7 }} // scroll height auto, không quá 600
961
- // scroll={{ y: scrollHeight - (summary ? 0 : 7) }} // scroll height auto, không quá 600
962
- ,
963
-
973
+ pagination: pagination,
964
974
  scroll: scrollHeight - (summary ? 1 : 1) < 0 ? {
965
975
  y: 500
966
976
  } : {
967
977
  y: scrollHeight - (summary ? 1 : 1)
968
978
  } // scroll height auto, không quá 600
969
-
970
- // height={isFullScreen ? windowSize.innerHeight - 100 : propsHeight}
971
979
  ,
972
980
  height: propsHeight,
973
- scrollHeight: scrollHeight,
974
- components: {
975
- header: {
976
- cell: ResizableTitle
977
- },
978
- body: {
979
- cell: TableBodyCell
980
- }
981
- },
982
- setTooltipContent: setTooltipContent,
981
+ scrollHeight: scrollHeight
982
+ // components={{
983
+ // header: { cell: ResizableTitle },
984
+ // body: { cell: TableBodyCell }
985
+ // }}
986
+ ,
987
+
983
988
  onFilter: val => {
984
989
  handleOnFilter(val);
985
- // triggerFilter?.(convertFilters(val))
986
- // onFilter?.(convertFilters(val))
987
990
  },
988
991
  setMergedFilterKeys: setMergedFilterKeys,
989
992
  mergedFilterKeys: mergedFilterKeys,
@@ -991,10 +994,6 @@ const InternalTable = props => {
991
994
  onChange: handleChange,
992
995
  handleFullScreen: handleFullScreen,
993
996
  isFullScreen: isFullScreen
994
-
995
- // onChange={(paging, filters, sorter) => {
996
- // handleChange(sorter)
997
- // }}
998
997
  })))), /*#__PURE__*/React.createElement(DragOverlay, {
999
998
  style: {
1000
999
  minWidth: 100,
@@ -1046,7 +1045,7 @@ const InternalTable = props => {
1046
1045
  strategy: horizontalListSortingStrategy
1047
1046
  }, /*#__PURE__*/React.createElement(DragIndexContext.Provider, {
1048
1047
  value: dragIndex
1049
- }, /*#__PURE__*/React.createElement(TableComponent, _extends({}, rest, {
1048
+ }, /*#__PURE__*/React.createElement(Grid, _extends({}, rest, {
1050
1049
  t: t,
1051
1050
  id: faker.string.alpha(20),
1052
1051
  locale: locale,
@@ -1092,8 +1091,10 @@ const InternalTable = props => {
1092
1091
  body: {
1093
1092
  cell: TableBodyCell
1094
1093
  }
1095
- },
1096
- setTooltipContent: setTooltipContent,
1094
+ }
1095
+ // setTooltipContent={setTooltipContent}
1096
+ ,
1097
+
1097
1098
  onFilter: val => {
1098
1099
  handleOnFilter(val);
1099
1100
  // triggerFilter?.(convertFilters(val))
@@ -1130,12 +1131,6 @@ const InternalTable = props => {
1130
1131
  id: `${id}-tooltip-cell-content`,
1131
1132
  style: {
1132
1133
  zIndex: 1999
1133
- },
1134
- render: () => {
1135
- if (tooltipContent) {
1136
- return /*#__PURE__*/React.createElement("span", null, typeof tooltipContent === 'function' ? tooltipContent() : tooltipContent);
1137
- }
1138
- return undefined;
1139
1134
  }
1140
1135
  }));
1141
1136
  };
@@ -62,7 +62,7 @@ const TableGrid = props => {
62
62
  rowHoverable,
63
63
  title,
64
64
  format,
65
- // virtual = true,
65
+ virtualRow = true,
66
66
  t,
67
67
  lang,
68
68
  contextMenuOpen,
@@ -322,14 +322,18 @@ const TableGrid = props => {
322
322
  'table-none-column-select': selectionSettings?.mode === undefined && selectionSettings?.type !== 'multiple'
323
323
  }, styles.customTable),
324
324
  bordered: true,
325
- virtual: true,
325
+ virtual: virtualRow,
326
326
  columns: columns,
327
327
  rowKey: rowKey,
328
328
  rowHoverable: rowHoverable,
329
329
  size: "small",
330
330
  scroll: scroll ? scroll : {
331
331
  y: 500
332
- },
332
+ }
333
+
334
+ // scroll={{ x: 'max-content', y: 700 }}
335
+ ,
336
+
333
337
  onRow: (data, index) => {
334
338
  return {
335
339
  onDoubleClick: handleRowDoubleClick(data, index),
@@ -380,16 +384,6 @@ const TableGrid = props => {
380
384
  , {
381
385
  items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
382
386
  mode: 'scroll'
383
- })), fullScreen !== false && (isFullScreen ? /*#__PURE__*/React.createElement(Minimize, {
384
- fontSize: 16,
385
- onClick: () => handleFullScreen?.(),
386
- "data-tooltip-id": "tooltip-icon",
387
- "data-tooltip-content": t ? t('Minimized') : 'Minimized'
388
- }) : /*#__PURE__*/React.createElement(Maximize, {
389
- fontSize: 16,
390
- onClick: () => handleFullScreen?.(),
391
- "data-tooltip-id": "tooltip-icon",
392
- "data-tooltip-content": t ? t('Full screen') : 'Full screen'
393
387
  })), /*#__PURE__*/React.createElement("div", {
394
388
  style: {
395
389
  display: 'flex',
@@ -405,7 +399,17 @@ const TableGrid = props => {
405
399
  // @ts-ignore
406
400
  ,
407
401
  showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
408
- }, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, showColumnChoose && /*#__PURE__*/React.createElement(ColumnsChoose, {
402
+ }, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, fullScreen !== false && (isFullScreen ? /*#__PURE__*/React.createElement(Minimize, {
403
+ fontSize: 16,
404
+ onClick: () => handleFullScreen?.(),
405
+ "data-tooltip-id": "tooltip-icon",
406
+ "data-tooltip-content": t ? t('Minimized') : 'Minimized'
407
+ }) : /*#__PURE__*/React.createElement(Maximize, {
408
+ fontSize: 16,
409
+ onClick: () => handleFullScreen?.(),
410
+ "data-tooltip-id": "tooltip-icon",
411
+ "data-tooltip-content": t ? t('Full screen') : 'Full screen'
412
+ })), showColumnChoose && /*#__PURE__*/React.createElement(ColumnsChoose, {
409
413
  columns: columns,
410
414
  t: t,
411
415
  columnsGroup: groupColumns,
@@ -8,11 +8,7 @@ const TempTable = props => {
8
8
  editAble,
9
9
  ...rest
10
10
  } = props;
11
-
12
- // const TabComponent = groupAble ? InternalTable : Table
13
11
  const TabComponent = groupAble ? InternalTable : Table;
14
- // const TabComponent = InternalTable
15
-
16
12
  return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(TabComponent, _extends({}, rest, {
17
13
  groupAble: groupAble,
18
14
  editAble: editAble
@@ -160,6 +160,7 @@ export declare const showDraggingPoint: (selectedCells: any, id?: any) => void;
160
160
  export declare const hideDraggingPoint: (selectedCells: any, id?: any) => void;
161
161
  export declare const isRangeCell: (selectedCells: any, type: string, rowIndex: number, colIndex: number) => boolean;
162
162
  export declare const isSelectedCell: (selectedCells: any, rowIndex: number, colIndex: number) => any;
163
+ export declare function groupAndSum(data: any[], columns: any[], groupField?: string): unknown[];
163
164
  export declare function groupArrayByColumns(data: any[], columns: string[] | undefined): any;
164
165
  export declare const isFormattedNumber: (str: string) => boolean;
165
166
  export declare const detectSeparators: (str: string) => {
@@ -2341,6 +2341,29 @@ export const isSelectedCell = (selectedCells, rowIndex, colIndex) => {
2341
2341
  const key = `${rowIndex}-${colIndex}`;
2342
2342
  return selectedCells.has(key);
2343
2343
  };
2344
+ export function groupAndSum(data, columns, groupField = "name") {
2345
+ const sumFields = columns.filter(col => col.sumGroup).map(col => col.field);
2346
+ const groups = {};
2347
+ data.forEach(item => {
2348
+ const key = item[groupField];
2349
+ if (!groups[key]) {
2350
+ groups[key] = {
2351
+ [groupField]: key
2352
+ };
2353
+
2354
+ // khởi tạo các trường sum = 0
2355
+ sumFields.forEach(field => {
2356
+ groups[key][field] = 0;
2357
+ });
2358
+ }
2359
+
2360
+ // cộng dồn các field có sumGroup
2361
+ sumFields.forEach(field => {
2362
+ groups[key][field] += Number(item[field] || 0);
2363
+ });
2364
+ });
2365
+ return Object.values(groups);
2366
+ }
2344
2367
  export function groupArrayByColumns(data, columns) {
2345
2368
  const result = [];
2346
2369
  const checkEmpty = d => {
@@ -2631,7 +2654,8 @@ export const removeInvisibleColumns = columns => {
2631
2654
  };
2632
2655
  export const sumByField = (data, field) => {
2633
2656
  return data.reduce((total, item) => {
2634
- if (item[field] != null) {
2657
+ // if (item[field] != null) {
2658
+ if (typeof item[field] === 'number' && !isNaN(item[field])) {
2635
2659
  return total + item[field];
2636
2660
  } else if (item.children && item.children.length > 0) {
2637
2661
  return total + sumByField(item.children, field);