ant-design/components/message/util.ts
lijianan 0c5557d1c2
refactor: [v6] use rc-component/resize-observer (#52578)
* refactor: [v6] use rc-component/resize-observer

* chore: mock of ResizeObserver

* test: update snap

* fix: fix

* chore: update dep

* test: back of snapshot

* fix: fix

* chore: update deps

* chore: update

* chore: update @rc-component/motion

---------

Signed-off-by: lijianan <574980606@qq.com>
Co-authored-by: 二货机器人 <smith3816@gmail.com>
2025-02-18 16:01:16 +08:00

29 lines
726 B
TypeScript

import type { CSSMotionProps } from '@rc-component/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;
const closePromise = new Promise<boolean>((resolve) => {
closeFn = openFn(() => {
resolve(true);
});
});
const result: any = () => {
closeFn?.();
};
result.then = (filled: VoidFunction, rejected: VoidFunction) =>
closePromise.then(filled, rejected);
result.promise = closePromise;
return result;
}