From dba226445cbbf6b24391a53405b028e3c28c2f21 Mon Sep 17 00:00:00 2001 From: Kira Date: Tue, 18 May 2021 09:50:06 +0800 Subject: [PATCH] =?UTF-8?q?KERNEL-7826=20refactor:=20jsx=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/single/label/abstract.label.ts | 11 +++++- typescript/base/single/label/label.ts | 6 +++ typescript/base/single/single.ts | 14 +++++++ typescript/core/ob.ts | 6 +++ typescript/shims-tsx.ts | 37 +++++++++++++++++++ 5 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 typescript/shims-tsx.ts diff --git a/typescript/base/single/label/abstract.label.ts b/typescript/base/single/label/abstract.label.ts index bf9266b20..683d6baef 100644 --- a/typescript/base/single/label/abstract.label.ts +++ b/typescript/base/single/label/abstract.label.ts @@ -2,7 +2,16 @@ import { Single } from "../single"; export declare class AbstractLabel extends Single { static xtype: string; - + + props: { + textAlign: "left" | "center" | "right", + whiteSpace: "nowrap" | "normal", + textWidth: number | null, + textHeight: number | null, + highLight: boolean, + handler: Function | null, + } & Single['props'] + doRedMark(...args: any[]): void; unRedMark(...args: any[]): void; diff --git a/typescript/base/single/label/label.ts b/typescript/base/single/label/label.ts index c64973af9..d4c393a97 100644 --- a/typescript/base/single/label/label.ts +++ b/typescript/base/single/label/label.ts @@ -1,5 +1,11 @@ import { AbstractLabel } from "./abstract.label"; export declare class Label extends AbstractLabel { + props: { + py: string; + keyword: string; + text: string; + } & AbstractLabel['props']; + static xtype: string; } diff --git a/typescript/base/single/single.ts b/typescript/base/single/single.ts index c5e72b1ac..4d7ced56e 100644 --- a/typescript/base/single/single.ts +++ b/typescript/base/single/single.ts @@ -5,6 +5,20 @@ interface SingleOpt { } export declare class Single extends Widget { + props: { + readonly: boolean, + title: string | (() => string) | null, + warningTitle: string | (() => string) | null, + tipType: "success" | "warning", + value: string | null, + + /** + * title是否跟随鼠标 + * @default false + */ + belowMouse: boolean, + } + _showToolTip(e: Event, opt?: SingleOpt): void; _hideTooltip(): void; diff --git a/typescript/core/ob.ts b/typescript/core/ob.ts index 9c4e4b947..36aeae46b 100644 --- a/typescript/core/ob.ts +++ b/typescript/core/ob.ts @@ -47,6 +47,12 @@ interface Props { } export declare class OB { + + /** + * 用于jsx props声明 + */ + __props: Partial; + props: Props | ((config: T) => Props & T); options: this["props"]; diff --git a/typescript/shims-tsx.ts b/typescript/shims-tsx.ts new file mode 100644 index 000000000..a8ad8e6ac --- /dev/null +++ b/typescript/shims-tsx.ts @@ -0,0 +1,37 @@ +declare const React: any; + +interface UIProps { + width: number; + height: number; + top: number; + left: number; + bottom: number; + right: number; + rgap: number; + lgap: number; + tgap: number; + bgap: number; +} + +interface ElementClassProps extends UIProps { + baseCls: string; + cls: string; + ref: (ref: T) => void; +} + +declare namespace JSX { + // for undefined + interface IntrinsicElements { + [elemName: string]: Partial; + } + + type ElementAttributesProperty = { + + /** + * specify the property name to use + */ + __props: any; + }; + + interface IntrinsicClassAttributes extends Partial> {} +}