Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 616
chore: sync antd-5.x to master#1336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
cad1f52542000c1e2ec33a056eaa42c37bd17fa387bd18ca48e6e892ffa3cea6c7dee31b655a748c89763e9410a3916bd3e97f0df8fd0790ce95747d22b38c1b75be29fd05efb6de81c8a7dac039c323a5531b2a46a165d024e63e29685c2524676754f9f28b0a7ff0File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| shamefully-hoist=true | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2,23 +2,25 @@ import * as React from 'react'; | ||
| import ResizeObserver from '@rc-component/resize-observer'; | ||
| import MeasureCell from './MeasureCell'; | ||
| import isVisible from '@rc-component/util/lib/Dom/isVisible'; | ||
| import type { ColumnType } from '../interface'; | ||
| export interface MeasureCellProps { | ||
| export interface MeasureRowProps { | ||
| prefixCls: string; | ||
| onColumnResize: (key: React.Key, width: number) => void; | ||
| columnsKey: React.Key[]; | ||
| columns: readonly ColumnType<any>[]; | ||
| } | ||
| export default function MeasureRow({ prefixCls, columnsKey, onColumnResize }: MeasureCellProps) { | ||
| export default function MeasureRow({ | ||
| prefixCls, | ||
| columnsKey, | ||
| onColumnResize, | ||
| columns, | ||
| }: MeasureRowProps) { | ||
| const ref = React.useRef<HTMLTableRowElement>(null); | ||
| return ( | ||
| <tr | ||
| aria-hidden="true" | ||
| className={`${prefixCls}-measure-row`} | ||
| style={{ height: 0, fontSize: 0 }} | ||
| ref={ref} | ||
| > | ||
| <tr aria-hidden="true" className={`${prefixCls}-measure-row`} style={{ height: 0 }} ref={ref}> | ||
| <ResizeObserver.Collection | ||
| onBatchResize={infoList => { | ||
| if (isVisible(ref.current)) { | ||
| @@ -28,9 +30,17 @@ export default function MeasureRow({ prefixCls, columnsKey, onColumnResize }: Me | ||
| } | ||
| }} | ||
| > | ||
| {columnsKey.map(columnKey => ( | ||
| <MeasureCell key={columnKey} columnKey={columnKey} onColumnResize={onColumnResize} /> | ||
| ))} | ||
| {columnsKey.map(columnKey => { | ||
| const column = columns.find(col => col.key === columnKey); | ||
| return ( | ||
| <MeasureCell | ||
| key={columnKey} | ||
| columnKey={columnKey} | ||
| onColumnResize={onColumnResize} | ||
| column={column} | ||
| /> | ||
| ); | ||
| })} | ||
crazyair marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| </ResizeObserver.Collection> | ||
| </tr> | ||
| ); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -22,7 +22,7 @@ function ColGroup<RecordType>({ colWidths, columns, columCount }: ColGroupProps< | ||
| for (let i = len - 1; i >= 0; i -= 1) { | ||
| const width = colWidths[i]; | ||
| const column = columns && columns[i]; | ||
| let additionalProps; | ||
| let additionalProps: Record<string, unknown>; | ||
| let minWidth: number; | ||
crazyair marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| if (column) { | ||
| additionalProps = column[INTERNAL_COL_DEFINE]; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -7,7 +7,7 @@ import ColGroup from '../ColGroup'; | ||
| import TableContext from '../context/TableContext'; | ||
| import type { HeaderProps } from '../Header/Header'; | ||
| import devRenderTimes from '../hooks/useRenderTimes'; | ||
| import type { ColumnsType, ColumnType, Direction } from '../interface'; | ||
| import type { ColumnsType, ColumnType, Direction, TableLayout } from '../interface'; | ||
| function useColumnWidth(colWidths: readonly number[], columCount: number) { | ||
| return useMemo(() => { | ||
| @@ -36,6 +36,8 @@ export interface FixedHeaderProps<RecordType> extends HeaderProps<RecordType> { | ||
| stickyTopOffset?: number; | ||
| stickyBottomOffset?: number; | ||
| stickyClassName?: string; | ||
| scrollTableStyle?: React.CSSProperties; | ||
| tableLayout?: TableLayout; | ||
| onScroll: (info: { currentTarget: HTMLDivElement; scrollLeft?: number }) => void; | ||
| children: (info: HeaderProps<RecordType>) => React.ReactNode; | ||
| } | ||
| @@ -59,6 +61,8 @@ const FixedHolder = React.forwardRef<HTMLDivElement, FixedHeaderProps<any>>((pro | ||
| stickyTopOffset, | ||
| stickyBottomOffset, | ||
| stickyClassName, | ||
| scrollTableStyle, | ||
| tableLayout = 'fixed', | ||
| onScroll, | ||
| maxContentScroll, | ||
| children, | ||
| @@ -115,12 +119,6 @@ const FixedHolder = React.forwardRef<HTMLDivElement, FixedHeaderProps<any>>((pro | ||
| }; | ||
| }, []); | ||
| // Check if all flattenColumns has width | ||
| const allFlattenColumnsWithWidth = React.useMemo( | ||
| () => flattenColumns.every(column => column.width), | ||
| [flattenColumns], | ||
| ); | ||
| // Add scrollbar column | ||
| const lastColumn = flattenColumns[flattenColumns.length - 1]; | ||
| const ScrollBarColumn: ColumnType<unknown> & { scrollbar: true } = { | ||
| @@ -158,6 +156,32 @@ const FixedHolder = React.forwardRef<HTMLDivElement, FixedHeaderProps<any>>((pro | ||
| const mergedColumnWidth = useColumnWidth(colWidths, columCount); | ||
| const colGroupNode = useMemo(() => { | ||
| // use original ColGroup if no data or no calculated column width, otherwise use calculated column width | ||
| // Return original colGroup if no data, or mergedColumnWidth is empty, or all widths are falsy | ||
| if ( | ||
| noData || | ||
| !mergedColumnWidth || | ||
| mergedColumnWidth.length === 0 || | ||
| mergedColumnWidth.every(width => !width) | ||
| ) { | ||
| return ColGroup; | ||
crazyair marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| return ( | ||
| <ColGroup | ||
| colWidths={[...mergedColumnWidth, combinationScrollBarSize]} | ||
| columCount={columCount + 1} | ||
| columns={flattenColumnsWithScrollbar} | ||
| /> | ||
| ); | ||
| }, [ | ||
| noData, | ||
| mergedColumnWidth, | ||
| combinationScrollBarSize, | ||
| columCount, | ||
| flattenColumnsWithScrollbar, | ||
| ]); | ||
crazyair marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| return ( | ||
| <div | ||
| style={{ | ||
| @@ -172,17 +196,12 @@ const FixedHolder = React.forwardRef<HTMLDivElement, FixedHeaderProps<any>>((pro | ||
| > | ||
| <TableComponent | ||
| style={{ | ||
| tableLayout: 'fixed', | ||
| tableLayout, | ||
| visibility: noData || mergedColumnWidth ? null : 'hidden', | ||
| ...scrollTableStyle, | ||
| }} | ||
| > | ||
| {(!noData || !maxContentScroll || allFlattenColumnsWithWidth) && ( | ||
| <ColGroup | ||
| colWidths={mergedColumnWidth ? [...mergedColumnWidth, combinationScrollBarSize] : []} | ||
| columCount={columCount + 1} | ||
| columns={flattenColumnsWithScrollbar} | ||
| /> | ||
| )} | ||
| {colGroupNode} | ||
| {children({ | ||
| ...restProps, | ||
| stickyOffsets: headerStickyOffsets, | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
请确认团队确实使用 pnpm;
shamefully-hoist为 pnpm 专属配置。若项目并未统一使用 pnpm,此项在 npm/yarn 下无效,且可能让新同学误解。若确需启用,建议补充注释或以更细粒度的
public-hoist-pattern限定,以避免无差别提升带来的体积增大与掩盖 peerDependencies 问题。可运行下列脚本核实仓库是否以 pnpm 为标准(检查 lockfile、packageManager 字段与 CI 使用情况):
如需仅保留说明,可采纳以下微调,以增加可维护性:
🏁 Script executed:
Length of output: 579
确认并纠正 .npmrc 中的 pnpm 专属配置
当前仓库未检测到 pnpm-lock.yaml、packageManager 字段或 CI 工作流中的 pnpm 相关引用,说明并未使用 pnpm。
shamefully-hoist=true;public-hoist-pattern以限定依赖提升范围,避免体积膨胀和 peerDependencies 被隐藏。🤖 Prompt for AI Agents