antd-mini
Version:
antd-mini 是支付宝小程序 UI 组件库,遵循 Ant Design 规范。
71 lines (70 loc) • 2.93 kB
TypeScript
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, props: defaultProps, methods, data, mixins, ...instanceMethods }: {
storeOptions?: TStoreOptions<S, M>;
props?: Props;
methods?: Methods;
data?: Data;
mixins?: any;
} & InstanceMethods) => 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, Data = unknown, Methods = unknown, Mixins = unknown, InstanceMethods = unknown>({ props: defaultProps, data, methods, mixins, ...instanceMethods }: {
props?: Props;
data?: Data;
methods?: Methods;
mixins?: Mixins & any;
} & InstanceMethods): 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, };