Skip to content

Conversation

@shenjunjian
Copy link
Collaborator

@shenjunjian shenjunjian commented Apr 11, 2025

PR

feat(transfer): 为穿梭框组件添加自定义面板宽度的功能,以及宽度自适应父空间

1、 增加3个属性, 不传入时面板的尺寸就是原来的宽度。 传入后,绑定用户的样式到style上, 优先级高于theme中的值。
2、panel面板的宽度大于外部容器的50%的时候, 面板会自适应容器的尺寸。

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features
    • Introduced enhanced panel customization options, allowing users to adjust styles for panels, content areas, and nested tables.
    • Added interactive demos showcasing flexible transfer interfaces with list, tree, and grid views, complete with filtering and pagination capabilities.
  • Style
    • Improved layout responsiveness with dynamic height adjustments and flexbox-based designs for a smoother visual experience.

@coderabbitai
Copy link

coderabbitai bot commented Apr 11, 2025

Walkthrough

This pull request introduces three new properties for the transfer component, enabling enhanced customization of panel styles and dimensions. New Vue components and demos have been added to showcase these features with list, tree, and grid configurations. Updates have been made to CSS files to incorporate dynamic styles using flexbox and CSS variables. Additionally, corresponding props have been integrated into both transfer and transfer panel components to propagate the new styling options throughout the system.

Changes

File(s) Change Summary
examples/sites/demos/apis/transfer.js, packages/vue/src/transfer-panel/src/pc.vue, packages/vue/src/transfer/src/index.ts, packages/vue/src/transfer/src/pc.vue Introduced new properties (panelStyle, panelBodyStyle, and panelTableHeight) to enhance panel customization in transfer components and applied them in the templates.
examples/sites/demos/pc/app/transfer/custom-size-composition-api.vue, examples/sites/demos/pc/app/transfer/custom-size.vue, examples/sites/demos/pc/app/transfer/webdoc/transfer.js Added new Vue components and a demo entry to showcase customizable transfer functionality across list, tree, and grid formats.
packages/theme-saas/src/transfer/index.less, packages/theme/src/transfer/index.less, packages/theme/src/transfer/vars.less Updated CSS styles to implement dynamic, flexbox-based layouts and adjusted CSS variables for improved responsiveness in transfer components.

Sequence Diagram(s)

sequenceDiagram
    participant Demo as DemoComponent
    participant Transfer as TransferComponent
    participant Panel as TransferPanel
    participant Theme as ThemeStyles

    Demo->>Transfer: Pass props (panelStyle, panelBodyStyle, panelTableHeight)
    Transfer->>Panel: Forward style customization props
    Panel->>Theme: Apply dynamic styles via CSS variables/flexbox
    Theme-->>Panel: Return computed style adjustments
    Panel-->>Transfer: Render component with custom styles
Loading

Possibly related PRs

Suggested reviewers

  • zzcr

Poem

I'm a rabbit, code-hopping with glee,
Adding new props for style, as spry as can be.
Panels now flex and dance in a vibrant display,
With grids, trees, and lists leading the way.
My whiskers twitch—coding magic unfolds each day! 🐇🥕

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

examples/sites/demos/pc/app/transfer/custom-size-composition-api.vue

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-vue".

(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-vue@latest --save-dev

The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

examples/sites/demos/pc/app/transfer/custom-size.vue

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-vue".

(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-vue@latest --save-dev

The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

examples/sites/demos/apis/transfer.js

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-vue".

(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-vue@latest --save-dev

The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

  • 4 others

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 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.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

@github-actions github-actions bot added the enhancement New feature or request (功能增强) label Apr 11, 2025
@petercat-assistant
Copy link

Walkthrough

此PR为穿梭框组件添加了自定义面板宽度的功能,并使宽度自适应父容器空间。通过增加三个属性,用户可以指定面板的样式和嵌套表格的高度。当面板宽度超过外部容器的50%时,面板会自动调整以适应容器宽度。

Changes

文件 概要
examples/sites/demos/apis/transfer.js 添加了三个新属性:panel-stylepanel-body-stylepanel-table-height,用于自定义面板样式和表格高度。
examples/sites/demos/pc/app/transfer/custom-size-composition-api.vue 新增示例,展示如何使用新增属性自定义面板样式。
examples/sites/demos/pc/app/transfer/custom-size.vue 新增示例,展示如何使用新增属性自定义面板样式。
examples/sites/demos/pc/app/transfer/webdoc/transfer.js 添加了新示例的文档描述。
packages/theme-saas/src/transfer/index.less 修改样式以支持动态面板和表格高度。
packages/theme/src/transfer/index.less 修改样式以支持动态面板和表格高度。
packages/theme/src/transfer/vars.less 更新变量以支持新的样式调整。
packages/vue/src/transfer-panel/src/pc.vue 添加了对新属性的支持。
packages/vue/src/transfer/src/index.ts 添加了对新属性的支持。
packages/vue/src/transfer/src/pc.vue 添加了对新属性的支持。

},
treeOp: Object,
beforeTransfer: Function
beforeTransfer: Function,

Choose a reason for hiding this comment

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

Ensure that the new properties panelStyle, panelBodyStyle, and panelTableHeight are validated and handled properly to avoid potential runtime errors if incorrect data types are passed.

@github-actions
Copy link

[e2e-test-warn]
The component to be tested is missing.

The title of the Pull request should look like "fix(vue-renderless): [action-menu, alert] fix xxx bug".

Please make sure you've read our contributing guide

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Walkthrough

This PR adds the ability to customize panel width to the shuttle box component and makes the width adaptable to the parent container space. By adding three properties, users can specify the style of the panel and the height of the nested table. When the panel width exceeds 50% of the external container, the panel will automatically adjust to suit the container width.

Changes

Documents Summary
examples/sites/demos/apis/transfer.js Added three new properties: panel-style, panel-body-style, panel-table-height, for custom panel styles and table heights.
examples/sites/demos/pc/app/transfer/custom-size-composition-api.vue Added examples to show how to customize panel styles using new properties.
examples/sites/demos/pc/app/transfer/custom-size.vue Added examples to show how to customize panel styles with new properties.
examples/sites/demos/pc/app/transfer/webdoc/transfer.js Added a document description for the new example.
packages/theme-saas/src/transfer/index.less Modify the style to support dynamic panel and table heights.
packages/theme/src/transfer/index.less Modify the style to support dynamic panel and table heights.
packages/theme/src/transfer/vars.less Update variables to support new style adjustments.
packages/vue/src/transfer-panel/src/pc.vue Added support for new properties.
packages/vue/src/transfer/src/index.ts Added support for new properties.
packages/vue/src/transfer/src/pc.vue Added support for new properties.

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: 0

🧹 Nitpick comments (1)
examples/sites/demos/pc/app/transfer/custom-size.vue (1)

78-84: Well-defined panel style configuration.

The panel customization properties are clearly defined with appropriate values. Consider adding a comment explaining the height unit (px) and what happens when the width exceeds container width (as mentioned in PR objectives).

// 自定义面板样式
panelStyle: {
  width: '650px'
+ // Panel width will be capped at 50% of container width if it exceeds that limit
},
panelBodyStyle: {
  height: '200px'
},
panelTableHeight: '700px', // Height for the table in grid mode
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d843901 and ff06e73.

📒 Files selected for processing (10)
  • examples/sites/demos/apis/transfer.js (1 hunks)
  • examples/sites/demos/pc/app/transfer/custom-size-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/transfer/custom-size.vue (1 hunks)
  • examples/sites/demos/pc/app/transfer/webdoc/transfer.js (1 hunks)
  • packages/theme-saas/src/transfer/index.less (2 hunks)
  • packages/theme/src/transfer/index.less (6 hunks)
  • packages/theme/src/transfer/vars.less (1 hunks)
  • packages/vue/src/transfer-panel/src/pc.vue (3 hunks)
  • packages/vue/src/transfer/src/index.ts (1 hunks)
  • packages/vue/src/transfer/src/pc.vue (2 hunks)
🔇 Additional comments (23)
packages/theme/src/transfer/vars.less (1)

143-143: Panel body tree filter height has been increased by 4px

The CSS variable for panel body tree filter height has been updated from calc(100% - 46px) to calc(100% - 50px), increasing the spacing by 4px.

This change affects the layout of tree components within the transfer panel and likely improves the visual appearance with the new customizable panel width feature.

packages/vue/src/transfer-panel/src/pc.vue (3)

17-17: Added support for custom panel styling

The main transfer panel container now supports dynamic styling through the new panelStyle prop, enabling customization of the panel's appearance.


33-37: Added support for custom panel body styling

The transfer panel body now supports dynamic styling through the new panelBodyStyle prop. This, combined with the panel container styling, provides comprehensive customization capabilities.


145-146: New style customization props added to transferPanelProps

Added two new props to the component:

  • panelStyle: For customizing the outer container
  • panelBodyStyle: For customizing the panel body

These props are correctly defined as Object types, allowing for flexible styling options.

examples/sites/demos/pc/app/transfer/webdoc/transfer.js (1)

104-123: Added new demo for panel size customization

A comprehensive demo entry has been added to showcase the new panel customization features. The documentation clearly explains:

  1. How panelStyle allows customizing the left and right panel containers
  2. How the panel auto-adapts when width exceeds 50% of container width
  3. How panelBodyStyle allows styling the content area
  4. How panelTableHeight can be used for nested tables

The documentation is thorough and includes both Chinese and English translations.

packages/vue/src/transfer/src/index.ts (1)

94-97: Added panel customization props to transferProps

Three new properties have been added to the transferProps object:

  • panelStyle: For customizing the panel container
  • panelBodyStyle: For customizing the panel body
  • panelTableHeight: For setting the height of nested tables

These properties are properly typed (Object for style props, String for height) and align with the implementation in other files.

packages/theme-saas/src/transfer/index.less (2)

136-137: Good update to flexbox layout for better panel structure.

Using flexbox for the panel body allows for better content organization and responsiveness. This change enables proper vertical stretching of child elements when the panel is resized.


392-392: Great implementation of dynamic table height.

Using CSS variables (--tv-Transfer-table-dyn-height) enables the component to accept externally configured table heights. This approach maintains separation of concerns while allowing for customization.

examples/sites/demos/pc/app/transfer/custom-size.vue (3)

6-8: LGTM: Good demonstration of the new panel customization properties.

The implementation correctly showcases how to use the new panelStyle and panelBodyStyle properties for the list transfer component.


19-20: LGTM: Consistent use of properties across component instances.

The tree transfer implementation correctly applies the same panel customization properties as the list example.


35-37: Good demonstration of all customization properties.

This example appropriately showcases all three new properties, including the grid-specific panelTableHeight property.

packages/vue/src/transfer/src/pc.vue (2)

14-14: Good implementation of dynamic CSS variable binding.

The implementation correctly applies the CSS variable --tv-Transfer-table-dyn-height based on the panelTableHeight prop, which enables dynamic styling of the table height.


161-163:

❓ Verification inconclusive

Well-defined new props for panel customization.

The new props panelStyle, panelBodyStyle, and panelTableHeight have been correctly added to the component's props array, enabling the customization features described in the PR objectives.


🏁 Script executed:

#!/bin/bash
# Check if these props are also defined in the TransferPanel component
echo "Checking if the props are passed to TransferPanel component..."
rg -A 5 "panelStyle|panelBodyStyle|panelTableHeight" --type vue

Length of output: 228


Review Update: Manual Verification Required

The new props (panelStyle, panelBodyStyle, and panelTableHeight) are correctly added to the component’s props array in packages/vue/src/transfer/src/pc.vue (lines 161-163), which supports the intended panel customization features. However, our initial automated check for these props in the TransferPanel component encountered an error due to unrecognized file type "vue." This means we couldn’t conclusively verify via our script that these props are also passed to or used within the TransferPanel.

• Please re-run the verification using a command that correctly targets Vue files (for example, using the --glob '*.vue' option) to ensure that the TransferPanel integration is in place.
• In the meantime, a manual review of the TransferPanel component to confirm that these new props are forwarded or utilized as expected is recommended.

examples/sites/demos/pc/app/transfer/custom-size-composition-api.vue (2)

73-75: Good implementation with Composition API.

The panel customization properties are correctly defined as reactive references, which is appropriate for the Composition API approach.


1-40: Consistent implementation across API styles.

The template structure and property usage match the Options API example, which ensures consistency across different API styles. This is good practice for documentation and developer experience.

packages/theme/src/transfer/index.less (5)

29-29: Adding code section comments improves maintainability.

The addition of clear section comments helps separate different styling sections of the transfer component, making the code more organized and easier to navigate.


99-99: LGTM: Improved CSS formatting consistency.

Adding consistent spacing after colons in CSS property declarations enhances code readability.

Also applies to: 119-119


142-142: Good structure enhancement with section comments and flexbox alignment.

Adding the section comment for transfer-panel styles and setting align-items: stretch ensures panels will expand to fill their container vertically, which is necessary for the panel width customization feature.

Also applies to: 153-153


157-157: Excellent implementation of flexible layout.

The addition of flexbox layout to the panel body with display: flex and flex-direction: column enables proper expansion of content, while the variable-based height enables custom height configurations through props.

Also applies to: 162-163


394-394: Good use of CSS variables for dynamic height.

Replacing the fixed 400px height with var(--tv-Transfer-table-dyn-height, 400px) allows the table height to be dynamically set through the new panel-table-height property while maintaining backward compatibility with a default value.

examples/sites/demos/apis/transfer.js (3)

292-305: Well-documented panel-style property implementation.

The panel-style property implementation is well-documented with clear descriptions in both Chinese and English. The property allows users to customize the panel container styles, supporting the PR's main objective of customizing panel width.

The documentation correctly notes that when panel width exceeds 50% of the container width, it will automatically adapt, which aligns with the PR objectives.


307-319: Clear documentation for the panel-body-style property.

The panel-body-style property is well-defined with appropriate type information and descriptions. This property complements the panel-style property by allowing customization of the content area within the panel, providing more granular styling control.


321-334: Thorough documentation for panel-table-height property.

The panel-table-height property documentation clearly explains its purpose and relationship with the default table height (400px). The explanation of how this property can be used to match customized panel heights with table heights is particularly helpful for users implementing responsive designs.

@shenjunjian shenjunjian changed the title feat(transfer): Adds the ability to customize the panel width for the shuttle box component and adapts the width to the parent space feat(transfer): [transfer] adds the ability to customize the panel width for the transfer component Apr 11, 2025
@zzcr zzcr merged commit f85dd71 into dev Apr 15, 2025
16 checks passed
@zzcr zzcr deleted the shen/add-transfer-panel-custom-size1 branch April 15, 2025 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request (功能增强)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants