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

Momo poppy/refactor theme select 0930 #2251

Closed

Conversation

MomoPoppy
Copy link
Collaborator

@MomoPoppy MomoPoppy commented Oct 12, 2024

PR

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

    • Enhanced user experience with new methods for managing select component interactions.
    • Improved event handling and state management for select components.
  • Bug Fixes

    • Updated test cases to ensure accuracy in select component behavior.
  • Style

    • Refined styles for select components, including hover and disabled states for better visual consistency.
    • Introduced new CSS variables and updated naming conventions for improved maintainability.

Copy link

coderabbitai bot commented Oct 12, 2024

Walkthrough

The changes in this pull request involve modifications to test cases for select components, enhancements to the functionality of base-select and select components, and updates to associated LESS stylesheets. Test cases have been refined for better accuracy, while new methods and improved event handling have been introduced in the component logic. Additionally, CSS variable names have been standardized across various LESS files, reflecting a shift towards a unified naming convention and improved styling consistency.

Changes

File Path Change Summary
examples/sites/demos/pc/app/select/events.spec.ts, input-box-type.spec.ts Updated test cases for select components, modifying selectors and assertions related to visual representation and interactions.
packages/renderless/src/base-select/index.ts, select/index.ts Introduced new methods and refined existing ones for improved functionality and user experience in select components. Enhanced event handling and selection logic, particularly for multi-select scenarios.
packages/theme-saas/src/select/index.less, packages/theme/src/select/index.less Modified LESS stylesheets for select components, including renaming classes and adjusting styles for various states, with a focus on responsive design.
packages/theme/src/base/vars.less, option-group/vars.less, option/vars.less, select-dropdown/vars.less, select/vars.less Restructured CSS variable declarations and introduced new variables across multiple LESS files, standardizing naming conventions and enhancing consistency in styling.

Possibly related PRs

Suggested labels

refactoring

Suggested reviewers

  • zzcr

Poem

In a garden of choices, we hop and we play,
With selects that now dance in a stylish ballet.
New methods and styles, oh what a delight,
Our components are shining, all ready for flight!
So let’s celebrate changes, both big and small,
For a world of selections, we’re grateful for all! 🐇✨


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

[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: 16

🧹 Outside diff range and nitpick comments (31)
packages/theme/src/option-group/index.less (2)

27-27: Consider using a CSS variable for padding-bottom.

The change to set padding-bottom: 0px for non-last option groups is good for reducing unnecessary spacing. However, to maintain consistency with the project's use of CSS variables and to improve maintainability, consider using a CSS variable instead of a hard-coded value.

You could define a new variable like --tv-OptionGroup-padding-bottom in the vars.less file and use it here:

-    padding-bottom: 0px;
+    padding-bottom: var(--tv-OptionGroup-padding-bottom, 0px);

This approach allows for easier theme customization in the future if needed.


42-48: Great improvements in variable usage and styling consistency.

The changes to the title class significantly improve the use of CSS variables, following a consistent naming convention. This enhances maintainability and customizability. The shift to height: auto provides more flexibility in accommodating varying content.

One suggestion for improvement:

Consider keeping separate variables for different margin directions instead of consolidating them into a single --tv-OptionGroup-title-margin variable. This would provide more fine-grained control over the layout. For example:

margin-top: var(--tv-OptionGroup-title-margin-top, 0);
margin-right: var(--tv-OptionGroup-title-margin-right, 0);
margin-bottom: var(--tv-OptionGroup-title-margin-bottom, 0);
margin-left: var(--tv-OptionGroup-title-margin-left, 0);

This approach allows for more specific customization while still maintaining the option to set all margins uniformly if desired.

packages/theme/src/option/vars.less (3)

14-25: Improved text-related variable definitions

The new text-related variables (--tv-Option-font-size, --tv-Option-line-height, --tv-Option-text-color, etc.) are well-structured and provide more granular control over text styling. The use of referenced variables (e.g., var(--tv-font-size-md, 14px)) allows for easier theme customization and maintains consistency across the component.

Consider adding a comment to explain the purpose of the --tv-Option-text-color-highlight variable, as its usage might not be immediately clear to other developers.


27-36: Well-defined icon and checkbox styling variables

The new icon-related variables (--tv-Option-icon-size, --tv-Option-icon-color-unchecked, etc.) provide excellent control over icon and checkbox styling. The naming is clear and consistent with the established pattern.

Consider grouping the checkbox-specific variables (lines 29-36) under a common prefix, such as --tv-Option-checkbox-*, to make their purpose even more explicit and improve code organization.


44-45: Hover state styling variable added

The addition of --tv-Option-bg-color-hover provides clear control over the hover state styling for the option component.

Consider adding variables for other interactive states, such as focus and active, to provide a complete set of state-related styling options. For example:

--tv-Option-bg-color-focus: var(--tv-color-bg-focus, #e6f0ff);
--tv-Option-bg-color-active: var(--tv-color-bg-active, #d9e8ff);
packages/vue/src/option/src/pc.vue (1)

21-21: LGTM! Consider a minor readability improvement.

The dynamic component rendering and class binding look good. This change enhances the flexibility of the component by allowing different icons and styles based on the select state.

For slightly improved readability, consider separating the dynamic component name and class binding:

<component 
  :is="`icon-${state.selectCls}`"
  :class="['tiny-svg-size', state.selectCls]"
/>

This separation makes it clearer that we're applying two classes: a static one and a dynamic one.

packages/vue/src/option/src/mobile-first.vue (1)

Line range hint 62-62: Approve new props with a request for documentation.

The addition of new props ('value', 'label', 'created', 'disabled', 'events', 'visible', 'highlightClass', 'required') enhances the component's flexibility and configurability. This is a positive change that allows for more fine-grained control over the component's behavior and appearance.

To ensure proper usage of these new props, please update the component's documentation to include:

  1. A description of each new prop
  2. The expected data type for each prop
  3. Any default values
  4. Examples of how these props can be used

Additionally, consider adding appropriate PropTypes or TypeScript types for these props to improve type safety and developer experience.

examples/sites/demos/pc/app/select/events.spec.ts (1)

Line range hint 1-72: Summary of changes and impact.

The changes in this file are part of a broader refactoring effort to standardize class names in the select component. The updates to the close icon selectors improve specificity and maintain consistency across both single and multi-select test cases. These changes align well with the PR objectives of refactoring without altering functionality or API.

To ensure the refactoring is complete:

  1. Verify that similar changes have been applied consistently across all relevant files in the project.
  2. Consider updating the documentation to reflect the new class naming convention, if applicable.
  3. Ensure that the CI/CD pipeline runs these tests to confirm that the selector changes haven't inadvertently broken any functionality.
examples/sites/demos/pc/app/select/input-box-type.spec.ts (2)

58-70: Approve changes and suggest additional multiple selection tests.

The updates to the class and CSS property assertions in the multiple selection test are consistent with the changes made in the previous test cases. The addition of the .tiny-select__multiple class assertion is a good improvement to ensure the multiple selection functionality is properly applied.

Consider adding more specific tests for multiple selection functionality, such as:

  1. Verifying that multiple options can be selected and deselected.
  2. Checking the behavior when the maximum number of selections is reached.
  3. Testing the clear all functionality for multiple selections.

Here's a sample test structure you could add:

test('multiple selection functionality', async ({ page }) => {
  // ... setup code ...

  // Select multiple options
  await select.click();
  await option.nth(0).click();
  await option.nth(1).click();
  await expect(tag).toHaveCount(2);

  // Deselect an option
  await tag.first().locator('.tiny-tag__close').click();
  await expect(tag).toHaveCount(1);

  // Test max selection (assuming max is 3)
  await select.click();
  await option.nth(2).click();
  await option.nth(3).click();
  await expect(tag).toHaveCount(3);
  await option.nth(4).click();
  await expect(tag).toHaveCount(3);

  // Test clear all
  await select.locator('.tiny-select__clear').click();
  await expect(tag).toHaveCount(0);
});

This will provide more comprehensive coverage of the multiple selection functionality.


Line range hint 1-71: Overall assessment of changes

The modifications in this file represent a consistent refactoring effort across all test cases for the select component. The changes improve the specificity of class and CSS property assertions, aligning them with an updated component structure where the underline styling is associated with the input element rather than the select element itself.

These updates enhance the accuracy of the tests and reflect improvements in the component's implementation. However, to ensure the refactoring hasn't introduced any regressions, it's recommended to:

  1. Run visual regression tests to verify the component's appearance hasn't changed unexpectedly.
  2. Check for consistency of these changes across related components in the codebase.
  3. Consider expanding the multiple selection tests to cover more specific functionality.

As this seems to be part of a larger refactoring effort, consider documenting these structural changes in the component's technical documentation or README. This will help other developers understand the new component structure and styling approach.

packages/theme/src/select/index.less (1)

193-201: LGTM with a note: Improved disabled state styling and TODO comment

The update to use --tv-Select-text-color-disabled and margin variables for disabled text improves theme consistency and maintainability. This refactoring enhances the component without changing its core functionality.

However, there's a TODO comment regarding the Aurora multi-select disabled text display. It might be worth evaluating whether this code is still necessary or if it can be removed/refactored in a future update.

Consider creating a separate issue to track the evaluation and potential refactoring of the Aurora multi-select disabled text display mentioned in the TODO comment.

packages/theme/src/base/vars.less (1)

Line range hint 1-394: Overall assessment of the change

The addition of the --tv-color-icon-checked-disabled variable is a positive improvement to the design system. It addresses a specific edge case (checked and disabled checkboxes) that wasn't explicitly handled before. This change enhances the granularity of control over component states and should improve consistency across the UI.

Some additional thoughts:

  1. Consider documenting this new state in the design system documentation, if it exists.
  2. Ensure that this new variable is applied consistently across all relevant components (checkboxes, radio buttons, etc.).
  3. It might be worth reviewing other form controls to see if similar disabled-but-active states need specific color variables.

Would you like me to generate a task list for implementing this new variable across relevant components?

packages/theme/src/select-dropdown/vars.less (1)

50-50: Add space after comment markers for consistency

In line 50, the comment //搜索框外边距 lacks a space after the //. For consistency with other comments in the file, please add a space after the comment markers.

Apply this diff to improve consistency:

-  //搜索框外边距
+  // 搜索框外边距
packages/theme/src/option/index.less (1)

54-58: Translate code comments to English for better maintainability

The code comments in lines 55-58 are in Chinese, which may hinder understanding among team members who are not fluent in Chinese. Please consider translating these comments into English to enhance readability and maintainability of the codebase.

packages/theme/src/select-dropdown/index.less (1)

159-159: Ensure consistent variable naming conventions

The variable --tv-SelectDropdown-empty-padding1 may be inconsistently named compared to others. Consider renaming it to --tv-SelectDropdown-empty-padding for uniformity.

packages/theme-saas/src/select/index.less (1)

Line range hint 338-343: Ensure consistent class naming for the close icon

The class .tiny-select__close is used here, while .@{select-prefix-cls}__close is used elsewhere (e.g., line 64). For consistency and easier maintenance, consider using .@{select-prefix-cls}__close throughout the file.

Apply the following diff to update the class name:

-          .tiny-select__close {
+          .@{select-prefix-cls}__close {
packages/vue/src/base-select/src/mobile-first.vue (3)

Line range hint 18-19: Undefined helper functions 'a', 'm', and 'gcls' used in the template

In the template, the functions a, m, and gcls are used within directives and class bindings (e.g., v-bind="a($attrs, ['class', 'style'], true)", :class="m(gcls('select-tags'), {...})). These helper functions are not defined or imported in the script section. This may lead to runtime errors if they are not available in the component's scope.

Please ensure that these functions are properly defined or imported into the component.


Line range hint 431-444: Refactor duplicated code blocks to improve maintainability

The code blocks between lines 431-444 and 464-477 are very similar, with only minor differences in conditions and variable usage. Here's an overview:

  • Lines 431-444: Handles the "Select All" option when there is no query (!state.query).
  • Lines 464-477: Handles the "Select All" option when there is a query (state.query).

Consider extracting the shared functionality into a reusable component or method. This will reduce code duplication and enhance maintainability.

Also applies to: 464-477


433-433: Replace magic number '-9' with a named constant for clarity

The value -9 is assigned to state.hoverIndex to represent a special hover state in both instances:

  • Line 433: @mouseenter="state.hoverIndex = -9"
  • Line 466: @mouseenter="state.hoverIndex = -9"

Using magic numbers can make the code less readable. Consider defining a constant to represent this special state:

+ <!-- In your script section -->
+ const HOVER_INDEX_SELECT_ALL = -9;

<!-- Then update the assignments -->
@mouseenter="state.hoverIndex = HOVER_INDEX_SELECT_ALL"

This enhances readability and makes future maintenance easier.

Also applies to: 466-466

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

Line range hint 458-466: Consider Refactoring Duplicate "Select All" Logic

There is a similar <li> element at lines 458-466 with a slightly different v-if condition:

v-if="
  multiple &&
  showCheck &&
  showAlloption &&
  !state.multipleLimit &&
  state.query &&
  !state.emptyText &&
  !remote
"

Since both elements handle "Select All" functionality under different conditions, consider abstracting this logic into a separate component or method to reduce code duplication and improve maintainability.


Line range hint 155-165: Define Prop Types and Default Values for New Props

Several new props have been added:

  • searchable
  • showEmptyImage
  • inputBoxType
  • tagType
  • clearNoMatchValue
  • showLimitText
  • showProportion
  • clickExpand
  • maxVisibleRows
  • allText

Please ensure that these new props have their types and default values defined in the props option. This helps with type checking, default behavior, and documentation for other developers using this component.

packages/renderless/src/base-select/index.ts (2)

Line range hint 1696-1700: Potential Issue: Setting state.previousQuery to undefined may cause unexpected behavior

In the clearSearchText method, state.previousQuery is set to undefined. If other parts of the code rely on state.previousQuery being a string, this could lead to unexpected behavior or errors. Consider setting it to an empty string '' to maintain consistent data types across the application.

Apply this diff to address the issue:

 export const clearSearchText =
   ({ state, api }) =>
   () => {
     state.query = ''
-    state.previousQuery = undefined
+    state.previousQuery = ''
     api.handleQueryChange(state.query)
   }

Line range hint 1702-1712: Suggestion: Use deep equality check for model values in clearNoMatchValue

In the clearNoMatchValue method, the comparison for props.modelValue and newModelValue might not detect differences in array content when their lengths are the same. This could lead to outdated or incorrect values not being updated. It's better to perform a deep equality check to ensure that any changes in the model values are accurately detected.

Consider modifying the condition to use a deep equality check:

 import { isEqual } from '../common/object'

 export const clearNoMatchValue =
   ({ props, emit }) =>
   (newModelValue) => {
     if (!props.clearNoMatchValue) {
       return
     }

-    if (
-      (props.multiple && props.modelValue.length !== newModelValue.length) ||
-      (!props.multiple && props.modelValue !== newModelValue)
-    ) {
+    if (
+      (props.multiple && !isEqual(props.modelValue, newModelValue)) ||
+      (!props.multiple && props.modelValue !== newModelValue)
+    ) {
       emit('update:modelValue', newModelValue)
     }
   }

[Note: Ensure that the isEqual function is correctly imported and handles deep comparison.]

packages/renderless/src/select/index.ts (8)

Line range hint 122-127: Translate code comments to English for consistency

The code contains comments in Chinese, such as // 多选时取远端数据与当前已选数据的并集 at line 122. To maintain consistency and improve readability for all contributors, please translate comments into English.


Line range hint 2194-2199: Fix typo in function name 'debouncRquest'

The function name debouncRquest appears to be a typo. It should be debounceRequest to accurately reflect its purpose and improve code clarity.

Apply this diff to correct the function name:

-export const debouncRquest = ({ api, state, props }) =>
+export const debounceRequest = ({ api, state, props }) =>
  debounce(props.delay, () => {
    if ((props.filterable || props.searchable) && state.query !== state.selectedLabel) {
      const isChange = false
      const isInput = true

      state.query = state.selectedLabel
      api.handleQueryChange(state.query, isChange, isInput)
    }
  })

Also, update the function call at line 902:

-if (!props.delay) {
+if (!props.delay) {
   // existing code
 } else {
-  api.debouncRquest()
+  api.debounceRequest()
 }

Also applies to: 902-902


Line range hint 373-373: Translate all code comments to English

Several comments in the code are written in Chinese. For example:

  • Line 373: // 单选,获取匹配的option
  • Line 437: // 1. 需要控制勾选或去勾选的项
  • Line 587: // 解决在特殊场景(表格使用select编辑器),选中下拉数据的一瞬间select组件被销毁时控制台报错的问题

Translating these comments into English will ensure that all team members can understand and maintain the code effectively.

Also applies to: 380-380, 401-401, 437-437, 441-441, 445-445, 587-587, 767-767, 1079-1079, 1085-1085, 1410-1410


Line range hint 1410-1414: Correct misuse of 'filter' method in 'nodeCheckClick'

In the nodeCheckClick function, the filter method is used without returning a boolean value, resulting in unexpected behavior. Additionally, the ESLint rule array-callback-return is being disabled to bypass this issue.

Replace filter with forEach since you're performing operations on each node without filtering:

-// eslint-disable-next-line array-callback-return
-state.selected = checkedNodes.filter((node) => {
+checkedNodes.forEach((node) => {
   node.currentLabel = node[props.textField]
   node.value = node[props.valueField]
+})
+state.selected = checkedNodes

This ensures that you're modifying each node as intended and assigning the checkedNodes array to state.selected without misusing filter.


Line range hint 350-353: Simplify type checks in 'getOption' function

The type checks using Object.prototype.toString.call(value).toLowerCase() are verbose and can be simplified for better readability.

Consider using:

-const isObject = Object.prototype.toString.call(value).toLowerCase() === '[object object]'
-const isNull = Object.prototype.toString.call(value).toLowerCase() === '[object null]'
-const isUndefined = Object.prototype.toString.call(value).toLowerCase() === '[object undefined]'
+const isObject = value !== null && typeof value === 'object'
+const isNull = value === null
+const isUndefined = typeof value === 'undefined'

This approach enhances code clarity and maintains the same functionality.


Line range hint 2631-2637: Remove unnecessary type annotation in event parameter

In the onClickCollapseTag function, the event parameter includes a TypeScript type annotation MouseEvent. Since this is a JavaScript file, the type annotation is unnecessary and may cause issues.

Apply this diff to remove the type annotation:

-export const onClickCollapseTag =
-  ({ state, props, nextTick, api }) =>
-  (event: MouseEvent) => {
+export const onClickCollapseTag =
+  ({ state, props, nextTick, api }) =>
+  (event) => {
     event.stopPropagation()
     if (props.clickExpand && !props.disabled && !state.isDisplayOnly) {
       state.showCollapseTag = !state.showCollapseTag

       nextTick(api.resetInputHeight)
     }
   }

Line range hint 1228-1233: Avoid assigning empty string to a variable intended as an object

In the selectOption function, option is initialized as an empty string but later expected to be an object.

Consider initializing option as null for better clarity:

-let option = ''
+let option = null
 if (state.query || props.remote) {
   option = state.options.find((item) => item.state.index === state.hoverValue)
 } else {
   option = state.options[state.hoverIndex]
 }

This makes the code more readable and avoids confusion about the expected data type of option.


Line range hint 616-625: Ensure safe access of properties in 'deletePrevTag'

In the deletePrevTag function, when accessing state.modelValue.slice(), ensure that state.modelValue is an array to prevent runtime errors.

Add a check to confirm state.modelValue is an array:

-if (event.target.value.length <= 0 && !api.toggleLastOptionHitState()) {
-  const value = state.modelValue.slice()
+if (event.target.value.length <= 0 && !api.toggleLastOptionHitState() && Array.isArray(state.modelValue)) {
+  const value = state.modelValue.slice()

This prevents potential errors if state.modelValue is null or not an array.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 98246dd and e80212c.

📒 Files selected for processing (20)
  • examples/sites/demos/pc/app/select/events.spec.ts (2 hunks)
  • examples/sites/demos/pc/app/select/input-box-type.spec.ts (3 hunks)
  • packages/renderless/src/base-select/index.ts (1 hunks)
  • packages/renderless/src/select/index.ts (1 hunks)
  • packages/theme-saas/src/select/index.less (2 hunks)
  • packages/theme/src/base/vars.less (1 hunks)
  • packages/theme/src/option-group/index.less (2 hunks)
  • packages/theme/src/option-group/vars.less (1 hunks)
  • packages/theme/src/option/index.less (2 hunks)
  • packages/theme/src/option/vars.less (1 hunks)
  • packages/theme/src/select-dropdown/index.less (4 hunks)
  • packages/theme/src/select-dropdown/vars.less (1 hunks)
  • packages/theme/src/select/index.less (11 hunks)
  • packages/theme/src/select/vars.less (1 hunks)
  • packages/vue/src/base-select/src/mobile-first.vue (2 hunks)
  • packages/vue/src/base-select/src/pc.vue (2 hunks)
  • packages/vue/src/option/src/mobile-first.vue (1 hunks)
  • packages/vue/src/option/src/pc.vue (1 hunks)
  • packages/vue/src/select/src/mobile-first.vue (2 hunks)
  • packages/vue/src/select/src/pc.vue (11 hunks)
🧰 Additional context used
🔇 Additional comments (46)
packages/theme/src/option-group/vars.less (5)

21-24: Divider styling has been updated for more flexibility.

The changes to divider-related variables provide more precise control:

  1. Replacing --ti-option-group-line-dividing-bg-color with --tv-OptionGroup-border-color-divider might change how the divider is styled. Ensure this is intentional and consistent with the design.
  2. The new --tv-OptionGroup-height-divider variable allows for easy adjustment of the divider's height, which is set to 0px by default. Consider if this default value is appropriate for all use cases.

To ensure these changes are applied consistently, run the following script:

#!/bin/bash
# Description: Check for any remaining usage of old divider-related variables and verify new ones

# Test: Search for old divider-related variables
echo "Checking for old divider-related variables:"
rg --type less '--ti-option-group-line-dividing-bg-color'

# Test: Verify the usage of new divider-related variables
echo "Verifying usage of new divider-related variables:"
rg --type less '(--tv-OptionGroup-border-color-divider|--tv-OptionGroup-height-divider)'

14-32: Naming convention has been updated for better consistency.

The change from --ti- to --tv- prefix and the adoption of PascalCase for component names in the variables is a significant improvement:

  1. This change likely aligns with a project-wide effort to standardize variable naming.
  2. The new convention improves readability and maintains consistency with Vue component naming conventions.

To ensure this naming convention is applied consistently across the project, run the following script:

#!/bin/bash
# Description: Check for any remaining old-style variable names and verify new naming convention

# Test: Search for any remaining --ti- prefixed variables in option-group related files
echo "Checking for any remaining --ti- prefixed variables:"
rg --type less '--ti-option-group' ./packages/theme/src/option-group

# Test: Verify the usage of new --tv- prefixed variables
echo "Verifying usage of new --tv- prefixed variables:"
rg --type less '--tv-OptionGroup' ./packages/theme/src/option-group

# Test: Check for consistency in PascalCase usage for component names
echo "Checking for consistency in PascalCase usage for component names:"
rg --type less '--tv-[A-Z]' ./packages/theme/src/option-group

If any inconsistencies are found, please update them to match the new naming convention.


14-32: Verify the impact of styling changes on the OptionGroup component.

The significant changes to the CSS variables may affect the OptionGroup component's appearance and layout. To ensure these changes don't introduce any styling issues:

  1. Thoroughly test the OptionGroup component in various scenarios and screen sizes.
  2. Verify that the removal of certain variables (e.g., --ti-option-group-title-font-weight, --ti-option-group-padding-bottom) doesn't negatively impact the component's design.
  3. Ensure that the new variable structure provides all necessary styling options for the component.

To help with verification, run the following script to identify files that might need updating:

#!/bin/bash
# Description: Identify files that might need updating due to CSS variable changes

# Test: Find .vue files that might use OptionGroup styles
echo "Checking for .vue files that might use OptionGroup styles:"
rg --type vue 'option-group' ./packages

# Test: Find .less files that might import or use OptionGroup styles
echo "Checking for .less files that might import or use OptionGroup styles:"
rg --type less 'option-group' ./packages/theme/src

# Test: Check for any hardcoded values that should now use the new variables
echo "Checking for potential hardcoded values:"
rg --type vue --type less '(12px|16px|8px|2px|4px|#808080|#f0f0f0)' ./packages

Review the output and update the identified files as necessary to use the new CSS variables.


26-32: Padding and margin variables have been simplified.

The changes to padding and margin variables streamline the styling:

  1. The new --tv-OptionGroup-title-padding-x replaces the old horizontal padding variable, maintaining similar functionality.
  2. The --tv-OptionGroup-title-margin now combines top and bottom margins into a single variable. This might affect the vertical spacing of the title. Ensure this change aligns with the intended design.
  3. The --tv-OptionGroup-title-margin-top-first variable is maintained, which is good for consistency in styling the first group.

However, note that the --ti-option-group-padding-bottom variable has been removed. Verify if this removal is intentional and doesn't negatively impact the layout.

Consider adding a comment explaining the decision to combine margin values and remove the bottom padding, to help future maintainers understand the reasoning behind these changes.

To ensure these changes are applied consistently, run the following script:

#!/bin/bash
# Description: Check for any remaining usage of old padding/margin variables and verify new ones

# Test: Search for old padding/margin-related variables
echo "Checking for old padding/margin-related variables:"
rg --type less '--ti-option-group-(title-padding-horizontal|title-margin-top|title-margin-bottom|padding-bottom)'

# Test: Verify the usage of new padding/margin-related variables
echo "Verifying usage of new padding/margin-related variables:"
rg --type less '(--tv-OptionGroup-title-padding-x|--tv-OptionGroup-title-margin|--tv-OptionGroup-title-margin-top-first)'

14-19: Font-related variables have been updated and streamlined.

The changes to font-related variables look good overall. However, please note:

  1. The font weight variable (--ti-option-group-title-font-weight) has been removed. Ensure this doesn't unintentionally affect the appearance of the option group title.
  2. The new line height variable (--tv-OptionGroup-line-height) is a welcome addition for better control over text spacing.

To ensure no unintended side effects, please run the following script:

✅ Verification successful

Font-related variables have been successfully updated and no old variables are found.

The removal of old font-related variables is confirmed, and the new variables are correctly implemented and used across the codebase. No issues detected with the current changes.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining usage of old font-related variables

# Test: Search for old font-related variables
echo "Checking for old font-related variables:"
rg --type less '--ti-option-group-(title-font-size|title-font-weight|title-text-color)'

# Test: Verify the usage of new font-related variables
echo "Verifying usage of new font-related variables:"
rg --type less '(--tv-OptionGroup-font-size|--tv-OptionGroup-text-color|--tv-OptionGroup-line-height)'

Length of output: 1910


Script:

#!/bin/bash
# Description: Corrected script to check for any remaining usage of old font-related variables

# Test: Search for old font-related variables
echo "Checking for old font-related variables:"
rg --type less '--ti-option-group-(title-font-size|title-font-weight|title-text-color)'

# Test: Verify the usage of new font-related variables
echo "Verifying usage of new font-related variables:"
rg --type less '(--tv-OptionGroup-font-size|--tv-OptionGroup-text-color|--tv-OptionGroup-line-height)'

Length of output: 1457


Script:

#!/bin/bash
# Description: Further corrected script to check for any remaining usage of old font-related variables

# Test: Search for old font-related variables
echo "Checking for old font-related variables:"
rg --type less -e '--ti-option-group-(title-font-size|title-font-weight|title-text-color)' . 

# Test: Verify the usage of new font-related variables
echo "Verifying usage of new font-related variables:"
rg --type less '(--tv-OptionGroup-font-size|--tv-OptionGroup-text-color|--tv-OptionGroup-line-height)' .

Length of output: 1003

packages/theme/src/option-group/index.less (3)

37-38: Excellent use of specific CSS variables for the divider.

The introduction of --tv-OptionGroup-height-divider and --tv-OptionGroup-border-color-divider variables for the ::after pseudo-element is a great improvement. These changes enhance the component's customizability and follow a consistent naming convention, which improves code readability and maintainability.


51-52: Good use of a specific variable for the first child's margin-top.

The introduction of --tv-OptionGroup-title-margin-top-first for the first child's top margin is a positive change. It follows the established naming convention and allows for easy customization of the first option group's spacing, enhancing the component's flexibility.


Line range hint 27-52: Excellent refactoring of the option-group styling.

The changes in this file significantly improve the component's styling structure:

  1. Consistent naming convention for CSS variables (e.g., --tv-OptionGroup-*).
  2. More specific and descriptive variable names.
  3. Improved customizability for various aspects of the option group.

These refactoring efforts enhance code maintainability, readability, and flexibility without altering the component's functionality. This aligns well with the PR's objective of refactoring the theme selection.

Great job on improving the codebase quality!

packages/theme/src/option/vars.less (2)

38-43: Improved layout control with new variables

The new layout-related variables (--tv-Option-height, --tv-Option-padding, --tv-Option-icon-margin-right) provide excellent control over the option component's layout. The naming is clear and consistent, and the use of referenced variables ensures theme consistency.


14-45: Overall improvement in theme variable organization and naming

The changes in this file represent a significant improvement in the organization and naming of theme variables for the Option component. The switch from --ti- to --tv- prefixes, along with more specific and well-commented variable names, enhances code readability and maintainability.

To ensure these changes don't introduce unintended side effects, please run the following script to check for any remaining usage of the old --ti-option-* variables in the codebase:

This script will help identify any remaining instances of the old variable names that need to be updated.

✅ Verification successful

Correction Needed in Verification Script Syntax

The provided script has an issue with the rg command usage. Please use the corrected script below to accurately search for old --ti-option-* variables:

Please run the updated script to verify that all instances of --ti-option-* have been addressed.


Script Correction: Adjust File Type Specification in Verification Script

The previous script encountered an issue because rg does not recognize the vue file type. Please use the corrected script below to accurately search for old --ti-option-* variables, including .vue files:

Please run the updated script to verify that all instances of --ti-option-* have been addressed.


Verification Successful: No Old Variables Found

All instances of the old --ti-option-* variables have been successfully removed and replaced with the new --tv-Option-* variables. The codebase is free from deprecated variable usages, ensuring improved organization and maintainability.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining usage of old --ti-option-* variables

# Search for old variable names in .vue, .js, .ts, and .less files
echo "Searching for old --ti-option-* variables in .vue, .js, .ts, and .less files:"
rg --type vue --type js --type ts --type less '--ti-option-' -l

# If any files are found, exit with an error code
if [ $? -eq 0 ]; then
  echo "Error: Found files still using old --ti-option-* variables. Please update them to use the new --tv-Option-* variables."
  exit 1
else
  echo "No files found using old --ti-option-* variables. All clear!"
fi

Length of output: 792


Script:

#!/bin/bash
# Description: Check for any remaining usage of old --ti-option-* variables

# Search for old variable names in .vue, .js, .ts, and .less files
echo "Searching for old --ti-option-* variables in .vue, .js, .ts, and .less files:"
rg --type vue --type js --type ts --type less -e '--ti-option-' -l

# If any files are found, exit with an error code
if [ $? -eq 0 ]; then
  echo "Error: Found files still using old --ti-option-* variables. Please update them to use the new --tv-Option-* variables."
  exit 1
else
  echo "No files found using old --ti-option-* variables. All clear!"
fi

Length of output: 408


Script:

#!/bin/bash
# Description: Check for any remaining usage of old --ti-option-* variables

# Search for old variable names in .vue, .js, .ts, and .less files
echo "Searching for old --ti-option-* variables in .vue, .js, .ts, and .less files:"
rg -g '*.vue' --type js --type ts --type less -e '--ti-option-' -l

# If any files are found, exit with an error code
if [ $? -eq 0 ]; then
  echo "Error: Found files still using old --ti-option-* variables. Please update them to use the new --tv-Option-* variables."
  exit 1
else
  echo "No files found using old --ti-option-* variables. All clear!"
fi

Length of output: 380

packages/vue/src/option/src/pc.vue (1)

Line range hint 52-52: LGTM! Please clarify the usage of new props.

The addition of new props enhances the component's API, allowing for more customization. The implementation looks clean.

Could you please clarify how the newly added props (except 'icon') are being used in the component? It's not immediately clear from the template or script how these props are utilized. If they're being passed to child components or used in the renderless logic, it would be helpful to have a brief comment explaining their purpose.

To verify the usage of these props, you can run the following script:

This will help ensure that the new props are properly utilized and not just added without purpose.

packages/vue/src/option/src/mobile-first.vue (2)

Line range hint 1-64: Overall changes improve component flexibility, consider additional steps.

The changes to this component enhance its flexibility and consistency:

  1. The template change improves semantic clarity.
  2. The addition of new props expands the component's API, allowing for more customization.

These improvements are welcome, but there are a few considerations:

  1. Ensure that the expanded API doesn't overly complicate the component's usage. Consider providing sensible defaults for new props where applicable.
  2. Update any existing documentation to reflect these changes, including usage examples for the new props.
  3. Extend the test suite to cover the new props and their interactions with existing functionality.
  4. If this component is part of a larger form system, ensure that these changes align with the overall design patterns and best practices of your form components.

To ensure proper test coverage, please run the following script:

#!/bin/bash
# Description: Check for test files related to this component and their content

# Test: Search for test files
echo "Searching for test files related to mobile-first.vue:"
fd -e spec.js -e test.js mobile-first

# Test: Check content of test files for new props
echo "Checking test files for coverage of new props:"
rg --type js 'value|label|created|disabled|events|visible|highlightClass|required' $(fd -e spec.js -e test.js mobile-first)

If the script doesn't find adequate test coverage for the new props, please update the test suite accordingly.


22-22: Approve data-tag change with a note on potential impacts.

The change from "tiny-select-dropdown-item" to "tiny-option" for the data-tag attribute improves semantic clarity. This refactoring aligns better with the component's purpose.

Please ensure that any code depending on this data attribute (e.g., CSS selectors, JavaScript queries) is updated accordingly. Run the following script to check for potential impacts:

examples/sites/demos/pc/app/select/events.spec.ts (2)

68-68: Approve consistent selector update.

The update to the close icon selector in this multi-select test case is consistent with the change made in the single-select test case. This consistency is commendable and aligns well with the refactoring objective.


29-29: Approve selector update and suggest verification.

The update to the close icon selector from .tiny-select__caret.icon-close to .tiny-select__caret.tiny-select__close appears to be a positive refactoring change. It aligns better with the component naming convention and improves specificity.

To ensure consistency, please verify that this class name change has been applied throughout the codebase. Run the following script to check for any remaining instances of the old selector:

✅ Verification successful

empty-nodata.png exists in the images directory

The file empty-nodata.png is present at packages/theme/src/images/empty-nodata.png.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if 'empty-nodata.png' exists in any 'images' directory.

# Test: Find 'empty-nodata.png' in 'images' directories.
# Expect: Paths where 'empty-nodata.png' is found.

fd 'empty-nodata.png' --glob 'images/*'

Length of output: 135


Script:

#!/bin/bash
# Description: Recursively search for 'empty-nodata.png' in the repository.

fd 'empty-nodata.png'

Length of output: 112

packages/theme-saas/src/select/index.less (1)

64-66: Class name update enhances consistency

The change to use .@{select-prefix-cls}__close as the class name promotes consistency and maintainability by utilizing the predefined prefix variable.

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

Line range hint 433-441: Verify Conditions for "Select All" Option

The v-if condition in the <li> element at lines 433-441 is:

v-if="multiple && showCheck && showAlloption && !state.multipleLimit && !state.query && !remote"

Please confirm that all these conditions are necessary and correctly reflect when the "Select All" option should be displayed. Ensure that state.multipleLimit and state.query are properly managed to prevent unexpected behavior.


Line range hint 94-95: Confirm Usage of TinyCheckbox Component

The TinyCheckbox component is imported at line 94:

import TinyCheckbox from '@opentiny/vue-checkbox'

And registered in the components at lines 110-118. However, there is no clear usage of TinyCheckbox within the template.

Please verify whether TinyCheckbox should be included in the template to provide checkbox functionality. If it is intended to be used, ensure it is correctly implemented. If not, consider removing the import and component registration to keep the code clean.

Also applies to: 110-118

packages/vue/src/select/src/mobile-first.vue (1)

445-448: ⚠️ Potential issue

Ensure all 'data-tag' attributes are consistently updated

The data-tag attribute has been changed to 'tiny-option' in multiple places. Please verify that all other instances of data-tag in this component and related components are updated accordingly. This ensures that event handlers and styles relying on these data-tag values function correctly.

To check for any remaining instances of the old data-tag value or other unexpected values, you can run:

Also applies to: 478-481

packages/vue/src/select/src/pc.vue (5)

28-28: Consistent Application of 'is-disabled' Class

The conditional addition of the 'is-disabled' class based on state.isDisabled ensures that the component correctly reflects its disabled state. This improves the user experience by visually indicating when the select component is disabled.


95-95: Correct Handling of Disabled State for Tags

By updating the :disabled attribute to state.selected[0].disabled || state.isDisabled, the first tag now appropriately reflects both its own disabled state and that of the entire select component. This provides better control over tag interactions in disabled scenarios.


129-129: Properly Disabling the Tag Count Indicator

Setting :disabled="state.isDisabled" on the tag displaying the additional selected count (+ N) ensures that this indicator is also disabled when the select component is disabled. This maintains consistency across the component's UI elements.


337-337: Confirm Class Naming Conventions and Potential Conflicts

The class list includes 'tiny-svg-size tiny-select__caret tiny-select__close'. Verify that combining 'tiny-select__caret' and 'tiny-select__close' does not introduce styling conflicts or unintended behaviors, as they may target overlapping styles.


432-435: Inconsistent Prop Casing: Ensure Consistency with 'input-box-type'

At line 435, the prop is used as input-box-type="underline" in kebab-case, which is consistent with Vue's template conventions. Ensure that the tiny-input component accepts this prop and that it's defined using the camelCase equivalent inputBoxType in the component's props.

packages/renderless/src/base-select/index.ts (2)

Line range hint 1714-1718: Ensure state.debounce is initialized properly

In the handleDebouncedQueryChange method, state.debounce is used to set the debounce delay. If state.debounce is not initialized or set to a valid number, this could lead to unintended delays or the method not functioning correctly. Verify that state.debounce is properly initialized with a numerical value before it's used.

If state.debounce is meant to be configurable, ensure it's set during the component initialization or provide a default value.


1769-1771: Verify consistency of selector update from tiny-select-dropdown-item to tiny-option

In the queryVisibleOptions method, the selector has been updated from tiny-select-dropdown-item to tiny-option. It's important to ensure that all references to tiny-select-dropdown-item have been updated throughout the codebase to prevent any inconsistent behavior or missed elements during queries.

Run the following script to find any remaining instances of tiny-select-dropdown-item:

This will help identify any places where the old selector is still in use.

✅ Verification successful

Selector update consistent across the codebase. No remaining instances of tiny-select-dropdown-item found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any occurrences of 'tiny-select-dropdown-item' in the codebase.

rg 'tiny-select-dropdown-item'

Length of output: 30

Comment on lines +33 to +37
await expect(select.locator('.tiny-input')).toHaveClass(/tiny-input-underline/)
await expect(input).toHaveCSS('border-top-width', '0px')
await expect(input).toHaveCSS('border-left-width', '0px')
await expect(input).toHaveCSS('border-right-width', '0px')
await expect(input).toHaveCSS('border-color', 'rgb(219, 219, 219)')
await expect(input).toHaveCSS('border-bottom-color', 'rgb(219, 219, 219)')
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Remaining border-color Assertion Found

A leftover assertion for border-color was detected in automatic-dropdown.spec.ts:

  • await expect(input).toHaveCSS('border-color', 'rgb(25, 25, 25)')

Please update this assertion to align with the recent refactoring to border-bottom-color to ensure consistency across the component's tests.

🔗 Analysis chain

Approve changes and suggest consistency check.

The updates to the class and CSS property assertions in the disabled state test are consistent with the changes made in the default state test. This systematic update improves the overall consistency of the component's structure and styling.

To ensure this refactoring has been applied consistently across all related components, please run the following check:

If these searches return results, it may indicate areas where the refactoring needs to be applied for consistency.


Update Verification Script to Include Vue Files and Check Remaining CSS Assertions

To address the issues found, please run the following updated shell script:

This script corrects the file type recognition by using glob patterns and will help ensure that all instances of the old class name and border-color assertions are identified.


Corrected Verification Script with Proper Quoting

To resolve the syntax error and accurately verify the consistency of the select component styling, please execute the following updated shell script:

Explanation of Changes:

  • First rg Command: Remains unchanged as it correctly searches for 'tiny-select__underline' in .ts and .vue files using single quotes.

  • Second rg Command:

    • Changed the outer quotes from single (') to double (") to allow single quotes within the regex pattern.
    • This adjustment prevents the shell from misinterpreting the single quotes around 'border-color', thereby eliminating the syntax error.

Please run this corrected script to ensure that all instances of the old class name and border-color assertions have been successfully addressed.


Corrected Verification Script with Proper Regex Escaping

To resolve the regex parse error and accurately verify the consistency of the select component styling, please execute the following updated shell script:

Explanation of Changes:

  • Second rg Command:

    • Changed the outer quotes from double (") to single (') to simplify escaping.
    • Escaped the parentheses and single quotes within the regex pattern using backslashes.
    • The corrected pattern toHaveCSS\('border-color' accurately matches the toHaveCSS('border-color', ...) assertions in the test files.

    Alternatively, if single quotes cause issues, you can use double quotes with properly escaped characters:

Please run this corrected script to ensure that all instances of the old class name and border-color assertions have been successfully addressed.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistency in select component styling across the codebase

# Test: Search for any remaining instances of the old class name
rg --type ts --type vue 'tiny-select__underline'

# Test: Search for any remaining instances of full border-color assertions in select tests
rg --type ts 'toHaveCSS\(.(border-color)' examples/sites/demos/pc/app/select

Length of output: 284


Script:

# 
#!/bin/bash
# Description: Check for consistency in select component styling across the codebase

# Test: Search for any remaining instances of the old class name in .ts and .vue files
rg 'tiny-select__underline' -g "*.ts" -g "*.vue"

# Test: Search for any remaining instances of full border-color assertions in select tests
rg 'toHaveCSS\(.\'border-color\'' examples/sites/demos/pc/app/select

Length of output: 142


Script:

# 
#!/bin/bash
# Description: Check for consistency in select component styling across the codebase

# Test: Search for any remaining instances of the old class name in .ts and .vue files
rg 'tiny-select__underline' -g "*.ts" -g "*.vue"

# Test: Search for any remaining instances of full border-color assertions in select tests
rg "toHaveCSS\(.\'border-color\'" examples/sites/demos/pc/app/select

Length of output: 232


Script:

# 
#!/bin/bash
# Description: Check for consistency in select component styling across the codebase

# Test: Search for any remaining instances of the old class name in .ts and .vue files
rg 'tiny-select__underline' -g "*.ts" -g "*.vue"

# Test: Search for any remaining instances of full border-color assertions in select tests
rg "toHaveCSS\('border-color'" examples/sites/demos/pc/app/select

Length of output: 251


Script:

  rg "toHaveCSS\('border-color'" examples/sites/demos/pc/app/select
  

Length of output: 202

--tv-SelectDropdown-search-width: calc(100% - var(--tv-space-xl, 16px) * 2);

// 空数据提示内边距
--tv-SelectDropdown-empty-padding: 46px 0;
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Replace hardcoded padding with CSS variable

The value 46px in --tv-SelectDropdown-empty-padding is hardcoded. To enhance scalability and themeability, consider using a CSS variable.

Define a new variable or reuse an existing one:

-  --tv-SelectDropdown-empty-padding: 46px 0;
+  --tv-SelectDropdown-empty-padding: var(--tv-space-xxxl, 46px) 0;

This approach ensures consistent spacing throughout the application.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
--tv-SelectDropdown-empty-padding: 46px 0;
--tv-SelectDropdown-empty-padding: var(--tv-space-xxxl, 46px) 0;

// 字号(loading、空数据等辅助提示类)
--tv-SelectDropdown-font-size-tip: var(--tv-font-size-sm, 12px);
// 文本色(loading、空数据等辅助提示类)
--tv-SelectDropdown-text-color-tip: var(---tv-color-text-secondary, #595959);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix typo in CSS variable name: Unexpected triple dash

The CSS variable ---tv-color-text-secondary in the var() function has an extra dash. It should be --tv-color-text-secondary.

Apply this diff to correct the typo:

-  --tv-SelectDropdown-text-color-tip: var(---tv-color-text-secondary, #595959);
+  --tv-SelectDropdown-text-color-tip: var(--tv-color-text-secondary, #595959);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
--tv-SelectDropdown-text-color-tip: var(---tv-color-text-secondary, #595959);
--tv-SelectDropdown-text-color-tip: var(--tv-color-text-secondary, #595959);

--tv-SelectDropdown-padding: var(--tv-space-md, 8px) 0;

// 搜索框内边距
--tv-SelectDropdown-search-padding: 0 var(--tv-space-lg, 12px) 0 20px;
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider using CSS variables instead of hardcoded values

In the declaration of --tv-SelectDropdown-search-padding, the value 20px is hardcoded. For maintainability and consistency, consider using a CSS variable instead of a fixed value.

You might define a new spacing variable or use an existing one if appropriate:

-  --tv-SelectDropdown-search-padding: 0 var(--tv-space-lg, 12px) 0 20px;
+  --tv-SelectDropdown-search-padding: 0 var(--tv-space-lg, 12px) 0 var(--tv-space-xxl, 20px);

If --tv-space-xxl does not exist, consider adding it to your spacing scale.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
--tv-SelectDropdown-search-padding: 0 var(--tv-space-lg, 12px) 0 20px;
--tv-SelectDropdown-search-padding: 0 var(--tv-space-lg, 12px) 0 var(--tv-space-xxl, 20px);

Comment on lines +83 to +84
&:not(:has(.tiny-option__checkbox-wrap)).selected {
color: var(--tv-Option-text-color-selected);
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

⚠️ Potential issue

Multiple Uses of :has() Pseudo-Class Detected

The :has() pseudo-class is used in several files within the codebase, which may impact browser compatibility:

  • packages/theme-saas/src/tree/index.less
  • packages/theme/src/textarea/index.less
  • packages/theme/src/nav-menu/index.less
  • packages/theme/src/option/index.less
  • packages/theme-saas/src/scrollbar/index.less
  • packages/theme-saas/src/query-builder-pro/index.less
  • packages/theme/src/link/index.less
  • packages/theme/src/input/index.less
  • packages/theme/src/grid/table.less
  • packages/theme/src/float-button/index.less
  • packages/theme/src/form-item/index.less
  • packages/theme/src/dropdown/index.less
  • packages/theme/src/dropdown-menu/index.less
  • packages/theme/src/date-table/index.less
  • packages/theme-saas/src/collapse-item/index.less
  • packages/theme-saas/src/amount/index.less
  • packages/theme-saas/src/grid/table-global.less

Please ensure that the use of :has() aligns with the project's browser support policy. If broader browser compatibility is required, consider using alternative selectors to replace :has().

🔗 Analysis chain

Verify browser support for the ':has()' pseudo-class

The CSS :has() pseudo-class used in line 83 may not be fully supported across all browsers, particularly older versions. This might lead to inconsistent styling or unexpected behavior in unsupported browsers. Please ensure that using :has() aligns with the project's browser support policy or consider alternative selectors for broader compatibility.

To verify the usage of the :has() pseudo-class in the codebase, you can run the following script:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for all occurrences of ':has(' in CSS and LESS files to identify potential compatibility issues.

# Test: Find all instances of ':has('. Expect: Only intentional uses in supported contexts.
rg --type css --type less ':has\('

Length of output: 182


Script:

#!/bin/bash
# Description: Correctly search for all occurrences of ':has(' in CSS and LESS files to identify potential compatibility issues.

rg --type css --type less ':has\('

Length of output: 4066

100% {
stroke-dasharray: 90, 150;
stroke-dashoffset: -120px;
// tiny 新增,空数据图片
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Translate comment to English for maintainability

The comment // tiny 新增,空数据图片 is in Chinese. Translating it to English will improve the code's readability for all contributors.

}

&.show-loading-icon {
text-align: left;
justify-content: left;
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Correct invalid justify-content value

The value left is not valid for justify-content. Replace it with flex-start to properly align items to the left.

Apply this diff to fix the issue:

-        justify-content: left;
+        justify-content: flex-start;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
justify-content: left;
justify-content: flex-start;

Comment on lines +445 to 448
data-tag="tiny-option"
@click.stop="toggleCheckAll(false)"
@mousedown.stop
@mouseenter="state.hoverIndex = -9"
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Avoid magic numbers by defining a constant for '-9'

In the @mouseenter event, state.hoverIndex is set to -9. Using magic numbers can reduce code readability and maintainability. Consider defining a constant to represent this special value, making the code clearer.

Define the constant in your script section:

const HOVER_INDEX_CHECK_ALL = -9;

Update the code to use the constant:

- @mouseenter="state.hoverIndex = -9"
+ @mouseenter="state.hoverIndex = HOVER_INDEX_CHECK_ALL"

Also applies to: 478-481

@@ -292,6 +292,7 @@
:display-only-content="state.displayOnlyContent"
:unselectable="state.readonly ? 'on' : 'off'"
:validate-event="false"
:inputBoxType="inputBoxType"
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Inconsistent Prop Naming: Use Kebab-Case for Prop Names in Templates

In Vue templates, prop names should be written in kebab-case when used within templates. The inputBoxType prop should be updated to input-box-type to adhere to Vue's style guidelines and maintain consistency.

Apply this diff to fix the prop name casing:

- :inputBoxType="inputBoxType"
+ input-box-type="inputBoxType"

Committable suggestion was skipped due to low confidence.

Comment on lines +571 to +587
<div v-if="loadingText || slots.empty" class="tiny-select-dropdown__empty-wrap">
<slot name="empty" v-if="slots.empty"></slot>
<span v-else-if="showEmptyImage" class="tiny-select-dropdown__empty-images"></span>
<p class="tiny-select-dropdown__empty" v-else>
{{ state.emptyText }}
</p>
</div>
<div v-else class="tiny-select-dropdown__loading" :class="{ 'show-loading-icon': loading }">
<template v-if="!loading">
<span v-if="showEmptyImage" class="tiny-select-dropdown__empty-images"></span>
<span v-else class="tiny-select-dropdown__empty"> {{ state.emptyText }}</span>
</template>

<component
v-if="loading"
class="circular"
:is="state.designConfig.icons.loadingIcon || 'icon-loading-shadow'"
></component>
<template v-else>
<span v-if="showEmptyImage" class="tiny-select-dropdown__empty-images"></span>
<span v-else class="tiny-select-dropdown__empty"> {{ state.emptyText }}</span>
</template>
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Improper Use of <template> Tag Inside a <div> Element

Using a <template> tag directly inside a <div> is invalid, as <template> is not rendered in the DOM. This can lead to unexpected rendering issues.

Apply this diff to replace <template> with <div>:

- <template v-else>
+ <div v-else>

Ensure to close the <div> appropriately:

- </template>
+ </div>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div v-if="loadingText || slots.empty" class="tiny-select-dropdown__empty-wrap">
<slot name="empty" v-if="slots.empty"></slot>
<span v-else-if="showEmptyImage" class="tiny-select-dropdown__empty-images"></span>
<p class="tiny-select-dropdown__empty" v-else>
{{ state.emptyText }}
</p>
</div>
<div v-else class="tiny-select-dropdown__loading" :class="{ 'show-loading-icon': loading }">
<template v-if="!loading">
<span v-if="showEmptyImage" class="tiny-select-dropdown__empty-images"></span>
<span v-else class="tiny-select-dropdown__empty"> {{ state.emptyText }}</span>
</template>
<component
v-if="loading"
class="circular"
:is="state.designConfig.icons.loadingIcon || 'icon-loading-shadow'"
></component>
<template v-else>
<span v-if="showEmptyImage" class="tiny-select-dropdown__empty-images"></span>
<span v-else class="tiny-select-dropdown__empty"> {{ state.emptyText }}</span>
</template>
<div v-if="loadingText || slots.empty" class="tiny-select-dropdown__empty-wrap">
<slot name="empty" v-if="slots.empty"></slot>
<span v-else-if="showEmptyImage" class="tiny-select-dropdown__empty-images"></span>
<p class="tiny-select-dropdown__empty" v-else>
{{ state.emptyText }}
</p>
</div>
<div v-else class="tiny-select-dropdown__loading" :class="{ 'show-loading-icon': loading }">
<component
v-if="loading"
class="circular"
:is="state.designConfig.icons.loadingIcon || 'icon-loading-shadow'"
></component>
<div v-else>
<span v-if="showEmptyImage" class="tiny-select-dropdown__empty-images"></span>
<span v-else class="tiny-select-dropdown__empty"> {{ state.emptyText }}</span>
</div>
</div>

@MomoPoppy MomoPoppy closed this Oct 14, 2024
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.

1 participant