es-grid-template 1.5.17 → 1.6.0

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 (53) hide show
  1. package/es/grid-component/CheckboxFilter2.js +0 -4
  2. package/es/grid-component/ColumnsChoose.js +9 -4
  3. package/es/grid-component/ColumnsGroup/ColumnsGroup.js +11 -4
  4. package/es/grid-component/EditableCell.js +26 -9
  5. package/es/grid-component/InternalTable.js +79 -27
  6. package/es/grid-component/TableGrid.js +39 -107
  7. package/es/grid-component/hooks/columns/index.d.ts +3 -2
  8. package/es/grid-component/hooks/columns/index.js +84 -8
  9. package/es/grid-component/hooks/content/ControlCheckbox.d.ts +13 -0
  10. package/es/grid-component/hooks/content/ControlCheckbox.js +87 -0
  11. package/es/grid-component/hooks/content/HeaderContent.d.ts +1 -1
  12. package/es/grid-component/hooks/content/HeaderContent.js +9 -4
  13. package/es/grid-component/hooks/useColumns.js +5 -5
  14. package/es/grid-component/hooks/utils.d.ts +28 -3
  15. package/es/grid-component/hooks/utils.js +544 -12
  16. package/es/grid-component/styles.scss +50 -1
  17. package/es/grid-component/table/Grid.d.ts +3 -0
  18. package/es/grid-component/table/GridEdit.d.ts +3 -0
  19. package/es/grid-component/table/GridEdit.js +349 -324
  20. package/es/grid-component/table/Group.d.ts +3 -0
  21. package/es/grid-component/table/InfiniteTable.d.ts +3 -0
  22. package/es/grid-component/table/InfiniteTable.js +4 -2
  23. package/es/grid-component/type.d.ts +1 -0
  24. package/es/index.d.ts +2 -0
  25. package/es/index.js +1 -0
  26. package/es/select/index.d.ts +1 -1
  27. package/lib/grid-component/CheckboxFilter2.js +0 -4
  28. package/lib/grid-component/ColumnsChoose.js +9 -4
  29. package/lib/grid-component/ColumnsGroup/ColumnsGroup.js +11 -4
  30. package/lib/grid-component/EditableCell.js +26 -9
  31. package/lib/grid-component/InternalTable.js +78 -26
  32. package/lib/grid-component/TableGrid.js +37 -105
  33. package/lib/grid-component/hooks/columns/index.d.ts +3 -2
  34. package/lib/grid-component/hooks/columns/index.js +86 -9
  35. package/lib/grid-component/hooks/content/ControlCheckbox.d.ts +13 -0
  36. package/lib/grid-component/hooks/content/ControlCheckbox.js +95 -0
  37. package/lib/grid-component/hooks/content/HeaderContent.d.ts +1 -1
  38. package/lib/grid-component/hooks/content/HeaderContent.js +9 -4
  39. package/lib/grid-component/hooks/useColumns.js +5 -5
  40. package/lib/grid-component/hooks/utils.d.ts +28 -3
  41. package/lib/grid-component/hooks/utils.js +565 -19
  42. package/lib/grid-component/styles.scss +50 -1
  43. package/lib/grid-component/table/Grid.d.ts +3 -0
  44. package/lib/grid-component/table/GridEdit.d.ts +3 -0
  45. package/lib/grid-component/table/GridEdit.js +339 -322
  46. package/lib/grid-component/table/Group.d.ts +3 -0
  47. package/lib/grid-component/table/InfiniteTable.d.ts +3 -0
  48. package/lib/grid-component/table/InfiniteTable.js +4 -2
  49. package/lib/grid-component/type.d.ts +1 -0
  50. package/lib/index.d.ts +2 -0
  51. package/lib/index.js +7 -0
  52. package/lib/select/index.d.ts +1 -1
  53. package/package.json +1 -1
@@ -79,7 +79,6 @@ const CheckboxFilter = props => {
79
79
 
80
80
  // const [searchValue, setSearchValue] = React.useState('');
81
81
 
82
- console.log('options', options);
83
82
  const [openKeys, setOpenKeys] = React.useState([]);
84
83
 
85
84
  // clear search value after close filter dropdown
@@ -172,9 +171,6 @@ const CheckboxFilter = props => {
172
171
  onSelect?.(keys);
173
172
  }
174
173
  };
175
- console.log('getTreeData({ filters: options })', getTreeData({
176
- filters: options
177
- }));
178
174
  if (filterMode === 'tree') {
179
175
  return /*#__PURE__*/React.createElement(React.Fragment, null, showFilter && /*#__PURE__*/React.createElement(FilterSearch, {
180
176
  filterSearch: filterSearch,
@@ -378,7 +378,7 @@ export const ColumnsChoose = props => {
378
378
  const defaultSelectedKeys = useMemo(() => {
379
379
  const defaultColumns = propsColumns.filter(it => (it.key || it.dataIndex) && it.showInColumnChoose !== false && !columnsGroup?.includes(it.field));
380
380
  return getVisibleColumnKeys(defaultColumns);
381
- }, [propsColumns]);
381
+ }, [columnsGroup, propsColumns]);
382
382
  const [clicked, setClicked] = useState(false);
383
383
  const [autoExpandParent, setAutoExpandParent] = useState(true);
384
384
 
@@ -473,7 +473,8 @@ export const ColumnsChoose = props => {
473
473
  placement: 'bottomLeft',
474
474
  content: /*#__PURE__*/React.createElement("div", {
475
475
  style: {
476
- minWidth: 250
476
+ minWidth: 250,
477
+ maxWidth: 320
477
478
  }
478
479
  }, /*#__PURE__*/React.createElement(Input, {
479
480
  style: {
@@ -518,8 +519,12 @@ export const ColumnsChoose = props => {
518
519
  defaultCheckedKeys: selectedKeys
519
520
  // defaultCheckedKeys={defaultSelectedKeys}
520
521
  ,
521
- selectedKeys: [],
522
- height: window.innerHeight - 200
522
+ selectedKeys: []
523
+
524
+ // height={window.innerHeight - 200}
525
+ ,
526
+ height: window.innerHeight / 2 > 450 ? 450 : window.innerHeight / 2 - 110
527
+ // style={{height: 300}}
523
528
  }), /*#__PURE__*/React.createElement(BoxAction, {
524
529
  className: 'px-1'
525
530
  }, /*#__PURE__*/React.createElement(Button
@@ -10,6 +10,7 @@ import { Button, Popover, Tooltip } from "antd";
10
10
  // import {SettingOutlined} from "@ant-design/icons";
11
11
  import { Select } from "rc-master-ui";
12
12
  import styled from "styled-components";
13
+ import { customFilterOption } from "../hooks";
13
14
  const BoxAction = styled.div.withConfig({
14
15
  displayName: "BoxAction",
15
16
  componentId: "es-grid-template__sc-1uj3tyy-0"
@@ -119,7 +120,8 @@ export const ColumnsGroup = props => {
119
120
  }, "M\u1EE9c 1"), /*#__PURE__*/React.createElement(Select, {
120
121
  style: {
121
122
  width: '100%'
122
- }
123
+ },
124
+ showSearch: true
123
125
  // labelInValue={true}
124
126
  // options={columns.filter((it: any) => !tempGroup.includes(it.field))}
125
127
  // options={columns && columns.length > 0 ? options : []}
@@ -136,7 +138,8 @@ export const ColumnsGroup = props => {
136
138
  labelRender: labelProps => {
137
139
  const it = columns.find(col => col.field === labelProps.value);
138
140
  return t ? t(it?.columnGroupText ?? it?.headerText) : it?.columnGroupText ?? it?.headerText;
139
- }
141
+ },
142
+ filterOption: customFilterOption
140
143
  // hideSelectedOptions
141
144
  })), /*#__PURE__*/React.createElement("div", {
142
145
  className: 'mb-1',
@@ -149,6 +152,7 @@ export const ColumnsGroup = props => {
149
152
  margin: 0
150
153
  }
151
154
  }, "M\u1EE9c 2"), /*#__PURE__*/React.createElement(Select, {
155
+ showSearch: true,
152
156
  style: {
153
157
  width: '100%'
154
158
  },
@@ -165,7 +169,8 @@ export const ColumnsGroup = props => {
165
169
  labelRender: labelProps => {
166
170
  const it = columns.find(col => col.field === labelProps.value);
167
171
  return t ? t(it?.columnGroupText ?? it?.headerText) : it?.columnGroupText ?? it?.headerText;
168
- }
172
+ },
173
+ filterOption: customFilterOption
169
174
  })), /*#__PURE__*/React.createElement("div", {
170
175
  className: 'mb-1',
171
176
  style: {
@@ -181,6 +186,7 @@ export const ColumnsGroup = props => {
181
186
  width: '100%'
182
187
  },
183
188
  options: options,
189
+ showSearch: true,
184
190
  value: tempGroup?.[2],
185
191
  onChange: val => onChangeGroupColumns(val, 2),
186
192
  allowClear: !!tempGroup?.[2] && !(unClearableLevel && unClearableLevel - 3 >= 0)
@@ -192,7 +198,8 @@ export const ColumnsGroup = props => {
192
198
  labelRender: labelProps => {
193
199
  const it = columns.find(col => col.field === labelProps.value);
194
200
  return t ? t(it?.columnGroupText ?? it?.headerText) : it?.columnGroupText ?? it?.headerText;
195
- }
201
+ },
202
+ filterOption: customFilterOption
196
203
  }))), /*#__PURE__*/React.createElement(BoxAction, {
197
204
  className: 'px-1'
198
205
  }, /*#__PURE__*/React.createElement(Button
@@ -28,6 +28,9 @@ import { cyan, green, red, blue } from '@ant-design/colors';
28
28
  const {
29
29
  SHOW_PARENT
30
30
  } = TreeSelect;
31
+ const {
32
+ TextArea
33
+ } = Input;
31
34
  const filterTreeNode = (input, treeNode) => {
32
35
  const {
33
36
  title,
@@ -114,8 +117,13 @@ const EditableCell = props => {
114
117
  style: {
115
118
  width: '100%',
116
119
  height: '100%'
117
- },
118
- value: date,
120
+ }
121
+ // value={date}
122
+ ,
123
+ defaultValue: date
124
+ // preserveInvalidOnBlur
125
+ ,
126
+
119
127
  onBlur: () => {
120
128
  const formState = getValues();
121
129
  const itemState = getValues(dataIndex);
@@ -178,8 +186,10 @@ const EditableCell = props => {
178
186
  width: '100%',
179
187
  height: '100%'
180
188
  },
181
- showTime: true,
182
- value: date,
189
+ showTime: true
190
+ // value={date}
191
+ ,
192
+ defaultValue: date,
183
193
  placeholder: t ? t(column.placeholder ?? 'Select') : column.placeholder ?? 'Select',
184
194
  disabled: isDisable(column, record) ?? false,
185
195
  maxDate: maxDate,
@@ -708,7 +718,7 @@ const EditableCell = props => {
708
718
  style: {
709
719
  display: 'flex',
710
720
  alignItems: 'center',
711
- justifyContent: column.align ?? 'left',
721
+ justifyContent: column.align ?? 'center',
712
722
  paddingInline: 5,
713
723
  height: '100%',
714
724
  width: '100%'
@@ -718,7 +728,7 @@ const EditableCell = props => {
718
728
  // style={{ textAlign: column.align ?? 'left' }}
719
729
  ,
720
730
  onChange: val => {
721
- const newVal = parseBooleanToValue(val.target.checked, typeof value);
731
+ const newVal = typeof value === "number" ? parseBooleanToValue(val.target.checked, typeof value) : val.target.checked;
722
732
  onChange(newVal);
723
733
  const key = getRowKey?.(record, index);
724
734
  const formState = getValues();
@@ -929,11 +939,14 @@ const EditableCell = props => {
929
939
  "data-tooltip-id": `${id}-tooltip-form-error`
930
940
  }));
931
941
  default:
932
- return /*#__PURE__*/React.createElement(Input, {
942
+ return /*#__PURE__*/React.createElement(TextArea, {
933
943
  id: `col${indexCol}-record${indexRow}`,
934
944
  style: {
935
- textAlign: column.align
945
+ textAlign: column.align,
946
+ resize: 'none',
947
+ height: '100%'
936
948
  }
949
+
937
950
  // @ts-ignore
938
951
  // value={!isNullOrUndefined(record[column.dataIndex]) ? record[column.dataIndex] : ''}
939
952
  ,
@@ -989,7 +1002,11 @@ const EditableCell = props => {
989
1002
  onChange: onChange,
990
1003
  status: isInvalid ? 'error' : undefined,
991
1004
  "data-tooltip-content": message,
992
- "data-tooltip-id": `${id}-tooltip-form-error`
1005
+ "data-tooltip-id": `${id}-tooltip-form-error`,
1006
+ autoSize: {
1007
+ minRows: 1,
1008
+ maxRows: 1
1009
+ }
993
1010
  });
994
1011
  }
995
1012
  };
@@ -3,7 +3,7 @@ import React, { createContext, Fragment, useCallback, useContext, useState } fro
3
3
  // import {Resizable} from "react-resizable";
4
4
  import 'react-resizable/css/styles.css';
5
5
  import customParseFormat from 'dayjs/plugin/customParseFormat';
6
- import { addRowIdArray, booleanOperator, findItemByKey, findItemPath, getFormat, getTypeFilter, groupArrayByColumns, numberOperator, removeColumns, stringOperator, translateOption, updateArrayByKey, updateColumnsByGroup, updateData } from "./hooks";
6
+ import { addRowIdArray, booleanOperator, convertFilters, convertFlatColumn, filterDataByColumns4, findItemByKey, findItemPath, getAllRowKey, getFormat, getTypeFilter, groupArrayByColumns, numberOperator, removeColumns, removeInvisibleColumns, stringOperator, translateOption, updateArrayByKey, updateColumnsByGroup, updateData } from "./hooks";
7
7
  import dayjs from "dayjs";
8
8
  import 'dayjs/locale/es';
9
9
  import 'dayjs/locale/vi';
@@ -37,6 +37,7 @@ import { arrayMove, horizontalListSortingStrategy, SortableContext, useSortable
37
37
  import { Resizable } from "react-resizable";
38
38
  import { faker } from "@faker-js/faker";
39
39
  import InfiniteTable from "./table/InfiniteTable";
40
+ import useMergedState from "rc-util/es/hooks/useMergedState";
40
41
  dayjs.extend(customParseFormat);
41
42
  const MySwal = withReactContent(Swal);
42
43
  const ASCEND = 'ascend';
@@ -180,15 +181,19 @@ const InternalTable = props => {
180
181
  summary,
181
182
  infiniteScroll,
182
183
  wrapSettings,
184
+ onFilter,
183
185
  ...rest
184
186
  } = props;
185
187
  const id = React.useMemo(() => {
186
188
  return tableId ?? faker.string.alpha(20);
187
189
  // return tableId ?? newGuid()
188
190
  }, [tableId]);
189
- const rowKey = React.useMemo(() => {
190
- return propRowKey ?? 'rowId';
191
- }, [propRowKey]);
191
+
192
+ // const rowKey = React.useMemo(() => {
193
+ // return propRowKey ?? 'rowId'
194
+ // }, [propRowKey])
195
+
196
+ const rowKey = 'rowId';
192
197
  const [scrollHeight, setHeight] = useState(0);
193
198
  const local = lang && lang === 'en' ? en : vi;
194
199
  const dateRangeLocale = lang && lang === 'en' ? enDr : viDr;
@@ -208,14 +213,30 @@ const InternalTable = props => {
208
213
  over: -1
209
214
  });
210
215
  const [tooltipContent, setTooltipContent] = useState('');
211
- const mergedData = React.useMemo(() => {
212
- // return addRowIdArray(dataSource)
216
+ const [filterStates, setFilterState] = React.useState(null);
217
+ // const [filterData, setFilterData] = React.useState<any>(null)
213
218
 
219
+ const mergedData = React.useMemo(() => {
214
220
  if (groupAble && groupSetting && groupSetting.client !== false) {
215
221
  return groupArrayByColumns(dataSource, groupColumns);
216
222
  }
217
223
  return addRowIdArray(dataSource);
218
224
  }, [dataSource, groupAble, groupColumns, groupSetting]);
225
+
226
+ // ========================= Keys =========================
227
+ const [mergedFilterKeys, setMergedFilterKeys] = useMergedState(getAllRowKey(mergedData), {
228
+ value: undefined
229
+ });
230
+ //
231
+ // const originData = React.useMemo(() => {
232
+ //
233
+ // if (groupAble && groupSetting && groupSetting.client !== false) {
234
+ // return groupArrayByColumns(dataSource, groupColumns)
235
+ // }
236
+ // return addRowIdArray(dataSource)
237
+ //
238
+ // }, [dataSource, groupAble, groupColumns, groupSetting])
239
+
219
240
  const [columns, setColumns] = React.useState([]);
220
241
  React.useEffect(() => {
221
242
  if (propsHeight) {
@@ -234,6 +255,20 @@ const InternalTable = props => {
234
255
  React.useEffect(() => {
235
256
  setColumns(propsColumns);
236
257
  }, [propsColumns]);
258
+ const handleOnFilter = queries => {
259
+ if (onFilter) {
260
+ onFilter?.(convertFilters(queries));
261
+ } else {
262
+ setFilterState(convertFilters(queries));
263
+ const b = filterDataByColumns4(mergedData, convertFilters(queries), []);
264
+ setMergedFilterKeys(getAllRowKey(b));
265
+ if (queries && queries.length > 0) {
266
+ // setIsFilter?.(true)
267
+ } else {
268
+ // setIsFilter?.(false)
269
+ }
270
+ }
271
+ };
237
272
  const handleResize = column => (e, {
238
273
  size
239
274
  }) => {
@@ -405,10 +440,11 @@ const InternalTable = props => {
405
440
  })
406
441
  }),
407
442
  render: (val, record) => {
443
+ const tmpData = filterDataByColumns4(mergedData, filterStates, mergedFilterKeys);
408
444
  if (pagination && pagination.onChange && pagination.currentPage && pagination.pageSize) {
409
- return findItemPath(mergedData, record, rowKey, pagination.currentPage, pagination.pageSize);
445
+ return findItemPath(tmpData, record, rowKey, pagination.currentPage, pagination.pageSize);
410
446
  }
411
- return findItemPath(mergedData, record, rowKey);
447
+ return findItemPath(tmpData, record, rowKey);
412
448
  }
413
449
  };
414
450
  }
@@ -504,28 +540,28 @@ const InternalTable = props => {
504
540
  render: (value, record, rowIndex) => {
505
541
  const colFormat = typeof column.format === 'function' ? column.format(record) : column.format;
506
542
  const cellFormat = getFormat(colFormat, format);
507
- if (groupSetting && groupSetting.hiddenColumnGroup === false) {
543
+ if (groupAble && groupSetting && groupSetting.hiddenColumnGroup === false) {
508
544
  if (record.children) {
509
- return renderContent(column, value, record, rowIndex, cellFormat);
545
+ return renderContent(column, value, record, rowIndex, colIndex, false, cellFormat);
510
546
  }
511
547
  if (groupColumns?.includes(column.field)) {
512
548
  return '';
513
549
  }
514
- return renderContent(column, value, record, rowIndex, cellFormat);
550
+ return renderContent(column, value, record, rowIndex, colIndex, false, cellFormat);
515
551
  }
516
- if (column.field === firstNonGroupColumn?.field && record.children) {
552
+ if (groupAble && column.field === firstNonGroupColumn?.field && record.children) {
517
553
  const currentGroupColumn = flatColumns2(columns).find(it => it.field === record.field);
518
554
  if (currentGroupColumn?.template) {
519
- return renderContent(currentGroupColumn, record[record.field], record, rowIndex, cellFormat);
555
+ return renderContent(currentGroupColumn, record[record.field], record, rowIndex, colIndex, false, cellFormat);
520
556
  }
521
- return /*#__PURE__*/React.createElement("span", null, currentGroupColumn?.headerText, ": ", renderContent(currentGroupColumn, record[record.field], record, rowIndex, cellFormat));
557
+ return /*#__PURE__*/React.createElement("span", null, currentGroupColumn?.headerText, ": ", renderContent(currentGroupColumn, record[record.field], record, rowIndex, colIndex, false, cellFormat));
522
558
  }
523
- return renderContent(column, value, record, rowIndex, cellFormat);
559
+ return renderContent(column, value, record, rowIndex, colIndex, false, cellFormat);
524
560
  },
525
561
  hidden: groupSetting && groupSetting.hiddenColumnGroup === false ? transformedColumn.hidden : groupAble && groupColumns && groupColumns.includes(column.field) ? true : transformedColumn.hidden
526
562
  };
527
563
  });
528
- }, [columns, t, getColumnSearchProps, sortMultiple, groupSetting, groupAble, groupColumns, pagination, mergedData, rowKey, handleResize, firstNonGroupColumn?.field, nonGroupColumns, format]);
564
+ }, [columns, t, id, wrapSettings, getColumnSearchProps, sortMultiple, groupSetting, groupAble, groupColumns, mergedData, filterStates, mergedFilterKeys, pagination, handleResize, firstNonGroupColumn?.field, nonGroupColumns, format]);
529
565
  const transformColumns = React.useCallback(cols => {
530
566
  return cols.map(column => {
531
567
  const find = convertColumns.find(it => it.field === column.field);
@@ -573,7 +609,7 @@ const InternalTable = props => {
573
609
  };
574
610
  }
575
611
  });
576
- }, [convertColumns, t]);
612
+ }, [convertColumns, id, t, wrapSettings]);
577
613
  const mergedColumns = React.useMemo(() => {
578
614
  return transformColumns(columns);
579
615
  }, [columns, transformColumns]);
@@ -591,9 +627,9 @@ const InternalTable = props => {
591
627
  });
592
628
  }
593
629
  onChooseColumns?.({
594
- showColumns: [],
595
- columns: [],
596
- flattenColumns: []
630
+ showColumns: removeInvisibleColumns([...newColumns]),
631
+ columns: [...newColumns],
632
+ flattenColumns: convertFlatColumn([...newColumns])
597
633
  });
598
634
  };
599
635
  const onDragEnd = ({
@@ -672,7 +708,9 @@ const InternalTable = props => {
672
708
  rowData,
673
709
  index
674
710
  } = args;
675
- const tmpData = [...mergedData];
711
+
712
+ // const tmpData = [...mergedData]
713
+ const tmpData = filterDataByColumns4(mergedData, filterStates, mergedFilterKeys);
676
714
  if (idCommand === 'DELETE') {
677
715
  // bật modal confirm
678
716
  if (commandSettings && commandSettings.confirmDialog) {
@@ -698,7 +736,7 @@ const InternalTable = props => {
698
736
 
699
737
  let newData = [];
700
738
  if (rowData?.parentId) {
701
- const parent = findItemByKey(mergedData, rowKey, rowData.parentId);
739
+ const parent = findItemByKey(tmpData, rowKey, rowData.parentId);
702
740
  const childData = parent?.children ? [...parent.children] : [];
703
741
  const findIndex = childData.findIndex(obj => obj[rowKey] === rowData[rowKey]);
704
742
  childData.splice(Number(findIndex), 1);
@@ -835,8 +873,13 @@ const InternalTable = props => {
835
873
  t: t,
836
874
  id: id,
837
875
  locale: locale,
838
- tableRef: tableRef,
839
- dataSource: mergedData,
876
+ tableRef: tableRef
877
+ // dataSource={mergedData}
878
+ ,
879
+ originData: mergedData
880
+ // dataSource={filterStates && filterStates.length ? filterData : mergedData}
881
+ ,
882
+ dataSource: filterDataByColumns4(mergedData, filterStates, mergedFilterKeys),
840
883
  format: format,
841
884
  columns: mergedColumns,
842
885
  showSorterTooltip: {
@@ -876,14 +919,23 @@ const InternalTable = props => {
876
919
  cell: TableBodyCell
877
920
  }
878
921
  },
879
- setTooltipContent: setTooltipContent
922
+ setTooltipContent: setTooltipContent,
923
+ onFilter: val => {
924
+ handleOnFilter(val);
925
+ // triggerFilter?.(convertFilters(val))
926
+ // onFilter?.(convertFilters(val))
927
+ },
928
+ setMergedFilterKeys: setMergedFilterKeys,
929
+ mergedFilterKeys: mergedFilterKeys,
930
+ wrapSettings: wrapSettings
880
931
  })))), /*#__PURE__*/React.createElement(DragOverlay, {
881
932
  style: {
882
- width: 100
933
+ minWidth: 100,
934
+ width: columns[columns.findIndex(i => i.field === dragIndex.active)]?.width
883
935
  }
884
936
  }, /*#__PURE__*/React.createElement("th", {
885
937
  style: {
886
- backgroundColor: '#c4c4c4',
938
+ backgroundColor: '#f0f0f0',
887
939
  padding: 6,
888
940
  borderRadius: 6,
889
941
  fontWeight: 500
@@ -14,10 +14,10 @@ import { checkDecimalSeparator, checkThousandSeparator,
14
14
  // filterDataByColumns3,
15
15
  filterDataByColumns4, getFormat,
16
16
  // convertFlatColumn,
17
- isEmpty,
17
+ isEmpty, sumByField
18
18
  // newGuid,
19
19
  // removeColumns,
20
- sumDataByField
20
+ // sumDataByField
21
21
  // updateArrayByKey
22
22
  } from "./hooks";
23
23
  // import {ConfigProvider} from "antd";
@@ -28,87 +28,6 @@ import { ColumnsChoose } from "./ColumnsChoose";
28
28
  import useMergedState from "rc-util/es/hooks/useMergedState";
29
29
  import AdvanceFilter from "./AdvanceFilter";
30
30
  import { Tooltip } from "react-tooltip";
31
- const convertFilters = filters => {
32
- const result = [];
33
- filters.forEach(({
34
- key,
35
- column,
36
- filteredKeys,
37
- operator
38
- }) => {
39
- if (!filteredKeys || filteredKeys.length === 0) {
40
- return;
41
- }
42
- if (column?.typeFilter === "DateRange" && filteredKeys.length === 2) {
43
- result.push({
44
- key,
45
- field: column?.dataIndex,
46
- value: filteredKeys[0],
47
- predicate: "and",
48
- operator: "greaterthanorequal"
49
- }, {
50
- key,
51
- field: column?.dataIndex,
52
- value: filteredKeys[1],
53
- predicate: "and",
54
- operator: "lessthanorequal"
55
- });
56
- } else if (column?.typeFilter === "NumberRange") {
57
- if ((filteredKeys[0] || filteredKeys[0] === 0) && !filteredKeys[1]) {
58
- result.push({
59
- key,
60
- field: column?.dataIndex,
61
- value: filteredKeys[0],
62
- predicate: "and",
63
- operator: "greaterthanorequal"
64
- });
65
- }
66
- if ((filteredKeys[1] || filteredKeys[1] === 0) && !filteredKeys[0]) {
67
- result.push({
68
- key,
69
- field: column?.dataIndex,
70
- value: filteredKeys[1],
71
- predicate: "and",
72
- operator: "lessthanorequal"
73
- });
74
- }
75
- if ((filteredKeys[0] || filteredKeys[0] === 0) && (filteredKeys[1] || filteredKeys[1] === 0)) {
76
- result.push({
77
- key,
78
- field: column?.dataIndex,
79
- value: filteredKeys[0],
80
- predicate: "and",
81
- operator: "greaterthanorequal"
82
- }, {
83
- key,
84
- field: column?.dataIndex,
85
- value: filteredKeys[1],
86
- predicate: "and",
87
- operator: "lessthanorequal"
88
- });
89
- }
90
- } else if (column?.typeFilter === 'Checkbox') {
91
- filteredKeys.forEach(value => {
92
- result.push({
93
- key,
94
- field: column?.dataIndex,
95
- value,
96
- predicate: "or",
97
- operator
98
- });
99
- });
100
- } else {
101
- result.push({
102
- key,
103
- field: column?.dataIndex,
104
- value: filteredKeys[0],
105
- predicate: 'and',
106
- operator
107
- });
108
- }
109
- });
110
- return result;
111
- };
112
31
  const useStyle = createStyles(({
113
32
  css
114
33
  }) => {
@@ -154,7 +73,7 @@ const TableGrid = props => {
154
73
  toolbarItems,
155
74
  showColumnChoose,
156
75
  showAdvanceFilter,
157
- onFilter,
76
+ // onFilter,
158
77
  triggerFilter,
159
78
  selectionSettings,
160
79
  rowSelection,
@@ -177,7 +96,7 @@ const TableGrid = props => {
177
96
  groupColumns,
178
97
  groupToolbar,
179
98
  showEmptyText,
180
- setIsFilter,
99
+ // setIsFilter,
181
100
  actionTemplate,
182
101
  ...rest
183
102
  } = props;
@@ -205,7 +124,8 @@ const TableGrid = props => {
205
124
  viewportWidth,
206
125
  viewportHeight
207
126
  });
208
- const [filterStates, setFilterState] = React.useState(null);
127
+
128
+ // const [filterStates, setFilterState] = React.useState<any>(null)
209
129
 
210
130
  // const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>(defaultSelected);
211
131
 
@@ -349,18 +269,22 @@ const TableGrid = props => {
349
269
  const handleChange = sorter => {
350
270
  onSorter?.(sorter);
351
271
  };
352
- const handleOnFilter = queries => {
353
- if (onFilter) {
354
- onFilter?.(convertFilters(queries));
355
- } else {
356
- setFilterState(convertFilters(queries));
357
- if (queries && queries.length > 0) {
358
- setIsFilter?.(true);
359
- } else {
360
- setIsFilter?.(false);
361
- }
362
- }
363
- };
272
+
273
+ // const handleOnFilter = (queries: any) => {
274
+ //
275
+ // if (onFilter) {
276
+ // onFilter?.(convertFilters(queries))
277
+ // } else {
278
+ // setFilterState(convertFilters(queries))
279
+ // if (queries && queries.length > 0) {
280
+ // // setIsFilter?.(true)
281
+ // } else {
282
+ // // setIsFilter?.(false)
283
+ // }
284
+ // }
285
+ //
286
+ // }
287
+
364
288
  return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(ContextMenu, {
365
289
  open: menuVisible,
366
290
  pos: position,
@@ -385,8 +309,10 @@ const TableGrid = props => {
385
309
  indicator: /*#__PURE__*/React.createElement(ComponentSpinner, null)
386
310
  }
387
311
  // dataSource={columns && columns.length > 0 ? filterDataByColumns3(dataSource, filterStates) : []}
312
+
313
+ // dataSource={columns && columns.length > 0 ? filterDataByColumns4(dataSource, filterStates) : []}
388
314
  ,
389
- dataSource: columns && columns.length > 0 ? filterDataByColumns4(dataSource, filterStates) : [],
315
+ dataSource: dataSource,
390
316
  className: classNames(className, {
391
317
  'table-none-column-select': selectionSettings?.mode === undefined && selectionSettings?.type !== 'multiple'
392
318
  }, styles.customTable),
@@ -423,13 +349,15 @@ const TableGrid = props => {
423
349
  // onScroll={(event) => {
424
350
  // console.log('event', event)
425
351
  // }}
352
+
353
+ // onFilter={(val: any) => {
354
+ // handleOnFilter(val)
355
+ // // triggerFilter?.(convertFilters(val))
356
+ // // onFilter?.(convertFilters(val))
357
+ //
358
+ // }}
426
359
  ,
427
360
 
428
- onFilter: val => {
429
- handleOnFilter(val);
430
- // triggerFilter?.(convertFilters(val))
431
- // onFilter?.(convertFilters(val))
432
- },
433
361
  onChange: (paging, filters, sorter) => handleChange(sorter),
434
362
  title: showToolbar === false ? undefined : () => {
435
363
  return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", null, title?.(dataSource)), /*#__PURE__*/React.createElement("div", {
@@ -499,9 +427,12 @@ const TableGrid = props => {
499
427
 
500
428
  // const dec = (col.format?.decimalScale || col.format?.decimalScale === 0) ? col.format?.decimalScale : format?.decimalScale
501
429
  const dec = cellFormat?.decimalScale;
502
- const sumValue = col.type === 'number' ? sumDataByField(filterDataByColumns4(dataSource, filterStates), col?.key) : 0;
430
+
431
+ // const sumValue = col.type === 'number' ? sumDataByField(filterDataByColumns4(dataSource, filterStates) as any[], col?.key as string) : 0
432
+ const sumValue = col.type === 'number' ? sumByField(filterDataByColumns4(dataSource, [], []), col?.field) : 0;
503
433
  const value = !isEmpty(sumValue) ? dec || dec === 0 ? parseFloat(Number(sumValue).toFixed(dec)).toString() : sumValue.toString() : '0';
504
434
  const cellValue = col.type === 'number' && col.isSummary !== false ? value : '';
435
+ const numberValue = Number(value);
505
436
  const numericFormatProps = {
506
437
  thousandSeparator: checkThousandSeparator(thousandSeparator, decimalSeparator),
507
438
  decimalSeparator: checkDecimalSeparator(thousandSeparator, decimalSeparator),
@@ -516,7 +447,7 @@ const TableGrid = props => {
516
447
  index: index,
517
448
  align: col.align ?? 'right',
518
449
  className: 'ui-rc-table-cell-ellipsis'
519
- }, col.summaryTemplate ? col.summaryTemplate(cellValue, col.key) : numericFormatter(cellValue, numericFormatProps));
450
+ }, col.summaryTemplate ? col.summaryTemplate(numberValue, col.key) : numericFormatter(cellValue, numericFormatProps));
520
451
  })));
521
452
  },
522
453
  pagination: !pagination || pagination && pagination?.onChange ? false : {
@@ -536,7 +467,8 @@ const TableGrid = props => {
536
467
  }, pagination)), bottomToolbar?.(), /*#__PURE__*/React.createElement(Tooltip, {
537
468
  id: `${id}-tooltip-header`,
538
469
  style: {
539
- zIndex: 1999
470
+ zIndex: 1999,
471
+ maxWidth: 350
540
472
  }
541
473
  }));
542
474
  };
@@ -4,6 +4,7 @@ import type { TableLocale } from "rc-master-ui/lib/table/interface";
4
4
  import type { ColumnsTable } from "../../type";
5
5
  export declare function flatColumns<RecordType>(columns: ColumnsTable<RecordType>, parentKey?: string): ColumnsTable<RecordType>;
6
6
  export declare const flatColumns2: <RecordType>(columns: ColumnsTable<RecordType>) => ColumnsTable<RecordType>;
7
- export declare const getValueCell: <T>(column: ColumnTable<T>, value: any, record: T, format?: IFormat) => any;
8
- export declare const renderContent: <T>(column: ColumnTable<T>, value: any, record: any, index: number, format?: IFormat) => React.JSX.Element;
7
+ export declare const getValueCell: <T>(column: ColumnTable<T>, value: any, record: T, rowIndex: number, colIndex: number, format?: IFormat) => any;
8
+ export declare const renderValueCell: <T>(column: ColumnTable<T>, value: any, record: T, rowIndex: number, colIndex: number, format?: IFormat, editAble?: boolean) => any;
9
+ export declare const renderContent: <T>(column: ColumnTable<T>, value: any, record: any, index: number, colIndex: number, editAble?: boolean, format?: IFormat, onClick?: any) => React.JSX.Element;
9
10
  export declare const renderFilter: <RecordType>(column: ColumnTable<RecordType>, selectedKeys: string[], setSelectedKeys: any, confirm: any, visible: boolean, searchValue: string, setSearchValue: any, dataSourceFilter: any[], buddhistLocale: any, locale?: TableLocale, t?: any, format?: IFormat, dateRangeLocale?: any) => React.JSX.Element;