@@ -2,8 +2,11 @@ import React from 'react';
22import { Modal , ModalProps } from 'antd' ;
33import { modalSizes } from 'constants/modalSizes' ;
44
5- interface BaseModalProps extends ModalProps {
5+ // Extend ModalProps to include our custom props
6+ interface BaseModalProps extends Omit < ModalProps , 'visible' > {
67 size ?: 'small' | 'medium' | 'large' ;
8+ visible ?: boolean ; // Deprecated prop
9+ open ?: boolean ; // New prop that will replace visible
710}
811
912interface BaseModalInterface extends React . FC < BaseModalProps > {
@@ -13,11 +16,33 @@ interface BaseModalInterface extends React.FC<BaseModalProps> {
1316 error : typeof Modal . error ;
1417}
1518
16- export const BaseModal : BaseModalInterface = ( { size = 'medium' , children, ...props } ) => {
19+ export const BaseModal : BaseModalInterface = ( {
20+ size = 'medium' ,
21+ visible,
22+ open,
23+ children,
24+ ...props
25+ } ) => {
1726 const modalSize = Object . entries ( modalSizes ) . find ( ( sz ) => sz [ 0 ] === size ) ?. [ 1 ] ;
27+
28+ // If open is provided, use it. Otherwise, fall back to visible.
29+ // This ensures backward compatibility while supporting the new prop.
30+ const isOpen = open !== undefined ? open : visible ;
31+
32+ // Show deprecation warning in development mode
33+ if ( process . env . NODE_ENV === 'development' && visible !== undefined && open === undefined ) {
34+ console . warn (
35+ '[antd: Modal] `visible` will be removed in next major version, please use `open` instead.'
36+ ) ;
37+ }
1838
1939 return (
20- < Modal getContainer = { false } width = { modalSize } { ...props } >
40+ < Modal
41+ getContainer = { false }
42+ width = { modalSize }
43+ open = { isOpen }
44+ { ...props }
45+ >
2146 { children }
2247 </ Modal >
2348 ) ;
0 commit comments