@atlaskit/popup 4.16.4 → 4.16.6
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 +12 -0
- package/dist/cjs/compositional/id-context.js +9 -0
- package/dist/cjs/compositional/is-inside-popup-context.js +19 -0
- package/dist/cjs/compositional/is-open-context.js +19 -0
- package/dist/cjs/compositional/popup-content.js +123 -0
- package/dist/cjs/compositional/popup-trigger.js +42 -0
- package/dist/cjs/compositional/popup.js +13 -165
- package/dist/cjs/compositional/role-context.js +10 -0
- package/dist/cjs/compositional/set-trigger-ref-context.js +12 -0
- package/dist/cjs/compositional/trigger-ref-context.js +10 -0
- package/dist/cjs/compositional/use-ensure-is-inside-popup.js +15 -0
- package/dist/cjs/entry-points/experimental/compositional.js +5 -3
- package/dist/cjs/popper-wrapper.js +24 -24
- package/dist/es2019/compositional/id-context.js +4 -0
- package/dist/es2019/compositional/is-inside-popup-context.js +14 -0
- package/dist/es2019/compositional/is-open-context.js +14 -0
- package/dist/es2019/compositional/popup-content.js +107 -0
- package/dist/es2019/compositional/popup-trigger.js +34 -0
- package/dist/es2019/compositional/popup.js +8 -153
- package/dist/es2019/compositional/role-context.js +3 -0
- package/dist/es2019/compositional/set-trigger-ref-context.js +4 -0
- package/dist/es2019/compositional/trigger-ref-context.js +3 -0
- package/dist/es2019/compositional/use-ensure-is-inside-popup.js +9 -0
- package/dist/es2019/entry-points/experimental/compositional.js +3 -1
- package/dist/es2019/popper-wrapper.js +24 -24
- package/dist/esm/compositional/id-context.js +4 -0
- package/dist/esm/compositional/is-inside-popup-context.js +14 -0
- package/dist/esm/compositional/is-open-context.js +14 -0
- package/dist/esm/compositional/popup-content.js +114 -0
- package/dist/esm/compositional/popup-trigger.js +34 -0
- package/dist/esm/compositional/popup.js +8 -160
- package/dist/esm/compositional/role-context.js +3 -0
- package/dist/esm/compositional/set-trigger-ref-context.js +4 -0
- package/dist/esm/compositional/trigger-ref-context.js +3 -0
- package/dist/esm/compositional/use-ensure-is-inside-popup.js +9 -0
- package/dist/esm/entry-points/experimental/compositional.js +3 -1
- package/dist/esm/popper-wrapper.js +24 -24
- package/dist/types/compositional/id-context.d.ts +2 -0
- package/dist/types/compositional/is-inside-popup-context.d.ts +11 -0
- package/dist/types/compositional/is-open-context.d.ts +11 -0
- package/dist/types/compositional/popup-content.d.ts +35 -0
- package/dist/types/compositional/popup-trigger.d.ts +13 -0
- package/dist/types/compositional/popup.d.ts +0 -45
- package/dist/types/compositional/role-context.d.ts +2 -0
- package/dist/types/compositional/set-trigger-ref-context.d.ts +2 -0
- package/dist/types/compositional/trigger-ref-context.d.ts +2 -0
- package/dist/types/compositional/use-ensure-is-inside-popup.d.ts +1 -0
- package/dist/types/entry-points/experimental/compositional.d.ts +6 -2
- package/dist/types-ts4.5/compositional/id-context.d.ts +2 -0
- package/dist/types-ts4.5/compositional/is-inside-popup-context.d.ts +11 -0
- package/dist/types-ts4.5/compositional/is-open-context.d.ts +11 -0
- package/dist/types-ts4.5/compositional/popup-content.d.ts +35 -0
- package/dist/types-ts4.5/compositional/popup-trigger.d.ts +13 -0
- package/dist/types-ts4.5/compositional/popup.d.ts +0 -45
- package/dist/types-ts4.5/compositional/role-context.d.ts +2 -0
- package/dist/types-ts4.5/compositional/set-trigger-ref-context.d.ts +2 -0
- package/dist/types-ts4.5/compositional/trigger-ref-context.d.ts +2 -0
- package/dist/types-ts4.5/compositional/use-ensure-is-inside-popup.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/experimental/compositional.d.ts +6 -2
- package/package.json +10 -10
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React, { useCallback, useContext } from 'react';
|
|
2
|
+
import { Layering } from '@atlaskit/layering';
|
|
3
|
+
import { useNotifyOpenLayerObserver } from '@atlaskit/layering/experimental/open-layer-observer';
|
|
4
|
+
import Portal from '@atlaskit/portal';
|
|
5
|
+
import PopperWrapper from '../popper-wrapper';
|
|
6
|
+
import { usePopupAppearance } from '../use-appearance';
|
|
7
|
+
import { IdContext } from './id-context';
|
|
8
|
+
import { IsOpenContext } from './is-open-context';
|
|
9
|
+
import { TriggerRefContext } from './trigger-ref-context';
|
|
10
|
+
import { useEnsureIsInsidePopup } from './use-ensure-is-inside-popup';
|
|
11
|
+
const defaultLayer = 400;
|
|
12
|
+
const shouldDisableGpuAccelerationModifiers = [{
|
|
13
|
+
name: 'computeStyles',
|
|
14
|
+
options: {
|
|
15
|
+
gpuAcceleration: false
|
|
16
|
+
}
|
|
17
|
+
}];
|
|
18
|
+
/**
|
|
19
|
+
* __Popup content__
|
|
20
|
+
*
|
|
21
|
+
* Popup content is the component that renders the content of the popup.
|
|
22
|
+
*
|
|
23
|
+
* It must be a child of the Popup component.
|
|
24
|
+
*/
|
|
25
|
+
export const PopupContent = ({
|
|
26
|
+
xcss,
|
|
27
|
+
appearance: inAppearance = 'default',
|
|
28
|
+
children,
|
|
29
|
+
boundary,
|
|
30
|
+
offset,
|
|
31
|
+
strategy,
|
|
32
|
+
onClose,
|
|
33
|
+
testId,
|
|
34
|
+
rootBoundary = 'viewport',
|
|
35
|
+
shouldFlip = true,
|
|
36
|
+
placement = 'auto',
|
|
37
|
+
fallbackPlacements,
|
|
38
|
+
popupComponent,
|
|
39
|
+
autoFocus = true,
|
|
40
|
+
zIndex = defaultLayer,
|
|
41
|
+
shouldUseCaptureOnOutsideClick = false,
|
|
42
|
+
shouldRenderToParent: inShouldRenderToParent,
|
|
43
|
+
shouldDisableFocusLock = false,
|
|
44
|
+
shouldFitContainer,
|
|
45
|
+
shouldFitViewport,
|
|
46
|
+
shouldDisableGpuAcceleration = false,
|
|
47
|
+
role,
|
|
48
|
+
titleId
|
|
49
|
+
}) => {
|
|
50
|
+
useEnsureIsInsidePopup();
|
|
51
|
+
const isOpen = useContext(IsOpenContext);
|
|
52
|
+
const id = useContext(IdContext);
|
|
53
|
+
const triggerRef = useContext(TriggerRefContext);
|
|
54
|
+
const {
|
|
55
|
+
appearance,
|
|
56
|
+
shouldRenderToParent
|
|
57
|
+
} = usePopupAppearance({
|
|
58
|
+
appearance: inAppearance,
|
|
59
|
+
shouldRenderToParent: inShouldRenderToParent
|
|
60
|
+
});
|
|
61
|
+
const handleOpenLayerObserverCloseSignal = useCallback(() => {
|
|
62
|
+
onClose === null || onClose === void 0 ? void 0 : onClose(null);
|
|
63
|
+
}, [onClose]);
|
|
64
|
+
useNotifyOpenLayerObserver({
|
|
65
|
+
isOpen,
|
|
66
|
+
onClose: handleOpenLayerObserverCloseSignal,
|
|
67
|
+
type: 'popup'
|
|
68
|
+
});
|
|
69
|
+
if (!isOpen) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
const popperWrapper = /*#__PURE__*/React.createElement(Layering, {
|
|
73
|
+
isDisabled: false
|
|
74
|
+
}, /*#__PURE__*/React.createElement(PopperWrapper, {
|
|
75
|
+
xcss: xcss,
|
|
76
|
+
appearance: appearance,
|
|
77
|
+
content: children,
|
|
78
|
+
isOpen: isOpen,
|
|
79
|
+
placement: placement,
|
|
80
|
+
fallbackPlacements: fallbackPlacements,
|
|
81
|
+
boundary: boundary,
|
|
82
|
+
rootBoundary: rootBoundary,
|
|
83
|
+
shouldFlip: shouldFlip,
|
|
84
|
+
offset: offset,
|
|
85
|
+
popupComponent: popupComponent,
|
|
86
|
+
id: id,
|
|
87
|
+
testId: testId,
|
|
88
|
+
onClose: onClose,
|
|
89
|
+
autoFocus: autoFocus,
|
|
90
|
+
shouldFitContainer: shouldFitContainer,
|
|
91
|
+
shouldUseCaptureOnOutsideClick: shouldUseCaptureOnOutsideClick,
|
|
92
|
+
shouldRenderToParent: shouldRenderToParent,
|
|
93
|
+
shouldDisableFocusLock: shouldDisableFocusLock,
|
|
94
|
+
triggerRef: triggerRef,
|
|
95
|
+
strategy: strategy,
|
|
96
|
+
shouldFitViewport: shouldFitViewport,
|
|
97
|
+
modifiers: shouldDisableGpuAcceleration ? shouldDisableGpuAccelerationModifiers : undefined,
|
|
98
|
+
role: role,
|
|
99
|
+
titleId: titleId
|
|
100
|
+
}));
|
|
101
|
+
if (shouldRenderToParent) {
|
|
102
|
+
return popperWrapper;
|
|
103
|
+
}
|
|
104
|
+
return /*#__PURE__*/React.createElement(Portal, {
|
|
105
|
+
zIndex: zIndex
|
|
106
|
+
}, popperWrapper);
|
|
107
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
|
+
import { Reference } from '@atlaskit/popper';
|
|
4
|
+
import { useGetMemoizedMergedTriggerRefNew } from '../use-get-memoized-merged-trigger-ref-new';
|
|
5
|
+
import { IdContext } from './id-context';
|
|
6
|
+
import { IsOpenContext } from './is-open-context';
|
|
7
|
+
import { RoleContext } from './role-context';
|
|
8
|
+
import { SetTriggerRefContext } from './set-trigger-ref-context';
|
|
9
|
+
import { useEnsureIsInsidePopup } from './use-ensure-is-inside-popup';
|
|
10
|
+
/**
|
|
11
|
+
* __Popup trigger__
|
|
12
|
+
*
|
|
13
|
+
* Popup trigger is the component that renders the trigger for the popup.
|
|
14
|
+
*
|
|
15
|
+
* It must be a child of the Popup component.
|
|
16
|
+
*/
|
|
17
|
+
export const PopupTrigger = ({
|
|
18
|
+
children
|
|
19
|
+
}) => {
|
|
20
|
+
useEnsureIsInsidePopup();
|
|
21
|
+
const id = useContext(IdContext);
|
|
22
|
+
const setTriggerRef = useContext(SetTriggerRefContext);
|
|
23
|
+
const isOpen = useContext(IsOpenContext);
|
|
24
|
+
const getMergedTriggerRef = useGetMemoizedMergedTriggerRefNew();
|
|
25
|
+
const role = useContext(RoleContext);
|
|
26
|
+
return /*#__PURE__*/React.createElement(Reference, null, ({
|
|
27
|
+
ref
|
|
28
|
+
}) => children({
|
|
29
|
+
ref: getMergedTriggerRef(ref, setTriggerRef),
|
|
30
|
+
'aria-controls': id,
|
|
31
|
+
'aria-expanded': isOpen,
|
|
32
|
+
'aria-haspopup': role === 'dialog' && fg('platform_dst_nav4_flyout_menu_slots_close_button') ? 'dialog' : true
|
|
33
|
+
}));
|
|
34
|
+
};
|
|
@@ -1,28 +1,12 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import invariant from 'tiny-invariant';
|
|
3
|
-
import noop from '@atlaskit/ds-lib/noop';
|
|
1
|
+
import React, { useState } from 'react';
|
|
4
2
|
import { useId } from '@atlaskit/ds-lib/use-id';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import { useGetMemoizedMergedTriggerRefNew } from '../use-get-memoized-merged-trigger-ref-new';
|
|
13
|
-
const IsOpenContext = /*#__PURE__*/createContext(false);
|
|
14
|
-
const IdContext = /*#__PURE__*/createContext(undefined);
|
|
15
|
-
const TriggerRefContext = /*#__PURE__*/createContext(null);
|
|
16
|
-
const SetTriggerRefContext = /*#__PURE__*/createContext(noop);
|
|
17
|
-
const EnsureIsInsidePopupContext = /*#__PURE__*/createContext(false);
|
|
18
|
-
const RoleContext = /*#__PURE__*/createContext(undefined);
|
|
19
|
-
|
|
20
|
-
// Used to ensure popup sub-components are used within a Popup
|
|
21
|
-
// and provide a useful error message if not.
|
|
22
|
-
const useEnsureIsInsidePopup = () => {
|
|
23
|
-
const context = useContext(EnsureIsInsidePopupContext);
|
|
24
|
-
invariant(context, 'PopupTrigger and PopupContent components must be used within a Popup');
|
|
25
|
-
};
|
|
3
|
+
import { Manager } from '@atlaskit/popper';
|
|
4
|
+
import { IdContext } from './id-context';
|
|
5
|
+
import { EnsureIsInsidePopupContext } from './is-inside-popup-context';
|
|
6
|
+
import { IsOpenContext } from './is-open-context';
|
|
7
|
+
import { RoleContext } from './role-context';
|
|
8
|
+
import { SetTriggerRefContext } from './set-trigger-ref-context';
|
|
9
|
+
import { TriggerRefContext } from './trigger-ref-context';
|
|
26
10
|
/**
|
|
27
11
|
* __Popup__
|
|
28
12
|
*
|
|
@@ -64,133 +48,4 @@ export const Popup = ({
|
|
|
64
48
|
}, /*#__PURE__*/React.createElement(IsOpenContext.Provider, {
|
|
65
49
|
value: isOpen
|
|
66
50
|
}, /*#__PURE__*/React.createElement(Manager, null, children)))))));
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* __Popup trigger__
|
|
70
|
-
*
|
|
71
|
-
* Popup trigger is the component that renders the trigger for the popup.
|
|
72
|
-
*
|
|
73
|
-
* It must be a child of the Popup component.
|
|
74
|
-
*/
|
|
75
|
-
export const PopupTrigger = ({
|
|
76
|
-
children
|
|
77
|
-
}) => {
|
|
78
|
-
useEnsureIsInsidePopup();
|
|
79
|
-
const id = useContext(IdContext);
|
|
80
|
-
const setTriggerRef = useContext(SetTriggerRefContext);
|
|
81
|
-
const isOpen = useContext(IsOpenContext);
|
|
82
|
-
const getMergedTriggerRef = useGetMemoizedMergedTriggerRefNew();
|
|
83
|
-
const role = useContext(RoleContext);
|
|
84
|
-
return /*#__PURE__*/React.createElement(Reference, null, ({
|
|
85
|
-
ref
|
|
86
|
-
}) => children({
|
|
87
|
-
ref: getMergedTriggerRef(ref, setTriggerRef),
|
|
88
|
-
'aria-controls': id,
|
|
89
|
-
'aria-expanded': isOpen,
|
|
90
|
-
'aria-haspopup': role === 'dialog' && fg('platform_dst_nav4_flyout_menu_slots_close_button') ? 'dialog' : true
|
|
91
|
-
}));
|
|
92
|
-
};
|
|
93
|
-
const defaultLayer = 400;
|
|
94
|
-
/**
|
|
95
|
-
* Disables popper.js GPU acceleration for this popup.
|
|
96
|
-
* This means only positioning will be used, without any transforms.
|
|
97
|
-
*
|
|
98
|
-
* Performance will be degraded if the popup is expected to move.
|
|
99
|
-
*/
|
|
100
|
-
const shouldDisableGpuAccelerationModifiers = [{
|
|
101
|
-
name: 'computeStyles',
|
|
102
|
-
options: {
|
|
103
|
-
gpuAcceleration: false
|
|
104
|
-
}
|
|
105
|
-
}];
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* __Popup content__
|
|
109
|
-
*
|
|
110
|
-
* Popup content is the component that renders the content of the popup.
|
|
111
|
-
*
|
|
112
|
-
* It must be a child of the Popup component.
|
|
113
|
-
*/
|
|
114
|
-
export const PopupContent = ({
|
|
115
|
-
xcss,
|
|
116
|
-
appearance: inAppearance = 'default',
|
|
117
|
-
children,
|
|
118
|
-
boundary,
|
|
119
|
-
offset,
|
|
120
|
-
strategy,
|
|
121
|
-
onClose,
|
|
122
|
-
testId,
|
|
123
|
-
rootBoundary = 'viewport',
|
|
124
|
-
shouldFlip = true,
|
|
125
|
-
placement = 'auto',
|
|
126
|
-
fallbackPlacements,
|
|
127
|
-
popupComponent,
|
|
128
|
-
autoFocus = true,
|
|
129
|
-
zIndex = defaultLayer,
|
|
130
|
-
shouldUseCaptureOnOutsideClick = false,
|
|
131
|
-
shouldRenderToParent: inShouldRenderToParent,
|
|
132
|
-
shouldDisableFocusLock = false,
|
|
133
|
-
shouldFitContainer,
|
|
134
|
-
shouldFitViewport,
|
|
135
|
-
shouldDisableGpuAcceleration = false,
|
|
136
|
-
role,
|
|
137
|
-
titleId
|
|
138
|
-
}) => {
|
|
139
|
-
useEnsureIsInsidePopup();
|
|
140
|
-
const isOpen = useContext(IsOpenContext);
|
|
141
|
-
const id = useContext(IdContext);
|
|
142
|
-
const triggerRef = useContext(TriggerRefContext);
|
|
143
|
-
const {
|
|
144
|
-
appearance,
|
|
145
|
-
shouldRenderToParent
|
|
146
|
-
} = usePopupAppearance({
|
|
147
|
-
appearance: inAppearance,
|
|
148
|
-
shouldRenderToParent: inShouldRenderToParent
|
|
149
|
-
});
|
|
150
|
-
const handleOpenLayerObserverCloseSignal = useCallback(() => {
|
|
151
|
-
onClose === null || onClose === void 0 ? void 0 : onClose(null);
|
|
152
|
-
}, [onClose]);
|
|
153
|
-
useNotifyOpenLayerObserver({
|
|
154
|
-
isOpen,
|
|
155
|
-
onClose: handleOpenLayerObserverCloseSignal,
|
|
156
|
-
type: 'popup'
|
|
157
|
-
});
|
|
158
|
-
if (!isOpen) {
|
|
159
|
-
return null;
|
|
160
|
-
}
|
|
161
|
-
const popperWrapper = /*#__PURE__*/React.createElement(Layering, {
|
|
162
|
-
isDisabled: false
|
|
163
|
-
}, /*#__PURE__*/React.createElement(PopperWrapper, {
|
|
164
|
-
xcss: xcss,
|
|
165
|
-
appearance: appearance,
|
|
166
|
-
content: children,
|
|
167
|
-
isOpen: isOpen,
|
|
168
|
-
placement: placement,
|
|
169
|
-
fallbackPlacements: fallbackPlacements,
|
|
170
|
-
boundary: boundary,
|
|
171
|
-
rootBoundary: rootBoundary,
|
|
172
|
-
shouldFlip: shouldFlip,
|
|
173
|
-
offset: offset,
|
|
174
|
-
popupComponent: popupComponent,
|
|
175
|
-
id: id,
|
|
176
|
-
testId: testId,
|
|
177
|
-
onClose: onClose,
|
|
178
|
-
autoFocus: autoFocus,
|
|
179
|
-
shouldFitContainer: shouldFitContainer,
|
|
180
|
-
shouldUseCaptureOnOutsideClick: shouldUseCaptureOnOutsideClick,
|
|
181
|
-
shouldRenderToParent: shouldRenderToParent,
|
|
182
|
-
shouldDisableFocusLock: shouldDisableFocusLock,
|
|
183
|
-
triggerRef: triggerRef,
|
|
184
|
-
strategy: strategy,
|
|
185
|
-
shouldFitViewport: shouldFitViewport,
|
|
186
|
-
modifiers: shouldDisableGpuAcceleration ? shouldDisableGpuAccelerationModifiers : undefined,
|
|
187
|
-
role: role,
|
|
188
|
-
titleId: titleId
|
|
189
|
-
}));
|
|
190
|
-
if (shouldRenderToParent) {
|
|
191
|
-
return popperWrapper;
|
|
192
|
-
}
|
|
193
|
-
return /*#__PURE__*/React.createElement(Portal, {
|
|
194
|
-
zIndex: zIndex
|
|
195
|
-
}, popperWrapper);
|
|
196
51
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import invariant from 'tiny-invariant';
|
|
3
|
+
import { EnsureIsInsidePopupContext } from './is-inside-popup-context';
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
6
|
+
export function useEnsureIsInsidePopup() {
|
|
7
|
+
const context = useContext(EnsureIsInsidePopupContext);
|
|
8
|
+
invariant(context, 'PopupTrigger and PopupContent components must be used within a Popup');
|
|
9
|
+
}
|
|
@@ -28,52 +28,52 @@ const focusRingStyles = {
|
|
|
28
28
|
};
|
|
29
29
|
const placementMap = {
|
|
30
30
|
top: {
|
|
31
|
-
enter: "var(--ds-popup-enter-top, 150ms cubic-bezier(0.4, 1, 0.6, 1)
|
|
32
|
-
exit: "var(--ds-popup-exit-top, 100ms cubic-bezier(0.6, 0, 0.8, 0.6)
|
|
31
|
+
enter: "var(--ds-popup-enter-top, 150ms cubic-bezier(0.4, 1, 0.6, 1) SlideInTop8px, 150ms cubic-bezier(0.4, 1, 0.6, 1) FadeIn0to100)",
|
|
32
|
+
exit: "var(--ds-popup-exit-top, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutTop8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
|
|
33
33
|
},
|
|
34
34
|
'top-start': {
|
|
35
|
-
enter: "var(--ds-popup-enter-top, 150ms cubic-bezier(0.4, 1, 0.6, 1)
|
|
36
|
-
exit: "var(--ds-popup-exit-top, 100ms cubic-bezier(0.6, 0, 0.8, 0.6)
|
|
35
|
+
enter: "var(--ds-popup-enter-top, 150ms cubic-bezier(0.4, 1, 0.6, 1) SlideInTop8px, 150ms cubic-bezier(0.4, 1, 0.6, 1) FadeIn0to100)",
|
|
36
|
+
exit: "var(--ds-popup-exit-top, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutTop8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
|
|
37
37
|
},
|
|
38
38
|
'top-end': {
|
|
39
|
-
enter: "var(--ds-popup-enter-top, 150ms cubic-bezier(0.4, 1, 0.6, 1)
|
|
40
|
-
exit: "var(--ds-popup-exit-top, 100ms cubic-bezier(0.6, 0, 0.8, 0.6)
|
|
39
|
+
enter: "var(--ds-popup-enter-top, 150ms cubic-bezier(0.4, 1, 0.6, 1) SlideInTop8px, 150ms cubic-bezier(0.4, 1, 0.6, 1) FadeIn0to100)",
|
|
40
|
+
exit: "var(--ds-popup-exit-top, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutTop8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
|
|
41
41
|
},
|
|
42
42
|
bottom: {
|
|
43
|
-
enter: "var(--ds-popup-enter-bottom, 150ms cubic-bezier(0.4, 1, 0.6, 1)
|
|
44
|
-
exit: "var(--ds-popup-exit-bottom, 100ms cubic-bezier(0.6, 0, 0.8, 0.6)
|
|
43
|
+
enter: "var(--ds-popup-enter-bottom, 150ms cubic-bezier(0.4, 1, 0.6, 1) SlideInBottom8px, 150ms cubic-bezier(0.4, 1, 0.6, 1) FadeIn0to100)",
|
|
44
|
+
exit: "var(--ds-popup-exit-bottom, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutBottom8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
|
|
45
45
|
},
|
|
46
46
|
'bottom-start': {
|
|
47
|
-
enter: "var(--ds-popup-enter-bottom, 150ms cubic-bezier(0.4, 1, 0.6, 1)
|
|
48
|
-
exit: "var(--ds-popup-exit-bottom, 100ms cubic-bezier(0.6, 0, 0.8, 0.6)
|
|
47
|
+
enter: "var(--ds-popup-enter-bottom, 150ms cubic-bezier(0.4, 1, 0.6, 1) SlideInBottom8px, 150ms cubic-bezier(0.4, 1, 0.6, 1) FadeIn0to100)",
|
|
48
|
+
exit: "var(--ds-popup-exit-bottom, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutBottom8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
|
|
49
49
|
},
|
|
50
50
|
'bottom-end': {
|
|
51
|
-
enter: "var(--ds-popup-enter-bottom, 150ms cubic-bezier(0.4, 1, 0.6, 1)
|
|
52
|
-
exit: "var(--ds-popup-exit-bottom, 100ms cubic-bezier(0.6, 0, 0.8, 0.6)
|
|
51
|
+
enter: "var(--ds-popup-enter-bottom, 150ms cubic-bezier(0.4, 1, 0.6, 1) SlideInBottom8px, 150ms cubic-bezier(0.4, 1, 0.6, 1) FadeIn0to100)",
|
|
52
|
+
exit: "var(--ds-popup-exit-bottom, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutBottom8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
|
|
53
53
|
},
|
|
54
54
|
left: {
|
|
55
|
-
enter: "var(--ds-popup-enter-left, 150ms cubic-bezier(0.4, 1, 0.6, 1)
|
|
56
|
-
exit: "var(--ds-popup-exit-left, 100ms cubic-bezier(0.6, 0, 0.8, 0.6)
|
|
55
|
+
enter: "var(--ds-popup-enter-left, 150ms cubic-bezier(0.4, 1, 0.6, 1) SlideInLeft8px, 150ms cubic-bezier(0.4, 1, 0.6, 1) FadeIn0to100)",
|
|
56
|
+
exit: "var(--ds-popup-exit-left, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutLeft8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
|
|
57
57
|
},
|
|
58
58
|
'left-start': {
|
|
59
|
-
enter: "var(--ds-popup-enter-left, 150ms cubic-bezier(0.4, 1, 0.6, 1)
|
|
60
|
-
exit: "var(--ds-popup-exit-left, 100ms cubic-bezier(0.6, 0, 0.8, 0.6)
|
|
59
|
+
enter: "var(--ds-popup-enter-left, 150ms cubic-bezier(0.4, 1, 0.6, 1) SlideInLeft8px, 150ms cubic-bezier(0.4, 1, 0.6, 1) FadeIn0to100)",
|
|
60
|
+
exit: "var(--ds-popup-exit-left, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutLeft8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
|
|
61
61
|
},
|
|
62
62
|
'left-end': {
|
|
63
|
-
enter: "var(--ds-popup-enter-left, 150ms cubic-bezier(0.4, 1, 0.6, 1)
|
|
64
|
-
exit: "var(--ds-popup-exit-left, 100ms cubic-bezier(0.6, 0, 0.8, 0.6)
|
|
63
|
+
enter: "var(--ds-popup-enter-left, 150ms cubic-bezier(0.4, 1, 0.6, 1) SlideInLeft8px, 150ms cubic-bezier(0.4, 1, 0.6, 1) FadeIn0to100)",
|
|
64
|
+
exit: "var(--ds-popup-exit-left, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutLeft8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
|
|
65
65
|
},
|
|
66
66
|
right: {
|
|
67
|
-
enter: "var(--ds-popup-enter-right, 150ms cubic-bezier(0.4, 1, 0.6, 1)
|
|
68
|
-
exit: "var(--ds-popup-exit-right, 100ms cubic-bezier(0.6, 0, 0.8, 0.6)
|
|
67
|
+
enter: "var(--ds-popup-enter-right, 150ms cubic-bezier(0.4, 1, 0.6, 1) SlideInRight8px, 150ms cubic-bezier(0.4, 1, 0.6, 1) FadeIn0to100)",
|
|
68
|
+
exit: "var(--ds-popup-exit-right, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutRight8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
|
|
69
69
|
},
|
|
70
70
|
'right-start': {
|
|
71
|
-
enter: "var(--ds-popup-enter-right, 150ms cubic-bezier(0.4, 1, 0.6, 1)
|
|
72
|
-
exit: "var(--ds-popup-exit-right, 100ms cubic-bezier(0.6, 0, 0.8, 0.6)
|
|
71
|
+
enter: "var(--ds-popup-enter-right, 150ms cubic-bezier(0.4, 1, 0.6, 1) SlideInRight8px, 150ms cubic-bezier(0.4, 1, 0.6, 1) FadeIn0to100)",
|
|
72
|
+
exit: "var(--ds-popup-exit-right, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutRight8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
|
|
73
73
|
},
|
|
74
74
|
'right-end': {
|
|
75
|
-
enter: "var(--ds-popup-enter-right, 150ms cubic-bezier(0.4, 1, 0.6, 1)
|
|
76
|
-
exit: "var(--ds-popup-exit-right, 100ms cubic-bezier(0.6, 0, 0.8, 0.6)
|
|
75
|
+
enter: "var(--ds-popup-enter-right, 150ms cubic-bezier(0.4, 1, 0.6, 1) SlideInRight8px, 150ms cubic-bezier(0.4, 1, 0.6, 1) FadeIn0to100)",
|
|
76
|
+
exit: "var(--ds-popup-exit-right, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutRight8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
79
|
const DefaultPopupComponent = /*#__PURE__*/forwardRef((props, ref) => {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
|
|
3
|
+
// TODO: Fill in the component {description} and ensure links point to the correct {packageName} location.
|
|
4
|
+
// Remove links that the component does not have (such as usage). If there are no links remove them all.
|
|
5
|
+
/**
|
|
6
|
+
* __Ensure is inside popup context__
|
|
7
|
+
*
|
|
8
|
+
* An ensure is inside popup context {description}.
|
|
9
|
+
*
|
|
10
|
+
* - [Examples](https://atlassian.design/components/{packageName}/examples)
|
|
11
|
+
* - [Code](https://atlassian.design/components/{packageName}/code)
|
|
12
|
+
* - [Usage](https://atlassian.design/components/{packageName}/usage)
|
|
13
|
+
*/
|
|
14
|
+
export var EnsureIsInsidePopupContext = /*#__PURE__*/createContext(false);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
|
|
3
|
+
// TODO: Fill in the component {description} and ensure links point to the correct {packageName} location.
|
|
4
|
+
// Remove links that the component does not have (such as usage). If there are no links remove them all.
|
|
5
|
+
/**
|
|
6
|
+
* __Is open context__
|
|
7
|
+
*
|
|
8
|
+
* An is open context {description}.
|
|
9
|
+
*
|
|
10
|
+
* - [Examples](https://atlassian.design/components/{packageName}/examples)
|
|
11
|
+
* - [Code](https://atlassian.design/components/{packageName}/code)
|
|
12
|
+
* - [Usage](https://atlassian.design/components/{packageName}/usage)
|
|
13
|
+
*/
|
|
14
|
+
export var IsOpenContext = /*#__PURE__*/createContext(false);
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import React, { useCallback, useContext } from 'react';
|
|
2
|
+
import { Layering } from '@atlaskit/layering';
|
|
3
|
+
import { useNotifyOpenLayerObserver } from '@atlaskit/layering/experimental/open-layer-observer';
|
|
4
|
+
import Portal from '@atlaskit/portal';
|
|
5
|
+
import PopperWrapper from '../popper-wrapper';
|
|
6
|
+
import { usePopupAppearance } from '../use-appearance';
|
|
7
|
+
import { IdContext } from './id-context';
|
|
8
|
+
import { IsOpenContext } from './is-open-context';
|
|
9
|
+
import { TriggerRefContext } from './trigger-ref-context';
|
|
10
|
+
import { useEnsureIsInsidePopup } from './use-ensure-is-inside-popup';
|
|
11
|
+
var defaultLayer = 400;
|
|
12
|
+
var shouldDisableGpuAccelerationModifiers = [{
|
|
13
|
+
name: 'computeStyles',
|
|
14
|
+
options: {
|
|
15
|
+
gpuAcceleration: false
|
|
16
|
+
}
|
|
17
|
+
}];
|
|
18
|
+
/**
|
|
19
|
+
* __Popup content__
|
|
20
|
+
*
|
|
21
|
+
* Popup content is the component that renders the content of the popup.
|
|
22
|
+
*
|
|
23
|
+
* It must be a child of the Popup component.
|
|
24
|
+
*/
|
|
25
|
+
export var PopupContent = function PopupContent(_ref) {
|
|
26
|
+
var xcss = _ref.xcss,
|
|
27
|
+
_ref$appearance = _ref.appearance,
|
|
28
|
+
inAppearance = _ref$appearance === void 0 ? 'default' : _ref$appearance,
|
|
29
|
+
children = _ref.children,
|
|
30
|
+
boundary = _ref.boundary,
|
|
31
|
+
offset = _ref.offset,
|
|
32
|
+
strategy = _ref.strategy,
|
|
33
|
+
onClose = _ref.onClose,
|
|
34
|
+
testId = _ref.testId,
|
|
35
|
+
_ref$rootBoundary = _ref.rootBoundary,
|
|
36
|
+
rootBoundary = _ref$rootBoundary === void 0 ? 'viewport' : _ref$rootBoundary,
|
|
37
|
+
_ref$shouldFlip = _ref.shouldFlip,
|
|
38
|
+
shouldFlip = _ref$shouldFlip === void 0 ? true : _ref$shouldFlip,
|
|
39
|
+
_ref$placement = _ref.placement,
|
|
40
|
+
placement = _ref$placement === void 0 ? 'auto' : _ref$placement,
|
|
41
|
+
fallbackPlacements = _ref.fallbackPlacements,
|
|
42
|
+
popupComponent = _ref.popupComponent,
|
|
43
|
+
_ref$autoFocus = _ref.autoFocus,
|
|
44
|
+
autoFocus = _ref$autoFocus === void 0 ? true : _ref$autoFocus,
|
|
45
|
+
_ref$zIndex = _ref.zIndex,
|
|
46
|
+
zIndex = _ref$zIndex === void 0 ? defaultLayer : _ref$zIndex,
|
|
47
|
+
_ref$shouldUseCapture = _ref.shouldUseCaptureOnOutsideClick,
|
|
48
|
+
shouldUseCaptureOnOutsideClick = _ref$shouldUseCapture === void 0 ? false : _ref$shouldUseCapture,
|
|
49
|
+
inShouldRenderToParent = _ref.shouldRenderToParent,
|
|
50
|
+
_ref$shouldDisableFoc = _ref.shouldDisableFocusLock,
|
|
51
|
+
shouldDisableFocusLock = _ref$shouldDisableFoc === void 0 ? false : _ref$shouldDisableFoc,
|
|
52
|
+
shouldFitContainer = _ref.shouldFitContainer,
|
|
53
|
+
shouldFitViewport = _ref.shouldFitViewport,
|
|
54
|
+
_ref$shouldDisableGpu = _ref.shouldDisableGpuAcceleration,
|
|
55
|
+
shouldDisableGpuAcceleration = _ref$shouldDisableGpu === void 0 ? false : _ref$shouldDisableGpu,
|
|
56
|
+
role = _ref.role,
|
|
57
|
+
titleId = _ref.titleId;
|
|
58
|
+
useEnsureIsInsidePopup();
|
|
59
|
+
var isOpen = useContext(IsOpenContext);
|
|
60
|
+
var id = useContext(IdContext);
|
|
61
|
+
var triggerRef = useContext(TriggerRefContext);
|
|
62
|
+
var _usePopupAppearance = usePopupAppearance({
|
|
63
|
+
appearance: inAppearance,
|
|
64
|
+
shouldRenderToParent: inShouldRenderToParent
|
|
65
|
+
}),
|
|
66
|
+
appearance = _usePopupAppearance.appearance,
|
|
67
|
+
shouldRenderToParent = _usePopupAppearance.shouldRenderToParent;
|
|
68
|
+
var handleOpenLayerObserverCloseSignal = useCallback(function () {
|
|
69
|
+
onClose === null || onClose === void 0 || onClose(null);
|
|
70
|
+
}, [onClose]);
|
|
71
|
+
useNotifyOpenLayerObserver({
|
|
72
|
+
isOpen: isOpen,
|
|
73
|
+
onClose: handleOpenLayerObserverCloseSignal,
|
|
74
|
+
type: 'popup'
|
|
75
|
+
});
|
|
76
|
+
if (!isOpen) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
var popperWrapper = /*#__PURE__*/React.createElement(Layering, {
|
|
80
|
+
isDisabled: false
|
|
81
|
+
}, /*#__PURE__*/React.createElement(PopperWrapper, {
|
|
82
|
+
xcss: xcss,
|
|
83
|
+
appearance: appearance,
|
|
84
|
+
content: children,
|
|
85
|
+
isOpen: isOpen,
|
|
86
|
+
placement: placement,
|
|
87
|
+
fallbackPlacements: fallbackPlacements,
|
|
88
|
+
boundary: boundary,
|
|
89
|
+
rootBoundary: rootBoundary,
|
|
90
|
+
shouldFlip: shouldFlip,
|
|
91
|
+
offset: offset,
|
|
92
|
+
popupComponent: popupComponent,
|
|
93
|
+
id: id,
|
|
94
|
+
testId: testId,
|
|
95
|
+
onClose: onClose,
|
|
96
|
+
autoFocus: autoFocus,
|
|
97
|
+
shouldFitContainer: shouldFitContainer,
|
|
98
|
+
shouldUseCaptureOnOutsideClick: shouldUseCaptureOnOutsideClick,
|
|
99
|
+
shouldRenderToParent: shouldRenderToParent,
|
|
100
|
+
shouldDisableFocusLock: shouldDisableFocusLock,
|
|
101
|
+
triggerRef: triggerRef,
|
|
102
|
+
strategy: strategy,
|
|
103
|
+
shouldFitViewport: shouldFitViewport,
|
|
104
|
+
modifiers: shouldDisableGpuAcceleration ? shouldDisableGpuAccelerationModifiers : undefined,
|
|
105
|
+
role: role,
|
|
106
|
+
titleId: titleId
|
|
107
|
+
}));
|
|
108
|
+
if (shouldRenderToParent) {
|
|
109
|
+
return popperWrapper;
|
|
110
|
+
}
|
|
111
|
+
return /*#__PURE__*/React.createElement(Portal, {
|
|
112
|
+
zIndex: zIndex
|
|
113
|
+
}, popperWrapper);
|
|
114
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
|
+
import { Reference } from '@atlaskit/popper';
|
|
4
|
+
import { useGetMemoizedMergedTriggerRefNew } from '../use-get-memoized-merged-trigger-ref-new';
|
|
5
|
+
import { IdContext } from './id-context';
|
|
6
|
+
import { IsOpenContext } from './is-open-context';
|
|
7
|
+
import { RoleContext } from './role-context';
|
|
8
|
+
import { SetTriggerRefContext } from './set-trigger-ref-context';
|
|
9
|
+
import { useEnsureIsInsidePopup } from './use-ensure-is-inside-popup';
|
|
10
|
+
/**
|
|
11
|
+
* __Popup trigger__
|
|
12
|
+
*
|
|
13
|
+
* Popup trigger is the component that renders the trigger for the popup.
|
|
14
|
+
*
|
|
15
|
+
* It must be a child of the Popup component.
|
|
16
|
+
*/
|
|
17
|
+
export var PopupTrigger = function PopupTrigger(_ref) {
|
|
18
|
+
var children = _ref.children;
|
|
19
|
+
useEnsureIsInsidePopup();
|
|
20
|
+
var id = useContext(IdContext);
|
|
21
|
+
var setTriggerRef = useContext(SetTriggerRefContext);
|
|
22
|
+
var isOpen = useContext(IsOpenContext);
|
|
23
|
+
var getMergedTriggerRef = useGetMemoizedMergedTriggerRefNew();
|
|
24
|
+
var role = useContext(RoleContext);
|
|
25
|
+
return /*#__PURE__*/React.createElement(Reference, null, function (_ref2) {
|
|
26
|
+
var ref = _ref2.ref;
|
|
27
|
+
return children({
|
|
28
|
+
ref: getMergedTriggerRef(ref, setTriggerRef),
|
|
29
|
+
'aria-controls': id,
|
|
30
|
+
'aria-expanded': isOpen,
|
|
31
|
+
'aria-haspopup': role === 'dialog' && fg('platform_dst_nav4_flyout_menu_slots_close_button') ? 'dialog' : true
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
};
|