Comparing version 7.38.1 to 7.39.0
@@ -123,3 +123,3 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
// >>>>> ClassName | ||
var mergedClassName = classNames(cellPrefixCls, className, (_classNames = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_classNames, "".concat(cellPrefixCls, "-fix-left"), isFixLeft && supportSticky), "".concat(cellPrefixCls, "-fix-left-first"), firstFixLeft && supportSticky), "".concat(cellPrefixCls, "-fix-left-last"), lastFixLeft && supportSticky), "".concat(cellPrefixCls, "-fix-left-all"), lastFixLeft && allColumnsFixedLeft && supportSticky), "".concat(cellPrefixCls, "-fix-right"), isFixRight && supportSticky), "".concat(cellPrefixCls, "-fix-right-first"), firstFixRight && supportSticky), "".concat(cellPrefixCls, "-fix-right-last"), lastFixRight && supportSticky), "".concat(cellPrefixCls, "-ellipsis"), ellipsis), "".concat(cellPrefixCls, "-with-append"), appendNode), "".concat(cellPrefixCls, "-fix-sticky"), (isFixLeft || isFixRight) && isSticky && supportSticky), _defineProperty(_classNames, "".concat(cellPrefixCls, "-row-hover"), !legacyCellProps && hovering)), additionalProps.className, legacyCellProps === null || legacyCellProps === void 0 ? void 0 : legacyCellProps.className); | ||
var mergedClassName = classNames(cellPrefixCls, className, (_classNames = {}, _defineProperty(_classNames, "".concat(cellPrefixCls, "-fix-left"), isFixLeft && supportSticky), _defineProperty(_classNames, "".concat(cellPrefixCls, "-fix-left-first"), firstFixLeft && supportSticky), _defineProperty(_classNames, "".concat(cellPrefixCls, "-fix-left-last"), lastFixLeft && supportSticky), _defineProperty(_classNames, "".concat(cellPrefixCls, "-fix-left-all"), lastFixLeft && allColumnsFixedLeft && supportSticky), _defineProperty(_classNames, "".concat(cellPrefixCls, "-fix-right"), isFixRight && supportSticky), _defineProperty(_classNames, "".concat(cellPrefixCls, "-fix-right-first"), firstFixRight && supportSticky), _defineProperty(_classNames, "".concat(cellPrefixCls, "-fix-right-last"), lastFixRight && supportSticky), _defineProperty(_classNames, "".concat(cellPrefixCls, "-ellipsis"), ellipsis), _defineProperty(_classNames, "".concat(cellPrefixCls, "-with-append"), appendNode), _defineProperty(_classNames, "".concat(cellPrefixCls, "-fix-sticky"), (isFixLeft || isFixRight) && isSticky && supportSticky), _defineProperty(_classNames, "".concat(cellPrefixCls, "-row-hover"), !legacyCellProps && hovering), _classNames), additionalProps.className, legacyCellProps === null || legacyCellProps === void 0 ? void 0 : legacyCellProps.className); | ||
@@ -126,0 +126,0 @@ // >>>>> Style |
@@ -28,4 +28,5 @@ import * as React from 'react'; | ||
flattenColumns: readonly ColumnType<RecordType>[], | ||
realScrollWidth: undefined | number | ||
realScrollWidth: undefined | number, | ||
hasGapFixed: boolean | ||
]; | ||
export default useColumns; |
@@ -69,24 +69,2 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray"; | ||
} | ||
function warningFixed(flattenColumns) { | ||
var allFixLeft = true; | ||
for (var i = 0; i < flattenColumns.length; i += 1) { | ||
var col = flattenColumns[i]; | ||
if (allFixLeft && col.fixed !== 'left') { | ||
allFixLeft = false; | ||
} else if (!allFixLeft && col.fixed === 'left') { | ||
warning(false, "Index ".concat(i - 1, " of `columns` missing `fixed='left'` prop.")); | ||
break; | ||
} | ||
} | ||
var allFixRight = true; | ||
for (var _i = flattenColumns.length - 1; _i >= 0; _i -= 1) { | ||
var _col = flattenColumns[_i]; | ||
if (allFixRight && _col.fixed !== 'right') { | ||
allFixRight = false; | ||
} else if (!allFixRight && _col.fixed === 'right') { | ||
warning(false, "Index ".concat(_i + 1, " of `columns` missing `fixed='right'` prop.")); | ||
break; | ||
} | ||
} | ||
} | ||
function revertForRtl(columns) { | ||
@@ -139,2 +117,3 @@ return columns.map(function (column) { | ||
if (expandable) { | ||
var _expandColumn; | ||
var cloneColumns = baseColumns.slice(); | ||
@@ -178,6 +157,6 @@ | ||
// >>> Create expandable column | ||
var expandColumn = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, INTERNAL_COL_DEFINE, { | ||
var expandColumn = (_expandColumn = {}, _defineProperty(_expandColumn, INTERNAL_COL_DEFINE, { | ||
className: "".concat(prefixCls, "-expand-icon-col"), | ||
columnType: 'EXPAND_COLUMN' | ||
}), "title", columnTitle), "fixed", fixedColumn), "className", "".concat(prefixCls, "-row-expand-icon-cell")), "width", columnWidth), "render", function render(_, record, index) { | ||
}), _defineProperty(_expandColumn, "title", columnTitle), _defineProperty(_expandColumn, "fixed", fixedColumn), _defineProperty(_expandColumn, "className", "".concat(prefixCls, "-row-expand-icon-cell")), _defineProperty(_expandColumn, "width", columnWidth), _defineProperty(_expandColumn, "render", function render(_, record, index) { | ||
var rowKey = getRowKey(record, index); | ||
@@ -201,3 +180,3 @@ var expanded = expandedKeys.has(rowKey); | ||
return icon; | ||
}); | ||
}), _expandColumn); | ||
return cloneColumns.map(function (col) { | ||
@@ -241,7 +220,38 @@ return col === EXPAND_COLUMN ? expandColumn : col; | ||
// Only check out of production since it's waste for each render | ||
if (process.env.NODE_ENV !== 'production') { | ||
warningFixed(direction === 'rtl' ? flattenColumns.slice().reverse() : flattenColumns); | ||
} | ||
// ========================= Gap Fixed ======================== | ||
var hasGapFixed = React.useMemo(function () { | ||
// Fixed: left, since old browser not support `findLastIndex`, we should use reverse loop | ||
var lastLeftIndex = -1; | ||
for (var i = flattenColumns.length - 1; i >= 0; i -= 1) { | ||
var colFixed = flattenColumns[i].fixed; | ||
if (colFixed === 'left' || colFixed === true) { | ||
lastLeftIndex = i; | ||
break; | ||
} | ||
} | ||
if (lastLeftIndex >= 0) { | ||
for (var _i = 0; _i <= lastLeftIndex; _i += 1) { | ||
var _colFixed = flattenColumns[_i].fixed; | ||
if (_colFixed !== 'left' && _colFixed !== true) { | ||
return true; | ||
} | ||
} | ||
} | ||
// Fixed: right | ||
var firstRightIndex = flattenColumns.findIndex(function (_ref3) { | ||
var colFixed = _ref3.fixed; | ||
return colFixed === 'right'; | ||
}); | ||
if (firstRightIndex >= 0) { | ||
for (var _i2 = firstRightIndex; _i2 < flattenColumns.length; _i2 += 1) { | ||
var _colFixed2 = flattenColumns[_i2].fixed; | ||
if (_colFixed2 !== 'right') { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
}, [flattenColumns]); | ||
// ========================= FillWidth ======================== | ||
@@ -252,4 +262,4 @@ var _useWidthColumns = useWidthColumns(flattenColumns, scrollWidth, clientWidth), | ||
realScrollWidth = _useWidthColumns2[1]; | ||
return [mergedColumns, filledColumns, realScrollWidth]; | ||
return [mergedColumns, filledColumns, realScrollWidth, hasGapFixed]; | ||
} | ||
export default useColumns; |
@@ -1,6 +0,6 @@ | ||
import type { Direction, StickyOffsets } from '../interface'; | ||
import type { ColumnType, Direction, StickyOffsets } from '../interface'; | ||
/** | ||
* Get sticky column offset width | ||
*/ | ||
declare function useStickyOffsets(colWidths: number[], columnCount: number, direction: Direction): StickyOffsets; | ||
declare function useStickyOffsets<RecordType>(colWidths: number[], flattenColumns: readonly ColumnType<RecordType>[], direction: Direction): StickyOffsets; | ||
export default useStickyOffsets; |
@@ -5,36 +5,28 @@ import { useMemo } from 'react'; | ||
*/ | ||
function useStickyOffsets(colWidths, columnCount, direction) { | ||
function useStickyOffsets(colWidths, flattenColumns, direction) { | ||
var stickyOffsets = useMemo(function () { | ||
var leftOffsets = []; | ||
var rightOffsets = []; | ||
var left = 0; | ||
var right = 0; | ||
for (var start = 0; start < columnCount; start += 1) { | ||
if (direction === 'rtl') { | ||
// Left offset | ||
rightOffsets[start] = right; | ||
right += colWidths[start] || 0; | ||
// Right offset | ||
var end = columnCount - start - 1; | ||
leftOffsets[end] = left; | ||
left += colWidths[end] || 0; | ||
} else { | ||
// Left offset | ||
leftOffsets[start] = left; | ||
left += colWidths[start] || 0; | ||
// Right offset | ||
var _end = columnCount - start - 1; | ||
rightOffsets[_end] = right; | ||
right += colWidths[_end] || 0; | ||
var columnCount = flattenColumns.length; | ||
var getOffsets = function getOffsets(startIndex, endIndex, offset) { | ||
var offsets = []; | ||
var total = 0; | ||
for (var i = startIndex; i !== endIndex; i += offset) { | ||
offsets.push(total); | ||
if (flattenColumns[i].fixed) { | ||
total += colWidths[i] || 0; | ||
} | ||
} | ||
} | ||
return { | ||
left: leftOffsets, | ||
right: rightOffsets | ||
return offsets; | ||
}; | ||
}, [colWidths, columnCount, direction]); | ||
var startOffsets = getOffsets(0, columnCount, 1); | ||
var endOffsets = getOffsets(columnCount - 1, -1, -1).reverse(); | ||
return direction === 'rtl' ? { | ||
left: endOffsets, | ||
right: startOffsets | ||
} : { | ||
left: startOffsets, | ||
right: endOffsets | ||
}; | ||
}, [colWidths, flattenColumns, direction]); | ||
return stickyOffsets; | ||
} | ||
export default useStickyOffsets; |
import { EXPAND_COLUMN, INTERNAL_HOOKS } from './constant'; | ||
import { FooterComponents as Summary } from './Footer'; | ||
import type { ColumnType, Reference } from './interface'; | ||
import type { ColumnType, ColumnsType, Reference } from './interface'; | ||
import Column from './sugar/Column'; | ||
@@ -11,3 +11,3 @@ import ColumnGroup from './sugar/ColumnGroup'; | ||
import VirtualTable, { genVirtualTable } from './VirtualTable'; | ||
export { genTable, Summary, Column, ColumnGroup, type TableProps, INTERNAL_COL_DEFINE, EXPAND_COLUMN, INTERNAL_HOOKS, VirtualTable, genVirtualTable, type VirtualTableProps, type Reference, type ColumnType, }; | ||
export { genTable, Summary, Column, ColumnGroup, type TableProps, INTERNAL_COL_DEFINE, EXPAND_COLUMN, INTERNAL_HOOKS, VirtualTable, genVirtualTable, type VirtualTableProps, type Reference, type ColumnType, type ColumnsType, }; | ||
export default Table; |
@@ -5,4 +5,3 @@ /* istanbul ignore next */ | ||
* So HOC will not work on this. | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
*/ // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
function Column(_) { | ||
@@ -9,0 +8,0 @@ return null; |
@@ -5,4 +5,3 @@ /* istanbul ignore next */ | ||
* So HOC will not work on this. | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
*/ // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
function ColumnGroup(_) { | ||
@@ -9,0 +8,0 @@ return null; |
@@ -72,2 +72,3 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
function Table(tableProps, ref) { | ||
var _classNames; | ||
var props = _objectSpread({ | ||
@@ -169,6 +170,7 @@ rowKey: 'key', | ||
}), useInternalHooks ? transformColumns : null), | ||
_useColumns2 = _slicedToArray(_useColumns, 3), | ||
_useColumns2 = _slicedToArray(_useColumns, 4), | ||
columns = _useColumns2[0], | ||
flattenColumns = _useColumns2[1], | ||
flattenScrollX = _useColumns2[2]; | ||
flattenScrollX = _useColumns2[2], | ||
hasGapFixed = _useColumns2[3]; | ||
var mergedScrollX = flattenScrollX !== null && flattenScrollX !== void 0 ? flattenScrollX : scrollX; | ||
@@ -238,3 +240,3 @@ var columnContext = React.useMemo(function () { | ||
}, [pureColWidths.join('_')]); | ||
var stickyOffsets = useStickyOffsets(colWidths, flattenColumns.length, direction); | ||
var stickyOffsets = useStickyOffsets(colWidths, flattenColumns, direction); | ||
var fixHeader = scroll && validateValue(scroll.y); | ||
@@ -576,3 +578,3 @@ var horizonScroll = scroll && validateValue(mergedScrollX) || Boolean(expandableConfig.fixed); | ||
var fullTable = /*#__PURE__*/React.createElement("div", _extends({ | ||
className: classNames(prefixCls, className, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-rtl"), direction === 'rtl'), "".concat(prefixCls, "-ping-left"), pingedLeft), "".concat(prefixCls, "-ping-right"), pingedRight), "".concat(prefixCls, "-layout-fixed"), tableLayout === 'fixed'), "".concat(prefixCls, "-fixed-header"), fixHeader), "".concat(prefixCls, "-fixed-column"), fixColumn), "".concat(prefixCls, "-scroll-horizontal"), horizonScroll), "".concat(prefixCls, "-has-fix-left"), flattenColumns[0] && flattenColumns[0].fixed), "".concat(prefixCls, "-has-fix-right"), flattenColumns[flattenColumns.length - 1] && flattenColumns[flattenColumns.length - 1].fixed === 'right')), | ||
className: classNames(prefixCls, className, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-rtl"), direction === 'rtl'), _defineProperty(_classNames, "".concat(prefixCls, "-ping-left"), pingedLeft), _defineProperty(_classNames, "".concat(prefixCls, "-ping-right"), pingedRight), _defineProperty(_classNames, "".concat(prefixCls, "-layout-fixed"), tableLayout === 'fixed'), _defineProperty(_classNames, "".concat(prefixCls, "-fixed-header"), fixHeader), _defineProperty(_classNames, "".concat(prefixCls, "-fixed-column"), fixColumn), _defineProperty(_classNames, "".concat(prefixCls, "-fixed-column-gapped"), fixColumn && hasGapFixed), _defineProperty(_classNames, "".concat(prefixCls, "-scroll-horizontal"), horizonScroll), _defineProperty(_classNames, "".concat(prefixCls, "-has-fix-left"), flattenColumns[0] && flattenColumns[0].fixed), _defineProperty(_classNames, "".concat(prefixCls, "-has-fix-right"), flattenColumns[flattenColumns.length - 1] && flattenColumns[flattenColumns.length - 1].fixed === 'right'), _classNames)), | ||
style: style, | ||
@@ -579,0 +581,0 @@ id: id, |
@@ -5,2 +5,3 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
export function renderExpandIcon(_ref) { | ||
var _classNames; | ||
var prefixCls = _ref.prefixCls, | ||
@@ -22,3 +23,3 @@ record = _ref.record, | ||
return /*#__PURE__*/React.createElement("span", { | ||
className: classNames(expandClassName, _defineProperty(_defineProperty({}, "".concat(prefixCls, "-row-expanded"), expanded), "".concat(prefixCls, "-row-collapsed"), !expanded)), | ||
className: classNames(expandClassName, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-row-expanded"), expanded), _defineProperty(_classNames, "".concat(prefixCls, "-row-collapsed"), !expanded), _classNames)), | ||
onClick: onClick | ||
@@ -25,0 +26,0 @@ }); |
@@ -133,3 +133,3 @@ "use strict"; | ||
// >>>>> ClassName | ||
var mergedClassName = (0, _classnames.default)(cellPrefixCls, className, (_classNames = {}, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)(_classNames, "".concat(cellPrefixCls, "-fix-left"), isFixLeft && supportSticky), "".concat(cellPrefixCls, "-fix-left-first"), firstFixLeft && supportSticky), "".concat(cellPrefixCls, "-fix-left-last"), lastFixLeft && supportSticky), "".concat(cellPrefixCls, "-fix-left-all"), lastFixLeft && allColumnsFixedLeft && supportSticky), "".concat(cellPrefixCls, "-fix-right"), isFixRight && supportSticky), "".concat(cellPrefixCls, "-fix-right-first"), firstFixRight && supportSticky), "".concat(cellPrefixCls, "-fix-right-last"), lastFixRight && supportSticky), "".concat(cellPrefixCls, "-ellipsis"), ellipsis), "".concat(cellPrefixCls, "-with-append"), appendNode), "".concat(cellPrefixCls, "-fix-sticky"), (isFixLeft || isFixRight) && isSticky && supportSticky), (0, _defineProperty2.default)(_classNames, "".concat(cellPrefixCls, "-row-hover"), !legacyCellProps && hovering)), additionalProps.className, legacyCellProps === null || legacyCellProps === void 0 ? void 0 : legacyCellProps.className); | ||
var mergedClassName = (0, _classnames.default)(cellPrefixCls, className, (_classNames = {}, (0, _defineProperty2.default)(_classNames, "".concat(cellPrefixCls, "-fix-left"), isFixLeft && supportSticky), (0, _defineProperty2.default)(_classNames, "".concat(cellPrefixCls, "-fix-left-first"), firstFixLeft && supportSticky), (0, _defineProperty2.default)(_classNames, "".concat(cellPrefixCls, "-fix-left-last"), lastFixLeft && supportSticky), (0, _defineProperty2.default)(_classNames, "".concat(cellPrefixCls, "-fix-left-all"), lastFixLeft && allColumnsFixedLeft && supportSticky), (0, _defineProperty2.default)(_classNames, "".concat(cellPrefixCls, "-fix-right"), isFixRight && supportSticky), (0, _defineProperty2.default)(_classNames, "".concat(cellPrefixCls, "-fix-right-first"), firstFixRight && supportSticky), (0, _defineProperty2.default)(_classNames, "".concat(cellPrefixCls, "-fix-right-last"), lastFixRight && supportSticky), (0, _defineProperty2.default)(_classNames, "".concat(cellPrefixCls, "-ellipsis"), ellipsis), (0, _defineProperty2.default)(_classNames, "".concat(cellPrefixCls, "-with-append"), appendNode), (0, _defineProperty2.default)(_classNames, "".concat(cellPrefixCls, "-fix-sticky"), (isFixLeft || isFixRight) && isSticky && supportSticky), (0, _defineProperty2.default)(_classNames, "".concat(cellPrefixCls, "-row-hover"), !legacyCellProps && hovering), _classNames), additionalProps.className, legacyCellProps === null || legacyCellProps === void 0 ? void 0 : legacyCellProps.className); | ||
@@ -136,0 +136,0 @@ // >>>>> Style |
@@ -28,4 +28,5 @@ import * as React from 'react'; | ||
flattenColumns: readonly ColumnType<RecordType>[], | ||
realScrollWidth: undefined | number | ||
realScrollWidth: undefined | number, | ||
hasGapFixed: boolean | ||
]; | ||
export default useColumns; |
@@ -80,24 +80,2 @@ "use strict"; | ||
} | ||
function warningFixed(flattenColumns) { | ||
var allFixLeft = true; | ||
for (var i = 0; i < flattenColumns.length; i += 1) { | ||
var col = flattenColumns[i]; | ||
if (allFixLeft && col.fixed !== 'left') { | ||
allFixLeft = false; | ||
} else if (!allFixLeft && col.fixed === 'left') { | ||
(0, _warning.default)(false, "Index ".concat(i - 1, " of `columns` missing `fixed='left'` prop.")); | ||
break; | ||
} | ||
} | ||
var allFixRight = true; | ||
for (var _i = flattenColumns.length - 1; _i >= 0; _i -= 1) { | ||
var _col = flattenColumns[_i]; | ||
if (allFixRight && _col.fixed !== 'right') { | ||
allFixRight = false; | ||
} else if (!allFixRight && _col.fixed === 'right') { | ||
(0, _warning.default)(false, "Index ".concat(_i + 1, " of `columns` missing `fixed='right'` prop.")); | ||
break; | ||
} | ||
} | ||
} | ||
function revertForRtl(columns) { | ||
@@ -150,2 +128,3 @@ return columns.map(function (column) { | ||
if (expandable) { | ||
var _expandColumn; | ||
var cloneColumns = baseColumns.slice(); | ||
@@ -189,6 +168,6 @@ | ||
// >>> Create expandable column | ||
var expandColumn = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _legacyUtil.INTERNAL_COL_DEFINE, { | ||
var expandColumn = (_expandColumn = {}, (0, _defineProperty2.default)(_expandColumn, _legacyUtil.INTERNAL_COL_DEFINE, { | ||
className: "".concat(prefixCls, "-expand-icon-col"), | ||
columnType: 'EXPAND_COLUMN' | ||
}), "title", columnTitle), "fixed", fixedColumn), "className", "".concat(prefixCls, "-row-expand-icon-cell")), "width", columnWidth), "render", function render(_, record, index) { | ||
}), (0, _defineProperty2.default)(_expandColumn, "title", columnTitle), (0, _defineProperty2.default)(_expandColumn, "fixed", fixedColumn), (0, _defineProperty2.default)(_expandColumn, "className", "".concat(prefixCls, "-row-expand-icon-cell")), (0, _defineProperty2.default)(_expandColumn, "width", columnWidth), (0, _defineProperty2.default)(_expandColumn, "render", function render(_, record, index) { | ||
var rowKey = getRowKey(record, index); | ||
@@ -212,3 +191,3 @@ var expanded = expandedKeys.has(rowKey); | ||
return icon; | ||
}); | ||
}), _expandColumn); | ||
return cloneColumns.map(function (col) { | ||
@@ -252,7 +231,38 @@ return col === _constant.EXPAND_COLUMN ? expandColumn : col; | ||
// Only check out of production since it's waste for each render | ||
if (process.env.NODE_ENV !== 'production') { | ||
warningFixed(direction === 'rtl' ? flattenColumns.slice().reverse() : flattenColumns); | ||
} | ||
// ========================= Gap Fixed ======================== | ||
var hasGapFixed = React.useMemo(function () { | ||
// Fixed: left, since old browser not support `findLastIndex`, we should use reverse loop | ||
var lastLeftIndex = -1; | ||
for (var i = flattenColumns.length - 1; i >= 0; i -= 1) { | ||
var colFixed = flattenColumns[i].fixed; | ||
if (colFixed === 'left' || colFixed === true) { | ||
lastLeftIndex = i; | ||
break; | ||
} | ||
} | ||
if (lastLeftIndex >= 0) { | ||
for (var _i = 0; _i <= lastLeftIndex; _i += 1) { | ||
var _colFixed = flattenColumns[_i].fixed; | ||
if (_colFixed !== 'left' && _colFixed !== true) { | ||
return true; | ||
} | ||
} | ||
} | ||
// Fixed: right | ||
var firstRightIndex = flattenColumns.findIndex(function (_ref3) { | ||
var colFixed = _ref3.fixed; | ||
return colFixed === 'right'; | ||
}); | ||
if (firstRightIndex >= 0) { | ||
for (var _i2 = firstRightIndex; _i2 < flattenColumns.length; _i2 += 1) { | ||
var _colFixed2 = flattenColumns[_i2].fixed; | ||
if (_colFixed2 !== 'right') { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
}, [flattenColumns]); | ||
// ========================= FillWidth ======================== | ||
@@ -263,4 +273,4 @@ var _useWidthColumns = (0, _useWidthColumns3.default)(flattenColumns, scrollWidth, clientWidth), | ||
realScrollWidth = _useWidthColumns2[1]; | ||
return [mergedColumns, filledColumns, realScrollWidth]; | ||
return [mergedColumns, filledColumns, realScrollWidth, hasGapFixed]; | ||
} | ||
var _default = exports.default = useColumns; |
@@ -1,6 +0,6 @@ | ||
import type { Direction, StickyOffsets } from '../interface'; | ||
import type { ColumnType, Direction, StickyOffsets } from '../interface'; | ||
/** | ||
* Get sticky column offset width | ||
*/ | ||
declare function useStickyOffsets(colWidths: number[], columnCount: number, direction: Direction): StickyOffsets; | ||
declare function useStickyOffsets<RecordType>(colWidths: number[], flattenColumns: readonly ColumnType<RecordType>[], direction: Direction): StickyOffsets; | ||
export default useStickyOffsets; |
@@ -11,36 +11,28 @@ "use strict"; | ||
*/ | ||
function useStickyOffsets(colWidths, columnCount, direction) { | ||
function useStickyOffsets(colWidths, flattenColumns, direction) { | ||
var stickyOffsets = (0, _react.useMemo)(function () { | ||
var leftOffsets = []; | ||
var rightOffsets = []; | ||
var left = 0; | ||
var right = 0; | ||
for (var start = 0; start < columnCount; start += 1) { | ||
if (direction === 'rtl') { | ||
// Left offset | ||
rightOffsets[start] = right; | ||
right += colWidths[start] || 0; | ||
// Right offset | ||
var end = columnCount - start - 1; | ||
leftOffsets[end] = left; | ||
left += colWidths[end] || 0; | ||
} else { | ||
// Left offset | ||
leftOffsets[start] = left; | ||
left += colWidths[start] || 0; | ||
// Right offset | ||
var _end = columnCount - start - 1; | ||
rightOffsets[_end] = right; | ||
right += colWidths[_end] || 0; | ||
var columnCount = flattenColumns.length; | ||
var getOffsets = function getOffsets(startIndex, endIndex, offset) { | ||
var offsets = []; | ||
var total = 0; | ||
for (var i = startIndex; i !== endIndex; i += offset) { | ||
offsets.push(total); | ||
if (flattenColumns[i].fixed) { | ||
total += colWidths[i] || 0; | ||
} | ||
} | ||
} | ||
return { | ||
left: leftOffsets, | ||
right: rightOffsets | ||
return offsets; | ||
}; | ||
}, [colWidths, columnCount, direction]); | ||
var startOffsets = getOffsets(0, columnCount, 1); | ||
var endOffsets = getOffsets(columnCount - 1, -1, -1).reverse(); | ||
return direction === 'rtl' ? { | ||
left: endOffsets, | ||
right: startOffsets | ||
} : { | ||
left: startOffsets, | ||
right: endOffsets | ||
}; | ||
}, [colWidths, flattenColumns, direction]); | ||
return stickyOffsets; | ||
} | ||
var _default = exports.default = useStickyOffsets; |
import { EXPAND_COLUMN, INTERNAL_HOOKS } from './constant'; | ||
import { FooterComponents as Summary } from './Footer'; | ||
import type { ColumnType, Reference } from './interface'; | ||
import type { ColumnType, ColumnsType, Reference } from './interface'; | ||
import Column from './sugar/Column'; | ||
@@ -11,3 +11,3 @@ import ColumnGroup from './sugar/ColumnGroup'; | ||
import VirtualTable, { genVirtualTable } from './VirtualTable'; | ||
export { genTable, Summary, Column, ColumnGroup, type TableProps, INTERNAL_COL_DEFINE, EXPAND_COLUMN, INTERNAL_HOOKS, VirtualTable, genVirtualTable, type VirtualTableProps, type Reference, type ColumnType, }; | ||
export { genTable, Summary, Column, ColumnGroup, type TableProps, INTERNAL_COL_DEFINE, EXPAND_COLUMN, INTERNAL_HOOKS, VirtualTable, genVirtualTable, type VirtualTableProps, type Reference, type ColumnType, type ColumnsType, }; | ||
export default Table; |
@@ -11,4 +11,3 @@ "use strict"; | ||
* So HOC will not work on this. | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
*/ // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
function Column(_) { | ||
@@ -15,0 +14,0 @@ return null; |
@@ -11,4 +11,3 @@ "use strict"; | ||
* So HOC will not work on this. | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
*/ // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
function ColumnGroup(_) { | ||
@@ -15,0 +14,0 @@ return null; |
@@ -83,2 +83,3 @@ "use strict"; | ||
function Table(tableProps, ref) { | ||
var _classNames; | ||
var props = (0, _objectSpread2.default)({ | ||
@@ -180,6 +181,7 @@ rowKey: 'key', | ||
}), useInternalHooks ? transformColumns : null), | ||
_useColumns2 = (0, _slicedToArray2.default)(_useColumns, 3), | ||
_useColumns2 = (0, _slicedToArray2.default)(_useColumns, 4), | ||
columns = _useColumns2[0], | ||
flattenColumns = _useColumns2[1], | ||
flattenScrollX = _useColumns2[2]; | ||
flattenScrollX = _useColumns2[2], | ||
hasGapFixed = _useColumns2[3]; | ||
var mergedScrollX = flattenScrollX !== null && flattenScrollX !== void 0 ? flattenScrollX : scrollX; | ||
@@ -249,3 +251,3 @@ var columnContext = React.useMemo(function () { | ||
}, [pureColWidths.join('_')]); | ||
var stickyOffsets = (0, _useStickyOffsets.default)(colWidths, flattenColumns.length, direction); | ||
var stickyOffsets = (0, _useStickyOffsets.default)(colWidths, flattenColumns, direction); | ||
var fixHeader = scroll && (0, _valueUtil.validateValue)(scroll.y); | ||
@@ -587,3 +589,3 @@ var horizonScroll = scroll && (0, _valueUtil.validateValue)(mergedScrollX) || Boolean(expandableConfig.fixed); | ||
var fullTable = /*#__PURE__*/React.createElement("div", (0, _extends2.default)({ | ||
className: (0, _classnames.default)(prefixCls, className, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, "".concat(prefixCls, "-rtl"), direction === 'rtl'), "".concat(prefixCls, "-ping-left"), pingedLeft), "".concat(prefixCls, "-ping-right"), pingedRight), "".concat(prefixCls, "-layout-fixed"), tableLayout === 'fixed'), "".concat(prefixCls, "-fixed-header"), fixHeader), "".concat(prefixCls, "-fixed-column"), fixColumn), "".concat(prefixCls, "-scroll-horizontal"), horizonScroll), "".concat(prefixCls, "-has-fix-left"), flattenColumns[0] && flattenColumns[0].fixed), "".concat(prefixCls, "-has-fix-right"), flattenColumns[flattenColumns.length - 1] && flattenColumns[flattenColumns.length - 1].fixed === 'right')), | ||
className: (0, _classnames.default)(prefixCls, className, (_classNames = {}, (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-rtl"), direction === 'rtl'), (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-ping-left"), pingedLeft), (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-ping-right"), pingedRight), (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-layout-fixed"), tableLayout === 'fixed'), (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-fixed-header"), fixHeader), (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-fixed-column"), fixColumn), (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-fixed-column-gapped"), fixColumn && hasGapFixed), (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-scroll-horizontal"), horizonScroll), (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-has-fix-left"), flattenColumns[0] && flattenColumns[0].fixed), (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-has-fix-right"), flattenColumns[flattenColumns.length - 1] && flattenColumns[flattenColumns.length - 1].fixed === 'right'), _classNames)), | ||
style: style, | ||
@@ -590,0 +592,0 @@ id: id, |
@@ -16,2 +16,3 @@ "use strict"; | ||
function renderExpandIcon(_ref) { | ||
var _classNames; | ||
var prefixCls = _ref.prefixCls, | ||
@@ -33,3 +34,3 @@ record = _ref.record, | ||
return /*#__PURE__*/React.createElement("span", { | ||
className: (0, _classnames.default)(expandClassName, (0, _defineProperty2.default)((0, _defineProperty2.default)({}, "".concat(prefixCls, "-row-expanded"), expanded), "".concat(prefixCls, "-row-collapsed"), !expanded)), | ||
className: (0, _classnames.default)(expandClassName, (_classNames = {}, (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-row-expanded"), expanded), (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-row-collapsed"), !expanded), _classNames)), | ||
onClick: onClick | ||
@@ -36,0 +37,0 @@ }); |
{ | ||
"name": "rc-table", | ||
"version": "7.38.1", | ||
"version": "7.39.0", | ||
"description": "table ui component for react", | ||
@@ -65,13 +65,12 @@ "engines": { | ||
"@rc-component/father-plugin": "^1.0.2", | ||
"@testing-library/jest-dom": "^5.16.5", | ||
"@testing-library/jest-dom": "^6.4.0", | ||
"@testing-library/react": "^12.1.5", | ||
"@types/enzyme": "^3.10.5", | ||
"@types/jest": "^29.5.0", | ||
"@types/react": "^18.0.28", | ||
"@types/jest": "^29.5.0", | ||
"@types/react-dom": "^18.0.5", | ||
"@types/responselike": "^1.0.0", | ||
"@types/styled-components": "^5.1.32", | ||
"@types/testing-library__jest-dom": "^6.0.0", | ||
"@umijs/fabric": "^4.0.1", | ||
"@vitest/coverage-c8": "^0.31.0", | ||
"@vitest/coverage-v8": "^1.2.2", | ||
"cross-env": "^7.0.0", | ||
@@ -109,3 +108,3 @@ "dumi": "^2.1.3", | ||
"typescript": "~5.3.0", | ||
"vitest": "^0.31.0" | ||
"vitest": "^1.2.2" | ||
}, | ||
@@ -112,0 +111,0 @@ "lint-staged": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
395249
44
8748
58