diff --git a/packages/goods-action-big-btn/index.js b/packages/goods-action-big-btn/index.js deleted file mode 100644 index 3cdc66538..000000000 --- a/packages/goods-action-big-btn/index.js +++ /dev/null @@ -1,38 +0,0 @@ -import { use } from '../utils'; -import Button from '../button'; -import { emit, inherit } from '../utils/functional'; -import { functionalRoute, routeProps } from '../mixins/router'; - -const [sfc, bem] = use('goods-action-big-btn'); - -function GoodsActionBigBtn(h, props, slots, ctx) { - const onClick = event => { - emit(ctx, 'click', event); - functionalRoute(ctx); - }; - - return ( - - ); -} - -GoodsActionBigBtn.props = { - ...routeProps, - text: String, - primary: Boolean, - loading: Boolean, - disabled: Boolean -}; - -export default sfc(GoodsActionBigBtn); diff --git a/packages/goods-action-big-btn/index.tsx b/packages/goods-action-big-btn/index.tsx new file mode 100644 index 000000000..b54838ad6 --- /dev/null +++ b/packages/goods-action-big-btn/index.tsx @@ -0,0 +1,54 @@ +import { use } from '../utils'; +import Button, { ButtonEvents } from '../button'; +import { emit, inherit } from '../utils/functional'; +import { functionalRoute, routeProps, RouteProps } from '../mixins/router'; + +// Types +import { CreateElement, RenderContext } from 'vue/types'; +import { DefaultSlots } from '../utils/use/sfc'; + +export type GoodsActionBigBtnProps = RouteProps & { + text?: string; + primary?: boolean; + loading?: boolean; + disabled?: boolean; +}; + +const [sfc, bem] = use('goods-action-big-btn'); + +function GoodsActionBigBtn( + h: CreateElement, + props: GoodsActionBigBtnProps, + slots: DefaultSlots, + ctx: RenderContext +) { + const onClick = (event: Event) => { + emit(ctx, 'click', event); + functionalRoute(ctx); + }; + + return ( + + ); +} + +GoodsActionBigBtn.props = { + ...routeProps, + text: String, + primary: Boolean, + loading: Boolean, + disabled: Boolean +}; + +export default sfc(GoodsActionBigBtn); diff --git a/packages/goods-action-mini-btn/index.js b/packages/goods-action-mini-btn/index.js deleted file mode 100644 index 4be77a8d4..000000000 --- a/packages/goods-action-mini-btn/index.js +++ /dev/null @@ -1,38 +0,0 @@ -import { use } from '../utils'; -import Icon from '../icon'; -import { emit, inherit } from '../utils/functional'; -import { functionalRoute, routeProps } from '../mixins/router'; - -const [sfc, bem] = use('goods-action-mini-btn'); - -function GoodsActionMiniBtn(h, props, slots, ctx) { - const onClick = event => { - emit(ctx, 'click', event); - functionalRoute(ctx); - }; - - return ( -
- - {slots.default ? slots.default() : props.text} -
- ); -} - -GoodsActionMiniBtn.props = { - ...routeProps, - text: String, - icon: String, - info: [String, Number], - iconClass: String -}; - -export default sfc(GoodsActionMiniBtn); diff --git a/packages/goods-action-mini-btn/index.tsx b/packages/goods-action-mini-btn/index.tsx new file mode 100644 index 000000000..f122e7db4 --- /dev/null +++ b/packages/goods-action-mini-btn/index.tsx @@ -0,0 +1,50 @@ +import { use } from '../utils'; +import Icon, { IconEvents } from '../icon'; +import { emit, inherit } from '../utils/functional'; +import { functionalRoute, routeProps, RouteProps } from '../mixins/router'; + +// Types +import { CreateElement, RenderContext } from 'vue/types'; +import { DefaultSlots } from '../utils/use/sfc'; + +export type GoodsActionMiniBtnProps = RouteProps & { + icon: string; + text?: string; + info?: string | number; + iconClass?: any; +}; + +const [sfc, bem] = use('goods-action-mini-btn'); + +function GoodsActionMiniBtn( + h: CreateElement, + props: GoodsActionMiniBtnProps, + slots: DefaultSlots, + ctx: RenderContext +) { + const onClick = (event: Event) => { + emit(ctx, 'click', event); + functionalRoute(ctx); + }; + + return ( +
+ + {slots.default ? slots.default() : props.text} +
+ ); +} + +GoodsActionMiniBtn.props = { + ...routeProps, + text: String, + icon: String, + info: [String, Number], + iconClass: null as any +}; + +export default sfc(GoodsActionMiniBtn); diff --git a/packages/goods-action/en-US.md b/packages/goods-action/en-US.md index c1e91409a..b8549ad72 100644 --- a/packages/goods-action/en-US.md +++ b/packages/goods-action/en-US.md @@ -89,13 +89,12 @@ Use `info` prop to show messages in upper right corner of icon |------|------|------|------| | text | Button text | `String` | - | | icon | Icon | `String` | - | -| icon-class | Icon class name | `String` | `''` | +| icon-class | Icon class name | `any` | `''` | | info | Info message | `String | Number` | - | | url | Link | `String` | - | | to | Target route of the link, same as to of `vue-router` | `String | Object` | - | | replace | If true, the navigation will not leave a history record | `String` | `false` | - #### GoodsActionBigBtn | Attribute | Description | Type | Default | diff --git a/packages/goods-action/index.js b/packages/goods-action/index.tsx similarity index 52% rename from packages/goods-action/index.js rename to packages/goods-action/index.tsx index d6c0649e9..3e09c01d2 100644 --- a/packages/goods-action/index.js +++ b/packages/goods-action/index.tsx @@ -1,9 +1,18 @@ import { use } from '../utils'; import { inherit } from '../utils/functional'; +// Types +import { CreateElement, RenderContext } from 'vue/types'; +import { DefaultProps, DefaultSlots } from '../utils/use/sfc'; + const [sfc, bem] = use('goods-action'); -function GoodsAction(h, props, slots, ctx) { +function GoodsAction( + h: CreateElement, + props: DefaultProps, + slots: DefaultSlots, + ctx: RenderContext +) { return (
{slots.default && slots.default()} diff --git a/packages/goods-action/zh-CN.md b/packages/goods-action/zh-CN.md index be92b8f25..2c22a1df1 100644 --- a/packages/goods-action/zh-CN.md +++ b/packages/goods-action/zh-CN.md @@ -88,7 +88,7 @@ export default { |------|------|------|------|------| | text | 按钮文字 | `String` | - | - | | icon | 图标 | `String` | - | - | -| icon-class | 图标额外类名 | `String` | - | - | +| icon-class | 图标额外类名 | `any` | - | - | | info | 图标右上角提示信息 | `String | Number` | - | - | | url | 跳转链接 | `String` | - | - | | to | 路由跳转对象,同 `vue-router` 的 to | `String | Object` | - | - |