Skip to content

Commit

Permalink
feat(radio): enable readonly (#2292)
Browse files Browse the repository at this point in the history
  • Loading branch information
betavs authored Aug 17, 2023
1 parent 2a12dc1 commit 295dfd3
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/radio-group/radio-group.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
content="{{item.content || ''}}"
allow-uncheck="{{item.allowUncheck || false}}"
content-disabled="{{item.contentDisabled || false}}"
readonly="{{item.readonly || false}}"
disabled="{{item.disabled || false}}"
icon="{{item.icon || icon}}"
placement="{{item.placement || placement}}"
Expand Down
1 change: 1 addition & 0 deletions src/radio-group/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export type RadioOption = string | number | RadioOptionObj;
export interface RadioOptionObj {
label?: string;
value?: string | number;
readonly?: boolean;
disabled?: boolean;
allowUncheck?: boolean;
}
1 change: 1 addition & 0 deletions src/radio/README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ name | type | default | description | required
-- | -- | -- | -- | --
placement | String | left | options:left/right | N
borderless | Boolean | false | \- | N
readonly | Boolean | false | \- | N
disabled | Boolean | undefined | \- | N
icon | String / Array | 'circle' | Typescript:`'circle' | 'line' | Array<string>` | N
keys | Object | - | Typescript:`KeysType` | N
Expand Down
1 change: 1 addition & 0 deletions src/radio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ checked | Boolean | false | 是否选中 | N
default-checked | Boolean | undefined | 是否选中。非受控属性 | N
content | String / Slot | - | 单选内容 | N
content-disabled | Boolean | false | 是否禁用组件内容(content)触发选中 | N
readonly | Boolean | false | 只读状态 | N
disabled | Boolean | undefined | 是否为禁用态 | N
icon | String / Array / Slot | 'circle' | 自定义选中图标和非选中图标。使用 Array 时表示:`[选中态图标,非选中态图标]`。使用 String 时,值为 circle 表示填充型图标、值为 line 表示描边型图标、值为 dot 表示圆点图标,值为 slot 时使用插槽。TS 类型:`'circle' \| 'line' \| 'dot' \| Array<string>` | N
label | String / Slot | - | 主文案 | N
Expand Down
5 changes: 5 additions & 0 deletions src/radio/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ const props: TdRadioProps = {
type: Boolean,
value: false,
},
/** 只读状态 */
readonly: {
type: Boolean,
value: false,
},
/** 是否为禁用态 */
disabled: {
type: Boolean,
Expand Down
2 changes: 1 addition & 1 deletion src/radio/radio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default class Radio extends SuperComponent {

methods = {
handleTap(e) {
if (this.data.disabled) return;
if (this.data.disabled || this.data.readonly) return;

const { target } = e.currentTarget.dataset;

Expand Down
8 changes: 8 additions & 0 deletions src/radio/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ export interface TdRadioProps<T = RadioValue> {
type: StringConstructor;
value?: string;
};
/**
* 只读状态
* @default false
*/
readonly?: {
type: BooleanConstructor;
value?: boolean;
};
/**
* 是否为禁用态
*/
Expand Down

0 comments on commit 295dfd3

Please sign in to comment.