es-grid-template 1.9.0 → 1.9.11

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 (48) hide show
  1. package/es/ali-table/Grid.d.ts +1 -1
  2. package/es/ali-table/Grid.js +9 -5
  3. package/es/ali-table/InternalTable.d.ts +1 -1
  4. package/es/ali-table/InternalTable.js +28 -8
  5. package/es/ali-table/base-table/styles.js +1 -1
  6. package/es/ali-table/common-views.js +1 -1
  7. package/es/ali-table/pipeline/features/ColumnsChoose.js +0 -3
  8. package/es/ali-table/pipeline/features/columnCustom.d.ts +11 -2
  9. package/es/ali-table/pipeline/features/columnCustom.js +27 -8
  10. package/es/ali-table/pipeline/features/treeMode.d.ts +1 -0
  11. package/es/ali-table/pipeline/features/treeMode.js +8 -1
  12. package/es/ali-table/pipeline/features/treeSelect.js +1 -1
  13. package/es/ali-table/utils/convertColumnsChoose.d.ts +1 -1
  14. package/es/ali-table/utils/convertColumnsChoose.js +2 -0
  15. package/es/grid-component/TempTable.d.ts +1 -1
  16. package/es/grid-component/type.d.ts +4 -0
  17. package/es/group-component/hook/utils.d.ts +1 -0
  18. package/es/table-component/TableContainer.js +5 -2
  19. package/es/table-component/TableContainerEdit.js +55 -10
  20. package/es/table-component/body/TableBodyCellEdit.js +1 -1
  21. package/es/table-component/index.d.ts +0 -2
  22. package/es/table-component/index.js +4 -0
  23. package/es/table-component/table/Grid.js +3 -1
  24. package/es/table-virtuoso/table/TableContainer.js +2 -1
  25. package/lib/ali-table/Grid.d.ts +1 -1
  26. package/lib/ali-table/Grid.js +10 -5
  27. package/lib/ali-table/InternalTable.d.ts +1 -1
  28. package/lib/ali-table/InternalTable.js +27 -7
  29. package/lib/ali-table/base-table/styles.js +1 -1
  30. package/lib/ali-table/common-views.js +1 -1
  31. package/lib/ali-table/pipeline/features/ColumnsChoose.js +0 -3
  32. package/lib/ali-table/pipeline/features/columnCustom.d.ts +11 -2
  33. package/lib/ali-table/pipeline/features/columnCustom.js +27 -8
  34. package/lib/ali-table/pipeline/features/treeMode.d.ts +1 -0
  35. package/lib/ali-table/pipeline/features/treeMode.js +8 -1
  36. package/lib/ali-table/utils/convertColumnsChoose.d.ts +1 -1
  37. package/lib/ali-table/utils/convertColumnsChoose.js +2 -0
  38. package/lib/grid-component/TempTable.d.ts +1 -1
  39. package/lib/grid-component/type.d.ts +4 -0
  40. package/lib/group-component/hook/utils.d.ts +1 -0
  41. package/lib/table-component/TableContainer.js +5 -2
  42. package/lib/table-component/TableContainerEdit.js +55 -10
  43. package/lib/table-component/body/TableBodyCellEdit.js +1 -1
  44. package/lib/table-component/index.d.ts +0 -2
  45. package/lib/table-component/index.js +2 -0
  46. package/lib/table-component/table/Grid.js +3 -1
  47. package/lib/table-virtuoso/table/TableContainer.js +2 -1
  48. package/package.json +2 -2
@@ -2,9 +2,9 @@ import type { TablePipeline } from "./pipeline";
2
2
  import type { Dispatch, SetStateAction } from "react";
3
3
  import React from "react";
4
4
  import './base-table/styles.scss';
5
- import type { TableProps } from "../table-component";
6
5
  import type { BaseTable } from "./base-table/table";
7
6
  import type { VirtualEnum } from "./base-table/interfaces";
7
+ import type { TableProps } from "../grid-component";
8
8
  declare const Grid: React.ForwardRefExoticComponent<Omit<TableProps, "useVirtual"> & {
9
9
  isFullScreen: boolean;
10
10
  setIsFullScreen: Dispatch<SetStateAction<boolean>>;
@@ -4,6 +4,7 @@ import { useLocale } from "rc-master-ui/es/locale";
4
4
  import React, { useContext } from "react";
5
5
  import { Tooltip } from "react-tooltip";
6
6
  import "./base-table/styles.scss";
7
+ // import type { TableProps } from "../table-component"
7
8
  import { Toolbar } from 'rc-master-ui';
8
9
  import classNames from "classnames";
9
10
  import Pagination from "rc-master-ui/es/pagination";
@@ -24,6 +25,7 @@ const Grid = /*#__PURE__*/React.forwardRef((props, ref) => {
24
25
  title,
25
26
  showToolbar,
26
27
  toolbarItems,
28
+ toolbarMode,
27
29
  pagination,
28
30
  infiniteScroll,
29
31
  dataSource,
@@ -50,7 +52,8 @@ const Grid = /*#__PURE__*/React.forwardRef((props, ref) => {
50
52
  setVisibleKeys,
51
53
  footerDataSource,
52
54
  loading,
53
- useVirtual
55
+ useVirtual,
56
+ useOuterBorder = true
54
57
 
55
58
  // onRowFooterStyles,
56
59
  // onRowHeaderStyles
@@ -143,12 +146,13 @@ const Grid = /*#__PURE__*/React.forwardRef((props, ref) => {
143
146
  setVisibleKeys(nextVisibleKeys);
144
147
  };
145
148
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
146
- className: classNames(`${prefix}-grid ${tableClassNames}`, {
149
+ className: classNames(`${prefix}-grid`, {
150
+ [tableClassNames]: !!tableClassNames,
147
151
  [`${prefix}-grid-light`]: !theme || theme.theme === 'light',
148
152
  [`${prefix}-grid-dark`]: theme?.theme === 'dark'
149
153
  }),
150
154
  style: {
151
- height: height ?? 700,
155
+ maxHeight: height ?? 700,
152
156
  minHeight,
153
157
  display: 'flex',
154
158
  flexDirection: 'column'
@@ -168,7 +172,7 @@ const Grid = /*#__PURE__*/React.forwardRef((props, ref) => {
168
172
  }
169
173
  }, /*#__PURE__*/React.createElement(Toolbar, {
170
174
  items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
171
- mode: 'scroll'
175
+ mode: toolbarMode
172
176
  })), /*#__PURE__*/React.createElement("div", {
173
177
  style: {
174
178
  display: 'flex',
@@ -228,7 +232,7 @@ const Grid = /*#__PURE__*/React.forwardRef((props, ref) => {
228
232
 
229
233
  // estimatedRowHeight={50}
230
234
  ,
231
- useOuterBorder: true
235
+ useOuterBorder: useOuterBorder
232
236
  // style={{ height: 700, overflow: 'auto' }}
233
237
  ,
234
238
  style: minHeight ? {
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
2
  import './base-table/styles.scss';
3
- import type { TableProps } from "../table-component";
3
+ import type { TableProps } from "../grid-component/type";
4
4
  declare const InternalTable: <RecordType extends object>(props: TableProps<RecordType>) => React.JSX.Element;
5
5
  export default InternalTable;
@@ -5,7 +5,7 @@ import { useLocale } from "rc-master-ui/es/locale";
5
5
  import { faker } from "@faker-js/faker";
6
6
  import React from "react";
7
7
  import "./base-table/styles.scss";
8
- import { addRowIdArray, filterDataByColumns, groupArrayByColumns, isTreeArray, sortByType, sumFields } from "../table-component/hook/utils";
8
+ import { addRowIdArray, filterDataByColumns, groupArrayByColumns, isTreeArray, revertConvertFilters, sortByType, sumFields } from "../table-component/hook/utils";
9
9
  import { CustomProvider, ConfigProvider } from 'rc-master-ui';
10
10
  import { Modal } from 'antd';
11
11
  import { getLocale, getLocales } from "../locale/useLocale";
@@ -33,7 +33,9 @@ const InternalTable = props => {
33
33
  expandable,
34
34
  sortMultiple,
35
35
  onFilter,
36
+ defaultFilter,
36
37
  onSorter,
38
+ defaultSorter,
37
39
  footerDataSource,
38
40
  summary,
39
41
  useVirtual,
@@ -88,11 +90,12 @@ const InternalTable = props => {
88
90
  return isTreeArray(convertData);
89
91
  }, [convertData]);
90
92
  const mergedData = React.useMemo(() => {
91
- if (sortState || filterState) {
92
- return filterDataByColumns(convertData, filterState ?? [], sortState ?? [], [], ignoreAccents);
93
+ const shouldSkip = onFilter && onSorter;
94
+ if (shouldSkip) {
95
+ return convertData;
93
96
  }
94
- return convertData;
95
- }, [convertData, filterState, ignoreAccents, sortState]);
97
+ return filterDataByColumns(convertData, onFilter ? undefined : filterState ?? defaultFilter, onSorter ? undefined : sortState ?? defaultSorter, [], ignoreAccents);
98
+ }, [convertData, filterState, ignoreAccents, sortState, onFilter, onSorter, defaultFilter, defaultSorter]);
96
99
  const footerData = React.useMemo(() => {
97
100
  if (!summary) {
98
101
  return undefined;
@@ -110,6 +113,12 @@ const InternalTable = props => {
110
113
  return undefined;
111
114
  }, [expandable?.defaultExpandAllRows, convertData, isDataTree]);
112
115
  const [isFullScreen, setIsFullScreen] = React.useState(false);
116
+ const defaultFilterConvert = React.useMemo(() => {
117
+ if (defaultFilter) {
118
+ return revertConvertFilters(defaultFilter);
119
+ }
120
+ return undefined;
121
+ }, [defaultFilter]);
113
122
  const pipeline = useTablePipeline({
114
123
  components: fusion
115
124
  }).input({
@@ -158,7 +167,8 @@ const InternalTable = props => {
158
167
  clickArea: 'icon',
159
168
  stopClickEventPropagation: true,
160
169
  expandIconColumnIndex: expandable?.expandIconColumnIndex,
161
- defaultOpenKeys: expandAllKeys ?? expandable?.defaultExpandedRowKeys
170
+ defaultOpenKeys: expandAllKeys ?? expandable?.defaultExpandedRowKeys,
171
+ isTreeArray: !!isDataTree
162
172
  })).use(features.columnCustom({
163
173
  id,
164
174
  t,
@@ -177,6 +187,8 @@ const InternalTable = props => {
177
187
  currentPage: pagination ? pagination?.currentPage : undefined,
178
188
  pageSize: pagination ? pagination?.pageSize : undefined,
179
189
  isDataTree,
190
+ defaultFilter: defaultFilterConvert,
191
+ defaultSorter,
180
192
  onFilter(val) {
181
193
  // const rs =
182
194
 
@@ -232,7 +244,11 @@ const InternalTable = props => {
232
244
  originColumns: columns,
233
245
  groupColumns: groupColumns,
234
246
  setVisibleKeys: setVisibleKeys,
235
- footerDataSource: footerData
247
+ footerDataSource: footerData,
248
+ onFilter: onFilter,
249
+ onSorter: onSorter,
250
+ defaultFilter: defaultFilter,
251
+ defaultSorter: defaultSorter
236
252
  })), /*#__PURE__*/React.createElement(Modal, {
237
253
  open: isFullScreen,
238
254
  footer: null,
@@ -278,7 +294,11 @@ const InternalTable = props => {
278
294
  originColumns: columns,
279
295
  groupColumns: groupColumns,
280
296
  setVisibleKeys: setVisibleKeys,
281
- footerDataSource: footerData
297
+ footerDataSource: footerData,
298
+ onFilter: onFilter,
299
+ onSorter: onSorter,
300
+ defaultFilter: defaultFilter,
301
+ defaultSorter: defaultSorter
282
302
  })))))));
283
303
  };
284
304
  export default InternalTable;
@@ -48,4 +48,4 @@ const outerBorderStyleMixin = css(["border-top:var(--cell-border-horizontal);bor
48
48
  export const StyledArtTableWrapper = styled.div.withConfig({
49
49
  displayName: "StyledArtTableWrapper",
50
50
  componentId: "es-grid-template__sc-ipj1ht-0"
51
- })(["--row-height:38px;--color:#333;--bgcolor:white;--hover-bgcolor:var(--hover-color,#f5f5f5);--highlight-bgcolor:#eee;--header-row-height:36px;--header-color:#000000de;--header-bgcolor:#ffffff;--header-hover-bgcolor:#ddd;--header-highlight-bgcolor:#e4e8ed;--cell-padding:7px 8px;--font-size:13px;--line-height:1.28571;--lock-shadow:rgba(152,152,152,0.5) 0 0 6px 2px;--border-color:#dfe3e8;--cell-border:1px solid var(--border-color);--cell-border-horizontal:var(--cell-border);--cell-border-vertical:var(--cell-border);--header-cell-border:1px solid var(--border-color);--header-cell-border-horizontal:var(--header-cell-border);--header-cell-border-vertical:var(--header-cell-border);--footer-bgColor:#fafafa;box-sizing:border-box;*{box-sizing:border-box;}cursor:default;color:var(--color);font-size:var(--font-size);line-height:var(--line-height);position:relative;overflow-anchor:none;&.use-outer-border{", ";}.no-scrollbar{scrollbar-width:none;::-webkit-scrollbar{display:none;}}.", "{overflow-x:auto;overflow-y:hidden;background:var(--header-bgcolor);.ui-rc-table-column-title{flex:1;min-width:0;text-align:start;}.", "{font-weight:500;.ui-rc-header-trigger{padding-left:6px;display:flex;align-items:center;.ui-rc-table-column-sorter-cancel{opacity:0;}}&:hover{.ui-rc-header-trigger{.ui-rc-table-column-sorter-cancel{opacity:1;}}}.", "{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;word-break:keep-all;}.", "{width:100%;white-space:normal;word-break:break-word;}.", "{text-align:center;}.", "{text-align:right;}}}.", "{.", "{&.", "{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;word-break:keep-all;}&.", "{width:100%;white-space:normal;word-break:break-word;}&.", "{text-align:center;}&.", "{text-align:right;}}}.", ",.", "{overflow-x:auto;overflow-y:hidden;background:var(--bgcolor);}&.sticky-header .", "{position:sticky;top:0;z-index:", ";}&.sticky-footer .", "{position:sticky;bottom:0;z-index:", ";}.", "{tr{td{&.lock-left,&.lock-right{border-bottom-width:0;box-shadow:0 -1px 0 0 var(--border-color),0 1px 0 0 var(--border-color),-1px 0 0 0 var(--border-color);}}}}table{width:100%;table-layout:fixed;border-collapse:separate;border-spacing:0;display:table;margin:0;padding:0;}tr:not(.no-hover):hover > td{background:var(--hover-bgcolor);}tr:not(.no-highlight).highlight > td{background:var(--highlight-bgcolor);}th{font-weight:normal;text-align:left;padding:var(--cell-padding);height:var(--header-row-height);color:var(--header-color);background:var(--header-bgcolor);border:none;border-right:var(--header-cell-border-vertical);border-bottom:var(--header-cell-border-horizontal);}tr.first th{border-top:var(--header-cell-border-horizontal);}th.first{border-left:var(--header-cell-border-vertical);}td{padding:var(--cell-padding);background:var(--bgcolor);height:var(--row-height);border:none;border-right:var(--cell-border-vertical);border-bottom:var(--cell-border-horizontal);}td.first{border-left:var(--cell-border-vertical);}tr.first td{border-top:var(--cell-border-horizontal);}&.has-header tbody tr.first td{border-top:none;}&.has-footer tbody tr.last td{border-bottom:none;}.lock-left,.lock-right{z-index:", ";}.resize-handle{width:6px;height:100%;position:absolute;top:0;right:0;cursor:col-resize;background-color:transparent;border-right:2px solid transparent}.", "{position:absolute;top:0;bottom:0;z-index:", ";pointer-events:none;overflow:hidden;.", "{height:100%;}.", "{margin-right:", "px;box-shadow:none;&.show-shadow{box-shadow:var(--lock-shadow);border-right:var(--cell-border-vertical);}}.", "{margin-left:", "px;box-shadow:none;&.show-shadow{box-shadow:var(--lock-shadow);border-left:var(--cell-border-vertical);}}}.", "{pointer-events:none;color:#99a3b3;font-size:12px;text-align:center;position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);.empty-image{width:50px;height:50px;}.empty-tips{margin-top:16px;line-height:1.5;}}.", "{overflow:auto;position:sticky;bottom:0;z-index:", ";margin-top:-17px;}.ui-rc-grid-loading-wrapper{}.ui-rc-grid-table{}.art-loading-content-wrapper{}.", "{height:1px;visibility:hidden;}.", "{position:relative;.", "{position:absolute;left:0;right:0;top:0;bottom:0;pointer-events:none;}.", "{position:sticky;z-index:", ";transform:translateY(-50%);}}"], outerBorderStyleMixin, Classes.tableHeader, Classes.tableHeaderCell, Classes.cellEllipsis, Classes.cellWrap, Classes.cellTextCenter, Classes.cellTextRight, Classes.tableBody, Classes.tableCell, Classes.cellEllipsis, Classes.cellWrap, Classes.cellTextCenter, Classes.cellTextRight, Classes.tableBody, Classes.tableFooter, Classes.tableHeader, Z.header, Classes.tableFooter, Z.footer, Classes.tableBody, Z.lock, Classes.lockShadowMask, Z.lockShadow, Classes.lockShadow, Classes.leftLockShadow, LOCK_SHADOW_PADDING, Classes.rightLockShadow, LOCK_SHADOW_PADDING, Classes.emptyWrapper, Classes.stickyScroll, Z.scrollItem, Classes.stickyScrollItem, Classes.loadingWrapper, Classes.loadingIndicatorWrapper, Classes.loadingIndicator, Z.loadingIndicator);
51
+ })(["--row-height:38px;--color:#333;--bgcolor:white;--hover-bgcolor:var(--hover-color,#f5f5f5);--highlight-bgcolor:#eee;--header-row-height:36px;--header-color:#000000de;--header-bgcolor:#ffffff;--header-hover-bgcolor:#ddd;--header-highlight-bgcolor:#e4e8ed;--cell-padding:7px 8px;--font-size:13px;--line-height:1.28571;--lock-shadow:rgba(152,152,152,0.5) 0 0 6px 2px;--border-color:#dfe3e8;--cell-border:1px solid var(--border-color);--cell-border-horizontal:var(--cell-border);--cell-border-vertical:var(--cell-border);--header-cell-border:1px solid var(--border-color);--header-cell-border-horizontal:var(--header-cell-border);--header-cell-border-vertical:var(--header-cell-border);--footer-bgColor:#fafafa;box-sizing:border-box;*{box-sizing:border-box;}cursor:default;color:var(--color);font-size:var(--font-size);line-height:var(--line-height);position:relative;overflow-anchor:none;&.use-outer-border{", ";}.no-scrollbar{scrollbar-width:none;::-webkit-scrollbar{display:none;}}.", "{overflow-x:auto;overflow-y:hidden;background:var(--header-bgcolor);.ui-rc-table-column-title{flex:1;min-width:0;text-align:start;}.", "{font-weight:500;.ui-rc-header-trigger{padding-left:6px;display:flex;align-items:center;.ui-rc-table-column-sorter-cancel{opacity:0;}}&:hover{.ui-rc-header-trigger{.ui-rc-table-column-sorter-cancel{opacity:1;}}}.", "{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;word-break:keep-all;}.", "{width:100%;white-space:normal;word-break:break-word;}.", "{text-align:center;}.", "{text-align:right;}}}.", "{.", "{&.", "{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;word-break:keep-all;.expansion-cell{.expansion-content{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;word-break:keep-all;}}}&.", "{width:100%;white-space:normal;word-break:break-word;}&.", "{text-align:center;}&.", "{text-align:right;}}}.", ",.", "{overflow-x:auto;overflow-y:hidden;background:var(--bgcolor);}&.sticky-header .", "{position:sticky;top:0;z-index:", ";}&.sticky-footer .", "{position:sticky;bottom:0;z-index:", ";}.", "{tr{td{&.lock-left,&.lock-right{border-bottom-width:0;box-shadow:0 -1px 0 0 var(--border-color),0 1px 0 0 var(--border-color),-1px 0 0 0 var(--border-color);}}}}table{width:100%;table-layout:fixed;border-collapse:separate;border-spacing:0;display:table;margin:0;padding:0;}tr:not(.no-hover):hover > td{background:var(--hover-bgcolor);}tr:not(.no-highlight).highlight > td{background:var(--highlight-bgcolor);}th{font-weight:normal;text-align:left;padding:var(--cell-padding);height:var(--header-row-height);color:var(--header-color);background:var(--header-bgcolor);border:none;border-right:var(--header-cell-border-vertical);border-bottom:var(--header-cell-border-horizontal);}tr.first th{border-top:var(--header-cell-border-horizontal);}th.first{border-left:var(--header-cell-border-vertical);}td{padding:var(--cell-padding);background:var(--bgcolor);height:var(--row-height);border:none;border-right:var(--cell-border-vertical);border-bottom:var(--cell-border-horizontal);}td.first{border-left:var(--cell-border-vertical);}tr.first td{border-top:var(--cell-border-horizontal);}&.has-header tbody tr.first td{border-top:none;}&.has-footer tbody tr.last td{border-bottom:none;}.lock-left,.lock-right{z-index:", ";}.resize-handle{width:6px;height:100%;position:absolute;top:0;right:0;cursor:col-resize;background-color:transparent;border-right:2px solid transparent}.", "{position:absolute;top:0;bottom:0;z-index:", ";pointer-events:none;overflow:hidden;.", "{height:100%;}.", "{margin-right:", "px;box-shadow:none;&.show-shadow{box-shadow:var(--lock-shadow);border-right:var(--cell-border-vertical);}}.", "{margin-left:", "px;box-shadow:none;&.show-shadow{box-shadow:var(--lock-shadow);border-left:var(--cell-border-vertical);}}}.", "{pointer-events:none;color:#99a3b3;font-size:12px;text-align:center;position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);.empty-image{width:50px;height:50px;}.empty-tips{margin-top:16px;line-height:1.5;}}.", "{overflow:auto;position:sticky;bottom:0;z-index:", ";margin-top:-17px;}.ui-rc-grid-loading-wrapper{}.ui-rc-grid-table{}.art-loading-content-wrapper{}.", "{height:1px;visibility:hidden;}.", "{position:relative;.", "{position:absolute;left:0;right:0;top:0;bottom:0;pointer-events:none;}.", "{position:sticky;z-index:", ";transform:translateY(-50%);}}"], outerBorderStyleMixin, Classes.tableHeader, Classes.tableHeaderCell, Classes.cellEllipsis, Classes.cellWrap, Classes.cellTextCenter, Classes.cellTextRight, Classes.tableBody, Classes.tableCell, Classes.cellEllipsis, Classes.cellWrap, Classes.cellTextCenter, Classes.cellTextRight, Classes.tableBody, Classes.tableFooter, Classes.tableHeader, Z.header, Classes.tableFooter, Z.footer, Classes.tableBody, Z.lock, Classes.lockShadowMask, Z.lockShadow, Classes.lockShadow, Classes.leftLockShadow, LOCK_SHADOW_PADDING, Classes.rightLockShadow, LOCK_SHADOW_PADDING, Classes.emptyWrapper, Classes.stickyScroll, Z.scrollItem, Classes.stickyScrollItem, Classes.loadingWrapper, Classes.loadingIndicatorWrapper, Classes.loadingIndicator, Z.loadingIndicator);
@@ -4,7 +4,7 @@ import styled from 'styled-components';
4
4
  export const InlineFlexCell = styled.div.withConfig({
5
5
  displayName: "InlineFlexCell",
6
6
  componentId: "es-grid-template__sc-1o0on5d-0"
7
- })(["display:inline-flex;align-items:center;"]);
7
+ })(["display:flex;align-items:center;"]);
8
8
  export const ExpansionCell = styled(InlineFlexCell).withConfig({
9
9
  displayName: "ExpansionCell",
10
10
  componentId: "es-grid-template__sc-1o0on5d-1"
@@ -33,9 +33,6 @@ export const ColumnsChoose = props => {
33
33
  const defaultSelectedKeys = React.useMemo(() => {
34
34
  const colsVisiables = originColumns.filter(it => it.showInColumnChoose !== false && it.visible !== false);
35
35
  const colsKeys = colsVisiables.map(it => it.field);
36
-
37
- // const aa = Object.keys(columnHidden)
38
-
39
36
  return colsKeys.filter(it => !columnsGroup?.includes(it));
40
37
  }, [columnsGroup, originColumns]);
41
38
  const [mergedSelectedKeys, setMergedSelectedKeys] = useMergedState(defaultSelectedKeys && defaultSelectedKeys.length ? defaultSelectedKeys : undefined, {
@@ -1,7 +1,14 @@
1
1
  import type { TablePipeline } from '../pipeline';
2
2
  import type { ColumnResizeMode } from '../../base-table/table';
3
- import type { SortOrder } from '../../interfaces';
3
+ import type { ArtColumn, SortOrder } from '../../interfaces';
4
4
  import type { FilterItem, IFormat, IWrapSettings, Sorter, SourceFilter } from '../../../grid-component/type';
5
+ type FilterState = {
6
+ field: any;
7
+ key: any;
8
+ column: ArtColumn;
9
+ filteredKeys: any[];
10
+ operator: string | undefined;
11
+ };
5
12
  export interface ColumnFeatureOptions {
6
13
  id: any;
7
14
  columns: any[];
@@ -39,7 +46,8 @@ export interface ColumnFeatureOptions {
39
46
  dataSourceFilter?: SourceFilter[];
40
47
  ignoreAccents?: boolean;
41
48
  onFilter?: (filterState: FilterItem[]) => void;
42
- defaultSorts?: Sorter[];
49
+ defaultFilter?: FilterState[];
50
+ defaultSorter?: Sorter[];
43
51
  mode?: 'single' | 'multiple';
44
52
  keepDataSource?: boolean;
45
53
  orders?: SortOrder[];
@@ -49,3 +57,4 @@ export interface ColumnFeatureOptions {
49
57
  pageSize?: number;
50
58
  }
51
59
  export declare function columnCustom(opts: ColumnFeatureOptions): (pipeline: TablePipeline) => TablePipeline;
60
+ export {};
@@ -41,7 +41,10 @@ export function columnCustom(opts) {
41
41
  wrapSettings,
42
42
  // ignoreAccents,
43
43
  dataSource,
44
- isDataTree
44
+ isDataTree,
45
+ defaultSorter,
46
+ defaultFilter
47
+
45
48
  // currentPage = 1,
46
49
  // pageSize
47
50
  } = opts;
@@ -52,7 +55,7 @@ export function columnCustom(opts) {
52
55
  } = opts;
53
56
  return function columnResizeFeature(pipeline) {
54
57
  const sizes = opts.sizes ?? pipeline.getStateAtKey(stateKeyResize) ?? opts.defaultSizes ?? [];
55
- const filterState = pipeline.getStateAtKey(stateKeyFilter) ?? [];
58
+ const filterState = pipeline.getStateAtKey(stateKeyFilter) ?? defaultFilter ?? [];
56
59
  const visible = pipeline.getStateAtKey(stateKeyVisible) ?? '';
57
60
  const isOpenTooltip = pipeline.getStateAtKey(stateKeyTooltip) ?? false;
58
61
  const pageSize = opts?.pageSize ?? pipeline.getStateAtKey(stateKey)?.pageSize ?? pageSizeOptions[0];
@@ -67,7 +70,7 @@ export function columnCustom(opts) {
67
70
  // const fieldOriginal = fieldOriginalKey ? columns.find((it) => it.field === fieldOriginalKey) : undefined
68
71
 
69
72
  // const sorterStates = pipeline.getStateAtKey(stateKeySorter) ?? []
70
- const sorterStates = pipeline.getStateAtKey(stateKeySorter) ?? opts.defaultSorts ?? [];
73
+ const sorterStates = pipeline.getStateAtKey(stateKeySorter) ?? defaultSorter ?? [];
71
74
  const activeSorts = sorterStates.filter(s => s.order !== 'none');
72
75
  const sorts = mode === 'multiple' ? activeSorts : activeSorts.slice(0, 1);
73
76
  const leafColumns = collectNodes(pipeline.getColumns(), 'leaf-only');
@@ -119,9 +122,10 @@ export function columnCustom(opts) {
119
122
  const onVisibleChange = (newVisible, info, column) => {
120
123
  if (info.source === 'trigger') {
121
124
  if (newVisible) {
122
- const filterValue = filterColumnState.filteredKeys ?? [];
125
+ const defaultFilterOption = defaultFilter?.find(it => it.field === column.field);
126
+ const filterValue = filterColumnState.filteredKeys === null ? [] : filterColumnState.filteredKeys ?? defaultFilterOption?.filteredKeys ?? [];
123
127
  const operator = filterColumnState.operator;
124
- const operatorValue = operator ?? getDefaultOperator(column);
128
+ const operatorValue = operator ?? defaultFilterOption?.operator ?? getDefaultOperator(column);
125
129
  pipeline.setStateAtKey(stateKeyColumnFilter, {
126
130
  operator: operatorValue,
127
131
  filteredKeys: filterValue,
@@ -193,8 +197,20 @@ export function columnCustom(opts) {
193
197
  // xóa column đang filter trong filterState
194
198
 
195
199
  const newFilterState = filterState.filter(it => it.field !== filterColumnState.field);
196
- pipeline.setStateAtKey(stateKeyColumnFilter, {});
197
- pipeline.setStateAtKey(stateKeyFilter, [...newFilterState]);
200
+ const currentFilter = {
201
+ field: filterColumnState.field,
202
+ key: filterColumnState.field,
203
+ column: filterColumnState.column,
204
+ filteredKeys: null,
205
+ operator: filterColumnState.operator ?? undefined
206
+ };
207
+ const rs = updateArrayByKey(filterState, currentFilter, 'field');
208
+ pipeline.setStateAtKey(stateKeyColumnFilter, {
209
+ ...currentFilter
210
+ });
211
+
212
+ // pipeline.setStateAtKey(stateKeyFilter, [...newFilterState])
213
+ pipeline.setStateAtKey(stateKeyFilter, rs);
198
214
  if (onFilter) {
199
215
  onFilter(convertFilters([...newFilterState]));
200
216
  } else {
@@ -242,7 +258,10 @@ export function columnCustom(opts) {
242
258
  const {
243
259
  order
244
260
  } = isSorted && sortMap.get(col.field);
245
- const filtered = !!filterState.find(it => it.field === col.field);
261
+ const find = filterState.find(it => it.field === col.field);
262
+
263
+ // const filtered = !!filterState.find((it) => it.field === col.field)
264
+ const filtered = !!find && find.filteredKeys !== null;
246
265
  const getDropdownTrigger = () => {
247
266
  let iconFilter;
248
267
  if (typeof filterIcon === 'function') {
@@ -16,5 +16,6 @@ export interface TreeModeFeatureOptions {
16
16
  clickArea?: 'cell' | 'content' | 'icon';
17
17
  stopClickEventPropagation?: boolean;
18
18
  treeMetaKey?: string | symbol;
19
+ isTreeArray?: boolean;
19
20
  }
20
21
  export declare function treeMode(opts?: TreeModeFeatureOptions): (pipeline: TablePipeline) => TablePipeline;
@@ -10,6 +10,7 @@ export function treeMode(opts = {}) {
10
10
  const stateKey = 'treeMode';
11
11
  const ctx = pipeline.ctx;
12
12
  const expandIconColumnIndex = opts.expandIconColumnIndex ?? 0;
13
+ const isTreeArray = opts.isTreeArray;
13
14
  const primaryKey = pipeline.ensurePrimaryKey('treeMode');
14
15
  if (typeof primaryKey !== 'string') {
15
16
  throw new Error('treeMode Only strings are supported primaryKey');
@@ -94,6 +95,9 @@ export function treeMode(opts = {}) {
94
95
  if (record[treeMetaKey] == null) {
95
96
  return content;
96
97
  }
98
+ if (!isTreeArray) {
99
+ return /*#__PURE__*/React.createElement(React.Fragment, null, content);
100
+ }
97
101
  const {
98
102
  rowKey,
99
103
  depth,
@@ -105,6 +109,7 @@ export function treeMode(opts = {}) {
105
109
  return /*#__PURE__*/React.createElement(InlineFlexCell, {
106
110
  className: "expansion-cell leaf"
107
111
  }, /*#__PURE__*/React.createElement("span", {
112
+ className: "expansion-content",
108
113
  style: {
109
114
  marginLeft: indent + iconWidth + iconGap
110
115
  }
@@ -131,7 +136,9 @@ export function treeMode(opts = {}) {
131
136
  marginRight: iconGap
132
137
  },
133
138
  onClick: clickArea === 'icon' ? onClick : undefined
134
- }), content);
139
+ }), /*#__PURE__*/React.createElement("span", {
140
+ className: "expansion-content"
141
+ }, content));
135
142
  };
136
143
  const getCellProps = (value, record, rowIndex) => {
137
144
  const prevProps = internals.safeGetCellProps(firstCol, record, rowIndex);
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React from "react";
2
2
  import { always } from "../../utils/others";
3
3
  import { findItemByKey, updateArrayByKey } from "../../../table-component/hook/utils";
4
4
  import { mergeCellProps } from "../../utils";
@@ -1,5 +1,5 @@
1
1
  import { TreeDataNode } from "antd";
2
- import type { ColumnTable } from "../../table-component";
2
+ import { ColumnTable } from "../../grid-component";
3
3
  export declare function convertColumnsToTreeData(columns: ColumnTable[], groupColumns?: string[], t?: any): TreeDataNode[];
4
4
  export declare function filterColumnsByField(columns: ColumnTable[], fieldList: string[]): ColumnTable[];
5
5
  export declare function filterVisibleColumns(columns: ColumnTable[]): ColumnTable[];
@@ -1,3 +1,5 @@
1
+ // import type { ColumnTable } from "../../table-component"
2
+
1
3
  export function convertColumnsToTreeData(columns, groupColumns, t) {
2
4
  if (!columns) {
3
5
  return [];
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
- import type { TableProps } from "../table-component";
2
+ import type { TableProps } from "../grid-component";
3
3
  declare const TempTable: <RecordType extends object>(props: TableProps<RecordType>) => React.JSX.Element;
4
4
  export default TempTable;
@@ -219,6 +219,8 @@ export type ColumnTable<RecordType = AnyObject> = {
219
219
  /** Custom render method */
220
220
  /** Custom method to get cell props */
221
221
  getCellProps?: (value: any, row: any, rowIndex: number) => CellProps;
222
+ /** Props for the header cell */
223
+ headerCellProps?: CellProps;
222
224
  /** Custom method to get cell SpanRect */
223
225
  getSpanRect?: (value: any, row: any, rowIndex: number) => SpanRect;
224
226
  };
@@ -230,6 +232,7 @@ export type TableProps<RecordType = AnyObject> = {
230
232
  backgroundColor?: string;
231
233
  color?: string;
232
234
  };
235
+ useOuterBorder?: boolean;
233
236
  className?: string;
234
237
  title?: ReactNode | ((data: RecordType) => ReactNode);
235
238
  fullScreenTitle?: ReactNode | (() => ReactNode);
@@ -256,6 +259,7 @@ export type TableProps<RecordType = AnyObject> = {
256
259
  /** Toolbar */
257
260
  showToolbar?: boolean;
258
261
  toolbarItems?: ToolbarItem[];
262
+ toolbarMode?: 'scroll';
259
263
  showColumnChoose?: boolean;
260
264
  onChooseColumns?: (props: IOnChooseColumns) => void;
261
265
  fullScreen?: boolean;
@@ -214,6 +214,7 @@ export declare const fixColumnsLeft: <RecordType>(columns: ColumnTable<RecordTyp
214
214
  sumGroup?: boolean;
215
215
  getValue?: (row: any, rowIndex: number) => any;
216
216
  getCellProps?: (value: any, row: any, rowIndex: number) => import("./../../grid-component/type").CellProps;
217
+ headerCellProps?: import("./../../grid-component/type").CellProps;
217
218
  getSpanRect?: (value: any, row: any, rowIndex: number) => import("./../../grid-component/type").SpanRect;
218
219
  }[];
219
220
  export declare function sortColumnsByField<T extends ColumnTable>(columns: T[], priorityFields: string[]): T[];
@@ -39,6 +39,7 @@ const TableContainer = props => {
39
39
  minHeight,
40
40
  showToolbar,
41
41
  toolbarItems,
42
+ toolbarMode,
42
43
  actionTemplate,
43
44
  pagination,
44
45
  fullScreen,
@@ -221,8 +222,10 @@ const TableContainer = props => {
221
222
  overflow: 'hidden'
222
223
  }
223
224
  }, /*#__PURE__*/React.createElement(Toolbar, {
224
- items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
225
- mode: 'scroll'
225
+ items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom')
226
+ // mode={'scroll'}
227
+ ,
228
+ mode: toolbarMode
226
229
  })), /*#__PURE__*/React.createElement("div", {
227
230
  style: {
228
231
  display: 'flex',
@@ -90,7 +90,9 @@ const TableContainerEdit = props => {
90
90
  onCellChange,
91
91
  onDataChange,
92
92
  defaultValue,
93
+ showToolbar,
93
94
  toolbarItems,
95
+ toolbarMode,
94
96
  mergedFilterKeys,
95
97
  setMergedFilterKeys,
96
98
  expanded,
@@ -98,7 +100,6 @@ const TableContainerEdit = props => {
98
100
  onBlur,
99
101
  fullScreen,
100
102
  pagination,
101
- showToolbar,
102
103
  actionTemplate,
103
104
  showColumnChoose,
104
105
  height,
@@ -241,6 +242,8 @@ const TableContainerEdit = props => {
241
242
  const [isPasting, setIsPasting] = React.useState(false);
242
243
  // const [isFullScreen] = React.useState(false);
243
244
  const [tableHeight, settableHeight] = React.useState(0);
245
+ const [topToolbarHeight, setTopToolbarHeight] = React.useState(0);
246
+ const [bottomToolbarHeight, setBottomToolbarHeight] = React.useState(0);
244
247
 
245
248
  // const [isAddNewRow, setIsAddNewRow] = React.useState(false)
246
249
 
@@ -641,14 +644,48 @@ const TableContainerEdit = props => {
641
644
  }
642
645
  }, [columnSizingInfo]);
643
646
  React.useEffect(() => {
644
- // const totalHeight = minHeight ?? height
645
647
  const totalHeight = getTableHeight(height, minHeight);
646
648
  if (totalHeight) {
647
- const topHeight = topToolbarRef.current ? topToolbarRef.current.offsetHeight : 0;
648
- const bottomHeight = bottomToolbarRef.current ? bottomToolbarRef.current.offsetHeight : 0;
649
- settableHeight(totalHeight - topHeight - bottomHeight);
649
+ // const topHeight = topToolbarRef.current ? topToolbarRef.current.offsetHeight : 0
650
+ // const bottomHeight = bottomToolbarRef.current ? bottomToolbarRef.current.offsetHeight : 0
651
+
652
+ // settableHeight(totalHeight - topHeight - bottomHeight)
653
+ settableHeight(totalHeight - topToolbarHeight - bottomToolbarHeight);
650
654
  }
651
- }, [id, height, editAble, minHeight, toolbarItems]);
655
+ }, [height, minHeight, topToolbarHeight, bottomToolbarHeight]);
656
+ // }, [height, minHeight])
657
+
658
+ React.useEffect(() => {
659
+ if (!topToolbarRef.current) return;
660
+ const observer = new ResizeObserver(entries => {
661
+ const entry = entries[0];
662
+ // const { top, bottom } = entry.contentRect;
663
+ const {
664
+ clientHeight
665
+ } = entry.target;
666
+ setTopToolbarHeight(clientHeight);
667
+ });
668
+ observer.observe(topToolbarRef.current);
669
+ return () => {
670
+ observer.disconnect();
671
+ };
672
+ }, []);
673
+ React.useEffect(() => {
674
+ if (!bottomToolbarRef.current) return;
675
+ const observer = new ResizeObserver(entries => {
676
+ const entry = entries[0];
677
+ // const { top, bottom } = entry.contentRect;
678
+ const {
679
+ clientHeight
680
+ } = entry.target;
681
+ // setBottomToolbarHeight(top + bottom)
682
+ setBottomToolbarHeight(clientHeight);
683
+ });
684
+ observer.observe(bottomToolbarRef.current);
685
+ return () => {
686
+ observer.disconnect();
687
+ };
688
+ }, []);
652
689
  const {
653
690
  control,
654
691
  handleSubmit,
@@ -1919,7 +1956,10 @@ const TableContainerEdit = props => {
1919
1956
  id: id
1920
1957
  }, (showToolbar !== false || fullScreen !== false || showColumnChoose || title) && /*#__PURE__*/React.createElement("div", {
1921
1958
  ref: topToolbarRef,
1922
- className: classNames(`${prefix}-grid-top-toolbar`, {})
1959
+ className: classNames(`${prefix}-grid-top-toolbar`, {}),
1960
+ style: {
1961
+ transition: 'max-height 0.3s ease'
1962
+ }
1923
1963
  }, /*#__PURE__*/React.createElement("div", {
1924
1964
  style: {
1925
1965
  display: 'flex',
@@ -1940,7 +1980,7 @@ const TableContainerEdit = props => {
1940
1980
  width: '100%'
1941
1981
  },
1942
1982
  items: toolbarItemsTop ?? [],
1943
- mode: 'scroll',
1983
+ mode: toolbarMode,
1944
1984
  onClick: ({}) => {
1945
1985
  setEditingKey('');
1946
1986
  }
@@ -2081,7 +2121,10 @@ const TableContainerEdit = props => {
2081
2121
  fixedLeftColumns: fixedLeftColumns,
2082
2122
  fixedRightColumns: fixedRightColumns
2083
2123
  }))), /*#__PURE__*/React.createElement("div", {
2084
- ref: bottomToolbarRef
2124
+ ref: bottomToolbarRef,
2125
+ style: {
2126
+ transition: 'max-height 0.3s ease'
2127
+ }
2085
2128
  }, toolbarItemsBottom && toolbarItemsBottom.length > 0 && /*#__PURE__*/React.createElement("div", {
2086
2129
  className: classNames('ui-rc-toolbar-bottom', {
2087
2130
  'ui-rc-toolbar-bottom_border-bottom': !pagination || infiniteScroll
@@ -2091,7 +2134,9 @@ const TableContainerEdit = props => {
2091
2134
  width: '100%'
2092
2135
  },
2093
2136
  items: toolbarItemsBottom ?? [],
2094
- mode: 'scroll',
2137
+ mode: toolbarMode
2138
+ // mode={'scroll'}
2139
+ ,
2095
2140
  onClick: ({}) => {
2096
2141
  setEditingKey('');
2097
2142
  }
@@ -1096,7 +1096,7 @@ const TableBodyCellEdit = props => {
1096
1096
  };
1097
1097
  const cellValue = cell.getValue();
1098
1098
  const rowIndex = cell.row.index;
1099
- const fomatedValue = renderValueCell(columnMeta, cellValue, record, rowIndex, colIndex, format, false);
1099
+ const fomatedValue = renderValueCell(columnMeta, cellValue, record, rowIndex, colIndex, format, true);
1100
1100
  return /*#__PURE__*/React.createElement("div", {
1101
1101
  key: cell.id,
1102
1102
  ref: el => {
@@ -1,4 +1,2 @@
1
1
  import InternalTable from './InternalTable';
2
- import type { ColumnsTable, TableProps, ColumnTable, ContextMenuItem } from './../grid-component/type';
3
- export type { ColumnsTable, TableProps, ColumnTable, ContextMenuItem };
4
2
  export default InternalTable;
@@ -1,2 +1,6 @@
1
1
  import InternalTable from "./InternalTable";
2
+ // import type { ColumnsTable, TableProps, ColumnTable, ContextMenuItem} from './../grid-component/type'
3
+
4
+ // export type {ColumnsTable, TableProps, ColumnTable, ContextMenuItem}
5
+
2
6
  export default InternalTable;
@@ -293,7 +293,9 @@ const Grid = props => {
293
293
  style: {
294
294
  minHeight: minHeight ?? undefined,
295
295
  maxHeight: height ?? undefined,
296
- backgroundColor: theme?.backgroundColor ?? undefined
296
+ backgroundColor: theme?.backgroundColor ?? undefined,
297
+ transition: 'max-height 0.3s ease',
298
+ overflow: 'hidden'
297
299
  }
298
300
  }, /*#__PURE__*/React.createElement(DndContext, {
299
301
  collisionDetection: closestCenter,
@@ -38,6 +38,7 @@ const TableContainer = props => {
38
38
  setFilterChange,
39
39
  height,
40
40
  minHeight,
41
+ toolbarMode,
41
42
  showToolbar,
42
43
  toolbarItems,
43
44
  actionTemplate,
@@ -181,7 +182,7 @@ const TableContainer = props => {
181
182
  }
182
183
  }, /*#__PURE__*/React.createElement(Toolbar, {
183
184
  items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
184
- mode: 'scroll'
185
+ mode: toolbarMode
185
186
  })), /*#__PURE__*/React.createElement("div", {
186
187
  style: {
187
188
  display: 'flex',
@@ -2,9 +2,9 @@ import type { TablePipeline } from "./pipeline";
2
2
  import type { Dispatch, SetStateAction } from "react";
3
3
  import React from "react";
4
4
  import './base-table/styles.scss';
5
- import type { TableProps } from "../table-component";
6
5
  import type { BaseTable } from "./base-table/table";
7
6
  import type { VirtualEnum } from "./base-table/interfaces";
7
+ import type { TableProps } from "../grid-component";
8
8
  declare const Grid: React.ForwardRefExoticComponent<Omit<TableProps, "useVirtual"> & {
9
9
  isFullScreen: boolean;
10
10
  setIsFullScreen: Dispatch<SetStateAction<boolean>>;