|
|
@ -13,23 +13,93 @@ import { _HighlightBehavior } from "./core/behavior/behavior.highlight"; |
|
|
|
import { _RedMarkBehavior } from "./core/behavior/behavior.redmark"; |
|
|
|
import { _RedMarkBehavior } from "./core/behavior/behavior.redmark"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type Constructor<T extends {}> = T & { |
|
|
|
type ClassConstructor<T extends {}> = T & { |
|
|
|
new(config: any): T; |
|
|
|
new(config: any): T; |
|
|
|
(config: any): T; |
|
|
|
(config: any): T; |
|
|
|
readonly prototype: T; |
|
|
|
readonly prototype: T; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export interface _BI extends _func, _i18n, _base { |
|
|
|
export interface _BI extends _func, _i18n, _base { |
|
|
|
OB: Constructor<_OB>; |
|
|
|
OB: ClassConstructor<_OB>; |
|
|
|
Widget: Constructor<_Widget> & _WidgetStatic; |
|
|
|
Widget: ClassConstructor<_Widget> & _WidgetStatic; |
|
|
|
Single: Constructor<_Single>; |
|
|
|
Single: ClassConstructor<_Single>; |
|
|
|
BasicButton: Constructor<_BasicButton>; |
|
|
|
BasicButton: ClassConstructor<_BasicButton>; |
|
|
|
Trigger: Constructor<_Trigger>; |
|
|
|
Trigger: ClassConstructor<_Trigger>; |
|
|
|
Action: Constructor<_Action>; |
|
|
|
Action: ClassConstructor<_Action>; |
|
|
|
ActionFactory: Constructor<_ActionFactory>; |
|
|
|
ActionFactory: ClassConstructor<_ActionFactory>; |
|
|
|
ShowAction: Constructor<_ShowAction>; |
|
|
|
ShowAction: ClassConstructor<_ShowAction>; |
|
|
|
Behavior: Constructor<_Behavior>; |
|
|
|
Behavior: ClassConstructor<_Behavior>; |
|
|
|
BehaviorFactory: Constructor<_BehaviorFactory>; |
|
|
|
BehaviorFactory: ClassConstructor<_BehaviorFactory>; |
|
|
|
HighlightBehavior: Constructor<_HighlightBehavior>; |
|
|
|
HighlightBehavior: ClassConstructor<_HighlightBehavior>; |
|
|
|
RedMarkBehavior: Constructor<_RedMarkBehavior>; |
|
|
|
RedMarkBehavior: ClassConstructor<_RedMarkBehavior>; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface Obj { |
|
|
|
|
|
|
|
[key: string]: any; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
declare let BI: Obj & _BI; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
declare const Fix: Obj; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export type Constructor<T> = new(...args: any[]) => T; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 注册widget |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
export function shortcut () { |
|
|
|
|
|
|
|
return function decorator<U> (Target: Constructor<U> & {xtype: string}): void { |
|
|
|
|
|
|
|
BI.shortcut(Target.xtype, Target); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 注册model |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
export function model () { |
|
|
|
|
|
|
|
return function decorator<U extends {new (...args:any[]):{}} & {xtype: string, context?: ReadonlyArray<string>}>(Target: U): void { |
|
|
|
|
|
|
|
BI.model(Target.xtype, class extends Target { |
|
|
|
|
|
|
|
context = Target.context; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 类注册_store属性 |
|
|
|
|
|
|
|
* @param Model model类 |
|
|
|
|
|
|
|
* @param opts 额外条件 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
export function store<T> (Model?: Constructor<T> & {xtype: string}, opts: { props?(this: unknown): { [key: string]: unknown } } = {}) { |
|
|
|
|
|
|
|
return function classDecorator<U extends {new (...args:any[]):{}}>(constructor:U) { |
|
|
|
|
|
|
|
return class extends constructor { |
|
|
|
|
|
|
|
_store () { |
|
|
|
|
|
|
|
const props = opts.props ? opts.props.apply(this) : undefined; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return BI.Models.getModel(Model.xtype, props); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Model基类 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
export class Model<U extends {types?: {[key: string]: any}, context?: ReadonlyArray<string>} = {}> extends Fix.Model { |
|
|
|
|
|
|
|
model: Pick<{[key in keyof U["types"]]: U["types"][key]}, U["context"][number]> & {[key in keyof ReturnType<this["state"]>]: ReturnType<this["state"]>[key]} & {[key in keyof this["computed"]]: ReturnType<this["computed"][key]>} & {[key: string]: unknown}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
store: this["actions"]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
state (): {[key: string]: any} { |
|
|
|
|
|
|
|
return {}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context: U["context"]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
actions:{[key: string]: (...args: any[]) => any}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
childContext: ReadonlyArray<keyof (this["computed"] & ReturnType<this["state"]>)>; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TYPE: Pick<{[key in keyof this["computed"]]: ReturnType<this["computed"][key]>} & {[key in keyof ReturnType<this["state"]>]: ReturnType<this["state"]>[key]}, this["childContext"][number]>; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
computed: {[key: string]: () => any}; |
|
|
|
} |
|
|
|
} |
|
|
|