Skip to content
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

refactor: rc-component/table #1219

Merged
merged 8 commits into from
Jan 17, 2025
Merged

refactor: rc-component/table #1219

merged 8 commits into from
Jan 17, 2025

Conversation

li-jia-nan
Copy link
Member

@li-jia-nan li-jia-nan commented Jan 10, 2025

Summary by CodeRabbit

发行说明

  • 新功能

    • 将包名从 rc-table 更改为 @rc-component/table
    • 表格组件的 API 进行了重构,简化了展开行和数据索引的处理
    • 新增了 summary 属性,允许自定义渲染表格摘要
  • 依赖变更

    • rc-util 迁移到 @rc-component/util
    • 更新了多个实用函数的导入路径
    • 添加了 @rc-component/util 依赖,移除了 rc-util
  • 版本更新

    • 版本号从 7.50.2 更改为 1.0.0

这些更改主要涉及包的重组和依赖管理,对用户的影响相对较小。

@li-jia-nan li-jia-nan requested a review from zombieJ January 10, 2025 19:25
Copy link

vercel bot commented Jan 10, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
table ❌ Failed (Inspect) Jan 17, 2025 8:34am

Copy link

coderabbitai bot commented Jan 10, 2025

概述

演练

这个拉取请求主要涉及从 rc-util 库到 @rc-component/util 库的广泛迁移。更改包括更新多个文件中的导入路径、重命名包名、更新依赖项,以及对 Table 组件的 API 进行了一些重构。这些更改反映了库的重组和版本升级,同时保持了大部分功能的一致性。

变更

文件 变更摘要
package.json - 包名从 rc-table 更改为 @rc-component/table
- 版本从 7.50.2 升级到 1.0.0-0
- 添加 @rc-component/util 依赖
- 移除 rc-util 依赖
多个 src/* 文件 rc-util 更新导入路径到 @rc-component/util
src/Table.tsx - 移除多个属性(如 expandIconAsCelluseFixedHeader
- 引入 expandablesummary 属性

序列图

sequenceDiagram
    participant Dev as 开发者
    participant Table as Table组件
    participant Util as @rc-component/util

    Dev->>Table: 配置表格
    Table->>Util: 请求工具函数
    Util-->>Table: 返回工具函数
    Table->>Dev: 渲染表格
Loading

可能相关的 PR

建议的审阅者

  • afc163

诗歌

🐰 代码的海洋,变化如潮
从 rc-util 到新的家
依赖重构,版本飞翔
兔子微笑,一切安好
开源的旅途,勇往直前!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 70c3661 and 1932798.

📒 Files selected for processing (1)
  • package.json (2 hunks)
🔇 Additional comments (2)
package.json (2)

63-63: 开发依赖版本升级

@rc-component/father-plugin 升级到 ^2.0.1 可能引入新特性或破坏性变更,建议:

  1. 检查 father-plugin 的更新日志
  2. 验证构建输出是否符合预期

57-57: 依赖迁移需要验证兼容性

rc-util 迁移至 @rc-component/util 是一个重要变更,需要:

  1. 确保所有 API 的兼容性
  2. 验证功能完整性
  3. 更新相关文档
✅ Verification successful

依赖迁移已完成且符合预期

代码库已完全从 rc-util 迁移至 @rc-component/[email protected],并且:

  • 所有原有 API 均已正确迁移
  • 未发现遗留的 rc-util 引用
  • 新包的使用模式保持一致
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查是否还有遗留的 rc-util 引用
rg "from 'rc-util" -t ts -t tsx
rg "from \"rc-util" -t ts -t tsx

Length of output: 126


Script:

#!/bin/bash
# 检查是否还存在 rc-util 的引用
echo "=== 检查 rc-util 导入 ==="
rg "from ['\"]rc-util" -l

echo -e "\n=== 检查 package.json 中的依赖 ==="
cat package.json | grep -i "rc-util"

echo -e "\n=== 检查具体的导入使用情况 ==="
rg "from ['\"]rc-util" -A 1

Length of output: 279


Script:

#!/bin/bash
# 检查新包的使用情况
echo "=== 检查 @rc-component/util 的导入 ==="
rg "from ['\"]@rc-component/util" -A 1

echo -e "\n=== 检查 package.json 中的新依赖版本 ==="
cat package.json | grep -A 1 -B 1 "@rc-component/util"

Length of output: 5559


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🔭 Outside diff range comments (1)
src/Table.tsx (1)

Line range hint 530-532: 修复可能的 TypeError 错误

在第 530-532 行,scrollBodyRef.current 可能为 undefined,直接使用会导致 TypeError,正如流水线失败日志所示。建议在使用前添加空值检查。

提供以下代码修改以修复此问题:

if (horizonScroll && scrollBodyRef.current) {
-   onInternalScroll({
-     currentTarget: getDOM(scrollBodyRef.current) as HTMLElement,
+   const currentTarget = getDOM(scrollBodyRef.current) as HTMLElement;
+   if (currentTarget) {
+     onInternalScroll({
+       currentTarget,
        scrollLeft: scrollBodyRef.current?.scrollLeft,
      });
+   }
  } else {
    setPingedLeft(false);
    setPingedRight(false);
  }
🧹 Nitpick comments (3)
src/stickyScrollBar.tsx (3)

61-63: 移除不必要的 event.persist() 调用

onMouseDown 函数中调用了 event.persist(),但在现代 React 中已不再需要。建议移除此调用。

提供以下代码修改:

const onMouseDown = (event: React.MouseEvent) => {
-   event.persist();
    refState.current.delta = event.pageX - scrollState.scrollLeft;
    refState.current.x = 0;
    setActive(true);
    event.preventDefault();
};

Line range hint 69-81: onMouseMove 事件参数指定正确的类型

onMouseMove 函数的事件参数当前类型为 any,建议将其明确为 MouseEvent 类型,增强类型安全性。

提供以下代码修改:

- const onMouseMove = (event: any) => {
+ const onMouseMove = (event: MouseEvent) => {
    // ...
}

79-81: 简化 left 计算表达式

在计算 left 时,存在冗余运算,可以简化为:

提供以下代码修改:

- let left = refState.current.x + event.pageX - refState.current.x - refState.current.delta;
+ let left = event.pageX - refState.current.delta;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 489e40f and b530fe9.

📒 Files selected for processing (27)
  • docs/examples/animation.tsx (1 hunks)
  • package.json (2 hunks)
  • src/Cell/index.tsx (1 hunks)
  • src/Cell/useCellRender.ts (1 hunks)
  • src/FixedHolder/index.tsx (1 hunks)
  • src/Table.tsx (2 hunks)
  • src/VirtualTable/index.tsx (1 hunks)
  • src/hooks/useColumns/index.tsx (1 hunks)
  • src/hooks/useExpand.ts (1 hunks)
  • src/hooks/useFixedInfo.ts (1 hunks)
  • src/hooks/useRowInfo.tsx (1 hunks)
  • src/hooks/useSticky.ts (1 hunks)
  • src/stickyScrollBar.tsx (6 hunks)
  • src/utils/legacyUtil.ts (1 hunks)
  • src/utils/offsetUtil.ts (1 hunks)
  • tests/Deprecated.spec.jsx (1 hunks)
  • tests/ExpandRow.spec.jsx (1 hunks)
  • tests/FixedColumn-IE.spec.jsx (1 hunks)
  • tests/FixedColumn.spec.tsx (1 hunks)
  • tests/FixedHeader.spec.jsx (1 hunks)
  • tests/Hover.spec.tsx (1 hunks)
  • tests/Scroll.spec.jsx (1 hunks)
  • tests/Sticky.spec.jsx (1 hunks)
  • tests/Table.spec.jsx (1 hunks)
  • tests/Virtual.spec.tsx (1 hunks)
  • tests/refs.spec.tsx (1 hunks)
  • tests/setup.ts (1 hunks)
✅ Files skipped from review due to trivial changes (23)
  • tests/FixedColumn.spec.tsx
  • src/hooks/useColumns/index.tsx
  • tests/Deprecated.spec.jsx
  • src/Cell/index.tsx
  • tests/Scroll.spec.jsx
  • tests/Table.spec.jsx
  • src/utils/legacyUtil.ts
  • docs/examples/animation.tsx
  • src/VirtualTable/index.tsx
  • tests/refs.spec.tsx
  • src/hooks/useExpand.ts
  • src/FixedHolder/index.tsx
  • src/hooks/useRowInfo.tsx
  • tests/ExpandRow.spec.jsx
  • src/hooks/useFixedInfo.ts
  • tests/Hover.spec.tsx
  • src/utils/offsetUtil.ts
  • tests/FixedColumn-IE.spec.jsx
  • tests/FixedHeader.spec.jsx
  • src/hooks/useSticky.ts
  • tests/Sticky.spec.jsx
  • src/Cell/useCellRender.ts
  • tests/Virtual.spec.tsx
🧰 Additional context used
🪛 GitHub Actions: ✅ test
src/Table.tsx

[error] 530-532: TypeError: Cannot read properties of undefined (reading 'width'). The error occurs when trying to access width property of scrollBodyRef.current or scrollBodyContainerRef which is undefined.

🔇 Additional comments (8)
src/Table.tsx (2)

30-36: 新的导入语句正确更新

导入语句已更新为使用新的 @rc-component/util 库,配置看起来正确。


78-78: 验证 getDOM 导入路径的正确性

请确认从 @rc-component/util/lib/Dom/findDOMNode 导入的 getDOM 函数路径是否正确,以确保模块路径和函数名准确无误。

tests/setup.ts (1)

10-10: 确认模拟模块的导入路径

已将模拟的模块路径更改为 @rc-component/util/lib/getScrollBarSize,请确认此路径和模块名称正确,确保测试能够正常运行。

src/stickyScrollBar.tsx (4)

3-3: 更新 getScrollBarSize 的导入路径

getScrollBarSize 的导入路径更新为 @rc-component/util/lib/getScrollBarSize,看起来正确。


7-7: 更新 raf 的导入路径

raf 的导入路径更新为 @rc-component/util/lib/raf,看起来正确。


10-14: 引入事件名称常量提高可读性

将事件名称提取为常量,提高了代码的可读性和维护性。


141-149: 确认使用 document.body 添加事件监听器的适用性

在添加和移除事件监听器时,使用了 document.body。请确认在所有目标浏览器中,这样的使用方式都能正常工作。如有必要,考虑改为使用 document

package.json (1)

58-58: 依赖包更新提醒

rc-util 替换为 @rc-component/util 是一个重要变更:

  1. 请确保新包 @rc-component/util 提供了与 rc-util 相同的功能
  2. 建议添加相关测试用例验证功能完整性

运行以下脚本检查依赖变更的影响:

✅ Verification successful

依赖迁移验证完成

经过代码扫描,确认:

  • 已完全移除 rc-util 的引用
  • @rc-component/util 的功能已被正确使用
  • 所有相关导入都已更新
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查是否还有遗留的 rc-util 导入
rg "from 'rc-util" || rg "from \"rc-util"

# 检查是否所有 @rc-component/util 的导入都是有效的
rg "from '@rc-component/util" || rg "from \"@rc-component/util"

Length of output: 3661

package.json Outdated Show resolved Hide resolved
Copy link

socket-security bot commented Jan 13, 2025

New, updated, and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@rc-component/[email protected] 🔁 npm/@rc-component/[email protected] None 0 8.71 kB afc163
npm/@rc-component/[email protected] environment +1 202 kB zombiej

View full report↗︎

Copy link

codecov bot commented Jan 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.76%. Comparing base (bd5e664) to head (1932798).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1219      +/-   ##
==========================================
- Coverage   97.76%   97.76%   -0.01%     
==========================================
  Files          76       76              
  Lines        7443     7441       -2     
  Branches     1128     1128              
==========================================
- Hits         7277     7275       -2     
  Misses        160      160              
  Partials        6        6              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2bd1de9 and 70c3661.

📒 Files selected for processing (1)
  • package.json (2 hunks)
🔇 Additional comments (2)
package.json (2)

Line range hint 2-58: 重大变更缺少必要文档说明

CHANGELOG.md 需要更新以下重要内容:

  • 包名从 rc-table 变更为 @rc-component/table 的说明
  • 版本从 7.50.2 降至 1.0.0-0 的破坏性变更详情
  • rc-util 迁移至 @rc-component/util 的迁移指南

建议:

  • 更新 CHANGELOG.md,添加 1.0.0 版本的完整变更记录
  • 添加迁移指南,详细说明 API 变更和依赖更新步骤
  • 考虑创建单独的 MIGRATION.md 文件

58-58: 依赖包迁移需要同步更新

将工具库从 rc-util 迁移至 @rc-component/util 是一个重要变更。请确保:

  1. 所有使用 rc-util 的代码都已更新
  2. 新的依赖版本 ^1.1.0 包含所需的所有功能
✅ Verification successful

依赖迁移已完成且使用正确

经验证,代码库中已完全迁移至 @rc-component/util

  • 所有原 rc-util 的引用已被移除
  • 新包 @rc-component/util 已在源码、测试和文档中得到广泛使用
  • 版本 ^1.1.0 满足当前使用需求
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查是否还有遗留的 rc-util 引用
rg "from 'rc-util" -l
rg "from \"rc-util" -l

Length of output: 50


Script:

#!/bin/bash
# Check if rc-util is still in package.json
grep -A 1 -B 1 "rc-util" package.json

# Broader search for any rc-util references
rg "rc-util" -l

# Check usage of new package
rg "@rc-component/util" -l

# Check actual imports from new package
ast-grep --pattern 'import $_ from "@rc-component/util"'

Length of output: 771

Comment on lines +2 to +3
"name": "@rc-component/table",
"version": "1.0.0-0",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

包名和版本号的重大变更需要谨慎处理

这些变更将对所有依赖项目产生重大影响:

  • 包名从 rc-table 变更为 @rc-component/table
  • 版本从 7.50.2 降至 1.0.0-0

建议:

  1. 确保已完成全面的测试
  2. 提供详细的迁移文档
  3. 考虑使用 alpha/beta 版本进行过渡

@zombieJ zombieJ merged commit 5703c8e into master Jan 17, 2025
11 of 12 checks passed
@zombieJ zombieJ deleted the v6-update branch January 17, 2025 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants