@atlaskit/top-layer 1.5.0 → 1.6.1

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 +16 -0
  2. package/compass.yml +10 -1
  3. package/dist/cjs/dialog/dialog-content.compiled.css +7 -25
  4. package/dist/cjs/dialog/dialog-content.js +16 -51
  5. package/dist/cjs/entry-points/animations.js +1 -48
  6. package/dist/cjs/internal/use-animated-visibility.js +35 -6
  7. package/dist/cjs/popover/animations.js +50 -0
  8. package/dist/cjs/popover/popover.compiled.css +7 -14
  9. package/dist/cjs/popover/popover.js +19 -31
  10. package/dist/cjs/testing/polyfill.js +3 -0
  11. package/dist/es2019/dialog/dialog-content.compiled.css +7 -25
  12. package/dist/es2019/dialog/dialog-content.js +15 -48
  13. package/dist/es2019/entry-points/animations.js +0 -1
  14. package/dist/es2019/internal/use-animated-visibility.js +35 -6
  15. package/dist/es2019/popover/animations.js +46 -0
  16. package/dist/es2019/popover/popover.compiled.css +7 -14
  17. package/dist/es2019/popover/popover.js +18 -28
  18. package/dist/es2019/testing/polyfill.js +3 -0
  19. package/dist/esm/dialog/dialog-content.compiled.css +7 -25
  20. package/dist/esm/dialog/dialog-content.js +16 -51
  21. package/dist/esm/entry-points/animations.js +0 -1
  22. package/dist/esm/internal/use-animated-visibility.js +35 -6
  23. package/dist/esm/popover/animations.js +44 -0
  24. package/dist/esm/popover/popover.compiled.css +7 -14
  25. package/dist/esm/popover/popover.js +19 -31
  26. package/dist/esm/testing/polyfill.js +3 -0
  27. package/dist/types/dialog/types.d.ts +5 -5
  28. package/dist/types/entry-points/animations.d.ts +0 -2
  29. package/dist/types/internal/use-animated-visibility.d.ts +16 -5
  30. package/dist/types/popover/animations.d.ts +7 -0
  31. package/dist/types/popover/types.d.ts +7 -4
  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,21 @@
1
1
  # @atlaskit/top-layer
2
2
 
3
+ ## 1.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`650f4c7ce7fb2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/650f4c7ce7fb2) -
8
+ Type-only fixes for TypeScript 7 (tsgo) compatibility with the updated DOM lib. No runtime or
9
+ public API changes.
10
+
11
+ ## 1.6.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [`530dfb5aee695`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/530dfb5aee695) -
16
+ Improves animation preset typing and makes animations more consistent by aligning timings and
17
+ introducing tokens.
18
+
3
19
  ## 1.5.0
4
20
 
5
21
  ### Minor Changes
package/compass.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  configVersion: 1
2
2
  id: ari:cloud:compass:a436116f-02ce-4520-8fbb-7301462a1674:component/c5751cc6-3513-4070-9deb-af31e86aed34/680f1177-ac84-4787-a7d1-258dd657dc9f
3
3
  name: '@atlaskit/top-layer'
4
- ownerId: ari:cloud:identity::team/be19136e-6275-419f-be0c-fcee844b8684 # Design System Engineers
4
+ ownerId: ari:cloud:teams::team/814283d6-8695-4329-b2f8-d78b2645722f # Design System Team (ADS)
5
5
  labels:
6
6
  - platform-code
7
7
  - platform-afm
@@ -27,6 +27,9 @@ customFields:
27
27
  - name: Technical Owner
28
28
  type: user
29
29
  value: ari:cloud:identity::user/557058:86a9b692-7997-49cb-9984-080801b1de91 # Jared Crowe
30
+ - name: Reviewer Team
31
+ type: text
32
+ value: ari:cloud:teams::team/be19136e-6275-419f-be0c-fcee844b8684 # Design System Engineers
30
33
  - name: Required Reviewers Opt In
31
34
  type: boolean
32
35
  value: true
@@ -36,3 +39,9 @@ customFields:
36
39
  - name: Required Reviewer Approvals
37
40
  type: number
38
41
  value: 1
42
+ - name: Trusted Committers
43
+ type: text
44
+ value: ari:cloud:teams::team/814283d6-8695-4329-b2f8-d78b2645722f # Design System Team (ADS)
45
+ - name: Trusted Reviewer Teams
46
+ type: text
47
+ value: ari:cloud:teams::team/42f4416b-e028-4daa-b2a5-afe213ac75e1 # Design System Designers
@@ -5,54 +5,36 @@
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))}
27
23
  ._1q51ze3t{padding-block-start:var(--ds-space-0,0)}
28
24
  ._1rsueoah[open]::-ms-backdrop{animation-fill-mode:backwards}
29
25
  ._1rsueoah[open]::backdrop{animation-fill-mode:backwards}
30
26
  ._1s9z1a5r{transition-behavior:allow-discrete}
31
27
  ._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)}
35
28
  ._85i5ze3t{padding-block-end:var(--ds-space-0,0)}
36
29
  ._bfhk1j28{background-color:transparent}
37
30
  ._bozgze3t{padding-inline-start:var(--ds-space-0,0)}
38
31
  ._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)}
41
32
  ._k8m011k7{transition-property:overlay,display}
42
- ._k8m01slm{transition-property:opacity,overlay,display}
43
- ._k8m0rv36{transition-property:opacity,transform,overlay,display}
44
33
  ._njwk11k7::-ms-backdrop{-ms-transition-property:overlay,display;transition-property:overlay,display}
45
34
  ._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
35
  ._otyr1wug{margin-bottom:auto}
49
36
  ._p12fglyw{max-width:none}
50
- ._t9ec9o47{transform:translateY(calc(var(--ds-dialog-ty, 9pt)*-1))}
51
- ._tzy4idpf{opacity:0}
52
37
  ._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))}}
38
+ ._yhpqi9qs::-ms-backdrop{transition-duration:var(--ds-duration-medium,.2s)}
39
+ ._yhpqi9qs::backdrop{transition-duration:var(--ds-duration-medium,.2s)}
40
+ @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,9 +9,6 @@ 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"));
@@ -25,12 +22,16 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
25
22
  // component so the Compiled transform can statically extract every referenced
26
23
  // style.
27
24
  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"
25
+ root: "_k8m011k7 _1oeci9qs _1s9z1a5r _1fsl1mzy _1oil1d08",
26
+ motion: "_y44vgeqi _1o51q7pw _1iu47kvq _1i0neoah"
31
27
  };
32
28
  var styles = {
33
- dialog: "_19itglyw _19pk1wug _2hwx1wug _otyr1wug _18u01wug _1q51ze3t _y4tize3t _85i5ze3t _bozgze3t _p12fglyw _c71lglyw _bfhk1j28 _1ltk1i5c"
29
+ dialog: "_19itglyw _19pk1wug _2hwx1wug _otyr1wug _18u01wug _1q51ze3t _y4tize3t _85i5ze3t _bozgze3t _p12fglyw _c71lglyw _bfhk1j28 _bl8aglyw _156y147i _10aiglyw _aeld147i"
30
+ };
31
+ var backdropStyles = {
32
+ root: "_1ltk1i5c",
33
+ hidden: "_1ltk1j28",
34
+ motion: "_1m5e1op4 _1jhdq7pw _njwk11k7 _yhpqi9qs _1fyf1a5r _vhgsxbuz _1rsueoah _l57nglyw _1sbq147i _19awglyw _1i6z147i"
34
35
  };
35
36
 
36
37
  /**
@@ -56,8 +57,9 @@ var Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(function Dialo
56
57
  onClose = _ref.onClose,
57
58
  onEnterFinish = _ref.onEnterFinish,
58
59
  onExitFinish = _ref.onExitFinish,
59
- animate = _ref.animate,
60
- xcssFromProps = _ref.xcss,
60
+ _ref$animate = _ref.animate,
61
+ animate = _ref$animate === void 0 ? false : _ref$animate,
62
+ consumerXcss = _ref.xcss,
61
63
  style = _ref.style,
62
64
  testId = _ref.testId,
63
65
  providedId = _ref.id,
@@ -70,6 +72,7 @@ var Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(function Dialo
70
72
  var combinedRef = (0, _mergeRefs.default)([ownRef, ref]);
71
73
  var _useAnimatedVisibilit = (0, _useAnimatedVisibility.useAnimatedVisibility)({
72
74
  isOpen: isOpen,
75
+ animationKind: 'dialog',
73
76
  animate: animate,
74
77
  elementRef: ownRef,
75
78
  onEnterFinish: onEnterFinish,
@@ -121,32 +124,6 @@ var Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(function Dialo
121
124
  }
122
125
  }, [isOpen]);
123
126
 
124
- // Apply preset-provided animation custom properties (e.g. the
125
- // `--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.
129
- (0, _react.useLayoutEffect)(function () {
130
- var dialog = ownRef.current;
131
- if (!dialog || !(preset !== null && preset !== void 0 && preset.getProperties)) {
132
- return;
133
- }
134
- var props = preset.getProperties({
135
- placement: {}
136
- });
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
- }, [preset, isVisible]);
149
-
150
127
  // Handle native Escape (cancel event)
151
128
  var handleCancel = (0, _react.useCallback)(function (event) {
152
129
  // Only handle a cancel targeting THIS dialog. Native `cancel` does not
@@ -186,12 +163,6 @@ var Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(function Dialo
186
163
  });
187
164
  }, [onClose, isVisible]);
188
165
 
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
166
  // Unmount the `<dialog>` once exit completes so it does not leave an
196
167
  // empty `role="dialog"` element in the accessibility tree. On the next
197
168
  // open the element remounts and the `[isOpen]` and `[onClose, isVisible]`
@@ -199,7 +170,7 @@ var Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(function Dialo
199
170
  if (!isVisible) {
200
171
  return null;
201
172
  }
202
- return /*#__PURE__*/_react.default.createElement("dialog", (0, _extends2.default)({
173
+ return /*#__PURE__*/_react.default.createElement("dialog", {
203
174
  ref: combinedRef,
204
175
  id: dialogId
205
176
  // `aria-modal` is intentionally NOT set: native `<dialog>.showModal()`
@@ -210,15 +181,9 @@ var Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(function Dialo
210
181
  ,
211
182
  "aria-label": label,
212
183
  "aria-labelledby": label ? undefined : labelledBy,
213
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
214
184
  style: style,
215
185
  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);
186
+ "data-testid": testId,
187
+ className: (0, _runtime.ax)([styles.dialog, shouldHideBackdrop ? backdropStyles.hidden : backdropStyles.root, preset && backdropStyles.motion, preset && dialogAnimationStyles.root, preset && dialogAnimationStyles.motion, consumerXcss])
188
+ }, children);
224
189
  });
@@ -1,48 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "dialogFade", {
7
- enumerable: true,
8
- get: function get() {
9
- return _presets.dialogFade;
10
- }
11
- });
12
- Object.defineProperty(exports, "dialogMotion", {
13
- enumerable: true,
14
- get: function get() {
15
- return _presets.dialogMotion;
16
- }
17
- });
18
- Object.defineProperty(exports, "dialogSlideUpAndFade", {
19
- enumerable: true,
20
- get: function get() {
21
- return _presets.dialogSlideUpAndFade;
22
- }
23
- });
24
- Object.defineProperty(exports, "fade", {
25
- enumerable: true,
26
- get: function get() {
27
- return _presets.fade;
28
- }
29
- });
30
- Object.defineProperty(exports, "popupMotion", {
31
- enumerable: true,
32
- get: function get() {
33
- return _presets.popupMotion;
34
- }
35
- });
36
- Object.defineProperty(exports, "scaleAndFade", {
37
- enumerable: true,
38
- get: function get() {
39
- return _presets.scaleAndFade;
40
- }
41
- });
42
- Object.defineProperty(exports, "slideAndFade", {
43
- enumerable: true,
44
- get: function get() {
45
- return _presets.slideAndFade;
46
- }
47
- });
48
- var _presets = require("../animations/presets");
1
+ "use strict";
@@ -9,6 +9,29 @@ 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
+ * Using the recommended motion timings for safety net.
14
+ *
15
+ * Not setting these timings on the preset config because they're defined in the CSS,
16
+ * so configuring it in the preset doesn't achieve anything except introduce a potential
17
+ * source of drift.
18
+ *
19
+ * TODO: figure out a way to not need to redeclare these in the future,
20
+ * and keep CSS and JS timings in sync always.
21
+ */
22
+ var safetyNetMsMap = {
23
+ dialog: {
24
+ enter: 250,
25
+ // Corresponds to `motion.duration.long`
26
+ exit: 200 // Corresponds to `motion.duration.medium`
27
+ },
28
+ popover: {
29
+ enter: 150,
30
+ // Corresponds to `motion.duration.short`
31
+ exit: 100 // Corresponds to `motion.duration.xshort`
32
+ }
33
+ };
34
+
12
35
  /**
13
36
  * Fires `onSettled` once when `transitionend` fires on `element`, or after
14
37
  * `safetyNetMs` if the event is swallowed (mid-transition unmount, CSS
@@ -44,6 +67,13 @@ function runOnTransitionEndOrTimeout(_ref) {
44
67
  return teardown;
45
68
  }
46
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
+
47
77
  /**
48
78
  * Visibility lifecycle phase shared between `useAnimatedVisibility`,
49
79
  * `useFocusWrap`, `useInitialFocus`, and the `Popover` / `Dialog`
@@ -107,6 +137,7 @@ function runOnTransitionEndOrTimeout(_ref) {
107
137
  */
108
138
  function useAnimatedVisibility(_ref2) {
109
139
  var isOpen = _ref2.isOpen,
140
+ animationKind = _ref2.animationKind,
110
141
  animate = _ref2.animate,
111
142
  elementRef = _ref2.elementRef,
112
143
  onEnterFinish = _ref2.onEnterFinish,
@@ -160,7 +191,6 @@ function useAnimatedVisibility(_ref2) {
160
191
  // move to `open`. The fallback guarantees settle on swallowed events
161
192
  // (zero-duration, browser quirk, mid-transition unmount).
162
193
  (0, _react.useEffect)(function () {
163
- var _preset$enterDuration;
164
194
  if (phase !== 'entering') {
165
195
  return;
166
196
  }
@@ -170,7 +200,7 @@ function useAnimatedVisibility(_ref2) {
170
200
  }
171
201
  return runOnTransitionEndOrTimeout({
172
202
  element: element,
173
- safetyNetMs: ((_preset$enterDuration = preset === null || preset === void 0 ? void 0 : preset.enterDurationMs) !== null && _preset$enterDuration !== void 0 ? _preset$enterDuration : 0) + 50,
203
+ safetyNetMs: safetyNetMsMap[animationKind].enter + 50,
174
204
  onSettled: function onSettled() {
175
205
  var _onEnterFinishRef$cur;
176
206
  // Fire the consumer callback before transitioning phase so any
@@ -183,7 +213,7 @@ function useAnimatedVisibility(_ref2) {
183
213
  });
184
214
  }
185
215
  });
186
- }, [phase, preset === null || preset === void 0 ? void 0 : preset.enterDurationMs, elementRef]);
216
+ }, [phase, animationKind, elementRef]);
187
217
 
188
218
  // Non-animated entry callback. The lifecycle goes `closed → open`
189
219
  // directly with no `entering` phase; fire `onEnterFinish` on that jump.
@@ -204,7 +234,6 @@ function useAnimatedVisibility(_ref2) {
204
234
  // Animated exit: wait for `transitionend` (or a safety-net timeout),
205
235
  // fire `onExitFinish`, then move to `closed` to unmount the host.
206
236
  (0, _react.useEffect)(function () {
207
- var _preset$exitDurationM;
208
237
  if (phase !== 'exiting' || !willAnimate) {
209
238
  return;
210
239
  }
@@ -214,7 +243,7 @@ function useAnimatedVisibility(_ref2) {
214
243
  }
215
244
  return runOnTransitionEndOrTimeout({
216
245
  element: element,
217
- safetyNetMs: ((_preset$exitDurationM = preset === null || preset === void 0 ? void 0 : preset.exitDurationMs) !== null && _preset$exitDurationM !== void 0 ? _preset$exitDurationM : 0) + 50,
246
+ safetyNetMs: safetyNetMsMap[animationKind].exit + 50,
218
247
  onSettled: function onSettled() {
219
248
  var _onExitFinishRef$curr;
220
249
  // Fire the consumer callback before transitioning phase to
@@ -229,7 +258,7 @@ function useAnimatedVisibility(_ref2) {
229
258
  });
230
259
  }
231
260
  });
232
- }, [phase, willAnimate, preset === null || preset === void 0 ? void 0 : preset.exitDurationMs, elementRef]);
261
+ }, [phase, willAnimate, animationKind, elementRef]);
233
262
 
234
263
  // Non-animated exit: wait for the browser's `toggle` (closed) or
235
264
  // `close` event before unmounting, so the consumer's listener (close
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getPopupMotionStyles = getPopupMotionStyles;
7
+ var _resolvePlacement = require("../internal/resolve-placement");
8
+ function getPopupMotionStyles(_ref) {
9
+ var placement = _ref.placement;
10
+ var _getPlacement = (0, _resolvePlacement.getPlacement)({
11
+ placement: placement
12
+ }),
13
+ axis = _getPlacement.axis,
14
+ edge = _getPlacement.edge;
15
+ if (axis === 'block' && edge === 'start') {
16
+ return [{
17
+ property: '--ds-popover-motion-enter',
18
+ 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)"
19
+ }, {
20
+ property: '--ds-popover-motion-exit',
21
+ 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)"
22
+ }];
23
+ }
24
+ if (axis === 'inline' && edge === 'start') {
25
+ return [{
26
+ property: '--ds-popover-motion-enter',
27
+ 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)"
28
+ }, {
29
+ property: '--ds-popover-motion-exit',
30
+ 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)"
31
+ }];
32
+ }
33
+ if (axis === 'inline' && edge === 'end') {
34
+ return [{
35
+ property: '--ds-popover-motion-enter',
36
+ 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)"
37
+ }, {
38
+ property: '--ds-popover-motion-exit',
39
+ 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)"
40
+ }];
41
+ }
42
+ // Default: block/end (popover below trigger)
43
+ return [{
44
+ property: '--ds-popover-motion-enter',
45
+ 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)"
46
+ }, {
47
+ property: '--ds-popover-motion-exit',
48
+ 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)"
49
+ }];
50
+ }
@@ -2,32 +2,25 @@
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}
12
10
  ._1o51q7pw{animation-fill-mode:forwards}
13
- ._1oec6ebc{transition-duration:.15s}
14
- ._1oecluct{transition-duration:175ms}
11
+ ._1oecdn4k{transition-duration:var(--ds-duration-xshort,.1s)}
12
+ ._1pgl1lbj{animation-timing-function:var(--ds-easing-in-practical,cubic-bezier(.6,0,.8,.6))}
13
+ ._1psg1ign:popover-open{animation-duration:var(--ds-duration-short,.15s)}
15
14
  ._1reoewfl{overflow-x:visible}
16
15
  ._1s9z1a5r{transition-behavior:allow-discrete}
17
16
  ._2hwxidpf{margin-right:0}
18
- ._6fl41a34{transition-timing-function:cubic-bezier(.15,1,.3,1)}
17
+ ._5sagdn4k{animation-duration:var(--ds-duration-xshort,.1s)}
19
18
  ._bfhk1j28{background-color:transparent}
20
19
  ._ca0qidpf{padding-top:0}
21
20
  ._k8m011k7{transition-property:overlay,display}
22
- ._k8m01slm{transition-property:opacity,overlay,display}
23
- ._k8m0rv36{transition-property:opacity,transform,overlay,display}
24
21
  ._n3tdidpf{padding-bottom:0}
25
22
  ._n70peoah:popover-open{animation-fill-mode:backwards}
23
+ ._o8i7indk:popover-open{animation-timing-function:var(--ds-easing-out-practical,cubic-bezier(.4,1,.6,1))}
26
24
  ._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
25
  ._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))}}
26
+ @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,18 +9,17 @@ 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");
22
+ var _animations = require("./animations");
24
23
  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); }
25
24
  /**
26
25
  * Detects `popover="hint"` support via DOM reflection. SSR-safe, cached.
@@ -40,10 +39,7 @@ var supportsPopoverHint = (0, _once.default)(function () {
40
39
  // Keep them in this component so the Compiled transform can statically extract
41
40
  // every referenced style.
42
41
  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"
42
+ root: "_y44vof1f _k8m011k7 _1oecdn4k _1s9z1a5r _1o51q7pw _5sagdn4k _1pgl1lbj _15ns179n _12t71ign _n70peoah _1psg1ign _o8i7indk _bl8aglyw _156yru3m _8rmvglyw _2qm2ru3m"
47
43
  };
48
44
  var styles = {
49
45
  root: "_19itglyw _ca0qidpf _u5f3idpf _n3tdidpf _19bvidpf _19pkidpf _2hwxidpf _otyridpf _18u0idpf _1r041wug _1reoewfl _18m9ewfl _bfhk1j28"
@@ -94,11 +90,12 @@ var Popover = exports.Popover = /*#__PURE__*/(0, _react.forwardRef)(function Pop
94
90
  onOpenChange = _ref.onOpenChange,
95
91
  onEnterFinish = _ref.onEnterFinish,
96
92
  onExitFinish = _ref.onExitFinish,
97
- animate = _ref.animate,
93
+ _ref$animate = _ref.animate,
94
+ animate = _ref$animate === void 0 ? false : _ref$animate,
98
95
  placement = _ref.placement,
99
96
  testId = _ref.testId,
100
97
  isOpen = _ref.isOpen,
101
- xcssFromProps = _ref.xcss,
98
+ consumerXcss = _ref.xcss,
102
99
  role = _ref.role,
103
100
  label = _ref.label,
104
101
  labelledBy = _ref.labelledBy,
@@ -110,6 +107,7 @@ var Popover = exports.Popover = /*#__PURE__*/(0, _react.forwardRef)(function Pop
110
107
  var popoverId = idProp !== null && idProp !== void 0 ? idProp : "popover-".concat(autoId.replace(/:/g, ''));
111
108
  var _useAnimatedVisibilit = (0, _useAnimatedVisibility.useAnimatedVisibility)({
112
109
  isOpen: isOpen,
110
+ animationKind: 'popover',
113
111
  animate: animate,
114
112
  elementRef: ownRef,
115
113
  onEnterFinish: onEnterFinish,
@@ -273,27 +271,19 @@ var Popover = exports.Popover = /*#__PURE__*/(0, _react.forwardRef)(function Pop
273
271
 
274
272
  // Placement-dependent animation CSS vars. Kept separate from show/hide
275
273
  // 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.
274
+ // restores the previous inline values so a preset change does not leave
275
+ // stale custom properties on the element.
278
276
  (0, _react.useLayoutEffect)(function () {
279
277
  var element = ownRef.current;
280
- if (!element || !(preset !== null && preset !== void 0 && preset.getProperties) || !placement) {
278
+ if (!element || !placement) {
281
279
  return;
282
280
  }
283
- var props = preset.getProperties({
284
- placement: placement
281
+ return (0, _setStyle.setStyle)({
282
+ element: element,
283
+ styles: (0, _animations.getPopupMotionStyles)({
284
+ placement: placement
285
+ })
285
286
  });
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
287
  }, [preset, placement, isVisible]);
298
288
 
299
289
  // Show/hide based on isOpen. `showPopover`/`hidePopover` are no-ops when
@@ -332,7 +322,7 @@ var Popover = exports.Popover = /*#__PURE__*/(0, _react.forwardRef)(function Pop
332
322
  if (!isVisible) {
333
323
  return null;
334
324
  }
335
- return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
325
+ return /*#__PURE__*/_react.default.createElement("div", {
336
326
  ref: combinedRef,
337
327
  id: popoverId
338
328
  // @ts-expect-error -- popover attribute not yet in React types
@@ -342,9 +332,7 @@ var Popover = exports.Popover = /*#__PURE__*/(0, _react.forwardRef)(function Pop
342
332
  role: role,
343
333
  "aria-label": label,
344
334
  "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);
335
+ "data-testid": testId,
336
+ className: (0, _runtime.ax)([styles.root, preset && popoverAnimationStyles.root, consumerXcss])
337
+ }, children);
350
338
  });
@@ -526,6 +526,9 @@ if (typeof HTMLElement !== 'undefined') {
526
526
  // delegate every other selector to the original implementation.
527
527
  // Spec: https://html.spec.whatwg.org/multipage/semantics-other.html#selector-popover-open
528
528
  var originalMatches = Element.prototype.matches;
529
+ // The DOM lib types `Element.prototype.matches` as a set of type-predicate
530
+ // overloads. This polyfill intentionally replaces it with a plain boolean
531
+ // implementation, so we cast to the original member type.
529
532
  Element.prototype.matches = function patchedMatches(selector) {
530
533
  if (selector === ':popover-open') {
531
534
  return this.hasAttribute('data-popover-open');