MCPcopy Create free account
hub / github.com/DTStack/dt-react-component / Drawer

Function Drawer

src/drawer/index.tsx:71–178  ·  view source on GitHub ↗
(props: DrawerProps<T>)

Source from the content-addressed store, hash-verified

69};
70
71const Drawer = <T extends readOnlyTab>(props: DrawerProps<T>) => {
72 const drawerPrefixCls = 'dtc-drawer';
73
74 const {
75 open,
76 loading = false,
77 bodyClassName,
78 mask = false,
79 maskClosable = true,
80 bodyStyle,
81 title,
82 width,
83 type = DrawerType.Normal,
84 size = 'default',
85 footer,
86 banner,
87 onClose,
88 ...rest
89 } = props;
90
91 const finalWidth = width ?? getWidthFromSize(size);
92 const isFormType = type === DrawerType.Form;
93
94 const [internalTabKey, setInternalTabKey] = useState<TabKey<T>>('');
95
96 useEffect(() => {
97 open &&
98 isTabMode(props) &&
99 setInternalTabKey(props.defaultKey ?? props.tabs?.[0]?.key ?? '');
100 }, [open]);
101
102 const currentKey = isControlled(props) ? props.activeKey : internalTabKey;
103
104 const renderButton = () => {
105 return (
106 <img
107 className={`${drawerPrefixCls}-icon`}
108 onClick={onClose}
109 src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAABwCAYAAAAE0LDPAAAAAXNSR0IArs4c6QAAAnlJREFUaEPtmk9IVHEQx78jufpw7ykouuEaBG6dEmrXOmRRt476VgvyEngKlNqQMu3PoSU7iCBq4CW2olNdRMRr7HasnnZb0y57WGODzUDjt/RIonbeyzfQYd51h/m8+c7395u3MOSs5Xexr4dKRLt5AhYJtbPRaNO7velo/4Bf6YhoB8B0R3vzNSLaNr8ECnBRRLTc0d583kBEAJU3J5o6HG0ZkgTs1OBATAxgqqghTIoCiPBeFABQSRggZFOxg/anC0ElYq9JlUglYhVgA9RFKhGrABugLlKJWAXYAHWRSsQqwAaoi1QiVgE2gHVRejKDUKgWQ1cvmj/XbMLfA3jA42dwVvPo7+tBd/xo8ICNzQLG7y3AskIYvz2IcEO9LwhbgcmWebGCpeUcEvEYBvrOBg8ol7cxOjaP4lYJqZEkIm2NniGeKjDZ3mQ/YPbJa7S1NiI1YntuuGeAgTx8lMHqx3XYvWdwOnHMUxW+AJufC7hzdwH1VggTt64gHLZYiC+Ayfb85QoWl3KIn+jEpeS54AHlb98xOjaHYrGEG8M2DkWaqkJ8V2CyZd86mJl7hdaWg7h5PVm14f8EMJD0zxM+ePkCuo4f+WsV/ycgm3MwMy8k0d4mp4ZtRIJusmvTxMlODNgB21T8oLlXRbK3B6cS3maDZxeJXnbudb315Wvl9AZ+XbsDpzseQ3/QA+fTRgET9wVHpvmqcNbWK6PSjEy/D9vkB+mnaLDq5D5b/L6x7+8iBbBNVolUItYDKpFKxCrABqiLVCJWATZAXaQSsQqwAeoilYhVgA1QFzESCS8wia9giS6Rma1B0TU40UU+sVVEoWXK6uugPwBjVkdxauLcgwAAAABJRU5ErkJggg=="
110 alt="closeBtn"
111 />
112 );
113 };
114
115 const handleChangeKey = (key: TabKey<T>) => {
116 !isControlled(props) && setInternalTabKey(key);
117 isTabMode(props) && props.onChange?.(key);
118 };
119
120 return (
121 <RcDrawer
122 open={open}
123 placement="right"
124 mask={isFormType ? true : mask}
125 maskClosable={isFormType ? false : maskClosable}
126 width={finalWidth}
127 prefixCls={drawerPrefixCls}
128 onClose={onClose}

Callers

nothing calls this directly

Calls 6

isAlertObjectPropsFunction · 0.90
renderButtonFunction · 0.85
isFunctionFunction · 0.85
getWidthFromSizeFunction · 0.70
isTabModeFunction · 0.70
isControlledFunction · 0.70

Tested by

no test coverage detected