@atlaskit/top-layer 1.10.0 → 2.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 CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/top-layer
2
2
 
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [`3f6f3bd7da074`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3f6f3bd7da074) -
8
+ Updates the Top Layer animation API:
9
+ - Renames `animate` to `shouldAnimate` and simplifies the type to just `boolean`, removing unused
10
+ config type
11
+ - Custom animation overrides should now be applied via the `enteringAnimationXcss` and
12
+ `exitingAnimationXcss` props.
13
+
14
+ ## 1.10.1
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies
19
+
3
20
  ## 1.10.0
4
21
 
5
22
  ### Minor Changes
package/README.md CHANGED
@@ -12,7 +12,6 @@ placement — compose it with the `useAnchorPosition` hook when you need anchor-
12
12
 
13
13
  ```tsx
14
14
  import { useRef } from 'react';
15
- import { slideAndFade } from '@atlaskit/top-layer/animations';
16
15
  import { getAriaForTrigger } from '@atlaskit/top-layer/get-aria-for-trigger';
17
16
  import { Popover } from '@atlaskit/top-layer/popover';
18
17
  import { PopoverSurface } from '@atlaskit/top-layer/popover-surface';
@@ -45,7 +44,7 @@ function MyPopup({ isOpen, onClose }: { isOpen: boolean; onClose: () => void })
45
44
  role="dialog"
46
45
  label="Settings"
47
46
  isOpen={isOpen}
48
- animate={slideAndFade()}
47
+ shouldAnimate
49
48
  onClose={onClose}
50
49
  >
51
50
  <PopoverSurface>Content here</PopoverSurface>
@@ -87,7 +86,7 @@ Compound component for modal dialogs using the native `<dialog>` element with `.
87
86
 
88
87
  ## Animations
89
88
 
90
- Both `Popover` and `Dialog` support CSS-based entry/exit animations via the `animate` prop.
89
+ Both `Popover` and `Dialog` support CSS-based entry/exit animations via the `shouldAnimate` prop.
91
90
  Animations use [`@starting-style`](https://developer.mozilla.org/en-US/docs/Web/CSS/@starting-style)
92
91
  for entry and
93
92
  [`allow-discrete`](https://developer.mozilla.org/en-US/docs/Web/CSS/transition-behavior) on
@@ -109,15 +108,12 @@ import {
109
108
 
110
109
  ### Popover animation
111
110
 
112
- Pass a preset to `Popover`:
111
+ Pass `shouldAnimate` to enable the default popover entry and exit animation:
113
112
 
114
113
  ```tsx
115
- import { slideAndFade } from '@atlaskit/top-layer/animations';
116
114
  import { Popover } from '@atlaskit/top-layer/popover';
117
115
 
118
- const animation = slideAndFade();
119
-
120
- <Popover animate={animation} role="dialog" label="My popover">
116
+ <Popover shouldAnimate role="dialog" label="My popover" isOpen={isOpen}>
121
117
  Content
122
118
  </Popover>;
123
119
  ```
@@ -125,31 +121,23 @@ const animation = slideAndFade();
125
121
  For overlay styling (background, shadow, border-radius), wrap children in `PopoverSurface` from
126
122
  `@atlaskit/top-layer/popover-surface`.
127
123
 
128
- Available popover presets:
129
-
130
- - `slideAndFade({ distance? })` — directional slide + opacity (default for tooltip)
131
- - `fade` — simple opacity transition
132
- - `scaleAndFade` — scale from 0.95 + opacity (suitable for menus/dropdowns)
124
+ Use `enteringAnimationXcss` and `exitingAnimationXcss` when a composed component needs to override
125
+ the phase-specific animation styles.
133
126
 
134
127
  ### Dialog animation
135
128
 
136
- Pass a preset to `Dialog.Content`:
129
+ Pass `shouldAnimate` to enable the default dialog entry and exit animation:
137
130
 
138
131
  ```tsx
139
- import { dialogSlideUpAndFade } from '@atlaskit/top-layer/animations';
140
-
141
- const animation = dialogSlideUpAndFade();
132
+ import { Dialog } from '@atlaskit/top-layer/dialog';
142
133
 
143
- <Dialog.Content animate={animation}>
144
- <Dialog.Surface>...</Dialog.Surface>
145
- </Dialog.Content>;
134
+ <Dialog shouldAnimate isOpen={isOpen} onClose={onClose} label="My dialog">
135
+ Content
136
+ </Dialog>;
146
137
  ```
147
138
 
148
- Available dialog presets:
149
-
150
- - `dialogSlideUpAndFade({ distance? })` — slide up + opacity with backdrop fade (matches legacy
151
- modal entrance)
152
- - `dialogFade` — simple opacity + backdrop fade
139
+ Use `enteringAnimationXcss` and `exitingAnimationXcss` when a composed component needs to override
140
+ the phase-specific animation styles.
153
141
 
154
142
  ### Progressive enhancement
155
143
 
@@ -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
- ._vhgsxbuz[open]::-ms-backdrop{animation:var(--ds-blanket-enter,.25s cubic-bezier(.4,0,0,1) FadeIn0to100)}
6
- ._vhgsxbuz[open]::backdrop{animation:var(--ds-blanket-enter,.25s cubic-bezier(.4,0,0,1) FadeIn0to100)}
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
- ._1o51q7pw{animation-fill-mode:forwards}
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
- ._yhpqi9qs::-ms-backdrop{transition-duration:var(--ds-duration-medium,.2s)}
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)}}
@@ -10,23 +10,15 @@ exports.Dialog = void 0;
10
10
  require("./dialog-content.compiled.css");
11
11
  var _runtime = require("@compiled/react/runtime");
12
12
  var _react = _interopRequireWildcard(require("react"));
13
+ var _react2 = require("@compiled/react");
13
14
  var _bindEventListener = require("bind-event-listener");
14
15
  var _mergeRefs = _interopRequireDefault(require("@atlaskit/ds-lib/merge-refs"));
15
16
  var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
16
- var _openLayerObserver = require("@atlaskit/layering/experimental/open-layer-observer");
17
+ var _useNotifyOpenLayerObserver = require("@atlaskit/layering/use-notify-open-layer-observer");
17
18
  var _useAnimatedVisibility = require("../internal/use-animated-visibility");
18
19
  var _useFocusWrap = require("../internal/use-focus-wrap");
19
20
  var _useSafariEscapeFix2 = require("../internal/use-safari-escape-fix");
20
21
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
21
- // These animation styles use the non-strict Compiled cssMap because they rely
22
- // on `@starting-style`, `[open]`, and `allow-discrete`. Keep them in this
23
- // component so the Compiled transform can statically extract every referenced
24
- // style.
25
- var dialogAnimationStyles = {
26
- root: "_k8m011k7 _1oeci9qs _1s9z1a5r _1fsl1mzy _1oil1d08",
27
- motion: "_y44vgeqi _1o51q7pw _1iu47kvq _1i0neoah"
28
- };
29
-
30
22
  // Surface reset — see the rationale on `surfaceResetStyles` in `popover/popover.tsx`.
31
23
  // Neutralises inherited text-layout properties (e.g. `white-space: nowrap`) that leak
32
24
  // into the top-layer surface. Excludes `color`/`font` (theming) and
@@ -39,13 +31,17 @@ var dialogAnimationStyles = {
39
31
  var surfaceResetStyles = {
40
32
  root: "_o5724jg8 _1nmz4jg8 _1i4q4jg8 _y3gnv2br _azhwidpf _1p1dglyw"
41
33
  };
42
- var styles = {
43
- dialog: "_19itglyw _19pk1wug _2hwx1wug _otyr1wug _18u01wug _1q51ze3t _y4tize3t _85i5ze3t _bozgze3t _p12fglyw _c71lglyw _bfhk1j28 _bl8aglyw _156y147i _10aiglyw _aeld147i"
34
+ var dialogStyles = {
35
+ root: "_19itglyw _19pk1wug _2hwx1wug _otyr1wug _18u01wug _1q51ze3t _y4tize3t _85i5ze3t _bozgze3t _p12fglyw _c71lglyw _bfhk1j28",
36
+ motion: "_k8m011k7 _1oeci9qs _1s9z1a5r _1o511hrf _bl8aglyw _156y147i",
37
+ enter: "_y44v7kvq",
38
+ exit: "_y44vgeqi"
44
39
  };
45
40
  var backdropStyles = {
46
41
  root: "_1ltk1i5c",
47
42
  hidden: "_1ltk1j28",
48
- motion: "_1m5e1op4 _1jhdq7pw _njwk11k7 _yhpqi9qs _1fyf1a5r _vhgsxbuz _1rsueoah _l57nglyw _1sbq147i _19awglyw _1i6z147i"
43
+ enter: "_1m5exbuz",
44
+ exit: "_1m5e1op4"
49
45
  };
50
46
 
51
47
  /**
@@ -71,9 +67,11 @@ var Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(function Dialo
71
67
  onClose = _ref.onClose,
72
68
  onEnterFinish = _ref.onEnterFinish,
73
69
  onExitFinish = _ref.onExitFinish,
74
- _ref$animate = _ref.animate,
75
- animate = _ref$animate === void 0 ? false : _ref$animate,
70
+ _ref$shouldAnimate = _ref.shouldAnimate,
71
+ shouldAnimate = _ref$shouldAnimate === void 0 ? false : _ref$shouldAnimate,
76
72
  consumerXcss = _ref.xcss,
73
+ enteringAnimationXcss = _ref.enteringAnimationXcss,
74
+ exitingAnimationXcss = _ref.exitingAnimationXcss,
77
75
  style = _ref.style,
78
76
  testId = _ref.testId,
79
77
  providedId = _ref.id,
@@ -87,13 +85,12 @@ var Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(function Dialo
87
85
  var _useAnimatedVisibilit = (0, _useAnimatedVisibility.useAnimatedVisibility)({
88
86
  isOpen: isOpen,
89
87
  animationKind: 'dialog',
90
- animate: animate,
88
+ shouldAnimate: shouldAnimate,
91
89
  elementRef: ownRef,
92
90
  onEnterFinish: onEnterFinish,
93
91
  onExitFinish: onExitFinish
94
92
  }),
95
- phase = _useAnimatedVisibilit.phase,
96
- preset = _useAnimatedVisibilit.preset;
93
+ phase = _useAnimatedVisibilit.phase;
97
94
 
98
95
  // True while the host element is mounted (any phase except `closed`).
99
96
  // Used as a dep so listener-rebind effects re-attach after a remount.
@@ -112,7 +109,7 @@ var Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(function Dialo
112
109
 
113
110
  // Notify the open layer observer so app-coordination features
114
111
  // (open-count subscriptions) work with top-layer dialogs.
115
- (0, _openLayerObserver.useNotifyOpenLayerObserver)({
112
+ (0, _useNotifyOpenLayerObserver.useNotifyOpenLayerObserver)({
116
113
  type: 'modal',
117
114
  isOpen: isOpen,
118
115
  // No-op: no current use case for programmatic close via OpenLayerObserver.
@@ -198,6 +195,7 @@ var Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(function Dialo
198
195
  if (!isVisible) {
199
196
  return null;
200
197
  }
198
+ var shouldAnimateBackdrop = !shouldHideBackdrop && shouldAnimate;
201
199
  return /*#__PURE__*/_react.default.createElement("dialog", {
202
200
  ref: combinedRef,
203
201
  id: dialogId
@@ -211,7 +209,11 @@ var Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(function Dialo
211
209
  "aria-labelledby": label ? undefined : labelledBy,
212
210
  style: style,
213
211
  onCancel: handleCancel,
214
- "data-testid": testId,
215
- className: (0, _runtime.ax)([styles.dialog, surfaceResetStyles.root, shouldHideBackdrop ? backdropStyles.hidden : backdropStyles.root, preset && backdropStyles.motion, preset && dialogAnimationStyles.root, preset && dialogAnimationStyles.motion, consumerXcss])
212
+ "data-testid": testId
213
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop, @atlaskit/ui-styling-standard/local-cx-xcss, @compiled/local-cx-xcss
214
+ ,
215
+ className: (0, _runtime.ax)([
216
+ // Dialog styles
217
+ 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, (0, _react2.cx)(consumerXcss, shouldAnimate && phase === 'entering' && enteringAnimationXcss, shouldAnimate && phase === 'exiting' && exitingAnimationXcss)])
216
218
  }, children);
217
219
  });
@@ -67,13 +67,6 @@ function runOnTransitionEndOrTimeout(_ref) {
67
67
  return teardown;
68
68
  }
69
69
 
70
- /**
71
- * Animation config for entry/exit transitions.
72
- *
73
- * Currently no configuration is supported via this prop,
74
- * and this is just a placeholder.
75
- */
76
-
77
70
  /**
78
71
  * Visibility lifecycle phase shared between `useAnimatedVisibility`,
79
72
  * `useFocusWrap`, `useInitialFocus`, and the `Popover` / `Dialog`
@@ -138,17 +131,11 @@ function runOnTransitionEndOrTimeout(_ref) {
138
131
  function useAnimatedVisibility(_ref2) {
139
132
  var isOpen = _ref2.isOpen,
140
133
  animationKind = _ref2.animationKind,
141
- animate = _ref2.animate,
134
+ shouldAnimate = _ref2.shouldAnimate,
142
135
  elementRef = _ref2.elementRef,
143
136
  onEnterFinish = _ref2.onEnterFinish,
144
137
  onExitFinish = _ref2.onExitFinish;
145
- // Styles are applied via the `css` prop on the host element (see `Popover`
146
- // and `Dialog`), so there is no longer any CSS injection step. Normalize a
147
- // falsy `animate` to `null`.
148
- var preset = animate || null;
149
-
150
- // False when there is no preset or `prefers-reduced-motion` is set.
151
- var willAnimate = Boolean(animate) && !(0, _reducedMotion.prefersReducedMotion)();
138
+ var willAnimate = shouldAnimate && !(0, _reducedMotion.prefersReducedMotion)();
152
139
 
153
140
  // Promote `closed → entering`/`closed → open` synchronously during
154
141
  // render so the host element mounts in the same commit as the open
@@ -317,7 +304,6 @@ function useAnimatedVisibility(_ref2) {
317
304
  }
318
305
  }, [phase, willAnimate]);
319
306
  return {
320
- phase: phase,
321
- preset: preset
307
+ phase: phase
322
308
  };
323
309
  }
@@ -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
- ._y44vof1f{animation:var(--ds-popover-motion-exit)}._12t71ign:popover-open{transition-duration:var(--ds-duration-short,.15s)}
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
- ._1o51q7pw{animation-fill-mode:forwards}
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}._156yru3m{transition-duration:0s}._8rmvglyw:popover-open{animation-name:none}._2qm2ru3m:popover-open{transition-duration:0s}}
26
+ @media (prefers-reduced-motion:reduce){._bl8aglyw{animation-name:none}._156y147i{transition-duration:var(--ds-duration-instant,0ms)}}
@@ -10,10 +10,11 @@ exports.Popover = void 0;
10
10
  require("./popover.compiled.css");
11
11
  var _runtime = require("@compiled/react/runtime");
12
12
  var _react = _interopRequireWildcard(require("react"));
13
+ var _react2 = require("@compiled/react");
13
14
  var _bindEventListener = require("bind-event-listener");
14
15
  var _mergeRefs = _interopRequireDefault(require("@atlaskit/ds-lib/merge-refs"));
15
16
  var _once = _interopRequireDefault(require("@atlaskit/ds-lib/once"));
16
- var _openLayerObserver = require("@atlaskit/layering/experimental/open-layer-observer");
17
+ var _useNotifyOpenLayerObserver = require("@atlaskit/layering/use-notify-open-layer-observer");
17
18
  var _roleTypes = require("../internal/role-types");
18
19
  var _setStyle = require("../internal/set-style");
19
20
  var _useAnimatedVisibility = require("../internal/use-animated-visibility");
@@ -34,14 +35,6 @@ var supportsPopoverHint = (0, _once.default)(function () {
34
35
  return element.popover === 'hint';
35
36
  });
36
37
 
37
- // These animation styles use the non-strict Compiled cssMap because they rely
38
- // on `@starting-style`, `:popover-open`, `[dir='rtl']`, and `allow-discrete`.
39
- // Keep them in this component so the Compiled transform can statically extract
40
- // every referenced style.
41
- var popoverAnimationStyles = {
42
- root: "_y44vof1f _k8m011k7 _1oecdn4k _1s9z1a5r _1o51q7pw _5sagdn4k _1pgl1lbj _15ns179n _12t71ign _n70peoah _1psg1ign _o8i7indk _bl8aglyw _156yru3m _8rmvglyw _2qm2ru3m"
43
- };
44
-
45
38
  // Surface reset — neutralises inherited text-layout properties (e.g.
46
39
  // `white-space: nowrap` from an `@atlaskit/select` option) that leak into a
47
40
  // top-layer element because, for CSS inheritance, it is still a DOM child of its
@@ -57,7 +50,10 @@ var surfaceResetStyles = {
57
50
  root: "_o5724jg8 _1nmz4jg8 _1i4q4jg8 _y3gnv2br _azhwidpf _1p1dglyw"
58
51
  };
59
52
  var styles = {
60
- root: "_19itglyw _ca0qidpf _u5f3idpf _n3tdidpf _19bvidpf _19pkidpf _2hwxidpf _otyridpf _18u0idpf _1r041wug _1reoewfl _18m9ewfl _bfhk1j28 _4t3i1wug"
53
+ root: "_19itglyw _ca0qidpf _u5f3idpf _n3tdidpf _19bvidpf _19pkidpf _2hwxidpf _otyridpf _18u0idpf _1r041wug _1reoewfl _18m9ewfl _bfhk1j28 _4t3i1wug",
54
+ motion: "_k8m011k7 _1oecdn4k _1s9z1a5r _1o511hrf _bl8aglyw _156y147i",
55
+ enter: "_y44v179n",
56
+ exit: "_y44vof1f"
61
57
  };
62
58
  /**
63
59
  * Roles registered with the open layer observer as `popup`, so `closeLayers()`
@@ -105,12 +101,13 @@ var Popover = exports.Popover = /*#__PURE__*/(0, _react.forwardRef)(function Pop
105
101
  onOpenChange = _ref.onOpenChange,
106
102
  onEnterFinish = _ref.onEnterFinish,
107
103
  onExitFinish = _ref.onExitFinish,
108
- _ref$animate = _ref.animate,
109
- animate = _ref$animate === void 0 ? false : _ref$animate,
104
+ _ref$shouldAnimate = _ref.shouldAnimate,
105
+ shouldAnimate = _ref$shouldAnimate === void 0 ? false : _ref$shouldAnimate,
110
106
  placement = _ref.placement,
111
107
  testId = _ref.testId,
112
108
  isOpen = _ref.isOpen,
113
- consumerXcss = _ref.xcss,
109
+ enteringAnimationXcss = _ref.enteringAnimationXcss,
110
+ exitingAnimationXcss = _ref.exitingAnimationXcss,
114
111
  role = _ref.role,
115
112
  label = _ref.label,
116
113
  labelledBy = _ref.labelledBy,
@@ -123,13 +120,12 @@ var Popover = exports.Popover = /*#__PURE__*/(0, _react.forwardRef)(function Pop
123
120
  var _useAnimatedVisibilit = (0, _useAnimatedVisibility.useAnimatedVisibility)({
124
121
  isOpen: isOpen,
125
122
  animationKind: 'popover',
126
- animate: animate,
123
+ shouldAnimate: shouldAnimate,
127
124
  elementRef: ownRef,
128
125
  onEnterFinish: onEnterFinish,
129
126
  onExitFinish: onExitFinish
130
127
  }),
131
- phase = _useAnimatedVisibilit.phase,
132
- preset = _useAnimatedVisibilit.preset;
128
+ phase = _useAnimatedVisibilit.phase;
133
129
 
134
130
  // True while the host element is mounted (any phase except `closed`).
135
131
  // Used as a dep so listener-rebind effects re-attach after a remount.
@@ -159,7 +155,7 @@ var Popover = exports.Popover = /*#__PURE__*/(0, _react.forwardRef)(function Pop
159
155
  reason: 'programmatic'
160
156
  });
161
157
  }, [onClose]);
162
- (0, _openLayerObserver.useNotifyOpenLayerObserver)({
158
+ (0, _useNotifyOpenLayerObserver.useNotifyOpenLayerObserver)({
163
159
  type: role && POPUP_ROLES.has(role) ? 'popup' : undefined,
164
160
  isOpen: isOpen,
165
161
  onClose: handleObserverClose
@@ -299,7 +295,7 @@ var Popover = exports.Popover = /*#__PURE__*/(0, _react.forwardRef)(function Pop
299
295
  placement: placement
300
296
  })
301
297
  });
302
- }, [preset, placement, isVisible]);
298
+ }, [placement, isVisible]);
303
299
 
304
300
  // Show/hide based on isOpen. `showPopover`/`hidePopover` are no-ops when
305
301
  // already in the target state. Try/catch guards `InvalidStateError` on
@@ -348,6 +344,7 @@ var Popover = exports.Popover = /*#__PURE__*/(0, _react.forwardRef)(function Pop
348
344
  "aria-label": label,
349
345
  "aria-labelledby": labelledBy,
350
346
  "data-testid": testId,
351
- className: (0, _runtime.ax)([styles.root, surfaceResetStyles.root, preset && popoverAnimationStyles.root, consumerXcss])
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: (0, _runtime.ax)([styles.root, surfaceResetStyles.root, shouldAnimate && phase === 'entering' && styles.enter, shouldAnimate && phase === 'exiting' && styles.exit, shouldAnimate && styles.motion, (0, _react2.cx)(shouldAnimate && phase === 'entering' && enteringAnimationXcss, shouldAnimate && phase === 'exiting' && exitingAnimationXcss)])
352
349
  }, children);
353
350
  });
@@ -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
- ._vhgsxbuz[open]::-ms-backdrop{animation:var(--ds-blanket-enter,.25s cubic-bezier(.4,0,0,1) FadeIn0to100)}
6
- ._vhgsxbuz[open]::backdrop{animation:var(--ds-blanket-enter,.25s cubic-bezier(.4,0,0,1) FadeIn0to100)}
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
- ._1o51q7pw{animation-fill-mode:forwards}
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
- ._yhpqi9qs::-ms-backdrop{transition-duration:var(--ds-duration-medium,.2s)}
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)}}
@@ -2,22 +2,14 @@
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';
8
- import { useNotifyOpenLayerObserver } from '@atlaskit/layering/experimental/open-layer-observer';
9
+ import { useNotifyOpenLayerObserver } from '@atlaskit/layering/use-notify-open-layer-observer';
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 styles = {
34
- dialog: "_19itglyw _19pk1wug _2hwx1wug _otyr1wug _18u01wug _1q51ze3t _y4tize3t _85i5ze3t _bozgze3t _p12fglyw _c71lglyw _bfhk1j28 _bl8aglyw _156y147i _10aiglyw _aeld147i"
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
- motion: "_1m5e1op4 _1jhdq7pw _njwk11k7 _yhpqi9qs _1fyf1a5r _vhgsxbuz _1rsueoah _l57nglyw _1sbq147i _19awglyw _1i6z147i"
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
- animate = false,
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
- animate,
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
- className: ax([styles.dialog, surfaceResetStyles.root, shouldHideBackdrop ? backdropStyles.hidden : backdropStyles.root, preset && backdropStyles.motion, preset && dialogAnimationStyles.root, preset && dialogAnimationStyles.motion, consumerXcss])
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
  });
@@ -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
- animate,
127
+ shouldAnimate,
135
128
  elementRef,
136
129
  onEnterFinish,
137
130
  onExitFinish
138
131
  }) {
139
- // Styles are applied via the `css` prop on the host element (see `Popover`
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
  }