@atlaskit/top-layer 1.5.0 → 1.6.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/dialog/animations.js +90 -0
  3. package/dist/cjs/dialog/dialog-content.compiled.css +17 -25
  4. package/dist/cjs/dialog/dialog-content.js +29 -41
  5. package/dist/cjs/entry-points/animations.js +9 -8
  6. package/dist/cjs/internal/use-animated-visibility.js +40 -8
  7. package/dist/cjs/popover/animations.js +196 -0
  8. package/dist/cjs/popover/popover.compiled.css +17 -14
  9. package/dist/cjs/popover/popover.js +21 -30
  10. package/dist/es2019/dialog/animations.js +80 -0
  11. package/dist/es2019/dialog/dialog-content.compiled.css +17 -25
  12. package/dist/es2019/dialog/dialog-content.js +29 -38
  13. package/dist/es2019/entry-points/animations.js +2 -1
  14. package/dist/es2019/internal/use-animated-visibility.js +41 -8
  15. package/dist/es2019/popover/animations.js +190 -0
  16. package/dist/es2019/popover/popover.compiled.css +17 -14
  17. package/dist/es2019/popover/popover.js +21 -27
  18. package/dist/esm/dialog/animations.js +82 -0
  19. package/dist/esm/dialog/dialog-content.compiled.css +17 -25
  20. package/dist/esm/dialog/dialog-content.js +29 -41
  21. package/dist/esm/entry-points/animations.js +2 -1
  22. package/dist/esm/internal/use-animated-visibility.js +41 -8
  23. package/dist/esm/popover/animations.js +187 -0
  24. package/dist/esm/popover/popover.compiled.css +17 -14
  25. package/dist/esm/popover/popover.js +21 -30
  26. package/dist/types/dialog/animations.d.ts +57 -0
  27. package/dist/types/dialog/types.d.ts +2 -2
  28. package/dist/types/entry-points/animations.d.ts +2 -2
  29. package/dist/types/internal/use-animated-visibility.d.ts +35 -6
  30. package/dist/types/popover/animations.d.ts +52 -0
  31. package/dist/types/popover/types.d.ts +3 -3
  32. package/package.json +27 -9
  33. package/dist/cjs/animations/presets.js +0 -298
  34. package/dist/cjs/animations/types.js +0 -5
  35. package/dist/es2019/animations/presets.js +0 -285
  36. package/dist/es2019/animations/types.js +0 -1
  37. package/dist/esm/animations/presets.js +0 -285
  38. package/dist/esm/animations/types.js +0 -1
  39. package/dist/types/animations/presets.d.ts +0 -128
  40. package/dist/types/animations/types.d.ts +0 -34
@@ -2,32 +2,35 @@
2
2
  ._15ns179n:popover-open{animation:var(--ds-popover-motion-enter)}
3
3
  ._19itglyw{border:none}
4
4
  ._1r041wug{inset:auto}
5
- ._y44vof1f{animation:var(--ds-popover-motion-exit)}._12t71ttt:popover-open{transition-duration:.35s}
6
- ._162xglyw:popover-open{transform:none}
5
+ ._y44vof1f{animation:var(--ds-popover-motion-exit)}._12t71ign:popover-open{transition-duration:var(--ds-duration-short,.15s)}
7
6
  ._18m9ewfl{overflow-y:visible}
8
7
  ._18u0idpf{margin-left:0}
9
8
  ._19bvidpf{padding-left:0}
10
9
  ._19pkidpf{margin-top:0}
11
- ._1f6ykb7n:popover-open{opacity:1}
10
+ ._1a5xt94y{--dir:1px}
12
11
  ._1o51q7pw{animation-fill-mode:forwards}
13
- ._1oec6ebc{transition-duration:.15s}
14
- ._1oecluct{transition-duration:175ms}
12
+ ._1oecdn4k{transition-duration:var(--ds-duration-xshort,.1s)}
13
+ ._1pgl1lbj{animation-timing-function:var(--ds-easing-in-practical,cubic-bezier(.6,0,.8,.6))}
14
+ ._1psg1ign:popover-open{animation-duration:var(--ds-duration-short,.15s)}
15
15
  ._1reoewfl{overflow-x:visible}
16
16
  ._1s9z1a5r{transition-behavior:allow-discrete}
17
17
  ._2hwxidpf{margin-right:0}
18
- ._6fl41a34{transition-timing-function:cubic-bezier(.15,1,.3,1)}
18
+ ._5sagdn4k{animation-duration:var(--ds-duration-xshort,.1s)}
19
+ ._71re1bym:popover-open{animation-name:var(--ds-keyframe-fade-in,FadeIn0to100)}
20
+ ._71re1v6b:popover-open{animation-name:var(--ds-keyframe-fade-in,FadeIn0to100),var(--ds-keyframe-scale-in-small,ScaleIn95to100)}
21
+ ._71rervlo:popover-open{animation-name:k1ut9kob,var(--ds-keyframe-fade-in,FadeIn0to100)}
19
22
  ._bfhk1j28{background-color:transparent}
20
23
  ._ca0qidpf{padding-top:0}
24
+ ._j7hq1a5s{animation-name:var(--ds-keyframe-fade-out,FadeOut100to0)}
25
+ ._j7hq1l2h{animation-name:k1e4c1ew,var(--ds-keyframe-fade-out,FadeOut100to0)}
26
+ ._j7hqneez{animation-name:var(--ds-keyframe-fade-out,FadeOut100to0),var(--ds-keyframe-scale-out-small,ScaleOut100to95)}
21
27
  ._k8m011k7{transition-property:overlay,display}
22
- ._k8m01slm{transition-property:opacity,overlay,display}
23
- ._k8m0rv36{transition-property:opacity,transform,overlay,display}
24
28
  ._n3tdidpf{padding-bottom:0}
25
29
  ._n70peoah:popover-open{animation-fill-mode:backwards}
30
+ ._o8i7indk:popover-open{animation-timing-function:var(--ds-easing-out-practical,cubic-bezier(.4,1,.6,1))}
26
31
  ._otyridpf{margin-bottom:0}
27
- ._t9ecgt2x{transform:scale(.95)}
28
- ._t9ecxauz{transform:translate(var(--ds-popover-tx,0),var(--ds-popover-ty,0))}
29
- ._tzy4idpf{opacity:0}
30
32
  ._u5f3idpf{padding-right:0}
31
- [dir=rtl] ._1tz31oq6{transform:translate(calc(var(--ds-popover-tx, 0)*-1),var(--ds-popover-ty,0))}
32
- @media (prefers-reduced-motion:reduce){._156yru3m{transition-duration:0s}._2qm2ru3m:popover-open{transition-duration:0s}._bl8aglyw{animation-name:none}._8rmvglyw:popover-open{animation-name:none}}
33
- @starting-style{._1wuhidpf:popover-open{opacity:0}._1423gt2x:popover-open{transform:scale(.95)}._1423xauz:popover-open{transform:translate(var(--ds-popover-tx,0),var(--ds-popover-ty,0))}[dir=rtl] ._1dml1oq6:popover-open{transform:translate(calc(var(--ds-popover-tx, 0)*-1),var(--ds-popover-ty,0))}}
33
+ [dir=rtl] ._34bx1n1a{--dir:-1px}
34
+ @keyframes k1e4c1ew{0%{transform:none}to{transform:translate(calc(var(--dir)*var(--ds-popover-tx, 0)),var(--ds-popover-ty,0))}}
35
+ @keyframes k1ut9kob{0%{transform:translate(calc(var(--dir)*var(--ds-popover-tx, 0)),var(--ds-popover-ty,0))}to{transform:none}}
36
+ @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}}
@@ -9,15 +9,13 @@ Object.defineProperty(exports, "__esModule", {
9
9
  exports.Popover = void 0;
10
10
  require("./popover.compiled.css");
11
11
  var _runtime = require("@compiled/react/runtime");
12
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
12
  var _react = _interopRequireWildcard(require("react"));
16
13
  var _bindEventListener = require("bind-event-listener");
17
14
  var _mergeRefs = _interopRequireDefault(require("@atlaskit/ds-lib/merge-refs"));
18
15
  var _once = _interopRequireDefault(require("@atlaskit/ds-lib/once"));
19
16
  var _openLayerObserver = require("@atlaskit/layering/experimental/open-layer-observer");
20
17
  var _roleTypes = require("../internal/role-types");
18
+ var _setStyle = require("../internal/set-style");
21
19
  var _useAnimatedVisibility = require("../internal/use-animated-visibility");
22
20
  var _useFocusWrap = require("../internal/use-focus-wrap");
23
21
  var _useInitialFocus = require("../internal/use-initial-focus");
@@ -34,16 +32,19 @@ var supportsPopoverHint = (0, _once.default)(function () {
34
32
  element.setAttribute('popover', 'hint');
35
33
  return element.popover === 'hint';
36
34
  });
35
+ var slideInKeyframes = null;
36
+ var slideOutKeyframes = null;
37
37
 
38
38
  // These animation styles use the non-strict Compiled cssMap because they rely
39
39
  // on `@starting-style`, `:popover-open`, `[dir='rtl']`, and `allow-discrete`.
40
40
  // Keep them in this component so the Compiled transform can statically extract
41
41
  // every referenced style.
42
42
  var popoverAnimationStyles = {
43
- popupMotion: "_y44vof1f _1o51q7pw _k8m011k7 _1oec6ebc _1s9z1a5r _15ns179n _n70peoah _bl8aglyw _156yru3m _8rmvglyw _2qm2ru3m",
44
- slideAndFade: "_tzy4idpf _t9ecxauz _k8m0rv36 _1oecluct _6fl41a34 _1s9z1a5r _1tz31oq6 _1f6ykb7n _162xglyw _12t71ttt _1wuhidpf _1423xauz _156yru3m _2qm2ru3m _1dml1oq6",
45
- fade: "_tzy4idpf _k8m01slm _1oecluct _6fl41a34 _1s9z1a5r _1f6ykb7n _12t71ttt _1wuhidpf _156yru3m _2qm2ru3m",
46
- scaleAndFade: "_tzy4idpf _t9ecgt2x _k8m0rv36 _1oecluct _6fl41a34 _1s9z1a5r _1f6ykb7n _162xglyw _12t71ttt _1wuhidpf _1423gt2x _156yru3m _2qm2ru3m"
43
+ root: "_k8m011k7 _1oecdn4k _1s9z1a5r _1a5xt94y _12t71ign _34bx1n1a _bl8aglyw _156yru3m _8rmvglyw _2qm2ru3m",
44
+ motion: "_y44vof1f _1o51q7pw _15ns179n _n70peoah",
45
+ 'slide-and-fade': "_j7hq1l2h _5sagdn4k _1pgl1lbj _71rervlo _1psg1ign _o8i7indk",
46
+ fade: "_j7hq1a5s _5sagdn4k _1pgl1lbj _71re1bym _1psg1ign _o8i7indk",
47
+ 'scale-and-fade': "_j7hqneez _5sagdn4k _1pgl1lbj _71re1v6b _1psg1ign _o8i7indk"
47
48
  };
48
49
  var styles = {
49
50
  root: "_19itglyw _ca0qidpf _u5f3idpf _n3tdidpf _19bvidpf _19pkidpf _2hwxidpf _otyridpf _18u0idpf _1r041wug _1reoewfl _18m9ewfl _bfhk1j28"
@@ -98,7 +99,7 @@ var Popover = exports.Popover = /*#__PURE__*/(0, _react.forwardRef)(function Pop
98
99
  placement = _ref.placement,
99
100
  testId = _ref.testId,
100
101
  isOpen = _ref.isOpen,
101
- xcssFromProps = _ref.xcss,
102
+ consumerXcss = _ref.xcss,
102
103
  role = _ref.role,
103
104
  label = _ref.label,
104
105
  labelledBy = _ref.labelledBy,
@@ -273,27 +274,19 @@ var Popover = exports.Popover = /*#__PURE__*/(0, _react.forwardRef)(function Pop
273
274
 
274
275
  // Placement-dependent animation CSS vars. Kept separate from show/hide
275
276
  // so preset reference changes do not re-trigger visibility. The cleanup
276
- // removes the properties so a preset change does not leave stale custom
277
- // properties on the element.
277
+ // restores the previous inline values so a preset change does not leave
278
+ // stale custom properties on the element.
278
279
  (0, _react.useLayoutEffect)(function () {
279
280
  var element = ownRef.current;
280
- if (!element || !(preset !== null && preset !== void 0 && preset.getProperties) || !placement) {
281
+ if (!element || !(preset !== null && preset !== void 0 && preset.getStyles) || !placement) {
281
282
  return;
282
283
  }
283
- var props = preset.getProperties({
284
- placement: placement
284
+ return (0, _setStyle.setStyle)({
285
+ element: element,
286
+ styles: preset.getStyles({
287
+ placement: placement
288
+ })
285
289
  });
286
- Object.entries(props).forEach(function (_ref2) {
287
- var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
288
- key = _ref3[0],
289
- value = _ref3[1];
290
- element.style.setProperty(key, String(value));
291
- });
292
- return function () {
293
- Object.keys(props).forEach(function (key) {
294
- element.style.removeProperty(key);
295
- });
296
- };
297
290
  }, [preset, placement, isVisible]);
298
291
 
299
292
  // Show/hide based on isOpen. `showPopover`/`hidePopover` are no-ops when
@@ -332,7 +325,7 @@ var Popover = exports.Popover = /*#__PURE__*/(0, _react.forwardRef)(function Pop
332
325
  if (!isVisible) {
333
326
  return null;
334
327
  }
335
- return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
328
+ return /*#__PURE__*/_react.default.createElement("div", {
336
329
  ref: combinedRef,
337
330
  id: popoverId
338
331
  // @ts-expect-error -- popover attribute not yet in React types
@@ -342,9 +335,7 @@ var Popover = exports.Popover = /*#__PURE__*/(0, _react.forwardRef)(function Pop
342
335
  role: role,
343
336
  "aria-label": label,
344
337
  "aria-labelledby": labelledBy,
345
- "data-testid": testId
346
- }, preset ? (0, _defineProperty2.default)({}, "data-ds-popover-".concat(preset.name), '') : undefined, {
347
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- xcss prop passes compiled atomic class names
348
- className: (0, _runtime.ax)([styles.root, (preset === null || preset === void 0 ? void 0 : preset.name) === 'popup-motion' && popoverAnimationStyles.popupMotion, (preset === null || preset === void 0 ? void 0 : preset.name) === 'slide-and-fade' && popoverAnimationStyles.slideAndFade, (preset === null || preset === void 0 ? void 0 : preset.name) === 'fade' && popoverAnimationStyles.fade, (preset === null || preset === void 0 ? void 0 : preset.name) === 'scale-and-fade' && popoverAnimationStyles.scaleAndFade, xcssFromProps])
349
- }), children);
338
+ "data-testid": testId,
339
+ className: (0, _runtime.ax)([styles.root, preset && popoverAnimationStyles.root, preset && popoverAnimationStyles[preset.name], consumerXcss])
340
+ }, children);
350
341
  });
@@ -0,0 +1,80 @@
1
+ // `custom` variant currently exists for typing reasons for Drawer
2
+ // not indicative of final API
3
+
4
+ /**
5
+ * Dialog motion animation.
6
+ *
7
+ * Includes backdrop fade animation.
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * import { dialogMotion } from '@atlaskit/top-layer/animations';
12
+ *
13
+ * <Dialog animate={dialogMotion()} isOpen={isOpen} onClose={handleClose} label="...">
14
+ * ...
15
+ * </Dialog>
16
+ * ```
17
+ */
18
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
19
+ export function dialogMotion() {
20
+ return {
21
+ kind: 'dialog',
22
+ name: 'motion'
23
+ };
24
+ }
25
+
26
+ /**
27
+ * Slide up + opacity animation for dialogs.
28
+ *
29
+ * Entry slides up from below; exit slides up and out (asymmetric).
30
+ * Includes backdrop fade animation.
31
+ *
32
+ * @param options.distance - Slide distance in pixels. Defaults to `12`.
33
+ *
34
+ * @example
35
+ * ```tsx
36
+ * import { dialogSlideUpAndFade } from '@atlaskit/top-layer/animations';
37
+ *
38
+ * const animation = dialogSlideUpAndFade();
39
+ * <Dialog animate={animation} isOpen={isOpen} onClose={handleClose} label="...">
40
+ * ...
41
+ * </Dialog>
42
+ * ```
43
+ */
44
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
45
+ export function dialogSlideUpAndFade(options) {
46
+ var _options$distance;
47
+ const distance = (_options$distance = options === null || options === void 0 ? void 0 : options.distance) !== null && _options$distance !== void 0 ? _options$distance : 12;
48
+
49
+ // The configurable distance is applied via the `--ds-dialog-ty` custom property
50
+ return {
51
+ kind: 'dialog',
52
+ name: 'slide-up-and-fade',
53
+ getStyles: () => [{
54
+ property: '--ds-dialog-ty',
55
+ value: `${distance}px`
56
+ }]
57
+ };
58
+ }
59
+
60
+ /**
61
+ * Simple opacity transition for dialogs, no transform.
62
+ *
63
+ * Includes backdrop fade animation.
64
+ *
65
+ * @example
66
+ * ```tsx
67
+ * import { dialogFade } from '@atlaskit/top-layer/animations';
68
+ *
69
+ * <Dialog animate={dialogFade()} isOpen={isOpen} onClose={handleClose} label="...">
70
+ * ...
71
+ * </Dialog>
72
+ * ```
73
+ */
74
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
75
+ export function dialogFade() {
76
+ return {
77
+ kind: 'dialog',
78
+ name: 'fade'
79
+ };
80
+ }
@@ -5,54 +5,46 @@
5
5
  ._1m5e1op4::backdrop{animation:var(--ds-blanket-exit,.2s cubic-bezier(.6,0,.8,.6) FadeOut100to0)}
6
6
  ._vhgsxbuz[open]::-ms-backdrop{animation:var(--ds-blanket-enter,.25s cubic-bezier(.4,0,0,1) FadeIn0to100)}
7
7
  ._vhgsxbuz[open]::backdrop{animation:var(--ds-blanket-enter,.25s cubic-bezier(.4,0,0,1) FadeIn0to100)}
8
- ._y44vgeqi{animation:var(--ds-modal-exit,.2s cubic-bezier(.6,0,.8,.6) ScaleOut100to95)}._13ku1a34::-ms-backdrop{transition-timing-function:cubic-bezier(.15,1,.3,1)}
9
- ._13ku1a34::backdrop{transition-timing-function:cubic-bezier(.15,1,.3,1)}
10
- ._18u01wug{margin-left:auto}
8
+ ._y44vgeqi{animation:var(--ds-modal-exit,.2s cubic-bezier(.6,0,.8,.6) ScaleOut100to95)}._18u01wug{margin-left:auto}
11
9
  ._19pk1wug{margin-top:auto}
12
- ._1fsl1ttt[open]{transition-duration:.35s}
10
+ ._1fsl1mzy[open]{transition-duration:var(--ds-duration-long,.25s)}
13
11
  ._1fyf1a5r::-ms-backdrop{transition-behavior:allow-discrete}
14
12
  ._1fyf1a5r::backdrop{transition-behavior:allow-discrete}
15
- ._1gbckb7n[open]{opacity:1}
16
13
  ._1i0neoah[open]{animation-fill-mode:backwards}
17
14
  ._1jhdq7pw::-ms-backdrop{animation-fill-mode:forwards}
18
15
  ._1jhdq7pw::backdrop{animation-fill-mode:forwards}
19
- ._1kdeglyw[open]{transform:none}
20
16
  ._1ltk1i5c::-ms-backdrop{background-color:var(--ds-blanket,#050c1f75)}
21
17
  ._1ltk1i5c::backdrop{background-color:var(--ds-blanket,#050c1f75)}
22
18
  ._1ltk1j28::-ms-backdrop{background-color:transparent}
23
19
  ._1ltk1j28::backdrop{background-color:transparent}
24
20
  ._1o51q7pw{animation-fill-mode:forwards}
25
- ._1oecfnf5{transition-duration:.2s}
26
- ._1oecluct{transition-duration:175ms}
21
+ ._1oeci9qs{transition-duration:var(--ds-duration-medium,.2s)}
22
+ ._1oil1d08[open]{transition-timing-function:var(--ds-easing-inout-bold,cubic-bezier(.4,0,0,1))}
23
+ ._1pgl1lbj{animation-timing-function:var(--ds-easing-in-practical,cubic-bezier(.6,0,.8,.6))}
27
24
  ._1q51ze3t{padding-block-start:var(--ds-space-0,0)}
25
+ ._1rjx1d08[open]{animation-timing-function:var(--ds-easing-inout-bold,cubic-bezier(.4,0,0,1))}
28
26
  ._1rsueoah[open]::-ms-backdrop{animation-fill-mode:backwards}
29
27
  ._1rsueoah[open]::backdrop{animation-fill-mode:backwards}
30
28
  ._1s9z1a5r{transition-behavior:allow-discrete}
29
+ ._1szp1mzy[open]{animation-duration:var(--ds-duration-long,.25s)}
31
30
  ._2hwx1wug{margin-right:auto}
32
- ._4v7i1ttt[open]::-ms-backdrop{transition-duration:.35s}
33
- ._4v7i1ttt[open]::backdrop{transition-duration:.35s}
34
- ._6fl41a34{transition-timing-function:cubic-bezier(.15,1,.3,1)}
31
+ ._5sagi9qs{animation-duration:var(--ds-duration-medium,.2s)}
35
32
  ._85i5ze3t{padding-block-end:var(--ds-space-0,0)}
33
+ ._8ar61bym[open]{animation-name:var(--ds-keyframe-fade-in,FadeIn0to100)}
34
+ ._8ar6ftdr[open]{animation-name:k1s4adx,var(--ds-keyframe-fade-in,FadeIn0to100)}
36
35
  ._bfhk1j28{background-color:transparent}
37
36
  ._bozgze3t{padding-inline-start:var(--ds-space-0,0)}
38
37
  ._c71lglyw{max-height:none}
39
- ._d7fr1i5c[open]::-ms-backdrop{background-color:var(--ds-blanket,#050c1f75)}
40
- ._d7fr1i5c[open]::backdrop{background-color:var(--ds-blanket,#050c1f75)}
38
+ ._j7hq1a5s{animation-name:var(--ds-keyframe-fade-out,FadeOut100to0)}
39
+ ._j7hq1x6c{animation-name:k1gxuu8c,var(--ds-keyframe-fade-out,FadeOut100to0)}
41
40
  ._k8m011k7{transition-property:overlay,display}
42
- ._k8m01slm{transition-property:opacity,overlay,display}
43
- ._k8m0rv36{transition-property:opacity,transform,overlay,display}
44
41
  ._njwk11k7::-ms-backdrop{-ms-transition-property:overlay,display;transition-property:overlay,display}
45
42
  ._njwk11k7::backdrop{transition-property:overlay,display}
46
- ._njwkivc9::-ms-backdrop{-ms-transition-property:background-color,overlay,display;transition-property:background-color,overlay,display}
47
- ._njwkivc9::backdrop{transition-property:background-color,overlay,display}
48
43
  ._otyr1wug{margin-bottom:auto}
49
44
  ._p12fglyw{max-width:none}
50
- ._t9ec9o47{transform:translateY(calc(var(--ds-dialog-ty, 9pt)*-1))}
51
- ._tzy4idpf{opacity:0}
52
45
  ._y4tize3t{padding-inline-end:var(--ds-space-0,0)}
53
- ._yhpqfnf5::-ms-backdrop{transition-duration:.2s}
54
- ._yhpqfnf5::backdrop{transition-duration:.2s}
55
- ._yhpqluct::-ms-backdrop{transition-duration:175ms}
56
- ._yhpqluct::backdrop{transition-duration:175ms}
57
- @media (prefers-reduced-motion:reduce){._156yru3m{transition-duration:0s}._aeldru3m[open]{transition-duration:0s}._1sbqru3m::-ms-backdrop{transition-duration:0s}._1sbqru3m::backdrop{transition-duration:0s}._1i6zru3m[open]::-ms-backdrop{transition-duration:0s}._1i6zru3m[open]::backdrop{transition-duration:0s}._bl8aglyw{animation-name:none}._10aiglyw[open]{animation-name:none}._l57nglyw::-ms-backdrop{animation-name:none}._l57nglyw::backdrop{animation-name:none}._19awglyw[open]::-ms-backdrop{animation-name:none}._19awglyw[open]::backdrop{animation-name:none}}
58
- @starting-style{._1dar1j28[open]::-ms-backdrop{background-color:transparent}._1dar1j28[open]::backdrop{background-color:transparent}._rornidpf[open]{opacity:0}._1hqtc4j2[open]{transform:translateY(var(--ds-dialog-ty,9pt))}}
46
+ ._yhpqi9qs::-ms-backdrop{transition-duration:var(--ds-duration-medium,.2s)}
47
+ ._yhpqi9qs::backdrop{transition-duration:var(--ds-duration-medium,.2s)}
48
+ @keyframes k1gxuu8c{0%{transform:none}to{transform:translateY(calc(var(--ds-dialog-ty, 9pt)*-1))}}
49
+ @keyframes k1s4adx{0%{transform:translateY(calc(var(--ds-dialog-ty, 9pt)))}to{transform:none}}
50
+ @media (prefers-reduced-motion:reduce){._bl8aglyw{animation-name:none}._156y147i{transition-duration:var(--ds-duration-instant,0ms)}._10aiglyw[open]{animation-name:none}._aeld147i[open]{transition-duration:var(--ds-duration-instant,0ms)}._l57nglyw::-ms-backdrop{animation-name:none}._l57nglyw::backdrop{animation-name:none}._1sbq147i::-ms-backdrop{transition-duration:var(--ds-duration-instant,0ms)}._1sbq147i::backdrop{transition-duration:var(--ds-duration-instant,0ms)}._19awglyw[open]::-ms-backdrop{animation-name:none}._19awglyw[open]::backdrop{animation-name:none}._1i6z147i[open]::-ms-backdrop{transition-duration:var(--ds-duration-instant,0ms)}._1i6z147i[open]::backdrop{transition-duration:var(--ds-duration-instant,0ms)}}
@@ -1,5 +1,4 @@
1
1
  /* dialog-content.tsx generated by @compiled/babel-plugin v0.39.1 */
2
- import _extends from "@babel/runtime/helpers/extends";
3
2
  import "./dialog-content.compiled.css";
4
3
  import { ax, ix } from "@compiled/react/runtime";
5
4
  import React, { forwardRef, useCallback, useEffect, useId, useLayoutEffect, useRef } from 'react';
@@ -7,19 +6,30 @@ import { bind } from 'bind-event-listener';
7
6
  import mergeRefs from '@atlaskit/ds-lib/merge-refs';
8
7
  import noop from '@atlaskit/ds-lib/noop';
9
8
  import { useNotifyOpenLayerObserver } from '@atlaskit/layering/experimental/open-layer-observer';
9
+ import { setStyle } from '../internal/set-style';
10
10
  import { useAnimatedVisibility } from '../internal/use-animated-visibility';
11
11
  import { useFocusWrap } from '../internal/use-focus-wrap';
12
+ const slideInKeyframes = null;
13
+ const slideOutKeyframes = null;
14
+
12
15
  // These animation styles use the non-strict Compiled cssMap because they rely
13
16
  // on `@starting-style`, `[open]`, and `allow-discrete`. Keep them in this
14
17
  // component so the Compiled transform can statically extract every referenced
15
18
  // style.
16
19
  const dialogAnimationStyles = {
17
- motion: "_y44vgeqi _1o51q7pw _k8m011k7 _1oecfnf5 _1s9z1a5r _1iu47kvq _1i0neoah _1m5e1op4 _1jhdq7pw _1ltk1i5c _njwk11k7 _yhpqfnf5 _1fyf1a5r _vhgsxbuz _1rsueoah _bl8aglyw _156yru3m _10aiglyw _aeldru3m _l57nglyw _1sbqru3m _19awglyw _1i6zru3m",
18
- slideUpAndFade: "_tzy4idpf _t9ec9o47 _k8m0rv36 _1oecluct _6fl41a34 _1s9z1a5r _1gbckb7n _1kdeglyw _1fsl1ttt _rornidpf _1hqtc4j2 _1ltk1j28 _njwkivc9 _yhpqluct _13ku1a34 _1fyf1a5r _d7fr1i5c _4v7i1ttt _1dar1j28 _156yru3m _aeldru3m _1sbqru3m _1i6zru3m",
19
- fade: "_tzy4idpf _k8m01slm _1oecluct _6fl41a34 _1s9z1a5r _1gbckb7n _1fsl1ttt _rornidpf _1ltk1j28 _njwkivc9 _yhpqluct _13ku1a34 _1fyf1a5r _d7fr1i5c _4v7i1ttt _1dar1j28 _156yru3m _aeldru3m _1sbqru3m _1i6zru3m"
20
+ root: "_k8m011k7 _1oeci9qs _1s9z1a5r _1fsl1mzy _1oil1d08",
21
+ motion: "_y44vgeqi _1o51q7pw _1iu47kvq _1i0neoah",
22
+ 'slide-up-and-fade': "_j7hq1x6c _5sagi9qs _1pgl1lbj _8ar6ftdr _1szp1mzy _1rjx1d08",
23
+ fade: "_j7hq1a5s _5sagi9qs _1pgl1lbj _8ar61bym _1szp1mzy _1rjx1d08",
24
+ custom: ""
20
25
  };
21
26
  const styles = {
22
- dialog: "_19itglyw _19pk1wug _2hwx1wug _otyr1wug _18u01wug _1q51ze3t _y4tize3t _85i5ze3t _bozgze3t _p12fglyw _c71lglyw _bfhk1j28 _1ltk1i5c"
27
+ dialog: "_19itglyw _19pk1wug _2hwx1wug _otyr1wug _18u01wug _1q51ze3t _y4tize3t _85i5ze3t _bozgze3t _p12fglyw _c71lglyw _bfhk1j28 _bl8aglyw _156y147i _10aiglyw _aeld147i"
28
+ };
29
+ const backdropStyles = {
30
+ root: "_1ltk1i5c",
31
+ hidden: "_1ltk1j28",
32
+ motion: "_1m5e1op4 _1jhdq7pw _njwk11k7 _yhpqi9qs _1fyf1a5r _vhgsxbuz _1rsueoah _l57nglyw _1sbq147i _19awglyw _1i6z147i"
23
33
  };
24
34
 
25
35
  /**
@@ -46,7 +56,7 @@ export const Dialog = /*#__PURE__*/forwardRef(function Dialog({
46
56
  onEnterFinish,
47
57
  onExitFinish,
48
58
  animate,
49
- xcss: xcssFromProps,
59
+ xcss: consumerXcss,
50
60
  style,
51
61
  testId,
52
62
  id: providedId,
@@ -114,25 +124,20 @@ export const Dialog = /*#__PURE__*/forwardRef(function Dialog({
114
124
 
115
125
  // Apply preset-provided animation custom properties (e.g. the
116
126
  // `--ds-dialog-ty` slide distance for `dialogSlideUpAndFade`). The
117
- // cleanup removes them so a preset change does not leave stale
118
- // custom properties on the element. Dialog presets do not vary by
119
- // placement, so an empty placement is passed.
127
+ // cleanup restores the previous inline values so a preset change does
128
+ // not leave stale custom properties on the element. Dialog presets do
129
+ // not vary by placement, so an empty placement is passed.
120
130
  useLayoutEffect(() => {
121
131
  const dialog = ownRef.current;
122
- if (!dialog || !(preset !== null && preset !== void 0 && preset.getProperties)) {
132
+ if (!dialog || !(preset !== null && preset !== void 0 && preset.getStyles)) {
123
133
  return;
124
134
  }
125
- const props = preset.getProperties({
126
- placement: {}
135
+ return setStyle({
136
+ element: dialog,
137
+ styles: preset.getStyles({
138
+ placement: {}
139
+ })
127
140
  });
128
- Object.entries(props).forEach(([key, value]) => {
129
- dialog.style.setProperty(key, String(value));
130
- });
131
- return () => {
132
- Object.keys(props).forEach(key => {
133
- dialog.style.removeProperty(key);
134
- });
135
- };
136
141
  }, [preset, isVisible]);
137
142
 
138
143
  // Handle native Escape (cancel event)
@@ -174,12 +179,6 @@ export const Dialog = /*#__PURE__*/forwardRef(function Dialog({
174
179
  });
175
180
  }, [onClose, isVisible]);
176
181
 
177
- // Atomic CSS (Compiled) deduplicates ::backdrop { background-color }
178
- // into a single class, making it impossible to toggle between two values
179
- // via cssMap entries. An ID-scoped <style> has higher specificity than
180
- // any atomic class, so the override always wins.
181
- const escapedId = CSS.escape(dialogId);
182
-
183
182
  // Unmount the `<dialog>` once exit completes so it does not leave an
184
183
  // empty `role="dialog"` element in the accessibility tree. On the next
185
184
  // open the element remounts and the `[isOpen]` and `[onClose, isVisible]`
@@ -187,7 +186,7 @@ export const Dialog = /*#__PURE__*/forwardRef(function Dialog({
187
186
  if (!isVisible) {
188
187
  return null;
189
188
  }
190
- return /*#__PURE__*/React.createElement("dialog", _extends({
189
+ return /*#__PURE__*/React.createElement("dialog", {
191
190
  ref: combinedRef,
192
191
  id: dialogId
193
192
  // `aria-modal` is intentionally NOT set: native `<dialog>.showModal()`
@@ -198,17 +197,9 @@ export const Dialog = /*#__PURE__*/forwardRef(function Dialog({
198
197
  ,
199
198
  "aria-label": label,
200
199
  "aria-labelledby": label ? undefined : labelledBy,
201
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
202
200
  style: style,
203
201
  onCancel: handleCancel,
204
- "data-testid": testId
205
- }, preset ? {
206
- [`data-ds-dialog-${preset.name}`]: ''
207
- } : undefined, {
208
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- xcss prop passes Compiled atomic class names from consumer-owned cssMap entries
209
- className: ax([styles.dialog, (preset === null || preset === void 0 ? void 0 : preset.name) === 'motion' && dialogAnimationStyles.motion, (preset === null || preset === void 0 ? void 0 : preset.name) === 'slide-up-and-fade' && dialogAnimationStyles.slideUpAndFade, (preset === null || preset === void 0 ? void 0 : preset.name) === 'fade' && dialogAnimationStyles.fade, xcssFromProps])
210
- }), shouldHideBackdrop &&
211
- /*#__PURE__*/
212
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles
213
- React.createElement("style", null, `#${escapedId}::backdrop{background-color:transparent}`), children);
202
+ "data-testid": testId,
203
+ className: ax([styles.dialog, shouldHideBackdrop ? backdropStyles.hidden : backdropStyles.root, preset && backdropStyles.motion, preset && dialogAnimationStyles.root, preset && dialogAnimationStyles[preset.name], consumerXcss])
204
+ }, children);
214
205
  });
@@ -1 +1,2 @@
1
- export { dialogMotion, popupMotion, slideAndFade, fade, scaleAndFade, dialogSlideUpAndFade, dialogFade } from '../animations/presets';
1
+ export { dialogMotion, dialogSlideUpAndFade, dialogFade } from '../dialog/animations';
2
+ export { popupMotion, slideAndFade, fade, scaleAndFade } from '../popover/animations';
@@ -1,6 +1,41 @@
1
1
  import { useEffect, useLayoutEffect, useRef, useState } from 'react';
2
2
  import { bind, bindAll } from 'bind-event-listener';
3
3
  import { prefersReducedMotion } from './reduced-motion';
4
+
5
+ /**
6
+ * A self-contained animation preset for top-layer elements.
7
+ *
8
+ * Contains a stable preset name used by the host component to select its
9
+ * component-local Compiled style entry, plus optional per-placement inline
10
+ * styles.
11
+ *
12
+ * The actual Compiled styles are kept static and component-local so the
13
+ * Compiled transform can extract them at build time.
14
+ */
15
+
16
+ /**
17
+ * Using the recommended motion timings for safety net.
18
+ *
19
+ * Not setting these timings on the preset config because they're defined in the CSS,
20
+ * so configuring it in the preset doesn't achieve anything except introduce a potential
21
+ * source of drift.
22
+ *
23
+ * TODO: figure out a way to not need to redeclare these in the future,
24
+ * and keep CSS and JS timings in sync always.
25
+ */
26
+ const safetyNetMsMap = {
27
+ dialog: {
28
+ enter: 250,
29
+ // Corresponds to `motion.duration.long`
30
+ exit: 200 // Corresponds to `motion.duration.medium`
31
+ },
32
+ popover: {
33
+ enter: 150,
34
+ // Corresponds to `motion.duration.short`
35
+ exit: 100 // Corresponds to `motion.duration.xshort`
36
+ }
37
+ };
38
+
4
39
  /**
5
40
  * Fires `onSettled` once when `transitionend` fires on `element`, or after
6
41
  * `safetyNetMs` if the event is swallowed (mid-transition unmount, CSS
@@ -151,8 +186,7 @@ export function useAnimatedVisibility({
151
186
  // move to `open`. The fallback guarantees settle on swallowed events
152
187
  // (zero-duration, browser quirk, mid-transition unmount).
153
188
  useEffect(() => {
154
- var _preset$enterDuration;
155
- if (phase !== 'entering') {
189
+ if (phase !== 'entering' || !(preset !== null && preset !== void 0 && preset.kind)) {
156
190
  return;
157
191
  }
158
192
  const element = elementRef.current;
@@ -161,7 +195,7 @@ export function useAnimatedVisibility({
161
195
  }
162
196
  return runOnTransitionEndOrTimeout({
163
197
  element,
164
- safetyNetMs: ((_preset$enterDuration = preset === null || preset === void 0 ? void 0 : preset.enterDurationMs) !== null && _preset$enterDuration !== void 0 ? _preset$enterDuration : 0) + 50,
198
+ safetyNetMs: safetyNetMsMap[preset.kind].enter + 50,
165
199
  onSettled: () => {
166
200
  var _onEnterFinishRef$cur;
167
201
  // Fire the consumer callback before transitioning phase so any
@@ -172,7 +206,7 @@ export function useAnimatedVisibility({
172
206
  setPhase(current => current === 'entering' ? 'open' : current);
173
207
  }
174
208
  });
175
- }, [phase, preset === null || preset === void 0 ? void 0 : preset.enterDurationMs, elementRef]);
209
+ }, [phase, preset === null || preset === void 0 ? void 0 : preset.kind, elementRef]);
176
210
 
177
211
  // Non-animated entry callback. The lifecycle goes `closed → open`
178
212
  // directly with no `entering` phase; fire `onEnterFinish` on that jump.
@@ -193,8 +227,7 @@ export function useAnimatedVisibility({
193
227
  // Animated exit: wait for `transitionend` (or a safety-net timeout),
194
228
  // fire `onExitFinish`, then move to `closed` to unmount the host.
195
229
  useEffect(() => {
196
- var _preset$exitDurationM;
197
- if (phase !== 'exiting' || !willAnimate) {
230
+ if (phase !== 'exiting' || !willAnimate || !(preset !== null && preset !== void 0 && preset.kind)) {
198
231
  return;
199
232
  }
200
233
  const element = elementRef.current;
@@ -203,7 +236,7 @@ export function useAnimatedVisibility({
203
236
  }
204
237
  return runOnTransitionEndOrTimeout({
205
238
  element,
206
- safetyNetMs: ((_preset$exitDurationM = preset === null || preset === void 0 ? void 0 : preset.exitDurationMs) !== null && _preset$exitDurationM !== void 0 ? _preset$exitDurationM : 0) + 50,
239
+ safetyNetMs: safetyNetMsMap[preset.kind].exit + 50,
207
240
  onSettled: () => {
208
241
  var _onExitFinishRef$curr;
209
242
  // Fire the consumer callback before transitioning phase to
@@ -216,7 +249,7 @@ export function useAnimatedVisibility({
216
249
  setPhase(current => current === 'exiting' ? 'closed' : current);
217
250
  }
218
251
  });
219
- }, [phase, willAnimate, preset === null || preset === void 0 ? void 0 : preset.exitDurationMs, elementRef]);
252
+ }, [phase, willAnimate, preset === null || preset === void 0 ? void 0 : preset.kind, elementRef]);
220
253
 
221
254
  // Non-animated exit: wait for the browser's `toggle` (closed) or
222
255
  // `close` event before unmounting, so the consumer's listener (close