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

CascaderProps 重构 #480

Merged
merged 58 commits into from
Apr 12, 2024
Merged

CascaderProps 重构 #480

merged 58 commits into from
Apr 12, 2024

Conversation

crazyair
Copy link
Contributor

@crazyair crazyair commented Apr 3, 2024

Cascader 泛型优化,解决了 options + filedNames + value + onChange params Value 的类型检测不爽的问题

遗留问题:
一、由于 checkableReactNode 类型,所以区分是否多选类型不完美,如下 5 种场景,会有 2 个 onChange value 为 any 类型,不过在 antd 没有此问题,antd 的 multiple 是 boolean 类型

image

PS:支持 ReactNode 也没什么历史背景,就是初设计就加上了类型 #184 导致没法去掉了

04-10 进展
给 CascaderProps 增加 Multiple 泛型,用来判断是否是多选,可完美解决 ReactNode 检测不健壮问题,以及 onChange 方法需要使用 2 个类型:单选 SingleCascaderProps['onChange'] 多选 MultipleCascaderProps['onChange']

image

遗留问题:
由于 Value 泛型在 OptionType 泛型后面,所以当传了 value 没传 options,那 onChange 的 value 会是 DefaultOptionType['value'] 类型
image

Copy link

vercel bot commented Apr 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
cascader ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 12, 2024 7:17am

@crazyair crazyair changed the title Fix type 2 CascaderProps 重构 Apr 3, 2024
Copy link

codecov bot commented Apr 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.67%. Comparing base (fab1188) to head (53af749).
Report is 3 commits behind head on master.

❗ Current head 53af749 differs from pull request most recent head b947106. Consider uploading reports for the commit b947106 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #480   +/-   ##
=======================================
  Coverage   99.66%   99.67%           
=======================================
  Files          23       23           
  Lines         604      611    +7     
  Branches      182      186    +4     
=======================================
+ Hits          602      609    +7     
  Misses          2        2           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

src/Cascader.tsx Outdated Show resolved Hide resolved
src/Cascader.tsx Outdated Show resolved Hide resolved
src/Cascader.tsx Outdated Show resolved Hide resolved
src/index.tsx Show resolved Hide resolved
@zombieJ zombieJ merged commit 5035090 into react-component:master Apr 12, 2024
9 checks passed
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.

2 participants