@atlaskit/top-layer 1.10.1 → 3.0.0
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 +24 -0
- package/README.md +13 -25
- package/dist/cjs/dialog/dialog-content.compiled.css +5 -18
- package/dist/cjs/dialog/dialog-content.js +22 -20
- package/dist/cjs/internal/placement-to-position-area.js +5 -5
- package/dist/cjs/internal/placement-to-try-fallbacks.js +1 -1
- package/dist/cjs/internal/resolve-css-length-to-pixels.js +1 -1
- package/dist/cjs/internal/resolve-placement.js +3 -3
- package/dist/cjs/internal/use-anchor-position.js +2 -2
- package/dist/cjs/internal/use-animated-visibility.js +3 -17
- package/dist/cjs/popover/popover.compiled.css +4 -10
- package/dist/cjs/popover/popover.js +56 -50
- package/dist/cjs/popover-surface/popover-surface.js +1 -1
- package/dist/es2019/dialog/dialog-content.compiled.css +5 -18
- package/dist/es2019/dialog/dialog-content.js +21 -19
- package/dist/es2019/internal/placement-to-position-area.js +2 -2
- package/dist/es2019/internal/placement-to-try-fallbacks.js +2 -2
- package/dist/es2019/internal/resolve-css-length-to-pixels.js +1 -1
- package/dist/es2019/internal/resolve-placement.js +2 -2
- package/dist/es2019/internal/use-anchor-position.js +3 -3
- package/dist/es2019/internal/use-animated-visibility.js +3 -17
- package/dist/es2019/popover/popover.compiled.css +4 -10
- package/dist/es2019/popover/popover.js +57 -50
- package/dist/es2019/popover-surface/popover-surface.js +1 -1
- package/dist/esm/dialog/dialog-content.compiled.css +5 -18
- package/dist/esm/dialog/dialog-content.js +22 -20
- package/dist/esm/internal/placement-to-position-area.js +5 -5
- package/dist/esm/internal/placement-to-try-fallbacks.js +2 -2
- package/dist/esm/internal/resolve-css-length-to-pixels.js +1 -1
- package/dist/esm/internal/resolve-placement.js +2 -2
- package/dist/esm/internal/use-anchor-position.js +3 -3
- package/dist/esm/internal/use-animated-visibility.js +3 -17
- package/dist/esm/popover/popover.compiled.css +4 -10
- package/dist/esm/popover/popover.js +57 -51
- package/dist/esm/popover-surface/popover-surface.js +1 -1
- package/dist/types/dialog/types.d.ts +24 -11
- package/dist/types/internal/resolve-placement.d.ts +6 -4
- package/dist/types/internal/use-animated-visibility.d.ts +2 -14
- package/dist/types/placement-map/legacy-placements.d.ts +1 -1
- package/dist/types/popover/types.d.ts +23 -41
- package/package.json +4 -4
- package/dist/cjs/popover/animations.js +0 -50
- package/dist/es2019/popover/animations.js +0 -46
- package/dist/esm/popover/animations.js +0 -44
- package/dist/types/popover/animations.d.ts +0 -7
|
@@ -1,30 +1,21 @@
|
|
|
1
1
|
._19itglyw{border:none}
|
|
2
|
-
._1iu47kvq[open]{animation:var(--ds-modal-enter,.25s cubic-bezier(.4,0,0,1) ScaleIn95to100)}
|
|
3
2
|
._1m5e1op4::-ms-backdrop{animation:var(--ds-blanket-exit,.2s cubic-bezier(.6,0,.8,.6) FadeOut100to0)}
|
|
4
3
|
._1m5e1op4::backdrop{animation:var(--ds-blanket-exit,.2s cubic-bezier(.6,0,.8,.6) FadeOut100to0)}
|
|
5
|
-
.
|
|
6
|
-
.
|
|
4
|
+
._1m5exbuz::-ms-backdrop{animation:var(--ds-blanket-enter,.25s cubic-bezier(.4,0,0,1) FadeIn0to100)}
|
|
5
|
+
._1m5exbuz::backdrop{animation:var(--ds-blanket-enter,.25s cubic-bezier(.4,0,0,1) FadeIn0to100)}
|
|
6
|
+
._y44v7kvq{animation:var(--ds-modal-enter,.25s cubic-bezier(.4,0,0,1) ScaleIn95to100)}
|
|
7
7
|
._y44vgeqi{animation:var(--ds-modal-exit,.2s cubic-bezier(.6,0,.8,.6) ScaleOut100to95)}._18u01wug{margin-left:auto}
|
|
8
8
|
._19pk1wug{margin-top:auto}
|
|
9
|
-
._1fsl1mzy[open]{transition-duration:var(--ds-duration-long,.25s)}
|
|
10
|
-
._1fyf1a5r::-ms-backdrop{transition-behavior:allow-discrete}
|
|
11
|
-
._1fyf1a5r::backdrop{transition-behavior:allow-discrete}
|
|
12
|
-
._1i0neoah[open]{animation-fill-mode:backwards}
|
|
13
9
|
._1i4q4jg8{overflow-wrap:normal}
|
|
14
|
-
._1jhdq7pw::-ms-backdrop{animation-fill-mode:forwards}
|
|
15
|
-
._1jhdq7pw::backdrop{animation-fill-mode:forwards}
|
|
16
10
|
._1ltk1i5c::-ms-backdrop{background-color:var(--ds-blanket,#050c1f75)}
|
|
17
11
|
._1ltk1i5c::backdrop{background-color:var(--ds-blanket,#050c1f75)}
|
|
18
12
|
._1ltk1j28::-ms-backdrop{background-color:transparent}
|
|
19
13
|
._1ltk1j28::backdrop{background-color:transparent}
|
|
20
14
|
._1nmz4jg8{word-break:normal}
|
|
21
|
-
.
|
|
15
|
+
._1o511hrf{animation-fill-mode:both}
|
|
22
16
|
._1oeci9qs{transition-duration:var(--ds-duration-medium,.2s)}
|
|
23
|
-
._1oil1d08[open]{transition-timing-function:var(--ds-easing-inout-bold,cubic-bezier(.4,0,0,1))}
|
|
24
17
|
._1p1dglyw{text-transform:none}
|
|
25
18
|
._1q51ze3t{padding-block-start:var(--ds-space-0,0)}
|
|
26
|
-
._1rsueoah[open]::-ms-backdrop{animation-fill-mode:backwards}
|
|
27
|
-
._1rsueoah[open]::backdrop{animation-fill-mode:backwards}
|
|
28
19
|
._1s9z1a5r{transition-behavior:allow-discrete}
|
|
29
20
|
._2hwx1wug{margin-right:auto}
|
|
30
21
|
._85i5ze3t{padding-block-end:var(--ds-space-0,0)}
|
|
@@ -33,13 +24,9 @@
|
|
|
33
24
|
._bozgze3t{padding-inline-start:var(--ds-space-0,0)}
|
|
34
25
|
._c71lglyw{max-height:none}
|
|
35
26
|
._k8m011k7{transition-property:overlay,display}
|
|
36
|
-
._njwk11k7::-ms-backdrop{-ms-transition-property:overlay,display;transition-property:overlay,display}
|
|
37
|
-
._njwk11k7::backdrop{transition-property:overlay,display}
|
|
38
27
|
._o5724jg8{white-space:normal}
|
|
39
28
|
._otyr1wug{margin-bottom:auto}
|
|
40
29
|
._p12fglyw{max-width:none}
|
|
41
30
|
._y3gnv2br{text-align:start}
|
|
42
31
|
._y4tize3t{padding-inline-end:var(--ds-space-0,0)}
|
|
43
|
-
.
|
|
44
|
-
._yhpqi9qs::backdrop{transition-duration:var(--ds-duration-medium,.2s)}
|
|
45
|
-
@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)}}
|
|
32
|
+
@media (prefers-reduced-motion:reduce){._bl8aglyw{animation-name:none}._156y147i{transition-duration:var(--ds-duration-instant,0ms)}}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
/* dialog-content.tsx generated by @compiled/babel-plugin
|
|
1
|
+
/* dialog-content.tsx generated by @compiled/babel-plugin v2.0.0 */
|
|
2
2
|
import "./dialog-content.compiled.css";
|
|
3
3
|
import { ax, ix } from "@compiled/react/runtime";
|
|
4
4
|
import React, { forwardRef, useCallback, useEffect, useId, useLayoutEffect, useRef } from 'react';
|
|
5
|
+
import { cx } from '@compiled/react';
|
|
5
6
|
import { bind } from 'bind-event-listener';
|
|
6
7
|
import mergeRefs from '@atlaskit/ds-lib/merge-refs';
|
|
7
8
|
import noop from '@atlaskit/ds-lib/noop';
|
|
@@ -9,15 +10,6 @@ import { useNotifyOpenLayerObserver } from '@atlaskit/layering/use-notify-open-l
|
|
|
9
10
|
import { useAnimatedVisibility } from '../internal/use-animated-visibility';
|
|
10
11
|
import { useFocusWrap } from '../internal/use-focus-wrap';
|
|
11
12
|
import { useSafariEscapeFix } from '../internal/use-safari-escape-fix';
|
|
12
|
-
// These animation styles use the non-strict Compiled cssMap because they rely
|
|
13
|
-
// on `@starting-style`, `[open]`, and `allow-discrete`. Keep them in this
|
|
14
|
-
// component so the Compiled transform can statically extract every referenced
|
|
15
|
-
// style.
|
|
16
|
-
const dialogAnimationStyles = {
|
|
17
|
-
root: "_k8m011k7 _1oeci9qs _1s9z1a5r _1fsl1mzy _1oil1d08",
|
|
18
|
-
motion: "_y44vgeqi _1o51q7pw _1iu47kvq _1i0neoah"
|
|
19
|
-
};
|
|
20
|
-
|
|
21
13
|
// Surface reset — see the rationale on `surfaceResetStyles` in `popover/popover.tsx`.
|
|
22
14
|
// Neutralises inherited text-layout properties (e.g. `white-space: nowrap`) that leak
|
|
23
15
|
// into the top-layer surface. Excludes `color`/`font` (theming) and
|
|
@@ -30,13 +22,17 @@ const dialogAnimationStyles = {
|
|
|
30
22
|
const surfaceResetStyles = {
|
|
31
23
|
root: "_o5724jg8 _1nmz4jg8 _1i4q4jg8 _y3gnv2br _azhwidpf _1p1dglyw"
|
|
32
24
|
};
|
|
33
|
-
const
|
|
34
|
-
|
|
25
|
+
const dialogStyles = {
|
|
26
|
+
root: "_19itglyw _19pk1wug _2hwx1wug _otyr1wug _18u01wug _1q51ze3t _y4tize3t _85i5ze3t _bozgze3t _p12fglyw _c71lglyw _bfhk1j28",
|
|
27
|
+
motion: "_k8m011k7 _1oeci9qs _1s9z1a5r _1o511hrf _bl8aglyw _156y147i",
|
|
28
|
+
enter: "_y44v7kvq",
|
|
29
|
+
exit: "_y44vgeqi"
|
|
35
30
|
};
|
|
36
31
|
const backdropStyles = {
|
|
37
32
|
root: "_1ltk1i5c",
|
|
38
33
|
hidden: "_1ltk1j28",
|
|
39
|
-
|
|
34
|
+
enter: "_1m5exbuz",
|
|
35
|
+
exit: "_1m5e1op4"
|
|
40
36
|
};
|
|
41
37
|
|
|
42
38
|
/**
|
|
@@ -62,8 +58,10 @@ export const Dialog = /*#__PURE__*/forwardRef(function Dialog({
|
|
|
62
58
|
onClose,
|
|
63
59
|
onEnterFinish,
|
|
64
60
|
onExitFinish,
|
|
65
|
-
|
|
61
|
+
shouldAnimate = false,
|
|
66
62
|
xcss: consumerXcss,
|
|
63
|
+
enteringAnimationXcss,
|
|
64
|
+
exitingAnimationXcss,
|
|
67
65
|
style,
|
|
68
66
|
testId,
|
|
69
67
|
id: providedId,
|
|
@@ -76,12 +74,11 @@ export const Dialog = /*#__PURE__*/forwardRef(function Dialog({
|
|
|
76
74
|
const ownRef = useRef(null);
|
|
77
75
|
const combinedRef = mergeRefs([ownRef, ref]);
|
|
78
76
|
const {
|
|
79
|
-
phase
|
|
80
|
-
preset
|
|
77
|
+
phase
|
|
81
78
|
} = useAnimatedVisibility({
|
|
82
79
|
isOpen,
|
|
83
80
|
animationKind: 'dialog',
|
|
84
|
-
|
|
81
|
+
shouldAnimate,
|
|
85
82
|
elementRef: ownRef,
|
|
86
83
|
onEnterFinish,
|
|
87
84
|
onExitFinish
|
|
@@ -191,6 +188,7 @@ export const Dialog = /*#__PURE__*/forwardRef(function Dialog({
|
|
|
191
188
|
if (!isVisible) {
|
|
192
189
|
return null;
|
|
193
190
|
}
|
|
191
|
+
const shouldAnimateBackdrop = !shouldHideBackdrop && shouldAnimate;
|
|
194
192
|
return /*#__PURE__*/React.createElement("dialog", {
|
|
195
193
|
ref: combinedRef,
|
|
196
194
|
id: dialogId
|
|
@@ -204,7 +202,11 @@ export const Dialog = /*#__PURE__*/forwardRef(function Dialog({
|
|
|
204
202
|
"aria-labelledby": label ? undefined : labelledBy,
|
|
205
203
|
style: style,
|
|
206
204
|
onCancel: handleCancel,
|
|
207
|
-
"data-testid": testId
|
|
208
|
-
|
|
205
|
+
"data-testid": testId
|
|
206
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop, @atlaskit/ui-styling-standard/local-cx-xcss, @compiled/local-cx-xcss
|
|
207
|
+
,
|
|
208
|
+
className: ax([
|
|
209
|
+
// Dialog styles
|
|
210
|
+
dialogStyles.root, surfaceResetStyles.root, shouldAnimate && phase === 'entering' && dialogStyles.enter, shouldAnimate && phase === 'exiting' && dialogStyles.exit, shouldAnimate && dialogStyles.motion, shouldHideBackdrop ? backdropStyles.hidden : backdropStyles.root, shouldAnimateBackdrop && phase === 'entering' && backdropStyles.enter, shouldAnimateBackdrop && phase === 'exiting' && backdropStyles.exit, cx(consumerXcss, shouldAnimate && phase === 'entering' && enteringAnimationXcss, shouldAnimate && phase === 'exiting' && exitingAnimationXcss)])
|
|
209
211
|
}, children);
|
|
210
212
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolvePlacement } from './resolve-placement';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Resolves placement options to CSS `position-area` syntax.
|
|
@@ -24,7 +24,7 @@ export function placementToPositionArea({
|
|
|
24
24
|
axis,
|
|
25
25
|
edge,
|
|
26
26
|
align
|
|
27
|
-
} =
|
|
27
|
+
} = resolvePlacement({
|
|
28
28
|
placement
|
|
29
29
|
});
|
|
30
30
|
const edgeValue = `${axis}-${edge}`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolvePlacement } from './resolve-placement';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* A `position-area` primary edge — the placement axis joined to its edge, e.g.
|
|
@@ -47,7 +47,7 @@ export function placementToTryFallbacks({
|
|
|
47
47
|
* The browser tries them _in order_ and uses the _first_ one that fits.
|
|
48
48
|
*/
|
|
49
49
|
|
|
50
|
-
const resolved =
|
|
50
|
+
const resolved = resolvePlacement({
|
|
51
51
|
placement
|
|
52
52
|
});
|
|
53
53
|
const {
|
|
@@ -61,7 +61,7 @@ export function resolveCssLengthToPixels({
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
// Fast path: bare `${n}px` strings come from the consumer normalisation
|
|
64
|
-
// in `
|
|
64
|
+
// in `resolvePlacement`. Avoid a reflow when we can.
|
|
65
65
|
const pxMatch = value.match(/^(-?\d+(?:\.\d+)?)px$/);
|
|
66
66
|
if (pxMatch) {
|
|
67
67
|
return Number(pxMatch[1]);
|
|
@@ -14,7 +14,7 @@ const DEFAULT_GAP = "var(--ds-space-100, 8px)";
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* Fully-resolved placement (internal). Use `
|
|
17
|
+
* Fully-resolved placement (internal). Use `resolvePlacement` for partial input.
|
|
18
18
|
* `offset.gap` and `offset.crossAxisShift.value` are always CSS
|
|
19
19
|
* length strings.
|
|
20
20
|
*/
|
|
@@ -37,7 +37,7 @@ const DEFAULT_GAP = "var(--ds-space-100, 8px)";
|
|
|
37
37
|
* `offset.gap: token('space.100', '8px')`,
|
|
38
38
|
* `offset.crossAxisShift: { value: '0px', direction: 'forwards' }`.
|
|
39
39
|
*/
|
|
40
|
-
export function
|
|
40
|
+
export function resolvePlacement({
|
|
41
41
|
placement
|
|
42
42
|
}) {
|
|
43
43
|
var _placement$offset, _placement$axis, _placement$edge, _placement$align, _placement$offset$cro, _placement$offset2, _placement$offset2$cr, _placement$offset$cro2, _placement$offset3, _placement$offset3$cr;
|
|
@@ -21,10 +21,10 @@ import { combine } from './combine';
|
|
|
21
21
|
import { placementToPositionArea } from './placement-to-position-area';
|
|
22
22
|
import { placementToTryFallbacks } from './placement-to-try-fallbacks';
|
|
23
23
|
import { resolveCssLengthToPixels } from './resolve-css-length-to-pixels';
|
|
24
|
-
import {
|
|
24
|
+
import { resolvePlacement } from './resolve-placement';
|
|
25
25
|
import { setStyle } from './set-style';
|
|
26
26
|
|
|
27
|
-
// `
|
|
27
|
+
// `resolvePlacement` is intentionally NOT re-exported here - import it directly
|
|
28
28
|
// from `./resolve-placement` so search-and-jump lands at the source of truth.
|
|
29
29
|
|
|
30
30
|
/**
|
|
@@ -144,7 +144,7 @@ function crossAxisShiftMargin({
|
|
|
144
144
|
* (or undefined fields vs explicit defaults) does not produce a fresh result.
|
|
145
145
|
*/
|
|
146
146
|
function useStablePlacement(placement) {
|
|
147
|
-
const resolved =
|
|
147
|
+
const resolved = resolvePlacement({
|
|
148
148
|
placement
|
|
149
149
|
});
|
|
150
150
|
const axis = resolved.axis;
|
|
@@ -60,13 +60,6 @@ function runOnTransitionEndOrTimeout({
|
|
|
60
60
|
return teardown;
|
|
61
61
|
}
|
|
62
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
|
-
|
|
70
63
|
/**
|
|
71
64
|
* Visibility lifecycle phase shared between `useAnimatedVisibility`,
|
|
72
65
|
* `useFocusWrap`, `useInitialFocus`, and the `Popover` / `Dialog`
|
|
@@ -131,18 +124,12 @@ function runOnTransitionEndOrTimeout({
|
|
|
131
124
|
export function useAnimatedVisibility({
|
|
132
125
|
isOpen,
|
|
133
126
|
animationKind,
|
|
134
|
-
|
|
127
|
+
shouldAnimate,
|
|
135
128
|
elementRef,
|
|
136
129
|
onEnterFinish,
|
|
137
130
|
onExitFinish
|
|
138
131
|
}) {
|
|
139
|
-
|
|
140
|
-
// and `Dialog`), so there is no longer any CSS injection step. Normalize a
|
|
141
|
-
// falsy `animate` to `null`.
|
|
142
|
-
const preset = animate || null;
|
|
143
|
-
|
|
144
|
-
// False when there is no preset or `prefers-reduced-motion` is set.
|
|
145
|
-
const willAnimate = Boolean(animate) && !prefersReducedMotion();
|
|
132
|
+
const willAnimate = shouldAnimate && !prefersReducedMotion();
|
|
146
133
|
|
|
147
134
|
// Promote `closed → entering`/`closed → open` synchronously during
|
|
148
135
|
// render so the host element mounts in the same commit as the open
|
|
@@ -302,7 +289,6 @@ export function useAnimatedVisibility({
|
|
|
302
289
|
}
|
|
303
290
|
}, [phase, willAnimate]);
|
|
304
291
|
return {
|
|
305
|
-
phase
|
|
306
|
-
preset
|
|
292
|
+
phase
|
|
307
293
|
};
|
|
308
294
|
}
|
|
@@ -1,32 +1,26 @@
|
|
|
1
|
-
._15ns179n:popover-open{animation:var(--ds-popover-motion-enter)}
|
|
2
1
|
._19itglyw{border:none}
|
|
3
2
|
._1r041wug{inset:auto}
|
|
4
|
-
.
|
|
5
|
-
._18m9ewfl{overflow-y:visible}
|
|
3
|
+
._y44v179n{animation:var(--ds-popover-motion-enter)}
|
|
4
|
+
._y44vof1f{animation:var(--ds-popover-motion-exit)}._18m9ewfl{overflow-y:visible}
|
|
6
5
|
._18u0idpf{margin-left:0}
|
|
7
6
|
._19bvidpf{padding-left:0}
|
|
8
7
|
._19pkidpf{margin-top:0}
|
|
9
8
|
._1i4q4jg8{overflow-wrap:normal}
|
|
10
9
|
._1nmz4jg8{word-break:normal}
|
|
11
|
-
.
|
|
10
|
+
._1o511hrf{animation-fill-mode:both}
|
|
12
11
|
._1oecdn4k{transition-duration:var(--ds-duration-xshort,.1s)}
|
|
13
12
|
._1p1dglyw{text-transform:none}
|
|
14
|
-
._1pgl1lbj{animation-timing-function:var(--ds-easing-in-practical,cubic-bezier(.6,0,.8,.6))}
|
|
15
|
-
._1psg1ign:popover-open{animation-duration:var(--ds-duration-short,.15s)}
|
|
16
13
|
._1reoewfl{overflow-x:visible}
|
|
17
14
|
._1s9z1a5r{transition-behavior:allow-discrete}
|
|
18
15
|
._2hwxidpf{margin-right:0}
|
|
19
16
|
._4t3i1wug{height:auto}
|
|
20
|
-
._5sagdn4k{animation-duration:var(--ds-duration-xshort,.1s)}
|
|
21
17
|
._azhwidpf{text-indent:0}
|
|
22
18
|
._bfhk1j28{background-color:transparent}
|
|
23
19
|
._ca0qidpf{padding-top:0}
|
|
24
20
|
._k8m011k7{transition-property:overlay,display}
|
|
25
21
|
._n3tdidpf{padding-bottom:0}
|
|
26
|
-
._n70peoah:popover-open{animation-fill-mode:backwards}
|
|
27
22
|
._o5724jg8{white-space:normal}
|
|
28
|
-
._o8i7indk:popover-open{animation-timing-function:var(--ds-easing-out-practical,cubic-bezier(.4,1,.6,1))}
|
|
29
23
|
._otyridpf{margin-bottom:0}
|
|
30
24
|
._u5f3idpf{padding-right:0}
|
|
31
25
|
._y3gnv2br{text-align:start}
|
|
32
|
-
@media (prefers-reduced-motion:reduce){._bl8aglyw{animation-name:none}.
|
|
26
|
+
@media (prefers-reduced-motion:reduce){._bl8aglyw{animation-name:none}._156y147i{transition-duration:var(--ds-duration-instant,0ms)}}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
/* popover.tsx generated by @compiled/babel-plugin
|
|
1
|
+
/* popover.tsx generated by @compiled/babel-plugin v2.0.0 */
|
|
2
2
|
import "./popover.compiled.css";
|
|
3
3
|
import { ax, ix } from "@compiled/react/runtime";
|
|
4
|
-
import React, { forwardRef, useCallback, useId, useLayoutEffect, useRef } from 'react';
|
|
4
|
+
import React, { forwardRef, useCallback, useId, useLayoutEffect, useMemo, useRef } from 'react';
|
|
5
|
+
import { cx } from '@compiled/react';
|
|
5
6
|
import { bind } from 'bind-event-listener';
|
|
6
7
|
import mergeRefs from '@atlaskit/ds-lib/merge-refs';
|
|
7
8
|
import once from '@atlaskit/ds-lib/once';
|
|
8
9
|
import { useNotifyOpenLayerObserver } from '@atlaskit/layering/use-notify-open-layer-observer';
|
|
10
|
+
import { resolvePlacement } from '../internal/resolve-placement';
|
|
9
11
|
import { shouldFocusIntoPopover } from '../internal/role-types';
|
|
10
|
-
import { setStyle } from '../internal/set-style';
|
|
11
12
|
import { useAnimatedVisibility } from '../internal/use-animated-visibility';
|
|
12
13
|
import { useFocusWrap } from '../internal/use-focus-wrap';
|
|
13
14
|
import { useInitialFocus } from '../internal/use-initial-focus';
|
|
14
|
-
import { getPopupMotionStyles } from './animations';
|
|
15
15
|
/**
|
|
16
16
|
* Detects `popover="hint"` support via DOM reflection. SSR-safe, cached.
|
|
17
17
|
*/
|
|
@@ -25,14 +25,6 @@ const supportsPopoverHint = once(() => {
|
|
|
25
25
|
return element.popover === 'hint';
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
// These animation styles use the non-strict Compiled cssMap because they rely
|
|
29
|
-
// on `@starting-style`, `:popover-open`, `[dir='rtl']`, and `allow-discrete`.
|
|
30
|
-
// Keep them in this component so the Compiled transform can statically extract
|
|
31
|
-
// every referenced style.
|
|
32
|
-
const popoverAnimationStyles = {
|
|
33
|
-
root: "_y44vof1f _k8m011k7 _1oecdn4k _1s9z1a5r _1o51q7pw _5sagdn4k _1pgl1lbj _15ns179n _12t71ign _n70peoah _1psg1ign _o8i7indk _bl8aglyw _156yru3m _8rmvglyw _2qm2ru3m"
|
|
34
|
-
};
|
|
35
|
-
|
|
36
28
|
// Surface reset — neutralises inherited text-layout properties (e.g.
|
|
37
29
|
// `white-space: nowrap` from an `@atlaskit/select` option) that leak into a
|
|
38
30
|
// top-layer element because, for CSS inheritance, it is still a DOM child of its
|
|
@@ -48,7 +40,35 @@ const surfaceResetStyles = {
|
|
|
48
40
|
root: "_o5724jg8 _1nmz4jg8 _1i4q4jg8 _y3gnv2br _azhwidpf _1p1dglyw"
|
|
49
41
|
};
|
|
50
42
|
const styles = {
|
|
51
|
-
root: "_19itglyw _ca0qidpf _u5f3idpf _n3tdidpf _19bvidpf _19pkidpf _2hwxidpf _otyridpf _18u0idpf _1r041wug _1reoewfl _18m9ewfl _bfhk1j28 _4t3i1wug"
|
|
43
|
+
root: "_19itglyw _ca0qidpf _u5f3idpf _n3tdidpf _19bvidpf _19pkidpf _2hwxidpf _otyridpf _18u0idpf _1r041wug _1reoewfl _18m9ewfl _bfhk1j28 _4t3i1wug",
|
|
44
|
+
motion: "_k8m011k7 _1oecdn4k _1s9z1a5r _1o511hrf _bl8aglyw _156y147i",
|
|
45
|
+
enter: "_y44v179n",
|
|
46
|
+
exit: "_y44vof1f"
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// Intentionally using `Record<string, string>` instead of `React.CSSProperties`
|
|
50
|
+
// to avoid type errors about the CSS variables not being valid property names
|
|
51
|
+
const popupMotionStyles = {
|
|
52
|
+
block: {
|
|
53
|
+
start: {
|
|
54
|
+
'--ds-popover-motion-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)",
|
|
55
|
+
'--ds-popover-motion-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)"
|
|
56
|
+
},
|
|
57
|
+
end: {
|
|
58
|
+
'--ds-popover-motion-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)",
|
|
59
|
+
'--ds-popover-motion-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)"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
inline: {
|
|
63
|
+
start: {
|
|
64
|
+
'--ds-popover-motion-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)",
|
|
65
|
+
'--ds-popover-motion-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)"
|
|
66
|
+
},
|
|
67
|
+
end: {
|
|
68
|
+
'--ds-popover-motion-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)",
|
|
69
|
+
'--ds-popover-motion-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)"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
52
72
|
};
|
|
53
73
|
/**
|
|
54
74
|
* Roles registered with the open layer observer as `popup`, so `closeLayers()`
|
|
@@ -92,14 +112,14 @@ export const Popover = /*#__PURE__*/forwardRef(function Popover({
|
|
|
92
112
|
children,
|
|
93
113
|
mode: modeProp = 'auto',
|
|
94
114
|
onClose,
|
|
95
|
-
onOpenChange,
|
|
96
115
|
onEnterFinish,
|
|
97
116
|
onExitFinish,
|
|
98
|
-
|
|
117
|
+
shouldAnimate = false,
|
|
99
118
|
placement,
|
|
100
119
|
testId,
|
|
101
120
|
isOpen,
|
|
102
|
-
|
|
121
|
+
enteringAnimationXcss,
|
|
122
|
+
exitingAnimationXcss,
|
|
103
123
|
// ARIA
|
|
104
124
|
role,
|
|
105
125
|
label,
|
|
@@ -112,12 +132,11 @@ export const Popover = /*#__PURE__*/forwardRef(function Popover({
|
|
|
112
132
|
// `useId()` colons are invalid in CSS selectors and popover target attributes.
|
|
113
133
|
const popoverId = idProp !== null && idProp !== void 0 ? idProp : `popover-${autoId.replace(/:/g, '')}`;
|
|
114
134
|
const {
|
|
115
|
-
phase
|
|
116
|
-
preset
|
|
135
|
+
phase
|
|
117
136
|
} = useAnimatedVisibility({
|
|
118
137
|
isOpen,
|
|
119
138
|
animationKind: 'popover',
|
|
120
|
-
|
|
139
|
+
shouldAnimate,
|
|
121
140
|
elementRef: ownRef,
|
|
122
141
|
onEnterFinish,
|
|
123
142
|
onExitFinish
|
|
@@ -162,6 +181,18 @@ export const Popover = /*#__PURE__*/forwardRef(function Popover({
|
|
|
162
181
|
// will close other `auto` popovers when opened. Acceptable trade-off given
|
|
163
182
|
// shrinking browser set without `hint` support.
|
|
164
183
|
const mode = modeProp === 'hint' && !supportsPopoverHint() ? 'auto' : modeProp;
|
|
184
|
+
const popupMotionStyle = useMemo(() => {
|
|
185
|
+
if (!placement || !shouldAnimate) {
|
|
186
|
+
return undefined;
|
|
187
|
+
}
|
|
188
|
+
const {
|
|
189
|
+
axis,
|
|
190
|
+
edge
|
|
191
|
+
} = resolvePlacement({
|
|
192
|
+
placement
|
|
193
|
+
});
|
|
194
|
+
return popupMotionStyles[axis][edge];
|
|
195
|
+
}, [placement, shouldAnimate]);
|
|
165
196
|
|
|
166
197
|
// Prevents toggle handler from calling onClose for our own hidePopover() calls.
|
|
167
198
|
const programmaticCloseRef = useRef(false);
|
|
@@ -183,21 +214,10 @@ export const Popover = /*#__PURE__*/forwardRef(function Popover({
|
|
|
183
214
|
const handleToggle = useCallback(event => {
|
|
184
215
|
const element = ownRef.current;
|
|
185
216
|
if (event.newState === 'open') {
|
|
186
|
-
if (element) {
|
|
187
|
-
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange({
|
|
188
|
-
isOpen: true,
|
|
189
|
-
element: element
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
217
|
return;
|
|
193
218
|
}
|
|
194
219
|
if (event.newState === 'closed') {
|
|
195
220
|
if (element) {
|
|
196
|
-
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange({
|
|
197
|
-
isOpen: false,
|
|
198
|
-
element: element
|
|
199
|
-
});
|
|
200
|
-
|
|
201
221
|
// Nested-popover focus restoration fallback (browser only
|
|
202
222
|
// restores outermost; Firefox skips nested entirely).
|
|
203
223
|
// Restore only when the role moved focus in on open AND the
|
|
@@ -234,7 +254,7 @@ export const Popover = /*#__PURE__*/forwardRef(function Popover({
|
|
|
234
254
|
reason
|
|
235
255
|
});
|
|
236
256
|
}
|
|
237
|
-
}, [onClose,
|
|
257
|
+
}, [onClose, role]);
|
|
238
258
|
|
|
239
259
|
// Bind via `useLayoutEffect`, and BEFORE the show/hide layout effect
|
|
240
260
|
// below, so listeners are attached when `showPopover()` synchronously
|
|
@@ -276,23 +296,6 @@ export const Popover = /*#__PURE__*/forwardRef(function Popover({
|
|
|
276
296
|
};
|
|
277
297
|
}, [handleToggle, handleBeforeToggle, isVisible]);
|
|
278
298
|
|
|
279
|
-
// Placement-dependent animation CSS vars. Kept separate from show/hide
|
|
280
|
-
// so preset reference changes do not re-trigger visibility. The cleanup
|
|
281
|
-
// restores the previous inline values so a preset change does not leave
|
|
282
|
-
// stale custom properties on the element.
|
|
283
|
-
useLayoutEffect(() => {
|
|
284
|
-
const element = ownRef.current;
|
|
285
|
-
if (!element || !placement) {
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
return setStyle({
|
|
289
|
-
element,
|
|
290
|
-
styles: getPopupMotionStyles({
|
|
291
|
-
placement
|
|
292
|
-
})
|
|
293
|
-
});
|
|
294
|
-
}, [preset, placement, isVisible]);
|
|
295
|
-
|
|
296
299
|
// Show/hide based on isOpen. `showPopover`/`hidePopover` are no-ops when
|
|
297
300
|
// already in the target state. Try/catch guards `InvalidStateError` on
|
|
298
301
|
// disconnected elements (StrictMode/concurrent/unmount edge cases).
|
|
@@ -339,7 +342,11 @@ export const Popover = /*#__PURE__*/forwardRef(function Popover({
|
|
|
339
342
|
role: role,
|
|
340
343
|
"aria-label": label,
|
|
341
344
|
"aria-labelledby": labelledBy,
|
|
342
|
-
"data-testid": testId
|
|
343
|
-
|
|
345
|
+
"data-testid": testId
|
|
346
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Motion styles are selected at runtime from the placement.
|
|
347
|
+
,
|
|
348
|
+
style: popupMotionStyle,
|
|
349
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop, @atlaskit/ui-styling-standard/local-cx-xcss, @compiled/local-cx-xcss
|
|
350
|
+
className: ax([styles.root, surfaceResetStyles.root, shouldAnimate && phase === 'entering' && styles.enter, shouldAnimate && phase === 'exiting' && styles.exit, shouldAnimate && styles.motion, cx(shouldAnimate && phase === 'entering' && enteringAnimationXcss, shouldAnimate && phase === 'exiting' && exitingAnimationXcss)])
|
|
344
351
|
}, children);
|
|
345
352
|
});
|
|
@@ -1,30 +1,21 @@
|
|
|
1
1
|
._19itglyw{border:none}
|
|
2
|
-
._1iu47kvq[open]{animation:var(--ds-modal-enter,.25s cubic-bezier(.4,0,0,1) ScaleIn95to100)}
|
|
3
2
|
._1m5e1op4::-ms-backdrop{animation:var(--ds-blanket-exit,.2s cubic-bezier(.6,0,.8,.6) FadeOut100to0)}
|
|
4
3
|
._1m5e1op4::backdrop{animation:var(--ds-blanket-exit,.2s cubic-bezier(.6,0,.8,.6) FadeOut100to0)}
|
|
5
|
-
.
|
|
6
|
-
.
|
|
4
|
+
._1m5exbuz::-ms-backdrop{animation:var(--ds-blanket-enter,.25s cubic-bezier(.4,0,0,1) FadeIn0to100)}
|
|
5
|
+
._1m5exbuz::backdrop{animation:var(--ds-blanket-enter,.25s cubic-bezier(.4,0,0,1) FadeIn0to100)}
|
|
6
|
+
._y44v7kvq{animation:var(--ds-modal-enter,.25s cubic-bezier(.4,0,0,1) ScaleIn95to100)}
|
|
7
7
|
._y44vgeqi{animation:var(--ds-modal-exit,.2s cubic-bezier(.6,0,.8,.6) ScaleOut100to95)}._18u01wug{margin-left:auto}
|
|
8
8
|
._19pk1wug{margin-top:auto}
|
|
9
|
-
._1fsl1mzy[open]{transition-duration:var(--ds-duration-long,.25s)}
|
|
10
|
-
._1fyf1a5r::-ms-backdrop{transition-behavior:allow-discrete}
|
|
11
|
-
._1fyf1a5r::backdrop{transition-behavior:allow-discrete}
|
|
12
|
-
._1i0neoah[open]{animation-fill-mode:backwards}
|
|
13
9
|
._1i4q4jg8{overflow-wrap:normal}
|
|
14
|
-
._1jhdq7pw::-ms-backdrop{animation-fill-mode:forwards}
|
|
15
|
-
._1jhdq7pw::backdrop{animation-fill-mode:forwards}
|
|
16
10
|
._1ltk1i5c::-ms-backdrop{background-color:var(--ds-blanket,#050c1f75)}
|
|
17
11
|
._1ltk1i5c::backdrop{background-color:var(--ds-blanket,#050c1f75)}
|
|
18
12
|
._1ltk1j28::-ms-backdrop{background-color:transparent}
|
|
19
13
|
._1ltk1j28::backdrop{background-color:transparent}
|
|
20
14
|
._1nmz4jg8{word-break:normal}
|
|
21
|
-
.
|
|
15
|
+
._1o511hrf{animation-fill-mode:both}
|
|
22
16
|
._1oeci9qs{transition-duration:var(--ds-duration-medium,.2s)}
|
|
23
|
-
._1oil1d08[open]{transition-timing-function:var(--ds-easing-inout-bold,cubic-bezier(.4,0,0,1))}
|
|
24
17
|
._1p1dglyw{text-transform:none}
|
|
25
18
|
._1q51ze3t{padding-block-start:var(--ds-space-0,0)}
|
|
26
|
-
._1rsueoah[open]::-ms-backdrop{animation-fill-mode:backwards}
|
|
27
|
-
._1rsueoah[open]::backdrop{animation-fill-mode:backwards}
|
|
28
19
|
._1s9z1a5r{transition-behavior:allow-discrete}
|
|
29
20
|
._2hwx1wug{margin-right:auto}
|
|
30
21
|
._85i5ze3t{padding-block-end:var(--ds-space-0,0)}
|
|
@@ -33,13 +24,9 @@
|
|
|
33
24
|
._bozgze3t{padding-inline-start:var(--ds-space-0,0)}
|
|
34
25
|
._c71lglyw{max-height:none}
|
|
35
26
|
._k8m011k7{transition-property:overlay,display}
|
|
36
|
-
._njwk11k7::-ms-backdrop{-ms-transition-property:overlay,display;transition-property:overlay,display}
|
|
37
|
-
._njwk11k7::backdrop{transition-property:overlay,display}
|
|
38
27
|
._o5724jg8{white-space:normal}
|
|
39
28
|
._otyr1wug{margin-bottom:auto}
|
|
40
29
|
._p12fglyw{max-width:none}
|
|
41
30
|
._y3gnv2br{text-align:start}
|
|
42
31
|
._y4tize3t{padding-inline-end:var(--ds-space-0,0)}
|
|
43
|
-
.
|
|
44
|
-
._yhpqi9qs::backdrop{transition-duration:var(--ds-duration-medium,.2s)}
|
|
45
|
-
@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)}}
|
|
32
|
+
@media (prefers-reduced-motion:reduce){._bl8aglyw{animation-name:none}._156y147i{transition-duration:var(--ds-duration-instant,0ms)}}
|