2022-05-11 14:26:18 +08:00
|
|
|
import type { CSSMotionProps } from 'rc-motion';
|
|
|
|
|
|
|
|
export function getMotion(prefixCls: string, transitionName?: string): CSSMotionProps {
|
|
|
|
return {
|
|
|
|
motionName: transitionName ?? `${prefixCls}-move-up`,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Wrap message open with promise like function */
|
|
|
|
export function wrapPromiseFn(openFn: (resolve: VoidFunction) => VoidFunction) {
|
|
|
|
let closeFn: VoidFunction;
|
|
|
|
|
2022-11-19 13:47:33 +08:00
|
|
|
const closePromise = new Promise<boolean>((resolve) => {
|
2022-05-11 14:26:18 +08:00
|
|
|
closeFn = openFn(() => {
|
|
|
|
resolve(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
const result: any = () => {
|
|
|
|
closeFn?.();
|
|
|
|
};
|
|
|
|
|
|
|
|
result.then = (filled: VoidFunction, rejected: VoidFunction) =>
|
|
|
|
closePromise.then(filled, rejected);
|
|
|
|
result.promise = closePromise;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|