@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,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
|
-
var 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 @@ var dialogAnimationStyles = {
|
|
|
30
22
|
var surfaceResetStyles = {
|
|
31
23
|
root: "_o5724jg8 _1nmz4jg8 _1i4q4jg8 _y3gnv2br _azhwidpf _1p1dglyw"
|
|
32
24
|
};
|
|
33
|
-
var
|
|
34
|
-
|
|
25
|
+
var 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
|
var backdropStyles = {
|
|
37
32
|
root: "_1ltk1i5c",
|
|
38
33
|
hidden: "_1ltk1j28",
|
|
39
|
-
|
|
34
|
+
enter: "_1m5exbuz",
|
|
35
|
+
exit: "_1m5e1op4"
|
|
40
36
|
};
|
|
41
37
|
|
|
42
38
|
/**
|
|
@@ -62,9 +58,11 @@ export var Dialog = /*#__PURE__*/forwardRef(function Dialog(_ref, ref) {
|
|
|
62
58
|
onClose = _ref.onClose,
|
|
63
59
|
onEnterFinish = _ref.onEnterFinish,
|
|
64
60
|
onExitFinish = _ref.onExitFinish,
|
|
65
|
-
_ref$
|
|
66
|
-
|
|
61
|
+
_ref$shouldAnimate = _ref.shouldAnimate,
|
|
62
|
+
shouldAnimate = _ref$shouldAnimate === void 0 ? false : _ref$shouldAnimate,
|
|
67
63
|
consumerXcss = _ref.xcss,
|
|
64
|
+
enteringAnimationXcss = _ref.enteringAnimationXcss,
|
|
65
|
+
exitingAnimationXcss = _ref.exitingAnimationXcss,
|
|
68
66
|
style = _ref.style,
|
|
69
67
|
testId = _ref.testId,
|
|
70
68
|
providedId = _ref.id,
|
|
@@ -78,13 +76,12 @@ export var Dialog = /*#__PURE__*/forwardRef(function Dialog(_ref, ref) {
|
|
|
78
76
|
var _useAnimatedVisibilit = useAnimatedVisibility({
|
|
79
77
|
isOpen: isOpen,
|
|
80
78
|
animationKind: 'dialog',
|
|
81
|
-
|
|
79
|
+
shouldAnimate: shouldAnimate,
|
|
82
80
|
elementRef: ownRef,
|
|
83
81
|
onEnterFinish: onEnterFinish,
|
|
84
82
|
onExitFinish: onExitFinish
|
|
85
83
|
}),
|
|
86
|
-
phase = _useAnimatedVisibilit.phase
|
|
87
|
-
preset = _useAnimatedVisibilit.preset;
|
|
84
|
+
phase = _useAnimatedVisibilit.phase;
|
|
88
85
|
|
|
89
86
|
// True while the host element is mounted (any phase except `closed`).
|
|
90
87
|
// Used as a dep so listener-rebind effects re-attach after a remount.
|
|
@@ -189,6 +186,7 @@ export var Dialog = /*#__PURE__*/forwardRef(function Dialog(_ref, ref) {
|
|
|
189
186
|
if (!isVisible) {
|
|
190
187
|
return null;
|
|
191
188
|
}
|
|
189
|
+
var shouldAnimateBackdrop = !shouldHideBackdrop && shouldAnimate;
|
|
192
190
|
return /*#__PURE__*/React.createElement("dialog", {
|
|
193
191
|
ref: combinedRef,
|
|
194
192
|
id: dialogId
|
|
@@ -202,7 +200,11 @@ export var Dialog = /*#__PURE__*/forwardRef(function Dialog(_ref, ref) {
|
|
|
202
200
|
"aria-labelledby": label ? undefined : labelledBy,
|
|
203
201
|
style: style,
|
|
204
202
|
onCancel: handleCancel,
|
|
205
|
-
"data-testid": testId
|
|
206
|
-
|
|
203
|
+
"data-testid": testId
|
|
204
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop, @atlaskit/ui-styling-standard/local-cx-xcss, @compiled/local-cx-xcss
|
|
205
|
+
,
|
|
206
|
+
className: ax([
|
|
207
|
+
// Dialog styles
|
|
208
|
+
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)])
|
|
207
209
|
}, children);
|
|
208
210
|
});
|
|
@@ -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.
|
|
@@ -19,12 +19,12 @@ import { getPlacement } from './resolve-placement';
|
|
|
19
19
|
*/
|
|
20
20
|
export function placementToPositionArea(_ref) {
|
|
21
21
|
var placement = _ref.placement;
|
|
22
|
-
var
|
|
22
|
+
var _resolvePlacement = resolvePlacement({
|
|
23
23
|
placement: placement
|
|
24
24
|
}),
|
|
25
|
-
axis =
|
|
26
|
-
edge =
|
|
27
|
-
align =
|
|
25
|
+
axis = _resolvePlacement.axis,
|
|
26
|
+
edge = _resolvePlacement.edge,
|
|
27
|
+
align = _resolvePlacement.align;
|
|
28
28
|
var edgeValue = "".concat(axis, "-").concat(edge);
|
|
29
29
|
if (align === 'center') {
|
|
30
30
|
return edgeValue;
|
|
@@ -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.
|
|
@@ -44,7 +44,7 @@ export function placementToTryFallbacks(_ref3) {
|
|
|
44
44
|
* The browser tries them _in order_ and uses the _first_ one that fits.
|
|
45
45
|
*/
|
|
46
46
|
|
|
47
|
-
var resolved =
|
|
47
|
+
var resolved = resolvePlacement({
|
|
48
48
|
placement: placement
|
|
49
49
|
});
|
|
50
50
|
var axis = resolved.axis,
|
|
@@ -58,7 +58,7 @@ export function resolveCssLengthToPixels(_ref3) {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
// Fast path: bare `${n}px` strings come from the consumer normalisation
|
|
61
|
-
// in `
|
|
61
|
+
// in `resolvePlacement`. Avoid a reflow when we can.
|
|
62
62
|
var pxMatch = value.match(/^(-?\d+(?:\.\d+)?)px$/);
|
|
63
63
|
if (pxMatch) {
|
|
64
64
|
return Number(pxMatch[1]);
|
|
@@ -14,7 +14,7 @@ var 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 @@ var 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(_ref) {
|
|
41
41
|
var _placement$offset, _placement$axis, _placement$edge, _placement$align, _placement$offset$cro, _placement$offset2, _placement$offset$cro2, _placement$offset3;
|
|
42
42
|
var placement = _ref.placement;
|
|
43
43
|
var consumerGap = (_placement$offset = placement.offset) === null || _placement$offset === void 0 ? void 0 : _placement$offset.gap;
|
|
@@ -23,10 +23,10 @@ import { combine } from './combine';
|
|
|
23
23
|
import { placementToPositionArea } from './placement-to-position-area';
|
|
24
24
|
import { placementToTryFallbacks } from './placement-to-try-fallbacks';
|
|
25
25
|
import { resolveCssLengthToPixels } from './resolve-css-length-to-pixels';
|
|
26
|
-
import {
|
|
26
|
+
import { resolvePlacement } from './resolve-placement';
|
|
27
27
|
import { setStyle } from './set-style';
|
|
28
28
|
|
|
29
|
-
// `
|
|
29
|
+
// `resolvePlacement` is intentionally NOT re-exported here - import it directly
|
|
30
30
|
// from `./resolve-placement` so search-and-jump lands at the source of truth.
|
|
31
31
|
|
|
32
32
|
/**
|
|
@@ -150,7 +150,7 @@ function crossAxisShiftMargin(_ref2) {
|
|
|
150
150
|
* (or undefined fields vs explicit defaults) does not produce a fresh result.
|
|
151
151
|
*/
|
|
152
152
|
function useStablePlacement(placement) {
|
|
153
|
-
var resolved =
|
|
153
|
+
var resolved = resolvePlacement({
|
|
154
154
|
placement: placement
|
|
155
155
|
});
|
|
156
156
|
var axis = resolved.axis;
|
|
@@ -60,13 +60,6 @@ function runOnTransitionEndOrTimeout(_ref) {
|
|
|
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,17 +124,11 @@ function runOnTransitionEndOrTimeout(_ref) {
|
|
|
131
124
|
export function useAnimatedVisibility(_ref2) {
|
|
132
125
|
var isOpen = _ref2.isOpen,
|
|
133
126
|
animationKind = _ref2.animationKind,
|
|
134
|
-
|
|
127
|
+
shouldAnimate = _ref2.shouldAnimate,
|
|
135
128
|
elementRef = _ref2.elementRef,
|
|
136
129
|
onEnterFinish = _ref2.onEnterFinish,
|
|
137
130
|
onExitFinish = _ref2.onExitFinish;
|
|
138
|
-
|
|
139
|
-
// and `Dialog`), so there is no longer any CSS injection step. Normalize a
|
|
140
|
-
// falsy `animate` to `null`.
|
|
141
|
-
var preset = animate || null;
|
|
142
|
-
|
|
143
|
-
// False when there is no preset or `prefers-reduced-motion` is set.
|
|
144
|
-
var willAnimate = Boolean(animate) && !prefersReducedMotion();
|
|
131
|
+
var willAnimate = shouldAnimate && !prefersReducedMotion();
|
|
145
132
|
|
|
146
133
|
// Promote `closed → entering`/`closed → open` synchronously during
|
|
147
134
|
// render so the host element mounts in the same commit as the open
|
|
@@ -310,7 +297,6 @@ export function useAnimatedVisibility(_ref2) {
|
|
|
310
297
|
}
|
|
311
298
|
}, [phase, willAnimate]);
|
|
312
299
|
return {
|
|
313
|
-
phase: phase
|
|
314
|
-
preset: preset
|
|
300
|
+
phase: phase
|
|
315
301
|
};
|
|
316
302
|
}
|
|
@@ -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 @@ var supportsPopoverHint = once(function () {
|
|
|
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
|
-
var 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 @@ var surfaceResetStyles = {
|
|
|
48
40
|
root: "_o5724jg8 _1nmz4jg8 _1i4q4jg8 _y3gnv2br _azhwidpf _1p1dglyw"
|
|
49
41
|
};
|
|
50
42
|
var 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
|
+
var 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()`
|
|
@@ -93,15 +113,15 @@ export var Popover = /*#__PURE__*/forwardRef(function Popover(_ref, ref) {
|
|
|
93
113
|
_ref$mode = _ref.mode,
|
|
94
114
|
modeProp = _ref$mode === void 0 ? 'auto' : _ref$mode,
|
|
95
115
|
onClose = _ref.onClose,
|
|
96
|
-
onOpenChange = _ref.onOpenChange,
|
|
97
116
|
onEnterFinish = _ref.onEnterFinish,
|
|
98
117
|
onExitFinish = _ref.onExitFinish,
|
|
99
|
-
_ref$
|
|
100
|
-
|
|
118
|
+
_ref$shouldAnimate = _ref.shouldAnimate,
|
|
119
|
+
shouldAnimate = _ref$shouldAnimate === void 0 ? false : _ref$shouldAnimate,
|
|
101
120
|
placement = _ref.placement,
|
|
102
121
|
testId = _ref.testId,
|
|
103
122
|
isOpen = _ref.isOpen,
|
|
104
|
-
|
|
123
|
+
enteringAnimationXcss = _ref.enteringAnimationXcss,
|
|
124
|
+
exitingAnimationXcss = _ref.exitingAnimationXcss,
|
|
105
125
|
role = _ref.role,
|
|
106
126
|
label = _ref.label,
|
|
107
127
|
labelledBy = _ref.labelledBy,
|
|
@@ -114,13 +134,12 @@ export var Popover = /*#__PURE__*/forwardRef(function Popover(_ref, ref) {
|
|
|
114
134
|
var _useAnimatedVisibilit = useAnimatedVisibility({
|
|
115
135
|
isOpen: isOpen,
|
|
116
136
|
animationKind: 'popover',
|
|
117
|
-
|
|
137
|
+
shouldAnimate: shouldAnimate,
|
|
118
138
|
elementRef: ownRef,
|
|
119
139
|
onEnterFinish: onEnterFinish,
|
|
120
140
|
onExitFinish: onExitFinish
|
|
121
141
|
}),
|
|
122
|
-
phase = _useAnimatedVisibilit.phase
|
|
123
|
-
preset = _useAnimatedVisibilit.preset;
|
|
142
|
+
phase = _useAnimatedVisibilit.phase;
|
|
124
143
|
|
|
125
144
|
// True while the host element is mounted (any phase except `closed`).
|
|
126
145
|
// Used as a dep so listener-rebind effects re-attach after a remount.
|
|
@@ -161,6 +180,17 @@ export var Popover = /*#__PURE__*/forwardRef(function Popover(_ref, ref) {
|
|
|
161
180
|
// will close other `auto` popovers when opened. Acceptable trade-off given
|
|
162
181
|
// shrinking browser set without `hint` support.
|
|
163
182
|
var mode = modeProp === 'hint' && !supportsPopoverHint() ? 'auto' : modeProp;
|
|
183
|
+
var popupMotionStyle = useMemo(function () {
|
|
184
|
+
if (!placement || !shouldAnimate) {
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
187
|
+
var _resolvePlacement = resolvePlacement({
|
|
188
|
+
placement: placement
|
|
189
|
+
}),
|
|
190
|
+
axis = _resolvePlacement.axis,
|
|
191
|
+
edge = _resolvePlacement.edge;
|
|
192
|
+
return popupMotionStyles[axis][edge];
|
|
193
|
+
}, [placement, shouldAnimate]);
|
|
164
194
|
|
|
165
195
|
// Prevents toggle handler from calling onClose for our own hidePopover() calls.
|
|
166
196
|
var programmaticCloseRef = useRef(false);
|
|
@@ -182,21 +212,10 @@ export var Popover = /*#__PURE__*/forwardRef(function Popover(_ref, ref) {
|
|
|
182
212
|
var handleToggle = useCallback(function (event) {
|
|
183
213
|
var element = ownRef.current;
|
|
184
214
|
if (event.newState === 'open') {
|
|
185
|
-
if (element) {
|
|
186
|
-
onOpenChange === null || onOpenChange === void 0 || onOpenChange({
|
|
187
|
-
isOpen: true,
|
|
188
|
-
element: element
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
215
|
return;
|
|
192
216
|
}
|
|
193
217
|
if (event.newState === 'closed') {
|
|
194
218
|
if (element) {
|
|
195
|
-
onOpenChange === null || onOpenChange === void 0 || onOpenChange({
|
|
196
|
-
isOpen: false,
|
|
197
|
-
element: element
|
|
198
|
-
});
|
|
199
|
-
|
|
200
219
|
// Nested-popover focus restoration fallback (browser only
|
|
201
220
|
// restores outermost; Firefox skips nested entirely).
|
|
202
221
|
// Restore only when the role moved focus in on open AND the
|
|
@@ -233,7 +252,7 @@ export var Popover = /*#__PURE__*/forwardRef(function Popover(_ref, ref) {
|
|
|
233
252
|
reason: reason
|
|
234
253
|
});
|
|
235
254
|
}
|
|
236
|
-
}, [onClose,
|
|
255
|
+
}, [onClose, role]);
|
|
237
256
|
|
|
238
257
|
// Bind via `useLayoutEffect`, and BEFORE the show/hide layout effect
|
|
239
258
|
// below, so listeners are attached when `showPopover()` synchronously
|
|
@@ -275,23 +294,6 @@ export var Popover = /*#__PURE__*/forwardRef(function Popover(_ref, ref) {
|
|
|
275
294
|
};
|
|
276
295
|
}, [handleToggle, handleBeforeToggle, isVisible]);
|
|
277
296
|
|
|
278
|
-
// Placement-dependent animation CSS vars. Kept separate from show/hide
|
|
279
|
-
// so preset reference changes do not re-trigger visibility. The cleanup
|
|
280
|
-
// restores the previous inline values so a preset change does not leave
|
|
281
|
-
// stale custom properties on the element.
|
|
282
|
-
useLayoutEffect(function () {
|
|
283
|
-
var element = ownRef.current;
|
|
284
|
-
if (!element || !placement) {
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
return setStyle({
|
|
288
|
-
element: element,
|
|
289
|
-
styles: getPopupMotionStyles({
|
|
290
|
-
placement: placement
|
|
291
|
-
})
|
|
292
|
-
});
|
|
293
|
-
}, [preset, placement, isVisible]);
|
|
294
|
-
|
|
295
297
|
// Show/hide based on isOpen. `showPopover`/`hidePopover` are no-ops when
|
|
296
298
|
// already in the target state. Try/catch guards `InvalidStateError` on
|
|
297
299
|
// disconnected elements (StrictMode/concurrent/unmount edge cases).
|
|
@@ -338,7 +340,11 @@ export var Popover = /*#__PURE__*/forwardRef(function Popover(_ref, ref) {
|
|
|
338
340
|
role: role,
|
|
339
341
|
"aria-label": label,
|
|
340
342
|
"aria-labelledby": labelledBy,
|
|
341
|
-
"data-testid": testId
|
|
342
|
-
|
|
343
|
+
"data-testid": testId
|
|
344
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Motion styles are selected at runtime from the placement.
|
|
345
|
+
,
|
|
346
|
+
style: popupMotionStyle,
|
|
347
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop, @atlaskit/ui-styling-standard/local-cx-xcss, @compiled/local-cx-xcss
|
|
348
|
+
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)])
|
|
343
349
|
}, children);
|
|
344
350
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
1
|
+
import type { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import type { XCSSProp } from '@compiled/react';
|
|
3
|
+
import type { StrictXCSSProp } from '@atlaskit/css';
|
|
4
4
|
/**
|
|
5
5
|
* Close reasons produced by the Dialog primitive.
|
|
6
6
|
*
|
|
@@ -23,9 +23,10 @@ type TDialogBaseProps = {
|
|
|
23
23
|
/**
|
|
24
24
|
* Whether the dialog is open.
|
|
25
25
|
*
|
|
26
|
-
* - `true`: calls `showModal()
|
|
27
|
-
*
|
|
28
|
-
*
|
|
26
|
+
* - `true`: calls `showModal()`. When `shouldAnimate` is `true`, the entry
|
|
27
|
+
* animation plays via `@starting-style`.
|
|
28
|
+
* - `false`: calls `close()`. When `shouldAnimate` is `true`, the exit
|
|
29
|
+
* animation plays via `allow-discrete` before the dialog becomes logically closed.
|
|
29
30
|
*
|
|
30
31
|
* **Lifecycle observable to consumers:**
|
|
31
32
|
*
|
|
@@ -48,19 +49,31 @@ type TDialogBaseProps = {
|
|
|
48
49
|
reason: TDialogCloseReason;
|
|
49
50
|
}) => void;
|
|
50
51
|
/**
|
|
51
|
-
*
|
|
52
|
+
* Whether the dialog should animate in and out.
|
|
52
53
|
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
54
|
+
* When `true`, default dialog animation styles are applied. Use `enteringAnimationXcss`
|
|
55
|
+
* and `exitingAnimationXcss` to override the animation used for each phase.
|
|
55
56
|
*/
|
|
56
|
-
|
|
57
|
+
shouldAnimate?: boolean;
|
|
57
58
|
/**
|
|
58
59
|
* Additional Compiled styles applied to the `<dialog>` element.
|
|
59
60
|
*
|
|
60
61
|
* Applied after built-in dialog and animation styles so consumers can own
|
|
61
62
|
* static styling that must live in their package.
|
|
62
63
|
*/
|
|
63
|
-
xcss?:
|
|
64
|
+
xcss?: XCSSProp<'margin' | 'height' | 'width' | 'maxWidth' | 'insetBlockStart' | 'insetInlineStart' | 'insetInlineEnd', never>;
|
|
65
|
+
/**
|
|
66
|
+
* Animation styles applied while the dialog is entering.
|
|
67
|
+
*
|
|
68
|
+
* Only applied when `shouldAnimate` is `true`.
|
|
69
|
+
*/
|
|
70
|
+
enteringAnimationXcss?: StrictXCSSProp<'animationName' | 'animationDuration' | 'animationTimingFunction' | 'animationDelay', never>;
|
|
71
|
+
/**
|
|
72
|
+
* Animation styles applied while the dialog is exiting.
|
|
73
|
+
*
|
|
74
|
+
* Only applied when `shouldAnimate` is `true`.
|
|
75
|
+
*/
|
|
76
|
+
exitingAnimationXcss?: StrictXCSSProp<'animationName' | 'animationDuration' | 'animationTimingFunction' | 'animationDelay', never>;
|
|
64
77
|
/**
|
|
65
78
|
* Additional inline styles applied to the `<dialog>` element.
|
|
66
79
|
*
|
|
@@ -7,14 +7,16 @@ export type TCrossAxisShiftOffset = {
|
|
|
7
7
|
value: string;
|
|
8
8
|
direction: 'forwards' | 'backwards';
|
|
9
9
|
};
|
|
10
|
+
export type TPlacementAxis = 'block' | 'inline';
|
|
11
|
+
export type TPlacementEdge = 'start' | 'end';
|
|
10
12
|
/**
|
|
11
|
-
* Fully-resolved placement (internal). Use `
|
|
13
|
+
* Fully-resolved placement (internal). Use `resolvePlacement` for partial input.
|
|
12
14
|
* `offset.gap` and `offset.crossAxisShift.value` are always CSS
|
|
13
15
|
* length strings.
|
|
14
16
|
*/
|
|
15
17
|
export type TPlacement = {
|
|
16
|
-
axis:
|
|
17
|
-
edge:
|
|
18
|
+
axis: TPlacementAxis;
|
|
19
|
+
edge: TPlacementEdge;
|
|
18
20
|
align: 'start' | 'center' | 'end';
|
|
19
21
|
offset: {
|
|
20
22
|
gap: string;
|
|
@@ -53,6 +55,6 @@ export type TPlacementOptions = {
|
|
|
53
55
|
* `offset.gap: token('space.100', '8px')`,
|
|
54
56
|
* `offset.crossAxisShift: { value: '0px', direction: 'forwards' }`.
|
|
55
57
|
*/
|
|
56
|
-
export declare function
|
|
58
|
+
export declare function resolvePlacement({ placement }: {
|
|
57
59
|
placement: TPlacementOptions;
|
|
58
60
|
}): TPlacement;
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import { type RefObject } from 'react';
|
|
2
2
|
type TAnimationKind = 'dialog' | 'popover';
|
|
3
|
-
/**
|
|
4
|
-
* Animation config for entry/exit transitions.
|
|
5
|
-
*
|
|
6
|
-
* Currently no configuration is supported via this prop,
|
|
7
|
-
* and this is just a placeholder.
|
|
8
|
-
*/
|
|
9
|
-
export type TAnimationConfig = never;
|
|
10
3
|
type TUseAnimatedVisibilityArgs = {
|
|
11
4
|
/**
|
|
12
5
|
* Whether the element is logically open.
|
|
@@ -20,7 +13,7 @@ type TUseAnimatedVisibilityArgs = {
|
|
|
20
13
|
* Animation config for entry/exit transitions.
|
|
21
14
|
* Pass `false` or `undefined` to disable animation.
|
|
22
15
|
*/
|
|
23
|
-
|
|
16
|
+
shouldAnimate: boolean;
|
|
24
17
|
/**
|
|
25
18
|
* Ref to the DOM element that plays the entry/exit transitions.
|
|
26
19
|
* Used to listen for `transitionend`.
|
|
@@ -49,11 +42,6 @@ type TUseAnimatedVisibilityResult = {
|
|
|
49
42
|
* trapping, listeners that must outlive the exit).
|
|
50
43
|
*/
|
|
51
44
|
phase: TPhase;
|
|
52
|
-
/**
|
|
53
|
-
* Resolved animation preset (styles applied via the host element's `css`
|
|
54
|
-
* prop), or `null` if animation is disabled.
|
|
55
|
-
*/
|
|
56
|
-
preset: boolean | TAnimationConfig | null;
|
|
57
45
|
};
|
|
58
46
|
/**
|
|
59
47
|
* Visibility lifecycle phase shared between `useAnimatedVisibility`,
|
|
@@ -116,5 +104,5 @@ export type TPhase = 'closed' | 'entering' | 'open' | 'exiting';
|
|
|
116
104
|
* Every effect dispatches on the single `phase` value instead of a
|
|
117
105
|
* cross-product of booleans.
|
|
118
106
|
*/
|
|
119
|
-
export declare function useAnimatedVisibility({ isOpen, animationKind,
|
|
107
|
+
export declare function useAnimatedVisibility({ isOpen, animationKind, shouldAnimate, elementRef, onEnterFinish, onExitFinish, }: TUseAnimatedVisibilityArgs): TUseAnimatedVisibilityResult;
|
|
120
108
|
export {};
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* to enumerate every placement (e.g. for a settings dropdown). New code
|
|
6
6
|
* should use the object-based `TPlacementOptions` directly.
|
|
7
7
|
*/
|
|
8
|
-
export declare const LEGACY_PLACEMENTS: readonly [
|
|
8
|
+
export declare const LEGACY_PLACEMENTS: readonly ['auto', 'auto-start', 'auto-end', 'top', 'top-start', 'top-center', 'top-end', 'bottom', 'bottom-start', 'bottom-center', 'bottom-end', 'right', 'right-start', 'right-end', 'left', 'left-start', 'left-end'];
|
|
9
9
|
export type TLegacyPlacement = (typeof LEGACY_PLACEMENTS)[number];
|