mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 05:29:26 +08:00
Merge branch 'main' into next
This commit is contained in:
commit
66ecba9d96
@ -67,21 +67,24 @@ const ActionModalContent: FC<{ footerNodeName: string; field: any; schema: any }
|
|||||||
);
|
);
|
||||||
|
|
||||||
export function useDelayedVisible(visible: boolean, delay = 200) {
|
export function useDelayedVisible(visible: boolean, delay = 200) {
|
||||||
const [ready, setReady] = useState(false);
|
const [ready, setReady] = useState(delay === 0);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (ready) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (visible) {
|
if (visible) {
|
||||||
const timer = setTimeout(() => setReady(true), delay);
|
const timer = setTimeout(() => setReady(true), delay);
|
||||||
return () => clearTimeout(timer);
|
return () => clearTimeout(timer);
|
||||||
} else {
|
} else {
|
||||||
setReady(false);
|
setReady(false);
|
||||||
}
|
}
|
||||||
}, [visible]);
|
}, [delay, ready, visible]);
|
||||||
return ready;
|
return ready;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const InternalActionModal: React.FC<ActionDrawerProps<ModalProps>> = observer(
|
export const InternalActionModal: React.FC<ActionDrawerProps<ModalProps>> = observer(
|
||||||
(props) => {
|
(props) => {
|
||||||
const { footerNodeName = 'Action.Modal.Footer', width, zIndex: _zIndex, ...others } = props;
|
const { footerNodeName = 'Action.Modal.Footer', width, zIndex: _zIndex, delay = 200, ...others } = props;
|
||||||
const { visible, setVisible, openSize = 'middle', modalProps } = useActionContext();
|
const { visible, setVisible, openSize = 'middle', modalProps } = useActionContext();
|
||||||
const actualWidth = width ?? openSizeWidthMap.get(openSize);
|
const actualWidth = width ?? openSizeWidthMap.get(openSize);
|
||||||
const schema = useFieldSchema();
|
const schema = useFieldSchema();
|
||||||
@ -102,7 +105,7 @@ export const InternalActionModal: React.FC<ActionDrawerProps<ModalProps>> = obse
|
|||||||
}
|
}
|
||||||
|
|
||||||
const zIndex = getZIndex('modal', _zIndex || parentZIndex, props.level || 0);
|
const zIndex = getZIndex('modal', _zIndex || parentZIndex, props.level || 0);
|
||||||
const ready = useDelayedVisible(visible, 200); // 200ms 与 Modal 动画时间一致
|
const ready = useDelayedVisible(visible, delay); // 200ms 与 Modal 动画时间一致
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ActionContextNoRerender>
|
<ActionContextNoRerender>
|
||||||
|
@ -92,6 +92,7 @@ export type ActionDrawerProps<T = DrawerProps> = T & {
|
|||||||
footerNodeName?: string;
|
footerNodeName?: string;
|
||||||
/** 当前弹窗嵌套的层级 */
|
/** 当前弹窗嵌套的层级 */
|
||||||
level?: number;
|
level?: number;
|
||||||
|
delay?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ComposedActionDrawer<T = DrawerProps> = React.FC<ActionDrawerProps<T>> & {
|
export type ComposedActionDrawer<T = DrawerProps> = React.FC<ActionDrawerProps<T>> & {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user