Skip to content

refactor(components): [radio] use type-based definitions#23466

Merged
btea merged 3 commits into
element-plus:devfrom
lw56777:refactor/radio-ComponentProps-#23399
Jan 19, 2026
Merged

refactor(components): [radio] use type-based definitions#23466
btea merged 3 commits into
element-plus:devfrom
lw56777:refactor/radio-ComponentProps-#23399

Conversation

@lw56777
Copy link
Copy Markdown
Contributor

@lw56777 lw56777 commented Jan 19, 2026

Please make sure these boxes are checked before submitting your PR, thank you!

  • Make sure you follow contributing guide English | (中文 | Español | Français).
  • Make sure you are merging your commits to dev branch.
  • Add some descriptions and refer to relative issues for your PR.

修复:#23399

Summary by CodeRabbit

  • Refactor
    • Improved public API and typing for radio components to enhance type safety and consistency.
    • Centralized default prop values for radios, radio buttons, and radio groups to standardize initialization.
    • Added deprecation notices and migration guidance for legacy prop typings; runtime behavior remains unchanged.

✏️ Tip: You can customize this high-level summary in your review settings.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 19, 2026

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 19, 2026

📝 Walkthrough

Walkthrough

Refactors radio props into explicit TypeScript public interfaces (RadioPropsBase/RadioProps, RadioButtonProps, RadioGroupProps), replaces ExtractPropTypes with ExtractPublicPropTypes, adds defaults constants (radioPropsDefaults, radioButtonPropsDefaults, radioGroupPropsDefaults), and updates Vue files to use defineProps() + withDefaults and pass props into hooks.

Changes

Cohort / File(s) Summary
Core radio types & defaults
packages/components/radio/src/radio.ts
Added RadioPropsBase, RadioProps, RadioPropsPublic, and exported radioPropsDefaults; switched to ExtractPublicPropTypes; kept deprecated runtime radioProps with notes.
Radio button types & defaults
packages/components/radio/src/radio-button.ts, packages/components/radio/src/radio-button.vue
Added RadioButtonProps (extends RadioPropsBase), introduced RadioButtonPropsPublic alias (deprecated), exported radioButtonPropsDefaults; radio-button.vue now uses defineProps<RadioButtonProps>() + withDefaults(...) and passes props into useRadio.
Radio group types & defaults
packages/components/radio/src/radio-group.ts, packages/components/radio/src/radio-group.vue
Added radioOptionProp/radioOption types, RadioGroupProps, RadioGroupPropsPublic (deprecated alias), exported radioDefaultProps and radioGroupPropsDefaults; radio-group.vue switched to typed defineProps<RadioGroupProps>() + withDefaults(...).
Radio component prop usage updates
packages/components/radio/src/radio.vue
Switched to defineProps<RadioProps>() + withDefaults(radioPropsDefaults) and updated imports to use the new type/default exports instead of the runtime radioProps.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • btea
  • keeplearning66

Poem

🐰 With a hop and a twitch of ear,
New types and defaults now appear.
Props aligned, types tidy and bright,
Radios sing in typed delight. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main refactoring objective of converting the radio component to use type-based definitions instead of object-based prop definitions.
Description check ✅ Passed The PR description includes all required checklist items marked as complete and references the related issue #23399, though it could benefit from more detailed technical explanation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jan 19, 2026

Open in StackBlitz

pnpm add https://pkg.pr.new/element-plus/element-plus@23466
npm i https://pkg.pr.new/element-plus/element-plus@23466
yarn add https://pkg.pr.new/element-plus/[email protected]

commit: cccc600

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 19, 2026

🧪 Playground Preview: https://element-plus.run/?pr=23466
Please comment the example via this playground if needed.

Comment thread packages/components/radio/src/radio-button.vue Outdated
Comment thread packages/components/radio/src/radio-group.ts Outdated
@btea btea merged commit 8235131 into element-plus:dev Jan 19, 2026
17 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

@lw56777 Thanks for your contribution! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants