fix(button): [button] add ts declaration for button , and remove hook-updated … (#1853)

* fix(button): add ts declaration for button , and remove hook-updated  event

* fix(button): fix

* Update index.ts
This commit is contained in:
申君健 2024-08-08 17:00:56 +08:00 committed by GitHub
parent 752a13e231
commit dc313563f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 36 additions and 11 deletions

View File

@ -191,7 +191,7 @@ export default {
name: 'type',
typeAnchorName: 'IButtonType',
type: 'IButtonType',
defaultValue: '',
defaultValue: 'default',
desc: {
'zh-CN': '展示按钮不同的状态设置为text则展示为文本按钮',
'en-US': 'Display different states of buttons, set to text to display as text buttons'
@ -239,7 +239,7 @@ export default {
{
name: 'IButtonType',
type: 'interface',
code: `type IButtonType = 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'text'`
code: `type IButtonType = 'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'text'`
}
]
}

View File

@ -544,7 +544,7 @@ interface IItemData {
name: 'IButtonType',
type: 'type',
code: `
type IButtonType = 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'text'
type IButtonType = 'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'text'
`
},
{

View File

@ -14,31 +14,39 @@ import template from 'virtual-template?pc|mobile|mobile-first'
export const buttonProps = {
...$props,
/** 展示按钮不同的状态设置为text则展示为文本按钮。可取值为'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'text' */
type: {
type: String,
default: 'default'
},
/** 设置原生的tabindex属性 */
tabindex: { type: String, default: '0' },
/** 按钮左侧展示的图标接收为Icon组件 */
icon: {
type: [Object, String],
default: ''
},
/** 按钮显示的文本 */
text: {
type: String,
default: ''
},
/** 设置按钮禁用时间,防止重复提交,单位毫秒 */
resetTime: {
type: Number,
default: 1000
},
/** 对应按钮原生 type 属性 */
nativeType: {
type: String,
default: 'button'
},
/** 当配置href后点击按钮则更新 location.href 进行页面跳转 */
href: {
type: String,
default: ''
},
/** 定义按钮尺寸 */
size: {
type: String,
default: '',
@ -46,21 +54,34 @@ export const buttonProps = {
return ['large', 'medium', 'small', 'mini', ''].includes(val)
}
},
/** 是否圆角按钮 */
round: Boolean,
/** 是否朴素按钮 */
plain: Boolean,
/** 是否圆形按钮 */
circle: Boolean,
/** 是否加载中状态 */
loading: Boolean,
/** 是否被禁用按钮 */
disabled: Boolean,
/** 是否默认聚焦 */
autofocus: Boolean,
/** 自定义类名, 仅 mobile-first 模板时有效 */
customClass: {
type: String,
default: ''
},
/** 设置通栏按钮,宽度充满水平方向, 仅 mobile-first 模板时有效 */
banner: {
type: Boolean,
default: false
},
ghost: Boolean
/** 是否幽灵按钮 */
ghost: Boolean,
/** 点击事件 */
onClick: {
type: Function as PropType<(ev: MouseEvent) => void>
}
}
export default defineComponent({
@ -70,7 +91,12 @@ export default defineComponent({
default: ''
}
},
props: buttonProps,
slots: Object as SlotsType<{
/** 默认插槽 */
default: {}
}>,
setup(props, context) {
return $setup({ props, context, template })
}

View File

@ -44,7 +44,7 @@ import { iconLoading } from '@opentiny/vue-icon'
import { classes } from './token'
export default defineComponent({
emits: ['click', 'hook-updated'],
emits: ['click'],
props: [
...props,
'type',

View File

@ -49,7 +49,7 @@ import { props, setup, defineComponent } from '@opentiny/vue-common'
import '@opentiny/vue-theme-mobile/button/index.less'
export default defineComponent({
emits: ['hook-updated', 'click'],
emits: ['click'],
props: [...props, 'type', 'text', 'size', 'icon', 'resetTime', 'nativeType', 'loading', 'disabled', 'customClass'],
components: {},
setup(props, context) {

View File

@ -49,7 +49,7 @@ import type { IButtonApi } from '@opentiny/vue-renderless/types/button.type'
import '@opentiny/vue-theme/button/index.less'
export default defineComponent({
emits: ['click', 'hook-updated'],
emits: ['click'],
props: [
...props,
'type',

View File

@ -14,7 +14,7 @@
<div class="tiny-fall-menu__wrap">
<div class="tiny-fall-menu__nav">
<div class="tiny-fall-menu__subnav">
<div v-show="state.pager != 1" class="icon-slot-left" @click="arrowClick(-1)">
<div v-show="state.pager !== 1" class="icon-slot-left" @click="arrowClick(-1)">
<slot name="left">
<icon-chevron-left class="tiny-svg-size" />
</slot>
@ -71,7 +71,7 @@
</h3>
<p class="mcate-item-bd">
<slot name="level3" :slot-scope="level2.children">
<a v-for="(level3, index) in level2.children" :href="level3.url" :key="index">{{
<a v-for="(level3, index3) in level2.children" :href="level3.url" :key="index3">{{
level3.title
}}</a>
</slot>
@ -95,7 +95,6 @@ import Col from '@opentiny/vue-col'
import { iconChevronLeft, iconChevronRight } from '@opentiny/vue-icon'
export default defineComponent({
emits: ['hook-updated'],
props: [...props, 'data'],
components: {
TinyRow: Row,

View File

@ -262,7 +262,7 @@ export default defineComponent({
parentTree: this
}
},
emits: ['update:modelValue', 'hook-updated', 'node-expand', 'radio-change', 'tree-node-expand', 'closeMenu'],
emits: ['update:modelValue', 'node-expand', 'radio-change', 'tree-node-expand', 'closeMenu'],
props: {
node: {
default() {