es-grid-template 1.9.11 → 1.9.13

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.
@@ -5,13 +5,17 @@ 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, revertConvertFilters, sortByType, sumFields } from "../table-component/hook/utils";
8
+ import { addRowIdArray, filterDataByColumns,
9
+ // getInvisibleColumns,
10
+ getVisibleFields, groupArrayByColumns, isTreeArray, revertConvertFilters, sortByType, sumFields } from "../table-component/hook/utils";
9
11
  import { CustomProvider, ConfigProvider } from 'rc-master-ui';
10
12
  import { Modal } from 'antd';
11
13
  import { getLocale, getLocales } from "../locale/useLocale";
12
14
  import { TableContext } from "./useContext";
13
15
  import Grid from "./Grid";
14
16
  import { getParentKeysLarge, getRowsByKeysKeepTreeOrder } from "./utils/selected";
17
+ // import { getInvisibleColumns } from "../group-component/hook/utils"
18
+
15
19
  const InternalTable = props => {
16
20
  const {
17
21
  t,
@@ -119,6 +123,14 @@ const InternalTable = props => {
119
123
  }
120
124
  return undefined;
121
125
  }, [defaultFilter]);
126
+
127
+ // const columnInVisibility = React.useMemo(() => {
128
+ // return getInvisibleColumns(columns)
129
+ // }, [columns])
130
+
131
+ const columnVisibility = React.useMemo(() => {
132
+ return getVisibleFields(columns);
133
+ }, [columns]);
122
134
  const pipeline = useTablePipeline({
123
135
  components: fusion
124
136
  }).input({
@@ -129,7 +141,9 @@ const InternalTable = props => {
129
141
  // .snapshot('flat')
130
142
  .use(features.hiddenColumns({
131
143
  columns,
132
- visibleKeys
144
+ visibleKeys: visibleKeys ?? columnVisibility
145
+ // visibleKeys: ['name']
146
+ // visibleKeys
133
147
  })).use(features.treeSelect({
134
148
  tree: mergedData,
135
149
  value: selectionSettings?.selectedRowKeys,
@@ -179,7 +179,9 @@ export default function TableHeader({
179
179
  const leftFlatCount = flat.left.length;
180
180
  const rightFlatCount = flat.right.length;
181
181
  const thead = headerRenderInfo.leveled.map((wrappedCols, level) => {
182
- const headerCells = wrappedCols.map(wrapped => {
182
+ const headerCells = [];
183
+ let currentColIndex = 0;
184
+ for (const wrapped of wrappedCols) {
183
185
  if (wrapped.type === 'normal') {
184
186
  const {
185
187
  colIndex,
@@ -187,42 +189,43 @@ export default function TableHeader({
187
189
  isLeaf,
188
190
  col
189
191
  } = wrapped;
192
+ if (currentColIndex > colIndex) continue;
190
193
  const headerCellProps = col.headerCellProps ?? {};
194
+ const actualColSpan = headerCellProps.colSpan ?? colSpan;
191
195
  const positionStyle = {};
192
196
  if (colIndex < leftFlatCount) {
193
197
  positionStyle.position = 'sticky';
194
198
  positionStyle.left = stickyLeftMap.get(colIndex);
195
199
  } else if (colIndex >= fullFlatCount - rightFlatCount) {
196
200
  positionStyle.position = 'sticky';
197
- positionStyle.right = stickyRightMap.get(colIndex + colSpan - 1);
201
+ positionStyle.right = stickyRightMap.get(colIndex + actualColSpan - 1);
198
202
  }
199
- return /*#__PURE__*/React.createElement("th", _extends({
203
+ headerCells.push( /*#__PURE__*/React.createElement("th", _extends({
200
204
  key: colIndex
201
205
  }, headerCellProps, {
202
206
  className: cx(Classes.tableHeaderCell, headerCellProps.className, {
203
207
  first: colIndex === 0,
204
- last: colIndex + colSpan === fullFlatCount,
208
+ last: colIndex + actualColSpan === fullFlatCount,
205
209
  'lock-left': colIndex < leftFlatCount,
206
210
  'lock-right': colIndex >= fullFlatCount - rightFlatCount
207
211
  }),
208
- colSpan: colSpan,
212
+ colSpan: actualColSpan,
209
213
  rowSpan: isLeaf ? rowCount - level : undefined,
210
214
  style: {
211
215
  textAlign: col.textAlign,
212
216
  ...headerCellProps.style,
213
217
  ...positionStyle
214
218
  }
215
- }), col.title ?? col.headerText);
219
+ }), col.title ?? col.headerText));
220
+ currentColIndex = colIndex + actualColSpan;
216
221
  } else {
217
222
  if (wrapped.width > 0) {
218
- return /*#__PURE__*/React.createElement("th", {
223
+ headerCells.push( /*#__PURE__*/React.createElement("th", {
219
224
  key: wrapped.blankSide
220
- });
221
- } else {
222
- return null;
225
+ }));
223
226
  }
224
227
  }
225
- });
228
+ }
226
229
  return /*#__PURE__*/React.createElement("tr", {
227
230
  key: level,
228
231
  className: cx(Classes.tableHeaderRow, {
@@ -208,9 +208,9 @@ export declare const fixColumnsLeft: <RecordType>(columns: ColumnTable<RecordTyp
208
208
  ellipsis?: boolean;
209
209
  allowResizing?: boolean;
210
210
  allowSelection?: boolean | ((rowData: RecordType) => boolean);
211
- onCellStyles?: Omit<CSSProperties, "position" | "left" | "right" | "display" | "width" | "minWidth"> | ((cellValue: any, cell: import("@tanstack/react-table").Cell<RecordType, unknown>) => Omit<CSSProperties, "position" | "left" | "right" | "display" | "width" | "minWidth">);
212
- onCellHeaderStyles?: Omit<CSSProperties, "position" | "left" | "right" | "display" | "width" | "minWidth"> | ((cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "position" | "left" | "right" | "display" | "width" | "minWidth">);
213
- onCellFooterStyles?: Omit<CSSProperties, "position" | "left" | "right" | "display" | "width" | "minWidth"> | ((cellValue: any, cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "position" | "left" | "right" | "display" | "width" | "minWidth">);
211
+ onCellStyles?: Omit<CSSProperties, "left" | "right" | "position" | "display" | "minWidth" | "width"> | ((cellValue: any, cell: import("@tanstack/react-table").Cell<RecordType, unknown>) => Omit<CSSProperties, "left" | "right" | "position" | "display" | "minWidth" | "width">);
212
+ onCellHeaderStyles?: Omit<CSSProperties, "left" | "right" | "position" | "display" | "minWidth" | "width"> | ((cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "left" | "right" | "position" | "display" | "minWidth" | "width">);
213
+ onCellFooterStyles?: Omit<CSSProperties, "left" | "right" | "position" | "display" | "minWidth" | "width"> | ((cellValue: any, cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "left" | "right" | "position" | "display" | "minWidth" | "width">);
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;
@@ -128,6 +128,7 @@ export declare function getHiddenParentKeys(columns: any[], parentKeys?: string[
128
128
  export declare function getHiddenParentKeys1(columns: ColumnTable[], parentKeys?: string[]): string[];
129
129
  export declare const getVisibleColumnKeys: (columns: any[]) => string[];
130
130
  export declare const getVisibleColumnKeys1: (columns: any[]) => string[];
131
+ export declare function getVisibleFields(columns: ColumnTable[]): string[];
131
132
  export declare function isObjEqual(obj1: any, obj2: any): boolean;
132
133
  export declare const sortByType: <T>(arr: ColumnTable<T>[]) => ColumnTable<T>[];
133
134
  export declare function convertColumnsToTreeData<T>(columns: ColumnDef<T, any>[], groupColumns?: string[]): TreeDataNode[];
@@ -1953,6 +1953,24 @@ export const getVisibleColumnKeys1 = columns => {
1953
1953
  const allParentKeys = getHiddenParentKeys1(columns);
1954
1954
  return allKeys.filter(item => !allParentKeys.includes(item));
1955
1955
  };
1956
+ export function getVisibleFields(columns) {
1957
+ const result = [];
1958
+ function traverse(nodes) {
1959
+ for (const node of nodes) {
1960
+ // nếu visible không phải false thì lấy field
1961
+ if (node.visible !== false) {
1962
+ result.push(node.field);
1963
+ }
1964
+
1965
+ // nếu có children thì duyệt tiếp
1966
+ if (node.children?.length) {
1967
+ traverse(node.children);
1968
+ }
1969
+ }
1970
+ }
1971
+ traverse(columns);
1972
+ return result;
1973
+ }
1956
1974
  export function isObjEqual(obj1, obj2) {
1957
1975
  // Trường hợp tham chiếu bằng nhau
1958
1976
  if (obj1 === obj2) return true;
@@ -830,7 +830,7 @@ $cell-index-focus-bg-Dark: #E6EFFD !default;
830
830
 
831
831
  .ui-rc-toolbar-bottom {
832
832
  position: relative;
833
- padding: .25rem 1rem;
833
+ padding: .25rem 0rem;
834
834
  background-color: #ffffff;
835
835
 
836
836
  // &::before {
@@ -294,8 +294,8 @@ const Grid = props => {
294
294
  minHeight: minHeight ?? undefined,
295
295
  maxHeight: height ?? undefined,
296
296
  backgroundColor: theme?.backgroundColor ?? undefined,
297
- transition: 'max-height 0.3s ease',
298
- overflow: 'hidden'
297
+ transition: 'max-height 0.3s ease'
298
+ // overflow: 'hidden'
299
299
  }
300
300
  }, /*#__PURE__*/React.createElement(DndContext, {
301
301
  collisionDetection: closestCenter,
@@ -21,6 +21,8 @@ var _Grid = _interopRequireDefault(require("./Grid"));
21
21
  var _selected = require("./utils/selected");
22
22
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
23
23
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
24
+ // import { getInvisibleColumns } from "../group-component/hook/utils"
25
+
24
26
  const InternalTable = props => {
25
27
  const {
26
28
  t,
@@ -128,6 +130,14 @@ const InternalTable = props => {
128
130
  }
129
131
  return undefined;
130
132
  }, [defaultFilter]);
133
+
134
+ // const columnInVisibility = React.useMemo(() => {
135
+ // return getInvisibleColumns(columns)
136
+ // }, [columns])
137
+
138
+ const columnVisibility = _react.default.useMemo(() => {
139
+ return (0, _utils.getVisibleFields)(columns);
140
+ }, [columns]);
131
141
  const pipeline = (0, _pipeline.useTablePipeline)({
132
142
  components: fusion
133
143
  }).input({
@@ -138,7 +148,9 @@ const InternalTable = props => {
138
148
  // .snapshot('flat')
139
149
  .use(_pipeline.features.hiddenColumns({
140
150
  columns,
141
- visibleKeys
151
+ visibleKeys: visibleKeys ?? columnVisibility
152
+ // visibleKeys: ['name']
153
+ // visibleKeys
142
154
  })).use(_pipeline.features.treeSelect({
143
155
  tree: mergedData,
144
156
  value: selectionSettings?.selectedRowKeys,
@@ -186,7 +186,9 @@ function TableHeader({
186
186
  const leftFlatCount = flat.left.length;
187
187
  const rightFlatCount = flat.right.length;
188
188
  const thead = headerRenderInfo.leveled.map((wrappedCols, level) => {
189
- const headerCells = wrappedCols.map(wrapped => {
189
+ const headerCells = [];
190
+ let currentColIndex = 0;
191
+ for (const wrapped of wrappedCols) {
190
192
  if (wrapped.type === 'normal') {
191
193
  const {
192
194
  colIndex,
@@ -194,42 +196,43 @@ function TableHeader({
194
196
  isLeaf,
195
197
  col
196
198
  } = wrapped;
199
+ if (currentColIndex > colIndex) continue;
197
200
  const headerCellProps = col.headerCellProps ?? {};
201
+ const actualColSpan = headerCellProps.colSpan ?? colSpan;
198
202
  const positionStyle = {};
199
203
  if (colIndex < leftFlatCount) {
200
204
  positionStyle.position = 'sticky';
201
205
  positionStyle.left = stickyLeftMap.get(colIndex);
202
206
  } else if (colIndex >= fullFlatCount - rightFlatCount) {
203
207
  positionStyle.position = 'sticky';
204
- positionStyle.right = stickyRightMap.get(colIndex + colSpan - 1);
208
+ positionStyle.right = stickyRightMap.get(colIndex + actualColSpan - 1);
205
209
  }
206
- return /*#__PURE__*/_react.default.createElement("th", (0, _extends2.default)({
210
+ headerCells.push( /*#__PURE__*/_react.default.createElement("th", (0, _extends2.default)({
207
211
  key: colIndex
208
212
  }, headerCellProps, {
209
213
  className: (0, _classnames.default)(_styles.Classes.tableHeaderCell, headerCellProps.className, {
210
214
  first: colIndex === 0,
211
- last: colIndex + colSpan === fullFlatCount,
215
+ last: colIndex + actualColSpan === fullFlatCount,
212
216
  'lock-left': colIndex < leftFlatCount,
213
217
  'lock-right': colIndex >= fullFlatCount - rightFlatCount
214
218
  }),
215
- colSpan: colSpan,
219
+ colSpan: actualColSpan,
216
220
  rowSpan: isLeaf ? rowCount - level : undefined,
217
221
  style: {
218
222
  textAlign: col.textAlign,
219
223
  ...headerCellProps.style,
220
224
  ...positionStyle
221
225
  }
222
- }), col.title ?? col.headerText);
226
+ }), col.title ?? col.headerText));
227
+ currentColIndex = colIndex + actualColSpan;
223
228
  } else {
224
229
  if (wrapped.width > 0) {
225
- return /*#__PURE__*/_react.default.createElement("th", {
230
+ headerCells.push( /*#__PURE__*/_react.default.createElement("th", {
226
231
  key: wrapped.blankSide
227
- });
228
- } else {
229
- return null;
232
+ }));
230
233
  }
231
234
  }
232
- });
235
+ }
233
236
  return /*#__PURE__*/_react.default.createElement("tr", {
234
237
  key: level,
235
238
  className: (0, _classnames.default)(_styles.Classes.tableHeaderRow, {
@@ -128,6 +128,7 @@ export declare function getHiddenParentKeys(columns: any[], parentKeys?: string[
128
128
  export declare function getHiddenParentKeys1(columns: ColumnTable[], parentKeys?: string[]): string[];
129
129
  export declare const getVisibleColumnKeys: (columns: any[]) => string[];
130
130
  export declare const getVisibleColumnKeys1: (columns: any[]) => string[];
131
+ export declare function getVisibleFields(columns: ColumnTable[]): string[];
131
132
  export declare function isObjEqual(obj1: any, obj2: any): boolean;
132
133
  export declare const sortByType: <T>(arr: ColumnTable<T>[]) => ColumnTable<T>[];
133
134
  export declare function convertColumnsToTreeData<T>(columns: ColumnDef<T, any>[], groupColumns?: string[]): TreeDataNode[];
@@ -40,6 +40,7 @@ exports.getInvisibleColumns = getInvisibleColumns;
40
40
  exports.getNewItemsOnly = exports.getLastSelectCell = void 0;
41
41
  exports.getRowIdsBetween = getRowIdsBetween;
42
42
  exports.getVisibleColumnKeys1 = exports.getVisibleColumnKeys = exports.getTypeFilter = exports.getTableHeight = exports.getSelectedCellMatrix = void 0;
43
+ exports.getVisibleFields = getVisibleFields;
43
44
  exports.groupArrayByColumns = groupArrayByColumns;
44
45
  exports.isColor = void 0;
45
46
  exports.isDateString = isDateString;
@@ -62,8 +63,7 @@ exports.sumSize = void 0;
62
63
  exports.toggleRowAndChildren = toggleRowAndChildren;
63
64
  exports.updateArrayByKey = exports.unFlattenData = void 0;
64
65
  exports.updateColumnWidthsRecursive = updateColumnWidthsRecursive;
65
- exports.updateColumns1 = void 0;
66
- exports.updateColumnsByGroup = void 0;
66
+ exports.updateColumnsByGroup = exports.updateColumns1 = void 0;
67
67
  exports.updateOrInsert = updateOrInsert;
68
68
  exports.updateWidthsByOther = updateWidthsByOther;
69
69
  var _uuid = require("uuid");
@@ -2074,6 +2074,24 @@ const getVisibleColumnKeys1 = columns => {
2074
2074
  return allKeys.filter(item => !allParentKeys.includes(item));
2075
2075
  };
2076
2076
  exports.getVisibleColumnKeys1 = getVisibleColumnKeys1;
2077
+ function getVisibleFields(columns) {
2078
+ const result = [];
2079
+ function traverse(nodes) {
2080
+ for (const node of nodes) {
2081
+ // nếu visible không phải false thì lấy field
2082
+ if (node.visible !== false) {
2083
+ result.push(node.field);
2084
+ }
2085
+
2086
+ // nếu có children thì duyệt tiếp
2087
+ if (node.children?.length) {
2088
+ traverse(node.children);
2089
+ }
2090
+ }
2091
+ }
2092
+ traverse(columns);
2093
+ return result;
2094
+ }
2077
2095
  function isObjEqual(obj1, obj2) {
2078
2096
  // Trường hợp tham chiếu bằng nhau
2079
2097
  if (obj1 === obj2) return true;
@@ -830,7 +830,7 @@ $cell-index-focus-bg-Dark: #E6EFFD !default;
830
830
 
831
831
  .ui-rc-toolbar-bottom {
832
832
  position: relative;
833
- padding: .25rem 1rem;
833
+ padding: .25rem 0rem;
834
834
  background-color: #ffffff;
835
835
 
836
836
  // &::before {
@@ -299,8 +299,8 @@ const Grid = props => {
299
299
  minHeight: minHeight ?? undefined,
300
300
  maxHeight: height ?? undefined,
301
301
  backgroundColor: theme?.backgroundColor ?? undefined,
302
- transition: 'max-height 0.3s ease',
303
- overflow: 'hidden'
302
+ transition: 'max-height 0.3s ease'
303
+ // overflow: 'hidden'
304
304
  }
305
305
  }, /*#__PURE__*/_react.default.createElement(_core.DndContext, {
306
306
  collisionDetection: _core.closestCenter,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-grid-template",
3
- "version": "1.9.11",
3
+ "version": "1.9.13",
4
4
  "description": "es-grid-template",
5
5
  "keywords": [
6
6
  "react",
@@ -66,7 +66,7 @@
66
66
  "rc-checkbox": "^3.5.0",
67
67
  "rc-dropdown": "^4.2.1",
68
68
  "rc-field-form": "^2.6.0",
69
- "rc-master-ui": "1.1.53",
69
+ "rc-master-ui": "1.1.58",
70
70
  "rc-select": "^14.16.3",
71
71
  "rc-tooltip": "^6.3.0",
72
72
  "rc-tree": "^5.10.1",