Skip to content

Commit

Permalink
feat(check-tag): enable props closable
Browse files Browse the repository at this point in the history
  • Loading branch information
betavs committed Sep 20, 2023
1 parent ec18136 commit 17ef47a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/check-tag/check-tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,10 @@ export default class CheckTag extends SuperComponent {
this._trigger('click');
this._trigger('change', { checked: !checked });
},

onClose(e: WechatMiniprogram.BaseEvent) {
if (this.data.disabled) return;
this._trigger('close', e);
},
};
}
9 changes: 9 additions & 0 deletions src/check-tag/check-tag.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,13 @@
<block wx:if="{{_.isArray(content) && content.length == 2}}">{{checked ? content[0] : content[1]}}</block>
<block wx:else>{{content}}</block>
</view>
<t-icon
wx:if="{{ closable }}"
class="{{classPrefix}}__icon-close"
t-class="{{prefix}}-icon"
catch:tap="onClose"
name="close"
aria-role="button"
aria-label="关闭"
/>
</view>
2 changes: 1 addition & 1 deletion src/check-tag/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const props: TdCheckTagProps = {
type: null,
value: undefined,
},
/** 已废弃。标签是否可关闭 */
/** 标签是否可关闭 */
closable: {
type: Boolean,
value: false,
Expand Down
3 changes: 2 additions & 1 deletion src/tag/README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ name | type | default | description | required
-- | -- | -- | -- | --
checked | Boolean | undefined | \- | N
default-checked | Boolean | undefined | uncontrolled property | N
closable | Boolean | false | `deprecated` | N
closable | Boolean | false | \- | N
content | String / Number / Array / Slot | - | Typescript:`string \| number \| string[]` | N
disabled | Boolean | false | \- | N
external-classes | Array | - | `['t-class']` | N
Expand All @@ -43,6 +43,7 @@ name | params | description
-- | -- | --
change | `(checked: boolean)` | \-
click | - | \-
close | - | \-


### CSS Variables
Expand Down
3 changes: 2 additions & 1 deletion src/tag/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ t-class | 根节点样式类
-- | -- | -- | -- | --
checked | Boolean | undefined | 标签选中的状态,默认风格(theme=default)才有选中态 | N
default-checked | Boolean | undefined | 标签选中的状态,默认风格(theme=default)才有选中态。非受控属性 | N
closable | Boolean | false | 已废弃。标签是否可关闭 | N
closable | Boolean | false | 标签是否可关闭 | N
content | String / Number / Array / Slot | - | 组件子元素;传入数组时:[选中内容,非选中内容]。TS 类型:`string \| number \| string[]` | N
disabled | Boolean | false | 标签禁用态,失效标签不能触发事件。默认风格(theme=default)才有禁用态 | N
icon | String / Object / Slot | - | 标签图标 | N
Expand All @@ -88,6 +88,7 @@ variant | String | dark | `0.26.0`。标签风格变体。可选项:dark/light
-- | -- | --
change | `(checked: boolean)` | 状态切换时触发
click | - | 点击标签时触发
close | - | 如果关闭按钮存在,点击关闭按钮时触发

### CheckTag 外部样式类
类名 | 说明
Expand Down

0 comments on commit 17ef47a

Please sign in to comment.