es-grid-template 1.7.23 → 1.7.25

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 (163) hide show
  1. package/es/index.d.ts +1 -0
  2. package/es/index.js +3 -1
  3. package/es/table-component/ColumnsChoose.d.ts +13 -0
  4. package/es/table-component/ColumnsChoose.js +206 -0
  5. package/es/table-component/ContextMenu.d.ts +20 -0
  6. package/es/table-component/ContextMenu.js +75 -0
  7. package/es/table-component/InternalTable.d.ts +9 -0
  8. package/es/table-component/InternalTable.js +308 -0
  9. package/es/table-component/TableContainer.d.ts +31 -0
  10. package/es/table-component/TableContainer.js +249 -0
  11. package/es/table-component/TableContainerEdit.d.ts +31 -0
  12. package/es/table-component/TableContainerEdit.js +1301 -0
  13. package/es/table-component/body/EditableCell.d.ts +16 -0
  14. package/es/table-component/body/EditableCell.js +1039 -0
  15. package/es/table-component/body/TableBody.d.ts +19 -0
  16. package/es/table-component/body/TableBody.js +64 -0
  17. package/es/table-component/body/TableBodyCell.d.ts +12 -0
  18. package/es/table-component/body/TableBodyCell.js +149 -0
  19. package/es/table-component/body/TableBodyCellEdit.d.ts +16 -0
  20. package/es/table-component/body/TableBodyCellEdit.js +931 -0
  21. package/es/table-component/body/TableBodyRow.d.ts +21 -0
  22. package/es/table-component/body/TableBodyRow.js +151 -0
  23. package/es/table-component/components/ControlCheckbox.d.ts +13 -0
  24. package/es/table-component/components/ControlCheckbox.js +84 -0
  25. package/es/table-component/components/EditForm/EditForm.d.ts +27 -0
  26. package/es/table-component/components/EditForm/EditForm.js +395 -0
  27. package/es/table-component/components/EditForm/index.d.ts +1 -0
  28. package/es/table-component/components/EditForm/index.js +1 -0
  29. package/es/table-component/components/InputControl/InputControl.d.ts +27 -0
  30. package/es/table-component/components/InputControl/InputControl.js +121 -0
  31. package/es/table-component/components/InputControl/index.d.ts +1 -0
  32. package/es/table-component/components/InputControl/index.js +1 -0
  33. package/es/table-component/components/async-select/index.d.ts +11 -0
  34. package/es/table-component/components/async-select/index.js +41 -0
  35. package/es/table-component/components/async-table-select/index.d.ts +11 -0
  36. package/es/table-component/components/async-table-select/index.js +44 -0
  37. package/es/table-component/components/checkbox-control/index.d.ts +13 -0
  38. package/es/table-component/components/checkbox-control/index.js +40 -0
  39. package/es/table-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
  40. package/es/table-component/components/checkbox-filter/CheckboxFilter.js +240 -0
  41. package/es/table-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
  42. package/es/table-component/components/checkbox-filter/FilterSearch.js +36 -0
  43. package/es/table-component/components/command/Command.d.ts +10 -0
  44. package/es/table-component/components/command/Command.js +33 -0
  45. package/es/table-component/components/number/index.d.ts +10 -0
  46. package/es/table-component/components/number/index.js +42 -0
  47. package/es/table-component/components/number-range/index.d.ts +11 -0
  48. package/es/table-component/components/number-range/index.js +66 -0
  49. package/es/table-component/features/operator.d.ts +24 -0
  50. package/es/table-component/features/operator.js +62 -0
  51. package/es/table-component/footer/TableFooter.d.ts +13 -0
  52. package/es/table-component/footer/TableFooter.js +33 -0
  53. package/es/table-component/footer/TableFooterCell.d.ts +10 -0
  54. package/es/table-component/footer/TableFooterCell.js +66 -0
  55. package/es/table-component/footer/TableFooterRow.d.ts +14 -0
  56. package/es/table-component/footer/TableFooterRow.js +73 -0
  57. package/es/table-component/header/TableHead.d.ts +14 -0
  58. package/es/table-component/header/TableHead.js +60 -0
  59. package/es/table-component/header/TableHeadCell.d.ts +14 -0
  60. package/es/table-component/header/TableHeadCell.js +343 -0
  61. package/es/table-component/header/TableHeadRow.d.ts +16 -0
  62. package/es/table-component/header/TableHeadRow.js +76 -0
  63. package/es/table-component/header/renderFilter.d.ts +20 -0
  64. package/es/table-component/header/renderFilter.js +281 -0
  65. package/es/table-component/hook/constant.d.ts +73 -0
  66. package/es/table-component/hook/constant.js +240 -0
  67. package/es/table-component/hook/useColumns.d.ts +9 -0
  68. package/es/table-component/hook/useColumns.js +169 -0
  69. package/es/table-component/hook/useFilterOperator.d.ts +7 -0
  70. package/es/table-component/hook/useFilterOperator.js +33 -0
  71. package/es/table-component/hook/utils.d.ts +133 -0
  72. package/es/table-component/hook/utils.js +1870 -0
  73. package/es/table-component/index.d.ts +5 -0
  74. package/es/table-component/index.js +2 -0
  75. package/es/table-component/style.scss +1129 -0
  76. package/es/table-component/table/Grid.d.ts +24 -0
  77. package/es/table-component/table/Grid.js +234 -0
  78. package/es/table-component/type.d.ts +513 -0
  79. package/es/table-component/type.js +1 -0
  80. package/es/table-component/useContext.d.ts +74 -0
  81. package/es/table-component/useContext.js +15 -0
  82. package/lib/index.d.ts +1 -0
  83. package/lib/index.js +8 -1
  84. package/lib/table-component/ColumnsChoose.d.ts +13 -0
  85. package/lib/table-component/ColumnsChoose.js +216 -0
  86. package/lib/table-component/ContextMenu.d.ts +20 -0
  87. package/lib/table-component/ContextMenu.js +85 -0
  88. package/lib/table-component/InternalTable.d.ts +9 -0
  89. package/lib/table-component/InternalTable.js +313 -0
  90. package/lib/table-component/TableContainer.d.ts +31 -0
  91. package/lib/table-component/TableContainer.js +257 -0
  92. package/lib/table-component/TableContainerEdit.d.ts +31 -0
  93. package/lib/table-component/TableContainerEdit.js +1310 -0
  94. package/lib/table-component/body/EditableCell.d.ts +16 -0
  95. package/lib/table-component/body/EditableCell.js +1041 -0
  96. package/lib/table-component/body/TableBody.d.ts +19 -0
  97. package/lib/table-component/body/TableBody.js +72 -0
  98. package/lib/table-component/body/TableBodyCell.d.ts +12 -0
  99. package/lib/table-component/body/TableBodyCell.js +158 -0
  100. package/lib/table-component/body/TableBodyCellEdit.d.ts +16 -0
  101. package/lib/table-component/body/TableBodyCellEdit.js +938 -0
  102. package/lib/table-component/body/TableBodyRow.d.ts +21 -0
  103. package/lib/table-component/body/TableBodyRow.js +158 -0
  104. package/lib/table-component/components/ControlCheckbox.d.ts +13 -0
  105. package/lib/table-component/components/ControlCheckbox.js +92 -0
  106. package/lib/table-component/components/EditForm/EditForm.d.ts +27 -0
  107. package/lib/table-component/components/EditForm/EditForm.js +406 -0
  108. package/lib/table-component/components/EditForm/index.d.ts +1 -0
  109. package/lib/table-component/components/EditForm/index.js +16 -0
  110. package/lib/table-component/components/InputControl/InputControl.d.ts +27 -0
  111. package/lib/table-component/components/InputControl/InputControl.js +131 -0
  112. package/lib/table-component/components/InputControl/index.d.ts +1 -0
  113. package/lib/table-component/components/InputControl/index.js +16 -0
  114. package/lib/table-component/components/async-select/index.d.ts +11 -0
  115. package/lib/table-component/components/async-select/index.js +49 -0
  116. package/lib/table-component/components/async-table-select/index.d.ts +11 -0
  117. package/lib/table-component/components/async-table-select/index.js +53 -0
  118. package/lib/table-component/components/checkbox-control/index.d.ts +13 -0
  119. package/lib/table-component/components/checkbox-control/index.js +48 -0
  120. package/lib/table-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
  121. package/lib/table-component/components/checkbox-filter/CheckboxFilter.js +249 -0
  122. package/lib/table-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
  123. package/lib/table-component/components/checkbox-filter/FilterSearch.js +44 -0
  124. package/lib/table-component/components/command/Command.d.ts +10 -0
  125. package/lib/table-component/components/command/Command.js +42 -0
  126. package/lib/table-component/components/number/index.d.ts +10 -0
  127. package/lib/table-component/components/number/index.js +50 -0
  128. package/lib/table-component/components/number-range/index.d.ts +11 -0
  129. package/lib/table-component/components/number-range/index.js +74 -0
  130. package/lib/table-component/features/operator.d.ts +24 -0
  131. package/lib/table-component/features/operator.js +67 -0
  132. package/lib/table-component/footer/TableFooter.d.ts +13 -0
  133. package/lib/table-component/footer/TableFooter.js +42 -0
  134. package/lib/table-component/footer/TableFooterCell.d.ts +10 -0
  135. package/lib/table-component/footer/TableFooterCell.js +76 -0
  136. package/lib/table-component/footer/TableFooterRow.d.ts +14 -0
  137. package/lib/table-component/footer/TableFooterRow.js +81 -0
  138. package/lib/table-component/header/TableHead.d.ts +14 -0
  139. package/lib/table-component/header/TableHead.js +69 -0
  140. package/lib/table-component/header/TableHeadCell.d.ts +14 -0
  141. package/lib/table-component/header/TableHeadCell.js +352 -0
  142. package/lib/table-component/header/TableHeadRow.d.ts +16 -0
  143. package/lib/table-component/header/TableHeadRow.js +84 -0
  144. package/lib/table-component/header/renderFilter.d.ts +20 -0
  145. package/lib/table-component/header/renderFilter.js +291 -0
  146. package/lib/table-component/hook/constant.d.ts +73 -0
  147. package/lib/table-component/hook/constant.js +247 -0
  148. package/lib/table-component/hook/useColumns.d.ts +9 -0
  149. package/lib/table-component/hook/useColumns.js +180 -0
  150. package/lib/table-component/hook/useFilterOperator.d.ts +7 -0
  151. package/lib/table-component/hook/useFilterOperator.js +40 -0
  152. package/lib/table-component/hook/utils.d.ts +133 -0
  153. package/lib/table-component/hook/utils.js +1969 -0
  154. package/lib/table-component/index.d.ts +5 -0
  155. package/lib/table-component/index.js +9 -0
  156. package/lib/table-component/style.scss +1129 -0
  157. package/lib/table-component/table/Grid.d.ts +24 -0
  158. package/lib/table-component/table/Grid.js +236 -0
  159. package/lib/table-component/type.d.ts +513 -0
  160. package/lib/table-component/type.js +5 -0
  161. package/lib/table-component/useContext.d.ts +74 -0
  162. package/lib/table-component/useContext.js +21 -0
  163. package/package.json +4 -2
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.OperatorFeature = void 0;
7
+ var _reactTable = require("@tanstack/react-table");
8
+ // TypeScript setup for our new feature with all of the same type-safety as stock TanStack Table features
9
+
10
+ // define types for our new feature's table options
11
+
12
+ // Define types for our new feature's table APIs
13
+ // export interface OperatorInstance {
14
+ // setDensity: (updater: Updater<OpetorState>) => void
15
+
16
+ // toggleDensity: (value?: OpetorState) => void
17
+ // }
18
+
19
+ // Use declaration merging to add our new feature APIs and state types to TanStack Table's existing types.
20
+
21
+ const OperatorFeature = exports.OperatorFeature = {
22
+ // define the new feature's initial state
23
+ getInitialState: state => {
24
+ return {
25
+ operator: [],
26
+ ...state
27
+ };
28
+ },
29
+ // define the new feature's default options
30
+ getDefaultOptions: table => {
31
+ return {
32
+ enableOperator: true,
33
+ onColumnOperatorChange: (0, _reactTable.makeStateUpdater)('operator', table)
34
+ };
35
+ },
36
+ // if you need to add a default column definition...
37
+ // getDefaultColumnDef: <TData extends RowData>(): Partial<ColumnDef<TData>> => {
38
+ // return { meta: {} } //use meta instead of directly adding to the columnDef to avoid typescript stuff that's hard to workaround
39
+ // },
40
+
41
+ // define the new feature's table instance methods
42
+
43
+ // if you need to add row instance APIs...
44
+ // createRow: <TData extends RowData>(row, table): void => {},
45
+ // if you need to add cell instance APIs...
46
+ // createCell: <TData extends RowData>(cell, column, row, table): void => {},
47
+ // if you need to add column instance APIs...
48
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
49
+ createColumn: (column, table) => {
50
+ column.getFilterOperator = () => {
51
+ return table.getState().operator?.find(op => op.id === column.id)?.operator ?? undefined;
52
+ };
53
+ column.setFilterOperator = updater => {
54
+ const safeUpdater = old => {
55
+ const others = old.filter(op => op.id !== column.id);
56
+ return [...others, {
57
+ id: column.id,
58
+ operator: updater
59
+ }];
60
+ };
61
+ return table.options.onColumnOperatorChange?.(safeUpdater);
62
+ };
63
+ }
64
+
65
+ // if you need to add header instance APIs...
66
+ // createHeader: <TData extends RowData>(header, table): void => {},
67
+ };
@@ -0,0 +1,13 @@
1
+ import type { Column, Table } from "@tanstack/react-table";
2
+ import type { Virtualizer } from "@tanstack/react-virtual";
3
+ import React from "react";
4
+ interface TableFooterProps<T> {
5
+ columnVirtualizer: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
6
+ table: Table<T>;
7
+ virtualPaddingLeft: number | undefined;
8
+ virtualPaddingRight: number | undefined;
9
+ fixedLeftColumns: Column<T, unknown>[];
10
+ fixedRightColumns: Column<T, unknown>[];
11
+ }
12
+ declare const TableFooter: <RecordType extends object>({ columnVirtualizer, table, virtualPaddingLeft, virtualPaddingRight, ...rest }: TableFooterProps<RecordType>) => React.JSX.Element;
13
+ export default TableFooter;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _TableFooterRow = _interopRequireDefault(require("./TableFooterRow"));
10
+ var _useContext = require("../useContext");
11
+ var _react = _interopRequireWildcard(require("react"));
12
+ 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); }
13
+ 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; }
14
+ const TableFooter = ({
15
+ columnVirtualizer,
16
+ table,
17
+ virtualPaddingLeft,
18
+ virtualPaddingRight,
19
+ ...rest
20
+ }) => {
21
+ const {
22
+ prefix
23
+ } = (0, _react.useContext)(_useContext.TableContext);
24
+ return /*#__PURE__*/_react.default.createElement("tfoot", {
25
+ className: `${prefix}-grid-tfoot`,
26
+ style: {
27
+ display: "grid",
28
+ position: "sticky",
29
+ bottom: 0,
30
+ zIndex: 1
31
+ }
32
+ }, /*#__PURE__*/_react.default.createElement(_TableFooterRow.default, (0, _extends2.default)({
33
+ table: table,
34
+ columnVirtualizer: columnVirtualizer,
35
+ headerGroup: table.getHeaderGroups()[table.getHeaderGroups().length - 1]
36
+ // key={headerGroup.id}
37
+ ,
38
+ virtualPaddingLeft: virtualPaddingLeft,
39
+ virtualPaddingRight: virtualPaddingRight
40
+ }, rest)));
41
+ };
42
+ var _default = exports.default = TableFooter;
@@ -0,0 +1,10 @@
1
+ import type { Header } from "@tanstack/react-table";
2
+ import type { VirtualItem, Virtualizer } from "@tanstack/react-virtual";
3
+ import React from "react";
4
+ interface TableFooterCellProps<T> {
5
+ columnVirtualizer?: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
6
+ header: Header<T, unknown>;
7
+ column: VirtualItem;
8
+ }
9
+ declare const TableFooterCell: <RecordType extends object>({ header }: TableFooterCellProps<RecordType>) => React.JSX.Element;
10
+ export default TableFooterCell;
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _utils = require("../hook/utils");
10
+ var _useContext = require("../useContext");
11
+ var _classnames = _interopRequireDefault(require("classnames"));
12
+ var _hooks = require("../../grid-component/hooks");
13
+ var _reactNumericComponent = require("react-numeric-component");
14
+ 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); }
15
+ 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; }
16
+ // import type { Person } from "../makeData";
17
+
18
+ // import type { Person } from "../../tanstack-table/makeData";
19
+
20
+ const TableFooterCell = ({
21
+ header
22
+ }) => {
23
+ const isPinned = header.column.getIsPinned();
24
+ const isLastLeftPinnedColumn = isPinned === 'left' && header.column.getIsLastColumn('left');
25
+ const isFirstRightPinnedColumn = isPinned === 'right' && header.column.getIsFirstColumn('right');
26
+ const {
27
+ prefix,
28
+ format,
29
+ dataSource
30
+ } = (0, _react.useContext)(_useContext.TableContext);
31
+ const col = header.column.columnDef.meta ?? {};
32
+ const colFormat = typeof col.format === 'function' ? col.format({}) : col.format;
33
+ const cellFormat = (0, _utils.getFormat)(colFormat, format);
34
+ const thousandSeparator = cellFormat?.thousandSeparator;
35
+ const decimalSeparator = cellFormat?.decimalSeparator;
36
+
37
+ // const dec = (col.format?.decimalScale || col.format?.decimalScale === 0) ? col.format?.decimalScale : format?.decimalScale
38
+ const dec = cellFormat?.decimalScale;
39
+
40
+ // const sumValue = col.type === 'number' ? sumDataByField(filterDataByColumns4(dataSource, filterStates) as any[], col?.key as string) : 0
41
+ const sumValue = col.type === 'number' ? (0, _hooks.sumByField)(dataSource, col?.field) : 0;
42
+ const value = !(0, _utils.isEmpty)(sumValue) ? dec || dec === 0 ? parseFloat(Number(sumValue).toFixed(dec)).toString() : sumValue.toString() : '0';
43
+ const cellValue = col.type === 'number' && col.isSummary !== false ? value : '';
44
+ const numberValue = Number(value);
45
+ const numericFormatProps = {
46
+ thousandSeparator: (0, _utils.checkThousandSeparator)(thousandSeparator, decimalSeparator),
47
+ decimalSeparator: (0, _utils.checkDecimalSeparator)(thousandSeparator, decimalSeparator),
48
+ allowNegative: cellFormat?.allowNegative ?? false,
49
+ prefix: cellFormat?.prefix,
50
+ suffix: cellFormat?.suffix,
51
+ decimalScale: dec,
52
+ fixedDecimalScale: cellFormat?.fixedDecimalScale ?? false
53
+ };
54
+ return /*#__PURE__*/_react.default.createElement("td", {
55
+ // ref={el => {
56
+ // if (el) columnVirtualizer.measureElement(el)
57
+ // }}
58
+ // data-index={header.id}
59
+
60
+ className: (0, _classnames.default)(`${prefix}-grid-cell`, {
61
+ // [`${prefix}-grid-cell-ellipsis`]:!wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header')),
62
+ // [`${prefix}-grid-cell-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header'),
63
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
64
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn
65
+ }),
66
+ key: header.id,
67
+ colSpan: header.colSpan,
68
+ style: {
69
+ display: 'flex',
70
+ ...(0, _utils.getCommonPinningStyles)(header.column),
71
+ width: header?.getSize() ?? header.column.getSize(),
72
+ backgroundColor: "#fafafa"
73
+ }
74
+ }, header.column.id !== "id" && header.column.id !== "selection_column" ? /*#__PURE__*/_react.default.createElement("span", null, col.summaryTemplate ? col.summaryTemplate(numberValue, col.field) : (0, _reactNumericComponent.numericFormatter)(cellValue, numericFormatProps)) : '');
75
+ };
76
+ var _default = exports.default = TableFooterCell;
@@ -0,0 +1,14 @@
1
+ import type { Column, HeaderGroup, Table } from "@tanstack/react-table";
2
+ import type { Virtualizer } from "@tanstack/react-virtual";
3
+ import React from "react";
4
+ interface TableFooterRowProps<T> {
5
+ table: Table<T>;
6
+ columnVirtualizer: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
7
+ headerGroup: HeaderGroup<T>;
8
+ virtualPaddingLeft: number | undefined;
9
+ virtualPaddingRight: number | undefined;
10
+ fixedLeftColumns: Column<T, unknown>[];
11
+ fixedRightColumns: Column<T, unknown>[];
12
+ }
13
+ declare const TableFooterRow: <RecordType extends object>({ table, headerGroup, virtualPaddingLeft, virtualPaddingRight, fixedLeftColumns, fixedRightColumns, columnVirtualizer }: TableFooterRowProps<RecordType>) => React.JSX.Element;
14
+ export default TableFooterRow;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _TableFooterCell = _interopRequireDefault(require("./TableFooterCell"));
9
+ var _react = _interopRequireDefault(require("react"));
10
+ // import type { Person } from "../makeData";
11
+
12
+ // import type { Person } from "../../tanstack-table/makeData";
13
+ // import TableHeadCell from "./TableHeadCell";
14
+
15
+ const TableFooterRow = ({
16
+ table,
17
+ // columnVirtualizer,
18
+ headerGroup,
19
+ virtualPaddingLeft,
20
+ virtualPaddingRight,
21
+ fixedLeftColumns,
22
+ fixedRightColumns,
23
+ // virtualColumns,
24
+ columnVirtualizer
25
+ }) => {
26
+ const virtualColumns = columnVirtualizer.getVirtualItems();
27
+ return /*#__PURE__*/_react.default.createElement("tr", {
28
+ // data-index={headerGroup.id}
29
+ key: headerGroup.id,
30
+ style: {
31
+ display: "flex",
32
+ width: "100%",
33
+ borderBottom: "1px solid #e0e0e0",
34
+ borderTop: "1px solid #e0e0e0",
35
+ height: 37
36
+ }
37
+ }, fixedLeftColumns.length > 0 ? fixedLeftColumns.map(column => {
38
+ return /*#__PURE__*/_react.default.createElement(_TableFooterCell.default, {
39
+ columnVirtualizer: columnVirtualizer,
40
+ key: column.id,
41
+ header: headerGroup.headers.find(h => h.column.id === column.id),
42
+ column: column
43
+ });
44
+ }) : null, virtualPaddingLeft ? /*#__PURE__*/_react.default.createElement("td", {
45
+ className: "",
46
+ style: {
47
+ display: "flex",
48
+ width: virtualPaddingLeft
49
+ }
50
+ }) : null, virtualColumns.map(virtualColumn => {
51
+ const header = headerGroup.headers[virtualColumn.index];
52
+ const isFixed = table.getState().columnPinning.left?.includes(header.column.id) || table.getState().columnPinning.right?.includes(header.column.id);
53
+ // const isFixed = table.getState().columnPinning.left?.includes(header.column.id)
54
+
55
+ if (header && !isFixed) {
56
+ return /*#__PURE__*/_react.default.createElement(_TableFooterCell.default, {
57
+ key: header.id,
58
+ header: header,
59
+ column: virtualColumn,
60
+ columnVirtualizer: columnVirtualizer
61
+ });
62
+ }
63
+ return null;
64
+ }),
65
+ //fake empty column to the right for virtualization scroll padding
66
+ fixedRightColumns.length > 0 ? fixedRightColumns.map(column => /*#__PURE__*/_react.default.createElement(_TableFooterCell.default, {
67
+ key: column.id,
68
+ header: headerGroup.headers.find(h => h.column.id === column.id),
69
+ column: column
70
+ })) : null, virtualPaddingRight ?
71
+ /*#__PURE__*/
72
+ //fake empty column to the right for virtualization scroll padding
73
+ _react.default.createElement("td", {
74
+ className: "",
75
+ style: {
76
+ display: "flex",
77
+ width: virtualPaddingRight
78
+ }
79
+ }) : null);
80
+ };
81
+ var _default = exports.default = TableFooterRow;
@@ -0,0 +1,14 @@
1
+ import type { Column, Table } from '@tanstack/react-table';
2
+ import { type Virtualizer } from '@tanstack/react-virtual';
3
+ import React from 'react';
4
+ interface TableHeadProps<T> {
5
+ tableContainerRef: React.RefObject<HTMLDivElement>;
6
+ columnVirtualizer: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
7
+ table: Table<T>;
8
+ virtualPaddingLeft: number | undefined;
9
+ virtualPaddingRight: number | undefined;
10
+ fixedLeftColumns: Column<T, unknown>[];
11
+ fixedRightColumns: Column<T, unknown>[];
12
+ }
13
+ declare const TableHead: <RecordType extends object>({ tableContainerRef, columnVirtualizer, table, virtualPaddingLeft, virtualPaddingRight, fixedLeftColumns, fixedRightColumns }: TableHeadProps<RecordType>) => React.JSX.Element;
14
+ export default TableHead;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _reactVirtual = require("@tanstack/react-virtual");
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _useContext = require("../useContext");
11
+ var _TableHeadRow = _interopRequireDefault(require("./TableHeadRow"));
12
+ 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); }
13
+ 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; }
14
+ const TableHead = ({
15
+ tableContainerRef,
16
+ columnVirtualizer,
17
+ table,
18
+ virtualPaddingLeft,
19
+ virtualPaddingRight,
20
+ fixedLeftColumns,
21
+ fixedRightColumns
22
+ }) => {
23
+ const {
24
+ prefix
25
+ } = (0, _react.useContext)(_useContext.TableContext);
26
+ const rowVirtualizer = (0, _reactVirtual.useVirtualizer)({
27
+ count: table.getHeaderGroups().length,
28
+ estimateSize: () => 34,
29
+ //estimate row height for accurate scrollbar dragging
30
+ getScrollElement: () => tableContainerRef.current,
31
+ //measure dynamic row height, except in firefox because it measures table border height incorrectly
32
+ measureElement: typeof window !== 'undefined' && navigator.userAgent.indexOf('Firefox') === -1 ? element => element?.getBoundingClientRect().height : undefined,
33
+ overscan: 5
34
+ });
35
+ const virtualRows = rowVirtualizer.getVirtualItems();
36
+
37
+ // const columnSizingState = table.getState().columnSizing
38
+
39
+ // React.useEffect(() => {
40
+ // requestAnimationFrame(() => {
41
+ // rowVirtualizer.measure()
42
+ // })
43
+ // }, [columnSizingState, rowVirtualizer])
44
+
45
+ return /*#__PURE__*/_react.default.createElement("thead", {
46
+ className: `${prefix}-grid-thead`,
47
+ style: {
48
+ display: 'grid',
49
+ position: 'sticky',
50
+ top: 0,
51
+ zIndex: 1
52
+ }
53
+ }, virtualRows.map(virtualRow => {
54
+ const headerGroup = table.getHeaderGroups()[virtualRow.index];
55
+ return /*#__PURE__*/_react.default.createElement(_TableHeadRow.default, {
56
+ table: table,
57
+ columnVirtualizer: columnVirtualizer,
58
+ rowHeaderVirtualizer: rowVirtualizer,
59
+ headerGroup: headerGroup,
60
+ key: headerGroup.id,
61
+ virtualPaddingLeft: virtualPaddingLeft,
62
+ virtualPaddingRight: virtualPaddingRight,
63
+ fixedLeftColumns: fixedLeftColumns,
64
+ fixedRightColumns: fixedRightColumns,
65
+ rowHeaderVirtual: virtualRow
66
+ });
67
+ }));
68
+ };
69
+ var _default = exports.default = TableHead;
@@ -0,0 +1,14 @@
1
+ import type { Table } from '@tanstack/react-table';
2
+ import { type Header } from '@tanstack/react-table';
3
+ import React from 'react';
4
+ import type { Virtualizer } from '@tanstack/react-virtual';
5
+ interface TableHeadCellProps<T> {
6
+ t?: any;
7
+ table: Table<T>;
8
+ header: Header<T, unknown>;
9
+ getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
10
+ columnVirtualizer: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
11
+ rowHeaderVirtualizer: Virtualizer<HTMLDivElement, HTMLTableRowElement>;
12
+ }
13
+ declare const TableHeadCell: <RecordType extends object>(props: TableHeadCellProps<RecordType>) => React.JSX.Element;
14
+ export default TableHeadCell;