es-grid-template 1.7.22 → 1.7.24

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 (173) hide show
  1. package/es/grid-component/GridStyle.js +1 -1
  2. package/es/grid-component/InternalTable.js +5 -1
  3. package/es/grid-component/TableGrid.js +2 -2
  4. package/es/index.d.ts +1 -0
  5. package/es/index.js +3 -1
  6. package/es/table-component/ColumnsChoose.d.ts +10 -0
  7. package/es/table-component/ColumnsChoose.js +557 -0
  8. package/es/table-component/ContextMenu.d.ts +20 -0
  9. package/es/table-component/ContextMenu.js +75 -0
  10. package/es/table-component/InternalTable.d.ts +9 -0
  11. package/es/table-component/InternalTable.js +295 -0
  12. package/es/table-component/TableContainer.d.ts +22 -0
  13. package/es/table-component/TableContainer.js +130 -0
  14. package/es/table-component/TableContainerEdit.d.ts +28 -0
  15. package/es/table-component/TableContainerEdit.js +1211 -0
  16. package/es/table-component/body/EditableCell.d.ts +16 -0
  17. package/es/table-component/body/EditableCell.js +1036 -0
  18. package/es/table-component/body/TableBody.d.ts +19 -0
  19. package/es/table-component/body/TableBody.js +64 -0
  20. package/es/table-component/body/TableBodyCell.d.ts +10 -0
  21. package/es/table-component/body/TableBodyCell.js +139 -0
  22. package/es/table-component/body/TableBodyCellEdit.d.ts +15 -0
  23. package/es/table-component/body/TableBodyCellEdit.js +814 -0
  24. package/es/table-component/body/TableBodyRow.d.ts +21 -0
  25. package/es/table-component/body/TableBodyRow.js +146 -0
  26. package/es/table-component/components/ControlCheckbox.d.ts +13 -0
  27. package/es/table-component/components/ControlCheckbox.js +87 -0
  28. package/es/table-component/components/EditForm/EditForm.d.ts +27 -0
  29. package/es/table-component/components/EditForm/EditForm.js +395 -0
  30. package/es/table-component/components/EditForm/index.d.ts +1 -0
  31. package/es/table-component/components/EditForm/index.js +1 -0
  32. package/es/table-component/components/InputControl/InputControl.d.ts +27 -0
  33. package/es/table-component/components/InputControl/InputControl.js +121 -0
  34. package/es/table-component/components/InputControl/index.d.ts +1 -0
  35. package/es/table-component/components/InputControl/index.js +1 -0
  36. package/es/table-component/components/async-select/index.d.ts +11 -0
  37. package/es/table-component/components/async-select/index.js +41 -0
  38. package/es/table-component/components/async-table-select/index.d.ts +11 -0
  39. package/es/table-component/components/async-table-select/index.js +43 -0
  40. package/es/table-component/components/checkbox-control/index.d.ts +13 -0
  41. package/es/table-component/components/checkbox-control/index.js +40 -0
  42. package/es/table-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
  43. package/es/table-component/components/checkbox-filter/CheckboxFilter.js +240 -0
  44. package/es/table-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
  45. package/es/table-component/components/checkbox-filter/FilterSearch.js +36 -0
  46. package/es/table-component/components/command/Command.d.ts +9 -0
  47. package/es/table-component/components/command/Command.js +28 -0
  48. package/es/table-component/components/number/index.d.ts +10 -0
  49. package/es/table-component/components/number/index.js +42 -0
  50. package/es/table-component/components/number-range/index.d.ts +11 -0
  51. package/es/table-component/components/number-range/index.js +66 -0
  52. package/es/table-component/features/operator.d.ts +24 -0
  53. package/es/table-component/features/operator.js +62 -0
  54. package/es/table-component/footer/TableFooter.d.ts +13 -0
  55. package/es/table-component/footer/TableFooter.js +33 -0
  56. package/es/table-component/footer/TableFooterCell.d.ts +10 -0
  57. package/es/table-component/footer/TableFooterCell.js +24 -0
  58. package/es/table-component/footer/TableFooterRow.d.ts +14 -0
  59. package/es/table-component/footer/TableFooterRow.js +71 -0
  60. package/es/table-component/header/TableHead.d.ts +14 -0
  61. package/es/table-component/header/TableHead.js +60 -0
  62. package/es/table-component/header/TableHeadCell.d.ts +14 -0
  63. package/es/table-component/header/TableHeadCell.js +324 -0
  64. package/es/table-component/header/TableHeadRow.d.ts +16 -0
  65. package/es/table-component/header/TableHeadRow.js +86 -0
  66. package/es/table-component/header/renderFilter.d.ts +20 -0
  67. package/es/table-component/header/renderFilter.js +281 -0
  68. package/es/table-component/hook/constant.d.ts +73 -0
  69. package/es/table-component/hook/constant.js +240 -0
  70. package/es/table-component/hook/useColumns.d.ts +11 -0
  71. package/es/table-component/hook/useColumns.js +209 -0
  72. package/es/table-component/hook/useFilterOperator.d.ts +7 -0
  73. package/es/table-component/hook/useFilterOperator.js +33 -0
  74. package/es/table-component/hook/utils.d.ts +121 -0
  75. package/es/table-component/hook/utils.js +1727 -0
  76. package/es/table-component/index.d.ts +5 -0
  77. package/es/table-component/index.js +2 -0
  78. package/es/table-component/style.scss +1083 -0
  79. package/es/table-component/table/Grid.d.ts +23 -0
  80. package/es/table-component/table/Grid.js +310 -0
  81. package/es/table-component/table/GridEdit.d.ts +23 -0
  82. package/es/table-component/table/GridEdit.js +282 -0
  83. package/es/table-component/type.d.ts +482 -0
  84. package/es/table-component/type.js +1 -0
  85. package/es/table-component/useContext.d.ts +119 -0
  86. package/es/table-component/useContext.js +61 -0
  87. package/lib/grid-component/GridStyle.js +1 -1
  88. package/lib/grid-component/InternalTable.js +5 -1
  89. package/lib/grid-component/TableGrid.js +2 -2
  90. package/lib/index.d.ts +1 -0
  91. package/lib/index.js +8 -1
  92. package/lib/table-component/ColumnsChoose.d.ts +10 -0
  93. package/lib/table-component/ColumnsChoose.js +568 -0
  94. package/lib/table-component/ContextMenu.d.ts +20 -0
  95. package/lib/table-component/ContextMenu.js +85 -0
  96. package/lib/table-component/InternalTable.d.ts +9 -0
  97. package/lib/table-component/InternalTable.js +299 -0
  98. package/lib/table-component/TableContainer.d.ts +22 -0
  99. package/lib/table-component/TableContainer.js +137 -0
  100. package/lib/table-component/TableContainerEdit.d.ts +28 -0
  101. package/lib/table-component/TableContainerEdit.js +1220 -0
  102. package/lib/table-component/body/EditableCell.d.ts +16 -0
  103. package/lib/table-component/body/EditableCell.js +1038 -0
  104. package/lib/table-component/body/TableBody.d.ts +19 -0
  105. package/lib/table-component/body/TableBody.js +72 -0
  106. package/lib/table-component/body/TableBodyCell.d.ts +10 -0
  107. package/lib/table-component/body/TableBodyCell.js +148 -0
  108. package/lib/table-component/body/TableBodyCellEdit.d.ts +15 -0
  109. package/lib/table-component/body/TableBodyCellEdit.js +821 -0
  110. package/lib/table-component/body/TableBodyRow.d.ts +21 -0
  111. package/lib/table-component/body/TableBodyRow.js +153 -0
  112. package/lib/table-component/components/ControlCheckbox.d.ts +13 -0
  113. package/lib/table-component/components/ControlCheckbox.js +95 -0
  114. package/lib/table-component/components/EditForm/EditForm.d.ts +27 -0
  115. package/lib/table-component/components/EditForm/EditForm.js +406 -0
  116. package/lib/table-component/components/EditForm/index.d.ts +1 -0
  117. package/lib/table-component/components/EditForm/index.js +16 -0
  118. package/lib/table-component/components/InputControl/InputControl.d.ts +27 -0
  119. package/lib/table-component/components/InputControl/InputControl.js +131 -0
  120. package/lib/table-component/components/InputControl/index.d.ts +1 -0
  121. package/lib/table-component/components/InputControl/index.js +16 -0
  122. package/lib/table-component/components/async-select/index.d.ts +11 -0
  123. package/lib/table-component/components/async-select/index.js +49 -0
  124. package/lib/table-component/components/async-table-select/index.d.ts +11 -0
  125. package/lib/table-component/components/async-table-select/index.js +51 -0
  126. package/lib/table-component/components/checkbox-control/index.d.ts +13 -0
  127. package/lib/table-component/components/checkbox-control/index.js +48 -0
  128. package/lib/table-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
  129. package/lib/table-component/components/checkbox-filter/CheckboxFilter.js +249 -0
  130. package/lib/table-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
  131. package/lib/table-component/components/checkbox-filter/FilterSearch.js +44 -0
  132. package/lib/table-component/components/command/Command.d.ts +9 -0
  133. package/lib/table-component/components/command/Command.js +37 -0
  134. package/lib/table-component/components/number/index.d.ts +10 -0
  135. package/lib/table-component/components/number/index.js +50 -0
  136. package/lib/table-component/components/number-range/index.d.ts +11 -0
  137. package/lib/table-component/components/number-range/index.js +74 -0
  138. package/lib/table-component/features/operator.d.ts +24 -0
  139. package/lib/table-component/features/operator.js +67 -0
  140. package/lib/table-component/footer/TableFooter.d.ts +13 -0
  141. package/lib/table-component/footer/TableFooter.js +42 -0
  142. package/lib/table-component/footer/TableFooterCell.d.ts +10 -0
  143. package/lib/table-component/footer/TableFooterCell.js +32 -0
  144. package/lib/table-component/footer/TableFooterRow.d.ts +14 -0
  145. package/lib/table-component/footer/TableFooterRow.js +79 -0
  146. package/lib/table-component/header/TableHead.d.ts +14 -0
  147. package/lib/table-component/header/TableHead.js +69 -0
  148. package/lib/table-component/header/TableHeadCell.d.ts +14 -0
  149. package/lib/table-component/header/TableHeadCell.js +333 -0
  150. package/lib/table-component/header/TableHeadRow.d.ts +16 -0
  151. package/lib/table-component/header/TableHeadRow.js +94 -0
  152. package/lib/table-component/header/renderFilter.d.ts +20 -0
  153. package/lib/table-component/header/renderFilter.js +291 -0
  154. package/lib/table-component/hook/constant.d.ts +73 -0
  155. package/lib/table-component/hook/constant.js +247 -0
  156. package/lib/table-component/hook/useColumns.d.ts +11 -0
  157. package/lib/table-component/hook/useColumns.js +220 -0
  158. package/lib/table-component/hook/useFilterOperator.d.ts +7 -0
  159. package/lib/table-component/hook/useFilterOperator.js +40 -0
  160. package/lib/table-component/hook/utils.d.ts +121 -0
  161. package/lib/table-component/hook/utils.js +1817 -0
  162. package/lib/table-component/index.d.ts +5 -0
  163. package/lib/table-component/index.js +9 -0
  164. package/lib/table-component/style.scss +1083 -0
  165. package/lib/table-component/table/Grid.d.ts +23 -0
  166. package/lib/table-component/table/Grid.js +313 -0
  167. package/lib/table-component/table/GridEdit.d.ts +23 -0
  168. package/lib/table-component/table/GridEdit.js +284 -0
  169. package/lib/table-component/type.d.ts +482 -0
  170. package/lib/table-component/type.js +5 -0
  171. package/lib/table-component/useContext.d.ts +119 -0
  172. package/lib/table-component/useContext.js +67 -0
  173. package/package.json +3 -1
@@ -0,0 +1,42 @@
1
+ import React, { Fragment } from "react";
2
+ import { NumericFormat } from "react-numeric-component";
3
+ import { Input } from "rc-master-ui";
4
+ import { checkDecimalSeparator, checkThousandSeparator } from "../../hook/utils";
5
+ // import type {IFormat} from "../type"
6
+ // import {checkDecimalSeparator, checkThousandSeparator} from "../hooks"
7
+
8
+ const NumberInput = props => {
9
+ const {
10
+ t,
11
+ value,
12
+ format,
13
+ onChange
14
+ } = props;
15
+ const values = React.useMemo(() => [value], [value]);
16
+
17
+ // const [values, setValues] = React.useState<any[]>(() =>
18
+ // mergedValues,
19
+ // );
20
+
21
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(NumericFormat, {
22
+ value: values[0] ?? ''
23
+ // value={min}
24
+ ,
25
+ thousandSeparator: checkThousandSeparator(format?.thousandSeparator, format?.decimalSeparator),
26
+ decimalSeparator: checkDecimalSeparator(format?.thousandSeparator, format?.decimalSeparator),
27
+ allowNegative: true,
28
+ customInput: Input,
29
+ className: 'rounded-0 input-element',
30
+ onValueChange: vals => {
31
+ // onChangeValueFilter(type, values.floatValue, 'min')
32
+
33
+ // setValues([vals.floatValue, values[1]])
34
+ onChange?.([vals.floatValue]);
35
+ }
36
+ // placeholder={t ? t('Min') : 'Min'}
37
+ ,
38
+ placeholder: t ? t('Enter') : 'Enter',
39
+ autoFocus: true
40
+ }));
41
+ };
42
+ export default NumberInput;
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import type { IFormat } from "../../type";
3
+ type Props = {
4
+ t?: any;
5
+ format?: IFormat;
6
+ min: number | string | undefined;
7
+ max: number | string | undefined;
8
+ onChange?: (values: any[]) => void;
9
+ };
10
+ declare const NumberRange: (props: Props) => React.JSX.Element;
11
+ export default NumberRange;
@@ -0,0 +1,66 @@
1
+ import React, { Fragment } from "react";
2
+ import { NumericFormat } from "react-numeric-component";
3
+ import { Input } from "rc-master-ui";
4
+ import { checkDecimalSeparator, checkThousandSeparator } from "../../hook/utils";
5
+ // import type {IFormat} from "../type"
6
+ // import {checkDecimalSeparator, checkThousandSeparator} from "../hooks"
7
+
8
+ const NumberRange = props => {
9
+ const {
10
+ t,
11
+ max,
12
+ min,
13
+ format,
14
+ onChange
15
+ } = props;
16
+ const values = React.useMemo(() => [min, max], [min, max]);
17
+
18
+ // const [values, setValues] = React.useState<any[]>(() =>
19
+ // mergedValues,
20
+ // );
21
+
22
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
23
+ className: '',
24
+ style: {
25
+ display: 'flex',
26
+ alignItems: 'center',
27
+ columnGap: 5
28
+ }
29
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(NumericFormat, {
30
+ value: values[0] ?? ''
31
+ // value={min}
32
+ ,
33
+ thousandSeparator: checkThousandSeparator(format?.thousandSeparator, format?.decimalSeparator),
34
+ decimalSeparator: checkDecimalSeparator(format?.thousandSeparator, format?.decimalSeparator),
35
+ allowNegative: true,
36
+ customInput: Input,
37
+ className: ' rounded-0 input-element',
38
+ onValueChange: vals => {
39
+ // onChangeValueFilter(type, values.floatValue, 'min')
40
+
41
+ // setValues([vals.floatValue, values[1]])
42
+ onChange?.([vals.floatValue, max]);
43
+ }
44
+ // placeholder={t ? t('Min') : 'Min'}
45
+ ,
46
+ placeholder: t ? t('From') : 'From',
47
+ autoFocus: true
48
+ })), /*#__PURE__*/React.createElement("span", null, " - "), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(NumericFormat, {
49
+ value: values[1] ?? ''
50
+ // value={max}
51
+ ,
52
+ thousandSeparator: checkThousandSeparator(format?.thousandSeparator, format?.decimalSeparator),
53
+ decimalSeparator: checkDecimalSeparator(format?.thousandSeparator, format?.decimalSeparator),
54
+ allowNegative: true,
55
+ customInput: Input,
56
+ className: ' rounded-0 input-element',
57
+ onValueChange: vals => {
58
+ // setValues([values[0], vals.floatValue])
59
+ onChange?.([min, vals.floatValue]);
60
+ }
61
+ // placeholder={t ? t('Max') : 'Max'}
62
+ ,
63
+ placeholder: t ? t('To') : 'To'
64
+ }))));
65
+ };
66
+ export default NumberRange;
@@ -0,0 +1,24 @@
1
+ import { OnChangeFn, RowData, TableFeature } from '@tanstack/react-table';
2
+ export type ColumnOperatorState = ColumnOperator[];
3
+ export interface OperatorTableState {
4
+ operator: ColumnOperatorState;
5
+ }
6
+ export interface ColumnOperator {
7
+ id: string;
8
+ operator: string;
9
+ }
10
+ export interface OperatorOptions {
11
+ enableOperator?: boolean;
12
+ onColumnOperatorChange?: OnChangeFn<ColumnOperatorState>;
13
+ }
14
+ declare module '@tanstack/react-table' {
15
+ interface TableState extends OperatorTableState {
16
+ }
17
+ interface TableOptionsResolved<TData extends RowData> extends OperatorOptions {
18
+ }
19
+ interface Column<TData extends RowData, TValue> {
20
+ getFilterOperator: () => string;
21
+ setFilterOperator: (operator: string) => void;
22
+ }
23
+ }
24
+ export declare const OperatorFeature: TableFeature<any>;
@@ -0,0 +1,62 @@
1
+ // TypeScript setup for our new feature with all of the same type-safety as stock TanStack Table features
2
+
3
+ import { makeStateUpdater } from '@tanstack/react-table';
4
+
5
+ // define types for our new feature's table options
6
+
7
+ // Define types for our new feature's table APIs
8
+ // export interface OperatorInstance {
9
+ // setDensity: (updater: Updater<OpetorState>) => void
10
+
11
+ // toggleDensity: (value?: OpetorState) => void
12
+ // }
13
+
14
+ // Use declaration merging to add our new feature APIs and state types to TanStack Table's existing types.
15
+
16
+ export const OperatorFeature = {
17
+ // define the new feature's initial state
18
+ getInitialState: state => {
19
+ return {
20
+ operator: [],
21
+ ...state
22
+ };
23
+ },
24
+ // define the new feature's default options
25
+ getDefaultOptions: table => {
26
+ return {
27
+ enableOperator: true,
28
+ onColumnOperatorChange: makeStateUpdater('operator', table)
29
+ };
30
+ },
31
+ // if you need to add a default column definition...
32
+ // getDefaultColumnDef: <TData extends RowData>(): Partial<ColumnDef<TData>> => {
33
+ // return { meta: {} } //use meta instead of directly adding to the columnDef to avoid typescript stuff that's hard to workaround
34
+ // },
35
+
36
+ // define the new feature's table instance methods
37
+
38
+ // if you need to add row instance APIs...
39
+ // createRow: <TData extends RowData>(row, table): void => {},
40
+ // if you need to add cell instance APIs...
41
+ // createCell: <TData extends RowData>(cell, column, row, table): void => {},
42
+ // if you need to add column instance APIs...
43
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
44
+ createColumn: (column, table) => {
45
+ column.getFilterOperator = () => {
46
+ return table.getState().operator?.find(op => op.id === column.id)?.operator ?? undefined;
47
+ };
48
+ column.setFilterOperator = updater => {
49
+ const safeUpdater = old => {
50
+ const others = old.filter(op => op.id !== column.id);
51
+ return [...others, {
52
+ id: column.id,
53
+ operator: updater
54
+ }];
55
+ };
56
+ return table.options.onColumnOperatorChange?.(safeUpdater);
57
+ };
58
+ }
59
+
60
+ // if you need to add header instance APIs...
61
+ // createHeader: <TData extends RowData>(header, table): void => {},
62
+ };
@@ -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,33 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import TableFooterRow from "./TableFooterRow";
3
+ import { TableContext } from "../useContext";
4
+ import React, { useContext } from "react";
5
+ const TableFooter = ({
6
+ columnVirtualizer,
7
+ table,
8
+ virtualPaddingLeft,
9
+ virtualPaddingRight,
10
+ ...rest
11
+ }) => {
12
+ const {
13
+ prefix
14
+ } = useContext(TableContext);
15
+ return /*#__PURE__*/React.createElement("tfoot", {
16
+ className: `${prefix}-grid-tfoot`,
17
+ style: {
18
+ display: "grid",
19
+ position: "sticky",
20
+ bottom: 0,
21
+ zIndex: 1
22
+ }
23
+ }, /*#__PURE__*/React.createElement(TableFooterRow, _extends({
24
+ table: table,
25
+ columnVirtualizer: columnVirtualizer,
26
+ headerGroup: table.getHeaderGroups()[table.getHeaderGroups().length - 1]
27
+ // key={headerGroup.id}
28
+ ,
29
+ virtualPaddingLeft: virtualPaddingLeft,
30
+ virtualPaddingRight: virtualPaddingRight
31
+ }, rest)));
32
+ };
33
+ export 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,24 @@
1
+ import React from "react";
2
+ // import type { Person } from "../makeData";
3
+ import { getCommonPinningStyles } from "../hook/utils";
4
+ // import type { Person } from "../../tanstack-table/makeData";
5
+
6
+ const TableFooterCell = ({
7
+ header
8
+ }) => {
9
+ return /*#__PURE__*/React.createElement("td", {
10
+ // ref={el => {
11
+ // if (el) columnVirtualizer.measureElement(el)
12
+ // }}
13
+ // data-index={header.id}
14
+ key: header.id,
15
+ colSpan: header.colSpan,
16
+ style: {
17
+ display: 'flex',
18
+ ...getCommonPinningStyles(header.column),
19
+ width: header?.getSize() ?? header.column.getSize(),
20
+ backgroundColor: "#fafafa"
21
+ }
22
+ }, header.column.id !== "id" && header.column.id !== "selection_column" ? /*#__PURE__*/React.createElement("span", null, "aaa") : '');
23
+ };
24
+ export 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,71 @@
1
+ // import type { Person } from "../makeData";
2
+ import TableFooterCell from "./TableFooterCell";
3
+ import React from "react";
4
+ // import type { Person } from "../../tanstack-table/makeData";
5
+ // import TableHeadCell from "./TableHeadCell";
6
+
7
+ const TableFooterRow = ({
8
+ table,
9
+ // columnVirtualizer,
10
+ headerGroup,
11
+ virtualPaddingLeft,
12
+ virtualPaddingRight,
13
+ fixedLeftColumns,
14
+ fixedRightColumns,
15
+ // virtualColumns,
16
+ columnVirtualizer
17
+ }) => {
18
+ const virtualColumns = columnVirtualizer.getVirtualItems();
19
+ return /*#__PURE__*/React.createElement("tr", {
20
+ // data-index={headerGroup.id}
21
+ key: headerGroup.id,
22
+ style: {
23
+ display: "flex",
24
+ width: "100%",
25
+ borderTop: "1px solid #e0e0e0"
26
+ }
27
+ }, fixedLeftColumns.length > 0 ? fixedLeftColumns.map(column => {
28
+ return /*#__PURE__*/React.createElement(TableFooterCell, {
29
+ columnVirtualizer: columnVirtualizer,
30
+ key: column.id,
31
+ header: headerGroup.headers.find(h => h.column.id === column.id),
32
+ column: column
33
+ });
34
+ }) : null, virtualPaddingLeft ? /*#__PURE__*/React.createElement("td", {
35
+ className: "",
36
+ style: {
37
+ display: "flex",
38
+ width: virtualPaddingLeft
39
+ }
40
+ }) : null, virtualColumns.map(virtualColumn => {
41
+ const header = headerGroup.headers[virtualColumn.index];
42
+ const isFixed = table.getState().columnPinning.left?.includes(header.column.id) || table.getState().columnPinning.right?.includes(header.column.id);
43
+ // const isFixed = table.getState().columnPinning.left?.includes(header.column.id)
44
+
45
+ if (header && !isFixed) {
46
+ return /*#__PURE__*/React.createElement(TableFooterCell, {
47
+ key: header.id,
48
+ header: header,
49
+ column: virtualColumn,
50
+ columnVirtualizer: columnVirtualizer
51
+ });
52
+ }
53
+ return null;
54
+ }),
55
+ //fake empty column to the right for virtualization scroll padding
56
+ fixedRightColumns.length > 0 ? fixedRightColumns.map(column => /*#__PURE__*/React.createElement(TableFooterCell, {
57
+ key: column.id,
58
+ header: headerGroup.headers.find(h => h.column.id === column.id),
59
+ column: column
60
+ })) : null, virtualPaddingRight ?
61
+ /*#__PURE__*/
62
+ //fake empty column to the right for virtualization scroll padding
63
+ React.createElement("td", {
64
+ className: "",
65
+ style: {
66
+ display: "flex",
67
+ width: virtualPaddingRight
68
+ }
69
+ }) : null);
70
+ };
71
+ export 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,60 @@
1
+ import { useVirtualizer } from '@tanstack/react-virtual';
2
+ import React, { useContext } from 'react';
3
+ import { TableContext } from "../useContext";
4
+ import TableHeadRow from "./TableHeadRow";
5
+ const TableHead = ({
6
+ tableContainerRef,
7
+ columnVirtualizer,
8
+ table,
9
+ virtualPaddingLeft,
10
+ virtualPaddingRight,
11
+ fixedLeftColumns,
12
+ fixedRightColumns
13
+ }) => {
14
+ const {
15
+ prefix
16
+ } = useContext(TableContext);
17
+ const rowVirtualizer = useVirtualizer({
18
+ count: table.getHeaderGroups().length,
19
+ estimateSize: () => 34,
20
+ //estimate row height for accurate scrollbar dragging
21
+ getScrollElement: () => tableContainerRef.current,
22
+ //measure dynamic row height, except in firefox because it measures table border height incorrectly
23
+ measureElement: typeof window !== 'undefined' && navigator.userAgent.indexOf('Firefox') === -1 ? element => element?.getBoundingClientRect().height : undefined,
24
+ overscan: 5
25
+ });
26
+ const virtualRows = rowVirtualizer.getVirtualItems();
27
+
28
+ // const columnSizingState = table.getState().columnSizing
29
+
30
+ // React.useEffect(() => {
31
+ // requestAnimationFrame(() => {
32
+ // rowVirtualizer.measure()
33
+ // })
34
+ // }, [columnSizingState, rowVirtualizer])
35
+
36
+ return /*#__PURE__*/React.createElement("thead", {
37
+ className: `${prefix}-grid-thead`,
38
+ style: {
39
+ display: 'grid',
40
+ position: 'sticky',
41
+ top: 0,
42
+ zIndex: 1
43
+ }
44
+ }, virtualRows.map(virtualRow => {
45
+ const headerGroup = table.getHeaderGroups()[virtualRow.index];
46
+ return /*#__PURE__*/React.createElement(TableHeadRow, {
47
+ table: table,
48
+ columnVirtualizer: columnVirtualizer,
49
+ rowHeaderVirtualizer: rowVirtualizer,
50
+ headerGroup: headerGroup,
51
+ key: headerGroup.id,
52
+ virtualPaddingLeft: virtualPaddingLeft,
53
+ virtualPaddingRight: virtualPaddingRight,
54
+ fixedLeftColumns: fixedLeftColumns,
55
+ fixedRightColumns: fixedRightColumns,
56
+ rowHeaderVirtual: virtualRow
57
+ });
58
+ }));
59
+ };
60
+ export 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;