@atlaskit/top-layer 1.4.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 +19 -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 +30 -12
  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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @atlaskit/top-layer
2
2
 
3
+ ## 1.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`530dfb5aee695`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/530dfb5aee695) -
8
+ Improves animation preset typing and makes animations more consistent by aligning timings and
9
+ introducing tokens.
10
+
11
+ ## 1.5.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [`2f56c78f969b8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2f56c78f969b8) -
16
+ Update i18n NPM package versions for teamwork-graph (Group 16)
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies
21
+
3
22
  ## 1.4.0
4
23
 
5
24
  ### Minor Changes
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.dialogFade = dialogFade;
7
+ exports.dialogMotion = dialogMotion;
8
+ exports.dialogSlideUpAndFade = dialogSlideUpAndFade;
9
+ // `custom` variant currently exists for typing reasons for Drawer
10
+ // not indicative of final API
11
+
12
+ /**
13
+ * Dialog motion animation.
14
+ *
15
+ * Includes backdrop fade animation.
16
+ *
17
+ * @example
18
+ * ```tsx
19
+ * import { dialogMotion } from '@atlaskit/top-layer/animations';
20
+ *
21
+ * <Dialog animate={dialogMotion()} isOpen={isOpen} onClose={handleClose} label="...">
22
+ * ...
23
+ * </Dialog>
24
+ * ```
25
+ */
26
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
27
+ function dialogMotion() {
28
+ return {
29
+ kind: 'dialog',
30
+ name: 'motion'
31
+ };
32
+ }
33
+
34
+ /**
35
+ * Slide up + opacity animation for dialogs.
36
+ *
37
+ * Entry slides up from below; exit slides up and out (asymmetric).
38
+ * Includes backdrop fade animation.
39
+ *
40
+ * @param options.distance - Slide distance in pixels. Defaults to `12`.
41
+ *
42
+ * @example
43
+ * ```tsx
44
+ * import { dialogSlideUpAndFade } from '@atlaskit/top-layer/animations';
45
+ *
46
+ * const animation = dialogSlideUpAndFade();
47
+ * <Dialog animate={animation} isOpen={isOpen} onClose={handleClose} label="...">
48
+ * ...
49
+ * </Dialog>
50
+ * ```
51
+ */
52
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
53
+ function dialogSlideUpAndFade(options) {
54
+ var _options$distance;
55
+ var distance = (_options$distance = options === null || options === void 0 ? void 0 : options.distance) !== null && _options$distance !== void 0 ? _options$distance : 12;
56
+
57
+ // The configurable distance is applied via the `--ds-dialog-ty` custom property
58
+ return {
59
+ kind: 'dialog',
60
+ name: 'slide-up-and-fade',
61
+ getStyles: function getStyles() {
62
+ return [{
63
+ property: '--ds-dialog-ty',
64
+ value: "".concat(distance, "px")
65
+ }];
66
+ }
67
+ };
68
+ }
69
+
70
+ /**
71
+ * Simple opacity transition for dialogs, no transform.
72
+ *
73
+ * Includes backdrop fade animation.
74
+ *
75
+ * @example
76
+ * ```tsx
77
+ * import { dialogFade } from '@atlaskit/top-layer/animations';
78
+ *
79
+ * <Dialog animate={dialogFade()} isOpen={isOpen} onClose={handleClose} label="...">
80
+ * ...
81
+ * </Dialog>
82
+ * ```
83
+ */
84
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
85
+ function dialogFade() {
86
+ return {
87
+ kind: 'dialog',
88
+ name: 'fade'
89
+ };
90
+ }
@@ -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
+ ._8ar6yjsl[open]{animation-name:k1c1nn4,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
+ ._j7hqcmlg{animation-name:ku52lnv,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 k1c1nn4{0%{transform:translateY(calc(var(--ds-dialog-ty, 9pt)))}to{transform:none}}
49
+ @keyframes ku52lnv{0%{transform:none}to{transform:translateY(calc(var(--ds-dialog-ty, 9pt)*-1))}}
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)}}
@@ -9,28 +9,36 @@ Object.defineProperty(exports, "__esModule", {
9
9
  exports.Dialog = void 0;
10
10
  require("./dialog-content.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 _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
19
16
  var _openLayerObserver = require("@atlaskit/layering/experimental/open-layer-observer");
17
+ var _setStyle = require("../internal/set-style");
20
18
  var _useAnimatedVisibility = require("../internal/use-animated-visibility");
21
19
  var _useFocusWrap = require("../internal/use-focus-wrap");
22
20
  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
+ var slideInKeyframes = null;
22
+ var slideOutKeyframes = null;
23
+
23
24
  // These animation styles use the non-strict Compiled cssMap because they rely
24
25
  // on `@starting-style`, `[open]`, and `allow-discrete`. Keep them in this
25
26
  // component so the Compiled transform can statically extract every referenced
26
27
  // style.
27
28
  var dialogAnimationStyles = {
28
- motion: "_y44vgeqi _1o51q7pw _k8m011k7 _1oecfnf5 _1s9z1a5r _1iu47kvq _1i0neoah _1m5e1op4 _1jhdq7pw _1ltk1i5c _njwk11k7 _yhpqfnf5 _1fyf1a5r _vhgsxbuz _1rsueoah _bl8aglyw _156yru3m _10aiglyw _aeldru3m _l57nglyw _1sbqru3m _19awglyw _1i6zru3m",
29
- slideUpAndFade: "_tzy4idpf _t9ec9o47 _k8m0rv36 _1oecluct _6fl41a34 _1s9z1a5r _1gbckb7n _1kdeglyw _1fsl1ttt _rornidpf _1hqtc4j2 _1ltk1j28 _njwkivc9 _yhpqluct _13ku1a34 _1fyf1a5r _d7fr1i5c _4v7i1ttt _1dar1j28 _156yru3m _aeldru3m _1sbqru3m _1i6zru3m",
30
- fade: "_tzy4idpf _k8m01slm _1oecluct _6fl41a34 _1s9z1a5r _1gbckb7n _1fsl1ttt _rornidpf _1ltk1j28 _njwkivc9 _yhpqluct _13ku1a34 _1fyf1a5r _d7fr1i5c _4v7i1ttt _1dar1j28 _156yru3m _aeldru3m _1sbqru3m _1i6zru3m"
29
+ root: "_k8m011k7 _1oeci9qs _1s9z1a5r _1fsl1mzy _1oil1d08",
30
+ motion: "_y44vgeqi _1o51q7pw _1iu47kvq _1i0neoah",
31
+ 'slide-up-and-fade': "_j7hqcmlg _5sagi9qs _1pgl1lbj _8ar6yjsl _1szp1mzy _1rjx1d08",
32
+ fade: "_j7hq1a5s _5sagi9qs _1pgl1lbj _8ar61bym _1szp1mzy _1rjx1d08",
33
+ custom: ""
31
34
  };
32
35
  var styles = {
33
- dialog: "_19itglyw _19pk1wug _2hwx1wug _otyr1wug _18u01wug _1q51ze3t _y4tize3t _85i5ze3t _bozgze3t _p12fglyw _c71lglyw _bfhk1j28 _1ltk1i5c"
36
+ dialog: "_19itglyw _19pk1wug _2hwx1wug _otyr1wug _18u01wug _1q51ze3t _y4tize3t _85i5ze3t _bozgze3t _p12fglyw _c71lglyw _bfhk1j28 _bl8aglyw _156y147i _10aiglyw _aeld147i"
37
+ };
38
+ var backdropStyles = {
39
+ root: "_1ltk1i5c",
40
+ hidden: "_1ltk1j28",
41
+ motion: "_1m5e1op4 _1jhdq7pw _njwk11k7 _yhpqi9qs _1fyf1a5r _vhgsxbuz _1rsueoah _l57nglyw _1sbq147i _19awglyw _1i6z147i"
34
42
  };
35
43
 
36
44
  /**
@@ -57,7 +65,7 @@ var Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(function Dialo
57
65
  onEnterFinish = _ref.onEnterFinish,
58
66
  onExitFinish = _ref.onExitFinish,
59
67
  animate = _ref.animate,
60
- xcssFromProps = _ref.xcss,
68
+ consumerXcss = _ref.xcss,
61
69
  style = _ref.style,
62
70
  testId = _ref.testId,
63
71
  providedId = _ref.id,
@@ -123,28 +131,20 @@ var Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(function Dialo
123
131
 
124
132
  // Apply preset-provided animation custom properties (e.g. the
125
133
  // `--ds-dialog-ty` slide distance for `dialogSlideUpAndFade`). The
126
- // cleanup removes them so a preset change does not leave stale
127
- // custom properties on the element. Dialog presets do not vary by
128
- // placement, so an empty placement is passed.
134
+ // cleanup restores the previous inline values so a preset change does
135
+ // not leave stale custom properties on the element. Dialog presets do
136
+ // not vary by placement, so an empty placement is passed.
129
137
  (0, _react.useLayoutEffect)(function () {
130
138
  var dialog = ownRef.current;
131
- if (!dialog || !(preset !== null && preset !== void 0 && preset.getProperties)) {
139
+ if (!dialog || !(preset !== null && preset !== void 0 && preset.getStyles)) {
132
140
  return;
133
141
  }
134
- var props = preset.getProperties({
135
- placement: {}
142
+ return (0, _setStyle.setStyle)({
143
+ element: dialog,
144
+ styles: preset.getStyles({
145
+ placement: {}
146
+ })
136
147
  });
137
- Object.entries(props).forEach(function (_ref2) {
138
- var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
139
- key = _ref3[0],
140
- value = _ref3[1];
141
- dialog.style.setProperty(key, String(value));
142
- });
143
- return function () {
144
- Object.keys(props).forEach(function (key) {
145
- dialog.style.removeProperty(key);
146
- });
147
- };
148
148
  }, [preset, isVisible]);
149
149
 
150
150
  // Handle native Escape (cancel event)
@@ -186,12 +186,6 @@ var Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(function Dialo
186
186
  });
187
187
  }, [onClose, isVisible]);
188
188
 
189
- // Atomic CSS (Compiled) deduplicates ::backdrop { background-color }
190
- // into a single class, making it impossible to toggle between two values
191
- // via cssMap entries. An ID-scoped <style> has higher specificity than
192
- // any atomic class, so the override always wins.
193
- var escapedId = CSS.escape(dialogId);
194
-
195
189
  // Unmount the `<dialog>` once exit completes so it does not leave an
196
190
  // empty `role="dialog"` element in the accessibility tree. On the next
197
191
  // open the element remounts and the `[isOpen]` and `[onClose, isVisible]`
@@ -199,7 +193,7 @@ var Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(function Dialo
199
193
  if (!isVisible) {
200
194
  return null;
201
195
  }
202
- return /*#__PURE__*/_react.default.createElement("dialog", (0, _extends2.default)({
196
+ return /*#__PURE__*/_react.default.createElement("dialog", {
203
197
  ref: combinedRef,
204
198
  id: dialogId
205
199
  // `aria-modal` is intentionally NOT set: native `<dialog>.showModal()`
@@ -210,15 +204,9 @@ var Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(function Dialo
210
204
  ,
211
205
  "aria-label": label,
212
206
  "aria-labelledby": label ? undefined : labelledBy,
213
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
214
207
  style: style,
215
208
  onCancel: handleCancel,
216
- "data-testid": testId
217
- }, preset ? (0, _defineProperty2.default)({}, "data-ds-dialog-".concat(preset.name), '') : undefined, {
218
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- xcss prop passes Compiled atomic class names from consumer-owned cssMap entries
219
- className: (0, _runtime.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])
220
- }), shouldHideBackdrop &&
221
- /*#__PURE__*/
222
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles
223
- _react.default.createElement("style", null, "#".concat(escapedId, "::backdrop{background-color:transparent}")), children);
209
+ "data-testid": testId,
210
+ className: (0, _runtime.ax)([styles.dialog, shouldHideBackdrop ? backdropStyles.hidden : backdropStyles.root, preset && backdropStyles.motion, preset && dialogAnimationStyles.root, preset && dialogAnimationStyles[preset.name], consumerXcss])
211
+ }, children);
224
212
  });
@@ -6,43 +6,44 @@ Object.defineProperty(exports, "__esModule", {
6
6
  Object.defineProperty(exports, "dialogFade", {
7
7
  enumerable: true,
8
8
  get: function get() {
9
- return _presets.dialogFade;
9
+ return _animations.dialogFade;
10
10
  }
11
11
  });
12
12
  Object.defineProperty(exports, "dialogMotion", {
13
13
  enumerable: true,
14
14
  get: function get() {
15
- return _presets.dialogMotion;
15
+ return _animations.dialogMotion;
16
16
  }
17
17
  });
18
18
  Object.defineProperty(exports, "dialogSlideUpAndFade", {
19
19
  enumerable: true,
20
20
  get: function get() {
21
- return _presets.dialogSlideUpAndFade;
21
+ return _animations.dialogSlideUpAndFade;
22
22
  }
23
23
  });
24
24
  Object.defineProperty(exports, "fade", {
25
25
  enumerable: true,
26
26
  get: function get() {
27
- return _presets.fade;
27
+ return _animations2.fade;
28
28
  }
29
29
  });
30
30
  Object.defineProperty(exports, "popupMotion", {
31
31
  enumerable: true,
32
32
  get: function get() {
33
- return _presets.popupMotion;
33
+ return _animations2.popupMotion;
34
34
  }
35
35
  });
36
36
  Object.defineProperty(exports, "scaleAndFade", {
37
37
  enumerable: true,
38
38
  get: function get() {
39
- return _presets.scaleAndFade;
39
+ return _animations2.scaleAndFade;
40
40
  }
41
41
  });
42
42
  Object.defineProperty(exports, "slideAndFade", {
43
43
  enumerable: true,
44
44
  get: function get() {
45
- return _presets.slideAndFade;
45
+ return _animations2.slideAndFade;
46
46
  }
47
47
  });
48
- var _presets = require("../animations/presets");
48
+ var _animations = require("../dialog/animations");
49
+ var _animations2 = require("../popover/animations");
@@ -9,6 +9,40 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
9
9
  var _react = require("react");
10
10
  var _bindEventListener = require("bind-event-listener");
11
11
  var _reducedMotion = require("./reduced-motion");
12
+ /**
13
+ * A self-contained animation preset for top-layer elements.
14
+ *
15
+ * Contains a stable preset name used by the host component to select its
16
+ * component-local Compiled style entry, plus optional per-placement inline
17
+ * styles.
18
+ *
19
+ * The actual Compiled styles are kept static and component-local so the
20
+ * Compiled transform can extract them at build time.
21
+ */
22
+
23
+ /**
24
+ * Using the recommended motion timings for safety net.
25
+ *
26
+ * Not setting these timings on the preset config because they're defined in the CSS,
27
+ * so configuring it in the preset doesn't achieve anything except introduce a potential
28
+ * source of drift.
29
+ *
30
+ * TODO: figure out a way to not need to redeclare these in the future,
31
+ * and keep CSS and JS timings in sync always.
32
+ */
33
+ var safetyNetMsMap = {
34
+ dialog: {
35
+ enter: 250,
36
+ // Corresponds to `motion.duration.long`
37
+ exit: 200 // Corresponds to `motion.duration.medium`
38
+ },
39
+ popover: {
40
+ enter: 150,
41
+ // Corresponds to `motion.duration.short`
42
+ exit: 100 // Corresponds to `motion.duration.xshort`
43
+ }
44
+ };
45
+
12
46
  /**
13
47
  * Fires `onSettled` once when `transitionend` fires on `element`, or after
14
48
  * `safetyNetMs` if the event is swallowed (mid-transition unmount, CSS
@@ -160,8 +194,7 @@ function useAnimatedVisibility(_ref2) {
160
194
  // move to `open`. The fallback guarantees settle on swallowed events
161
195
  // (zero-duration, browser quirk, mid-transition unmount).
162
196
  (0, _react.useEffect)(function () {
163
- var _preset$enterDuration;
164
- if (phase !== 'entering') {
197
+ if (phase !== 'entering' || !(preset !== null && preset !== void 0 && preset.kind)) {
165
198
  return;
166
199
  }
167
200
  var element = elementRef.current;
@@ -170,7 +203,7 @@ function useAnimatedVisibility(_ref2) {
170
203
  }
171
204
  return runOnTransitionEndOrTimeout({
172
205
  element: element,
173
- safetyNetMs: ((_preset$enterDuration = preset === null || preset === void 0 ? void 0 : preset.enterDurationMs) !== null && _preset$enterDuration !== void 0 ? _preset$enterDuration : 0) + 50,
206
+ safetyNetMs: safetyNetMsMap[preset.kind].enter + 50,
174
207
  onSettled: function onSettled() {
175
208
  var _onEnterFinishRef$cur;
176
209
  // Fire the consumer callback before transitioning phase so any
@@ -183,7 +216,7 @@ function useAnimatedVisibility(_ref2) {
183
216
  });
184
217
  }
185
218
  });
186
- }, [phase, preset === null || preset === void 0 ? void 0 : preset.enterDurationMs, elementRef]);
219
+ }, [phase, preset === null || preset === void 0 ? void 0 : preset.kind, elementRef]);
187
220
 
188
221
  // Non-animated entry callback. The lifecycle goes `closed → open`
189
222
  // directly with no `entering` phase; fire `onEnterFinish` on that jump.
@@ -204,8 +237,7 @@ function useAnimatedVisibility(_ref2) {
204
237
  // Animated exit: wait for `transitionend` (or a safety-net timeout),
205
238
  // fire `onExitFinish`, then move to `closed` to unmount the host.
206
239
  (0, _react.useEffect)(function () {
207
- var _preset$exitDurationM;
208
- if (phase !== 'exiting' || !willAnimate) {
240
+ if (phase !== 'exiting' || !willAnimate || !(preset !== null && preset !== void 0 && preset.kind)) {
209
241
  return;
210
242
  }
211
243
  var element = elementRef.current;
@@ -214,7 +246,7 @@ function useAnimatedVisibility(_ref2) {
214
246
  }
215
247
  return runOnTransitionEndOrTimeout({
216
248
  element: element,
217
- safetyNetMs: ((_preset$exitDurationM = preset === null || preset === void 0 ? void 0 : preset.exitDurationMs) !== null && _preset$exitDurationM !== void 0 ? _preset$exitDurationM : 0) + 50,
249
+ safetyNetMs: safetyNetMsMap[preset.kind].exit + 50,
218
250
  onSettled: function onSettled() {
219
251
  var _onExitFinishRef$curr;
220
252
  // Fire the consumer callback before transitioning phase to
@@ -229,7 +261,7 @@ function useAnimatedVisibility(_ref2) {
229
261
  });
230
262
  }
231
263
  });
232
- }, [phase, willAnimate, preset === null || preset === void 0 ? void 0 : preset.exitDurationMs, elementRef]);
264
+ }, [phase, willAnimate, preset === null || preset === void 0 ? void 0 : preset.kind, elementRef]);
233
265
 
234
266
  // Non-animated exit: wait for the browser's `toggle` (closed) or
235
267
  // `close` event before unmounting, so the consumer's listener (close
@@ -0,0 +1,196 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.fade = fade;
7
+ exports.popupMotion = popupMotion;
8
+ exports.scaleAndFade = scaleAndFade;
9
+ exports.slideAndFade = slideAndFade;
10
+ var _resolvePlacement = require("../internal/resolve-placement");
11
+ function getPopupMotionStyles(_ref) {
12
+ var placement = _ref.placement;
13
+ var _getPlacement = (0, _resolvePlacement.getPlacement)({
14
+ placement: placement
15
+ }),
16
+ axis = _getPlacement.axis,
17
+ edge = _getPlacement.edge;
18
+ if (axis === 'block' && edge === 'start') {
19
+ return [{
20
+ property: '--ds-popover-motion-enter',
21
+ value: "var(--ds-popup-enter-top, 150ms cubic-bezier(0.4, 1, 0.6, 1) SlideInTop8px, 150ms cubic-bezier(0.4, 1, 0.6, 1) FadeIn0to100)"
22
+ }, {
23
+ property: '--ds-popover-motion-exit',
24
+ value: "var(--ds-popup-exit-top, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutTop8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
25
+ }];
26
+ }
27
+ if (axis === 'inline' && edge === 'start') {
28
+ return [{
29
+ property: '--ds-popover-motion-enter',
30
+ value: "var(--ds-popup-enter-left, 150ms cubic-bezier(0.4, 1, 0.6, 1) SlideInLeft8px, 150ms cubic-bezier(0.4, 1, 0.6, 1) FadeIn0to100)"
31
+ }, {
32
+ property: '--ds-popover-motion-exit',
33
+ value: "var(--ds-popup-exit-left, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutLeft8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
34
+ }];
35
+ }
36
+ if (axis === 'inline' && edge === 'end') {
37
+ return [{
38
+ property: '--ds-popover-motion-enter',
39
+ value: "var(--ds-popup-enter-right, 150ms cubic-bezier(0.4, 1, 0.6, 1) SlideInRight8px, 150ms cubic-bezier(0.4, 1, 0.6, 1) FadeIn0to100)"
40
+ }, {
41
+ property: '--ds-popover-motion-exit',
42
+ value: "var(--ds-popup-exit-right, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutRight8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
43
+ }];
44
+ }
45
+ // Default: block/end (popover below trigger)
46
+ return [{
47
+ property: '--ds-popover-motion-enter',
48
+ value: "var(--ds-popup-enter-bottom, 150ms cubic-bezier(0.4, 1, 0.6, 1) SlideInBottom8px, 150ms cubic-bezier(0.4, 1, 0.6, 1) FadeIn0to100)"
49
+ }, {
50
+ property: '--ds-popover-motion-exit',
51
+ value: "var(--ds-popup-exit-bottom, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutBottom8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
52
+ }];
53
+ }
54
+
55
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
56
+ function popupMotion() {
57
+ return {
58
+ kind: 'popover',
59
+ name: 'motion',
60
+ getStyles: getPopupMotionStyles
61
+ };
62
+ }
63
+ function getSlideAndFadeStyles(_ref2) {
64
+ var placement = _ref2.placement,
65
+ distance = _ref2.distance;
66
+ var pos = "".concat(distance, "px");
67
+ var neg = "-".concat(distance, "px");
68
+ var _getPlacement2 = (0, _resolvePlacement.getPlacement)({
69
+ placement: placement
70
+ }),
71
+ axis = _getPlacement2.axis,
72
+ edge = _getPlacement2.edge;
73
+ if (axis === 'block' && edge === 'start') {
74
+ return [{
75
+ property: '--ds-popover-tx',
76
+ value: '0'
77
+ }, {
78
+ property: '--ds-popover-ty',
79
+ value: pos
80
+ }];
81
+ }
82
+ if (axis === 'block' && edge === 'end') {
83
+ return [{
84
+ property: '--ds-popover-tx',
85
+ value: '0'
86
+ }, {
87
+ property: '--ds-popover-ty',
88
+ value: neg
89
+ }];
90
+ }
91
+ if (axis === 'inline' && edge === 'start') {
92
+ return [{
93
+ property: '--ds-popover-tx',
94
+ value: pos
95
+ }, {
96
+ property: '--ds-popover-ty',
97
+ value: '0'
98
+ }];
99
+ }
100
+ if (axis === 'inline' && edge === 'end') {
101
+ return [{
102
+ property: '--ds-popover-tx',
103
+ value: neg
104
+ }, {
105
+ property: '--ds-popover-ty',
106
+ value: '0'
107
+ }];
108
+ }
109
+ return [{
110
+ property: '--ds-popover-tx',
111
+ value: '0'
112
+ }, {
113
+ property: '--ds-popover-ty',
114
+ value: neg
115
+ }];
116
+ }
117
+
118
+ /**
119
+ * Directional slide + opacity animation.
120
+ *
121
+ * The popover slides in from the direction opposite its placement edge
122
+ * (e.g. a `block-end` popover slides down from above).
123
+ *
124
+ * @param options.distance - Slide distance in pixels. Defaults to `4`.
125
+ *
126
+ * @example
127
+ * ```tsx
128
+ * import { slideAndFade } from '@atlaskit/top-layer/animations';
129
+ *
130
+ * // Default 4px slide (tooltip)
131
+ * <Popover animate={slideAndFade()} />
132
+ *
133
+ * // Custom 8px slide (popup / dropdown)
134
+ * <Popover animate={slideAndFade({ distance: 8 })} />
135
+ * ```
136
+ */
137
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
138
+ function slideAndFade(options) {
139
+ var _options$distance;
140
+ var distance = (_options$distance = options === null || options === void 0 ? void 0 : options.distance) !== null && _options$distance !== void 0 ? _options$distance : 4;
141
+ return {
142
+ kind: 'popover',
143
+ name: 'slide-and-fade',
144
+ getStyles: function getStyles(_ref3) {
145
+ var placement = _ref3.placement;
146
+ return getSlideAndFadeStyles({
147
+ placement: placement,
148
+ distance: distance
149
+ });
150
+ }
151
+ };
152
+ }
153
+
154
+ // fade
155
+
156
+ /**
157
+ * Simple opacity transition, no transform.
158
+ *
159
+ * Suitable for popup dialogs or content that does not need directional motion.
160
+ *
161
+ * @example
162
+ * ```tsx
163
+ * import { fade } from '@atlaskit/top-layer/animations';
164
+ *
165
+ * <Popover animate={fade()} />
166
+ * ```
167
+ */
168
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
169
+ function fade() {
170
+ return {
171
+ kind: 'popover',
172
+ name: 'fade'
173
+ };
174
+ }
175
+
176
+ // scaleAndFade
177
+
178
+ /**
179
+ * Scale from 0.95 + opacity transition.
180
+ *
181
+ * Suitable for menus, dropdowns, and select options.
182
+ *
183
+ * @example
184
+ * ```tsx
185
+ * import { scaleAndFade } from '@atlaskit/top-layer/animations';
186
+ *
187
+ * <Popover animate={scaleAndFade()} />
188
+ * ```
189
+ */
190
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
191
+ function scaleAndFade() {
192
+ return {
193
+ kind: 'popover',
194
+ name: 'scale-and-fade'
195
+ };
196
+ }