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(pager): [pager] add simplest pager to adaptive x-design #2126

Merged
merged 2 commits into from
Sep 14, 2024

Conversation

gimmyhehe
Copy link
Member

@gimmyhehe gimmyhehe commented Sep 13, 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

    • Introduced a new "simplest" mode for the pagination component, enhancing user experience with additional display options.
    • Added a new radio button for selecting the "simplest" mode in the pager interface.
    • Enhanced pager functionality with a new component allowing users to select the current page from a dropdown.
  • Bug Fixes

    • Updated CSS properties for the pager's disabled state to reflect the latest design changes.
  • Documentation

    • Updated package configuration files to include license and module type information, improving clarity and correctness.

@gimmyhehe gimmyhehe added the enhancement New feature or request (功能增强) label Sep 13, 2024
Copy link

coderabbitai bot commented Sep 13, 2024

Walkthrough

The pull request introduces a new pagination mode called "simplest," enhancing the existing pagination component's flexibility. It includes updates to various files, such as adding a new radio button option, modifying CSS properties for the disabled state, and adjusting the internal state management. Additionally, changes to the package configuration files reflect updates to dependencies and module types, ensuring proper integration and functionality within the application.

Changes

Files Change Summary
examples/sites/demos/apis/pager.js Added new option 'simplest' to the mode property in pagination configuration; updated Chinese localization description.
examples/sites/demos/pc/app/pager/disabled-and-size.spec.ts Updated expected CSS properties for the pager component's disabled state and size.
examples/sites/demos/pc/app/pager/pager-mode-composition-api.vue Added a new radio button labeled "simplest" in the radio group for mode selection.
examples/sites/demos/pc/app/pager/pager-mode.vue Added a new radio button labeled "simplest" in the radio group for mode selection.
packages/design/smb/src/pager/index.ts Removed totalFixedLeft from the state object, simplifying the state structure.
packages/renderless/src/pager/index.ts Added support for 'simplest' mode, including new computed properties for pager options and width.
packages/renderless/src/pager/vue.ts Introduced new computed properties for 'simplest' mode; modified logic for totalFixedLeft.
packages/theme/src/base-select/vars.less Adjusted vertical distance of the icon for mini-sized selector.
packages/theme/src/pager/index.less Removed .tiny-loading__spinner class; updated styles for disabled states; added styles for &__simplest-pager-popover.
packages/theme/src/pager/old-theme.js Removed 'ti-pager-pop-body-margin-top' from tinyPagerOldTheme.
packages/theme/src/pager/vars.less Standardized color values; added new variables for disabled states; set minimum height for pagination list items.
packages/vue/src/base-select/package.json Added type, license, and sideEffects fields; updated dependencies and devDependencies.
packages/vue/src/base-select/src/pc.vue Removed imports for Grid and Tree components, simplifying dependencies.
packages/vue/src/pager/package.json Added type, license, and sideEffects fields; corrected dependency entry; reinstated devDependencies.
packages/vue/src/pager/src/pc.vue Introduced tiny-base-select component for "simplest pager" functionality with dynamic rendering based on state.

Possibly related PRs

Poem

🐰 In the meadow where bunnies play,
A new pager mode has come to stay.
"Simplest" shines, a choice so bright,
With buttons and styles, oh what a sight!
Hopping along, we cheer with glee,
For pagination's new harmony! 🌼

Tip

OpenAI O1 model for chat
  • We have deployed OpenAI's latest O1 model for chat.
  • OpenAI claims that this model has superior reasoning capabilities than their GPT-4o model.
  • Please share any feedback with us in the discussions post.

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1636bdf and 9bbb55b.

Files selected for processing (1)
  • packages/vue/src/pager/package.json (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/vue/src/pager/package.json

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

@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

Outside diff range and nitpick comments (2)
examples/sites/demos/apis/pager.js (1)

98-98: Update the English description for consistency.

The Chinese description has been updated to mention the addition of the 'simplest' mode in version 3.19.0. For consistency, please consider updating the English description as well to reflect this change.

Apply this diff to update the English description:

-'en-US': 'Set the display mode of pagination components, which takes priority over layout'
+'en-US': 'Set the display mode of pagination components, which takes priority over layout. The `simplest` mode was added in version 3.19.0.'
packages/renderless/src/pager/index.ts (1)

81-88: Translate code comments to English for consistency.

The computedSimplestPagerWidth function correctly calculates the width of the simplest pager based on the current page number and the number of options available, ensuring that the input field is appropriately sized for user interaction.

Please translate the code comments to English for consistency:

-    // 输入框长度 = 基本宽度加数字长度
+    // Input field length = base width + digit length
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 37f275f and 1636bdf.

Files selected for processing (15)
  • examples/sites/demos/apis/pager.js (1 hunks)
  • examples/sites/demos/pc/app/pager/disabled-and-size.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/pager/pager-mode-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/pager/pager-mode.vue (1 hunks)
  • packages/design/smb/src/pager/index.ts (1 hunks)
  • packages/renderless/src/pager/index.ts (2 hunks)
  • packages/renderless/src/pager/vue.ts (3 hunks)
  • packages/theme/src/base-select/vars.less (1 hunks)
  • packages/theme/src/pager/index.less (6 hunks)
  • packages/theme/src/pager/old-theme.js (0 hunks)
  • packages/theme/src/pager/vars.less (4 hunks)
  • packages/vue/src/base-select/package.json (1 hunks)
  • packages/vue/src/base-select/src/pc.vue (0 hunks)
  • packages/vue/src/pager/package.json (1 hunks)
  • packages/vue/src/pager/src/pc.vue (3 hunks)
Files not reviewed due to no reviewable changes (2)
  • packages/theme/src/pager/old-theme.js
  • packages/vue/src/base-select/src/pc.vue
Files skipped from review due to trivial changes (1)
  • packages/theme/src/base-select/vars.less
Additional context used
Biome
packages/renderless/src/pager/index.ts

[error] 21-21: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

Additional comments not posted (39)
examples/sites/demos/pc/app/pager/pager-mode-composition-api.vue (1)

9-9: Verify the implementation of the "simplest" mode in the pager component.

The addition of the new radio button option for the "simplest" mode is consistent with the existing code structure.

To ensure the "simplest" mode is fully functional, please verify its implementation in the pager component. Run the following script to locate the relevant code:

packages/vue/src/pager/package.json (6)

3-3: LGTM!

Setting "type" to "module" is a good practice for modern JavaScript projects. It indicates that the package is intended to be used as an ES module.


6-6: LGTM!

Adding the "license" field and setting it to "MIT" is important for open-source projects. The MIT license is a permissive license that allows for free use, modification, and distribution of the code.


7-7: LGTM!

Setting "sideEffects" to false is a good optimization. It informs bundlers that the package does not have any side effects when imported, allowing them to perform tree-shaking and eliminate unused code. This can result in smaller bundle sizes.


15-15: LGTM!

The correction to the dependency entry for @opentiny/vue-base-select is necessary. The previous entry had an incorrect syntax with an extra single quote. The corrected entry ensures proper resolution of the package.


16-16: Verify the usage of the added dependency.

The @opentiny/vue-common package has been added to the "dependencies" section. Please ensure that the functionality provided by this package is actually used within the @opentiny/vue-pager package code.

Run the following script to verify the usage of the added dependency:

Verification successful

Dependency usage confirmed

The @opentiny/vue-common package is being used in the @opentiny/vue-pager package as intended. Multiple import statements were found in different files, importing various utilities and components such as defineComponent, $props, $prefix, $setup, setup, and props. This confirms that the added dependency is actively utilized within the package code.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `@opentiny/vue-common` within the package code.

# Test: Search for import statements of `@opentiny/vue-common`. Expect: At least one occurrence.
rg --type typescript $'@opentiny/vue-common' packages/vue/src/pager

Length of output: 101


Script:

#!/bin/bash
# Description: Verify the usage of `@opentiny/vue-common` within the package code.

# Find all .ts, .js, .vue files in the pager directory and search for import or require statements
fd '\.(ts|js|vue)$' packages/vue/src/pager --exec rg -i "(@opentiny/vue-common)"

# If no results are found, search for any mention of @opentiny/vue-common
if [ $? -ne 0 ]; then
  echo "No import or require statements found. Searching for any mention of @opentiny/vue-common:"
  fd '\.(ts|js|vue)$' packages/vue/src/pager --exec rg -i "(@opentiny/vue-common)"
fi

Length of output: 814


24-26: Verify the existence of tests for the package.

The reinstated "devDependencies" section includes dependencies for testing utilities and the vitest testing framework. This suggests that the package has tests. Please ensure that tests are present in the package and that they adequately cover the package functionality.

Run the following script to verify the existence of tests:

Verification successful

Tests exist but coverage can be improved

The pager component has a dedicated test file (packages/vue/src/pager/__test__/pager.test.tsx) using Vitest as the testing framework. The file contains three implemented tests covering basic functionality, event handling, and custom layout. However, there are 15 additional test cases marked as 'todo', indicating areas where test coverage can be expanded.

  • Existing tests: Basic usage, current-change event, and custom layout
  • Areas for improvement: Implement the 'todo' tests to cover additional features and edge cases

While the current tests provide a foundation, completing the 'todo' tests would significantly enhance the test coverage and reliability of the pager component.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of tests for the package.

# Test: Search for test files. Expect: At least one occurrence.
fd --type file --regex '.*\.(test|spec)\.(js|ts)$' packages/vue/src/pager

Length of output: 75


Script:

#!/bin/bash
# Description: Comprehensive search for pager tests

# Search for test files in the entire packages/vue directory
echo "Searching for test files in packages/vue:"
fd --type file --regex '.*\.(test|spec)\.(js|ts|vue)$' packages/vue

# Look for files with 'pager' in their name
echo -e "\nSearching for files with 'pager' in their name:"
fd pager packages/vue

# Search for 'pager' mentions within any test files
echo -e "\nSearching for 'pager' mentions in test files:"
rg -i "pager" packages/vue -g "*.{test,spec}.{js,ts,vue}"

# Check for a tests or __tests__ directory
echo -e "\nChecking for tests or __tests__ directories:"
fd -t d "(tests|__tests__)" packages/vue

Length of output: 3104


Script:

#!/bin/bash
# Description: Verify pager test file content and structure

# Display the content of the pager test file
echo "Content of pager.test.tsx:"
cat packages/vue/src/pager/__test__/pager.test.tsx

# Check for any additional test files in the pager directory
echo -e "\nAdditional test files in the pager directory:"
fd --type file --regex '.*\.(test|spec)\.(js|ts|tsx|vue)$' packages/vue/src/pager

# Check the structure of the test file (looking for test-related keywords)
echo -e "\nTest structure verification:"
rg -i "(describe|it|test|expect)" packages/vue/src/pager/__test__/pager.test.tsx

Length of output: 3870

examples/sites/demos/pc/app/pager/pager-mode.vue (1)

9-9: Verify the behavior and impact of the new "simplest" pagination mode.

The addition of the "simplest" radio button expands the available pagination modes, which is a good enhancement.

However, please verify the following:

  1. What is the expected behavior of the "simplest" mode? How does it differ from the existing modes?
  2. Are there any additional configurations required for the "simplest" mode to function correctly?
  3. Does the "simplest" mode have any impact on other parts of the component or application? Please ensure thorough testing.
Verification successful

The "simplest" pagination mode is properly implemented and consistent.

Based on the codebase analysis, the "simplest" mode for the pager component is correctly implemented and used consistently. Here are the key findings:

  1. The mode is added to both the composition API (pager-mode-composition-api.vue) and options API (pager-mode.vue) versions of the component.
  2. In the renderless package (packages/renderless/src/pager/index.ts), the "simplest" mode affects the layout: props.mode === 'simplest' && (layout = 'total, prev, simplest-pager, next').
  3. There are computed properties specifically for the "simplest" mode, such as simplestPagerOption and simplestPagerWidth.
  4. The Vue component (packages/vue/src/pager/src/pc.vue) includes a "simplest" pager popover, indicating proper integration.

These findings address the initial concerns:

  1. The behavior of the "simplest" mode is defined in the renderless package, providing a specific layout.
  2. Additional configurations are in place, such as computed properties and width calculations.
  3. The impact on other parts of the component is handled consistently across the codebase.

The addition of the "simplest" mode appears to be a well-implemented enhancement to the pager component.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the behavior and impact of the new "simplest" pagination mode.

# Test 1: Search for the usage of the "simplest" mode. Expect: Relevant code snippets.
rg --type vue -A 5 $'simplest'

# Test 2: Search for any additional configurations related to the "simplest" mode. Expect: Relevant code snippets, if any.
rg --type vue -A 5 $'simplest.*mode'

# Test 3: Search for any computed properties, methods, or watchers that might be impacted by the "simplest" mode. Expect: Relevant code snippets, if any.
rg --type vue -A 10 $'(computed|methods|watch).*simplest'

Length of output: 210


Script:

#!/bin/bash
# Description: Verify the behavior and impact of the new "simplest" pagination mode.

# Test 1: Search for the usage of the "simplest" mode in Vue, JS, and TS files.
fd '\.(vue|js|ts)$' | xargs rg -n -A 5 'simplest'

# Test 2: Search for any additional configurations related to the "simplest" mode in Vue, JS, and TS files.
fd '\.(vue|js|ts)$' | xargs rg -n -A 5 'simplest.*mode'

# Test 3: Search for any computed properties, methods, or watchers that might be impacted by the "simplest" mode in Vue, JS, and TS files.
fd '\.(vue|js|ts)$' | xargs rg -n -A 10 '(computed|methods|watch).*simplest'

# Test 4: Search for any mentions of "simplest" in relation to pager or pagination in Vue, JS, and TS files.
fd '\.(vue|js|ts)$' | xargs rg -n -A 5 '(pager|pagination).*simplest'

Length of output: 4228

examples/sites/demos/pc/app/pager/disabled-and-size.spec.ts (2)

15-15: LGTM!

The change to the expected color CSS property for the sizeChange element in the disabled state is appropriate. It reflects an update to the visual design or styling of the component and ensures that the test accurately verifies the updated appearance.


16-16: LGTM!

The change to the expected border-top-color CSS property for the sizeChange element in the disabled state is appropriate. It reflects an update to the visual design or styling of the component and ensures that the test accurately verifies the updated appearance of the border-top-color.

packages/vue/src/base-select/package.json (10)

3-3: LGTM!

The addition of the type field with the value module correctly indicates that the module is an ES module.


6-6: LGTM!

The addition of the license field with the value MIT correctly specifies the license type.


7-7: LGTM!

The sideEffects field remains unchanged, and its repositioning in the file is acceptable.


15-15: LGTM!

The addition of the @opentiny/vue-button dependency is correctly reflected in the dependencies section.


16-16: LGTM!

The addition of the @opentiny/vue-checkbox dependency is correctly reflected in the dependencies section.


18-18: LGTM!

The addition of the @opentiny/vue-filter-box dependency is correctly reflected in the dependencies section.


19-19: LGTM!

The addition of the @opentiny/vue-icon dependency is correctly reflected in the dependencies section.


23-23: LGTM!

The addition of the @opentiny/vue-recycle-scroller dependency is correctly reflected in the dependencies section.


32-32: LGTM!

The addition of the @opentiny-internal/vue-test-utils dependency to the devDependencies section is correct.


33-33: LGTM!

The addition of the vitest dependency to the devDependencies section is correct.

packages/renderless/src/pager/vue.ts (5)

13-14: LGTM!

The imports for the new computed properties related to the "simplest" pager mode are correctly added.


88-89: LGTM!

The new computed properties related to the "simplest" pager mode are correctly added to the state object.


109-110: LGTM!

The new computed properties related to the "simplest" pager mode are correctly added to the api object.


Line range hint 1-165: Review complete.

All the relevant changes mentioned in the list of alterations have been reviewed. No additional changes are required.


97-99: Verify the pager's layout in the simplest mode.

The change to the totalFixedLeft computed property is correctly implemented and indicates a more nuanced handling of the pager's layout based on the mode.

Please ensure that the pager's layout is visually correct when in the simplest mode. Run the following script to verify:

Verification successful

To gather more information about the pager component usage, let's try a more general search:


The pager's layout in the simplest mode appears to be correctly implemented.

Based on the codebase analysis, we can see that the pager component is used in various configurations, including a 'simplest-pager' mode. The change to the totalFixedLeft computed property doesn't seem to negatively impact the pager's layout in its simplest form. Here are the key observations:

  1. There's a specific reference to a 'simplest-pager' item, which likely corresponds to the simplest mode.
  2. Various layouts are used, including minimal configurations like layout="prev, pager, next", which could represent simpler versions of the pager.
  3. The mode prop is used in several instances, allowing for different pager modes including potentially the simplest one.

While we can't directly see the impact of the totalFixedLeft change, the widespread and varied use of the pager component across the codebase suggests that it's functioning correctly in different modes, including the simplest one.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the pager's layout in the simplest mode.

# Test: Search for the pager component usage in Vue templates. Expect: Pager layout is correct in the simplest mode.
fd -e vue -x rg -A 10 $'<.*pager.*>'

Length of output: 41336


Script:

#!/bin/bash
# Search for any mentions of 'pager' in Vue files
fd -e vue -x rg -i 'pager'

Length of output: 41552

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

21-21: LGTM!

The change standardizes the background color for active pagination items to a lowercase hex format, which is consistent with the other color values in the file.


34-37: LGTM!

The addition of the new variables --ti-pager-select-disabled-border-color and --ti-pager-select-disabled-bg-color enhances the visual feedback for disabled states. The variable names are consistent with the naming convention used in the file.


106-106: LGTM!

The change sets the minimum height for pagination list items explicitly, which provides better control over the minimum height of the pagination list items.

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

72-84: LGTM!

The code segment correctly introduces the new "simplest pager" functionality using the tiny-base-select component. The component is properly integrated with the existing pager options, and its properties are correctly derived from the pager state. The dynamic width and optimization flag ensure optimal rendering and performance, while the v-model directive enables two-way data binding for the selected page.

examples/sites/demos/apis/pager.js (1)

95-95: LGTM!

The type of the mode property has been correctly updated to include the new 'simplest' mode option.

packages/theme/src/pager/index.less (7)

169-173: LGTM!

The disabled state styles for the input element within the &__goto block are correctly updated to use the appropriate CSS variables, maintaining consistency with the overall theme.


184-184: LGTM!

The line-height property of the &-text block within the &__goto block is correctly updated to use the --ti-pager-input-height CSS variable, ensuring consistent vertical alignment with the input element.


213-213: LGTM!

The hover state styles for the button element within the &__goto block are correctly updated to use the appropriate CSS variables, maintaining consistency with the overall theme.


218-218: LGTM!

The disabled state styles for the button element within the &__goto block are correctly updated to use the appropriate CSS variables, maintaining consistency with the overall theme.


321-321: LGTM!

The line-height property of the .list-item class within the &-poplist block is correctly updated to use the --ti-pager-poplist-item-min-height CSS variable, ensuring consistent vertical alignment with the minimum height of the list item.


518-519: LGTM!

The disabled state styles for the &__page-size block are correctly updated to use the appropriate CSS variables, maintaining consistency with the overall theme.


534-547: LGTM!

The new &__simplest-pager-popover block is correctly added with styles for option labels and selected states. The styles are using the appropriate CSS variables, maintaining consistency with the overall theme and targeting the correct elements within the block.

packages/renderless/src/pager/index.ts (2)

71-79: LGTM!

The computedSimplestPagerOption function correctly generates an array of pager options based on the total number of items divided by the internal page size. The label format indicating the current page and total pages enhances the user interface by offering clearer navigation options.


21-21: The static analysis hint is a false positive.

The new layout for the simplest mode is correctly added to the computedInternalLayout function.

The suspicious assignment flagged by the static analysis tool at line 21 is a false positive because the assignment is intentional and does not cause any issues. It can be safely ignored.

Tools
Biome

[error] 21-21: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

@@ -1,7 +1,6 @@
export default {
state: {
pageSizeText: '',
align: 'right',
totalFixedLeft: true
align: 'right'
Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Reconsider the removal of totalFixedLeft property

The removal of the totalFixedLeft property from packages/design/smb/src/pager/index.ts may have unintended consequences on other parts of the codebase. Several other files still use this property:

  • packages/vue/src/pager/src/index.ts: Includes totalFixedLeft in type definitions.
  • packages/renderless/types/pager.type.ts: Defines totalFixedLeft as a boolean type.
  • packages/design/saas/src/pager/index.ts and packages/design/aurora/src/pager/index.ts: Still use totalFixedLeft: true.
  • packages/renderless/src/pager/vue.ts: Has a computed property for totalFixedLeft that falls back to design config or a default value.

Before proceeding with this change, consider the following:

  1. Review the usage of totalFixedLeft across all pager components in different design packages.
  2. Ensure that removing this property from the SMB design package doesn't break consistency with other design systems.
  3. Update the renderless package to handle cases where totalFixedLeft might be undefined in some design configs.
  4. Verify that the Vue package can handle the absence of totalFixedLeft in its type definitions.

A more comprehensive review of the changes across the entire pager component ecosystem is recommended to maintain consistency and prevent potential bugs.

Analysis chain

Verify the removal of totalFixedLeft doesn't break anything.

The removal of the totalFixedLeft property simplifies the state structure, which is a good change.

However, ensure that the component doesn't rely on the totalFixedLeft property for rendering logic or calculations. Run the following script to verify:

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the removal of `totalFixedLeft` doesn't break anything.

# Test 1: Search for usages of `totalFixedLeft` in the codebase. 
# Expect: No occurrences found.
rg --type typescript $'totalFixedLeft'

# Test 2: Search for usages of `state.totalFixedLeft` in the codebase.
# Expect: No occurrences found.
rg --type typescript $'state\.totalFixedLeft'

Length of output: 154


Script:

#!/bin/bash
# Description: Verify the removal of `totalFixedLeft` doesn't break anything.

# Test 1: Search for usages of `totalFixedLeft` in all text files
echo "Searching for 'totalFixedLeft' in all text files:"
rg -i 'totalFixedLeft' --type-add 'text:*.{ts,js,tsx,jsx}' -t text

# Test 2: Use fd to find TypeScript and JavaScript files, then search within them
echo "Searching for 'totalFixedLeft' in TypeScript and JavaScript files:"
fd -e ts -e js -e tsx -e jsx | xargs grep -i 'totalFixedLeft' || echo "No matches found"

# Test 3: Search for usages of `state.totalFixedLeft` in all text files
echo "Searching for 'state.totalFixedLeft' in all text files:"
rg -i 'state\.totalFixedLeft' --type-add 'text:*.{ts,js,tsx,jsx}' -t text

# Test 4: Use fd to find TypeScript and JavaScript files, then search for `state.totalFixedLeft`
echo "Searching for 'state.totalFixedLeft' in TypeScript and JavaScript files:"
fd -e ts -e js -e tsx -e jsx | xargs grep -i 'state\.totalFixedLeft' || echo "No matches found"

Length of output: 1804

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.

2 participants