es-grid-template 0.0.13 → 0.1.1

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 (52) hide show
  1. package/CHANGELOG.md +6 -6
  2. package/README.md +1 -1
  3. package/es/grid-component/ColumnsChoose.d.ts +3 -4
  4. package/es/grid-component/ColumnsChoose.js +3 -7
  5. package/es/grid-component/Command.d.ts +8 -0
  6. package/es/grid-component/Command.js +80 -0
  7. package/es/grid-component/EditableCell.js +56 -87
  8. package/es/grid-component/InternalTable.d.ts +1 -0
  9. package/es/grid-component/InternalTable.js +36 -19
  10. package/es/grid-component/TableGrid.d.ts +2 -1
  11. package/es/grid-component/TableGrid.js +63 -18
  12. package/es/grid-component/index.d.ts +2 -0
  13. package/es/{table-grid → grid-component}/styles.scss +204 -195
  14. package/es/grid-component/table/Grid.js +85 -0
  15. package/{lib/grid-component/rc-table → es/grid-component/table}/GridEdit.d.ts +4 -0
  16. package/es/grid-component/{rc-table → table}/GridEdit.js +98 -15
  17. package/es/grid-component/type.d.ts +26 -11
  18. package/es/grid-component/useContext.d.ts +10 -7
  19. package/es/grid-component/useContext.js +3 -0
  20. package/es/index.d.ts +2 -1
  21. package/es/index.js +1 -2
  22. package/lib/grid-component/ColumnsChoose.d.ts +3 -4
  23. package/lib/grid-component/ColumnsChoose.js +3 -7
  24. package/lib/grid-component/Command.d.ts +8 -0
  25. package/lib/grid-component/Command.js +88 -0
  26. package/lib/grid-component/EditableCell.js +56 -87
  27. package/lib/grid-component/InternalTable.d.ts +1 -0
  28. package/lib/grid-component/InternalTable.js +35 -18
  29. package/lib/grid-component/TableGrid.d.ts +2 -1
  30. package/lib/grid-component/TableGrid.js +62 -17
  31. package/lib/grid-component/index.d.ts +2 -0
  32. package/lib/{table-grid → grid-component}/styles.scss +204 -195
  33. package/lib/grid-component/{rc-table → table}/Grid.js +42 -56
  34. package/{es/grid-component/rc-table → lib/grid-component/table}/GridEdit.d.ts +4 -0
  35. package/lib/grid-component/{rc-table → table}/GridEdit.js +98 -15
  36. package/lib/grid-component/type.d.ts +26 -11
  37. package/lib/grid-component/useContext.d.ts +10 -7
  38. package/lib/grid-component/useContext.js +2 -0
  39. package/lib/index.d.ts +2 -1
  40. package/lib/index.js +1 -1
  41. package/package.json +113 -86
  42. package/es/grid-component/rc-table/Grid.js +0 -99
  43. /package/es/{grid-component/Message → Message}/Message.d.ts +0 -0
  44. /package/es/{grid-component/Message → Message}/Message.js +0 -0
  45. /package/es/{grid-component/Message → Message}/index.d.ts +0 -0
  46. /package/es/{grid-component/Message → Message}/index.js +0 -0
  47. /package/es/grid-component/{rc-table → table}/Grid.d.ts +0 -0
  48. /package/lib/{grid-component/Message → Message}/Message.d.ts +0 -0
  49. /package/lib/{grid-component/Message → Message}/Message.js +0 -0
  50. /package/lib/{grid-component/Message → Message}/index.d.ts +0 -0
  51. /package/lib/{grid-component/Message → Message}/index.js +0 -0
  52. /package/lib/grid-component/{rc-table → table}/Grid.d.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
- # Changelog
2
-
3
-
4
- ## 0.0.1 / 20-02-2025
5
-
6
- add package
1
+ # Changelog
2
+
3
+
4
+ ## 0.0.1 / 20-02-2025
5
+
6
+ add package
package/README.md CHANGED
@@ -1 +1 @@
1
- # es-grid-template
1
+ # es-grid-template
@@ -1,9 +1,8 @@
1
- import type { Dispatch, SetStateAction } from "react";
2
1
  import React from "react";
3
- import type { ColumnsType } from "./type";
2
+ import type { ColumnsTable } from "./type";
4
3
  export type IColumnsChoose<RecordType> = {
5
- columns: any[];
6
- setColumns: Dispatch<SetStateAction<ColumnsType<RecordType>>>;
4
+ columns: ColumnsTable<RecordType>;
5
+ triggerChangeColumns?: (columns: ColumnsTable<RecordType>) => void;
7
6
  t?: any;
8
7
  };
9
8
  export declare const ColumnsChoose: <RecordType extends object>(props: IColumnsChoose<RecordType>) => React.JSX.Element;
@@ -1,14 +1,10 @@
1
1
  import React, { Fragment, useEffect, useMemo, useState } from "react";
2
2
  import styled from "styled-components";
3
- // import type { TreeDataNode} from "antd";
4
3
  import { Button, Input, Popover, Tooltip } from "antd";
5
4
  import { SettingOutlined } from "@ant-design/icons";
6
5
  import { getVisibleColumnKeys, updateColumns } from "./hooks";
7
6
  import Tree from "rc-master-ui/es/tree";
8
7
  import SearchOutlined from "@ant-design/icons/SearchOutlined";
9
-
10
- // const { Search } = Input;
11
-
12
8
  const BoxAction = styled.div.withConfig({
13
9
  displayName: "BoxAction",
14
10
  componentId: "es-grid-template__sc-1ix8yky-0"
@@ -16,7 +12,7 @@ const BoxAction = styled.div.withConfig({
16
12
  export const ColumnsChoose = props => {
17
13
  const {
18
14
  columns: propsColumns,
19
- setColumns: changeHiddenColumn
15
+ triggerChangeColumns
20
16
  // t,
21
17
  } = props;
22
18
 
@@ -32,7 +28,7 @@ export const ColumnsChoose = props => {
32
28
  const [columns, setColumns] = useState([]);
33
29
  const [selectedKeys, setSelectedKeys] = useState([]);
34
30
  useEffect(() => {
35
- const defaultColumns = propsColumns.filter(it => it.key || it.dataIndex && it.showColumnChoose !== false);
31
+ const defaultColumns = propsColumns.filter(it => it.key || it.dataIndex && it.showInColumnChoose !== false);
36
32
  const defaultSelectedKeys = getVisibleColumnKeys(propsColumns);
37
33
  setSelectedKeys(defaultSelectedKeys);
38
34
  setColumns(defaultColumns);
@@ -126,7 +122,7 @@ export const ColumnsChoose = props => {
126
122
  };
127
123
  const handleAccept = () => {
128
124
  const rs1 = updateColumns(propsColumns, selectedKeys);
129
- changeHiddenColumn(rs1);
125
+ triggerChangeColumns?.(rs1);
130
126
  hide();
131
127
  };
132
128
  const handleCancel = () => {
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import type { CommandItem } from "./type";
3
+ type Props = {
4
+ item: CommandItem;
5
+ onClick: (e: any) => void;
6
+ };
7
+ declare const Command: (props: Props) => React.JSX.Element;
8
+ export default Command;
@@ -0,0 +1,80 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import React, { Fragment, useState } from "react";
3
+ // import {getTemplate} from "../../hooks"
4
+ import classnames from "classnames";
5
+ import { useFloating, autoUpdate, offset, flip, shift, useHover, useFocus, useDismiss, useRole, useInteractions, FloatingPortal
6
+ // useClick
7
+ } from "@floating-ui/react";
8
+ import { Button } from "antd";
9
+ import styled from "styled-components";
10
+ import { getTemplate } from "./hooks";
11
+ const TooltipStyle = styled.div.withConfig({
12
+ displayName: "TooltipStyle",
13
+ componentId: "es-grid-template__sc-1iotu11-0"
14
+ })(["width:max-content;background-color:#444;color:white;font-size:90%;padding:4px 8px;border-radius:4px;opacity:0.9;z-index:9999;max-width:450px;"]);
15
+ const Command = props => {
16
+ const {
17
+ item,
18
+ onClick
19
+ } = props;
20
+ const [isOpen, setIsOpen] = useState(false);
21
+ const {
22
+ refs,
23
+ floatingStyles,
24
+ context
25
+ } = useFloating({
26
+ open: isOpen,
27
+ onOpenChange: setIsOpen,
28
+ placement: "top",
29
+ whileElementsMounted: autoUpdate,
30
+ middleware: [offset(5), flip({
31
+ fallbackAxisSideDirection: "start"
32
+ }), shift()]
33
+ });
34
+ const hover = useHover(context, {
35
+ move: false
36
+ });
37
+ const focus = useFocus(context);
38
+ const dismiss = useDismiss(context);
39
+ const role = useRole(context, {
40
+ role: "tooltip"
41
+ });
42
+ const {
43
+ getReferenceProps,
44
+ getFloatingProps
45
+ } = useInteractions([hover, focus, dismiss, role]);
46
+ return /*#__PURE__*/React.createElement(Fragment, null, item.template ? /*#__PURE__*/React.createElement("div", _extends({
47
+ ref: refs.setReference
48
+ }, getReferenceProps(), {
49
+ id: item.id,
50
+ onClick: onClick
51
+ }), getTemplate(item.template)) : /*#__PURE__*/React.createElement("div", _extends({
52
+ ref: refs.setReference
53
+ }, getReferenceProps()), /*#__PURE__*/React.createElement(Button, {
54
+ id: 'tooltip',
55
+ tabIndex: -1,
56
+ style: {
57
+ padding: '3px',
58
+ maxWidth: 45,
59
+ height: '100%'
60
+ },
61
+ className: classnames('command-item', {
62
+ 'btn-icon': item.title === ''
63
+ }),
64
+ color: item.color ? item.color : 'primary',
65
+ onClick: onClick
66
+ }, item.icon ? getTemplate(item.icon) : item.title))
67
+
68
+ // <span>{item.title}</span>
69
+ , isOpen && item.tooltip && /*#__PURE__*/React.createElement(FloatingPortal, {
70
+ root: document.body
71
+ }, /*#__PURE__*/React.createElement(TooltipStyle, _extends({
72
+ className: "Tooltip",
73
+ ref: refs.setFloating,
74
+ style: {
75
+ ...floatingStyles,
76
+ zIndex: 99
77
+ }
78
+ }, getFloatingProps()), item.tooltip)));
79
+ };
80
+ export default Command;
@@ -52,7 +52,8 @@ const EditableCell = props => {
52
52
  format,
53
53
  control,
54
54
  getValues,
55
- handleCellChange
55
+ handleCellChange,
56
+ getRowKey
56
57
  } = useContext(TableContext);
57
58
  const datePickerRef = React.useRef(null);
58
59
  const dateTimePickerRef = React.useRef(null);
@@ -70,38 +71,33 @@ const EditableCell = props => {
70
71
  const minDate = convertDateToDayjs(column.minDate, dateFormat) ?? undefined;
71
72
  switch (editType) {
72
73
  case 'date':
73
- return /*#__PURE__*/React.createElement(DatePicker
74
- // id={`col${indexCol}-record${indexRow}`}
75
- , {
74
+ return /*#__PURE__*/React.createElement(DatePicker, {
76
75
  ref: datePickerRef,
77
76
  format: {
78
77
  format: dateFormat,
79
78
  type: 'mask'
80
79
  }
81
-
82
80
  // locale={buddhistLocale}
83
81
  ,
84
82
  style: {
85
83
  width: '100%',
86
84
  height: '100%'
87
85
  },
88
- value: date
89
- // defaultValue={date}
90
- ,
91
-
86
+ value: date,
92
87
  onBlur: () => {
93
88
  const formState = getValues();
94
89
  const itemState = getValues(dataIndex);
95
90
  // @ts-ignore
96
91
  const prevState = record[dataIndex];
97
92
  const newState = itemState;
93
+ const key = getRowKey?.(record, index);
98
94
  if (newState !== prevState) {
99
- // @ts-ignore
100
95
  handleCellChange?.({
101
- key: record[rowKey],
96
+ key: key,
102
97
  record: formState,
103
98
  prevState,
104
99
  newState,
100
+ option: newState,
105
101
  type: 'blur'
106
102
  });
107
103
  }
@@ -158,6 +154,7 @@ const EditableCell = props => {
158
154
  minDate: minDate,
159
155
  onChange: (newDate, dateString) => {
160
156
  const newDateValue = dateString ? moment(convertDayjsToDate(dateString, dateFormat)).format() : null;
157
+ // console.log('newDateValue', newDateValue)
161
158
  onChange(newDateValue);
162
159
  setTimeout(() => {
163
160
  // @ts-ignore
@@ -170,13 +167,14 @@ const EditableCell = props => {
170
167
  // @ts-ignore
171
168
  const prevState = record[dataIndex];
172
169
  const newState = itemState;
170
+ const key = getRowKey?.(record, index);
173
171
  if (prevState !== newState) {
174
- // @ts-ignore
175
172
  handleCellChange?.({
176
- key: record[rowKey],
173
+ key: key,
177
174
  record: formState,
178
175
  prevState,
179
176
  newState,
177
+ option: newState,
180
178
  type: 'blur'
181
179
  });
182
180
  }
@@ -187,8 +185,6 @@ const EditableCell = props => {
187
185
  case 'quarter':
188
186
  case 'year':
189
187
  const pickerFormat = getDatepickerFormat(editType, column);
190
- // @ts-ignore
191
- // const dateValue = !isEmpty(record[column.dataIndex]) ? dayjs(record[column.key], pickerFormat) : null
192
188
  const maxDateValue1 = !isEmpty(column.maxDate) ? dayjs(column.maxDate, pickerFormat) : undefined;
193
189
  const minDateValue1 = !isEmpty(column.minDate) ? dayjs(column.minDate, pickerFormat) : undefined;
194
190
  return /*#__PURE__*/React.createElement(DatePicker, {
@@ -200,28 +196,16 @@ const EditableCell = props => {
200
196
  style: {
201
197
  width: '100%',
202
198
  height: '100%'
203
- }
204
- // defaultValue={dateValue}
205
- ,
199
+ },
206
200
  picker: editType,
207
201
  placeholder: column.placeholder,
208
202
  disabled: isDisable(column, record) ?? false,
209
203
  maxDate: maxDateValue1,
210
- minDate: minDateValue1
211
- // onChange={(dValue, dateString) => {
212
- // const newDateValue = dateString ? dateString : null
213
- //
214
- // // record[column.dataIndex] = newDateValue
215
- // // handleCellChange(newDateValue, newDateValue, record, col, indexRow, indexCol)
216
- // }}
217
- ,
204
+ minDate: minDateValue1,
218
205
  popupClassName: 'be-popup-container'
219
206
  });
220
207
  case 'week':
221
208
  const weekFormat = getDatepickerFormat(editType, column);
222
-
223
- // @ts-ignore
224
- // const weekValue = !isEmpty(record[column.dataIndex]) ? dayjs(record[column.dataIndex], weekFormat) : null
225
209
  const maxWeekValue = !isEmpty(column.maxDate) ? dayjs(column.maxDate, weekFormat) : undefined;
226
210
  const minWeekValue = !isEmpty(column.minDate) ? dayjs(column.minDate, weekFormat) : undefined;
227
211
  return /*#__PURE__*/React.createElement(DatePicker, {
@@ -229,21 +213,12 @@ const EditableCell = props => {
229
213
  style: {
230
214
  width: '100%',
231
215
  height: '100%'
232
- }
233
- // defaultValue={weekValue}
234
- ,
216
+ },
235
217
  picker: editType,
236
218
  placeholder: column.placeholder,
237
219
  disabled: isDisable(column, record) ?? false,
238
220
  maxDate: maxWeekValue,
239
- minDate: minWeekValue
240
- // onChange={(dateValue, dateString) => {
241
- // const newDateValue = dateString ? dateString : null
242
- //
243
- // record[column.dataIndex] = newDateValue
244
- // handleCellChange(newDateValue, newDateValue, record, col, indexRow, indexCol)
245
- // }}
246
- ,
221
+ minDate: minWeekValue,
247
222
  popupClassName: 'be-popup-container'
248
223
  });
249
224
  case 'time':
@@ -259,22 +234,10 @@ const EditableCell = props => {
259
234
  format: {
260
235
  format: timeFormat,
261
236
  type: 'mask'
262
- }
263
- // defaultValue={timeValue}
264
- ,
237
+ },
265
238
  maxDate: maxTime,
266
239
  minDate: minTime,
267
- disabled: isDisable(column, record) ?? false
268
- // onChange={(values: any, timeString) => {
269
- // const newTimeValue = timeString ? timeString : null
270
- // const newrecordData = {
271
- // ...record,
272
- // // [column.dataIndex]: newTimeValue
273
- // }
274
- //
275
- // // handleCellChange(newTimeValue, newTimeValue, newrecordData, col, indexRow, indexCol)
276
- // }}
277
- ,
240
+ disabled: isDisable(column, record) ?? false,
278
241
  style: {
279
242
  width: '100%',
280
243
  height: '100%'
@@ -337,21 +300,31 @@ const EditableCell = props => {
337
300
  // @ts-ignore
338
301
  valueSelectTable = column?.editSelectSettings?.defaultValue(record[column.dataIndex], record);
339
302
  }
303
+ console.log('valueSelectTable', valueSelectTable);
340
304
  return /*#__PURE__*/React.createElement(AsyncTableSelect, {
341
305
  id: `col${indexCol}-record${indexRow}`,
342
306
  columns: columnsTable,
343
307
  options: options,
344
308
  defaultOptions: options
345
- // onChange={(val: any, option) => {
346
- // // const newValue = val && (column?.editSelectSettings?.isMulti || column?.editSelectSettings?.selectMode === 'checkbox') ? (val?.map((item: any) => item[keySelect]) ?? []) : (val ? val[keySelect] : null)
347
- // const newrecordData = {
348
- // ...record,
349
- // [column.dataIndex]: val
350
- // }
351
- //
352
- // // handleCellChange(option, val, newrecordData, col, indexRow, indexCol)
353
- // }}
309
+ // value={valueSelectTable}
354
310
  ,
311
+ value: value,
312
+ onChange: (val, option) => {
313
+ onChange(val);
314
+ const formState = getValues();
315
+ // const itemState = getValues(dataIndex)
316
+ // @ts-ignore
317
+ const prevState = record[dataIndex];
318
+ const newState = val;
319
+ handleCellChange?.({
320
+ key: getRowKey?.(record, index),
321
+ record: formState,
322
+ prevState,
323
+ newState,
324
+ option: option,
325
+ type: 'blur'
326
+ });
327
+ },
355
328
  showSearch: true,
356
329
  mode: column?.editSelectSettings?.isMulti || column?.editSelectSettings?.selectMode === 'checkbox' ? 'multiple' : undefined,
357
330
  focusToSelectAll: true,
@@ -360,16 +333,13 @@ const EditableCell = props => {
360
333
  width: '100%',
361
334
  height: '100%'
362
335
  },
363
- value: valueSelectTable,
364
336
  placeholder: t ? t('Select') : 'Select',
365
337
  allowClear: column.isClearable ?? false,
366
338
  maxTagCount: 'responsive',
367
339
  rowKey: keySelect,
368
340
  popupMatchSelectWidth: column?.editSelectSettings?.menuWidth ? column?.editSelectSettings?.menuWidth + 10 : undefined,
369
341
  optionFilterProp: "label",
370
- popupClassName: 'be-popup-container'
371
- // onPaste={(e: any) => handleOnCellPaste(e, indexRow, indexCol)}
372
- ,
342
+ popupClassName: 'be-popup-container',
373
343
  loadOptions: column?.editSelectSettings?.loadOptions,
374
344
  status: isInvalid ? 'error' : undefined,
375
345
  dropdownRender: menu => {
@@ -457,27 +427,26 @@ const EditableCell = props => {
457
427
  onChange: (val, item) => {
458
428
  console.log('item', item);
459
429
  onChange(val);
460
- },
461
- onBlur: () => {
462
- const formState = getValues();
463
- // const itemState = getValues(dataIndex)
464
-
465
- // @ts-ignore
466
- const prevState = record[dataIndex];
467
- // const newState = value
430
+ }
468
431
 
469
- // console.log('prevState', prevState)
470
- // console.log('newState', newState)
471
- // console.log('itemState', itemState)
472
- if (value !== prevState) {
473
- // @ts-ignore
474
- handleCellChange?.({
475
- key: record[rowKey],
476
- record: formState,
477
- type: 'blur'
478
- });
479
- }
480
- },
432
+ // onBlur={() => {
433
+ // const formState = getValues()
434
+ // // const itemState = getValues(dataIndex)
435
+ //
436
+ // // @ts-ignore
437
+ // const prevState = record[dataIndex]
438
+ // // const newState = value
439
+ //
440
+ // // console.log('prevState', prevState)
441
+ // // console.log('newState', newState)
442
+ // // console.log('itemState', itemState)
443
+ //
444
+ // if (value !== prevState) {
445
+ // // @ts-ignore
446
+ // handleCellChange?.({key: record[rowKey], record: formState, type: 'blur'})
447
+ // }
448
+ // }}
449
+ ,
481
450
  popupClassName: 'be-popup-container'
482
451
  });
483
452
  case 'treeSelect':
@@ -2,5 +2,6 @@ import React from 'react';
2
2
  import type { GridTableProps } from "./type";
3
3
  import 'dayjs/locale/es';
4
4
  import 'dayjs/locale/vi';
5
+ import './styles.scss';
5
6
  declare const InternalTable: <RecordType extends object>(props: GridTableProps<RecordType>) => React.JSX.Element;
6
7
  export default InternalTable;
@@ -1,9 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import React, { Fragment, useCallback, useEffect, useRef, useState } from 'react';
2
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
3
3
  import { Select, Table } from "rc-master-ui";
4
4
  import { Button, Space } from "antd";
5
5
  import { SearchOutlined } from "@ant-design/icons";
6
- import styled from "styled-components";
7
6
  import { Resizable } from "react-resizable";
8
7
  import customParseFormat from 'dayjs/plugin/customParseFormat';
9
8
  import { numberOperator, translateOption, updateArrayByKey } from "./hooks";
@@ -14,8 +13,9 @@ import 'dayjs/locale/es';
14
13
  import 'dayjs/locale/vi';
15
14
  import en from 'rc-master-ui/es/date-picker/locale/en_US';
16
15
  import vi from 'rc-master-ui/es/date-picker/locale/vi_VN';
17
- import GridEdit from "./rc-table/GridEdit";
18
- import Grid from "./rc-table/Grid";
16
+ import "./styles.scss";
17
+ import GridEdit from "./table/GridEdit";
18
+ import Grid from "./table/Grid";
19
19
  dayjs.extend(customParseFormat);
20
20
  const ResizableTitle = props => {
21
21
  const {
@@ -45,20 +45,17 @@ const ResizableTitle = props => {
45
45
  }, /*#__PURE__*/React.createElement("th", restProps))
46
46
  );
47
47
  };
48
- const GridStyle = styled.div.withConfig({
49
- displayName: "GridStyle",
50
- componentId: "es-grid-template__sc-1awgu8w-0"
51
- })([".ui-rc-pagination{border-bottom:1px solid #e0e0e0;border-top:1px solid #e0e0e0;margin:0;padding:.75rem 1rem;.ui-rc-pagination-total-text{order:2;margin-left:auto;}&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:", ";bottom:0;left:0;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:", ";bottom:0;visibility:visible;right:0;}}"], props => props.heightTable ? typeof props.heightTable === 'string' ? props.heightTable : `${props.heightTable}px` : undefined, props => props.heightTable ? `${props.heightTable}px` : undefined);
52
48
  const InternalTable = props => {
53
49
  const {
54
50
  t,
55
51
  columns: propsColumns,
56
52
  lang,
57
53
  dataSource,
58
- allowResizing = true,
54
+ allowResizing,
59
55
  dataSourceFilter: propDataSourceFilter,
60
56
  onFilterClick,
61
57
  editAble,
58
+ rowKey,
62
59
  ...rest
63
60
  } = props;
64
61
  const locale = lang && lang === 'en' ? en : vi;
@@ -83,6 +80,17 @@ const InternalTable = props => {
83
80
  }
84
81
  setIsManualUpdate(false);
85
82
  }, [dataSource]);
83
+
84
+ // ============================ RowKey ============================
85
+ const getRowKey = React.useMemo(() => {
86
+ if (typeof rowKey === 'function') {
87
+ return rowKey;
88
+ }
89
+
90
+ // @ts-ignore
91
+ return record => record?.[rowKey];
92
+ }, [rowKey]);
93
+ console.log('getRowKey', getRowKey);
86
94
  const handleSearch = (selectedKeys, confirm) => {
87
95
  confirm();
88
96
  };
@@ -244,11 +252,14 @@ const InternalTable = props => {
244
252
  return {
245
253
  ...getColumnSearchProps(col),
246
254
  ...col,
255
+ dataIndex: col.field ?? col.dataIndex,
247
256
  title: col.headerText ?? col.title,
248
257
  ellipsis: col.ellipsis !== false,
258
+ align: col.textAlign ?? col.align,
259
+ fixed: col.frozen ? col.frozen.toLowerCase() : col.fixed,
249
260
  onFilter: (value, record) => {
250
261
  // @ts-ignore
251
- return record[column?.dataIndex];
262
+ return record[col.field ?? col.dataIndex];
252
263
  },
253
264
  onHeaderCell: () => ({
254
265
  width: col.width,
@@ -260,13 +271,13 @@ const InternalTable = props => {
260
271
  const mergedColumns = React.useMemo(() => {
261
272
  return transformColumns(columns);
262
273
  }, [transformColumns, columns]);
274
+
275
+ // console.log('mergedColumns', mergedColumns)
276
+
277
+ const triggerChangeColumns = () => {};
278
+ const triggerChangeData = () => {};
263
279
  const TableComponent = editAble ? GridEdit : Grid;
264
- return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(GridStyle, {
265
- heightTable: props.style?.minHeight,
266
- style: {
267
- position: 'relative'
268
- }
269
- }, /*#__PURE__*/React.createElement(TableComponent, _extends({}, rest, {
280
+ return /*#__PURE__*/React.createElement(TableComponent, _extends({}, rest, {
270
281
  tableRef: tableRef,
271
282
  dataSource: data,
272
283
  components: {
@@ -274,10 +285,16 @@ const InternalTable = props => {
274
285
  cell: allowResizing ? ResizableTitle : undefined
275
286
  }
276
287
  },
277
- columns: mergedColumns,
288
+ columns: mergedColumns
289
+ // columns={columns}
290
+ ,
278
291
  showSorterTooltip: {
279
292
  target: 'sorter-icon'
280
- }
281
- }))));
293
+ },
294
+ triggerChangeColumns: triggerChangeColumns,
295
+ triggerChangeData: triggerChangeData,
296
+ rowKey: rowKey,
297
+ getRowKey: getRowKey
298
+ }));
282
299
  };
283
300
  export default InternalTable;
@@ -3,7 +3,8 @@ import 'dayjs/locale/es';
3
3
  import 'dayjs/locale/vi';
4
4
  import type { GridTableProps } from "./type";
5
5
  type GridProps<T> = GridTableProps<T> & {
6
- setColumns?: any;
6
+ triggerChangeColumns?: () => void;
7
+ triggerChangeData?: () => void;
7
8
  tableRef: any;
8
9
  };
9
10
  declare const TableGrid: <RecordType extends object>(props: GridProps<RecordType>) => React.JSX.Element;