-
-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathDrawerPanel.tsx
More file actions
60 lines (50 loc) · 1.7 KB
/
Copy pathDrawerPanel.tsx
File metadata and controls
60 lines (50 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import classNames from 'classnames';
import * as React from 'react';
import { RefContext } from './context';
import pickAttrs from '@rc-component/util/lib/pickAttrs';
import { useComposeRef } from '@rc-component/util/lib/ref';
export interface DrawerPanelRef {
focus: VoidFunction;
}
export interface DrawerPanelEvents {
onMouseEnter?: React.MouseEventHandler<HTMLDivElement>;
onMouseOver?: React.MouseEventHandler<HTMLDivElement>;
onMouseLeave?: React.MouseEventHandler<HTMLDivElement>;
onClick?: React.MouseEventHandler<HTMLDivElement>;
onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;
onKeyUp?: React.KeyboardEventHandler<HTMLDivElement>;
}
export type DrawerPanelAccessibility = Pick<
React.DialogHTMLAttributes<HTMLDivElement>,
keyof React.AriaAttributes
>;
export interface DrawerPanelProps
extends DrawerPanelEvents,
DrawerPanelAccessibility {
prefixCls: string;
className?: string;
id?: string;
style?: React.CSSProperties;
children?: React.ReactNode;
containerRef?: React.Ref<HTMLDivElement>;
}
const DrawerPanel: React.FC<Readonly<DrawerPanelProps>> = props => {
const { prefixCls, className, containerRef, ...restProps } = props;
const { panel: panelRef } = React.useContext(RefContext);
const mergedRef = useComposeRef(panelRef, containerRef);
// =============================== Render ===============================
return (
<div
className={classNames(`${prefixCls}-section`, className)}
role="dialog"
ref={mergedRef}
{...pickAttrs(props, { aria: true })}
aria-modal="true"
{...restProps}
/>
);
};
if (process.env.NODE_ENV !== 'production') {
DrawerPanel.displayName = 'DrawerPanel';
}
export default DrawerPanel;