1 | import * as React from "react";
|
2 | import PopperJS from "popper.js";
|
3 | import StyledSystem from "styled-system";
|
4 | import { BoxProps } from "../Box";
|
5 | import { PseudoBoxProps } from "../PseudoBox";
|
6 | import { PopperProps } from "../Popper";
|
7 |
|
8 | interface PopoverContextValue {
|
9 | popoverRef: React.RefObject<HTMLElement>;
|
10 | placement: PopperJS.Placement;
|
11 | referenceRef: React.RefObject<HTMLElement>;
|
12 | headerId: string;
|
13 | bodyId: string;
|
14 | popoverId: string;
|
15 | onOpen: () => void;
|
16 | onClose: () => void;
|
17 | onToggle: () => void;
|
18 | trigger: "hover" | "click";
|
19 | isOpen: boolean;
|
20 | onBlur: React.FocusEventHandler<HTMLElement>;
|
21 | closeOnEsc: boolean;
|
22 | initialFocusRef: boolean;
|
23 | isHoveringRef: React.RefObject<boolean>;
|
24 | usePortal: boolean;
|
25 | }
|
26 |
|
27 | declare const PopoverContext: React.Context<{}>;
|
28 | declare const usePopoverContext: () => PopoverContextValue | undefined;
|
29 |
|
30 | type InternalState = { isOpen?: boolean; onClose?: () => void };
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | type PopoverChildren =
|
36 | | {
|
37 | children: React.ReactNode;
|
38 | }
|
39 | | { children: (props: InternalState) => React.ReactNode };
|
40 |
|
41 | interface IPopover {
|
42 | |
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 | id?: string;
|
50 | |
51 |
|
52 |
|
53 | isOpen?: boolean;
|
54 | |
55 |
|
56 |
|
57 | defaultIsOpen?: boolean;
|
58 | |
59 |
|
60 |
|
61 | initialFocusRef?: React.RefObject<HTMLElement>;
|
62 | |
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 | trigger?: "hover" | "click";
|
72 | |
73 |
|
74 |
|
75 | returnFocusOnClose?: boolean;
|
76 | |
77 |
|
78 |
|
79 |
|
80 | gutter?: number;
|
81 | |
82 |
|
83 |
|
84 | placement?: PopperJS.Placement;
|
85 | |
86 |
|
87 |
|
88 |
|
89 | closeOnBlur?: boolean;
|
90 | |
91 |
|
92 |
|
93 | closeOnEsc?: boolean;
|
94 | |
95 |
|
96 |
|
97 | onOpen?: () => void;
|
98 | |
99 |
|
100 |
|
101 | onClose?: () => void;
|
102 | |
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 | usePortal?: boolean;
|
109 | }
|
110 |
|
111 | type PopoverProps = IPopover & PopoverChildren;
|
112 | export const Popover: React.FC<PopoverProps>;
|
113 |
|
114 | interface IPopoverTrigger {
|
115 | children: React.ReactNode;
|
116 | }
|
117 | export const PopoverTrigger: React.FC<IPopoverTrigger>;
|
118 |
|
119 | interface IPopoverContent {
|
120 | onKeyDown?: React.KeyboardEventHandler<HTMLElement>;
|
121 | onBlur?: React.FocusEventHandler<HTMLElement>;
|
122 | onMouseLeave?: React.MouseEventHandler<HTMLElement>;
|
123 | onMouseEnter?: React.MouseEventHandler<HTMLElement>;
|
124 | onFocus?: React.FocusEventHandler<HTMLElement>;
|
125 | gutter?: number;
|
126 | |
127 |
|
128 |
|
129 |
|
130 | "aria-label"?: string;
|
131 | }
|
132 | type PopoverContentProps = IPopoverContent & PopperProps;
|
133 | export const PopoverContent: React.FC<PopoverContentProps>;
|
134 |
|
135 | export const PopoverArrow: React.FC<BoxProps>;
|
136 | export const PopoverHeader: React.FC<BoxProps>;
|
137 | export const PopoverFooter: React.FC<BoxProps>;
|
138 | export const PopoverBody: React.FC<BoxProps>;
|
139 |
|
140 | type PopoverCloseButtonProps = PseudoBoxProps & {
|
141 | onClick?: React.MouseEventHandler<HTMLElement>;
|
142 | };
|
143 | export const PopoverCloseButton: React.FC<PopoverCloseButtonProps>;
|