1
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
||||
import * as React from 'react';
|
||||
import type { AlignType } from '../interface';
|
||||
export interface SummaryCellProps {
|
||||
className?: string;
|
||||
index: number;
|
||||
colSpan?: number;
|
||||
rowSpan?: number;
|
||||
align?: AlignType;
|
||||
}
|
||||
declare const SummaryCell: React.FC<React.PropsWithChildren<SummaryCellProps>>;
|
||||
export default SummaryCell;
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
||||
import * as React from 'react';
|
||||
import Cell from "../Cell";
|
||||
import TableContext from "../context/TableContext";
|
||||
import { useContext } from '@rc-component/context';
|
||||
import { getCellFixedInfo } from "../utils/fixUtil";
|
||||
import SummaryContext from "./SummaryContext";
|
||||
const SummaryCell = props => {
|
||||
const {
|
||||
className,
|
||||
index,
|
||||
children,
|
||||
colSpan = 1,
|
||||
rowSpan,
|
||||
align
|
||||
} = props;
|
||||
const {
|
||||
prefixCls
|
||||
} = useContext(TableContext, ['prefixCls']);
|
||||
const {
|
||||
scrollColumnIndex,
|
||||
stickyOffsets,
|
||||
flattenColumns
|
||||
} = React.useContext(SummaryContext);
|
||||
const lastIndex = index + colSpan - 1;
|
||||
const mergedColSpan = lastIndex + 1 === scrollColumnIndex ? colSpan + 1 : colSpan;
|
||||
const fixedInfo = React.useMemo(() => getCellFixedInfo(index, index + mergedColSpan - 1, flattenColumns, stickyOffsets), [index, mergedColSpan, flattenColumns, stickyOffsets]);
|
||||
return /*#__PURE__*/React.createElement(Cell, _extends({
|
||||
className: className,
|
||||
index: index,
|
||||
component: "td",
|
||||
prefixCls: prefixCls,
|
||||
record: null,
|
||||
dataIndex: null,
|
||||
align: align,
|
||||
colSpan: mergedColSpan,
|
||||
rowSpan: rowSpan,
|
||||
render: () => children
|
||||
}, fixedInfo));
|
||||
};
|
||||
export default SummaryCell;
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import * as React from 'react';
|
||||
export interface FooterRowProps {
|
||||
className?: string;
|
||||
style?: React.CSSProperties;
|
||||
onClick?: React.MouseEventHandler<HTMLTableRowElement>;
|
||||
}
|
||||
declare const FooterRow: React.FC<React.PropsWithChildren<FooterRowProps>>;
|
||||
export default FooterRow;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import * as React from 'react';
|
||||
const FooterRow = props => {
|
||||
const {
|
||||
children,
|
||||
...restProps
|
||||
} = props;
|
||||
return /*#__PURE__*/React.createElement("tr", restProps, children);
|
||||
};
|
||||
export default FooterRow;
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import type * as React from 'react';
|
||||
import Cell from './Cell';
|
||||
import Row from './Row';
|
||||
export interface SummaryProps {
|
||||
fixed?: boolean | 'top' | 'bottom';
|
||||
}
|
||||
/**
|
||||
* Syntactic sugar. Do not support HOC.
|
||||
*/
|
||||
declare const Summary: React.FC<React.PropsWithChildren<SummaryProps>> & {
|
||||
Row: typeof Row;
|
||||
Cell: typeof Cell;
|
||||
};
|
||||
export default Summary;
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import Cell from "./Cell";
|
||||
import Row from "./Row";
|
||||
/**
|
||||
* Syntactic sugar. Do not support HOC.
|
||||
*/
|
||||
const Summary = props => {
|
||||
const {
|
||||
children
|
||||
} = props;
|
||||
return children;
|
||||
};
|
||||
Summary.Row = Row;
|
||||
Summary.Cell = Cell;
|
||||
export default Summary;
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import * as React from 'react';
|
||||
import type { ColumnType, StickyOffsets } from '../interface';
|
||||
type FlattenColumns<RecordType> = readonly (ColumnType<RecordType> & {
|
||||
scrollbar?: boolean;
|
||||
})[];
|
||||
declare const SummaryContext: React.Context<{
|
||||
stickyOffsets?: StickyOffsets;
|
||||
scrollColumnIndex?: number;
|
||||
flattenColumns?: FlattenColumns<any>;
|
||||
}>;
|
||||
export default SummaryContext;
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import * as React from 'react';
|
||||
const SummaryContext = /*#__PURE__*/React.createContext({});
|
||||
export default SummaryContext;
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import * as React from 'react';
|
||||
import type { ColumnType, StickyOffsets } from '../interface';
|
||||
type FlattenColumns<RecordType> = readonly (ColumnType<RecordType> & {
|
||||
scrollbar?: boolean;
|
||||
})[];
|
||||
export interface FooterProps<RecordType> {
|
||||
children: React.ReactNode;
|
||||
stickyOffsets: StickyOffsets;
|
||||
flattenColumns: FlattenColumns<RecordType>;
|
||||
}
|
||||
declare const _default: <RecordType>(props: FooterProps<RecordType>) => React.JSX.Element;
|
||||
export default _default;
|
||||
export declare const FooterComponents: React.FC<React.PropsWithChildren<import("./Summary").SummaryProps>> & {
|
||||
Row: React.FC<React.PropsWithChildren<import("./Row").FooterRowProps>>;
|
||||
Cell: React.FC<React.PropsWithChildren<import("./Cell").SummaryCellProps>>;
|
||||
};
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
import { useContext } from '@rc-component/context';
|
||||
import * as React from 'react';
|
||||
import TableContext, { responseImmutable } from "../context/TableContext";
|
||||
import devRenderTimes from "../hooks/useRenderTimes";
|
||||
import Summary from "./Summary";
|
||||
import SummaryContext from "./SummaryContext";
|
||||
const Footer = props => {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
devRenderTimes(props);
|
||||
}
|
||||
const {
|
||||
children,
|
||||
stickyOffsets,
|
||||
flattenColumns
|
||||
} = props;
|
||||
const prefixCls = useContext(TableContext, 'prefixCls');
|
||||
const lastColumnIndex = flattenColumns.length - 1;
|
||||
const scrollColumn = flattenColumns[lastColumnIndex];
|
||||
const summaryContext = React.useMemo(() => ({
|
||||
stickyOffsets,
|
||||
flattenColumns,
|
||||
scrollColumnIndex: scrollColumn?.scrollbar ? lastColumnIndex : null
|
||||
}), [scrollColumn, flattenColumns, lastColumnIndex, stickyOffsets]);
|
||||
return /*#__PURE__*/React.createElement(SummaryContext.Provider, {
|
||||
value: summaryContext
|
||||
}, /*#__PURE__*/React.createElement("tfoot", {
|
||||
className: `${prefixCls}-summary`
|
||||
}, children));
|
||||
};
|
||||
export default responseImmutable(Footer);
|
||||
export const FooterComponents = Summary;
|
||||
Reference in New Issue
Block a user