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.
@@ -249,7 +249,7 @@ const GridEdit = props => {
249
249
  contextMenuItems: propsContext,
250
250
  showDefaultContext,
251
251
  validate,
252
- setTooltipContent,
252
+ // setTooltipContent,
253
253
  onBlur,
254
254
  locale,
255
255
  mergedFilterKeys,
@@ -1908,7 +1908,8 @@ const GridEdit = props => {
1908
1908
  };
1909
1909
  const handleEdit = (record, col, editType, rowIndex, e) => {
1910
1910
  onRemoveBorderSelectedCell(selectedCells.current, id);
1911
- setTooltipContent('');
1911
+
1912
+ // setTooltipContent('')
1912
1913
 
1913
1914
  // @ts-ignore
1914
1915
  // setEditingKey(record[rowKey])
@@ -2377,7 +2378,9 @@ const GridEdit = props => {
2377
2378
  const colFormat = typeof column.format === 'function' ? column.format(record) : column.format;
2378
2379
  const cellFormat = getFormat(colFormat, format);
2379
2380
  const rowError = dataErrors.find(it => it.index === rowNumber);
2380
- const cellError = rowError && column.field && rowError[column.field]?.field === column.field ? rowError[column.field] : null;
2381
+
2382
+ // const cellError = rowError && column.field && rowError[column.field]?.field === column.field ? rowError[column.field] : null
2383
+
2381
2384
  const handleClick = event => {
2382
2385
  if (!(record[rowKey] === editingKey.current) && record[rowKey] !== editingKey.current && isEditable(column, record)) {
2383
2386
  handleEdit(record, column, getEditType(column, record), rowNumber, event);
@@ -2393,7 +2396,8 @@ const GridEdit = props => {
2393
2396
  }),
2394
2397
  onMouseDown: event => handleMouseDown(record, rowNumber, colIndex, event),
2395
2398
  onMouseEnter: event => {
2396
- setTooltipContent(cellError ? cellError.message : '');
2399
+ // setTooltipContent(cellError ? cellError.message : '')
2400
+
2397
2401
  handleMouseEnter(rowNumber, colIndex, event);
2398
2402
 
2399
2403
  // hoveredRow.current = rowNumber
@@ -6,6 +6,7 @@ import { findAllChildrenKeys } from "../hooks";
6
6
  import { ColumnsGroup } from "../ColumnsGroup/ColumnsGroup";
7
7
  import { flatColumns2 } from "../hooks/columns";
8
8
  import { Collapse2, Expand2 } from "becoxy-icons";
9
+ import { ConfigProvider } from 'rc-master-ui';
9
10
  const Group = props => {
10
11
  const {
11
12
  t,
@@ -42,11 +43,12 @@ const Group = props => {
42
43
  return [];
43
44
  });
44
45
  React.useEffect(() => {
45
- if (defaultExpandedRowKeys) {
46
- setInnerExpandedKeys(defaultExpandedRowKeys);
47
- }
48
46
  if (defaultExpandAllRows) {
49
47
  setInnerExpandedKeys(findAllChildrenKeys(dataSource, getRowKey, childrenColumnName) ?? []);
48
+ } else {
49
+ if (defaultExpandedRowKeys) {
50
+ setInnerExpandedKeys(defaultExpandedRowKeys);
51
+ }
50
52
  }
51
53
  }, [defaultExpandedRowKeys, defaultExpandAllRows, dataSource]);
52
54
  const mergedExpandedKeys = React.useMemo(() => new Set(innerExpandedKeys || []), [innerExpandedKeys]);
@@ -96,11 +98,11 @@ const Group = props => {
96
98
  columnsGrouped: groupColumns,
97
99
  onSubmit: handleOnGroup
98
100
  }), /*#__PURE__*/React.createElement(Fragment, null, innerExpandedKeys.length > 0 ? /*#__PURE__*/React.createElement(Collapse2, {
99
- fontSize: 18,
101
+ fontSize: 16,
100
102
  color: '#555555',
101
103
  onClick: handleCollapseAllGroup
102
104
  }) : /*#__PURE__*/React.createElement(Expand2, {
103
- fontSize: 18,
105
+ fontSize: 16,
104
106
  color: '#555555',
105
107
  onClick: handleExpandAllGroup
106
108
  })));
@@ -113,6 +115,20 @@ const Group = props => {
113
115
  position: 'relative'
114
116
  },
115
117
  id: id
118
+ }, /*#__PURE__*/React.createElement(ConfigProvider, {
119
+ theme: {
120
+ components: {
121
+ Table: {
122
+ rowHoverBg: '#eb461912',
123
+ rowSelectedBg: '#eb4619',
124
+ rowSelectedHoverBg: '#eb4619',
125
+ cellFontSize: 12,
126
+ cellFontSizeSM: 13,
127
+ headerBg: '#ffffff',
128
+ cellPaddingBlockSM: 7
129
+ }
130
+ }
131
+ }
116
132
  }, /*#__PURE__*/React.createElement(TableGrid, _extends({}, rest, {
117
133
  t: t,
118
134
  id: id,
@@ -174,6 +190,6 @@ const Group = props => {
174
190
  groupToolbar: groupToolbar,
175
191
  groupColumns: groupColumns,
176
192
  isFullScreen: isFullScreen
177
- }))));
193
+ })))));
178
194
  };
179
195
  export default Group;
@@ -92,7 +92,7 @@ const InfiniteTable = props => {
92
92
  id: id,
93
93
  dataSource: dataSource,
94
94
  pagination: false,
95
- virtual: true,
95
+ virtualRow: true,
96
96
  onScroll: handleScroll,
97
97
  loading: loading,
98
98
  isFullScreen: isFullScreen
@@ -118,7 +118,10 @@ export type ColumnTable<RecordType = AnyObject> = Omit<RcColumnType<RecordType>,
118
118
  headerTextAlign?: ITextAlign;
119
119
  template?: ReactNode | ReactElement | ((args: ColumnTemplate<RecordType>) => ReactNode | ReactElement);
120
120
  showTooltip?: boolean;
121
- tooltipDescription?: ReactNode | ReactElement | ((value: any, record: RecordType, index: number) => ReactNode | ReactElement);
121
+ tooltipDescription?: ReactNode | ReactElement | ((args: {
122
+ value: any;
123
+ record: RecordType;
124
+ }) => ReactNode | ReactElement);
122
125
  headerTemplate?: React.ReactNode | React.ReactElement | ((column: ColumnTable<RecordType>) => React.ReactNode | React.ReactElement);
123
126
  commandItems?: CommandItem[];
124
127
  children?: ColumnTable<RecordType>[];
@@ -136,6 +139,7 @@ export type ColumnTable<RecordType = AnyObject> = Omit<RcColumnType<RecordType>,
136
139
  editFromSettings?: IEditFromSettings;
137
140
  fixedType?: FixedType;
138
141
  headerTextWrap?: boolean;
142
+ sumGroup?: boolean;
139
143
  allowSelection?: boolean | ((rowData: RecordType) => boolean);
140
144
  onCellStyles?: Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'> | ((cellValue: any, cell: Cell<RecordType, unknown>) => Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'>);
141
145
  onCellHeaderStyles?: Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'> | ((cell: Header<RecordType, unknown>) => Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'>);
@@ -195,7 +199,7 @@ export type Sort = {
195
199
  field: string;
196
200
  order: 'ascend' | 'descend' | null;
197
201
  };
198
- export interface TableProps<RecordType = AnyObject> extends Omit<RcTableProps<RecordType>, 'columns' | 'rowSelection' | 'loading' | 'dataSource' | 'summary' | 'pagination' | 'locale'> {
202
+ export interface TableProps<RecordType = AnyObject> extends Omit<RcTableProps<RecordType>, 'columns' | 'rowSelection' | 'loading' | 'dataSource' | 'summary' | 'pagination' | 'locale' | 'virtual'> {
199
203
  editAble?: boolean;
200
204
  infiniteScroll?: boolean;
201
205
  theme?: {
@@ -203,6 +207,8 @@ export interface TableProps<RecordType = AnyObject> extends Omit<RcTableProps<Re
203
207
  backgroundColor?: string;
204
208
  color?: string;
205
209
  };
210
+ virtualRow?: boolean;
211
+ virtualColumns?: boolean;
206
212
  next?: () => void;
207
213
  locale?: Locale;
208
214
  groupAble?: boolean;
@@ -65,33 +65,6 @@ const TableBody = ({
65
65
  })))) : /*#__PURE__*/React.createElement(Fragment, null, virtualRows.map(virtualRow => {
66
66
  const row = rows[virtualRow.index];
67
67
  const isEditing = row.id === editingKey;
68
-
69
- // return (
70
- // <tr key={row.id}>
71
- // {row.getVisibleCells().map((cell) => (
72
- // <td
73
- // key={cell.id}
74
- // style={{
75
- // padding: '12px',
76
- // whiteSpace: 'nowrap',
77
- // fontSize: '0.875rem',
78
- // color: '#6b7280',
79
- // border: '1px solid #e5e7eb',
80
- // width: cell.column.getSize(),
81
- // maxWidth: cell.column.getSize(),
82
- // overflow: "hidden",
83
- // ...getCommonPinningStyles(cell.column)
84
- // }}>
85
-
86
- // {cell.column.id}
87
-
88
- // {/* {flexRender(cell.column.columnDef.cell, cell.getContext())} */}
89
-
90
- // </td>
91
- // ))}
92
- // </tr>
93
- // )
94
-
95
68
  return /*#__PURE__*/React.createElement(TableBodyRow, _extends({}, rest, {
96
69
  table: table,
97
70
  tableId: tableId,
@@ -208,7 +208,7 @@ export const toggleRowSelection = props => {
208
208
  isChange: true,
209
209
  type: 'rowSelected',
210
210
  rowData: row.original,
211
- rowsData: checkedRows
211
+ rowsData: selectionSettings?.type === 'single' ? [row] : checkedRows
212
212
  });
213
213
  }
214
214
  return;
@@ -284,8 +284,11 @@ export const toggleRowSelection = props => {
284
284
  } else {
285
285
  // chỉ thêm vào row hiện tại
286
286
 
287
- const isInclude = prevSelected.find(it => it.id === cell.row.id);
288
- if (isInclude) {
287
+ const isInclude = prevSelected.findIndex(it => it.id === cell.row.id);
288
+ if (isInclude > -1) {
289
+ // cập nhật data row hiện tại
290
+
291
+ prevSelected[isInclude] = row;
289
292
  checkedRows = [...prevSelected];
290
293
  } else {
291
294
  checkedRows = [...prevSelected, row];
@@ -8,331 +8,12 @@ exports.ColumnsChoose = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  var _styledComponents = _interopRequireDefault(require("styled-components"));
10
10
  var _antd = require("antd");
11
- var _icons = require("@ant-design/icons");
11
+ var _becoxyIcons = require("becoxy-icons");
12
12
  var _hooks = require("./hooks");
13
13
  var _tree = _interopRequireDefault(require("rc-master-ui/es/tree"));
14
14
  var _SearchOutlined = _interopRequireDefault(require("@ant-design/icons/SearchOutlined"));
15
15
  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); }
16
16
  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; }
17
- // import React, {Fragment, useMemo, useState} from "react"
18
- //
19
- // import styled from "styled-components"
20
- // import {Button, Input, Popover, Tooltip} from "antd";
21
- // import {SettingOutlined} from "@ant-design/icons";
22
- // import {
23
- // getVisibleColumnKeys,
24
- // updateColumns
25
- // } from "./hooks";
26
- //
27
- // // import type {TableColumnsType} from "rc-master-ui";
28
- // import Tree from "rc-master-ui/es/tree";
29
- // import SearchOutlined from "@ant-design/icons/SearchOutlined";
30
- // import type {ColumnsTable} from "./type";
31
- // import useMergedState from "rc-util/lib/hooks/useMergedState";
32
- //
33
- //
34
- // const BoxAction = styled.div`
35
- // border-top: 1px solid #c4c4c4;
36
- // padding-top: .75rem;
37
- // display: flex;
38
- // justify-content: end;
39
- // gap: 10px;
40
- //
41
- // .btn-action {
42
- // background: none !important;
43
- // border: none !important;
44
- // &.btn-action-submit {
45
- // color: #df4318;
46
- // &:disabled {
47
- // background-color: #f0f0f0 !important;
48
- // }
49
- // &:hover {
50
- // color: #df4318 !important;
51
- // }
52
- // }
53
- //
54
- // &:hover {
55
- // background-color: #f0f0f0 !important;
56
- // }
57
- // }
58
- // `
59
- //
60
- // export type IColumnsChoose<RecordType> = {
61
- // columns: ColumnsTable<RecordType>
62
- // columnsGroup?: string[]
63
- // triggerChangeColumns?: (columns: ColumnsTable<RecordType>, type: string) => void
64
- // t?: any
65
- //
66
- // }
67
- //
68
- //
69
- // export const ColumnsChoose = <RecordType extends object>(props: IColumnsChoose<RecordType>) => {
70
- // const {
71
- // columns: propsColumns,
72
- // triggerChangeColumns,
73
- // t,
74
- // columnsGroup,
75
- // } = props
76
- //
77
- // // const dataList: { key: React.Key; title: string }[] = [];
78
- //
79
- // // const defaultColumns = useMemo(() => {
80
- // // return propsColumns.filter((it) => it.key || it.dataIndex && it.showColumnChoose !== false)
81
- // // }, [propsColumns])
82
- //
83
- //
84
- // // const columnsChooseRef: any = useRef()
85
- // // const searchRef: any = useRef()
86
- //
87
- //
88
- //
89
- // // const [columns, setColumns] = useState<TableColumnsType>([])
90
- //
91
- // // const [selectedKeys, setSelectedKeys] = useState<string[]>([]);
92
- //
93
- // // const [isManualUpdate, setIsManualUpdate] = useState(false);
94
- //
95
- //
96
- // // useEffect(() => {
97
- // //
98
- // // const defaultColumns = propsColumns.filter((it) => it.key || it.dataIndex && it.showInColumnChoose !== false)
99
- // // setColumns(defaultColumns as TableColumnsType)
100
- // //
101
- // // }, [propsColumns])
102
- //
103
- // const columns = useMemo(() => {
104
- //
105
- // // return propsColumns.filter((it) => (it.key || it.dataIndex) && it.showInColumnChoose !== false && !columnsGroup?.includes(it.field as string))
106
- // return propsColumns.filter((it) => (it.key || it.dataIndex) && it.showInColumnChoose !== false)
107
- // // setColumns(defaultColumns as TableColumnsType)
108
- // }, [columnsGroup, propsColumns])
109
- //
110
- //
111
- // // useEffect(() => {
112
- // //
113
- // // const defaultColumns = propsColumns.filter((it) => it.key || it.dataIndex && it.showInColumnChoose !== false)
114
- // //
115
- // // const defaultSelectedKeys = getVisibleColumnKeys(defaultColumns)
116
- // //
117
- // // if (!isManualUpdate) {
118
- // // setSelectedKeys(defaultSelectedKeys)
119
- // // }
120
- // // setIsManualUpdate(false);
121
- // //
122
- // //
123
- // // }, [isManualUpdate, propsColumns])
124
- //
125
- // const defaultSelectedKeys = React.useMemo(() => {
126
- //
127
- // const rs = propsColumns.filter((it) => (it.key || it.dataIndex) && it.showInColumnChoose !== false && !columnsGroup?.includes(it.field as string))
128
- // return getVisibleColumnKeys(rs)
129
- //
130
- // }, [columnsGroup, propsColumns])
131
- //
132
- // const [mergedSelectedKeys, setMergedSelectedKeys] = useMergedState(
133
- // defaultSelectedKeys || [],
134
- // {
135
- // value: defaultSelectedKeys,
136
- // },
137
- // );
138
- //
139
- // //
140
- // // const defaultSelectedKeys = useMemo(() => {
141
- // //
142
- // // return getVisibleColumnKeys(propsColumns)
143
- // //
144
- // // }, [propsColumns])
145
- //
146
- //
147
- // const [clicked, setClicked] = useState(false);
148
- // const [autoExpandParent, setAutoExpandParent] = useState(true);
149
- //
150
- //
151
- // // const treeData = useMemo(() => {
152
- // // const loop = (data: TreeDataNode[]): TreeDataNode[] =>
153
- // // data.map((item) => {
154
- // // const strTitle = item.title as string;
155
- // // const index = strTitle.indexOf(searchValue);
156
- // // const beforeStr = strTitle.substring(0, index);
157
- // // const afterStr = strTitle.slice(index + searchValue.length);
158
- // // const title =
159
- // // index > -1 ? (
160
- // // <span key={item.key}>
161
- // // {beforeStr}
162
- // // <span className="site-tree-search-value">{searchValue}</span>
163
- // // {afterStr}
164
- // // </span>
165
- // // ) : (
166
- // // <span key={item.key}>{strTitle}</span>
167
- // // );
168
- // // if (item.children) {
169
- // // return { title, key: item.key, children: loop(item.children) };
170
- // // }
171
- // //
172
- // // return {
173
- // // title,
174
- // // key: item.key,
175
- // // };
176
- // // });
177
- // //
178
- // // // return loop(defaultData);
179
- // // return loop(columns as any);
180
- // // }, [searchValue, columns]);
181
- //
182
- //
183
- // const hide = () => {
184
- // setClicked(false)
185
- // }
186
- //
187
- // const handleClickChange = (open: boolean) => {
188
- // setClicked(open)
189
- // }
190
- //
191
- // const onExpand = () => {
192
- // // setExpandedKeys(newExpandedKeys)
193
- // setAutoExpandParent(false)
194
- // }
195
- //
196
- // // const getParentKey = (key: React.Key, tree: TreeDataNode[]): React.Key => {
197
- // // let parentKey: React.Key
198
- // // for (let i = 0; i < tree.length; i++) {
199
- // // const node = tree[i]
200
- // // if (node.children) {
201
- // // if (node.children.some((item) => item.key === key)) {
202
- // // parentKey = node.key
203
- // // } else if (getParentKey(key, node.children)) {
204
- // // parentKey = getParentKey(key, node.children)
205
- // // }
206
- // // }
207
- // // }
208
- // // return parentKey!
209
- // // }
210
- //
211
- // // const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
212
- // const onChange = () => {
213
- // // const { value } = e.target
214
- // // const newExpandedKeys = dataList
215
- // // .map((item) => {
216
- // // if (item.title.indexOf(value) > -1) {
217
- // // return getParentKey(item.key, defaultData)
218
- // // }
219
- // // return null
220
- // // })
221
- // // .filter((item, i, self): item is React.Key => !!(item && self.indexOf(item) === i))
222
- // // setExpandedKeys(newExpandedKeys)
223
- //
224
- // // setSearchValue(value)
225
- // setAutoExpandParent(true)
226
- // };
227
- //
228
- // const onCheck = (keys: string[]) => {
229
- //
230
- // // setSelectedKeys(keys)
231
- // setMergedSelectedKeys(keys)
232
- // // setIsManualUpdate(true)
233
- //
234
- // }
235
- //
236
- // const handleAccept = () => {
237
- //
238
- //
239
- // // const rs1 = updateColumns(propsColumns, selectedKeys)
240
- // const rs1 = updateColumns(propsColumns, mergedSelectedKeys)
241
- //
242
- //
243
- // triggerChangeColumns?.(rs1, 'columnChoose')
244
- //
245
- // hide()
246
- //
247
- // }
248
- //
249
- // const handleCancel = () => {
250
- // // setSelectedKeys(defaultSelectedKeys)
251
- // hide()
252
- // }
253
- //
254
- //
255
- // return (
256
- // <Fragment>
257
- // <Popover
258
- // placement={'bottomLeft'}
259
- // content={
260
- // <div style={{minWidth: 250}}>
261
- // <Input style={{ marginBottom: 8 }} placeholder={t ? t("Search") : 'Search'} prefix={<SearchOutlined />} onChange={onChange} />
262
- //
263
- // <Tree
264
- // onExpand={onExpand}
265
- // // expandedKeys={expandedKeys}
266
- // autoExpandParent={autoExpandParent}
267
- // // treeData={treeData}
268
- // treeData={columns}
269
- // defaultExpandAll={true}
270
- // checkable={true}
271
- // // onSelect={(keys, info) => {
272
- // // const key = info.node.key
273
- // //
274
- // // const find = findItemByKey(columns, 'key', key)
275
- // //
276
- // // // const tmpColumn
277
- // //
278
- // // // if (selectedKeys.includes(key as string)) {
279
- // // // const rssss = findKeyPath(columns, key as string)
280
- // // // const rs = selectedKeys.filter(item => !rssss.includes(item));
281
- // // //
282
- // // // setSelectedKeys(rs)
283
- // // // } else {
284
- // //
285
- // // // const rs = [...selectedKeys, keys[0]]
286
- // //
287
- // // // setSelectedKeys(keys)
288
- // // // }
289
- // // }}
290
- // onCheck={(keys) => onCheck(keys as string[])}
291
- //
292
- //
293
- // multiple={true}
294
- // // checkedKeys={selectedKeys}
295
- //
296
- // defaultCheckedKeys={mergedSelectedKeys}
297
- // // defaultCheckedKeys={defaultSelectedKeys}
298
- // // selectedKeys={[]}
299
- //
300
- // height={window.innerHeight - 200}
301
- //
302
- // />
303
- //
304
- //
305
- // <BoxAction className={'px-1'}>
306
- // <Button
307
- // // className={classnames('btn-action btn-action-submit', {
308
- // // // disable: !columns.find((item) => item.visible !== false || item.visible)
309
- // // })}
310
- // onClick={handleAccept}
311
- // // disabled={!columns.find((item) => item.visible !== false || item.visible)}
312
- // >
313
- // {t ? t('OK') : 'OK'}
314
- // {/*{'OK'}*/}
315
- // </Button>
316
- //
317
- // {/*<Button className={'btn-action btn-action-cancel'} onClick={hide} >{('Cancel') }</Button>*/}
318
- // <Button className={'btn-action btn-action-cancel'} onClick={handleCancel} >{t ? t('Cancel') : 'Cancel' }</Button>
319
- // </BoxAction>
320
- // </div>
321
- // }
322
- // trigger="click"
323
- // open={clicked}
324
- // onOpenChange={handleClickChange}
325
- // arrow={false}
326
- // >
327
- // <Tooltip arrow={false} title={'Cài đặt'} >
328
- // <SettingOutlined size={16} color={'#555555'} style={{fontSize: 16, color: '#555555'}} />
329
- // </Tooltip>
330
- //
331
- // </Popover>
332
- // </Fragment>
333
- // )
334
- // }
335
-
336
17
  // import type {TableColumnsType} from "rc-master-ui";
337
18
 
338
19
  const BoxAction = _styledComponents.default.div.withConfig({
@@ -552,6 +233,8 @@ const ColumnsChoose = props => {
552
233
  }, /*#__PURE__*/_react.default.createElement(_antd.Tooltip, {
553
234
  arrow: false,
554
235
  title: 'Cài đặt'
555
- }, /*#__PURE__*/_react.default.createElement(_icons.SettingOutlined, null))));
236
+ }, /*#__PURE__*/_react.default.createElement(_becoxyIcons.Settings, {
237
+ fontSize: 16
238
+ }))));
556
239
  };
557
240
  exports.ColumnsChoose = ColumnsChoose;