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(comp:select): add loading prop for select component #1439

Merged
merged 2 commits into from Feb 21, 2023

Conversation

kovsu
Copy link
Member

@kovsu kovsu commented Feb 9, 2023

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our guidelines
  • Tests for the changes have been added/updated or not needed
  • Docs and demo have been added/updated or not needed

What is the current behavior?

fix #1435

What is the new behavior?

Other information

@idux-bot
Copy link

idux-bot bot commented Feb 9, 2023

This preview will be available after the AzureCI is passed.

@kovsu kovsu changed the title Add loading prop for select component feat(comp:select): add loading prop for select component Feb 9, 2023
@codecov
Copy link

codecov bot commented Feb 9, 2023

Codecov Report

Merging #1439 (602eeab) into main (caf4dbf) will increase coverage by 0.17%.
The diff coverage is 92.68%.

❗ Current head 602eeab differs from pull request most recent head f33c9b7. Consider uploading reports for the commit f33c9b7 to get more accurate results

@@            Coverage Diff             @@
##             main    #1439      +/-   ##
==========================================
+ Coverage   92.80%   92.98%   +0.17%     
==========================================
  Files         327      327              
  Lines       30292    30361      +69     
  Branches     2541     2561      +20     
==========================================
+ Hits        28114    28232     +118     
+ Misses       2178     2129      -49     
Impacted Files Coverage Δ
packages/pro/search/src/ProSearch.tsx 15.49% <0.00%> (ø)
packages/components/select/src/Select.tsx 86.95% <83.33%> (-0.39%) ⬇️
packages/pro/tree/src/ProTree.tsx 96.96% <95.83%> (+0.65%) ⬆️
packages/cdk/utils/src/tree.ts 98.40% <100.00%> (ø)
packages/components/notification/src/types.ts 100.00% <100.00%> (ø)
packages/components/select/src/types.ts 100.00% <100.00%> (ø)
packages/components/tree/src/Tree.tsx 95.29% <100.00%> (+0.14%) ⬆️
packages/components/tree/src/types.ts 99.65% <100.00%> (+<0.01%) ⬆️
packages/cdk/a11y/src/focusMonitor.ts 91.59% <0.00%> (+1.75%) ⬆️
.../components/utils/src/useTreeCheckStateResolver.ts 89.71% <0.00%> (+14.89%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

packages/components/select/src/Select.tsx Outdated Show resolved Hide resolved
packages/components/select/demo/Loading.vue Outdated Show resolved Hide resolved
packages/components/select/src/Select.tsx Outdated Show resolved Hide resolved
packages/components/select/src/panel/Panel.tsx Outdated Show resolved Hide resolved
packages/components/select/src/panel/Panel.tsx Outdated Show resolved Hide resolved
packages/components/select/style/index.less Outdated Show resolved Hide resolved
@sallerli1
Copy link
Contributor

sallerli1 commented Feb 13, 2023

不建议在面板上加loading,可以加在外部 content 组件上面,面板仅仅是数据展示,耦合太多功能会影响后续扩展问题。

比如以下场景,这样的写法可能没有办法兼容:

  1. 用户有自定义面板,loading需要覆盖全部内容
  2. loading的时候需要处理浮层内输入的状态,因为可能存在搜索和可输入的情况
  3. 面板组件被单独用在其他高级组件中

另外,loading是需要考虑自定义 spin 配置的,可以参考一下其他组件的 spin 写法

@@ -107,7 +108,13 @@ export default defineComponent({
}
}

const handleBlur = () => accessor.markAsBlurred()
const handleBlur = () => {
Copy link
Member

Choose a reason for hiding this comment

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

这个地方还是没有正确 rebase 哈,你需要先在 main 分支 pull 一下最新代码,再切换到 select-loading 分支做一次rebase

@@ -37,6 +37,7 @@
| `status` | 手动指定校验状态 | `valid \| invalid \| validating` | - | - | - |
| `suffix` | 设置后缀图标 | `string \| #suffix` | `down` | ✅ | - |
| `virtual` | 是否开启虚拟滚动 | `boolean` | `false` | - | - |
| `loading` | 是否显示加载中状态 | `boolean \| SpinPublicProps` | `false` | - | - |
Copy link
Member

Choose a reason for hiding this comment

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

这个直接改成 spin 吧, 跟 table 直接保持一致,默认值为 undefined
然后注意下 API 顺序,按照字母顺序排下序

Comment on lines 171 to 179
const { loading } = props
if (!loading) {
return children
}
if (typeof loading === 'boolean') {
return <IxSpin>{children}</IxSpin>
} else {
return <IxSpin {...loading}>{children}</IxSpin>
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const { loading } = props
if (!loading) {
return children
}
if (typeof loading === 'boolean') {
return <IxSpin>{children}</IxSpin>
} else {
return <IxSpin {...loading}>{children}</IxSpin>
}
const { spin } = props
const spinProps = isBoolean(spin) ? { spinning: spin } : spin
return spinProps ? <IxSpin {...spinProps }>{children}</IxSpin> : children

@@ -12,6 +12,7 @@ import type { VirtualScrollToFn } from '@idux/cdk/scroll'
import type { ExtractInnerPropTypes, ExtractPublicPropTypes, MaybeArray, VKey } from '@idux/cdk/utils'
import type { EmptyProps } from '@idux/components/empty'
import type { FormSize } from '@idux/components/form'
import type { SpinPublicProps } from '@idux/components/spin/src/types'
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
import type { SpinPublicProps } from '@idux/components/spin/src/types'
import type { SpinProps } from '@idux/components/spin'

@@ -80,6 +81,7 @@ export const selectProps = {
status: String as PropType<ValidateStatus>,
suffix: { type: String, default: undefined },
virtual: { type: Boolean, default: false },
loading: { type: [Boolean, Object] as PropType<boolean | SpinPublicProps>, default: false },
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
loading: { type: [Boolean, Object] as PropType<boolean | SpinPublicProps>, default: false },
spin: { type: [Boolean, Object] as PropType<boolean | SpinProps >, default: undefined },

@kovsu kovsu requested a review from danranVm February 18, 2023 04:12
@danranVm danranVm changed the base branch from main to feature February 21, 2023 11:45
@danranVm danranVm merged commit 56c892e into IDuxFE:feature Feb 21, 2023
danranVm pushed a commit that referenced this pull request Feb 27, 2023
* feat(comp:select): add loading prop

* fix(comp:select): spin type in api doc
danranVm pushed a commit that referenced this pull request Feb 27, 2023
* feat(comp:select): add loading prop

* fix(comp:select): spin type in api doc
@kovsu kovsu deleted the select-loading branch March 10, 2023 06:41
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.

[comp:select] 下拉框新增loading 效果
3 participants