Skip to content

feat: enhance panelRender API support components#962

Open
li-jia-nan wants to merge 1 commit intomasterfrom
Panel-panelRender
Open

feat: enhance panelRender API support components#962
li-jia-nan wants to merge 1 commit intomasterfrom
Panel-panelRender

Conversation

@li-jia-nan
Copy link
Copy Markdown
Member

@li-jia-nan li-jia-nan commented Apr 13, 2026

Summary by CodeRabbit

  • New Features

    • panelRender 回调函数现在接收第二个参数,提供面板组件以支持高级定制。
  • Documentation

    • 更新了示例代码,展示 panelRender 回调的新用法。
  • Tests

    • 新增测试用例验证面板自定义渲染功能。

Copilot AI review requested due to automatic review settings April 13, 2026 04:01
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
picker Ready Ready Preview, Comment Apr 13, 2026 4:03am

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 13, 2026

概览

本次变更重构了选择器面板渲染系统,引入新的上下文(Context)和组件包装器,使 panelRender 回调函数接收第二个参数,提供面板组件的自定义能力,同时提取共享逻辑到专用辅助函数中。

变更内容

选择器 / 文件 总结
文档示例
docs/examples/panelRender.tsx
更新 Picker 示例的 panelRender 回调,使其接收第二个参数并解构 components.Panel,渲染输出中新增 <Panel picker="time" /> 元素。
面板上下文提取
src/PickerInput/Popup/PopupPanel.tsx
提取两个新的导出函数:getPopupPanelSharedContext() 用于处理确认提交逻辑,getPopupPanelPickerProps() 用于构造面板属性(包括悬停值、隐藏标题等)。
面板渲染集成
src/PickerInput/Popup/index.tsx
创建 PanelRenderContext 上下文和 PanelRenderPanel 组件包装器;将 panelRender 调用由单参数改为双参数,第二个参数传入 { components: { Panel } };通过上下文注入 needConfirm 和相关属性。
类型定义更新
src/interface.tsx
新增 PanelRenderPanelProps<DateType>PanelRenderExtra<DateType> 类型;更新 SharedPickerProps.panelRender 签名以支持第二个参数传递面板组件。
测试用例
tests/picker.spec.tsx
新增两个 panelRender 测试用例,验证通过 components.Panel 渲染面板和覆盖面板模式的行为。

序列图

sequenceDiagram
    participant User
    participant Popup as Popup<br/>(PopupPanel)
    participant Context as PanelRenderContext
    participant Panel as PanelRenderPanel
    participant Render as panelRender<br/>(Custom)
    participant PickerPanel

    User->>Popup: 打开选择器
    Popup->>Context: 创建上下文<br/>(getPopupPanelSharedContext)
    Popup->>Panel: 注入上下文<br/>Provider
    Panel->>Render: 调用 panelRender<br/>(mergedNodes, { components })
    Render->>Panel: 返回自定义面板内容
    Panel->>Panel: 合并属性<br/>(mode, hideHeader,<br/>components, styles)
    Panel->>PickerPanel: 渲染 PickerPanel<br/>带 PickerHackContext
    PickerPanel->>User: 显示面板 UI
Loading

代码审查工作量评估

🎯 3 (中等复杂度) | ⏱️ ~25 分钟

可能相关的 PR

  • PR #926:同样修改面板渲染和上下文配线,引入并使用 PickerHackContext 相关的面板配置钩子。
  • PR #922:修改选择器/面板渲染上下文接口,更新面板相关类型定义并合并组件、样式配置。

建议审查人员

  • zombieJ
  • afc163

🐰 新上下文绘妙曲,
面板组件任君取,
双参数秘密藏,
选择器换新装,
渲染从此更自由!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了主要变更:增强 panelRender API 以支持自定义 Panel 组件,这正是本次 PR 的核心目的。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch Panel-panelRender

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request enhances the panelRender functionality by providing a second argument that includes a Panel component, allowing users to more easily compose custom layouts within the picker popup. The implementation involves refactoring internal logic into reusable utility functions and introducing a PanelRenderContext to bridge props to the custom panel. Feedback suggests memoizing the panelRenderContext object to prevent unnecessary re-renders of the custom panel components when the parent Popup component updates.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

❌ Patch coverage is 88.09524% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.63%. Comparing base (d27127f) to head (83717a6).

Files with missing lines Patch % Lines
src/PickerInput/Popup/index.tsx 80.76% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #962      +/-   ##
==========================================
- Coverage   98.81%   98.63%   -0.18%     
==========================================
  Files          65       65              
  Lines        2691     2720      +29     
  Branches      722      734      +12     
==========================================
+ Hits         2659     2683      +24     
- Misses         29       32       +3     
- Partials        3        5       +2     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR expands the panelRender API so consumers can render a pre-wired Panel component that automatically inherits the popup’s picker context (value, handlers, config), while still allowing selective overrides (e.g., switching picker to time).

Changes:

  • Extends panelRender to receive an extra object that exposes components.Panel.
  • Introduces a context-backed PanelRenderPanel implementation so Panel instances render with the same popup state/handlers by default.
  • Adds test coverage validating default context wiring and picker override behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/picker.spec.tsx Adds tests proving the new panelRender(..., { components: { Panel }}) API works and supports picker overrides.
src/PickerInput/Popup/PopupPanel.tsx Refactors popup panel context/prop construction into reusable helpers for shared use by Popup and the new Panel component.
src/PickerInput/Popup/index.tsx Implements PanelRenderContext + PanelRenderPanel and wires the new panelRender signature with components.Panel.
src/interface.tsx Updates public types: new PanelRenderExtra and updated SharedPickerProps.panelRender signature.
docs/examples/panelRender.tsx Updates the example to use the new panelRender extra argument and demonstrates rendering Panel.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/PickerInput/Popup/index.tsx`:
- Around line 41-56: The mergedProps currently only overrides picker, mode and
hideHeader when panelRender supplies a different picker, but other
picker-dependent defaults remain from the outer popup; after you compute
mergedPicker and the initial mergedProps, re-run the panel-derived defaults
using the final mergedPicker and merge those defaults into mergedProps so the
panel receives the correct semantics for that picker (e.g. default open values
for empty state). Concretely: after computing mergedPicker and mergedProps in
Popup/index.tsx, invoke the same logic (or helper) that derives panel defaults
from a picker (the code that produces PickerPanelProps<DateType> based on
picker) using mergedPicker, then shallow-merge those derived defaults into
mergedProps (without clobbering explicit props passed in) so mergedProps fully
reflects the final picker before rendering the Panel.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c8069c8d-3b35-4230-bdb3-d0c8226801d3

📥 Commits

Reviewing files that changed from the base of the PR and between d27127f and 83717a6.

📒 Files selected for processing (5)
  • docs/examples/panelRender.tsx
  • src/PickerInput/Popup/PopupPanel.tsx
  • src/PickerInput/Popup/index.tsx
  • src/interface.tsx
  • tests/picker.spec.tsx

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