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

feat(tree-select): [tree-select] add tree-select component #1683

Merged
merged 2 commits into from
Jun 26, 2024

Conversation

kagol
Copy link
Member

@kagol kagol commented Jun 18, 2024

PR

基于 BaseSelect+Tree 封装 TreeSelect 组件,已完善:

  • 组件模板
  • 组件 renderless 逻辑
  • 组件API文档
  • 基础Demo文档(Demo文档代码量太大,为避免影响代码检视,后面单独提交一个PR进行补充)
  • Demo对应的E2E测试用例(用例已通过)

效果如下:
image

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 a tree select feature with selectable nodes and filtering capabilities.
    • Added support for node click events and multiple selections.
  • Improvements

    • Enhanced component to include new props: filterable and filterMethod, allowing customized filtering of tree data.
  • User Interface

    • Updated template structure to incorporate new tree interactions and filtering functionalities.

@kagol kagol added the enhancement New feature or request label Jun 18, 2024
Copy link

coderabbitai bot commented Jun 18, 2024

Walkthrough

The new functionality introduces a tree-select feature within the UI, allowing users to interact with and filter tree nodes. Core functions like filter, nodeClick, and check implemented in the core logic are now integrated with a Vue component. These updates provide a robust framework for managing tree selections with options for single and multiple selections.

Changes

File Change Summary
packages/renderless/src/tree-select/index.ts Introduced filter, nodeClick, and check functions for handling tree selection behavior.
packages/renderless/src/tree-select/vue.ts Added renderless function to create an API object for state management and tree interactions.
packages/vue/src/tree-select/src/pc.vue Added filterable and filterMethod props, integrated renderless and api in setup, and added a template for the panel.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant VueComponent as TreeSelect Vue Component
    participant API as Renderless API
    participant TreeNode as Tree Node

    User->>+VueComponent: Enters filter text
    VueComponent->>API: Call filter function
    API->>VueComponent: Return filtered nodes

    User->>+TreeNode: Clicks on node (single selection)
    TreeNode->>VueComponent: Trigger nodeClick
    VueComponent->>API: Call nodeClick function
    API->>VueComponent: Update selected node

    User->>+TreeNode: Clicks on checkbox (multi-selection)
    TreeNode->>VueComponent: Trigger check
    VueComponent->>API: Call check function
    API->>VueComponent: Update checked nodes
Loading

Poem

In the forest of code so grand,
Trees now dance by user’s hand.
With clicks and filters they unfold,
Selections made, both new and old.
A rabbit cheers, in code we trust, 🌳✨
For tree-select, a seamless must. 🐇💻


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

@kagol kagol changed the title feat(tree-select): add tree-select component feat(tree-select): [tree-select] add tree-select component Jun 18, 2024
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

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

Commits

Files that changed from the base of the PR and between 5e02624 and adab1b0.

Files selected for processing (15)
  • examples/sites/demos/apis/tree-select.js (1 hunks)
  • examples/sites/demos/pc/app/tree-select/basic-usage-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/tree-select/basic-usage.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/tree-select/basic-usage.vue (1 hunks)
  • examples/sites/demos/pc/app/tree-select/webdoc/tree-select.cn.md (1 hunks)
  • examples/sites/demos/pc/app/tree-select/webdoc/tree-select.en.md (1 hunks)
  • examples/sites/demos/pc/app/tree-select/webdoc/tree-select.js (1 hunks)
  • examples/sites/demos/pc/menus.js (1 hunks)
  • packages/modules.json (1 hunks)
  • packages/renderless/src/tree-select/index.ts (1 hunks)
  • packages/renderless/src/tree-select/vue.ts (1 hunks)
  • packages/vue/package.json (1 hunks)
  • packages/vue/src/tree-select/index.ts (1 hunks)
  • packages/vue/src/tree-select/package.json (1 hunks)
  • packages/vue/src/tree-select/src/pc.vue (1 hunks)
Files skipped from review due to trivial changes (3)
  • examples/sites/demos/pc/app/tree-select/basic-usage.spec.ts
  • packages/vue/package.json
  • packages/vue/src/tree-select/package.json
Additional context used
Markdownlint
examples/sites/demos/pc/app/tree-select/webdoc/tree-select.cn.md

5-5: null (MD025, single-title, single-h1)
Multiple top-level headings in the same document

examples/sites/demos/pc/app/tree-select/webdoc/tree-select.en.md

5-5: null (MD025, single-title, single-h1)
Multiple top-level headings in the same document

Biome
packages/vue/src/tree-select/index.ts

[error] 16-18: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)

Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.

Additional comments not posted (14)
examples/sites/demos/pc/app/tree-select/webdoc/tree-select.cn.md (1)

5-7: The documentation succinctly explains the purpose and functionality of the TreeSelect component.

Tools
Markdownlint

5-5: null (MD025, single-title, single-h1)
Multiple top-level headings in the same document

examples/sites/demos/pc/app/tree-select/webdoc/tree-select.en.md (1)

5-7: The documentation clearly describes the TreeSelect component, combining BaseSelect and Tree components effectively.

Tools
Markdownlint

5-5: null (MD025, single-title, single-h1)
Multiple top-level headings in the same document

examples/sites/demos/pc/app/tree-select/webdoc/tree-select.js (1)

1-18: The configuration for the TreeSelect component's demo is correctly set up, providing clear multilingual support and appropriate linkage to the demo code.

packages/renderless/src/tree-select/vue.ts (1)

1-21: The renderless function is well-implemented, using Vue's composition API effectively to manage the state and behaviors of the TreeSelect component.

packages/renderless/src/tree-select/index.ts (3)

1-5: Function filter correctly delegates tree node filtering to the tree component. Well implemented.


7-21: Function nodeClick handles node click events effectively, updating selected data and conditionally hiding the panel based on the multiple prop.


24-38: Function check effectively manages the state for multiple node selections, ensuring that node data is correctly mapped and updated.

examples/sites/demos/pc/app/tree-select/basic-usage-composition-api.vue (1)

1-49: The template and script setup in basic-usage-composition-api.vue correctly utilize Vue's Composition API and component binding. Nicely done.

examples/sites/demos/pc/app/tree-select/basic-usage.vue (1)

1-55: The template and script setup in basic-usage.vue correctly utilize Vue's Options API and component binding. Well implemented.

packages/vue/src/tree-select/src/pc.vue (2)

1-34: The template section is well-structured and correctly implements the tiny-base-select and tiny-tree components with appropriate props and event handling.


36-71: The script section is well-implemented with correct imports, component registration, props definition, and setup function logic.

examples/sites/demos/apis/tree-select.js (1)

1-118: The API configuration for the tree-select component is comprehensive, including detailed descriptions and default values for each property. It is well-prepared for both English and Chinese users.

examples/sites/demos/pc/menus.js (1)

150-156: The addition of the TreeSelect component to the menu is correctly implemented. The 'Beta' warning is a good practice for new features, helping to set the right expectations for users.

packages/modules.json (1)

2981-2993: The new entries for TreeSelect and TreeSelectPc are correctly structured and follow the conventions used throughout the file. The exclude flag is set to false, which means these components are included in builds or deployments, and the mode is correctly set to pc, indicating these components are intended for PC environments.

packages/vue/src/tree-select/index.ts Show resolved Hide resolved
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

Outside diff range and nitpick comments (2)
examples/sites/demos/pc/app/tree-select/webdoc/tree-select.cn.md (1)

5-5: Consider consolidating the top-level headings to maintain Markdown best practices.

Tools
Markdownlint

5-5: null (MD025, single-title, single-h1)
Multiple top-level headings in the same document

examples/sites/demos/pc/app/tree-select/webdoc/tree-select.en.md (1)

5-5: Consider consolidating the top-level headings to maintain Markdown best practices.

Tools
Markdownlint

5-5: null (MD025, single-title, single-h1)
Multiple top-level headings in the same document

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between adab1b0 and 464a602.

Files selected for processing (15)
  • examples/sites/demos/apis/tree-select.js (1 hunks)
  • examples/sites/demos/pc/app/tree-select/basic-usage-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/tree-select/basic-usage.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/tree-select/basic-usage.vue (1 hunks)
  • examples/sites/demos/pc/app/tree-select/webdoc/tree-select.cn.md (1 hunks)
  • examples/sites/demos/pc/app/tree-select/webdoc/tree-select.en.md (1 hunks)
  • examples/sites/demos/pc/app/tree-select/webdoc/tree-select.js (1 hunks)
  • examples/sites/demos/pc/menus.js (1 hunks)
  • packages/modules.json (1 hunks)
  • packages/renderless/src/tree-select/index.ts (1 hunks)
  • packages/renderless/src/tree-select/vue.ts (1 hunks)
  • packages/vue/package.json (1 hunks)
  • packages/vue/src/tree-select/index.ts (1 hunks)
  • packages/vue/src/tree-select/package.json (1 hunks)
  • packages/vue/src/tree-select/src/pc.vue (1 hunks)
Files skipped from review as they are similar to previous changes (12)
  • examples/sites/demos/apis/tree-select.js
  • examples/sites/demos/pc/app/tree-select/basic-usage-composition-api.vue
  • examples/sites/demos/pc/app/tree-select/basic-usage.spec.ts
  • examples/sites/demos/pc/app/tree-select/basic-usage.vue
  • examples/sites/demos/pc/app/tree-select/webdoc/tree-select.js
  • examples/sites/demos/pc/menus.js
  • packages/modules.json
  • packages/renderless/src/tree-select/index.ts
  • packages/renderless/src/tree-select/vue.ts
  • packages/vue/package.json
  • packages/vue/src/tree-select/package.json
  • packages/vue/src/tree-select/src/pc.vue
Additional context used
Markdownlint
examples/sites/demos/pc/app/tree-select/webdoc/tree-select.cn.md

5-5: null (MD025, single-title, single-h1)
Multiple top-level headings in the same document

examples/sites/demos/pc/app/tree-select/webdoc/tree-select.en.md

5-5: null (MD025, single-title, single-h1)
Multiple top-level headings in the same document

Biome
packages/vue/src/tree-select/index.ts

[error] 16-18: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)

Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.

Additional comments not posted (1)
packages/vue/src/tree-select/index.ts (1)

16-18: Consider converting this function expression into an arrow function for better consistency with modern JavaScript practices.

- TreeSelect.install = function (Vue) {
-   Vue.component(TreeSelect.name, TreeSelect)
- }
+ TreeSelect.install = (Vue) => {
+   Vue.component(TreeSelect.name, TreeSelect)
+ }
Tools
Biome

[error] 16-18: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)

Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 464a602 and 19a6503.

Files selected for processing (3)
  • packages/renderless/src/tree-select/index.ts (1 hunks)
  • packages/renderless/src/tree-select/vue.ts (1 hunks)
  • packages/vue/src/tree-select/src/pc.vue (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • packages/renderless/src/tree-select/index.ts
  • packages/renderless/src/tree-select/vue.ts
  • packages/vue/src/tree-select/src/pc.vue

@zzcr zzcr merged commit 196ab84 into dev Jun 26, 2024
4 of 5 checks passed
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.

None yet

3 participants