@atlaskit/top-layer 1.3.0 → 1.5.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 (36) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/animations/presets.js +46 -48
  3. package/dist/cjs/dialog/dialog-content.compiled.css +46 -2
  4. package/dist/cjs/dialog/dialog-content.js +39 -2
  5. package/dist/cjs/internal/use-animated-visibility.js +4 -4
  6. package/dist/cjs/popover/popover.compiled.css +22 -2
  7. package/dist/cjs/popover/popover.js +19 -3
  8. package/dist/es2019/animations/presets.js +42 -299
  9. package/dist/es2019/dialog/dialog-content.compiled.css +46 -2
  10. package/dist/es2019/dialog/dialog-content.js +35 -2
  11. package/dist/es2019/internal/use-animated-visibility.js +4 -4
  12. package/dist/es2019/popover/popover.compiled.css +22 -2
  13. package/dist/es2019/popover/popover.js +19 -3
  14. package/dist/esm/animations/presets.js +45 -48
  15. package/dist/esm/dialog/dialog-content.compiled.css +46 -2
  16. package/dist/esm/dialog/dialog-content.js +39 -2
  17. package/dist/esm/internal/use-animated-visibility.js +4 -4
  18. package/dist/esm/popover/popover.compiled.css +22 -2
  19. package/dist/esm/popover/popover.js +19 -3
  20. package/dist/types/animations/presets.d.ts +18 -0
  21. package/dist/types/animations/types.d.ts +10 -14
  22. package/dist/types/dialog/types.d.ts +9 -1
  23. package/dist/types/internal/use-animated-visibility.d.ts +2 -2
  24. package/package.json +13 -31
  25. package/dist/cjs/internal/ensure-preset-styles.js +0 -34
  26. package/dist/cjs/internal/use-animation-preset.js +0 -24
  27. package/dist/cjs/internal/use-preset-styles.js +0 -27
  28. package/dist/es2019/internal/ensure-preset-styles.js +0 -29
  29. package/dist/es2019/internal/use-animation-preset.js +0 -18
  30. package/dist/es2019/internal/use-preset-styles.js +0 -22
  31. package/dist/esm/internal/ensure-preset-styles.js +0 -28
  32. package/dist/esm/internal/use-animation-preset.js +0 -18
  33. package/dist/esm/internal/use-preset-styles.js +0 -21
  34. package/dist/types/internal/ensure-preset-styles.d.ts +0 -6
  35. package/dist/types/internal/use-animation-preset.d.ts +0 -11
  36. package/dist/types/internal/use-preset-styles.d.ts +0 -15
@@ -1,11 +1,25 @@
1
1
  import { getPlacement } from '../internal/resolve-placement';
2
- // ══════════════════════════════════════════════════════════════════════════════
3
- // Popover presets
4
- // ══════════════════════════════════════════════════════════════════════════════
5
-
6
- // ── popupMotion ──
2
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
3
+ export var animationDurations = {
4
+ popupMotion: {
5
+ enter: 150,
6
+ exit: 100
7
+ },
8
+ popoverTransition: {
9
+ enter: 350,
10
+ exit: 175
11
+ },
12
+ dialogMotion: {
13
+ enter: 250,
14
+ exit: 200
15
+ },
16
+ dialogTransition: {
17
+ enter: 350,
18
+ exit: 175
19
+ }
20
+ };
21
+ // popupMotion
7
22
 
8
- var POPUP_MOTION_CSS = "\n [data-ds-popover-popup-motion] {\n animation: var(--ds-popover-motion-exit);\n animation-fill-mode: forwards;\n transition:\n overlay 150ms allow-discrete,\n display 150ms allow-discrete;\n }\n\n [data-ds-popover-popup-motion]:popover-open {\n animation: var(--ds-popover-motion-enter);\n animation-fill-mode: backwards;\n }\n\n @media (prefers-reduced-motion: reduce) {\n [data-ds-popover-popup-motion],\n [data-ds-popover-popup-motion]:popover-open {\n animation: none;\n transition-duration: 0s;\n }\n }\n";
9
23
  function getPopupMotionProperties(_ref) {
10
24
  var placement = _ref.placement;
11
25
  var _getPlacement = getPlacement({
@@ -42,9 +56,8 @@ function getPopupMotionProperties(_ref) {
42
56
  export function popupMotion() {
43
57
  return {
44
58
  name: 'popup-motion',
45
- css: POPUP_MOTION_CSS,
46
- enterDurationMs: 150,
47
- exitDurationMs: 100,
59
+ enterDurationMs: animationDurations.popupMotion.enter,
60
+ exitDurationMs: animationDurations.popupMotion.exit,
48
61
  getProperties: function getProperties(_ref2) {
49
62
  var placement = _ref2.placement;
50
63
  return getPopupMotionProperties({
@@ -54,7 +67,7 @@ export function popupMotion() {
54
67
  };
55
68
  }
56
69
 
57
- // ── slideAndFade ──
70
+ // slideAndFade
58
71
 
59
72
  function getSlideAndFadeProperties(_ref3) {
60
73
  var placement = _ref3.placement,
@@ -96,9 +109,6 @@ function getSlideAndFadeProperties(_ref3) {
96
109
  };
97
110
  }
98
111
 
99
- // ℹ️ Note: The `transform` x value is flipped in right-to-left mode using the `[dir='rtl']` selector.
100
- var SLIDE_AND_FADE_CSS = "\n[data-ds-popover-slide-and-fade] {\n opacity: 0;\n transform: translate(var(--ds-popover-tx, 0), var(--ds-popover-ty, 0));\n transition:\n opacity 175ms cubic-bezier(0.15, 1, 0.3, 1),\n transform 175ms cubic-bezier(0.15, 1, 0.3, 1),\n overlay 175ms allow-discrete,\n display 175ms allow-discrete;\n}\n\n[dir='rtl'] [data-ds-popover-slide-and-fade] {\n transform: translate(calc(-1 * var(--ds-popover-tx, 0)), var(--ds-popover-ty, 0));\n}\n\n[data-ds-popover-slide-and-fade]:popover-open {\n opacity: 1;\n transform: none;\n transition-duration: 350ms;\n}\n\n@starting-style {\n [data-ds-popover-slide-and-fade]:popover-open {\n opacity: 0;\n transform: translate(var(--ds-popover-tx, 0), var(--ds-popover-ty, 0));\n }\n}\n\n@starting-style {\n [dir='rtl'] [data-ds-popover-slide-and-fade]:popover-open {\n transform: translate(calc(-1 * var(--ds-popover-tx, 0)), var(--ds-popover-ty, 0));\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n [data-ds-popover-slide-and-fade],\n [data-ds-popover-slide-and-fade]:popover-open {\n transition-duration: 0s;\n }\n}\n";
101
-
102
112
  /**
103
113
  * Directional slide + opacity animation.
104
114
  *
@@ -124,7 +134,6 @@ export function slideAndFade(options) {
124
134
  var distance = (_options$distance = options === null || options === void 0 ? void 0 : options.distance) !== null && _options$distance !== void 0 ? _options$distance : 4;
125
135
  return {
126
136
  name: 'slide-and-fade',
127
- css: SLIDE_AND_FADE_CSS,
128
137
  getProperties: function getProperties(_ref4) {
129
138
  var placement = _ref4.placement;
130
139
  return getSlideAndFadeProperties({
@@ -132,15 +141,13 @@ export function slideAndFade(options) {
132
141
  distance: distance
133
142
  });
134
143
  },
135
- enterDurationMs: 350,
136
- exitDurationMs: 175
144
+ enterDurationMs: animationDurations.popoverTransition.enter,
145
+ exitDurationMs: animationDurations.popoverTransition.exit
137
146
  };
138
147
  }
139
148
 
140
149
  // fade
141
150
 
142
- var FADE_CSS = "\n[data-ds-popover-fade] {\n opacity: 0;\n transition:\n opacity 175ms cubic-bezier(0.15, 1, 0.3, 1),\n overlay 175ms allow-discrete,\n display 175ms allow-discrete;\n}\n\n[data-ds-popover-fade]:popover-open {\n opacity: 1;\n transition-duration: 350ms;\n}\n\n@starting-style {\n [data-ds-popover-fade]:popover-open {\n opacity: 0;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n [data-ds-popover-fade],\n [data-ds-popover-fade]:popover-open {\n transition-duration: 0s;\n }\n}\n";
143
-
144
151
  /**
145
152
  * Simple opacity transition, no transform.
146
153
  *
@@ -157,16 +164,13 @@ var FADE_CSS = "\n[data-ds-popover-fade] {\n opacity: 0;\n transition:\n op
157
164
  export function fade() {
158
165
  return {
159
166
  name: 'fade',
160
- css: FADE_CSS,
161
- enterDurationMs: 350,
162
- exitDurationMs: 175
167
+ enterDurationMs: animationDurations.popoverTransition.enter,
168
+ exitDurationMs: animationDurations.popoverTransition.exit
163
169
  };
164
170
  }
165
171
 
166
172
  // scaleAndFade
167
173
 
168
- var SCALE_AND_FADE_CSS = "\n[data-ds-popover-scale-and-fade] {\n opacity: 0;\n transform: scale(0.95);\n transition:\n opacity 175ms cubic-bezier(0.15, 1, 0.3, 1),\n transform 175ms cubic-bezier(0.15, 1, 0.3, 1),\n overlay 175ms allow-discrete,\n display 175ms allow-discrete;\n}\n\n[data-ds-popover-scale-and-fade]:popover-open {\n opacity: 1;\n transform: none;\n transition-duration: 350ms;\n}\n\n@starting-style {\n [data-ds-popover-scale-and-fade]:popover-open {\n opacity: 0;\n transform: scale(0.95);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n [data-ds-popover-scale-and-fade],\n [data-ds-popover-scale-and-fade]:popover-open {\n transition-duration: 0s;\n }\n}\n";
169
-
170
174
  /**
171
175
  * Scale from 0.95 + opacity transition.
172
176
  *
@@ -183,19 +187,12 @@ var SCALE_AND_FADE_CSS = "\n[data-ds-popover-scale-and-fade] {\n opacity: 0;\n
183
187
  export function scaleAndFade() {
184
188
  return {
185
189
  name: 'scale-and-fade',
186
- css: SCALE_AND_FADE_CSS,
187
- enterDurationMs: 350,
188
- exitDurationMs: 175
190
+ enterDurationMs: animationDurations.popoverTransition.enter,
191
+ exitDurationMs: animationDurations.popoverTransition.exit
189
192
  };
190
193
  }
191
194
 
192
- // ══════════════════════════════════════════════════════════════════════════════
193
- // Dialog presets
194
- // ══════════════════════════════════════════════════════════════════════════════
195
-
196
- // ── dialogMotion ──
197
-
198
- var DIALOG_MOTION_CSS = "\n [data-ds-dialog-motion] {\n animation: ".concat("var(--ds-modal-exit, 200ms cubic-bezier(0.6, 0, 0.8, 0.6) ScaleOut100to95)", ";\n animation-fill-mode: forwards;\n transition:\n overlay 200ms allow-discrete,\n display 200ms allow-discrete;\n }\n\n [data-ds-dialog-motion][open] {\n animation: ", "var(--ds-modal-enter, 250ms cubic-bezier(0.4, 0, 0, 1) ScaleIn95to100)", ";\n animation-fill-mode: backwards;\n }\n\n [data-ds-dialog-motion]::backdrop {\n animation: ", "var(--ds-blanket-exit, 200ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)", ";\n animation-fill-mode: forwards;\n background-color: var(--ds-blanket, #050C1F75);\n transition:\n overlay 200ms allow-discrete,\n display 200ms allow-discrete;\n }\n\n [data-ds-dialog-motion][open]::backdrop {\n animation: ", "var(--ds-blanket-enter, 250ms cubic-bezier(0.4, 0, 0, 1) FadeIn0to100)", ";\n animation-fill-mode: backwards;\n }\n\n @media (prefers-reduced-motion: reduce) {\n [data-ds-dialog-motion],\n [data-ds-dialog-motion][open],\n [data-ds-dialog-motion]::backdrop,\n [data-ds-dialog-motion][open]::backdrop {\n animation: none;\n transition-duration: 0s;\n }\n }\n");
195
+ // dialogMotion
199
196
 
200
197
  /**
201
198
  * Dialog motion animation.
@@ -216,15 +213,12 @@ export function dialogMotion() {
216
213
  // Bare preset name; `Dialog` prefixes it via `data-ds-dialog-{name}`.
217
214
  return {
218
215
  name: 'motion',
219
- css: DIALOG_MOTION_CSS,
220
- enterDurationMs: 250,
221
- exitDurationMs: 200
216
+ enterDurationMs: animationDurations.dialogMotion.enter,
217
+ exitDurationMs: animationDurations.dialogMotion.exit
222
218
  };
223
219
  }
224
220
 
225
- // ── dialogSlideUpAndFade ──
226
-
227
- var DIALOG_SLIDE_UP_AND_FADE_CSS = "\n[data-ds-dialog-slide-up-and-fade] {\n opacity: 0;\n transform: translateY(calc(-1 * var(--ds-dialog-ty, 12px)));\n transition:\n opacity 175ms cubic-bezier(0.15, 1, 0.3, 1),\n transform 175ms cubic-bezier(0.15, 1, 0.3, 1),\n overlay 175ms allow-discrete,\n display 175ms allow-discrete;\n}\n\n[data-ds-dialog-slide-up-and-fade][open] {\n opacity: 1;\n transform: none;\n transition-duration: 350ms;\n}\n\n@starting-style {\n [data-ds-dialog-slide-up-and-fade][open] {\n opacity: 0;\n transform: translateY(var(--ds-dialog-ty, 12px));\n }\n}\n\n[data-ds-dialog-slide-up-and-fade]::backdrop {\n background-color: transparent;\n transition:\n background-color 175ms cubic-bezier(0.15, 1, 0.3, 1),\n overlay 175ms allow-discrete,\n display 175ms allow-discrete;\n}\n\n[data-ds-dialog-slide-up-and-fade][open]::backdrop {\n background-color: var(--ds-blanket, #050C1F75);\n transition-duration: 350ms;\n}\n\n@starting-style {\n [data-ds-dialog-slide-up-and-fade][open]::backdrop {\n background-color: transparent;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n [data-ds-dialog-slide-up-and-fade],\n [data-ds-dialog-slide-up-and-fade][open],\n [data-ds-dialog-slide-up-and-fade]::backdrop,\n [data-ds-dialog-slide-up-and-fade][open]::backdrop {\n transition-duration: 0s;\n }\n}\n";
221
+ // dialogSlideUpAndFade
228
222
 
229
223
  /**
230
224
  * Slide up + opacity animation for dialogs.
@@ -250,18 +244,22 @@ export function dialogSlideUpAndFade(options) {
250
244
  var distance = (_options$distance2 = options === null || options === void 0 ? void 0 : options.distance) !== null && _options$distance2 !== void 0 ? _options$distance2 : 12;
251
245
 
252
246
  // Bare preset name; `Dialog` prefixes it via `data-ds-dialog-{name}`.
247
+ // The distance is applied via the `--ds-dialog-ty` custom property rather
248
+ // than baked into the styles, so the name stays stable across distances.
253
249
  return {
254
- name: distance === 12 ? 'slide-up-and-fade' : "slide-up-and-fade-".concat(distance),
255
- css: distance === 12 ? DIALOG_SLIDE_UP_AND_FADE_CSS : DIALOG_SLIDE_UP_AND_FADE_CSS.replace(/12px/g, "".concat(distance, "px")),
256
- enterDurationMs: 350,
257
- exitDurationMs: 175
250
+ name: 'slide-up-and-fade',
251
+ getProperties: function getProperties() {
252
+ return {
253
+ '--ds-dialog-ty': "".concat(distance, "px")
254
+ };
255
+ },
256
+ enterDurationMs: animationDurations.dialogTransition.enter,
257
+ exitDurationMs: animationDurations.dialogTransition.exit
258
258
  };
259
259
  }
260
260
 
261
261
  // dialogFade
262
262
 
263
- var DIALOG_FADE_CSS = "\n[data-ds-dialog-fade] {\n opacity: 0;\n transition:\n opacity 175ms cubic-bezier(0.15, 1, 0.3, 1),\n overlay 175ms allow-discrete,\n display 175ms allow-discrete;\n}\n\n[data-ds-dialog-fade][open] {\n opacity: 1;\n transition-duration: 350ms;\n}\n\n@starting-style {\n [data-ds-dialog-fade][open] {\n opacity: 0;\n }\n}\n\n[data-ds-dialog-fade]::backdrop {\n background-color: transparent;\n transition:\n background-color 175ms cubic-bezier(0.15, 1, 0.3, 1),\n overlay 175ms allow-discrete,\n display 175ms allow-discrete;\n}\n\n[data-ds-dialog-fade][open]::backdrop {\n background-color: var(--ds-blanket, #050C1F75);\n transition-duration: 350ms;\n}\n\n@starting-style {\n [data-ds-dialog-fade][open]::backdrop {\n background-color: transparent;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n [data-ds-dialog-fade],\n [data-ds-dialog-fade][open],\n [data-ds-dialog-fade]::backdrop,\n [data-ds-dialog-fade][open]::backdrop {\n transition-duration: 0s;\n }\n}\n";
264
-
265
263
  /**
266
264
  * Simple opacity transition for dialogs, no transform.
267
265
  *
@@ -281,8 +279,7 @@ export function dialogFade() {
281
279
  // Bare preset name; `Dialog` prefixes it via `data-ds-dialog-{name}`.
282
280
  return {
283
281
  name: 'fade',
284
- css: DIALOG_FADE_CSS,
285
- enterDurationMs: 350,
286
- exitDurationMs: 175
282
+ enterDurationMs: animationDurations.dialogTransition.enter,
283
+ exitDurationMs: animationDurations.dialogTransition.exit
287
284
  };
288
285
  }
@@ -1,14 +1,58 @@
1
1
 
2
- ._19itglyw{border:none}._18u01wug{margin-left:auto}
2
+ ._19itglyw{border:none}
3
+ ._1iu47kvq[open]{animation:var(--ds-modal-enter,.25s cubic-bezier(.4,0,0,1) ScaleIn95to100)}
4
+ ._1m5e1op4::-ms-backdrop{animation:var(--ds-blanket-exit,.2s cubic-bezier(.6,0,.8,.6) FadeOut100to0)}
5
+ ._1m5e1op4::backdrop{animation:var(--ds-blanket-exit,.2s cubic-bezier(.6,0,.8,.6) FadeOut100to0)}
6
+ ._vhgsxbuz[open]::-ms-backdrop{animation:var(--ds-blanket-enter,.25s cubic-bezier(.4,0,0,1) FadeIn0to100)}
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}
3
11
  ._19pk1wug{margin-top:auto}
12
+ ._1fsl1ttt[open]{transition-duration:.35s}
13
+ ._1fyf1a5r::-ms-backdrop{transition-behavior:allow-discrete}
14
+ ._1fyf1a5r::backdrop{transition-behavior:allow-discrete}
15
+ ._1gbckb7n[open]{opacity:1}
16
+ ._1i0neoah[open]{animation-fill-mode:backwards}
17
+ ._1jhdq7pw::-ms-backdrop{animation-fill-mode:forwards}
18
+ ._1jhdq7pw::backdrop{animation-fill-mode:forwards}
19
+ ._1kdeglyw[open]{transform:none}
4
20
  ._1ltk1i5c::-ms-backdrop{background-color:var(--ds-blanket,#050c1f75)}
5
21
  ._1ltk1i5c::backdrop{background-color:var(--ds-blanket,#050c1f75)}
22
+ ._1ltk1j28::-ms-backdrop{background-color:transparent}
23
+ ._1ltk1j28::backdrop{background-color:transparent}
24
+ ._1o51q7pw{animation-fill-mode:forwards}
25
+ ._1oecfnf5{transition-duration:.2s}
26
+ ._1oecluct{transition-duration:175ms}
6
27
  ._1q51ze3t{padding-block-start:var(--ds-space-0,0)}
28
+ ._1rsueoah[open]::-ms-backdrop{animation-fill-mode:backwards}
29
+ ._1rsueoah[open]::backdrop{animation-fill-mode:backwards}
30
+ ._1s9z1a5r{transition-behavior:allow-discrete}
7
31
  ._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)}
8
35
  ._85i5ze3t{padding-block-end:var(--ds-space-0,0)}
9
36
  ._bfhk1j28{background-color:transparent}
10
37
  ._bozgze3t{padding-inline-start:var(--ds-space-0,0)}
11
38
  ._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
+ ._k8m011k7{transition-property:overlay,display}
42
+ ._k8m01slm{transition-property:opacity,overlay,display}
43
+ ._k8m0rv36{transition-property:opacity,transform,overlay,display}
44
+ ._njwk11k7::-ms-backdrop{-ms-transition-property:overlay,display;transition-property:overlay,display}
45
+ ._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}
12
48
  ._otyr1wug{margin-bottom:auto}
13
49
  ._p12fglyw{max-width:none}
14
- ._y4tize3t{padding-inline-end:var(--ds-space-0,0)}
50
+ ._t9ec9o47{transform:translateY(calc(var(--ds-dialog-ty, 9pt)*-1))}
51
+ ._tzy4idpf{opacity:0}
52
+ ._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))}}
@@ -1,6 +1,7 @@
1
1
  /* dialog-content.tsx generated by @compiled/babel-plugin v0.39.1 */
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
5
  import "./dialog-content.compiled.css";
5
6
  import { ax, ix } from "@compiled/react/runtime";
6
7
  import React, { forwardRef, useCallback, useEffect, useId, useLayoutEffect, useRef } from 'react';
@@ -10,7 +11,15 @@ import noop from '@atlaskit/ds-lib/noop';
10
11
  import { useNotifyOpenLayerObserver } from '@atlaskit/layering/experimental/open-layer-observer';
11
12
  import { useAnimatedVisibility } from '../internal/use-animated-visibility';
12
13
  import { useFocusWrap } from '../internal/use-focus-wrap';
13
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- dialog reset requires values not in cssMap's type union
14
+ // These animation styles use the non-strict Compiled cssMap because they rely
15
+ // on `@starting-style`, `[open]`, and `allow-discrete`. Keep them in this
16
+ // component so the Compiled transform can statically extract every referenced
17
+ // style.
18
+ var dialogAnimationStyles = {
19
+ motion: "_y44vgeqi _1o51q7pw _k8m011k7 _1oecfnf5 _1s9z1a5r _1iu47kvq _1i0neoah _1m5e1op4 _1jhdq7pw _1ltk1i5c _njwk11k7 _yhpqfnf5 _1fyf1a5r _vhgsxbuz _1rsueoah _bl8aglyw _156yru3m _10aiglyw _aeldru3m _l57nglyw _1sbqru3m _19awglyw _1i6zru3m",
20
+ slideUpAndFade: "_tzy4idpf _t9ec9o47 _k8m0rv36 _1oecluct _6fl41a34 _1s9z1a5r _1gbckb7n _1kdeglyw _1fsl1ttt _rornidpf _1hqtc4j2 _1ltk1j28 _njwkivc9 _yhpqluct _13ku1a34 _1fyf1a5r _d7fr1i5c _4v7i1ttt _1dar1j28 _156yru3m _aeldru3m _1sbqru3m _1i6zru3m",
21
+ fade: "_tzy4idpf _k8m01slm _1oecluct _6fl41a34 _1s9z1a5r _1gbckb7n _1fsl1ttt _rornidpf _1ltk1j28 _njwkivc9 _yhpqluct _13ku1a34 _1fyf1a5r _d7fr1i5c _4v7i1ttt _1dar1j28 _156yru3m _aeldru3m _1sbqru3m _1i6zru3m"
22
+ };
14
23
  var styles = {
15
24
  dialog: "_19itglyw _19pk1wug _2hwx1wug _otyr1wug _18u01wug _1q51ze3t _y4tize3t _85i5ze3t _bozgze3t _p12fglyw _c71lglyw _bfhk1j28 _1ltk1i5c"
16
25
  };
@@ -39,6 +48,7 @@ export var Dialog = /*#__PURE__*/forwardRef(function Dialog(_ref, ref) {
39
48
  onEnterFinish = _ref.onEnterFinish,
40
49
  onExitFinish = _ref.onExitFinish,
41
50
  animate = _ref.animate,
51
+ xcssFromProps = _ref.xcss,
42
52
  style = _ref.style,
43
53
  testId = _ref.testId,
44
54
  providedId = _ref.id,
@@ -102,6 +112,32 @@ export var Dialog = /*#__PURE__*/forwardRef(function Dialog(_ref, ref) {
102
112
  }
103
113
  }, [isOpen]);
104
114
 
115
+ // Apply preset-provided animation custom properties (e.g. the
116
+ // `--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.
120
+ useLayoutEffect(function () {
121
+ var dialog = ownRef.current;
122
+ if (!dialog || !(preset !== null && preset !== void 0 && preset.getProperties)) {
123
+ return;
124
+ }
125
+ var props = preset.getProperties({
126
+ placement: {}
127
+ });
128
+ Object.entries(props).forEach(function (_ref2) {
129
+ var _ref3 = _slicedToArray(_ref2, 2),
130
+ key = _ref3[0],
131
+ value = _ref3[1];
132
+ dialog.style.setProperty(key, String(value));
133
+ });
134
+ return function () {
135
+ Object.keys(props).forEach(function (key) {
136
+ dialog.style.removeProperty(key);
137
+ });
138
+ };
139
+ }, [preset, isVisible]);
140
+
105
141
  // Handle native Escape (cancel event)
106
142
  var handleCancel = useCallback(function (event) {
107
143
  // Only handle a cancel targeting THIS dialog. Native `cancel` does not
@@ -170,7 +206,8 @@ export var Dialog = /*#__PURE__*/forwardRef(function Dialog(_ref, ref) {
170
206
  onCancel: handleCancel,
171
207
  "data-testid": testId
172
208
  }, preset ? _defineProperty({}, "data-ds-dialog-".concat(preset.name), '') : undefined, {
173
- className: ax([styles.dialog])
209
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- xcss prop passes Compiled atomic class names from consumer-owned cssMap entries
210
+ 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])
174
211
  }), shouldHideBackdrop &&
175
212
  /*#__PURE__*/
176
213
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles
@@ -2,7 +2,6 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import { useEffect, useLayoutEffect, useRef, useState } from 'react';
3
3
  import { bind, bindAll } from 'bind-event-listener';
4
4
  import { prefersReducedMotion } from './reduced-motion';
5
- import { usePresetStyles } from './use-preset-styles';
6
5
  /**
7
6
  * Fires `onSettled` once when `transitionend` fires on `element`, or after
8
7
  * `safetyNetMs` if the event is swallowed (mid-transition unmount, CSS
@@ -105,9 +104,10 @@ export function useAnimatedVisibility(_ref2) {
105
104
  elementRef = _ref2.elementRef,
106
105
  onEnterFinish = _ref2.onEnterFinish,
107
106
  onExitFinish = _ref2.onExitFinish;
108
- var preset = usePresetStyles({
109
- preset: animate
110
- });
107
+ // Styles are applied via the `css` prop on the host element (see `Popover`
108
+ // and `Dialog`), so there is no longer any CSS injection step. Normalize a
109
+ // falsy `animate` to `null`.
110
+ var preset = animate || null;
111
111
 
112
112
  // False when there is no preset or `prefers-reduced-motion` is set.
113
113
  var willAnimate = Boolean(animate) && !prefersReducedMotion();
@@ -1,13 +1,33 @@
1
1
 
2
+ ._15ns179n:popover-open{animation:var(--ds-popover-motion-enter)}
2
3
  ._19itglyw{border:none}
3
- ._1r041wug{inset:auto}._18m9ewfl{overflow-y:visible}
4
+ ._1r041wug{inset:auto}
5
+ ._y44vof1f{animation:var(--ds-popover-motion-exit)}._12t71ttt:popover-open{transition-duration:.35s}
6
+ ._162xglyw:popover-open{transform:none}
7
+ ._18m9ewfl{overflow-y:visible}
4
8
  ._18u0idpf{margin-left:0}
5
9
  ._19bvidpf{padding-left:0}
6
10
  ._19pkidpf{margin-top:0}
11
+ ._1f6ykb7n:popover-open{opacity:1}
12
+ ._1o51q7pw{animation-fill-mode:forwards}
13
+ ._1oec6ebc{transition-duration:.15s}
14
+ ._1oecluct{transition-duration:175ms}
7
15
  ._1reoewfl{overflow-x:visible}
16
+ ._1s9z1a5r{transition-behavior:allow-discrete}
8
17
  ._2hwxidpf{margin-right:0}
18
+ ._6fl41a34{transition-timing-function:cubic-bezier(.15,1,.3,1)}
9
19
  ._bfhk1j28{background-color:transparent}
10
20
  ._ca0qidpf{padding-top:0}
21
+ ._k8m011k7{transition-property:overlay,display}
22
+ ._k8m01slm{transition-property:opacity,overlay,display}
23
+ ._k8m0rv36{transition-property:opacity,transform,overlay,display}
11
24
  ._n3tdidpf{padding-bottom:0}
25
+ ._n70peoah:popover-open{animation-fill-mode:backwards}
12
26
  ._otyridpf{margin-bottom:0}
13
- ._u5f3idpf{padding-right: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
+ ._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,7 +26,16 @@ var supportsPopoverHint = once(function () {
26
26
  return element.popover === 'hint';
27
27
  });
28
28
 
29
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- popover UA reset requires values not in cssMap's type union
29
+ // These animation styles use the non-strict Compiled cssMap because they rely
30
+ // on `@starting-style`, `:popover-open`, `[dir='rtl']`, and `allow-discrete`.
31
+ // Keep them in this component so the Compiled transform can statically extract
32
+ // every referenced style.
33
+ var popoverAnimationStyles = {
34
+ popupMotion: "_y44vof1f _1o51q7pw _k8m011k7 _1oec6ebc _1s9z1a5r _15ns179n _n70peoah _bl8aglyw _156yru3m _8rmvglyw _2qm2ru3m",
35
+ slideAndFade: "_tzy4idpf _t9ecxauz _k8m0rv36 _1oecluct _6fl41a34 _1s9z1a5r _1tz31oq6 _1f6ykb7n _162xglyw _12t71ttt _1wuhidpf _1423xauz _156yru3m _2qm2ru3m _1dml1oq6",
36
+ fade: "_tzy4idpf _k8m01slm _1oecluct _6fl41a34 _1s9z1a5r _1f6ykb7n _12t71ttt _1wuhidpf _156yru3m _2qm2ru3m",
37
+ scaleAndFade: "_tzy4idpf _t9ecgt2x _k8m0rv36 _1oecluct _6fl41a34 _1s9z1a5r _1f6ykb7n _162xglyw _12t71ttt _1wuhidpf _1423gt2x _156yru3m _2qm2ru3m"
38
+ };
30
39
  var styles = {
31
40
  root: "_19itglyw _ca0qidpf _u5f3idpf _n3tdidpf _19bvidpf _19pkidpf _2hwxidpf _otyridpf _18u0idpf _1r041wug _1reoewfl _18m9ewfl _bfhk1j28"
32
41
  };
@@ -254,7 +263,9 @@ export var Popover = /*#__PURE__*/forwardRef(function Popover(_ref, ref) {
254
263
  }, [handleToggle, handleBeforeToggle, isVisible]);
255
264
 
256
265
  // Placement-dependent animation CSS vars. Kept separate from show/hide
257
- // so preset reference changes do not re-trigger visibility.
266
+ // so preset reference changes do not re-trigger visibility. The cleanup
267
+ // removes the properties so a preset change does not leave stale custom
268
+ // properties on the element.
258
269
  useLayoutEffect(function () {
259
270
  var element = ownRef.current;
260
271
  if (!element || !(preset !== null && preset !== void 0 && preset.getProperties) || !placement) {
@@ -269,6 +280,11 @@ export var Popover = /*#__PURE__*/forwardRef(function Popover(_ref, ref) {
269
280
  value = _ref3[1];
270
281
  element.style.setProperty(key, String(value));
271
282
  });
283
+ return function () {
284
+ Object.keys(props).forEach(function (key) {
285
+ element.style.removeProperty(key);
286
+ });
287
+ };
272
288
  }, [preset, placement, isVisible]);
273
289
 
274
290
  // Show/hide based on isOpen. `showPopover`/`hidePopover` are no-ops when
@@ -320,6 +336,6 @@ export var Popover = /*#__PURE__*/forwardRef(function Popover(_ref, ref) {
320
336
  "data-testid": testId
321
337
  }, preset ? _defineProperty({}, "data-ds-popover-".concat(preset.name), '') : undefined, {
322
338
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- xcss prop passes compiled atomic class names
323
- className: ax([styles.root, xcssFromProps])
339
+ className: 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])
324
340
  }), children);
325
341
  });
@@ -1,4 +1,22 @@
1
1
  import { type TAnimationPreset } from './types';
2
+ export declare const animationDurations: {
3
+ readonly popupMotion: {
4
+ readonly enter: 150;
5
+ readonly exit: 100;
6
+ };
7
+ readonly popoverTransition: {
8
+ readonly enter: 350;
9
+ readonly exit: 175;
10
+ };
11
+ readonly dialogMotion: {
12
+ readonly enter: 250;
13
+ readonly exit: 200;
14
+ };
15
+ readonly dialogTransition: {
16
+ readonly enter: 350;
17
+ readonly exit: 175;
18
+ };
19
+ };
2
20
  export declare function popupMotion(): TAnimationPreset;
3
21
  type TSlideAndFadeOptions = {
4
22
  /**
@@ -1,28 +1,24 @@
1
1
  import type { TPlacementOptions } from '../internal/resolve-placement';
2
2
  /**
3
- * A self-contained animation preset for top-layer elements (popovers and dialogs).
3
+ * A self-contained animation preset for top-layer elements.
4
4
  *
5
- * Contains the CSS rules (injected once into `<head>`), a data-attribute name
6
- * for CSS targeting, optional per-placement custom properties, and the exit
7
- * duration used for a `transitionend` fallback timeout.
5
+ * Contains a data-attribute name used as a stable test and debugging hook,
6
+ * optional per-placement custom properties, and the entry and exit durations
7
+ * used for a `transitionend` fallback timeout.
8
8
  *
9
- * Entry animation uses `@starting-style`.
10
- * Exit animation uses `allow-discrete` on `display`/`overlay` to keep the
11
- * element visible in the top layer while CSS transitions play.
9
+ * The actual Compiled styles are kept static and component-local so the
10
+ * Compiled transform can extract them at build time.
12
11
  */
13
12
  export type TAnimationPreset = {
14
13
  /**
15
- * CSS to inject once into `document.head`, scoped via a data attribute
16
- * (e.g. `[data-ds-popover-{name}]` or `[data-ds-dialog-{name}]`).
17
- */
18
- css: string;
19
- /**
20
- * Data attribute suffix for CSS targeting (e.g. `'slide-and-fade'`).
14
+ * Data attribute suffix used as a stable test and debugging hook (e.g.
15
+ * `'slide-and-fade'` becomes `data-ds-popover-slide-and-fade`).
21
16
  */
22
17
  name: string;
23
18
  /**
24
19
  * Per-placement CSS custom properties (e.g. directional offset for
25
- * `slideAndFade`). Only used by popover presets that vary by placement.
20
+ * `slideAndFade`). Only used by presets that vary by placement or by a
21
+ * configurable distance.
26
22
  */
27
23
  getProperties?: (args: {
28
24
  placement: TPlacementOptions;
@@ -1,4 +1,5 @@
1
1
  import { type CSSProperties, type ReactNode } from 'react';
2
+ import { type CompiledStyles } from '@compiled/react';
2
3
  import { type TAnimationPreset } from '../animations/types';
3
4
  /**
4
5
  * Close reasons produced by the Dialog primitive.
@@ -49,10 +50,17 @@ type TDialogBaseProps = {
49
50
  /**
50
51
  * Animation preset for entry/exit transitions.
51
52
  *
52
- * Pass an `TAnimationPreset` (e.g. `dialogSlideUpAndFade()`) to enable
53
+ * Pass a `TAnimationPreset` (e.g. `dialogSlideUpAndFade()`) to enable
53
54
  * CSS-based entry and exit animation. Pass `false` (or omit) to disable.
54
55
  */
55
56
  animate?: TAnimationPreset | false;
57
+ /**
58
+ * Additional Compiled styles applied to the `<dialog>` element.
59
+ *
60
+ * Applied after built-in dialog and animation styles so consumers can own
61
+ * static styling that must live in their package.
62
+ */
63
+ xcss?: CompiledStyles<Record<string, unknown>> | false | null | undefined;
56
64
  /**
57
65
  * Additional inline styles applied to the `<dialog>` element.
58
66
  *
@@ -39,8 +39,8 @@ type TUseAnimatedVisibilityResult = {
39
39
  */
40
40
  phase: TPhase;
41
41
  /**
42
- * Resolved animation preset (with CSS injected), or `null` if
43
- * animation is disabled.
42
+ * Resolved animation preset (styles applied via the host element's `css`
43
+ * prop), or `null` if animation is disabled.
44
44
  */
45
45
  preset: TAnimationPreset | null;
46
46
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/top-layer",
3
- "version": "1.3.0",
3
+ "version": "1.5.0",
4
4
  "description": "Low-level layering primitives based on popover and dialog",
5
5
  "homepage": "https://atlassian.design/components/top-layer",
6
6
  "repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
@@ -10,9 +10,7 @@
10
10
  "module": "dist/esm/index.js",
11
11
  "module:es2019": "dist/es2019/index.js",
12
12
  "types": "dist/types/index.d.ts",
13
- "sideEffects": [
14
- "*.compiled.css"
15
- ],
13
+ "sideEffects": ["*.compiled.css"],
16
14
  "atlaskit:src": "src/index.tsx",
17
15
  "atlassian": {
18
16
  "react-compiler": {
@@ -28,9 +26,7 @@
28
26
  "category": "Libraries"
29
27
  },
30
28
  "integrationTests": {
31
- "additionalBrowsers": [
32
- "desktop-firefox"
33
- ]
29
+ "additionalBrowsers": ["desktop-firefox"]
34
30
  }
35
31
  },
36
32
  "dependencies": {
@@ -39,7 +35,7 @@
39
35
  "@atlaskit/ds-lib": "^8.0.0",
40
36
  "@atlaskit/layering": "^4.1.0",
41
37
  "@atlaskit/react-compiler-gating": "^0.2.0",
42
- "@atlaskit/tokens": "^15.4.0",
38
+ "@atlaskit/tokens": "^15.5.0",
43
39
  "@babel/runtime": "^7.0.0",
44
40
  "@compiled/react": "^0.20.0",
45
41
  "bind-event-listener": "^3.0.0",
@@ -53,13 +49,13 @@
53
49
  "@af/integration-testing": "workspace:^",
54
50
  "@af/visual-regression": "workspace:^",
55
51
  "@atlaskit/button": "^24.3.0",
56
- "@atlaskit/heading": "^6.1.0",
52
+ "@atlaskit/heading": "^6.2.0",
57
53
  "@atlaskit/lozenge": "^14.1.0",
58
- "@atlaskit/primitives": "^20.3.0",
54
+ "@atlaskit/primitives": "^20.5.0",
59
55
  "@atlaskit/ssr": "workspace:^",
60
56
  "@atlaskit/textfield": "^9.1.0",
61
57
  "@atlassian/ssr-tests": "workspace:^",
62
- "@atlassian/testing-library": "^0.7.0",
58
+ "@atlassian/testing-library": "^0.10.0",
63
59
  "@testing-library/jest-dom": "^6.4.5",
64
60
  "@testing-library/react": "^16.3.0",
65
61
  "@types/raf-schd": "^4.0.1",
@@ -69,29 +65,15 @@
69
65
  },
70
66
  "techstack": {
71
67
  "@atlassian/frontend": {
72
- "import-structure": [
73
- "atlassian-conventions"
74
- ],
75
- "circular-dependencies": [
76
- "file-and-folder-level"
77
- ]
68
+ "import-structure": ["atlassian-conventions"],
69
+ "circular-dependencies": ["file-and-folder-level"]
78
70
  },
79
71
  "@repo/internal": {
80
72
  "dom-events": "use-bind-event-listener",
81
- "ui-components": [
82
- "lite-mode"
83
- ],
84
- "design-tokens": [
85
- "color",
86
- "spacing"
87
- ],
88
- "deprecation": [
89
- "no-deprecated-imports"
90
- ],
91
- "styling": [
92
- "static",
93
- "compiled"
94
- ]
73
+ "ui-components": ["lite-mode"],
74
+ "design-tokens": ["color", "spacing"],
75
+ "deprecation": ["no-deprecated-imports"],
76
+ "styling": ["static", "compiled"]
95
77
  }
96
78
  },
97
79
  "publishConfig": {