Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@

import { TdSwitchProps } from './type';

export const switchDefaultProps: TdSwitchProps = { disabled: undefined, label: [], loading: false, size: 'medium' };
export const switchDefaultProps: TdSwitchProps = {
disabled: undefined,
label: [],
loading: false,
shape: 'circle',
size: 'medium',
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ customValue | Array | - | Typescript:`Array<SwitchValue>` | N
disabled | Boolean | undefined | \- | N
label | TNode | [] | Typescript:`Array<string \| TNode> \| TNode<{ value: SwitchValue }>`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
loading | Boolean | false | \- | N
shape | String | circle | Switch shape. `label` is not rendered when shape is `line`. Options: circle/round/line | N
size | String | medium | options: small/medium/large | N
value | String / Number / Boolean | - | Typescript:`T` `type SwitchValue = string \| number \| boolean`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/switch/type.ts) | N
defaultValue | String / Number / Boolean | - | uncontrolled property。Typescript:`T` `type SwitchValue = string \| number \| boolean`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/switch/type.ts) | N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ customValue | Array | - | 用于自定义开关的值,[打开时的值,关
disabled | Boolean | undefined | 是否禁用组件。优先级:Switch.disabled > Form.disabled | N
label | TNode | [] | 开关内容,[开启时内容,关闭时内容]。示例:['开', '关'] 或 (value) => value ? '开' : '关'。TS 类型:`Array<string \| TNode> \| TNode<{ value: SwitchValue }>`。[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
loading | Boolean | false | 是否处于加载中状态 | N
shape | String | circle | 开关形状。`line` 形态不展示开关内容 `label`。可选项:circle/round/line | N
size | String | medium | 开关尺寸。可选项:small/medium/large | N
value | String / Number / Boolean | - | 开关值。TS 类型:`T` `type SwitchValue = string \| number \| boolean`。[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/switch/type.ts) | N
defaultValue | String / Number / Boolean | - | 开关值。非受控属性。TS 类型:`T` `type SwitchValue = string \| number \| boolean`。[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/switch/type.ts) | N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ export interface TdSwitchProps<T = SwitchValue> {
* @default false
*/
loading?: boolean;
/**
* 开关形状。`line` 形态不展示开关内容 `label`
* @default circle
*/
shape?: 'circle' | 'round' | 'line';
/**
* 开关尺寸
* @default medium
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ customValue | Array | - | Typescript:`Array<SwitchValue>` | N
disabled | Boolean | - | \- | N
label | Array / Slot / Function | [] | Typescript:`Array<string | TNode> | TNode<{ value: SwitchValue }>`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts) | N
loading | Boolean | false | \- | N
shape | String | circle | Switch shape. `label` is not rendered when shape is `line`. Options: circle/round/line | N
size | String | medium | options:small/medium/large | N
value | String / Number / Boolean | - | `v-model` and `v-model:value` is supported。Typescript:`SwitchValue` `type SwitchValue = string | number | boolean`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/tree/develop/src/switch/type.ts) | N
defaultValue | String / Number / Boolean | - | uncontrolled property。Typescript:`SwitchValue` `type SwitchValue = string | number | boolean`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/tree/develop/src/switch/type.ts) | N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ customValue | Array | - | 用于自定义开关的值,[打开时的值,关
disabled | Boolean | - | 是否禁用组件 | N
label | Array / Slot / Function | [] | 开关内容,[开启时内容,关闭时内容]。示例:['开', '关'] 或 (value) => value ? '开' : '关'。TS 类型:`Array<string | TNode> | TNode<{ value: SwitchValue }>`。[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts) | N
loading | Boolean | false | 是否处于加载中状态 | N
shape | String | circle | 开关形状。`line` 形态不展示开关内容 `label`。可选项:circle/round/line | N
size | String | medium | 开关尺寸。可选项:small/medium/large | N
value | String / Number / Boolean | - | 开关值。支持语法糖 `v-model` 或 `v-model:value`。TS 类型:`SwitchValue` `type SwitchValue = string | number | boolean`。[详细类型定义](https://github.com/Tencent/tdesign-vue-next/tree/develop/src/switch/type.ts) | N
defaultValue | String / Number / Boolean | - | 开关值。非受控属性。TS 类型:`SwitchValue` `type SwitchValue = string | number | boolean`。[详细类型定义](https://github.com/Tencent/tdesign-vue-next/tree/develop/src/switch/type.ts) | N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ export default {
},
/** 是否处于加载中状态 */
loading: Boolean,
/** 开关形状。`line` 形态不展示开关内容 `label` */
shape: {
type: String as PropType<TdSwitchProps['shape']>,
default: 'circle' as TdSwitchProps['shape'],
validator(val: TdSwitchProps['shape']): boolean {
if (!val) return true;
return ['circle', 'round', 'line'].includes(val);
},
},
/** 开关尺寸 */
size: {
type: String as PropType<TdSwitchProps['size']>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ customValue | Array | - | Typescript:`Array<SwitchValue>` | N
disabled | Boolean | undefined | \- | N
label | Array / Slot / Function | [] | Typescript:`Array<string \| TNode> \| TNode<{ value: SwitchValue }>`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
loading | Boolean | false | \- | N
shape | String | circle | Switch shape. `label` is not rendered when shape is `line`. Options: circle/round/line | N
size | String | medium | options: small/medium/large | N
value | String / Number / Boolean | - | `v-model` and `v-model:value` is supported。Typescript:`T` `type SwitchValue = string \| number \| boolean`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/switch/type.ts) | N
defaultValue | String / Number / Boolean | - | uncontrolled property。Typescript:`T` `type SwitchValue = string \| number \| boolean`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/switch/type.ts) | N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ customValue | Array | - | 用于自定义开关的值,[打开时的值,关
disabled | Boolean | undefined | 是否禁用组件。优先级:Switch.disabled > Form.disabled | N
label | Array / Slot / Function | [] | 开关内容,[开启时内容,关闭时内容]。示例:['开', '关'] 或 (value) => value ? '开' : '关'。TS 类型:`Array<string \| TNode> \| TNode<{ value: SwitchValue }>`。[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
loading | Boolean | false | 是否处于加载中状态 | N
shape | String | circle | 开关形状。`line` 形态不展示开关内容 `label`。可选项:circle/round/line | N
size | String | medium | 开关尺寸。可选项:small/medium/large | N
value | String / Number / Boolean | - | 开关值。支持语法糖 `v-model` 或 `v-model:value`。TS 类型:`T` `type SwitchValue = string \| number \| boolean`。[详细类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/switch/type.ts) | N
defaultValue | String / Number / Boolean | - | 开关值。非受控属性。TS 类型:`T` `type SwitchValue = string \| number \| boolean`。[详细类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/switch/type.ts) | N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ export interface TdSwitchProps<T = SwitchValue> {
* @default false
*/
loading?: boolean;
/**
* 开关形状。`line` 形态不展示开关内容 `label`
* @default circle
*/
shape?: 'circle' | 'round' | 'line';
/**
* 开关尺寸
* @default medium
Expand Down
9 changes: 9 additions & 0 deletions packages/products/tdesign-vue/src/switch/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ export default {
},
/** 是否处于加载中状态 */
loading: Boolean,
/** 开关形状。`line` 形态不展示开关内容 `label` */
shape: {
type: String as PropType<TdSwitchProps['shape']>,
default: 'circle' as TdSwitchProps['shape'],
validator(val: TdSwitchProps['shape']): boolean {
if (!val) return true;
return ['circle', 'round', 'line'].includes(val);
},
},
/** 开关尺寸 */
size: {
type: String as PropType<TdSwitchProps['size']>,
Expand Down
1 change: 1 addition & 0 deletions packages/products/tdesign-vue/src/switch/switch.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ customValue | Array | - | Typescript:`Array<SwitchValue>` | N
disabled | Boolean | undefined | \- | N
label | Array / Slot / Function | [] | Typescript:`Array<string \| TNode> \| TNode<{ value: SwitchValue }>`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N
loading | Boolean | false | \- | N
shape | String | circle | Switch shape. `label` is not rendered when shape is `line`. Options: circle/round/line | N
size | String | medium | options: small/medium/large | N
value | String / Number / Boolean | - | `v-model` is supported。Typescript:`T` `type SwitchValue = string \| number \| boolean`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/switch/type.ts) | N
defaultValue | String / Number / Boolean | - | uncontrolled property。Typescript:`T` `type SwitchValue = string \| number \| boolean`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/switch/type.ts) | N
Expand Down
1 change: 1 addition & 0 deletions packages/products/tdesign-vue/src/switch/switch.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ customValue | Array | - | 用于自定义开关的值,[打开时的值,关
disabled | Boolean | undefined | 是否禁用组件。优先级:Switch.disabled > Form.disabled | N
label | Array / Slot / Function | [] | 开关内容,[开启时内容,关闭时内容]。示例:['开', '关'] 或 (value) => value ? '开' : '关'。TS 类型:`Array<string \| TNode> \| TNode<{ value: SwitchValue }>`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N
loading | Boolean | false | 是否处于加载中状态 | N
shape | String | circle | 开关形状。`line` 形态不展示开关内容 `label`。可选项:circle/round/line | N
size | String | medium | 开关尺寸。可选项:small/medium/large | N
value | String / Number / Boolean | - | 开关值。支持语法糖 `v-model`。TS 类型:`T` `type SwitchValue = string \| number \| boolean`。[详细类型定义](https://github.com/Tencent/tdesign-vue/tree/develop/src/switch/type.ts) | N
defaultValue | String / Number / Boolean | - | 开关值。非受控属性。TS 类型:`T` `type SwitchValue = string \| number \| boolean`。[详细类型定义](https://github.com/Tencent/tdesign-vue/tree/develop/src/switch/type.ts) | N
Expand Down
5 changes: 5 additions & 0 deletions packages/products/tdesign-vue/src/switch/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ export interface TdSwitchProps<T = SwitchValue> {
* @default false
*/
loading?: boolean;
/**
* 开关形状。`line` 形态不展示开关内容 `label`
* @default circle
*/
shape?: 'circle' | 'round' | 'line';
/**
* 开关尺寸
* @default medium
Expand Down