@atlaskit/top-layer 1.5.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 +16 -0
- package/compass.yml +10 -1
- package/dist/cjs/dialog/dialog-content.compiled.css +7 -25
- package/dist/cjs/dialog/dialog-content.js +16 -51
- package/dist/cjs/entry-points/animations.js +1 -48
- package/dist/cjs/internal/use-animated-visibility.js +35 -6
- package/dist/cjs/popover/animations.js +50 -0
- package/dist/cjs/popover/popover.compiled.css +7 -14
- package/dist/cjs/popover/popover.js +19 -31
- package/dist/cjs/testing/polyfill.js +3 -0
- package/dist/es2019/dialog/dialog-content.compiled.css +7 -25
- package/dist/es2019/dialog/dialog-content.js +15 -48
- package/dist/es2019/entry-points/animations.js +0 -1
- package/dist/es2019/internal/use-animated-visibility.js +35 -6
- package/dist/es2019/popover/animations.js +46 -0
- package/dist/es2019/popover/popover.compiled.css +7 -14
- package/dist/es2019/popover/popover.js +18 -28
- package/dist/es2019/testing/polyfill.js +3 -0
- package/dist/esm/dialog/dialog-content.compiled.css +7 -25
- package/dist/esm/dialog/dialog-content.js +16 -51
- package/dist/esm/entry-points/animations.js +0 -1
- package/dist/esm/internal/use-animated-visibility.js +35 -6
- package/dist/esm/popover/animations.js +44 -0
- package/dist/esm/popover/popover.compiled.css +7 -14
- package/dist/esm/popover/popover.js +19 -31
- 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 +16 -5
- package/dist/types/popover/animations.d.ts +7 -0
- package/dist/types/popover/types.d.ts +7 -4
- package/package.json +30 -12
- package/dist/cjs/animations/presets.js +0 -298
- package/dist/cjs/animations/types.js +0 -5
- package/dist/es2019/animations/presets.js +0 -285
- package/dist/es2019/animations/types.js +0 -1
- package/dist/esm/animations/presets.js +0 -285
- package/dist/esm/animations/types.js +0 -1
- package/dist/types/animations/presets.d.ts +0 -128
- package/dist/types/animations/types.d.ts +0 -34
|
@@ -5,54 +5,36 @@
|
|
|
5
5
|
._1m5e1op4::backdrop{animation:var(--ds-blanket-exit,.2s cubic-bezier(.6,0,.8,.6) FadeOut100to0)}
|
|
6
6
|
._vhgsxbuz[open]::-ms-backdrop{animation:var(--ds-blanket-enter,.25s cubic-bezier(.4,0,0,1) FadeIn0to100)}
|
|
7
7
|
._vhgsxbuz[open]::backdrop{animation:var(--ds-blanket-enter,.25s cubic-bezier(.4,0,0,1) FadeIn0to100)}
|
|
8
|
-
._y44vgeqi{animation:var(--ds-modal-exit,.2s cubic-bezier(.6,0,.8,.6) ScaleOut100to95)}.
|
|
9
|
-
._13ku1a34::backdrop{transition-timing-function:cubic-bezier(.15,1,.3,1)}
|
|
10
|
-
._18u01wug{margin-left:auto}
|
|
8
|
+
._y44vgeqi{animation:var(--ds-modal-exit,.2s cubic-bezier(.6,0,.8,.6) ScaleOut100to95)}._18u01wug{margin-left:auto}
|
|
11
9
|
._19pk1wug{margin-top:auto}
|
|
12
|
-
.
|
|
10
|
+
._1fsl1mzy[open]{transition-duration:var(--ds-duration-long,.25s)}
|
|
13
11
|
._1fyf1a5r::-ms-backdrop{transition-behavior:allow-discrete}
|
|
14
12
|
._1fyf1a5r::backdrop{transition-behavior:allow-discrete}
|
|
15
|
-
._1gbckb7n[open]{opacity:1}
|
|
16
13
|
._1i0neoah[open]{animation-fill-mode:backwards}
|
|
17
14
|
._1jhdq7pw::-ms-backdrop{animation-fill-mode:forwards}
|
|
18
15
|
._1jhdq7pw::backdrop{animation-fill-mode:forwards}
|
|
19
|
-
._1kdeglyw[open]{transform:none}
|
|
20
16
|
._1ltk1i5c::-ms-backdrop{background-color:var(--ds-blanket,#050c1f75)}
|
|
21
17
|
._1ltk1i5c::backdrop{background-color:var(--ds-blanket,#050c1f75)}
|
|
22
18
|
._1ltk1j28::-ms-backdrop{background-color:transparent}
|
|
23
19
|
._1ltk1j28::backdrop{background-color:transparent}
|
|
24
20
|
._1o51q7pw{animation-fill-mode:forwards}
|
|
25
|
-
.
|
|
26
|
-
.
|
|
21
|
+
._1oeci9qs{transition-duration:var(--ds-duration-medium,.2s)}
|
|
22
|
+
._1oil1d08[open]{transition-timing-function:var(--ds-easing-inout-bold,cubic-bezier(.4,0,0,1))}
|
|
27
23
|
._1q51ze3t{padding-block-start:var(--ds-space-0,0)}
|
|
28
24
|
._1rsueoah[open]::-ms-backdrop{animation-fill-mode:backwards}
|
|
29
25
|
._1rsueoah[open]::backdrop{animation-fill-mode:backwards}
|
|
30
26
|
._1s9z1a5r{transition-behavior:allow-discrete}
|
|
31
27
|
._2hwx1wug{margin-right:auto}
|
|
32
|
-
._4v7i1ttt[open]::-ms-backdrop{transition-duration:.35s}
|
|
33
|
-
._4v7i1ttt[open]::backdrop{transition-duration:.35s}
|
|
34
|
-
._6fl41a34{transition-timing-function:cubic-bezier(.15,1,.3,1)}
|
|
35
28
|
._85i5ze3t{padding-block-end:var(--ds-space-0,0)}
|
|
36
29
|
._bfhk1j28{background-color:transparent}
|
|
37
30
|
._bozgze3t{padding-inline-start:var(--ds-space-0,0)}
|
|
38
31
|
._c71lglyw{max-height:none}
|
|
39
|
-
._d7fr1i5c[open]::-ms-backdrop{background-color:var(--ds-blanket,#050c1f75)}
|
|
40
|
-
._d7fr1i5c[open]::backdrop{background-color:var(--ds-blanket,#050c1f75)}
|
|
41
32
|
._k8m011k7{transition-property:overlay,display}
|
|
42
|
-
._k8m01slm{transition-property:opacity,overlay,display}
|
|
43
|
-
._k8m0rv36{transition-property:opacity,transform,overlay,display}
|
|
44
33
|
._njwk11k7::-ms-backdrop{-ms-transition-property:overlay,display;transition-property:overlay,display}
|
|
45
34
|
._njwk11k7::backdrop{transition-property:overlay,display}
|
|
46
|
-
._njwkivc9::-ms-backdrop{-ms-transition-property:background-color,overlay,display;transition-property:background-color,overlay,display}
|
|
47
|
-
._njwkivc9::backdrop{transition-property:background-color,overlay,display}
|
|
48
35
|
._otyr1wug{margin-bottom:auto}
|
|
49
36
|
._p12fglyw{max-width:none}
|
|
50
|
-
._t9ec9o47{transform:translateY(calc(var(--ds-dialog-ty, 9pt)*-1))}
|
|
51
|
-
._tzy4idpf{opacity:0}
|
|
52
37
|
._y4tize3t{padding-inline-end:var(--ds-space-0,0)}
|
|
53
|
-
.
|
|
54
|
-
.
|
|
55
|
-
.
|
|
56
|
-
._yhpqluct::backdrop{transition-duration:175ms}
|
|
57
|
-
@media (prefers-reduced-motion:reduce){._156yru3m{transition-duration:0s}._aeldru3m[open]{transition-duration:0s}._1sbqru3m::-ms-backdrop{transition-duration:0s}._1sbqru3m::backdrop{transition-duration:0s}._1i6zru3m[open]::-ms-backdrop{transition-duration:0s}._1i6zru3m[open]::backdrop{transition-duration:0s}._bl8aglyw{animation-name:none}._10aiglyw[open]{animation-name:none}._l57nglyw::-ms-backdrop{animation-name:none}._l57nglyw::backdrop{animation-name:none}._19awglyw[open]::-ms-backdrop{animation-name:none}._19awglyw[open]::backdrop{animation-name:none}}
|
|
58
|
-
@starting-style{._1dar1j28[open]::-ms-backdrop{background-color:transparent}._1dar1j28[open]::backdrop{background-color:transparent}._rornidpf[open]{opacity:0}._1hqtc4j2[open]{transform:translateY(var(--ds-dialog-ty,9pt))}}
|
|
38
|
+
._yhpqi9qs::-ms-backdrop{transition-duration:var(--ds-duration-medium,.2s)}
|
|
39
|
+
._yhpqi9qs::backdrop{transition-duration:var(--ds-duration-medium,.2s)}
|
|
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)}}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* dialog-content.tsx generated by @compiled/babel-plugin v0.39.1 */
|
|
2
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
3
2
|
import "./dialog-content.compiled.css";
|
|
4
3
|
import { ax, ix } from "@compiled/react/runtime";
|
|
5
4
|
import React, { forwardRef, useCallback, useEffect, useId, useLayoutEffect, useRef } from 'react';
|
|
@@ -14,12 +13,16 @@ import { useFocusWrap } from '../internal/use-focus-wrap';
|
|
|
14
13
|
// component so the Compiled transform can statically extract every referenced
|
|
15
14
|
// style.
|
|
16
15
|
const dialogAnimationStyles = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
fade: "_tzy4idpf _k8m01slm _1oecluct _6fl41a34 _1s9z1a5r _1gbckb7n _1fsl1ttt _rornidpf _1ltk1j28 _njwkivc9 _yhpqluct _13ku1a34 _1fyf1a5r _d7fr1i5c _4v7i1ttt _1dar1j28 _156yru3m _aeldru3m _1sbqru3m _1i6zru3m"
|
|
16
|
+
root: "_k8m011k7 _1oeci9qs _1s9z1a5r _1fsl1mzy _1oil1d08",
|
|
17
|
+
motion: "_y44vgeqi _1o51q7pw _1iu47kvq _1i0neoah"
|
|
20
18
|
};
|
|
21
19
|
const styles = {
|
|
22
|
-
dialog: "_19itglyw _19pk1wug _2hwx1wug _otyr1wug _18u01wug _1q51ze3t _y4tize3t _85i5ze3t _bozgze3t _p12fglyw _c71lglyw _bfhk1j28
|
|
20
|
+
dialog: "_19itglyw _19pk1wug _2hwx1wug _otyr1wug _18u01wug _1q51ze3t _y4tize3t _85i5ze3t _bozgze3t _p12fglyw _c71lglyw _bfhk1j28 _bl8aglyw _156y147i _10aiglyw _aeld147i"
|
|
21
|
+
};
|
|
22
|
+
const backdropStyles = {
|
|
23
|
+
root: "_1ltk1i5c",
|
|
24
|
+
hidden: "_1ltk1j28",
|
|
25
|
+
motion: "_1m5e1op4 _1jhdq7pw _njwk11k7 _yhpqi9qs _1fyf1a5r _vhgsxbuz _1rsueoah _l57nglyw _1sbq147i _19awglyw _1i6z147i"
|
|
23
26
|
};
|
|
24
27
|
|
|
25
28
|
/**
|
|
@@ -45,8 +48,8 @@ export const Dialog = /*#__PURE__*/forwardRef(function Dialog({
|
|
|
45
48
|
onClose,
|
|
46
49
|
onEnterFinish,
|
|
47
50
|
onExitFinish,
|
|
48
|
-
animate,
|
|
49
|
-
xcss:
|
|
51
|
+
animate = false,
|
|
52
|
+
xcss: consumerXcss,
|
|
50
53
|
style,
|
|
51
54
|
testId,
|
|
52
55
|
id: providedId,
|
|
@@ -63,6 +66,7 @@ export const Dialog = /*#__PURE__*/forwardRef(function Dialog({
|
|
|
63
66
|
preset
|
|
64
67
|
} = useAnimatedVisibility({
|
|
65
68
|
isOpen,
|
|
69
|
+
animationKind: 'dialog',
|
|
66
70
|
animate,
|
|
67
71
|
elementRef: ownRef,
|
|
68
72
|
onEnterFinish,
|
|
@@ -112,29 +116,6 @@ export const Dialog = /*#__PURE__*/forwardRef(function Dialog({
|
|
|
112
116
|
}
|
|
113
117
|
}, [isOpen]);
|
|
114
118
|
|
|
115
|
-
// Apply preset-provided animation custom properties (e.g. the
|
|
116
|
-
// `--ds-dialog-ty` slide distance for `dialogSlideUpAndFade`). The
|
|
117
|
-
// cleanup removes them so a preset change does not leave stale
|
|
118
|
-
// custom properties on the element. Dialog presets do not vary by
|
|
119
|
-
// placement, so an empty placement is passed.
|
|
120
|
-
useLayoutEffect(() => {
|
|
121
|
-
const dialog = ownRef.current;
|
|
122
|
-
if (!dialog || !(preset !== null && preset !== void 0 && preset.getProperties)) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
const props = preset.getProperties({
|
|
126
|
-
placement: {}
|
|
127
|
-
});
|
|
128
|
-
Object.entries(props).forEach(([key, value]) => {
|
|
129
|
-
dialog.style.setProperty(key, String(value));
|
|
130
|
-
});
|
|
131
|
-
return () => {
|
|
132
|
-
Object.keys(props).forEach(key => {
|
|
133
|
-
dialog.style.removeProperty(key);
|
|
134
|
-
});
|
|
135
|
-
};
|
|
136
|
-
}, [preset, isVisible]);
|
|
137
|
-
|
|
138
119
|
// Handle native Escape (cancel event)
|
|
139
120
|
const handleCancel = useCallback(event => {
|
|
140
121
|
// Only handle a cancel targeting THIS dialog. Native `cancel` does not
|
|
@@ -174,12 +155,6 @@ export const Dialog = /*#__PURE__*/forwardRef(function Dialog({
|
|
|
174
155
|
});
|
|
175
156
|
}, [onClose, isVisible]);
|
|
176
157
|
|
|
177
|
-
// Atomic CSS (Compiled) deduplicates ::backdrop { background-color }
|
|
178
|
-
// into a single class, making it impossible to toggle between two values
|
|
179
|
-
// via cssMap entries. An ID-scoped <style> has higher specificity than
|
|
180
|
-
// any atomic class, so the override always wins.
|
|
181
|
-
const escapedId = CSS.escape(dialogId);
|
|
182
|
-
|
|
183
158
|
// Unmount the `<dialog>` once exit completes so it does not leave an
|
|
184
159
|
// empty `role="dialog"` element in the accessibility tree. On the next
|
|
185
160
|
// open the element remounts and the `[isOpen]` and `[onClose, isVisible]`
|
|
@@ -187,7 +162,7 @@ export const Dialog = /*#__PURE__*/forwardRef(function Dialog({
|
|
|
187
162
|
if (!isVisible) {
|
|
188
163
|
return null;
|
|
189
164
|
}
|
|
190
|
-
return /*#__PURE__*/React.createElement("dialog",
|
|
165
|
+
return /*#__PURE__*/React.createElement("dialog", {
|
|
191
166
|
ref: combinedRef,
|
|
192
167
|
id: dialogId
|
|
193
168
|
// `aria-modal` is intentionally NOT set: native `<dialog>.showModal()`
|
|
@@ -198,17 +173,9 @@ export const Dialog = /*#__PURE__*/forwardRef(function Dialog({
|
|
|
198
173
|
,
|
|
199
174
|
"aria-label": label,
|
|
200
175
|
"aria-labelledby": label ? undefined : labelledBy,
|
|
201
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
202
176
|
style: style,
|
|
203
177
|
onCancel: handleCancel,
|
|
204
|
-
"data-testid": testId
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
} : undefined, {
|
|
208
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- xcss prop passes Compiled atomic class names from consumer-owned cssMap entries
|
|
209
|
-
className: ax([styles.dialog, (preset === null || preset === void 0 ? void 0 : preset.name) === 'motion' && dialogAnimationStyles.motion, (preset === null || preset === void 0 ? void 0 : preset.name) === 'slide-up-and-fade' && dialogAnimationStyles.slideUpAndFade, (preset === null || preset === void 0 ? void 0 : preset.name) === 'fade' && dialogAnimationStyles.fade, xcssFromProps])
|
|
210
|
-
}), shouldHideBackdrop &&
|
|
211
|
-
/*#__PURE__*/
|
|
212
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles
|
|
213
|
-
React.createElement("style", null, `#${escapedId}::backdrop{background-color:transparent}`), children);
|
|
178
|
+
"data-testid": testId,
|
|
179
|
+
className: ax([styles.dialog, shouldHideBackdrop ? backdropStyles.hidden : backdropStyles.root, preset && backdropStyles.motion, preset && dialogAnimationStyles.root, preset && dialogAnimationStyles.motion, consumerXcss])
|
|
180
|
+
}, children);
|
|
214
181
|
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { dialogMotion, popupMotion, slideAndFade, fade, scaleAndFade, dialogSlideUpAndFade, dialogFade } from '../animations/presets';
|
|
@@ -1,6 +1,29 @@
|
|
|
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
|
+
* Using the recommended motion timings for safety net.
|
|
6
|
+
*
|
|
7
|
+
* Not setting these timings on the preset config because they're defined in the CSS,
|
|
8
|
+
* so configuring it in the preset doesn't achieve anything except introduce a potential
|
|
9
|
+
* source of drift.
|
|
10
|
+
*
|
|
11
|
+
* TODO: figure out a way to not need to redeclare these in the future,
|
|
12
|
+
* and keep CSS and JS timings in sync always.
|
|
13
|
+
*/
|
|
14
|
+
const safetyNetMsMap = {
|
|
15
|
+
dialog: {
|
|
16
|
+
enter: 250,
|
|
17
|
+
// Corresponds to `motion.duration.long`
|
|
18
|
+
exit: 200 // Corresponds to `motion.duration.medium`
|
|
19
|
+
},
|
|
20
|
+
popover: {
|
|
21
|
+
enter: 150,
|
|
22
|
+
// Corresponds to `motion.duration.short`
|
|
23
|
+
exit: 100 // Corresponds to `motion.duration.xshort`
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
4
27
|
/**
|
|
5
28
|
* Fires `onSettled` once when `transitionend` fires on `element`, or after
|
|
6
29
|
* `safetyNetMs` if the event is swallowed (mid-transition unmount, CSS
|
|
@@ -37,6 +60,13 @@ function runOnTransitionEndOrTimeout({
|
|
|
37
60
|
return teardown;
|
|
38
61
|
}
|
|
39
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
|
+
|
|
40
70
|
/**
|
|
41
71
|
* Visibility lifecycle phase shared between `useAnimatedVisibility`,
|
|
42
72
|
* `useFocusWrap`, `useInitialFocus`, and the `Popover` / `Dialog`
|
|
@@ -100,6 +130,7 @@ function runOnTransitionEndOrTimeout({
|
|
|
100
130
|
*/
|
|
101
131
|
export function useAnimatedVisibility({
|
|
102
132
|
isOpen,
|
|
133
|
+
animationKind,
|
|
103
134
|
animate,
|
|
104
135
|
elementRef,
|
|
105
136
|
onEnterFinish,
|
|
@@ -151,7 +182,6 @@ export function useAnimatedVisibility({
|
|
|
151
182
|
// move to `open`. The fallback guarantees settle on swallowed events
|
|
152
183
|
// (zero-duration, browser quirk, mid-transition unmount).
|
|
153
184
|
useEffect(() => {
|
|
154
|
-
var _preset$enterDuration;
|
|
155
185
|
if (phase !== 'entering') {
|
|
156
186
|
return;
|
|
157
187
|
}
|
|
@@ -161,7 +191,7 @@ export function useAnimatedVisibility({
|
|
|
161
191
|
}
|
|
162
192
|
return runOnTransitionEndOrTimeout({
|
|
163
193
|
element,
|
|
164
|
-
safetyNetMs:
|
|
194
|
+
safetyNetMs: safetyNetMsMap[animationKind].enter + 50,
|
|
165
195
|
onSettled: () => {
|
|
166
196
|
var _onEnterFinishRef$cur;
|
|
167
197
|
// Fire the consumer callback before transitioning phase so any
|
|
@@ -172,7 +202,7 @@ export function useAnimatedVisibility({
|
|
|
172
202
|
setPhase(current => current === 'entering' ? 'open' : current);
|
|
173
203
|
}
|
|
174
204
|
});
|
|
175
|
-
}, [phase,
|
|
205
|
+
}, [phase, animationKind, elementRef]);
|
|
176
206
|
|
|
177
207
|
// Non-animated entry callback. The lifecycle goes `closed → open`
|
|
178
208
|
// directly with no `entering` phase; fire `onEnterFinish` on that jump.
|
|
@@ -193,7 +223,6 @@ export function useAnimatedVisibility({
|
|
|
193
223
|
// Animated exit: wait for `transitionend` (or a safety-net timeout),
|
|
194
224
|
// fire `onExitFinish`, then move to `closed` to unmount the host.
|
|
195
225
|
useEffect(() => {
|
|
196
|
-
var _preset$exitDurationM;
|
|
197
226
|
if (phase !== 'exiting' || !willAnimate) {
|
|
198
227
|
return;
|
|
199
228
|
}
|
|
@@ -203,7 +232,7 @@ export function useAnimatedVisibility({
|
|
|
203
232
|
}
|
|
204
233
|
return runOnTransitionEndOrTimeout({
|
|
205
234
|
element,
|
|
206
|
-
safetyNetMs:
|
|
235
|
+
safetyNetMs: safetyNetMsMap[animationKind].exit + 50,
|
|
207
236
|
onSettled: () => {
|
|
208
237
|
var _onExitFinishRef$curr;
|
|
209
238
|
// Fire the consumer callback before transitioning phase to
|
|
@@ -216,7 +245,7 @@ export function useAnimatedVisibility({
|
|
|
216
245
|
setPhase(current => current === 'exiting' ? 'closed' : current);
|
|
217
246
|
}
|
|
218
247
|
});
|
|
219
|
-
}, [phase, willAnimate,
|
|
248
|
+
}, [phase, willAnimate, animationKind, elementRef]);
|
|
220
249
|
|
|
221
250
|
// Non-animated exit: wait for the browser's `toggle` (closed) or
|
|
222
251
|
// `close` event before unmounting, so the consumer's listener (close
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { getPlacement } from '../internal/resolve-placement';
|
|
2
|
+
export function getPopupMotionStyles({
|
|
3
|
+
placement
|
|
4
|
+
}) {
|
|
5
|
+
const {
|
|
6
|
+
axis,
|
|
7
|
+
edge
|
|
8
|
+
} = getPlacement({
|
|
9
|
+
placement
|
|
10
|
+
});
|
|
11
|
+
if (axis === 'block' && edge === 'start') {
|
|
12
|
+
return [{
|
|
13
|
+
property: '--ds-popover-motion-enter',
|
|
14
|
+
value: "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)"
|
|
15
|
+
}, {
|
|
16
|
+
property: '--ds-popover-motion-exit',
|
|
17
|
+
value: "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)"
|
|
18
|
+
}];
|
|
19
|
+
}
|
|
20
|
+
if (axis === 'inline' && edge === 'start') {
|
|
21
|
+
return [{
|
|
22
|
+
property: '--ds-popover-motion-enter',
|
|
23
|
+
value: "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)"
|
|
24
|
+
}, {
|
|
25
|
+
property: '--ds-popover-motion-exit',
|
|
26
|
+
value: "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)"
|
|
27
|
+
}];
|
|
28
|
+
}
|
|
29
|
+
if (axis === 'inline' && edge === 'end') {
|
|
30
|
+
return [{
|
|
31
|
+
property: '--ds-popover-motion-enter',
|
|
32
|
+
value: "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)"
|
|
33
|
+
}, {
|
|
34
|
+
property: '--ds-popover-motion-exit',
|
|
35
|
+
value: "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)"
|
|
36
|
+
}];
|
|
37
|
+
}
|
|
38
|
+
// Default: block/end (popover below trigger)
|
|
39
|
+
return [{
|
|
40
|
+
property: '--ds-popover-motion-enter',
|
|
41
|
+
value: "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)"
|
|
42
|
+
}, {
|
|
43
|
+
property: '--ds-popover-motion-exit',
|
|
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
|
+
}];
|
|
46
|
+
}
|
|
@@ -2,32 +2,25 @@
|
|
|
2
2
|
._15ns179n:popover-open{animation:var(--ds-popover-motion-enter)}
|
|
3
3
|
._19itglyw{border:none}
|
|
4
4
|
._1r041wug{inset:auto}
|
|
5
|
-
._y44vof1f{animation:var(--ds-popover-motion-exit)}.
|
|
6
|
-
._162xglyw:popover-open{transform:none}
|
|
5
|
+
._y44vof1f{animation:var(--ds-popover-motion-exit)}._12t71ign:popover-open{transition-duration:var(--ds-duration-short,.15s)}
|
|
7
6
|
._18m9ewfl{overflow-y:visible}
|
|
8
7
|
._18u0idpf{margin-left:0}
|
|
9
8
|
._19bvidpf{padding-left:0}
|
|
10
9
|
._19pkidpf{margin-top:0}
|
|
11
|
-
._1f6ykb7n:popover-open{opacity:1}
|
|
12
10
|
._1o51q7pw{animation-fill-mode:forwards}
|
|
13
|
-
.
|
|
14
|
-
.
|
|
11
|
+
._1oecdn4k{transition-duration:var(--ds-duration-xshort,.1s)}
|
|
12
|
+
._1pgl1lbj{animation-timing-function:var(--ds-easing-in-practical,cubic-bezier(.6,0,.8,.6))}
|
|
13
|
+
._1psg1ign:popover-open{animation-duration:var(--ds-duration-short,.15s)}
|
|
15
14
|
._1reoewfl{overflow-x:visible}
|
|
16
15
|
._1s9z1a5r{transition-behavior:allow-discrete}
|
|
17
16
|
._2hwxidpf{margin-right:0}
|
|
18
|
-
.
|
|
17
|
+
._5sagdn4k{animation-duration:var(--ds-duration-xshort,.1s)}
|
|
19
18
|
._bfhk1j28{background-color:transparent}
|
|
20
19
|
._ca0qidpf{padding-top:0}
|
|
21
20
|
._k8m011k7{transition-property:overlay,display}
|
|
22
|
-
._k8m01slm{transition-property:opacity,overlay,display}
|
|
23
|
-
._k8m0rv36{transition-property:opacity,transform,overlay,display}
|
|
24
21
|
._n3tdidpf{padding-bottom:0}
|
|
25
22
|
._n70peoah:popover-open{animation-fill-mode:backwards}
|
|
23
|
+
._o8i7indk:popover-open{animation-timing-function:var(--ds-easing-out-practical,cubic-bezier(.4,1,.6,1))}
|
|
26
24
|
._otyridpf{margin-bottom:0}
|
|
27
|
-
._t9ecgt2x{transform:scale(.95)}
|
|
28
|
-
._t9ecxauz{transform:translate(var(--ds-popover-tx,0),var(--ds-popover-ty,0))}
|
|
29
|
-
._tzy4idpf{opacity:0}
|
|
30
25
|
._u5f3idpf{padding-right:0}
|
|
31
|
-
|
|
32
|
-
@media (prefers-reduced-motion:reduce){._156yru3m{transition-duration:0s}._2qm2ru3m:popover-open{transition-duration:0s}._bl8aglyw{animation-name:none}._8rmvglyw:popover-open{animation-name:none}}
|
|
33
|
-
@starting-style{._1wuhidpf:popover-open{opacity:0}._1423gt2x:popover-open{transform:scale(.95)}._1423xauz:popover-open{transform:translate(var(--ds-popover-tx,0),var(--ds-popover-ty,0))}[dir=rtl] ._1dml1oq6:popover-open{transform:translate(calc(var(--ds-popover-tx, 0)*-1),var(--ds-popover-ty,0))}}
|
|
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}}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* popover.tsx generated by @compiled/babel-plugin v0.39.1 */
|
|
2
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
3
2
|
import "./popover.compiled.css";
|
|
4
3
|
import { ax, ix } from "@compiled/react/runtime";
|
|
5
4
|
import React, { forwardRef, useCallback, useId, useLayoutEffect, useRef } from 'react';
|
|
@@ -8,9 +7,11 @@ import mergeRefs from '@atlaskit/ds-lib/merge-refs';
|
|
|
8
7
|
import once from '@atlaskit/ds-lib/once';
|
|
9
8
|
import { useNotifyOpenLayerObserver } from '@atlaskit/layering/experimental/open-layer-observer';
|
|
10
9
|
import { shouldFocusIntoPopover } from '../internal/role-types';
|
|
10
|
+
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
|
*/
|
|
@@ -29,10 +30,7 @@ const supportsPopoverHint = once(() => {
|
|
|
29
30
|
// Keep them in this component so the Compiled transform can statically extract
|
|
30
31
|
// every referenced style.
|
|
31
32
|
const popoverAnimationStyles = {
|
|
32
|
-
|
|
33
|
-
slideAndFade: "_tzy4idpf _t9ecxauz _k8m0rv36 _1oecluct _6fl41a34 _1s9z1a5r _1tz31oq6 _1f6ykb7n _162xglyw _12t71ttt _1wuhidpf _1423xauz _156yru3m _2qm2ru3m _1dml1oq6",
|
|
34
|
-
fade: "_tzy4idpf _k8m01slm _1oecluct _6fl41a34 _1s9z1a5r _1f6ykb7n _12t71ttt _1wuhidpf _156yru3m _2qm2ru3m",
|
|
35
|
-
scaleAndFade: "_tzy4idpf _t9ecgt2x _k8m0rv36 _1oecluct _6fl41a34 _1s9z1a5r _1f6ykb7n _162xglyw _12t71ttt _1wuhidpf _1423gt2x _156yru3m _2qm2ru3m"
|
|
33
|
+
root: "_y44vof1f _k8m011k7 _1oecdn4k _1s9z1a5r _1o51q7pw _5sagdn4k _1pgl1lbj _15ns179n _12t71ign _n70peoah _1psg1ign _o8i7indk _bl8aglyw _156yru3m _8rmvglyw _2qm2ru3m"
|
|
36
34
|
};
|
|
37
35
|
const styles = {
|
|
38
36
|
root: "_19itglyw _ca0qidpf _u5f3idpf _n3tdidpf _19bvidpf _19pkidpf _2hwxidpf _otyridpf _18u0idpf _1r041wug _1reoewfl _18m9ewfl _bfhk1j28"
|
|
@@ -82,11 +80,11 @@ export const Popover = /*#__PURE__*/forwardRef(function Popover({
|
|
|
82
80
|
onOpenChange,
|
|
83
81
|
onEnterFinish,
|
|
84
82
|
onExitFinish,
|
|
85
|
-
animate,
|
|
83
|
+
animate = false,
|
|
86
84
|
placement,
|
|
87
85
|
testId,
|
|
88
86
|
isOpen,
|
|
89
|
-
xcss:
|
|
87
|
+
xcss: consumerXcss,
|
|
90
88
|
// ARIA
|
|
91
89
|
role,
|
|
92
90
|
label,
|
|
@@ -103,6 +101,7 @@ export const Popover = /*#__PURE__*/forwardRef(function Popover({
|
|
|
103
101
|
preset
|
|
104
102
|
} = useAnimatedVisibility({
|
|
105
103
|
isOpen,
|
|
104
|
+
animationKind: 'popover',
|
|
106
105
|
animate,
|
|
107
106
|
elementRef: ownRef,
|
|
108
107
|
onEnterFinish,
|
|
@@ -264,24 +263,19 @@ export const Popover = /*#__PURE__*/forwardRef(function Popover({
|
|
|
264
263
|
|
|
265
264
|
// Placement-dependent animation CSS vars. Kept separate from show/hide
|
|
266
265
|
// so preset reference changes do not re-trigger visibility. The cleanup
|
|
267
|
-
//
|
|
268
|
-
// properties on the element.
|
|
266
|
+
// restores the previous inline values so a preset change does not leave
|
|
267
|
+
// stale custom properties on the element.
|
|
269
268
|
useLayoutEffect(() => {
|
|
270
269
|
const element = ownRef.current;
|
|
271
|
-
if (!element || !
|
|
270
|
+
if (!element || !placement) {
|
|
272
271
|
return;
|
|
273
272
|
}
|
|
274
|
-
|
|
275
|
-
|
|
273
|
+
return setStyle({
|
|
274
|
+
element,
|
|
275
|
+
styles: getPopupMotionStyles({
|
|
276
|
+
placement
|
|
277
|
+
})
|
|
276
278
|
});
|
|
277
|
-
Object.entries(props).forEach(([key, value]) => {
|
|
278
|
-
element.style.setProperty(key, String(value));
|
|
279
|
-
});
|
|
280
|
-
return () => {
|
|
281
|
-
Object.keys(props).forEach(key => {
|
|
282
|
-
element.style.removeProperty(key);
|
|
283
|
-
});
|
|
284
|
-
};
|
|
285
279
|
}, [preset, placement, isVisible]);
|
|
286
280
|
|
|
287
281
|
// Show/hide based on isOpen. `showPopover`/`hidePopover` are no-ops when
|
|
@@ -320,7 +314,7 @@ export const Popover = /*#__PURE__*/forwardRef(function Popover({
|
|
|
320
314
|
if (!isVisible) {
|
|
321
315
|
return null;
|
|
322
316
|
}
|
|
323
|
-
return /*#__PURE__*/React.createElement("div",
|
|
317
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
324
318
|
ref: combinedRef,
|
|
325
319
|
id: popoverId
|
|
326
320
|
// @ts-expect-error -- popover attribute not yet in React types
|
|
@@ -330,11 +324,7 @@ export const Popover = /*#__PURE__*/forwardRef(function Popover({
|
|
|
330
324
|
role: role,
|
|
331
325
|
"aria-label": label,
|
|
332
326
|
"aria-labelledby": labelledBy,
|
|
333
|
-
"data-testid": testId
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
} : undefined, {
|
|
337
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- xcss prop passes compiled atomic class names
|
|
338
|
-
className: ax([styles.root, (preset === null || preset === void 0 ? void 0 : preset.name) === 'popup-motion' && popoverAnimationStyles.popupMotion, (preset === null || preset === void 0 ? void 0 : preset.name) === 'slide-and-fade' && popoverAnimationStyles.slideAndFade, (preset === null || preset === void 0 ? void 0 : preset.name) === 'fade' && popoverAnimationStyles.fade, (preset === null || preset === void 0 ? void 0 : preset.name) === 'scale-and-fade' && popoverAnimationStyles.scaleAndFade, xcssFromProps])
|
|
339
|
-
}), children);
|
|
327
|
+
"data-testid": testId,
|
|
328
|
+
className: ax([styles.root, preset && popoverAnimationStyles.root, consumerXcss])
|
|
329
|
+
}, children);
|
|
340
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');
|
|
@@ -5,54 +5,36 @@
|
|
|
5
5
|
._1m5e1op4::backdrop{animation:var(--ds-blanket-exit,.2s cubic-bezier(.6,0,.8,.6) FadeOut100to0)}
|
|
6
6
|
._vhgsxbuz[open]::-ms-backdrop{animation:var(--ds-blanket-enter,.25s cubic-bezier(.4,0,0,1) FadeIn0to100)}
|
|
7
7
|
._vhgsxbuz[open]::backdrop{animation:var(--ds-blanket-enter,.25s cubic-bezier(.4,0,0,1) FadeIn0to100)}
|
|
8
|
-
._y44vgeqi{animation:var(--ds-modal-exit,.2s cubic-bezier(.6,0,.8,.6) ScaleOut100to95)}.
|
|
9
|
-
._13ku1a34::backdrop{transition-timing-function:cubic-bezier(.15,1,.3,1)}
|
|
10
|
-
._18u01wug{margin-left:auto}
|
|
8
|
+
._y44vgeqi{animation:var(--ds-modal-exit,.2s cubic-bezier(.6,0,.8,.6) ScaleOut100to95)}._18u01wug{margin-left:auto}
|
|
11
9
|
._19pk1wug{margin-top:auto}
|
|
12
|
-
.
|
|
10
|
+
._1fsl1mzy[open]{transition-duration:var(--ds-duration-long,.25s)}
|
|
13
11
|
._1fyf1a5r::-ms-backdrop{transition-behavior:allow-discrete}
|
|
14
12
|
._1fyf1a5r::backdrop{transition-behavior:allow-discrete}
|
|
15
|
-
._1gbckb7n[open]{opacity:1}
|
|
16
13
|
._1i0neoah[open]{animation-fill-mode:backwards}
|
|
17
14
|
._1jhdq7pw::-ms-backdrop{animation-fill-mode:forwards}
|
|
18
15
|
._1jhdq7pw::backdrop{animation-fill-mode:forwards}
|
|
19
|
-
._1kdeglyw[open]{transform:none}
|
|
20
16
|
._1ltk1i5c::-ms-backdrop{background-color:var(--ds-blanket,#050c1f75)}
|
|
21
17
|
._1ltk1i5c::backdrop{background-color:var(--ds-blanket,#050c1f75)}
|
|
22
18
|
._1ltk1j28::-ms-backdrop{background-color:transparent}
|
|
23
19
|
._1ltk1j28::backdrop{background-color:transparent}
|
|
24
20
|
._1o51q7pw{animation-fill-mode:forwards}
|
|
25
|
-
.
|
|
26
|
-
.
|
|
21
|
+
._1oeci9qs{transition-duration:var(--ds-duration-medium,.2s)}
|
|
22
|
+
._1oil1d08[open]{transition-timing-function:var(--ds-easing-inout-bold,cubic-bezier(.4,0,0,1))}
|
|
27
23
|
._1q51ze3t{padding-block-start:var(--ds-space-0,0)}
|
|
28
24
|
._1rsueoah[open]::-ms-backdrop{animation-fill-mode:backwards}
|
|
29
25
|
._1rsueoah[open]::backdrop{animation-fill-mode:backwards}
|
|
30
26
|
._1s9z1a5r{transition-behavior:allow-discrete}
|
|
31
27
|
._2hwx1wug{margin-right:auto}
|
|
32
|
-
._4v7i1ttt[open]::-ms-backdrop{transition-duration:.35s}
|
|
33
|
-
._4v7i1ttt[open]::backdrop{transition-duration:.35s}
|
|
34
|
-
._6fl41a34{transition-timing-function:cubic-bezier(.15,1,.3,1)}
|
|
35
28
|
._85i5ze3t{padding-block-end:var(--ds-space-0,0)}
|
|
36
29
|
._bfhk1j28{background-color:transparent}
|
|
37
30
|
._bozgze3t{padding-inline-start:var(--ds-space-0,0)}
|
|
38
31
|
._c71lglyw{max-height:none}
|
|
39
|
-
._d7fr1i5c[open]::-ms-backdrop{background-color:var(--ds-blanket,#050c1f75)}
|
|
40
|
-
._d7fr1i5c[open]::backdrop{background-color:var(--ds-blanket,#050c1f75)}
|
|
41
32
|
._k8m011k7{transition-property:overlay,display}
|
|
42
|
-
._k8m01slm{transition-property:opacity,overlay,display}
|
|
43
|
-
._k8m0rv36{transition-property:opacity,transform,overlay,display}
|
|
44
33
|
._njwk11k7::-ms-backdrop{-ms-transition-property:overlay,display;transition-property:overlay,display}
|
|
45
34
|
._njwk11k7::backdrop{transition-property:overlay,display}
|
|
46
|
-
._njwkivc9::-ms-backdrop{-ms-transition-property:background-color,overlay,display;transition-property:background-color,overlay,display}
|
|
47
|
-
._njwkivc9::backdrop{transition-property:background-color,overlay,display}
|
|
48
35
|
._otyr1wug{margin-bottom:auto}
|
|
49
36
|
._p12fglyw{max-width:none}
|
|
50
|
-
._t9ec9o47{transform:translateY(calc(var(--ds-dialog-ty, 9pt)*-1))}
|
|
51
|
-
._tzy4idpf{opacity:0}
|
|
52
37
|
._y4tize3t{padding-inline-end:var(--ds-space-0,0)}
|
|
53
|
-
.
|
|
54
|
-
.
|
|
55
|
-
.
|
|
56
|
-
._yhpqluct::backdrop{transition-duration:175ms}
|
|
57
|
-
@media (prefers-reduced-motion:reduce){._156yru3m{transition-duration:0s}._aeldru3m[open]{transition-duration:0s}._1sbqru3m::-ms-backdrop{transition-duration:0s}._1sbqru3m::backdrop{transition-duration:0s}._1i6zru3m[open]::-ms-backdrop{transition-duration:0s}._1i6zru3m[open]::backdrop{transition-duration:0s}._bl8aglyw{animation-name:none}._10aiglyw[open]{animation-name:none}._l57nglyw::-ms-backdrop{animation-name:none}._l57nglyw::backdrop{animation-name:none}._19awglyw[open]::-ms-backdrop{animation-name:none}._19awglyw[open]::backdrop{animation-name:none}}
|
|
58
|
-
@starting-style{._1dar1j28[open]::-ms-backdrop{background-color:transparent}._1dar1j28[open]::backdrop{background-color:transparent}._rornidpf[open]{opacity:0}._1hqtc4j2[open]{transform:translateY(var(--ds-dialog-ty,9pt))}}
|
|
38
|
+
._yhpqi9qs::-ms-backdrop{transition-duration:var(--ds-duration-medium,.2s)}
|
|
39
|
+
._yhpqi9qs::backdrop{transition-duration:var(--ds-duration-medium,.2s)}
|
|
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)}}
|