feat: enhance panelRender API support components#962
feat: enhance panelRender API support components#962li-jia-nan wants to merge 1 commit intomasterfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
概览本次变更重构了选择器面板渲染系统,引入新的上下文(Context)和组件包装器,使 变更内容
序列图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
代码审查工作量评估🎯 3 (中等复杂度) | ⏱️ ~25 分钟 可能相关的 PR
建议审查人员
诗
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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 Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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
panelRenderto receive anextraobject that exposescomponents.Panel. - Introduces a context-backed
PanelRenderPanelimplementation soPanelinstances render with the same popup state/handlers by default. - Adds test coverage validating default context wiring and
pickeroverride 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.
There was a problem hiding this comment.
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
📒 Files selected for processing (5)
docs/examples/panelRender.tsxsrc/PickerInput/Popup/PopupPanel.tsxsrc/PickerInput/Popup/index.tsxsrc/interface.tsxtests/picker.spec.tsx
Summary by CodeRabbit
New Features
panelRender回调函数现在接收第二个参数,提供面板组件以支持高级定制。Documentation
panelRender回调的新用法。Tests