Skip to content

Commit

Permalink
fix(comp:*): the control type of all form components is incomplete (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
danranVm committed Mar 8, 2023
1 parent c217da6 commit ace2a1e
Show file tree
Hide file tree
Showing 27 changed files with 87 additions and 38 deletions.
2 changes: 1 addition & 1 deletion packages/components/cascader/docs/Api.zh.md
Expand Up @@ -5,7 +5,7 @@

| 名称 | 说明 | 类型 | 默认值 | 全局配置 | 备注 |
| --- | --- | --- | --- | --- | --- |
| `control` | 控件控制器 | `string \| number \| AbstractControl` | - | - | 配合 `@idux/cdk/forms` 使用, 参考 [Form](/components/form/zh) |
| `control` | 控件控制器 | `string \| number \| (string \| number)[] \| AbstractControl` | - | - | 配合 `@idux/cdk/forms` 使用, 参考 [Form](/components/form/zh) |
| `v-model:value` | 当前选中的的值 | `any \| any[] \| any[][]` | - | - | 使用 `control` 时,此配置无效 |
| `v-model:expandedKeys` | 展开节点的 `key` 数组 | `VKey[]` | - | - | - |
| `v-model:loadedKeys` | 已经加载完毕的节点的 `key` | `VKey[]` | - | - | - |
Expand Down
5 changes: 4 additions & 1 deletion packages/components/cascader/src/types.ts
Expand Up @@ -61,7 +61,10 @@ export const cascaderPanelProps = {
} as const

export const cascaderProps = {
control: { type: [String, Number, Object] as PropType<string | number | AbstractControl>, default: undefined },
control: {
type: [String, Number, Object, Array] as PropType<string | number | (string | number)[] | AbstractControl>,
default: undefined,
},
value: { type: null, default: undefined },
expandedKeys: { type: Array as PropType<VKey[]>, default: undefined },
loadedKeys: { type: Array as PropType<VKey[]>, default: undefined },
Expand Down
4 changes: 2 additions & 2 deletions packages/components/checkbox/docs/Api.zh.md
Expand Up @@ -7,7 +7,7 @@

| 名称 | 说明 | 类型 | 默认值 | 全局配置 | 备注 |
| --- | --- | --- | --- | --- | --- |
| `control` | 控件控制器 | `string \| number \| AbstractControl` | - | - | 配合 `@idux/cdk/forms` 使用, 参考 [Form](/components/form/zh) |
| `control` | 控件控制器 | `string \| number \| (string \| number)[] \| AbstractControl` | - | - | 配合 `@idux/cdk/forms` 使用, 参考 [Form](/components/form/zh) |
| `v-model:checked` | 指定当前勾选框是否选中 | `boolean \| string \| number` | - | - | 使用 `control` 时,此配置无效 |
| `autofocus` | 是否以自动聚焦 | `boolean` | `false` | - | - |.
| `buttoned` | 是否以按钮显示 | `boolean` | - | - | - |
Expand Down Expand Up @@ -36,7 +36,7 @@
| 名称 | 说明 | 类型 | 默认值 | 全局配置 | 备注 |
| --- | --- | --- | --- | --- | --- |
| `control` | 控件控制器 | `string \| number \| AbstractControl` | - | - | 配合 `@idux/cdk/forms` 使用, 参考 [Form](/components/form/zh) |
| `control` | 控件控制器 | `string \| number \| (string \| number)[] \| AbstractControl` | - | - | 配合 `@idux/cdk/forms` 使用, 参考 [Form](/components/form/zh) |
| `v-model:value` | 指定当前勾选框是否选中 | `any[]` | - | - | 使用 `control` 时,此配置无效 |
| `buttoned` | 设置组内 `IxCheckbox``buttoned` 属性 | `boolean` | `false` | - | - |
| `dataSource` | 勾选框组数据源 | `CheckboxData[]` | - | - | 优先级高于 `default` 插槽 |
Expand Down
10 changes: 8 additions & 2 deletions packages/components/checkbox/src/types.ts
Expand Up @@ -14,7 +14,10 @@ import type { SpaceProps } from '@idux/components/space'
import type { DefineComponent, HTMLAttributes, LabelHTMLAttributes, PropType } from 'vue'

export const checkboxProps = {
control: { type: [String, Number, Object] as PropType<string | number | AbstractControl>, default: undefined },
control: {
type: [String, Number, Object, Array] as PropType<string | number | (string | number)[] | AbstractControl>,
default: undefined,
},
checked: { type: [String, Number, Boolean] as PropType<CheckValue>, default: undefined },

autofocus: { type: Boolean, default: false },
Expand Down Expand Up @@ -50,7 +53,10 @@ export type CheckboxComponent = DefineComponent<
export type CheckboxInstance = InstanceType<DefineComponent<CheckboxProps, CheckboxBindings>>

export const checkboxGroupProps = {
control: { type: [String, Number, Object] as PropType<string | number | AbstractControl>, default: undefined },
control: {
type: [String, Number, Object, Array] as PropType<string | number | (string | number)[] | AbstractControl>,
default: undefined,
},
value: { type: Array, default: undefined },

buttoned: { type: Boolean, default: false },
Expand Down
2 changes: 1 addition & 1 deletion packages/components/date-picker/docs/Api.zh.md
Expand Up @@ -6,7 +6,7 @@
| 名称 | 说明 | 类型 | 默认值 | 全局配置 | 备注 |
| --- | --- | --- | --- | --- | --- |
| `v-model:open` | 日期面板是否展开 | `boolean` | - | - | - |
| `control` | 控件控制器 | `string \| number \| AbstractControl` | - | - | 配合 `@idux/cdk/forms` 使用, 参考 [Form](/components/form/zh) |
| `control` | 控件控制器 | `string \| number \| (string \| number)[] \| AbstractControl` | - | - | 配合 `@idux/cdk/forms` 使用, 参考 [Form](/components/form/zh) |
| `cellTooltip` | 日期节点的tooltip | `(cell: { value: Date, disabled: boolean }) => string | void` | - | - | - |
| `allowInput` | 允许输入模式 | `boolean \| 'overlay'` | `false` | - | `'overlay'` 时在浮层内输入 |
| `autofocus` | 默认获取焦点 | `boolean` | `false` | - | - |
Expand Down
5 changes: 4 additions & 1 deletion packages/components/date-picker/src/types.ts
Expand Up @@ -34,7 +34,10 @@ export interface TimePanelOptions extends PickerTimePanelOptions {
}

const datePickerCommonProps = {
control: { type: [String, Number, Object] as PropType<string | number | AbstractControl>, default: undefined },
control: {
type: [String, Number, Object, Array] as PropType<string | number | (string | number)[] | AbstractControl>,
default: undefined,
},
cellTooltip: Function as PropType<(cell: { value: Date; disabled: boolean }) => string | void>,
open: {
type: Boolean,
Expand Down
6 changes: 3 additions & 3 deletions packages/components/form/docs/Api.zh.md
Expand Up @@ -6,7 +6,7 @@
| 名称 | 说明 | 类型 | 默认值 | 全局配置 | 备注 |
| --- | --- | --- | --- | --- | --- |
| `colonless` | 配置 `IxFormItem``colonless` 默认值 | `boolean` | `false` || `seer` 主题默认为 `true` |
| `control` | 表单的控制器 | `string \| number \| AbstractControl` | - | - | 通常是配合 `useFormGroup` 使用 |
| `control` | 表单的控制器 | `string \| number \| (string \| number)[] \| AbstractControl` | - | - | 通常是配合 `useFormGroup` 使用 |
| `controlCol` | 配置 `IxFormItem``controlCol` 默认值 | `number \| ColProps` | - | - | - |
| `controlTooltipIcon` | 配置表单控件的提示信息icon | `string` | `'info-circle'` || - |
| `labelAlign` | 配置 `IxFormItem``labelAlign` 默认值 | `'start' \| 'end'` | `'end'` || `seer` 主题默认为 `'start'` |
Expand All @@ -28,7 +28,7 @@
| 名称 | 说明 | 类型 | 默认值 | 全局配置 | 备注 |
| --- | --- | --- | --- | --- | --- |
| `colonless` | 是否不显示 `label` 后面的冒号 | `boolean` | - | - | - |
| `control` | 表单控件的控制器 | `string \| number \| AbstractControl` | - | - | 默认取第 1 个子输入控件的 control,如果存在多个输入控件,建议手动指定,参考示例中的 `Phone Number`|
| `control` | 表单控件的控制器 | `string \| number \| (string \| number)[] \| AbstractControl` | - | - | 默认取第 1 个子输入控件的 control,如果存在多个输入控件,建议手动指定,参考示例中的 `Phone Number`|
| `controlCol` | 配置表单控件的布局配置,可参考 `IxCol` 组件 | `number \| ColProps` | - | - | 传入 `string` 或者 `number` 时,为 `IxCol``span` 配置 |
| `controlTooltip` | 配置表单控件的提示信息 | `string \| #controlTooltip` | - | - | 通常用于对输入规则的详细说明 |
| `controlTooltipIcon` | 配置表单控件的提示信息icon | `string` | - | - | - |
Expand All @@ -52,7 +52,7 @@

| 名称 | 说明 | 类型 | 默认值 | 全局配置 | 备注 |
| --- | --- | --- | --- | --- | --- |
| `control` | 表单控件的控制器 | `string \| number \| AbstractControl` | - | - | - |
| `control` | 表单控件的控制器 | `string \| number \| (string \| number)[] \| AbstractControl` | - | - | - |

### useFormItemRegister

Expand Down
15 changes: 12 additions & 3 deletions packages/components/form/src/types.ts
Expand Up @@ -14,7 +14,10 @@ import type { DefineComponent, HTMLAttributes, PropType } from 'vue'
const colProp = [Number, String, Object] as PropType<number | string | ColProps>

export const formProps = {
control: { type: [String, Number, Object] as PropType<string | number | AbstractControl>, default: undefined },
control: {
type: [String, Number, Object, Array] as PropType<string | number | (string | number)[] | AbstractControl>,
default: undefined,
},
colonless: { type: Boolean, default: undefined },
controlCol: colProp,
controlTooltipIcon: String,
Expand All @@ -35,7 +38,10 @@ export type FormInstance = InstanceType<DefineComponent<FormProps>>

export const formItemProps = {
colonless: { type: Boolean, default: undefined },
control: { type: [String, Number, Object] as PropType<string | number | AbstractControl>, default: undefined },
control: {
type: [String, Number, Object, Array] as PropType<string | number | (string | number)[] | AbstractControl>,
default: undefined,
},
controlCol: colProp,
controlTooltip: String,
controlTooltipIcon: String,
Expand All @@ -62,7 +68,10 @@ export type FormItemComponent = DefineComponent<
export type FormItemInstance = InstanceType<DefineComponent<FormItemProps>>

export const formWrapperProps = {
control: { type: [String, Number, Object] as PropType<string | number | AbstractControl>, default: undefined },
control: {
type: [String, Number, Object, Array] as PropType<string | number | (string | number)[] | AbstractControl>,
default: undefined,
},
} as const

export type FormWrapperProps = ExtractInnerPropTypes<typeof formWrapperProps>
Expand Down
2 changes: 1 addition & 1 deletion packages/components/input-number/docs/Api.zh.md
Expand Up @@ -8,7 +8,7 @@
| 名称 | 说明 | 类型 | 默认值 | 全局配置 | 备注 |
| --- | --- | --- | --- | --- | --- |
| `v-model:value` | 控件值 | `number` | - | - | 使用 `control` 时,此配置无效 |
| `control` | 控件控制器 | `string \| number \| AbstractControl` | - | - | 配合 `@idux/cdk/forms` 使用, 参考 [Form](/components/form/zh) |
| `control` | 控件控制器 | `string \| number \| (string \| number)[] \| AbstractControl` | - | - | 配合 `@idux/cdk/forms` 使用, 参考 [Form](/components/form/zh) |
| `addonAfter` | 设置后缀 | `string \| #addonAfter` | - | - | - |
| `addonBefore` | 设置前缀 | `string \| #addonBefore` | - | - | - |
| `disabled` | 禁用 | `boolean` | `false` | - | 使用 `control` 时,此配置无效 |
Expand Down
5 changes: 4 additions & 1 deletion packages/components/input-number/src/types.ts
Expand Up @@ -14,7 +14,10 @@ export type InputNumberButtonPosition = 'inner' | 'outer'

export const inputNumberProps = {
value: [Number, null] as PropType<number | null>,
control: { type: [String, Number, Object] as PropType<string | number | AbstractControl>, default: undefined },
control: {
type: [String, Number, Object, Array] as PropType<string | number | (string | number)[] | AbstractControl>,
default: undefined,
},
disabled: {
type: Boolean,
default: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/components/input/docs/Api.zh.md
Expand Up @@ -8,7 +8,7 @@
| 名称 | 说明 | 类型 | 默认值 | 全局配置 | 备注 |
| --- | --- | --- | --- | --- | --- |
| `v-model:value` | 控件值 | `string` | - | - | 使用 `control` 时,此配置无效 |
| `control` | 控件控制器 | `string \| number \| AbstractControl` | - | - | 配合 `@idux/cdk/forms` 使用, 参考 [Form](/components/form/zh) |
| `control` | 控件控制器 | `string \| number \| (string \| number)[] \| AbstractControl` | - | - | 配合 `@idux/cdk/forms` 使用, 参考 [Form](/components/form/zh) |
| `addonAfter` | 设置后置标签 | `string \| #addonAfter` | - | - | - |
| `addonBefore` | 设置前置标签 | `string \| #addonBefore` | - | - | - |
| `borderless` | 是否显示边框 | `boolean` | `false` || - |
Expand Down
8 changes: 4 additions & 4 deletions packages/components/input/src/types.ts
Expand Up @@ -10,11 +10,11 @@ import type { ExtractInnerPropTypes, ExtractPublicPropTypes, MaybeArray } from '
import type { FormSize } from '@idux/components/form'
import type { DefineComponent, InputHTMLAttributes, PropType } from 'vue'

export type TextareaResize = 'none' | 'both' | 'horizontal' | 'vertical'
export type TextareaAutoRows = { minRows: number; maxRows: number }

export const inputCommonProps = {
control: { type: [String, Number, Object] as PropType<string | number | AbstractControl>, default: undefined },
control: {
type: [String, Number, Object, Array] as PropType<string | number | (string | number)[] | AbstractControl>,
default: undefined,
},
value: { type: String, default: undefined },

clearable: { type: Boolean, default: undefined },
Expand Down
4 changes: 2 additions & 2 deletions packages/components/radio/docs/Api.zh.md
Expand Up @@ -5,7 +5,7 @@

| 名称 | 说明 | 类型 | 默认值 | 全局配置 | 备注 |
| --- | --- | --- | --- | --- | --- |
| `control` | 控件控制器 | `string \| number \| AbstractControl` | - | - | 配合 `@idux/cdk/forms` 使用, 参考 [Form](/components/form/zh) |
| `control` | 控件控制器 | `string \| number \| (string \| number)[] \| AbstractControl` | - | - | 配合 `@idux/cdk/forms` 使用, 参考 [Form](/components/form/zh) |
| `v-model:checked` | 是否选中 | `boolean` | - | - | 使用 `control` 时,此配置无效 |
| `autofocus` | 是否以自动聚焦 | `boolean` | `false` | - | - |
| `buttoned` | 是否以按钮显示 | `boolean` | `false` | - | - |
Expand Down Expand Up @@ -34,7 +34,7 @@

| 名称 | 说明 | 类型 | 默认值 | 全局配置 | 备注 |
| --- | --- | --- | --- | --- | --- |
| `control` | 控件控制器 | `string \| number \| AbstractControl` | - | - | 配合 `@idux/cdk/forms` 使用, 参考 [Form](/components/form/zh) |
| `control` | 控件控制器 | `string \| number \| (string \| number)[] \| AbstractControl` | - | - | 配合 `@idux/cdk/forms` 使用, 参考 [Form](/components/form/zh) |
| `v-model:value` | 当前选中的值 | `any` | - | - | 使用 `control` 时,此配置无效 |
| `buttoned` | 设置单选框组内 `IxRadio``buttoned` | `boolean` | - | - | - |
| `dataSource` | 以配置形式设置子元素 | `RadioData[]`| - | 优先级高于 `default` 插槽 | |
Expand Down
10 changes: 8 additions & 2 deletions packages/components/radio/src/types.ts
Expand Up @@ -14,7 +14,10 @@ import type { SpaceProps } from '@idux/components/space'
import type { DefineComponent, HTMLAttributes, LabelHTMLAttributes, PropType } from 'vue'

export const radioProps = {
control: { type: [String, Number, Object] as PropType<string | number | AbstractControl>, default: undefined },
control: {
type: [String, Number, Object, Array] as PropType<string | number | (string | number)[] | AbstractControl>,
default: undefined,
},
checked: { type: Boolean, default: undefined },

autofocus: { type: Boolean, default: false },
Expand Down Expand Up @@ -46,7 +49,10 @@ export type RadioComponent = DefineComponent<
export type RadioInstance = InstanceType<DefineComponent<RadioProps, RadioBindings>>

export const radioGroupProps = {
control: { type: [String, Number, Object] as PropType<string | number | AbstractControl>, default: undefined },
control: {
type: [String, Number, Object, Array] as PropType<string | number | (string | number)[] | AbstractControl>,
default: undefined,
},
value: { type: null, default: undefined },

buttoned: { type: Boolean, default: false },
Expand Down
2 changes: 1 addition & 1 deletion packages/components/rate/docs/Api.zh.md
Expand Up @@ -6,7 +6,7 @@
| 名称 | 说明 | 类型 | 默认值 | 全局配置 | 备注 |
| --- | --- | --- | --- | --- | --- |
| `v-model:value` | 高亮的数目(分数) | `number` | - | - | 使用 `control` 时,此配置无效 |
| `control` | 控件控制器 | `string \| number \| AbstractControl` | - | - | 配合 `@idux/cdk/forms` 使用, 参考 [Form](/components/form/zh) |
| `control` | 控件控制器 | `string \| number \| (string \| number)[] \| AbstractControl` | - | - | 配合 `@idux/cdk/forms` 使用, 参考 [Form](/components/form/zh) |
| `allowHalf` | 支持半分(选) | `boolean` | `false` || - |
| `clearable` | 二次点击元素后清除选择 | `boolean` | `false` ||-|
| `count` | 图标数目 | `number` | `5` || - |
Expand Down
5 changes: 4 additions & 1 deletion packages/components/rate/src/types.ts
Expand Up @@ -11,7 +11,10 @@ import type { FormSize } from '@idux/components/form'
import type { DefineComponent, HTMLAttributes, PropType } from 'vue'

export const rateProps = {
control: { type: [String, Number, Object] as PropType<string | number | AbstractControl>, default: undefined },
control: {
type: [String, Number, Object, Array] as PropType<string | number | (string | number)[] | AbstractControl>,
default: undefined,
},
value: [Number, String] as PropType<number | string>,

allowHalf: {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/select/docs/Api.zh.md
Expand Up @@ -5,7 +5,7 @@

| 名称 | 说明 | 类型 | 默认值 | 全局配置 | 备注 |
| --- | --- | --- | --- | --- | --- |
| `control` | 控件控制器 | `string \| number \| AbstractControl` | - | - | 配合 `@idux/cdk/forms` 使用, 参考 [Form](/components/form/zh) |
| `control` | 控件控制器 | `string \| number \| (string \| number)[] \| AbstractControl` | - | - | 配合 `@idux/cdk/forms` 使用, 参考 [Form](/components/form/zh) |
| `v-model:value` | 当前选中的 option 的值 | `any \| any[]` | - | - |`multiple=true` 时,`value` 为数组,使用 `control` 时,此配置无效 |
| `v-model:open` | 下拉菜单是否展开 | `boolean` | - | - | - |
| `allowInput` | 允许输入模式 | `boolean` | `false` | - | - |
Expand Down
5 changes: 4 additions & 1 deletion packages/components/select/src/types.ts
Expand Up @@ -45,7 +45,10 @@ export const selectPanelProps = {
} as const

export const selectProps = {
control: { type: [String, Number, Object] as PropType<string | number | AbstractControl>, default: undefined },
control: {
type: [String, Number, Object, Array] as PropType<string | number | (string | number)[] | AbstractControl>,
default: undefined,
},
value: { type: [String, Number, Symbol, Array] as PropType<MaybeArray<VKey>>, default: undefined },
open: { type: Boolean, default: undefined },

Expand Down
2 changes: 1 addition & 1 deletion packages/components/slider/docs/Api.zh.md
Expand Up @@ -6,7 +6,7 @@
| 名称 | 说明 | 类型 | 默认值 | 全局配置 | 备注 |
| --- | --- | --- | --- | --- | --- |
| `v-model:value` | 绑定值 | `number \| [number, number]` | `0 \| [0, 0]` | - | 使用 `control` 时,此配置无效 |
| `control` | 控件控制器 | `string \| number \| AbstractControl` | - | - | 配合 `@idux/cdk/forms` 使用, 参考 [Form](/components/form/zh) |
| `control` | 控件控制器 | `string \| number \| (string \| number)[] \| AbstractControl` | - | - | 配合 `@idux/cdk/forms` 使用, 参考 [Form](/components/form/zh) |
| `disabled` | 设置禁用状态 | `boolean` | `false` | - | 使用 `control` 时,此配置无效 |
| `dots` | 显示间断点 | `boolean` | `false` | - | `marks` 间断点会始终显示 |
|`marks`|刻度标记,`key` 的类型必须为 `number` 且取值在闭区间 `[min, max]` 内,每个标签可以单独设置样式|`object`|-|-|`{ number: string \| VNode } or { number: { style: object, label: string \| VNode } } or { number: () => VNode }` |
Expand Down
5 changes: 4 additions & 1 deletion packages/components/slider/src/types.ts
Expand Up @@ -13,7 +13,10 @@ import type { CSSProperties, DefineComponent, HTMLAttributes, PropType, VNode }

// slider
export const sliderProps = {
control: { type: [String, Number, Object] as PropType<string | number | AbstractControl>, default: undefined },
control: {
type: [String, Number, Object, Array] as PropType<string | number | (string | number)[] | AbstractControl>,
default: undefined,
},
value: { type: [Number, Array] as PropType<number | number[]>, default: undefined },

disabled: { type: Boolean, default: false },
Expand Down
2 changes: 1 addition & 1 deletion packages/components/switch/docs/Api.zh.md
Expand Up @@ -5,7 +5,7 @@

| 名称 | 说明 | 类型 | 默认值 | 全局配置 | 备注 |
| --- | --- | --- | --- | --- | --- |
| `control` | 控件控制器 | `string \| number \| AbstractControl` | - | - | 配合 `@idux/cdk/forms` 使用, 参考 [Form](/components/form/zh) |
| `control` | 控件控制器 | `string \| number \| (string \| number)[] \| AbstractControl` | - | - | 配合 `@idux/cdk/forms` 使用, 参考 [Form](/components/form/zh) |
| `v-model:checked` | 是否开启 | `boolean` | `false` | - | 使用 `control` 时,此配置无效 |
| `autofocus` | 自动获取焦点 | `boolean` | `false` | - | - |
| `disabled` | 是否禁止操作 | `boolean` | `false`| - | 使用 `control` 时,此配置无效 |
Expand Down
6 changes: 5 additions & 1 deletion packages/components/switch/src/types.ts
Expand Up @@ -10,8 +10,12 @@ import type { ExtractInnerPropTypes, ExtractPublicPropTypes, MaybeArray } from '
import type { DefineComponent, HTMLAttributes, PropType } from 'vue'

export const switchProps = {
control: {
type: [String, Number, Object, Array] as PropType<string | number | (string | number)[] | AbstractControl>,
default: undefined,
},
checked: { type: Boolean, default: undefined },
control: [String, Number, Object] as PropType<string | number | AbstractControl>,

autofocus: { type: Boolean, default: false },
disabled: { type: Boolean, default: false },
labels: { type: Array as PropType<string[]>, default: () => [] },
Expand Down

0 comments on commit ace2a1e

Please sign in to comment.