@atlaskit/top-layer 1.6.0 → 1.6.1
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 +8 -0
- package/compass.yml +10 -1
- package/dist/cjs/dialog/dialog-content.compiled.css +0 -10
- package/dist/cjs/dialog/dialog-content.js +5 -28
- package/dist/cjs/entry-points/animations.js +1 -49
- package/dist/cjs/internal/use-animated-visibility.js +14 -17
- package/dist/cjs/popover/animations.js +1 -147
- package/dist/cjs/popover/popover.compiled.css +0 -10
- package/dist/cjs/popover/popover.js +8 -11
- package/dist/cjs/testing/polyfill.js +3 -0
- package/dist/es2019/dialog/dialog-content.compiled.css +0 -10
- package/dist/es2019/dialog/dialog-content.js +4 -28
- package/dist/es2019/entry-points/animations.js +0 -2
- package/dist/es2019/internal/use-animated-visibility.js +14 -18
- package/dist/es2019/popover/animations.js +1 -145
- package/dist/es2019/popover/popover.compiled.css +0 -10
- package/dist/es2019/popover/popover.js +7 -11
- package/dist/es2019/testing/polyfill.js +3 -0
- package/dist/esm/dialog/dialog-content.compiled.css +0 -10
- package/dist/esm/dialog/dialog-content.js +5 -28
- package/dist/esm/entry-points/animations.js +0 -2
- package/dist/esm/internal/use-animated-visibility.js +14 -18
- package/dist/esm/popover/animations.js +1 -144
- package/dist/esm/popover/popover.compiled.css +0 -10
- package/dist/esm/popover/popover.js +8 -11
- package/dist/esm/testing/polyfill.js +3 -0
- package/dist/types/dialog/types.d.ts +5 -5
- package/dist/types/entry-points/animations.d.ts +0 -2
- package/dist/types/internal/use-animated-visibility.d.ts +15 -33
- package/dist/types/popover/animations.d.ts +7 -52
- package/dist/types/popover/types.d.ts +6 -3
- package/package.json +4 -4
- package/dist/cjs/dialog/animations.js +0 -90
- package/dist/es2019/dialog/animations.js +0 -80
- package/dist/esm/dialog/animations.js +0 -82
- package/dist/types/dialog/animations.d.ts +0 -57
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
2
2
|
import { bind, bindAll } from 'bind-event-listener';
|
|
3
3
|
import { prefersReducedMotion } from './reduced-motion';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* A self-contained animation preset for top-layer elements.
|
|
7
|
-
*
|
|
8
|
-
* Contains a stable preset name used by the host component to select its
|
|
9
|
-
* component-local Compiled style entry, plus optional per-placement inline
|
|
10
|
-
* styles.
|
|
11
|
-
*
|
|
12
|
-
* The actual Compiled styles are kept static and component-local so the
|
|
13
|
-
* Compiled transform can extract them at build time.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
4
|
/**
|
|
17
5
|
* Using the recommended motion timings for safety net.
|
|
18
6
|
*
|
|
@@ -72,6 +60,13 @@ function runOnTransitionEndOrTimeout({
|
|
|
72
60
|
return teardown;
|
|
73
61
|
}
|
|
74
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Animation config for entry/exit transitions.
|
|
65
|
+
*
|
|
66
|
+
* Currently no configuration is supported via this prop,
|
|
67
|
+
* and this is just a placeholder.
|
|
68
|
+
*/
|
|
69
|
+
|
|
75
70
|
/**
|
|
76
71
|
* Visibility lifecycle phase shared between `useAnimatedVisibility`,
|
|
77
72
|
* `useFocusWrap`, `useInitialFocus`, and the `Popover` / `Dialog`
|
|
@@ -135,6 +130,7 @@ function runOnTransitionEndOrTimeout({
|
|
|
135
130
|
*/
|
|
136
131
|
export function useAnimatedVisibility({
|
|
137
132
|
isOpen,
|
|
133
|
+
animationKind,
|
|
138
134
|
animate,
|
|
139
135
|
elementRef,
|
|
140
136
|
onEnterFinish,
|
|
@@ -186,7 +182,7 @@ export function useAnimatedVisibility({
|
|
|
186
182
|
// move to `open`. The fallback guarantees settle on swallowed events
|
|
187
183
|
// (zero-duration, browser quirk, mid-transition unmount).
|
|
188
184
|
useEffect(() => {
|
|
189
|
-
if (phase !== 'entering'
|
|
185
|
+
if (phase !== 'entering') {
|
|
190
186
|
return;
|
|
191
187
|
}
|
|
192
188
|
const element = elementRef.current;
|
|
@@ -195,7 +191,7 @@ export function useAnimatedVisibility({
|
|
|
195
191
|
}
|
|
196
192
|
return runOnTransitionEndOrTimeout({
|
|
197
193
|
element,
|
|
198
|
-
safetyNetMs: safetyNetMsMap[
|
|
194
|
+
safetyNetMs: safetyNetMsMap[animationKind].enter + 50,
|
|
199
195
|
onSettled: () => {
|
|
200
196
|
var _onEnterFinishRef$cur;
|
|
201
197
|
// Fire the consumer callback before transitioning phase so any
|
|
@@ -206,7 +202,7 @@ export function useAnimatedVisibility({
|
|
|
206
202
|
setPhase(current => current === 'entering' ? 'open' : current);
|
|
207
203
|
}
|
|
208
204
|
});
|
|
209
|
-
}, [phase,
|
|
205
|
+
}, [phase, animationKind, elementRef]);
|
|
210
206
|
|
|
211
207
|
// Non-animated entry callback. The lifecycle goes `closed → open`
|
|
212
208
|
// directly with no `entering` phase; fire `onEnterFinish` on that jump.
|
|
@@ -227,7 +223,7 @@ export function useAnimatedVisibility({
|
|
|
227
223
|
// Animated exit: wait for `transitionend` (or a safety-net timeout),
|
|
228
224
|
// fire `onExitFinish`, then move to `closed` to unmount the host.
|
|
229
225
|
useEffect(() => {
|
|
230
|
-
if (phase !== 'exiting' || !willAnimate
|
|
226
|
+
if (phase !== 'exiting' || !willAnimate) {
|
|
231
227
|
return;
|
|
232
228
|
}
|
|
233
229
|
const element = elementRef.current;
|
|
@@ -236,7 +232,7 @@ export function useAnimatedVisibility({
|
|
|
236
232
|
}
|
|
237
233
|
return runOnTransitionEndOrTimeout({
|
|
238
234
|
element,
|
|
239
|
-
safetyNetMs: safetyNetMsMap[
|
|
235
|
+
safetyNetMs: safetyNetMsMap[animationKind].exit + 50,
|
|
240
236
|
onSettled: () => {
|
|
241
237
|
var _onExitFinishRef$curr;
|
|
242
238
|
// Fire the consumer callback before transitioning phase to
|
|
@@ -249,7 +245,7 @@ export function useAnimatedVisibility({
|
|
|
249
245
|
setPhase(current => current === 'exiting' ? 'closed' : current);
|
|
250
246
|
}
|
|
251
247
|
});
|
|
252
|
-
}, [phase, willAnimate,
|
|
248
|
+
}, [phase, willAnimate, animationKind, elementRef]);
|
|
253
249
|
|
|
254
250
|
// Non-animated exit: wait for the browser's `toggle` (closed) or
|
|
255
251
|
// `close` event before unmounting, so the consumer's listener (close
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getPlacement } from '../internal/resolve-placement';
|
|
2
|
-
function getPopupMotionStyles({
|
|
2
|
+
export function getPopupMotionStyles({
|
|
3
3
|
placement
|
|
4
4
|
}) {
|
|
5
5
|
const {
|
|
@@ -43,148 +43,4 @@ function getPopupMotionStyles({
|
|
|
43
43
|
property: '--ds-popover-motion-exit',
|
|
44
44
|
value: "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
|
-
}
|
|
47
|
-
|
|
48
|
-
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
49
|
-
export function popupMotion() {
|
|
50
|
-
return {
|
|
51
|
-
kind: 'popover',
|
|
52
|
-
name: 'motion',
|
|
53
|
-
getStyles: getPopupMotionStyles
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
function getSlideAndFadeStyles({
|
|
57
|
-
placement,
|
|
58
|
-
distance
|
|
59
|
-
}) {
|
|
60
|
-
const pos = `${distance}px`;
|
|
61
|
-
const neg = `-${distance}px`;
|
|
62
|
-
const {
|
|
63
|
-
axis,
|
|
64
|
-
edge
|
|
65
|
-
} = getPlacement({
|
|
66
|
-
placement
|
|
67
|
-
});
|
|
68
|
-
if (axis === 'block' && edge === 'start') {
|
|
69
|
-
return [{
|
|
70
|
-
property: '--ds-popover-tx',
|
|
71
|
-
value: '0'
|
|
72
|
-
}, {
|
|
73
|
-
property: '--ds-popover-ty',
|
|
74
|
-
value: pos
|
|
75
|
-
}];
|
|
76
|
-
}
|
|
77
|
-
if (axis === 'block' && edge === 'end') {
|
|
78
|
-
return [{
|
|
79
|
-
property: '--ds-popover-tx',
|
|
80
|
-
value: '0'
|
|
81
|
-
}, {
|
|
82
|
-
property: '--ds-popover-ty',
|
|
83
|
-
value: neg
|
|
84
|
-
}];
|
|
85
|
-
}
|
|
86
|
-
if (axis === 'inline' && edge === 'start') {
|
|
87
|
-
return [{
|
|
88
|
-
property: '--ds-popover-tx',
|
|
89
|
-
value: pos
|
|
90
|
-
}, {
|
|
91
|
-
property: '--ds-popover-ty',
|
|
92
|
-
value: '0'
|
|
93
|
-
}];
|
|
94
|
-
}
|
|
95
|
-
if (axis === 'inline' && edge === 'end') {
|
|
96
|
-
return [{
|
|
97
|
-
property: '--ds-popover-tx',
|
|
98
|
-
value: neg
|
|
99
|
-
}, {
|
|
100
|
-
property: '--ds-popover-ty',
|
|
101
|
-
value: '0'
|
|
102
|
-
}];
|
|
103
|
-
}
|
|
104
|
-
return [{
|
|
105
|
-
property: '--ds-popover-tx',
|
|
106
|
-
value: '0'
|
|
107
|
-
}, {
|
|
108
|
-
property: '--ds-popover-ty',
|
|
109
|
-
value: neg
|
|
110
|
-
}];
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Directional slide + opacity animation.
|
|
115
|
-
*
|
|
116
|
-
* The popover slides in from the direction opposite its placement edge
|
|
117
|
-
* (e.g. a `block-end` popover slides down from above).
|
|
118
|
-
*
|
|
119
|
-
* @param options.distance - Slide distance in pixels. Defaults to `4`.
|
|
120
|
-
*
|
|
121
|
-
* @example
|
|
122
|
-
* ```tsx
|
|
123
|
-
* import { slideAndFade } from '@atlaskit/top-layer/animations';
|
|
124
|
-
*
|
|
125
|
-
* // Default 4px slide (tooltip)
|
|
126
|
-
* <Popover animate={slideAndFade()} />
|
|
127
|
-
*
|
|
128
|
-
* // Custom 8px slide (popup / dropdown)
|
|
129
|
-
* <Popover animate={slideAndFade({ distance: 8 })} />
|
|
130
|
-
* ```
|
|
131
|
-
*/
|
|
132
|
-
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
133
|
-
export function slideAndFade(options) {
|
|
134
|
-
var _options$distance;
|
|
135
|
-
const distance = (_options$distance = options === null || options === void 0 ? void 0 : options.distance) !== null && _options$distance !== void 0 ? _options$distance : 4;
|
|
136
|
-
return {
|
|
137
|
-
kind: 'popover',
|
|
138
|
-
name: 'slide-and-fade',
|
|
139
|
-
getStyles: ({
|
|
140
|
-
placement
|
|
141
|
-
}) => getSlideAndFadeStyles({
|
|
142
|
-
placement,
|
|
143
|
-
distance
|
|
144
|
-
})
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// fade
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Simple opacity transition, no transform.
|
|
152
|
-
*
|
|
153
|
-
* Suitable for popup dialogs or content that does not need directional motion.
|
|
154
|
-
*
|
|
155
|
-
* @example
|
|
156
|
-
* ```tsx
|
|
157
|
-
* import { fade } from '@atlaskit/top-layer/animations';
|
|
158
|
-
*
|
|
159
|
-
* <Popover animate={fade()} />
|
|
160
|
-
* ```
|
|
161
|
-
*/
|
|
162
|
-
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
163
|
-
export function fade() {
|
|
164
|
-
return {
|
|
165
|
-
kind: 'popover',
|
|
166
|
-
name: 'fade'
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// scaleAndFade
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Scale from 0.95 + opacity transition.
|
|
174
|
-
*
|
|
175
|
-
* Suitable for menus, dropdowns, and select options.
|
|
176
|
-
*
|
|
177
|
-
* @example
|
|
178
|
-
* ```tsx
|
|
179
|
-
* import { scaleAndFade } from '@atlaskit/top-layer/animations';
|
|
180
|
-
*
|
|
181
|
-
* <Popover animate={scaleAndFade()} />
|
|
182
|
-
* ```
|
|
183
|
-
*/
|
|
184
|
-
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
185
|
-
export function scaleAndFade() {
|
|
186
|
-
return {
|
|
187
|
-
kind: 'popover',
|
|
188
|
-
name: 'scale-and-fade'
|
|
189
|
-
};
|
|
190
46
|
}
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
._18u0idpf{margin-left:0}
|
|
8
8
|
._19bvidpf{padding-left:0}
|
|
9
9
|
._19pkidpf{margin-top:0}
|
|
10
|
-
._1a5xt94y{--dir:1px}
|
|
11
10
|
._1o51q7pw{animation-fill-mode:forwards}
|
|
12
11
|
._1oecdn4k{transition-duration:var(--ds-duration-xshort,.1s)}
|
|
13
12
|
._1pgl1lbj{animation-timing-function:var(--ds-easing-in-practical,cubic-bezier(.6,0,.8,.6))}
|
|
@@ -16,21 +15,12 @@
|
|
|
16
15
|
._1s9z1a5r{transition-behavior:allow-discrete}
|
|
17
16
|
._2hwxidpf{margin-right:0}
|
|
18
17
|
._5sagdn4k{animation-duration:var(--ds-duration-xshort,.1s)}
|
|
19
|
-
._71re1bym:popover-open{animation-name:var(--ds-keyframe-fade-in,FadeIn0to100)}
|
|
20
|
-
._71re1v6b:popover-open{animation-name:var(--ds-keyframe-fade-in,FadeIn0to100),var(--ds-keyframe-scale-in-small,ScaleIn95to100)}
|
|
21
|
-
._71rervlo:popover-open{animation-name:k1ut9kob,var(--ds-keyframe-fade-in,FadeIn0to100)}
|
|
22
18
|
._bfhk1j28{background-color:transparent}
|
|
23
19
|
._ca0qidpf{padding-top:0}
|
|
24
|
-
._j7hq1a5s{animation-name:var(--ds-keyframe-fade-out,FadeOut100to0)}
|
|
25
|
-
._j7hq1l2h{animation-name:k1e4c1ew,var(--ds-keyframe-fade-out,FadeOut100to0)}
|
|
26
|
-
._j7hqneez{animation-name:var(--ds-keyframe-fade-out,FadeOut100to0),var(--ds-keyframe-scale-out-small,ScaleOut100to95)}
|
|
27
20
|
._k8m011k7{transition-property:overlay,display}
|
|
28
21
|
._n3tdidpf{padding-bottom:0}
|
|
29
22
|
._n70peoah:popover-open{animation-fill-mode:backwards}
|
|
30
23
|
._o8i7indk:popover-open{animation-timing-function:var(--ds-easing-out-practical,cubic-bezier(.4,1,.6,1))}
|
|
31
24
|
._otyridpf{margin-bottom:0}
|
|
32
25
|
._u5f3idpf{padding-right:0}
|
|
33
|
-
[dir=rtl] ._34bx1n1a{--dir:-1px}
|
|
34
|
-
@keyframes k1e4c1ew{0%{transform:none}to{transform:translate(calc(var(--dir)*var(--ds-popover-tx, 0)),var(--ds-popover-ty,0))}}
|
|
35
|
-
@keyframes k1ut9kob{0%{transform:translate(calc(var(--dir)*var(--ds-popover-tx, 0)),var(--ds-popover-ty,0))}to{transform:none}}
|
|
36
26
|
@media (prefers-reduced-motion:reduce){._bl8aglyw{animation-name:none}._156yru3m{transition-duration:0s}._8rmvglyw:popover-open{animation-name:none}._2qm2ru3m:popover-open{transition-duration:0s}}
|
|
@@ -11,6 +11,7 @@ import { setStyle } from '../internal/set-style';
|
|
|
11
11
|
import { useAnimatedVisibility } from '../internal/use-animated-visibility';
|
|
12
12
|
import { useFocusWrap } from '../internal/use-focus-wrap';
|
|
13
13
|
import { useInitialFocus } from '../internal/use-initial-focus';
|
|
14
|
+
import { getPopupMotionStyles } from './animations';
|
|
14
15
|
/**
|
|
15
16
|
* Detects `popover="hint"` support via DOM reflection. SSR-safe, cached.
|
|
16
17
|
*/
|
|
@@ -23,19 +24,13 @@ const supportsPopoverHint = once(() => {
|
|
|
23
24
|
element.setAttribute('popover', 'hint');
|
|
24
25
|
return element.popover === 'hint';
|
|
25
26
|
});
|
|
26
|
-
const slideInKeyframes = null;
|
|
27
|
-
const slideOutKeyframes = null;
|
|
28
27
|
|
|
29
28
|
// These animation styles use the non-strict Compiled cssMap because they rely
|
|
30
29
|
// on `@starting-style`, `:popover-open`, `[dir='rtl']`, and `allow-discrete`.
|
|
31
30
|
// Keep them in this component so the Compiled transform can statically extract
|
|
32
31
|
// every referenced style.
|
|
33
32
|
const popoverAnimationStyles = {
|
|
34
|
-
root: "_k8m011k7 _1oecdn4k _1s9z1a5r
|
|
35
|
-
motion: "_y44vof1f _1o51q7pw _15ns179n _n70peoah",
|
|
36
|
-
'slide-and-fade': "_j7hq1l2h _5sagdn4k _1pgl1lbj _71rervlo _1psg1ign _o8i7indk",
|
|
37
|
-
fade: "_j7hq1a5s _5sagdn4k _1pgl1lbj _71re1bym _1psg1ign _o8i7indk",
|
|
38
|
-
'scale-and-fade': "_j7hqneez _5sagdn4k _1pgl1lbj _71re1v6b _1psg1ign _o8i7indk"
|
|
33
|
+
root: "_y44vof1f _k8m011k7 _1oecdn4k _1s9z1a5r _1o51q7pw _5sagdn4k _1pgl1lbj _15ns179n _12t71ign _n70peoah _1psg1ign _o8i7indk _bl8aglyw _156yru3m _8rmvglyw _2qm2ru3m"
|
|
39
34
|
};
|
|
40
35
|
const styles = {
|
|
41
36
|
root: "_19itglyw _ca0qidpf _u5f3idpf _n3tdidpf _19bvidpf _19pkidpf _2hwxidpf _otyridpf _18u0idpf _1r041wug _1reoewfl _18m9ewfl _bfhk1j28"
|
|
@@ -85,7 +80,7 @@ export const Popover = /*#__PURE__*/forwardRef(function Popover({
|
|
|
85
80
|
onOpenChange,
|
|
86
81
|
onEnterFinish,
|
|
87
82
|
onExitFinish,
|
|
88
|
-
animate,
|
|
83
|
+
animate = false,
|
|
89
84
|
placement,
|
|
90
85
|
testId,
|
|
91
86
|
isOpen,
|
|
@@ -106,6 +101,7 @@ export const Popover = /*#__PURE__*/forwardRef(function Popover({
|
|
|
106
101
|
preset
|
|
107
102
|
} = useAnimatedVisibility({
|
|
108
103
|
isOpen,
|
|
104
|
+
animationKind: 'popover',
|
|
109
105
|
animate,
|
|
110
106
|
elementRef: ownRef,
|
|
111
107
|
onEnterFinish,
|
|
@@ -271,12 +267,12 @@ export const Popover = /*#__PURE__*/forwardRef(function Popover({
|
|
|
271
267
|
// stale custom properties on the element.
|
|
272
268
|
useLayoutEffect(() => {
|
|
273
269
|
const element = ownRef.current;
|
|
274
|
-
if (!element || !
|
|
270
|
+
if (!element || !placement) {
|
|
275
271
|
return;
|
|
276
272
|
}
|
|
277
273
|
return setStyle({
|
|
278
274
|
element,
|
|
279
|
-
styles:
|
|
275
|
+
styles: getPopupMotionStyles({
|
|
280
276
|
placement
|
|
281
277
|
})
|
|
282
278
|
});
|
|
@@ -329,6 +325,6 @@ export const Popover = /*#__PURE__*/forwardRef(function Popover({
|
|
|
329
325
|
"aria-label": label,
|
|
330
326
|
"aria-labelledby": labelledBy,
|
|
331
327
|
"data-testid": testId,
|
|
332
|
-
className: ax([styles.root, preset && popoverAnimationStyles.root,
|
|
328
|
+
className: ax([styles.root, preset && popoverAnimationStyles.root, consumerXcss])
|
|
333
329
|
}, children);
|
|
334
330
|
});
|
|
@@ -540,6 +540,9 @@ if (typeof HTMLElement !== 'undefined') {
|
|
|
540
540
|
// delegate every other selector to the original implementation.
|
|
541
541
|
// Spec: https://html.spec.whatwg.org/multipage/semantics-other.html#selector-popover-open
|
|
542
542
|
const originalMatches = Element.prototype.matches;
|
|
543
|
+
// The DOM lib types `Element.prototype.matches` as a set of type-predicate
|
|
544
|
+
// overloads. This polyfill intentionally replaces it with a plain boolean
|
|
545
|
+
// implementation, so we cast to the original member type.
|
|
543
546
|
Element.prototype.matches = function patchedMatches(selector) {
|
|
544
547
|
if (selector === ':popover-open') {
|
|
545
548
|
return this.hasAttribute('data-popover-open');
|
|
@@ -20,23 +20,15 @@
|
|
|
20
20
|
._1o51q7pw{animation-fill-mode:forwards}
|
|
21
21
|
._1oeci9qs{transition-duration:var(--ds-duration-medium,.2s)}
|
|
22
22
|
._1oil1d08[open]{transition-timing-function:var(--ds-easing-inout-bold,cubic-bezier(.4,0,0,1))}
|
|
23
|
-
._1pgl1lbj{animation-timing-function:var(--ds-easing-in-practical,cubic-bezier(.6,0,.8,.6))}
|
|
24
23
|
._1q51ze3t{padding-block-start:var(--ds-space-0,0)}
|
|
25
|
-
._1rjx1d08[open]{animation-timing-function:var(--ds-easing-inout-bold,cubic-bezier(.4,0,0,1))}
|
|
26
24
|
._1rsueoah[open]::-ms-backdrop{animation-fill-mode:backwards}
|
|
27
25
|
._1rsueoah[open]::backdrop{animation-fill-mode:backwards}
|
|
28
26
|
._1s9z1a5r{transition-behavior:allow-discrete}
|
|
29
|
-
._1szp1mzy[open]{animation-duration:var(--ds-duration-long,.25s)}
|
|
30
27
|
._2hwx1wug{margin-right:auto}
|
|
31
|
-
._5sagi9qs{animation-duration:var(--ds-duration-medium,.2s)}
|
|
32
28
|
._85i5ze3t{padding-block-end:var(--ds-space-0,0)}
|
|
33
|
-
._8ar61bym[open]{animation-name:var(--ds-keyframe-fade-in,FadeIn0to100)}
|
|
34
|
-
._8ar6yjsl[open]{animation-name:k1c1nn4,var(--ds-keyframe-fade-in,FadeIn0to100)}
|
|
35
29
|
._bfhk1j28{background-color:transparent}
|
|
36
30
|
._bozgze3t{padding-inline-start:var(--ds-space-0,0)}
|
|
37
31
|
._c71lglyw{max-height:none}
|
|
38
|
-
._j7hq1a5s{animation-name:var(--ds-keyframe-fade-out,FadeOut100to0)}
|
|
39
|
-
._j7hqcmlg{animation-name:ku52lnv,var(--ds-keyframe-fade-out,FadeOut100to0)}
|
|
40
32
|
._k8m011k7{transition-property:overlay,display}
|
|
41
33
|
._njwk11k7::-ms-backdrop{-ms-transition-property:overlay,display;transition-property:overlay,display}
|
|
42
34
|
._njwk11k7::backdrop{transition-property:overlay,display}
|
|
@@ -45,6 +37,4 @@
|
|
|
45
37
|
._y4tize3t{padding-inline-end:var(--ds-space-0,0)}
|
|
46
38
|
._yhpqi9qs::-ms-backdrop{transition-duration:var(--ds-duration-medium,.2s)}
|
|
47
39
|
._yhpqi9qs::backdrop{transition-duration:var(--ds-duration-medium,.2s)}
|
|
48
|
-
@keyframes k1c1nn4{0%{transform:translateY(calc(var(--ds-dialog-ty, 9pt)))}to{transform:none}}
|
|
49
|
-
@keyframes ku52lnv{0%{transform:none}to{transform:translateY(calc(var(--ds-dialog-ty, 9pt)*-1))}}
|
|
50
40
|
@media (prefers-reduced-motion:reduce){._bl8aglyw{animation-name:none}._156y147i{transition-duration:var(--ds-duration-instant,0ms)}._10aiglyw[open]{animation-name:none}._aeld147i[open]{transition-duration:var(--ds-duration-instant,0ms)}._l57nglyw::-ms-backdrop{animation-name:none}._l57nglyw::backdrop{animation-name:none}._1sbq147i::-ms-backdrop{transition-duration:var(--ds-duration-instant,0ms)}._1sbq147i::backdrop{transition-duration:var(--ds-duration-instant,0ms)}._19awglyw[open]::-ms-backdrop{animation-name:none}._19awglyw[open]::backdrop{animation-name:none}._1i6z147i[open]::-ms-backdrop{transition-duration:var(--ds-duration-instant,0ms)}._1i6z147i[open]::backdrop{transition-duration:var(--ds-duration-instant,0ms)}}
|
|
@@ -6,22 +6,15 @@ import { bind } from 'bind-event-listener';
|
|
|
6
6
|
import mergeRefs from '@atlaskit/ds-lib/merge-refs';
|
|
7
7
|
import noop from '@atlaskit/ds-lib/noop';
|
|
8
8
|
import { useNotifyOpenLayerObserver } from '@atlaskit/layering/experimental/open-layer-observer';
|
|
9
|
-
import { setStyle } from '../internal/set-style';
|
|
10
9
|
import { useAnimatedVisibility } from '../internal/use-animated-visibility';
|
|
11
10
|
import { useFocusWrap } from '../internal/use-focus-wrap';
|
|
12
|
-
var slideInKeyframes = null;
|
|
13
|
-
var slideOutKeyframes = null;
|
|
14
|
-
|
|
15
11
|
// These animation styles use the non-strict Compiled cssMap because they rely
|
|
16
12
|
// on `@starting-style`, `[open]`, and `allow-discrete`. Keep them in this
|
|
17
13
|
// component so the Compiled transform can statically extract every referenced
|
|
18
14
|
// style.
|
|
19
15
|
var dialogAnimationStyles = {
|
|
20
16
|
root: "_k8m011k7 _1oeci9qs _1s9z1a5r _1fsl1mzy _1oil1d08",
|
|
21
|
-
motion: "_y44vgeqi _1o51q7pw _1iu47kvq _1i0neoah"
|
|
22
|
-
'slide-up-and-fade': "_j7hqcmlg _5sagi9qs _1pgl1lbj _8ar6yjsl _1szp1mzy _1rjx1d08",
|
|
23
|
-
fade: "_j7hq1a5s _5sagi9qs _1pgl1lbj _8ar61bym _1szp1mzy _1rjx1d08",
|
|
24
|
-
custom: ""
|
|
17
|
+
motion: "_y44vgeqi _1o51q7pw _1iu47kvq _1i0neoah"
|
|
25
18
|
};
|
|
26
19
|
var styles = {
|
|
27
20
|
dialog: "_19itglyw _19pk1wug _2hwx1wug _otyr1wug _18u01wug _1q51ze3t _y4tize3t _85i5ze3t _bozgze3t _p12fglyw _c71lglyw _bfhk1j28 _bl8aglyw _156y147i _10aiglyw _aeld147i"
|
|
@@ -55,7 +48,8 @@ export var Dialog = /*#__PURE__*/forwardRef(function Dialog(_ref, ref) {
|
|
|
55
48
|
onClose = _ref.onClose,
|
|
56
49
|
onEnterFinish = _ref.onEnterFinish,
|
|
57
50
|
onExitFinish = _ref.onExitFinish,
|
|
58
|
-
animate = _ref.animate,
|
|
51
|
+
_ref$animate = _ref.animate,
|
|
52
|
+
animate = _ref$animate === void 0 ? false : _ref$animate,
|
|
59
53
|
consumerXcss = _ref.xcss,
|
|
60
54
|
style = _ref.style,
|
|
61
55
|
testId = _ref.testId,
|
|
@@ -69,6 +63,7 @@ export var Dialog = /*#__PURE__*/forwardRef(function Dialog(_ref, ref) {
|
|
|
69
63
|
var combinedRef = mergeRefs([ownRef, ref]);
|
|
70
64
|
var _useAnimatedVisibilit = useAnimatedVisibility({
|
|
71
65
|
isOpen: isOpen,
|
|
66
|
+
animationKind: 'dialog',
|
|
72
67
|
animate: animate,
|
|
73
68
|
elementRef: ownRef,
|
|
74
69
|
onEnterFinish: onEnterFinish,
|
|
@@ -120,24 +115,6 @@ export var Dialog = /*#__PURE__*/forwardRef(function Dialog(_ref, ref) {
|
|
|
120
115
|
}
|
|
121
116
|
}, [isOpen]);
|
|
122
117
|
|
|
123
|
-
// Apply preset-provided animation custom properties (e.g. the
|
|
124
|
-
// `--ds-dialog-ty` slide distance for `dialogSlideUpAndFade`). The
|
|
125
|
-
// cleanup restores the previous inline values so a preset change does
|
|
126
|
-
// not leave stale custom properties on the element. Dialog presets do
|
|
127
|
-
// not vary by placement, so an empty placement is passed.
|
|
128
|
-
useLayoutEffect(function () {
|
|
129
|
-
var dialog = ownRef.current;
|
|
130
|
-
if (!dialog || !(preset !== null && preset !== void 0 && preset.getStyles)) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
return setStyle({
|
|
134
|
-
element: dialog,
|
|
135
|
-
styles: preset.getStyles({
|
|
136
|
-
placement: {}
|
|
137
|
-
})
|
|
138
|
-
});
|
|
139
|
-
}, [preset, isVisible]);
|
|
140
|
-
|
|
141
118
|
// Handle native Escape (cancel event)
|
|
142
119
|
var handleCancel = useCallback(function (event) {
|
|
143
120
|
// Only handle a cancel targeting THIS dialog. Native `cancel` does not
|
|
@@ -198,6 +175,6 @@ export var Dialog = /*#__PURE__*/forwardRef(function Dialog(_ref, ref) {
|
|
|
198
175
|
style: style,
|
|
199
176
|
onCancel: handleCancel,
|
|
200
177
|
"data-testid": testId,
|
|
201
|
-
className: ax([styles.dialog, shouldHideBackdrop ? backdropStyles.hidden : backdropStyles.root, preset && backdropStyles.motion, preset && dialogAnimationStyles.root, preset && dialogAnimationStyles
|
|
178
|
+
className: ax([styles.dialog, shouldHideBackdrop ? backdropStyles.hidden : backdropStyles.root, preset && backdropStyles.motion, preset && dialogAnimationStyles.root, preset && dialogAnimationStyles.motion, consumerXcss])
|
|
202
179
|
}, children);
|
|
203
180
|
});
|
|
@@ -2,18 +2,6 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
2
2
|
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
3
3
|
import { bind, bindAll } from 'bind-event-listener';
|
|
4
4
|
import { prefersReducedMotion } from './reduced-motion';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* A self-contained animation preset for top-layer elements.
|
|
8
|
-
*
|
|
9
|
-
* Contains a stable preset name used by the host component to select its
|
|
10
|
-
* component-local Compiled style entry, plus optional per-placement inline
|
|
11
|
-
* styles.
|
|
12
|
-
*
|
|
13
|
-
* The actual Compiled styles are kept static and component-local so the
|
|
14
|
-
* Compiled transform can extract them at build time.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
5
|
/**
|
|
18
6
|
* Using the recommended motion timings for safety net.
|
|
19
7
|
*
|
|
@@ -72,6 +60,13 @@ function runOnTransitionEndOrTimeout(_ref) {
|
|
|
72
60
|
return teardown;
|
|
73
61
|
}
|
|
74
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Animation config for entry/exit transitions.
|
|
65
|
+
*
|
|
66
|
+
* Currently no configuration is supported via this prop,
|
|
67
|
+
* and this is just a placeholder.
|
|
68
|
+
*/
|
|
69
|
+
|
|
75
70
|
/**
|
|
76
71
|
* Visibility lifecycle phase shared between `useAnimatedVisibility`,
|
|
77
72
|
* `useFocusWrap`, `useInitialFocus`, and the `Popover` / `Dialog`
|
|
@@ -135,6 +130,7 @@ function runOnTransitionEndOrTimeout(_ref) {
|
|
|
135
130
|
*/
|
|
136
131
|
export function useAnimatedVisibility(_ref2) {
|
|
137
132
|
var isOpen = _ref2.isOpen,
|
|
133
|
+
animationKind = _ref2.animationKind,
|
|
138
134
|
animate = _ref2.animate,
|
|
139
135
|
elementRef = _ref2.elementRef,
|
|
140
136
|
onEnterFinish = _ref2.onEnterFinish,
|
|
@@ -188,7 +184,7 @@ export function useAnimatedVisibility(_ref2) {
|
|
|
188
184
|
// move to `open`. The fallback guarantees settle on swallowed events
|
|
189
185
|
// (zero-duration, browser quirk, mid-transition unmount).
|
|
190
186
|
useEffect(function () {
|
|
191
|
-
if (phase !== 'entering'
|
|
187
|
+
if (phase !== 'entering') {
|
|
192
188
|
return;
|
|
193
189
|
}
|
|
194
190
|
var element = elementRef.current;
|
|
@@ -197,7 +193,7 @@ export function useAnimatedVisibility(_ref2) {
|
|
|
197
193
|
}
|
|
198
194
|
return runOnTransitionEndOrTimeout({
|
|
199
195
|
element: element,
|
|
200
|
-
safetyNetMs: safetyNetMsMap[
|
|
196
|
+
safetyNetMs: safetyNetMsMap[animationKind].enter + 50,
|
|
201
197
|
onSettled: function onSettled() {
|
|
202
198
|
var _onEnterFinishRef$cur;
|
|
203
199
|
// Fire the consumer callback before transitioning phase so any
|
|
@@ -210,7 +206,7 @@ export function useAnimatedVisibility(_ref2) {
|
|
|
210
206
|
});
|
|
211
207
|
}
|
|
212
208
|
});
|
|
213
|
-
}, [phase,
|
|
209
|
+
}, [phase, animationKind, elementRef]);
|
|
214
210
|
|
|
215
211
|
// Non-animated entry callback. The lifecycle goes `closed → open`
|
|
216
212
|
// directly with no `entering` phase; fire `onEnterFinish` on that jump.
|
|
@@ -231,7 +227,7 @@ export function useAnimatedVisibility(_ref2) {
|
|
|
231
227
|
// Animated exit: wait for `transitionend` (or a safety-net timeout),
|
|
232
228
|
// fire `onExitFinish`, then move to `closed` to unmount the host.
|
|
233
229
|
useEffect(function () {
|
|
234
|
-
if (phase !== 'exiting' || !willAnimate
|
|
230
|
+
if (phase !== 'exiting' || !willAnimate) {
|
|
235
231
|
return;
|
|
236
232
|
}
|
|
237
233
|
var element = elementRef.current;
|
|
@@ -240,7 +236,7 @@ export function useAnimatedVisibility(_ref2) {
|
|
|
240
236
|
}
|
|
241
237
|
return runOnTransitionEndOrTimeout({
|
|
242
238
|
element: element,
|
|
243
|
-
safetyNetMs: safetyNetMsMap[
|
|
239
|
+
safetyNetMs: safetyNetMsMap[animationKind].exit + 50,
|
|
244
240
|
onSettled: function onSettled() {
|
|
245
241
|
var _onExitFinishRef$curr;
|
|
246
242
|
// Fire the consumer callback before transitioning phase to
|
|
@@ -255,7 +251,7 @@ export function useAnimatedVisibility(_ref2) {
|
|
|
255
251
|
});
|
|
256
252
|
}
|
|
257
253
|
});
|
|
258
|
-
}, [phase, willAnimate,
|
|
254
|
+
}, [phase, willAnimate, animationKind, elementRef]);
|
|
259
255
|
|
|
260
256
|
// Non-animated exit: wait for the browser's `toggle` (closed) or
|
|
261
257
|
// `close` event before unmounting, so the consumer's listener (close
|