antd-mini
Version:
antd-mini 是支付宝小程序 UI 组件库,遵循 Ant Design 规范。
64 lines (63 loc) • 3.02 kB
TypeScript
type ComponentInstance<Props, Methods, Data, Mixins, InstanceMethods> = unknown;
interface IComponentOptions {
onInit?: () => void;
didUnmount?: () => void;
}
type ExtendedInstanceMethods = Partial<IComponentOptions> & Record<string, any>;
export declare const ComponentWithSignalStoreImpl: <S, M extends Record<string, (o: {
store: S;
}) => unknown>, Props, Methods = unknown, Data = unknown, Mixins = unknown, InstanceMethods extends ExtendedInstanceMethods = ExtendedInstanceMethods>(storeOptions: TStoreOptions<S, M>, defaultProps: Props, methods?: Methods & ThisType<unknown>, data?: any, mixins?: any, instanceMethods?: InstanceMethods & ThisType<{
$store: S;
props: Props;
}>) => void;
type TMapState<S> = Record<string, (o: {
store: S;
}) => unknown>;
export type TStoreOptions<S, M extends TMapState<S>> = {
/**
* store 的创建器,因为页面会有多实例,所以 store 必须每个页面实例单独创建一次
* 如果你非要多个实例共用一个 store,那你可以 const store = new Store(); store: => store;
*/
store: () => S;
/**
* store 数据更新后的 listener,通过它来触发向页面数据的同步,返回值是一个 dispose 函数。
* 在 mobx 是 autorun、redux 是 subscribe、你要不在意性能,setInterval 也可以
*/
updateHook: (fn: () => void) => () => void;
/**
* store 数据到页面 data 的映射关系
*/
mapState: M;
};
export type TStoreInitOptions<S> = {
setData: (o: Record<string, unknown>, callback?: () => void) => void;
$store?: S;
};
export declare class StoreBinder<S, M extends TMapState<S>> {
private storeOptions;
private disposeStore?;
constructor(storeOptions: TStoreOptions<S, M>);
/**
* 绑定和 store 的关系
*/
init(theThis: TStoreInitOptions<S>): void;
/**
* 释放和 store 的关系
*/
dispose(): void;
}
declare function ComponentImpl<Props, Methods = unknown, Data = unknown, Mixins = unknown, InstanceMethods = unknown>(defaultProps: Props, methods?: Methods & ThisType<ComponentInstance<Props, Methods, Data, Mixins, InstanceMethods>>, data?: Data & any, mixins?: Mixins & any, instanceMethods?: InstanceMethods & any): void;
export interface IPlatformEvent {
currentTarget: {
dataset: Record<string, unknown>;
};
target: {
dataset: Record<string, unknown>;
};
}
export declare function triggerEvent(instance: any, eventName: string, value: unknown, e?: any): void;
export declare function triggerEventOnly(instance: any, eventName: string, e?: any): void;
export declare function triggerEventValues(instance: any, eventName: string, values: any[], e?: any): void;
export declare function triggerCatchEvent(instance: any, eventName: string, e?: any): void;
export declare function getValueFromProps(instance: any, propName?: string | string[]): any;
export { ComponentWithSignalStoreImpl as ComponentWithSignalStore, ComponentImpl as Component, };