Skip to content

Commit 9307197

Browse files
committed
feat: implement new helper for antd deperecated prop
1 parent 5bd49dd commit 9307197

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

src/index.test.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import NiceModal, {
77
register,
88
create,
99
antdDrawer,
10+
antdDrawerV5,
1011
antdModal,
12+
antdModalV5,
1113
muiDialog,
1214
bootstrapDialog,
1315
reducer,
@@ -360,9 +362,20 @@ const AntdModal = ({ visible, onOk, onCancel, afterClose, children }) => {
360362
</TestModal>
361363
);
362364
};
365+
const AntdModalV5 = ({ open, onOk, onCancel, afterClose, children }) => {
366+
return (
367+
<TestModal visible={open} onClose={onOk} onCancel={onCancel} onExited={afterClose}>
368+
{children}
369+
</TestModal>
370+
);
371+
};
363372
test('test antd modal helper', async () => {
364-
await testHelper(AntdModal, antdModal, 'AntdModal');
365-
await testHelper(AntdModal, antdModal, 'AntdModal', true);
373+
await testHelper(AntdModalV5, antdModalV5, 'AntdModalV5');
374+
await testHelper(AntdModalV5, antdModalV5, 'AntdModalV5', true);
375+
});
376+
test('test antd modal v5 helper', async () => {
377+
await testHelper(AntdModalV5, antdModalV5, 'AntdModalV5');
378+
await testHelper(AntdModalV5, antdModalV5, 'AntdModalV5', true);
366379
});
367380

368381
test('test antd modal onCancel', async () => {
@@ -392,6 +405,16 @@ test('test antd drawer helper', async () => {
392405
};
393406
await testHelper(AntdDrawer, antdDrawer, 'AntdDrawerTest');
394407
});
408+
test('test antd drawer v5 helper', async () => {
409+
const AntdDrawerV5 = ({ open, onClose, afterOpenChange, children }) => {
410+
return (
411+
<TestModal visible={open} onClose={onClose} onExited={() => afterOpenChange(false)}>
412+
{children}
413+
</TestModal>
414+
);
415+
};
416+
await testHelper(AntdDrawerV5, antdDrawerV5, 'AntdDrawerV5Test');
417+
});
395418

396419
test('test mui dialog helper', async () => {
397420
const MuiDialog = ({ open, onClose, onExited, children }) => {

src/index.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,17 @@ export const antdModal = (
502502
},
503503
};
504504
};
505+
export const antdModalV5 = (
506+
modal: NiceModalHandler,
507+
): { open: boolean; onCancel: () => void; onOk: () => void; afterClose: () => void } => {
508+
const {onOk, onCancel, afterClose} = antdModal(modal)
509+
return {
510+
open: modal.visible,
511+
onOk,
512+
onCancel,
513+
afterClose,
514+
};
515+
};
505516
export const antdDrawer = (
506517
modal: NiceModalHandler,
507518
): { visible: boolean; onClose: () => void; afterVisibleChange: (visible: boolean) => void } => {
@@ -516,6 +527,16 @@ export const antdDrawer = (
516527
},
517528
};
518529
};
530+
export const antdDrawerV5 = (
531+
modal: NiceModalHandler,
532+
): { open: boolean; onClose: () => void; afterOpenChange: (visible: boolean) => void } => {
533+
const {onClose, afterVisibleChange: afterOpenChange} = antdDrawer(modal)
534+
return {
535+
open: modal.visible,
536+
onClose,
537+
afterOpenChange,
538+
};
539+
};
519540
export const muiDialog = (modal: NiceModalHandler): { open: boolean; onClose: () => void; onExited: () => void } => {
520541
return {
521542
open: modal.visible,

0 commit comments

Comments
 (0)