From ad27b885c95edf14c42ef77a255966e3695a1570 Mon Sep 17 00:00:00 2001 From: neverland Date: Mon, 18 Feb 2019 20:10:56 +0800 Subject: [PATCH] [improvement] Panel: tsx (#2782) --- packages/cell/index.tsx | 2 +- packages/panel/{index.js => index.tsx} | 25 +++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) rename packages/panel/{index.js => index.tsx} (64%) diff --git a/packages/cell/index.tsx b/packages/cell/index.tsx index 2b43d2ce5..40c1ffaf0 100644 --- a/packages/cell/index.tsx +++ b/packages/cell/index.tsx @@ -23,7 +23,7 @@ export type CellSlots = DefaultSlots & { }; export type CellEvents = { - onClick(event: Event): void; + onClick?(event: Event): void; }; const [sfc, bem] = use('cell'); diff --git a/packages/panel/index.js b/packages/panel/index.tsx similarity index 64% rename from packages/panel/index.js rename to packages/panel/index.tsx index 70cb93829..952a6168b 100644 --- a/packages/panel/index.js +++ b/packages/panel/index.tsx @@ -3,9 +3,30 @@ import Cell from '../cell'; import CellGroup from '../cell-group'; import { inherit } from '../utils/functional'; +// Types +import { CreateElement, RenderContext } from 'vue/types'; +import { ScopedSlot, DefaultSlots } from '../utils/use/sfc'; + +export type PanelProps = { + icon?: string; + desc?: string; + title?: string; + status?: string; +}; + +export type PanelSlots = DefaultSlots & { + header?: ScopedSlot; + footer?: ScopedSlot; +}; + const [sfc, bem] = use('panel'); -function Panel(h, props, slots, ctx) { +function Panel( + h: CreateElement, + props: PanelProps, + slots: PanelSlots, + ctx: RenderContext +) { const Content = () => [ slots.header ? ( slots.header() @@ -41,4 +62,4 @@ Panel.props = { status: String }; -export default sfc(Panel); +export default sfc(Panel);