@atlaskit/popup 1.6.1 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types-ts4.5/index.d.ts +4 -0
- package/dist/types-ts4.5/popper-wrapper.d.ts +4 -0
- package/dist/types-ts4.5/popup.d.ts +5 -0
- package/dist/types-ts4.5/reposition-on-update.d.ts +3 -0
- package/dist/types-ts4.5/types.d.ts +169 -0
- package/dist/types-ts4.5/use-close-manager.d.ts +2 -0
- package/dist/types-ts4.5/use-focus-manager.d.ts +2 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/cjs/version.json
CHANGED
package/dist/es2019/version.json
CHANGED
package/dist/esm/version.json
CHANGED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { jsx } from '@emotion/react';
|
|
2
|
+
import { PopperWrapperProps } from './types';
|
|
3
|
+
declare function PopperWrapper({ isOpen, id, offset, testId, content, fallbackPlacements, onClose, boundary, rootBoundary, shouldFlip, placement, popupComponent: PopupContainer, autoFocus, triggerRef, shouldUseCaptureOnOutsideClick, }: PopperWrapperProps): jsx.JSX.Element;
|
|
4
|
+
export default PopperWrapper;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import React, { ComponentType, CSSProperties, Dispatch, ReactNode, Ref, SetStateAction } from 'react';
|
|
2
|
+
import { Placement, PopperChildrenProps } from '@atlaskit/popper';
|
|
3
|
+
export interface TriggerProps {
|
|
4
|
+
ref: Ref<any>;
|
|
5
|
+
'aria-controls'?: string;
|
|
6
|
+
'aria-expanded': boolean;
|
|
7
|
+
'aria-haspopup': boolean;
|
|
8
|
+
}
|
|
9
|
+
export type PopupRef = HTMLDivElement | null;
|
|
10
|
+
export type TriggerRef = HTMLElement | HTMLButtonElement | null;
|
|
11
|
+
export interface ContentProps {
|
|
12
|
+
/**
|
|
13
|
+
* Will reposition the popup if any of the content has changed.
|
|
14
|
+
* Useful for when positions change and the popup was not aware.
|
|
15
|
+
*/
|
|
16
|
+
update: PopperChildrenProps['update'];
|
|
17
|
+
/**
|
|
18
|
+
* Passed through from the parent popup.
|
|
19
|
+
*/
|
|
20
|
+
isOpen: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Passed through from the parent popup.
|
|
23
|
+
*/
|
|
24
|
+
onClose?: BaseProps['onClose'];
|
|
25
|
+
/**
|
|
26
|
+
* Escape hatch to set the initial focus for a specific element when the popup is opened.
|
|
27
|
+
*/
|
|
28
|
+
setInitialFocusRef: Dispatch<SetStateAction<HTMLElement | null>>;
|
|
29
|
+
}
|
|
30
|
+
export interface PopupComponentProps {
|
|
31
|
+
/**
|
|
32
|
+
* Children passed passed through by the parent popup.
|
|
33
|
+
*/
|
|
34
|
+
children: ReactNode;
|
|
35
|
+
/**
|
|
36
|
+
* Placement passed through by the parent popup.
|
|
37
|
+
*/
|
|
38
|
+
'data-placement': Placement;
|
|
39
|
+
/**
|
|
40
|
+
* Test id passed through by the parent popup.
|
|
41
|
+
*/
|
|
42
|
+
'data-testid'?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Id passed through by the parent popup.
|
|
45
|
+
*/
|
|
46
|
+
id?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Ref that should be assigned to the root element.
|
|
49
|
+
*/
|
|
50
|
+
ref: Ref<HTMLDivElement>;
|
|
51
|
+
/**
|
|
52
|
+
* Style that should be assigned to the root element.
|
|
53
|
+
*/
|
|
54
|
+
style: CSSProperties;
|
|
55
|
+
/**
|
|
56
|
+
* Tab index passed through by the parent popup.
|
|
57
|
+
*/
|
|
58
|
+
tabIndex: number | undefined;
|
|
59
|
+
}
|
|
60
|
+
interface BaseProps {
|
|
61
|
+
/**
|
|
62
|
+
* Used to either show or hide the popup.
|
|
63
|
+
* When set to `false` popup will not render anything to the DOM.
|
|
64
|
+
*/
|
|
65
|
+
isOpen: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Render props for content that is displayed inside the popup.
|
|
68
|
+
*/
|
|
69
|
+
content: (props: ContentProps) => React.ReactNode;
|
|
70
|
+
/**
|
|
71
|
+
* Id that is assigned to the popup container element.
|
|
72
|
+
*/
|
|
73
|
+
id?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Distance the popup should be offset from the reference in the format of [along, away] (units in px).
|
|
76
|
+
* Defaults to [0, 8] - which means the popup will be 8px away from the edge of the reference specified
|
|
77
|
+
* by the `placement` prop.
|
|
78
|
+
*/
|
|
79
|
+
offset?: [
|
|
80
|
+
number,
|
|
81
|
+
number
|
|
82
|
+
];
|
|
83
|
+
/**
|
|
84
|
+
* Placement of where the popup should be displayed relative to the trigger element.
|
|
85
|
+
* Defaults to `"auto"`.
|
|
86
|
+
*/
|
|
87
|
+
placement?: Placement;
|
|
88
|
+
/**
|
|
89
|
+
* Defines a list of placements to try.
|
|
90
|
+
* When no space is available on the preferred placement,
|
|
91
|
+
* the modifier will test the ones provided in the list, and use the first useful one.
|
|
92
|
+
*/
|
|
93
|
+
fallbackPlacements?: Placement[];
|
|
94
|
+
/**
|
|
95
|
+
* The boundary element that the popup will check for overflow.
|
|
96
|
+
* Defaults to `"clippingParents"` which are parent scroll containers,
|
|
97
|
+
* but can be set to any element.
|
|
98
|
+
*/
|
|
99
|
+
boundary?: 'clippingParents' | HTMLElement;
|
|
100
|
+
/**
|
|
101
|
+
* The root boundary that the popup will check for overflow.
|
|
102
|
+
* Defaults to `"viewport"` but can be set to `"document"`.
|
|
103
|
+
*/
|
|
104
|
+
rootBoundary?: 'viewport' | 'document';
|
|
105
|
+
/**
|
|
106
|
+
* Allows the Popup to be placed on the opposite side of its trigger if it does not fit in the viewport.
|
|
107
|
+
* Defaults to `true`.
|
|
108
|
+
*/
|
|
109
|
+
shouldFlip?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* A `testId` prop is provided for specified elements,
|
|
112
|
+
* which is a unique string that appears as a data attribute `data-testid` in the rendered code,
|
|
113
|
+
* serving as a hook for automated tests.
|
|
114
|
+
*/
|
|
115
|
+
testId?: string;
|
|
116
|
+
/**
|
|
117
|
+
* Handler that is called when the popup wants to close itself.
|
|
118
|
+
* Generally this will be either when clicking away from the popup or pressing the escape key.
|
|
119
|
+
* You'll want to use this to set open state accordingly and then pump it back into the `isOpen` prop.
|
|
120
|
+
*/
|
|
121
|
+
onClose?(event: Event | React.MouseEvent | React.KeyboardEvent): void;
|
|
122
|
+
/**
|
|
123
|
+
* The element that is shown when `isOpen` prop is `true`.
|
|
124
|
+
* The result of the `content` prop will be placed as children here.
|
|
125
|
+
* Defaults to an element with an elevation of `e200` with _no padding_.
|
|
126
|
+
*/
|
|
127
|
+
popupComponent?: ComponentType<PopupComponentProps>;
|
|
128
|
+
/**
|
|
129
|
+
* Controls whether the popup takes focus when opening.
|
|
130
|
+
* This changes the `popupComponent` component tabIndex to `null`.
|
|
131
|
+
* Defaults to `true`.
|
|
132
|
+
*/
|
|
133
|
+
autoFocus?: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Controls if the event which handles clicks outside the popup is be bound with
|
|
136
|
+
* `capture: true`.
|
|
137
|
+
*/
|
|
138
|
+
shouldUseCaptureOnOutsideClick?: boolean;
|
|
139
|
+
}
|
|
140
|
+
export interface PopupProps extends BaseProps {
|
|
141
|
+
/**
|
|
142
|
+
* Render props used to anchor the popup to your content.
|
|
143
|
+
* Make this an interactive element,
|
|
144
|
+
* such as an `@atlaskit/button` component.
|
|
145
|
+
*/
|
|
146
|
+
trigger: (props: TriggerProps) => React.ReactNode;
|
|
147
|
+
/**
|
|
148
|
+
* Z-index that the popup should be displayed in.
|
|
149
|
+
* This is passed to the portal component.
|
|
150
|
+
* Defaults to `layers.layer()` from `@atlaskit/theme`.
|
|
151
|
+
*/
|
|
152
|
+
zIndex?: number;
|
|
153
|
+
}
|
|
154
|
+
export interface PopperWrapperProps extends BaseProps {
|
|
155
|
+
triggerRef: TriggerRef;
|
|
156
|
+
}
|
|
157
|
+
export type CloseManagerHook = Pick<PopupProps, 'isOpen' | 'onClose'> & {
|
|
158
|
+
popupRef: PopupRef;
|
|
159
|
+
triggerRef: TriggerRef;
|
|
160
|
+
shouldUseCaptureOnOutsideClick?: boolean;
|
|
161
|
+
};
|
|
162
|
+
export type FocusManagerHook = {
|
|
163
|
+
popupRef: PopupRef;
|
|
164
|
+
initialFocusRef: HTMLElement | null;
|
|
165
|
+
};
|
|
166
|
+
export type RepositionOnUpdateProps = {
|
|
167
|
+
update: PopperChildrenProps['update'];
|
|
168
|
+
};
|
|
169
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/popup",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"description": "A popup displays brief content in an overlay.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@atlaskit/button": "^16.7.0",
|
|
54
54
|
"@atlaskit/docs": "*",
|
|
55
55
|
"@atlaskit/icon": "^21.12.0",
|
|
56
|
-
"@atlaskit/menu": "^1.
|
|
56
|
+
"@atlaskit/menu": "^1.7.0",
|
|
57
57
|
"@atlaskit/radio": "^5.5.0",
|
|
58
58
|
"@atlaskit/section-message": "^6.4.0",
|
|
59
59
|
"@atlaskit/select": "^16.2.0",
|