@atlaskit/top-layer 1.2.0 → 1.4.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 (37) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/compass.yml +38 -0
  3. package/dist/cjs/animations/presets.js +46 -48
  4. package/dist/cjs/dialog/dialog-content.compiled.css +46 -2
  5. package/dist/cjs/dialog/dialog-content.js +49 -2
  6. package/dist/cjs/internal/use-animated-visibility.js +4 -4
  7. package/dist/cjs/popover/popover.compiled.css +22 -2
  8. package/dist/cjs/popover/popover.js +19 -3
  9. package/dist/es2019/animations/presets.js +42 -299
  10. package/dist/es2019/dialog/dialog-content.compiled.css +46 -2
  11. package/dist/es2019/dialog/dialog-content.js +45 -2
  12. package/dist/es2019/internal/use-animated-visibility.js +4 -4
  13. package/dist/es2019/popover/popover.compiled.css +22 -2
  14. package/dist/es2019/popover/popover.js +19 -3
  15. package/dist/esm/animations/presets.js +45 -48
  16. package/dist/esm/dialog/dialog-content.compiled.css +46 -2
  17. package/dist/esm/dialog/dialog-content.js +49 -2
  18. package/dist/esm/internal/use-animated-visibility.js +4 -4
  19. package/dist/esm/popover/popover.compiled.css +22 -2
  20. package/dist/esm/popover/popover.js +19 -3
  21. package/dist/types/animations/presets.d.ts +18 -0
  22. package/dist/types/animations/types.d.ts +10 -14
  23. package/dist/types/dialog/types.d.ts +18 -1
  24. package/dist/types/internal/use-animated-visibility.d.ts +2 -2
  25. package/package.json +13 -31
  26. package/dist/cjs/internal/ensure-preset-styles.js +0 -34
  27. package/dist/cjs/internal/use-animation-preset.js +0 -24
  28. package/dist/cjs/internal/use-preset-styles.js +0 -27
  29. package/dist/es2019/internal/ensure-preset-styles.js +0 -29
  30. package/dist/es2019/internal/use-animation-preset.js +0 -18
  31. package/dist/es2019/internal/use-preset-styles.js +0 -22
  32. package/dist/esm/internal/ensure-preset-styles.js +0 -28
  33. package/dist/esm/internal/use-animation-preset.js +0 -18
  34. package/dist/esm/internal/use-preset-styles.js +0 -21
  35. package/dist/types/internal/ensure-preset-styles.d.ts +0 -6
  36. package/dist/types/internal/use-animation-preset.d.ts +0 -11
  37. package/dist/types/internal/use-preset-styles.d.ts +0 -15
@@ -1,32 +1,25 @@
1
1
  import { getPlacement } from '../internal/resolve-placement';
2
- // ══════════════════════════════════════════════════════════════════════════════
3
- // Popover presets
4
- // ══════════════════════════════════════════════════════════════════════════════
5
-
6
- // ── popupMotion ──
7
-
8
- const POPUP_MOTION_CSS = `
9
- [data-ds-popover-popup-motion] {
10
- animation: var(--ds-popover-motion-exit);
11
- animation-fill-mode: forwards;
12
- transition:
13
- overlay 150ms allow-discrete,
14
- display 150ms allow-discrete;
15
- }
16
-
17
- [data-ds-popover-popup-motion]:popover-open {
18
- animation: var(--ds-popover-motion-enter);
19
- animation-fill-mode: backwards;
2
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
3
+ export const 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
20
19
  }
20
+ };
21
+ // popupMotion
21
22
 
22
- @media (prefers-reduced-motion: reduce) {
23
- [data-ds-popover-popup-motion],
24
- [data-ds-popover-popup-motion]:popover-open {
25
- animation: none;
26
- transition-duration: 0s;
27
- }
28
- }
29
- `;
30
23
  function getPopupMotionProperties({
31
24
  placement
32
25
  }) {
@@ -65,9 +58,8 @@ function getPopupMotionProperties({
65
58
  export function popupMotion() {
66
59
  return {
67
60
  name: 'popup-motion',
68
- css: POPUP_MOTION_CSS,
69
- enterDurationMs: 150,
70
- exitDurationMs: 100,
61
+ enterDurationMs: animationDurations.popupMotion.enter,
62
+ exitDurationMs: animationDurations.popupMotion.exit,
71
63
  getProperties: ({
72
64
  placement
73
65
  }) => getPopupMotionProperties({
@@ -76,7 +68,7 @@ export function popupMotion() {
76
68
  };
77
69
  }
78
70
 
79
- // ── slideAndFade ──
71
+ // slideAndFade
80
72
 
81
73
  function getSlideAndFadeProperties({
82
74
  placement,
@@ -120,49 +112,6 @@ function getSlideAndFadeProperties({
120
112
  };
121
113
  }
122
114
 
123
- // ℹ️ Note: The `transform` x value is flipped in right-to-left mode using the `[dir='rtl']` selector.
124
- const SLIDE_AND_FADE_CSS = `
125
- [data-ds-popover-slide-and-fade] {
126
- opacity: 0;
127
- transform: translate(var(--ds-popover-tx, 0), var(--ds-popover-ty, 0));
128
- transition:
129
- opacity 175ms cubic-bezier(0.15, 1, 0.3, 1),
130
- transform 175ms cubic-bezier(0.15, 1, 0.3, 1),
131
- overlay 175ms allow-discrete,
132
- display 175ms allow-discrete;
133
- }
134
-
135
- [dir='rtl'] [data-ds-popover-slide-and-fade] {
136
- transform: translate(calc(-1 * var(--ds-popover-tx, 0)), var(--ds-popover-ty, 0));
137
- }
138
-
139
- [data-ds-popover-slide-and-fade]:popover-open {
140
- opacity: 1;
141
- transform: none;
142
- transition-duration: 350ms;
143
- }
144
-
145
- @starting-style {
146
- [data-ds-popover-slide-and-fade]:popover-open {
147
- opacity: 0;
148
- transform: translate(var(--ds-popover-tx, 0), var(--ds-popover-ty, 0));
149
- }
150
- }
151
-
152
- @starting-style {
153
- [dir='rtl'] [data-ds-popover-slide-and-fade]:popover-open {
154
- transform: translate(calc(-1 * var(--ds-popover-tx, 0)), var(--ds-popover-ty, 0));
155
- }
156
- }
157
-
158
- @media (prefers-reduced-motion: reduce) {
159
- [data-ds-popover-slide-and-fade],
160
- [data-ds-popover-slide-and-fade]:popover-open {
161
- transition-duration: 0s;
162
- }
163
- }
164
- `;
165
-
166
115
  /**
167
116
  * Directional slide + opacity animation.
168
117
  *
@@ -188,48 +137,19 @@ export function slideAndFade(options) {
188
137
  const distance = (_options$distance = options === null || options === void 0 ? void 0 : options.distance) !== null && _options$distance !== void 0 ? _options$distance : 4;
189
138
  return {
190
139
  name: 'slide-and-fade',
191
- css: SLIDE_AND_FADE_CSS,
192
140
  getProperties: ({
193
141
  placement
194
142
  }) => getSlideAndFadeProperties({
195
143
  placement,
196
144
  distance
197
145
  }),
198
- enterDurationMs: 350,
199
- exitDurationMs: 175
146
+ enterDurationMs: animationDurations.popoverTransition.enter,
147
+ exitDurationMs: animationDurations.popoverTransition.exit
200
148
  };
201
149
  }
202
150
 
203
151
  // fade
204
152
 
205
- const FADE_CSS = `
206
- [data-ds-popover-fade] {
207
- opacity: 0;
208
- transition:
209
- opacity 175ms cubic-bezier(0.15, 1, 0.3, 1),
210
- overlay 175ms allow-discrete,
211
- display 175ms allow-discrete;
212
- }
213
-
214
- [data-ds-popover-fade]:popover-open {
215
- opacity: 1;
216
- transition-duration: 350ms;
217
- }
218
-
219
- @starting-style {
220
- [data-ds-popover-fade]:popover-open {
221
- opacity: 0;
222
- }
223
- }
224
-
225
- @media (prefers-reduced-motion: reduce) {
226
- [data-ds-popover-fade],
227
- [data-ds-popover-fade]:popover-open {
228
- transition-duration: 0s;
229
- }
230
- }
231
- `;
232
-
233
153
  /**
234
154
  * Simple opacity transition, no transform.
235
155
  *
@@ -246,46 +166,13 @@ const FADE_CSS = `
246
166
  export function fade() {
247
167
  return {
248
168
  name: 'fade',
249
- css: FADE_CSS,
250
- enterDurationMs: 350,
251
- exitDurationMs: 175
169
+ enterDurationMs: animationDurations.popoverTransition.enter,
170
+ exitDurationMs: animationDurations.popoverTransition.exit
252
171
  };
253
172
  }
254
173
 
255
174
  // scaleAndFade
256
175
 
257
- const SCALE_AND_FADE_CSS = `
258
- [data-ds-popover-scale-and-fade] {
259
- opacity: 0;
260
- transform: scale(0.95);
261
- transition:
262
- opacity 175ms cubic-bezier(0.15, 1, 0.3, 1),
263
- transform 175ms cubic-bezier(0.15, 1, 0.3, 1),
264
- overlay 175ms allow-discrete,
265
- display 175ms allow-discrete;
266
- }
267
-
268
- [data-ds-popover-scale-and-fade]:popover-open {
269
- opacity: 1;
270
- transform: none;
271
- transition-duration: 350ms;
272
- }
273
-
274
- @starting-style {
275
- [data-ds-popover-scale-and-fade]:popover-open {
276
- opacity: 0;
277
- transform: scale(0.95);
278
- }
279
- }
280
-
281
- @media (prefers-reduced-motion: reduce) {
282
- [data-ds-popover-scale-and-fade],
283
- [data-ds-popover-scale-and-fade]:popover-open {
284
- transition-duration: 0s;
285
- }
286
- }
287
- `;
288
-
289
176
  /**
290
177
  * Scale from 0.95 + opacity transition.
291
178
  *
@@ -302,56 +189,12 @@ const SCALE_AND_FADE_CSS = `
302
189
  export function scaleAndFade() {
303
190
  return {
304
191
  name: 'scale-and-fade',
305
- css: SCALE_AND_FADE_CSS,
306
- enterDurationMs: 350,
307
- exitDurationMs: 175
192
+ enterDurationMs: animationDurations.popoverTransition.enter,
193
+ exitDurationMs: animationDurations.popoverTransition.exit
308
194
  };
309
195
  }
310
196
 
311
- // ══════════════════════════════════════════════════════════════════════════════
312
- // Dialog presets
313
- // ══════════════════════════════════════════════════════════════════════════════
314
-
315
- // ── dialogMotion ──
316
-
317
- const DIALOG_MOTION_CSS = `
318
- [data-ds-dialog-motion] {
319
- animation: ${"var(--ds-modal-exit, 200ms cubic-bezier(0.6, 0, 0.8, 0.6) ScaleOut100to95)"};
320
- animation-fill-mode: forwards;
321
- transition:
322
- overlay 200ms allow-discrete,
323
- display 200ms allow-discrete;
324
- }
325
-
326
- [data-ds-dialog-motion][open] {
327
- animation: ${"var(--ds-modal-enter, 250ms cubic-bezier(0.4, 0, 0, 1) ScaleIn95to100)"};
328
- animation-fill-mode: backwards;
329
- }
330
-
331
- [data-ds-dialog-motion]::backdrop {
332
- animation: ${"var(--ds-blanket-exit, 200ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"};
333
- animation-fill-mode: forwards;
334
- background-color: var(--ds-blanket, #050C1F75);
335
- transition:
336
- overlay 200ms allow-discrete,
337
- display 200ms allow-discrete;
338
- }
339
-
340
- [data-ds-dialog-motion][open]::backdrop {
341
- animation: ${"var(--ds-blanket-enter, 250ms cubic-bezier(0.4, 0, 0, 1) FadeIn0to100)"};
342
- animation-fill-mode: backwards;
343
- }
344
-
345
- @media (prefers-reduced-motion: reduce) {
346
- [data-ds-dialog-motion],
347
- [data-ds-dialog-motion][open],
348
- [data-ds-dialog-motion]::backdrop,
349
- [data-ds-dialog-motion][open]::backdrop {
350
- animation: none;
351
- transition-duration: 0s;
352
- }
353
- }
354
- `;
197
+ // dialogMotion
355
198
 
356
199
  /**
357
200
  * Dialog motion animation.
@@ -372,66 +215,12 @@ export function dialogMotion() {
372
215
  // Bare preset name; `Dialog` prefixes it via `data-ds-dialog-{name}`.
373
216
  return {
374
217
  name: 'motion',
375
- css: DIALOG_MOTION_CSS,
376
- enterDurationMs: 250,
377
- exitDurationMs: 200
218
+ enterDurationMs: animationDurations.dialogMotion.enter,
219
+ exitDurationMs: animationDurations.dialogMotion.exit
378
220
  };
379
221
  }
380
222
 
381
- // ── dialogSlideUpAndFade ──
382
-
383
- const DIALOG_SLIDE_UP_AND_FADE_CSS = `
384
- [data-ds-dialog-slide-up-and-fade] {
385
- opacity: 0;
386
- transform: translateY(calc(-1 * var(--ds-dialog-ty, 12px)));
387
- transition:
388
- opacity 175ms cubic-bezier(0.15, 1, 0.3, 1),
389
- transform 175ms cubic-bezier(0.15, 1, 0.3, 1),
390
- overlay 175ms allow-discrete,
391
- display 175ms allow-discrete;
392
- }
393
-
394
- [data-ds-dialog-slide-up-and-fade][open] {
395
- opacity: 1;
396
- transform: none;
397
- transition-duration: 350ms;
398
- }
399
-
400
- @starting-style {
401
- [data-ds-dialog-slide-up-and-fade][open] {
402
- opacity: 0;
403
- transform: translateY(var(--ds-dialog-ty, 12px));
404
- }
405
- }
406
-
407
- [data-ds-dialog-slide-up-and-fade]::backdrop {
408
- background-color: transparent;
409
- transition:
410
- background-color 175ms cubic-bezier(0.15, 1, 0.3, 1),
411
- overlay 175ms allow-discrete,
412
- display 175ms allow-discrete;
413
- }
414
-
415
- [data-ds-dialog-slide-up-and-fade][open]::backdrop {
416
- background-color: var(--ds-blanket, #050C1F75);
417
- transition-duration: 350ms;
418
- }
419
-
420
- @starting-style {
421
- [data-ds-dialog-slide-up-and-fade][open]::backdrop {
422
- background-color: transparent;
423
- }
424
- }
425
-
426
- @media (prefers-reduced-motion: reduce) {
427
- [data-ds-dialog-slide-up-and-fade],
428
- [data-ds-dialog-slide-up-and-fade][open],
429
- [data-ds-dialog-slide-up-and-fade]::backdrop,
430
- [data-ds-dialog-slide-up-and-fade][open]::backdrop {
431
- transition-duration: 0s;
432
- }
433
- }
434
- `;
223
+ // dialogSlideUpAndFade
435
224
 
436
225
  /**
437
226
  * Slide up + opacity animation for dialogs.
@@ -457,65 +246,20 @@ export function dialogSlideUpAndFade(options) {
457
246
  const distance = (_options$distance2 = options === null || options === void 0 ? void 0 : options.distance) !== null && _options$distance2 !== void 0 ? _options$distance2 : 12;
458
247
 
459
248
  // Bare preset name; `Dialog` prefixes it via `data-ds-dialog-{name}`.
249
+ // The distance is applied via the `--ds-dialog-ty` custom property rather
250
+ // than baked into the styles, so the name stays stable across distances.
460
251
  return {
461
- name: distance === 12 ? 'slide-up-and-fade' : `slide-up-and-fade-${distance}`,
462
- css: distance === 12 ? DIALOG_SLIDE_UP_AND_FADE_CSS : DIALOG_SLIDE_UP_AND_FADE_CSS.replace(/12px/g, `${distance}px`),
463
- enterDurationMs: 350,
464
- exitDurationMs: 175
252
+ name: 'slide-up-and-fade',
253
+ getProperties: () => ({
254
+ '--ds-dialog-ty': `${distance}px`
255
+ }),
256
+ enterDurationMs: animationDurations.dialogTransition.enter,
257
+ exitDurationMs: animationDurations.dialogTransition.exit
465
258
  };
466
259
  }
467
260
 
468
261
  // dialogFade
469
262
 
470
- const DIALOG_FADE_CSS = `
471
- [data-ds-dialog-fade] {
472
- opacity: 0;
473
- transition:
474
- opacity 175ms cubic-bezier(0.15, 1, 0.3, 1),
475
- overlay 175ms allow-discrete,
476
- display 175ms allow-discrete;
477
- }
478
-
479
- [data-ds-dialog-fade][open] {
480
- opacity: 1;
481
- transition-duration: 350ms;
482
- }
483
-
484
- @starting-style {
485
- [data-ds-dialog-fade][open] {
486
- opacity: 0;
487
- }
488
- }
489
-
490
- [data-ds-dialog-fade]::backdrop {
491
- background-color: transparent;
492
- transition:
493
- background-color 175ms cubic-bezier(0.15, 1, 0.3, 1),
494
- overlay 175ms allow-discrete,
495
- display 175ms allow-discrete;
496
- }
497
-
498
- [data-ds-dialog-fade][open]::backdrop {
499
- background-color: var(--ds-blanket, #050C1F75);
500
- transition-duration: 350ms;
501
- }
502
-
503
- @starting-style {
504
- [data-ds-dialog-fade][open]::backdrop {
505
- background-color: transparent;
506
- }
507
- }
508
-
509
- @media (prefers-reduced-motion: reduce) {
510
- [data-ds-dialog-fade],
511
- [data-ds-dialog-fade][open],
512
- [data-ds-dialog-fade]::backdrop,
513
- [data-ds-dialog-fade][open]::backdrop {
514
- transition-duration: 0s;
515
- }
516
- }
517
- `;
518
-
519
263
  /**
520
264
  * Simple opacity transition for dialogs, no transform.
521
265
  *
@@ -535,8 +279,7 @@ export function dialogFade() {
535
279
  // Bare preset name; `Dialog` prefixes it via `data-ds-dialog-{name}`.
536
280
  return {
537
281
  name: 'fade',
538
- css: DIALOG_FADE_CSS,
539
- enterDurationMs: 350,
540
- exitDurationMs: 175
282
+ enterDurationMs: animationDurations.dialogTransition.enter,
283
+ exitDurationMs: animationDurations.dialogTransition.exit
541
284
  };
542
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))}}
@@ -9,7 +9,15 @@ import noop from '@atlaskit/ds-lib/noop';
9
9
  import { useNotifyOpenLayerObserver } from '@atlaskit/layering/experimental/open-layer-observer';
10
10
  import { useAnimatedVisibility } from '../internal/use-animated-visibility';
11
11
  import { useFocusWrap } from '../internal/use-focus-wrap';
12
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- dialog reset requires values not in cssMap's type union
12
+ // These animation styles use the non-strict Compiled cssMap because they rely
13
+ // on `@starting-style`, `[open]`, and `allow-discrete`. Keep them in this
14
+ // component so the Compiled transform can statically extract every referenced
15
+ // style.
16
+ const dialogAnimationStyles = {
17
+ motion: "_y44vgeqi _1o51q7pw _k8m011k7 _1oecfnf5 _1s9z1a5r _1iu47kvq _1i0neoah _1m5e1op4 _1jhdq7pw _1ltk1i5c _njwk11k7 _yhpqfnf5 _1fyf1a5r _vhgsxbuz _1rsueoah _bl8aglyw _156yru3m _10aiglyw _aeldru3m _l57nglyw _1sbqru3m _19awglyw _1i6zru3m",
18
+ slideUpAndFade: "_tzy4idpf _t9ec9o47 _k8m0rv36 _1oecluct _6fl41a34 _1s9z1a5r _1gbckb7n _1kdeglyw _1fsl1ttt _rornidpf _1hqtc4j2 _1ltk1j28 _njwkivc9 _yhpqluct _13ku1a34 _1fyf1a5r _d7fr1i5c _4v7i1ttt _1dar1j28 _156yru3m _aeldru3m _1sbqru3m _1i6zru3m",
19
+ fade: "_tzy4idpf _k8m01slm _1oecluct _6fl41a34 _1s9z1a5r _1gbckb7n _1fsl1ttt _rornidpf _1ltk1j28 _njwkivc9 _yhpqluct _13ku1a34 _1fyf1a5r _d7fr1i5c _4v7i1ttt _1dar1j28 _156yru3m _aeldru3m _1sbqru3m _1i6zru3m"
20
+ };
13
21
  const styles = {
14
22
  dialog: "_19itglyw _19pk1wug _2hwx1wug _otyr1wug _18u01wug _1q51ze3t _y4tize3t _85i5ze3t _bozgze3t _p12fglyw _c71lglyw _bfhk1j28 _1ltk1i5c"
15
23
  };
@@ -35,8 +43,10 @@ export const Dialog = /*#__PURE__*/forwardRef(function Dialog({
35
43
  children,
36
44
  isOpen,
37
45
  onClose,
46
+ onEnterFinish,
38
47
  onExitFinish,
39
48
  animate,
49
+ xcss: xcssFromProps,
40
50
  style,
41
51
  testId,
42
52
  id: providedId,
@@ -55,6 +65,7 @@ export const Dialog = /*#__PURE__*/forwardRef(function Dialog({
55
65
  isOpen,
56
66
  animate,
57
67
  elementRef: ownRef,
68
+ onEnterFinish,
58
69
  onExitFinish
59
70
  });
60
71
 
@@ -101,8 +112,39 @@ export const Dialog = /*#__PURE__*/forwardRef(function Dialog({
101
112
  }
102
113
  }, [isOpen]);
103
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(() => {
121
+ const dialog = ownRef.current;
122
+ if (!dialog || !(preset !== null && preset !== void 0 && preset.getProperties)) {
123
+ return;
124
+ }
125
+ const props = preset.getProperties({
126
+ placement: {}
127
+ });
128
+ Object.entries(props).forEach(([key, value]) => {
129
+ dialog.style.setProperty(key, String(value));
130
+ });
131
+ return () => {
132
+ Object.keys(props).forEach(key => {
133
+ dialog.style.removeProperty(key);
134
+ });
135
+ };
136
+ }, [preset, isVisible]);
137
+
104
138
  // Handle native Escape (cancel event)
105
139
  const handleCancel = useCallback(event => {
140
+ // Only handle a cancel targeting THIS dialog. Native `cancel` does not
141
+ // bubble, but React's synthetic event bubbles up the component tree, so
142
+ // for nested dialogs (one rendered inside another's DOM subtree) the
143
+ // inner dialog's Escape would otherwise also fire an ancestor dialog's
144
+ // handler and close it too. Mirrors the backdrop-click target guard below.
145
+ if (event.target !== event.currentTarget) {
146
+ return;
147
+ }
106
148
  event.preventDefault();
107
149
  onClose({
108
150
  reason: 'escape'
@@ -163,7 +205,8 @@ export const Dialog = /*#__PURE__*/forwardRef(function Dialog({
163
205
  }, preset ? {
164
206
  [`data-ds-dialog-${preset.name}`]: ''
165
207
  } : undefined, {
166
- className: ax([styles.dialog])
208
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- xcss prop passes Compiled atomic class names from consumer-owned cssMap entries
209
+ className: ax([styles.dialog, (preset === null || preset === void 0 ? void 0 : preset.name) === 'motion' && dialogAnimationStyles.motion, (preset === null || preset === void 0 ? void 0 : preset.name) === 'slide-up-and-fade' && dialogAnimationStyles.slideUpAndFade, (preset === null || preset === void 0 ? void 0 : preset.name) === 'fade' && dialogAnimationStyles.fade, xcssFromProps])
167
210
  }), shouldHideBackdrop &&
168
211
  /*#__PURE__*/
169
212
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles
@@ -1,7 +1,6 @@
1
1
  import { useEffect, useLayoutEffect, useRef, useState } from 'react';
2
2
  import { bind, bindAll } from 'bind-event-listener';
3
3
  import { prefersReducedMotion } from './reduced-motion';
4
- import { usePresetStyles } from './use-preset-styles';
5
4
  /**
6
5
  * Fires `onSettled` once when `transitionend` fires on `element`, or after
7
6
  * `safetyNetMs` if the event is swallowed (mid-transition unmount, CSS
@@ -106,9 +105,10 @@ export function useAnimatedVisibility({
106
105
  onEnterFinish,
107
106
  onExitFinish
108
107
  }) {
109
- const preset = usePresetStyles({
110
- preset: animate
111
- });
108
+ // Styles are applied via the `css` prop on the host element (see `Popover`
109
+ // and `Dialog`), so there is no longer any CSS injection step. Normalize a
110
+ // falsy `animate` to `null`.
111
+ const preset = animate || null;
112
112
 
113
113
  // False when there is no preset or `prefers-reduced-motion` is set.
114
114
  const 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))}}
@@ -24,7 +24,16 @@ const supportsPopoverHint = once(() => {
24
24
  return element.popover === 'hint';
25
25
  });
26
26
 
27
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- popover UA reset requires values not in cssMap's type union
27
+ // These animation styles use the non-strict Compiled cssMap because they rely
28
+ // on `@starting-style`, `:popover-open`, `[dir='rtl']`, and `allow-discrete`.
29
+ // Keep them in this component so the Compiled transform can statically extract
30
+ // every referenced style.
31
+ const popoverAnimationStyles = {
32
+ popupMotion: "_y44vof1f _1o51q7pw _k8m011k7 _1oec6ebc _1s9z1a5r _15ns179n _n70peoah _bl8aglyw _156yru3m _8rmvglyw _2qm2ru3m",
33
+ slideAndFade: "_tzy4idpf _t9ecxauz _k8m0rv36 _1oecluct _6fl41a34 _1s9z1a5r _1tz31oq6 _1f6ykb7n _162xglyw _12t71ttt _1wuhidpf _1423xauz _156yru3m _2qm2ru3m _1dml1oq6",
34
+ fade: "_tzy4idpf _k8m01slm _1oecluct _6fl41a34 _1s9z1a5r _1f6ykb7n _12t71ttt _1wuhidpf _156yru3m _2qm2ru3m",
35
+ scaleAndFade: "_tzy4idpf _t9ecgt2x _k8m0rv36 _1oecluct _6fl41a34 _1s9z1a5r _1f6ykb7n _162xglyw _12t71ttt _1wuhidpf _1423gt2x _156yru3m _2qm2ru3m"
36
+ };
28
37
  const styles = {
29
38
  root: "_19itglyw _ca0qidpf _u5f3idpf _n3tdidpf _19bvidpf _19pkidpf _2hwxidpf _otyridpf _18u0idpf _1r041wug _1reoewfl _18m9ewfl _bfhk1j28"
30
39
  };
@@ -254,7 +263,9 @@ export const Popover = /*#__PURE__*/forwardRef(function Popover({
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(() => {
259
270
  const element = ownRef.current;
260
271
  if (!element || !(preset !== null && preset !== void 0 && preset.getProperties) || !placement) {
@@ -266,6 +277,11 @@ export const Popover = /*#__PURE__*/forwardRef(function Popover({
266
277
  Object.entries(props).forEach(([key, value]) => {
267
278
  element.style.setProperty(key, String(value));
268
279
  });
280
+ return () => {
281
+ Object.keys(props).forEach(key => {
282
+ element.style.removeProperty(key);
283
+ });
284
+ };
269
285
  }, [preset, placement, isVisible]);
270
286
 
271
287
  // Show/hide based on isOpen. `showPopover`/`hidePopover` are no-ops when
@@ -319,6 +335,6 @@ export const Popover = /*#__PURE__*/forwardRef(function Popover({
319
335
  [`data-ds-popover-${preset.name}`]: ''
320
336
  } : undefined, {
321
337
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- xcss prop passes compiled atomic class names
322
- className: ax([styles.root, xcssFromProps])
338
+ 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])
323
339
  }), children);
324
340
  });