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

[comp: Checkbox ] add Checkbox Component #120

Closed
1 task done
liuzaijiang opened this issue Jan 7, 2021 · 12 comments · Fixed by #162
Closed
1 task done

[comp: Checkbox ] add Checkbox Component #120

liuzaijiang opened this issue Jan 7, 2021 · 12 comments · Fixed by #162
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@liuzaijiang
Copy link
Contributor

liuzaijiang commented Jan 7, 2021

  • I have searched the issues of this repository and believe that this is not a duplicate.

What problem does this feature solve?

多选框

What does the proposed API look like?

Checkbox

Props

支持原生input属性, 例如value, name, id

参数 说明 类型 默认值 全局配置 备注
checked 指定当前勾选框是否选中 boolean false - 支持双向绑定,使用时按照v-model:checked = 形式
disabled 禁用状态 boolean false - -
indeterminate 是否处于不确定状态 boolean false - 当值为true时,按钮样式处于半选状态,且不受checked影响
trueValue 勾选框选中时返回的值 string | number true - -
falseValue 勾选框不选中时返回的值 string | number false - -

Slots

名称 说明 参数类型 备注
defalut 文本区域 - -

Emits

名称 说明 参数类型 备注
change 点击勾选框时触发 Function(checkValue:boolean | string | number) -

Checkbox Group

Group Props

| 名称 | 说明 | 类型 | 默认值 | 全局配置 | 备注 |
| --- | --- | --- | --- | --- | --- |value
| value | 指定选中的选项 | string[] | [] | - | 支持双向绑定,使用时按照v-model:value = 形式 |
| disabled | 子ix-checkbox禁用状态 | boolean | false | - |- |
| name | 子ix-checkbox 的 name 属性 | string | - | - |- |

Group Slots

名称 说明 参数类型 备注
defalut ix-checkbox区域 - -

Group Emits

名称 说明 参数类型 备注
change value变化时的回调函数 Function(checkValue:string[]) -
@liuzaijiang liuzaijiang added the enhancement New feature or request label Jan 7, 2021
@danranVm danranVm added this to the v1.0.0 milestone Jan 8, 2021
@liuzaijiang
Copy link
Contributor Author

对于Checkbox Group的子checkbox的实现方式我们是按照ant的options属性直接传进去好还是说以插槽形式传入?
@LaamGinghong @danranVm

@LaamGinghong
Copy link
Contributor

对于Checkbox Group的子checkbox的实现方式我们是按照ant的options属性直接传进去好还是说以插槽形式传入?
@LaamGinghong @danranVm

我个人更倾向于使用slots的方式来实现

@LaamGinghong
Copy link
Contributor

LaamGinghong commented Jan 11, 2021

有一个疑惑,beforeChange 这个 API 应该是更倾向于对非受控组件的,我们的业务是否会有这样的场景?
在我看来,大部分需要使用 Checkbox 的场景应该都会使它变成受控组件,那么 beforeChange 这个 API 似乎意义不大。

@danranVm
Copy link
Member

danranVm commented Jan 11, 2021

API 设计过于复杂了,checkbox 应该是一个很简单的组件才对。

几点建议:

  • checbox 和 checkbox-group 的 defaultCheckedbeforeChange 都移除。
  • checkox 的 tip 移除
  • checkout 的 checked 支持 v-model
  • checkout 支持 value,搭配 checkout-group 使用
  • checkout-group 的 value 支持 v-model

@danranVm
Copy link
Member

对于Checkbox Group的子checkbox的实现方式我们是按照ant的options属性直接传进去好还是说以插槽形式传入?
@LaamGinghong @danranVm

暂时可以仅支持 slot ,后续可能要支持 options, slot 的优先级高于 options

@LaamGinghong
Copy link
Contributor

CheckoutGroup的value应该是一个泛型,不应局限于使用string

@liuzaijiang
Copy link
Contributor Author

liuzaijiang commented Jan 11, 2021

CheckoutGroup的value应该是一个泛型,不应局限于使用string

ant也只支持string,这样使用起来也简单,类型增加多了有啥好处?
@LaamGinghong

@LaamGinghong
Copy link
Contributor

CheckoutGroup的value应该是一个泛型,不应局限于使用string

ant也只支持string,这样使用起来也简单,类型增加多了有啥好处?
@LaamGinghong

我忽略了input的value只支持string,除了去掉 beforeChange 以外,我没有别的问题了

@danranVm
Copy link
Member

CheckoutGroup的value应该是一个泛型,不应局限于使用string

ant也只支持string,这样使用起来也简单,类型增加多了有啥好处?
@LaamGinghong

value 的类型应该支持 any

@coolyuantao
Copy link
Member

label呢?

@zymoplastic
Copy link
Contributor

zymoplastic commented Jan 11, 2021

有一个疑惑,beforeChange 这个 API 应该是更倾向于对非受控组件的,我们的业务是否会有这样的场景?
在我看来,大部分需要使用 Checkbox 的场景应该都会使它变成受控组件,那么 beforeChange 这个 API 似乎意义不大。

beforeChange 这种比如用户点击了组件, 但是这个操作很重, 需要二次确认后生效, 如果没有这个 API, 我们只能事后再把值重新改回去, 而这种时候其实产生了副作用, 有可能某个地方 watch 了这个值的变化.
这个其实代表了一类需求, 也就是外部的使用者想在某些时机控制内部程序的流程, 决定是否执行内部的一些逻辑, 而这类需求使用普通的 Vue 事件机制是很难做到的

@liuzaijiang
Copy link
Contributor Author

label呢?

checkbox提供默认插槽来完成文本区域的功能,后续如用户需要增加tip也可以在里面自行增加
slot:

名称 说明 参数类型 备注
defalut checkbox文本区域 - -

@coolyuantao

liuzaijiang added a commit to liuzaijiang/components that referenced this issue Jan 21, 2021
liuzaijiang added a commit to liuzaijiang/components that referenced this issue Jan 21, 2021
liuzaijiang added a commit to liuzaijiang/components that referenced this issue Jan 25, 2021
liuzaijiang added a commit to liuzaijiang/components that referenced this issue Jan 25, 2021
liuzaijiang added a commit to liuzaijiang/components that referenced this issue Jan 25, 2021
liuzaijiang added a commit to liuzaijiang/components that referenced this issue Jan 25, 2021
liuzaijiang added a commit to liuzaijiang/components that referenced this issue Jan 25, 2021
liuzaijiang added a commit to liuzaijiang/components that referenced this issue Jan 25, 2021
liuzaijiang added a commit to liuzaijiang/components that referenced this issue Jan 25, 2021
liuzaijiang added a commit to liuzaijiang/components that referenced this issue Jan 25, 2021
liuzaijiang added a commit to liuzaijiang/components that referenced this issue Jan 25, 2021
liuzaijiang added a commit to liuzaijiang/components that referenced this issue Jan 25, 2021
liuzaijiang added a commit to liuzaijiang/components that referenced this issue Jan 26, 2021
liuzaijiang added a commit to liuzaijiang/components that referenced this issue Jan 26, 2021
liuzaijiang added a commit to liuzaijiang/components that referenced this issue Jan 26, 2021
liuzaijiang added a commit to liuzaijiang/components that referenced this issue Jan 26, 2021
liuzaijiang added a commit to liuzaijiang/components that referenced this issue Jan 26, 2021
liuzaijiang added a commit to liuzaijiang/components that referenced this issue Jan 27, 2021
liuzaijiang added a commit to liuzaijiang/components that referenced this issue Jan 27, 2021
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 a pull request may close this issue.

5 participants