@atlaskit/top-layer 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/cjs/dialog/animations.js +90 -0
- package/dist/cjs/dialog/dialog-content.compiled.css +17 -25
- package/dist/cjs/dialog/dialog-content.js +29 -41
- package/dist/cjs/entry-points/animations.js +9 -8
- package/dist/cjs/internal/use-animated-visibility.js +40 -8
- package/dist/cjs/popover/animations.js +196 -0
- package/dist/cjs/popover/popover.compiled.css +17 -14
- package/dist/cjs/popover/popover.js +21 -30
- package/dist/es2019/dialog/animations.js +80 -0
- package/dist/es2019/dialog/dialog-content.compiled.css +17 -25
- package/dist/es2019/dialog/dialog-content.js +29 -38
- package/dist/es2019/entry-points/animations.js +2 -1
- package/dist/es2019/internal/use-animated-visibility.js +41 -8
- package/dist/es2019/popover/animations.js +190 -0
- package/dist/es2019/popover/popover.compiled.css +17 -14
- package/dist/es2019/popover/popover.js +21 -27
- package/dist/esm/dialog/animations.js +82 -0
- package/dist/esm/dialog/dialog-content.compiled.css +17 -25
- package/dist/esm/dialog/dialog-content.js +29 -41
- package/dist/esm/entry-points/animations.js +2 -1
- package/dist/esm/internal/use-animated-visibility.js +41 -8
- package/dist/esm/popover/animations.js +187 -0
- package/dist/esm/popover/popover.compiled.css +17 -14
- package/dist/esm/popover/popover.js +21 -30
- package/dist/types/dialog/animations.d.ts +57 -0
- package/dist/types/dialog/types.d.ts +2 -2
- package/dist/types/entry-points/animations.d.ts +2 -2
- package/dist/types/internal/use-animated-visibility.d.ts +35 -6
- package/dist/types/popover/animations.d.ts +52 -0
- package/dist/types/popover/types.d.ts +3 -3
- package/package.json +27 -9
- package/dist/cjs/animations/presets.js +0 -298
- package/dist/cjs/animations/types.js +0 -5
- package/dist/es2019/animations/presets.js +0 -285
- package/dist/es2019/animations/types.js +0 -1
- package/dist/esm/animations/presets.js +0 -285
- package/dist/esm/animations/types.js +0 -1
- package/dist/types/animations/presets.d.ts +0 -128
- package/dist/types/animations/types.d.ts +0 -34
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { getPlacement } from '../internal/resolve-placement';
|
|
2
|
+
function getPopupMotionStyles({
|
|
3
|
+
placement
|
|
4
|
+
}) {
|
|
5
|
+
const {
|
|
6
|
+
axis,
|
|
7
|
+
edge
|
|
8
|
+
} = getPlacement({
|
|
9
|
+
placement
|
|
10
|
+
});
|
|
11
|
+
if (axis === 'block' && edge === 'start') {
|
|
12
|
+
return [{
|
|
13
|
+
property: '--ds-popover-motion-enter',
|
|
14
|
+
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)"
|
|
15
|
+
}, {
|
|
16
|
+
property: '--ds-popover-motion-exit',
|
|
17
|
+
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)"
|
|
18
|
+
}];
|
|
19
|
+
}
|
|
20
|
+
if (axis === 'inline' && edge === 'start') {
|
|
21
|
+
return [{
|
|
22
|
+
property: '--ds-popover-motion-enter',
|
|
23
|
+
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)"
|
|
24
|
+
}, {
|
|
25
|
+
property: '--ds-popover-motion-exit',
|
|
26
|
+
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)"
|
|
27
|
+
}];
|
|
28
|
+
}
|
|
29
|
+
if (axis === 'inline' && edge === 'end') {
|
|
30
|
+
return [{
|
|
31
|
+
property: '--ds-popover-motion-enter',
|
|
32
|
+
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)"
|
|
33
|
+
}, {
|
|
34
|
+
property: '--ds-popover-motion-exit',
|
|
35
|
+
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)"
|
|
36
|
+
}];
|
|
37
|
+
}
|
|
38
|
+
// Default: block/end (popover below trigger)
|
|
39
|
+
return [{
|
|
40
|
+
property: '--ds-popover-motion-enter',
|
|
41
|
+
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)"
|
|
42
|
+
}, {
|
|
43
|
+
property: '--ds-popover-motion-exit',
|
|
44
|
+
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)"
|
|
45
|
+
}];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
49
|
+
export function popupMotion() {
|
|
50
|
+
return {
|
|
51
|
+
kind: 'popover',
|
|
52
|
+
name: 'motion',
|
|
53
|
+
getStyles: getPopupMotionStyles
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function getSlideAndFadeStyles({
|
|
57
|
+
placement,
|
|
58
|
+
distance
|
|
59
|
+
}) {
|
|
60
|
+
const pos = `${distance}px`;
|
|
61
|
+
const neg = `-${distance}px`;
|
|
62
|
+
const {
|
|
63
|
+
axis,
|
|
64
|
+
edge
|
|
65
|
+
} = getPlacement({
|
|
66
|
+
placement
|
|
67
|
+
});
|
|
68
|
+
if (axis === 'block' && edge === 'start') {
|
|
69
|
+
return [{
|
|
70
|
+
property: '--ds-popover-tx',
|
|
71
|
+
value: '0'
|
|
72
|
+
}, {
|
|
73
|
+
property: '--ds-popover-ty',
|
|
74
|
+
value: pos
|
|
75
|
+
}];
|
|
76
|
+
}
|
|
77
|
+
if (axis === 'block' && edge === 'end') {
|
|
78
|
+
return [{
|
|
79
|
+
property: '--ds-popover-tx',
|
|
80
|
+
value: '0'
|
|
81
|
+
}, {
|
|
82
|
+
property: '--ds-popover-ty',
|
|
83
|
+
value: neg
|
|
84
|
+
}];
|
|
85
|
+
}
|
|
86
|
+
if (axis === 'inline' && edge === 'start') {
|
|
87
|
+
return [{
|
|
88
|
+
property: '--ds-popover-tx',
|
|
89
|
+
value: pos
|
|
90
|
+
}, {
|
|
91
|
+
property: '--ds-popover-ty',
|
|
92
|
+
value: '0'
|
|
93
|
+
}];
|
|
94
|
+
}
|
|
95
|
+
if (axis === 'inline' && edge === 'end') {
|
|
96
|
+
return [{
|
|
97
|
+
property: '--ds-popover-tx',
|
|
98
|
+
value: neg
|
|
99
|
+
}, {
|
|
100
|
+
property: '--ds-popover-ty',
|
|
101
|
+
value: '0'
|
|
102
|
+
}];
|
|
103
|
+
}
|
|
104
|
+
return [{
|
|
105
|
+
property: '--ds-popover-tx',
|
|
106
|
+
value: '0'
|
|
107
|
+
}, {
|
|
108
|
+
property: '--ds-popover-ty',
|
|
109
|
+
value: neg
|
|
110
|
+
}];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Directional slide + opacity animation.
|
|
115
|
+
*
|
|
116
|
+
* The popover slides in from the direction opposite its placement edge
|
|
117
|
+
* (e.g. a `block-end` popover slides down from above).
|
|
118
|
+
*
|
|
119
|
+
* @param options.distance - Slide distance in pixels. Defaults to `4`.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```tsx
|
|
123
|
+
* import { slideAndFade } from '@atlaskit/top-layer/animations';
|
|
124
|
+
*
|
|
125
|
+
* // Default 4px slide (tooltip)
|
|
126
|
+
* <Popover animate={slideAndFade()} />
|
|
127
|
+
*
|
|
128
|
+
* // Custom 8px slide (popup / dropdown)
|
|
129
|
+
* <Popover animate={slideAndFade({ distance: 8 })} />
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
133
|
+
export function slideAndFade(options) {
|
|
134
|
+
var _options$distance;
|
|
135
|
+
const distance = (_options$distance = options === null || options === void 0 ? void 0 : options.distance) !== null && _options$distance !== void 0 ? _options$distance : 4;
|
|
136
|
+
return {
|
|
137
|
+
kind: 'popover',
|
|
138
|
+
name: 'slide-and-fade',
|
|
139
|
+
getStyles: ({
|
|
140
|
+
placement
|
|
141
|
+
}) => getSlideAndFadeStyles({
|
|
142
|
+
placement,
|
|
143
|
+
distance
|
|
144
|
+
})
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// fade
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Simple opacity transition, no transform.
|
|
152
|
+
*
|
|
153
|
+
* Suitable for popup dialogs or content that does not need directional motion.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```tsx
|
|
157
|
+
* import { fade } from '@atlaskit/top-layer/animations';
|
|
158
|
+
*
|
|
159
|
+
* <Popover animate={fade()} />
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
163
|
+
export function fade() {
|
|
164
|
+
return {
|
|
165
|
+
kind: 'popover',
|
|
166
|
+
name: 'fade'
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// scaleAndFade
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Scale from 0.95 + opacity transition.
|
|
174
|
+
*
|
|
175
|
+
* Suitable for menus, dropdowns, and select options.
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```tsx
|
|
179
|
+
* import { scaleAndFade } from '@atlaskit/top-layer/animations';
|
|
180
|
+
*
|
|
181
|
+
* <Popover animate={scaleAndFade()} />
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
185
|
+
export function scaleAndFade() {
|
|
186
|
+
return {
|
|
187
|
+
kind: 'popover',
|
|
188
|
+
name: 'scale-and-fade'
|
|
189
|
+
};
|
|
190
|
+
}
|
|
@@ -2,32 +2,35 @@
|
|
|
2
2
|
._15ns179n:popover-open{animation:var(--ds-popover-motion-enter)}
|
|
3
3
|
._19itglyw{border:none}
|
|
4
4
|
._1r041wug{inset:auto}
|
|
5
|
-
._y44vof1f{animation:var(--ds-popover-motion-exit)}.
|
|
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
|
-
.
|
|
10
|
+
._1a5xt94y{--dir:1px}
|
|
12
11
|
._1o51q7pw{animation-fill-mode:forwards}
|
|
13
|
-
.
|
|
14
|
-
.
|
|
12
|
+
._1oecdn4k{transition-duration:var(--ds-duration-xshort,.1s)}
|
|
13
|
+
._1pgl1lbj{animation-timing-function:var(--ds-easing-in-practical,cubic-bezier(.6,0,.8,.6))}
|
|
14
|
+
._1psg1ign:popover-open{animation-duration:var(--ds-duration-short,.15s)}
|
|
15
15
|
._1reoewfl{overflow-x:visible}
|
|
16
16
|
._1s9z1a5r{transition-behavior:allow-discrete}
|
|
17
17
|
._2hwxidpf{margin-right:0}
|
|
18
|
-
.
|
|
18
|
+
._5sagdn4k{animation-duration:var(--ds-duration-xshort,.1s)}
|
|
19
|
+
._71re1bym:popover-open{animation-name:var(--ds-keyframe-fade-in,FadeIn0to100)}
|
|
20
|
+
._71re1v6b:popover-open{animation-name:var(--ds-keyframe-fade-in,FadeIn0to100),var(--ds-keyframe-scale-in-small,ScaleIn95to100)}
|
|
21
|
+
._71rervlo:popover-open{animation-name:k1ut9kob,var(--ds-keyframe-fade-in,FadeIn0to100)}
|
|
19
22
|
._bfhk1j28{background-color:transparent}
|
|
20
23
|
._ca0qidpf{padding-top:0}
|
|
24
|
+
._j7hq1a5s{animation-name:var(--ds-keyframe-fade-out,FadeOut100to0)}
|
|
25
|
+
._j7hq1l2h{animation-name:k1e4c1ew,var(--ds-keyframe-fade-out,FadeOut100to0)}
|
|
26
|
+
._j7hqneez{animation-name:var(--ds-keyframe-fade-out,FadeOut100to0),var(--ds-keyframe-scale-out-small,ScaleOut100to95)}
|
|
21
27
|
._k8m011k7{transition-property:overlay,display}
|
|
22
|
-
._k8m01slm{transition-property:opacity,overlay,display}
|
|
23
|
-
._k8m0rv36{transition-property:opacity,transform,overlay,display}
|
|
24
28
|
._n3tdidpf{padding-bottom:0}
|
|
25
29
|
._n70peoah:popover-open{animation-fill-mode:backwards}
|
|
30
|
+
._o8i7indk:popover-open{animation-timing-function:var(--ds-easing-out-practical,cubic-bezier(.4,1,.6,1))}
|
|
26
31
|
._otyridpf{margin-bottom:0}
|
|
27
|
-
._t9ecgt2x{transform:scale(.95)}
|
|
28
|
-
._t9ecxauz{transform:translate(var(--ds-popover-tx,0),var(--ds-popover-ty,0))}
|
|
29
|
-
._tzy4idpf{opacity:0}
|
|
30
32
|
._u5f3idpf{padding-right:0}
|
|
31
|
-
[dir=rtl] .
|
|
32
|
-
@
|
|
33
|
-
@
|
|
33
|
+
[dir=rtl] ._34bx1n1a{--dir:-1px}
|
|
34
|
+
@keyframes k1e4c1ew{0%{transform:none}to{transform:translate(calc(var(--dir)*var(--ds-popover-tx, 0)),var(--ds-popover-ty,0))}}
|
|
35
|
+
@keyframes k1ut9kob{0%{transform:translate(calc(var(--dir)*var(--ds-popover-tx, 0)),var(--ds-popover-ty,0))}to{transform:none}}
|
|
36
|
+
@media (prefers-reduced-motion:reduce){._bl8aglyw{animation-name:none}._156yru3m{transition-duration:0s}._8rmvglyw:popover-open{animation-name:none}._2qm2ru3m:popover-open{transition-duration:0s}}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* popover.tsx generated by @compiled/babel-plugin v0.39.1 */
|
|
2
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
3
2
|
import "./popover.compiled.css";
|
|
4
3
|
import { ax, ix } from "@compiled/react/runtime";
|
|
5
4
|
import React, { forwardRef, useCallback, useId, useLayoutEffect, useRef } from 'react';
|
|
@@ -8,6 +7,7 @@ import mergeRefs from '@atlaskit/ds-lib/merge-refs';
|
|
|
8
7
|
import once from '@atlaskit/ds-lib/once';
|
|
9
8
|
import { useNotifyOpenLayerObserver } from '@atlaskit/layering/experimental/open-layer-observer';
|
|
10
9
|
import { shouldFocusIntoPopover } from '../internal/role-types';
|
|
10
|
+
import { setStyle } from '../internal/set-style';
|
|
11
11
|
import { useAnimatedVisibility } from '../internal/use-animated-visibility';
|
|
12
12
|
import { useFocusWrap } from '../internal/use-focus-wrap';
|
|
13
13
|
import { useInitialFocus } from '../internal/use-initial-focus';
|
|
@@ -23,16 +23,19 @@ const supportsPopoverHint = once(() => {
|
|
|
23
23
|
element.setAttribute('popover', 'hint');
|
|
24
24
|
return element.popover === 'hint';
|
|
25
25
|
});
|
|
26
|
+
const slideInKeyframes = null;
|
|
27
|
+
const slideOutKeyframes = null;
|
|
26
28
|
|
|
27
29
|
// These animation styles use the non-strict Compiled cssMap because they rely
|
|
28
30
|
// on `@starting-style`, `:popover-open`, `[dir='rtl']`, and `allow-discrete`.
|
|
29
31
|
// Keep them in this component so the Compiled transform can statically extract
|
|
30
32
|
// every referenced style.
|
|
31
33
|
const popoverAnimationStyles = {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
fade: "
|
|
35
|
-
|
|
34
|
+
root: "_k8m011k7 _1oecdn4k _1s9z1a5r _1a5xt94y _12t71ign _34bx1n1a _bl8aglyw _156yru3m _8rmvglyw _2qm2ru3m",
|
|
35
|
+
motion: "_y44vof1f _1o51q7pw _15ns179n _n70peoah",
|
|
36
|
+
'slide-and-fade': "_j7hq1l2h _5sagdn4k _1pgl1lbj _71rervlo _1psg1ign _o8i7indk",
|
|
37
|
+
fade: "_j7hq1a5s _5sagdn4k _1pgl1lbj _71re1bym _1psg1ign _o8i7indk",
|
|
38
|
+
'scale-and-fade': "_j7hqneez _5sagdn4k _1pgl1lbj _71re1v6b _1psg1ign _o8i7indk"
|
|
36
39
|
};
|
|
37
40
|
const styles = {
|
|
38
41
|
root: "_19itglyw _ca0qidpf _u5f3idpf _n3tdidpf _19bvidpf _19pkidpf _2hwxidpf _otyridpf _18u0idpf _1r041wug _1reoewfl _18m9ewfl _bfhk1j28"
|
|
@@ -86,7 +89,7 @@ export const Popover = /*#__PURE__*/forwardRef(function Popover({
|
|
|
86
89
|
placement,
|
|
87
90
|
testId,
|
|
88
91
|
isOpen,
|
|
89
|
-
xcss:
|
|
92
|
+
xcss: consumerXcss,
|
|
90
93
|
// ARIA
|
|
91
94
|
role,
|
|
92
95
|
label,
|
|
@@ -264,24 +267,19 @@ export const Popover = /*#__PURE__*/forwardRef(function Popover({
|
|
|
264
267
|
|
|
265
268
|
// Placement-dependent animation CSS vars. Kept separate from show/hide
|
|
266
269
|
// so preset reference changes do not re-trigger visibility. The cleanup
|
|
267
|
-
//
|
|
268
|
-
// properties on the element.
|
|
270
|
+
// restores the previous inline values so a preset change does not leave
|
|
271
|
+
// stale custom properties on the element.
|
|
269
272
|
useLayoutEffect(() => {
|
|
270
273
|
const element = ownRef.current;
|
|
271
|
-
if (!element || !(preset !== null && preset !== void 0 && preset.
|
|
274
|
+
if (!element || !(preset !== null && preset !== void 0 && preset.getStyles) || !placement) {
|
|
272
275
|
return;
|
|
273
276
|
}
|
|
274
|
-
|
|
275
|
-
|
|
277
|
+
return setStyle({
|
|
278
|
+
element,
|
|
279
|
+
styles: preset.getStyles({
|
|
280
|
+
placement
|
|
281
|
+
})
|
|
276
282
|
});
|
|
277
|
-
Object.entries(props).forEach(([key, value]) => {
|
|
278
|
-
element.style.setProperty(key, String(value));
|
|
279
|
-
});
|
|
280
|
-
return () => {
|
|
281
|
-
Object.keys(props).forEach(key => {
|
|
282
|
-
element.style.removeProperty(key);
|
|
283
|
-
});
|
|
284
|
-
};
|
|
285
283
|
}, [preset, placement, isVisible]);
|
|
286
284
|
|
|
287
285
|
// Show/hide based on isOpen. `showPopover`/`hidePopover` are no-ops when
|
|
@@ -320,7 +318,7 @@ export const Popover = /*#__PURE__*/forwardRef(function Popover({
|
|
|
320
318
|
if (!isVisible) {
|
|
321
319
|
return null;
|
|
322
320
|
}
|
|
323
|
-
return /*#__PURE__*/React.createElement("div",
|
|
321
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
324
322
|
ref: combinedRef,
|
|
325
323
|
id: popoverId
|
|
326
324
|
// @ts-expect-error -- popover attribute not yet in React types
|
|
@@ -330,11 +328,7 @@ export const Popover = /*#__PURE__*/forwardRef(function Popover({
|
|
|
330
328
|
role: role,
|
|
331
329
|
"aria-label": label,
|
|
332
330
|
"aria-labelledby": labelledBy,
|
|
333
|
-
"data-testid": testId
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
} : undefined, {
|
|
337
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- xcss prop passes compiled atomic class names
|
|
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])
|
|
339
|
-
}), children);
|
|
331
|
+
"data-testid": testId,
|
|
332
|
+
className: ax([styles.root, preset && popoverAnimationStyles.root, preset && popoverAnimationStyles[preset.name], consumerXcss])
|
|
333
|
+
}, children);
|
|
340
334
|
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// `custom` variant currently exists for typing reasons for Drawer
|
|
2
|
+
// not indicative of final API
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Dialog motion animation.
|
|
6
|
+
*
|
|
7
|
+
* Includes backdrop fade animation.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* import { dialogMotion } from '@atlaskit/top-layer/animations';
|
|
12
|
+
*
|
|
13
|
+
* <Dialog animate={dialogMotion()} isOpen={isOpen} onClose={handleClose} label="...">
|
|
14
|
+
* ...
|
|
15
|
+
* </Dialog>
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
19
|
+
export function dialogMotion() {
|
|
20
|
+
return {
|
|
21
|
+
kind: 'dialog',
|
|
22
|
+
name: 'motion'
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Slide up + opacity animation for dialogs.
|
|
28
|
+
*
|
|
29
|
+
* Entry slides up from below; exit slides up and out (asymmetric).
|
|
30
|
+
* Includes backdrop fade animation.
|
|
31
|
+
*
|
|
32
|
+
* @param options.distance - Slide distance in pixels. Defaults to `12`.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* import { dialogSlideUpAndFade } from '@atlaskit/top-layer/animations';
|
|
37
|
+
*
|
|
38
|
+
* const animation = dialogSlideUpAndFade();
|
|
39
|
+
* <Dialog animate={animation} isOpen={isOpen} onClose={handleClose} label="...">
|
|
40
|
+
* ...
|
|
41
|
+
* </Dialog>
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
45
|
+
export function dialogSlideUpAndFade(options) {
|
|
46
|
+
var _options$distance;
|
|
47
|
+
var distance = (_options$distance = options === null || options === void 0 ? void 0 : options.distance) !== null && _options$distance !== void 0 ? _options$distance : 12;
|
|
48
|
+
|
|
49
|
+
// The configurable distance is applied via the `--ds-dialog-ty` custom property
|
|
50
|
+
return {
|
|
51
|
+
kind: 'dialog',
|
|
52
|
+
name: 'slide-up-and-fade',
|
|
53
|
+
getStyles: function getStyles() {
|
|
54
|
+
return [{
|
|
55
|
+
property: '--ds-dialog-ty',
|
|
56
|
+
value: "".concat(distance, "px")
|
|
57
|
+
}];
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Simple opacity transition for dialogs, no transform.
|
|
64
|
+
*
|
|
65
|
+
* Includes backdrop fade animation.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```tsx
|
|
69
|
+
* import { dialogFade } from '@atlaskit/top-layer/animations';
|
|
70
|
+
*
|
|
71
|
+
* <Dialog animate={dialogFade()} isOpen={isOpen} onClose={handleClose} label="...">
|
|
72
|
+
* ...
|
|
73
|
+
* </Dialog>
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
77
|
+
export function dialogFade() {
|
|
78
|
+
return {
|
|
79
|
+
kind: 'dialog',
|
|
80
|
+
name: 'fade'
|
|
81
|
+
};
|
|
82
|
+
}
|
|
@@ -5,54 +5,46 @@
|
|
|
5
5
|
._1m5e1op4::backdrop{animation:var(--ds-blanket-exit,.2s cubic-bezier(.6,0,.8,.6) FadeOut100to0)}
|
|
6
6
|
._vhgsxbuz[open]::-ms-backdrop{animation:var(--ds-blanket-enter,.25s cubic-bezier(.4,0,0,1) FadeIn0to100)}
|
|
7
7
|
._vhgsxbuz[open]::backdrop{animation:var(--ds-blanket-enter,.25s cubic-bezier(.4,0,0,1) FadeIn0to100)}
|
|
8
|
-
._y44vgeqi{animation:var(--ds-modal-exit,.2s cubic-bezier(.6,0,.8,.6) ScaleOut100to95)}.
|
|
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
|
-
.
|
|
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
|
-
.
|
|
26
|
-
.
|
|
21
|
+
._1oeci9qs{transition-duration:var(--ds-duration-medium,.2s)}
|
|
22
|
+
._1oil1d08[open]{transition-timing-function:var(--ds-easing-inout-bold,cubic-bezier(.4,0,0,1))}
|
|
23
|
+
._1pgl1lbj{animation-timing-function:var(--ds-easing-in-practical,cubic-bezier(.6,0,.8,.6))}
|
|
27
24
|
._1q51ze3t{padding-block-start:var(--ds-space-0,0)}
|
|
25
|
+
._1rjx1d08[open]{animation-timing-function:var(--ds-easing-inout-bold,cubic-bezier(.4,0,0,1))}
|
|
28
26
|
._1rsueoah[open]::-ms-backdrop{animation-fill-mode:backwards}
|
|
29
27
|
._1rsueoah[open]::backdrop{animation-fill-mode:backwards}
|
|
30
28
|
._1s9z1a5r{transition-behavior:allow-discrete}
|
|
29
|
+
._1szp1mzy[open]{animation-duration:var(--ds-duration-long,.25s)}
|
|
31
30
|
._2hwx1wug{margin-right:auto}
|
|
32
|
-
.
|
|
33
|
-
._4v7i1ttt[open]::backdrop{transition-duration:.35s}
|
|
34
|
-
._6fl41a34{transition-timing-function:cubic-bezier(.15,1,.3,1)}
|
|
31
|
+
._5sagi9qs{animation-duration:var(--ds-duration-medium,.2s)}
|
|
35
32
|
._85i5ze3t{padding-block-end:var(--ds-space-0,0)}
|
|
33
|
+
._8ar61bym[open]{animation-name:var(--ds-keyframe-fade-in,FadeIn0to100)}
|
|
34
|
+
._8ar6yjsl[open]{animation-name:k1c1nn4,var(--ds-keyframe-fade-in,FadeIn0to100)}
|
|
36
35
|
._bfhk1j28{background-color:transparent}
|
|
37
36
|
._bozgze3t{padding-inline-start:var(--ds-space-0,0)}
|
|
38
37
|
._c71lglyw{max-height:none}
|
|
39
|
-
.
|
|
40
|
-
.
|
|
38
|
+
._j7hq1a5s{animation-name:var(--ds-keyframe-fade-out,FadeOut100to0)}
|
|
39
|
+
._j7hqcmlg{animation-name:ku52lnv,var(--ds-keyframe-fade-out,FadeOut100to0)}
|
|
41
40
|
._k8m011k7{transition-property:overlay,display}
|
|
42
|
-
._k8m01slm{transition-property:opacity,overlay,display}
|
|
43
|
-
._k8m0rv36{transition-property:opacity,transform,overlay,display}
|
|
44
41
|
._njwk11k7::-ms-backdrop{-ms-transition-property:overlay,display;transition-property:overlay,display}
|
|
45
42
|
._njwk11k7::backdrop{transition-property:overlay,display}
|
|
46
|
-
._njwkivc9::-ms-backdrop{-ms-transition-property:background-color,overlay,display;transition-property:background-color,overlay,display}
|
|
47
|
-
._njwkivc9::backdrop{transition-property:background-color,overlay,display}
|
|
48
43
|
._otyr1wug{margin-bottom:auto}
|
|
49
44
|
._p12fglyw{max-width:none}
|
|
50
|
-
._t9ec9o47{transform:translateY(calc(var(--ds-dialog-ty, 9pt)*-1))}
|
|
51
|
-
._tzy4idpf{opacity:0}
|
|
52
45
|
._y4tize3t{padding-inline-end:var(--ds-space-0,0)}
|
|
53
|
-
.
|
|
54
|
-
.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
@media (prefers-reduced-motion:reduce){.
|
|
58
|
-
@starting-style{._1dar1j28[open]::-ms-backdrop{background-color:transparent}._1dar1j28[open]::backdrop{background-color:transparent}._rornidpf[open]{opacity:0}._1hqtc4j2[open]{transform:translateY(var(--ds-dialog-ty,9pt))}}
|
|
46
|
+
._yhpqi9qs::-ms-backdrop{transition-duration:var(--ds-duration-medium,.2s)}
|
|
47
|
+
._yhpqi9qs::backdrop{transition-duration:var(--ds-duration-medium,.2s)}
|
|
48
|
+
@keyframes k1c1nn4{0%{transform:translateY(calc(var(--ds-dialog-ty, 9pt)))}to{transform:none}}
|
|
49
|
+
@keyframes ku52lnv{0%{transform:none}to{transform:translateY(calc(var(--ds-dialog-ty, 9pt)*-1))}}
|
|
50
|
+
@media (prefers-reduced-motion:reduce){._bl8aglyw{animation-name:none}._156y147i{transition-duration:var(--ds-duration-instant,0ms)}._10aiglyw[open]{animation-name:none}._aeld147i[open]{transition-duration:var(--ds-duration-instant,0ms)}._l57nglyw::-ms-backdrop{animation-name:none}._l57nglyw::backdrop{animation-name:none}._1sbq147i::-ms-backdrop{transition-duration:var(--ds-duration-instant,0ms)}._1sbq147i::backdrop{transition-duration:var(--ds-duration-instant,0ms)}._19awglyw[open]::-ms-backdrop{animation-name:none}._19awglyw[open]::backdrop{animation-name:none}._1i6z147i[open]::-ms-backdrop{transition-duration:var(--ds-duration-instant,0ms)}._1i6z147i[open]::backdrop{transition-duration:var(--ds-duration-instant,0ms)}}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
/* dialog-content.tsx generated by @compiled/babel-plugin v0.39.1 */
|
|
2
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
5
2
|
import "./dialog-content.compiled.css";
|
|
6
3
|
import { ax, ix } from "@compiled/react/runtime";
|
|
7
4
|
import React, { forwardRef, useCallback, useEffect, useId, useLayoutEffect, useRef } from 'react';
|
|
@@ -9,19 +6,30 @@ import { bind } from 'bind-event-listener';
|
|
|
9
6
|
import mergeRefs from '@atlaskit/ds-lib/merge-refs';
|
|
10
7
|
import noop from '@atlaskit/ds-lib/noop';
|
|
11
8
|
import { useNotifyOpenLayerObserver } from '@atlaskit/layering/experimental/open-layer-observer';
|
|
9
|
+
import { setStyle } from '../internal/set-style';
|
|
12
10
|
import { useAnimatedVisibility } from '../internal/use-animated-visibility';
|
|
13
11
|
import { useFocusWrap } from '../internal/use-focus-wrap';
|
|
12
|
+
var slideInKeyframes = null;
|
|
13
|
+
var slideOutKeyframes = null;
|
|
14
|
+
|
|
14
15
|
// These animation styles use the non-strict Compiled cssMap because they rely
|
|
15
16
|
// on `@starting-style`, `[open]`, and `allow-discrete`. Keep them in this
|
|
16
17
|
// component so the Compiled transform can statically extract every referenced
|
|
17
18
|
// style.
|
|
18
19
|
var dialogAnimationStyles = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
fade: "
|
|
20
|
+
root: "_k8m011k7 _1oeci9qs _1s9z1a5r _1fsl1mzy _1oil1d08",
|
|
21
|
+
motion: "_y44vgeqi _1o51q7pw _1iu47kvq _1i0neoah",
|
|
22
|
+
'slide-up-and-fade': "_j7hqcmlg _5sagi9qs _1pgl1lbj _8ar6yjsl _1szp1mzy _1rjx1d08",
|
|
23
|
+
fade: "_j7hq1a5s _5sagi9qs _1pgl1lbj _8ar61bym _1szp1mzy _1rjx1d08",
|
|
24
|
+
custom: ""
|
|
22
25
|
};
|
|
23
26
|
var styles = {
|
|
24
|
-
dialog: "_19itglyw _19pk1wug _2hwx1wug _otyr1wug _18u01wug _1q51ze3t _y4tize3t _85i5ze3t _bozgze3t _p12fglyw _c71lglyw _bfhk1j28
|
|
27
|
+
dialog: "_19itglyw _19pk1wug _2hwx1wug _otyr1wug _18u01wug _1q51ze3t _y4tize3t _85i5ze3t _bozgze3t _p12fglyw _c71lglyw _bfhk1j28 _bl8aglyw _156y147i _10aiglyw _aeld147i"
|
|
28
|
+
};
|
|
29
|
+
var backdropStyles = {
|
|
30
|
+
root: "_1ltk1i5c",
|
|
31
|
+
hidden: "_1ltk1j28",
|
|
32
|
+
motion: "_1m5e1op4 _1jhdq7pw _njwk11k7 _yhpqi9qs _1fyf1a5r _vhgsxbuz _1rsueoah _l57nglyw _1sbq147i _19awglyw _1i6z147i"
|
|
25
33
|
};
|
|
26
34
|
|
|
27
35
|
/**
|
|
@@ -48,7 +56,7 @@ export var Dialog = /*#__PURE__*/forwardRef(function Dialog(_ref, ref) {
|
|
|
48
56
|
onEnterFinish = _ref.onEnterFinish,
|
|
49
57
|
onExitFinish = _ref.onExitFinish,
|
|
50
58
|
animate = _ref.animate,
|
|
51
|
-
|
|
59
|
+
consumerXcss = _ref.xcss,
|
|
52
60
|
style = _ref.style,
|
|
53
61
|
testId = _ref.testId,
|
|
54
62
|
providedId = _ref.id,
|
|
@@ -114,28 +122,20 @@ export var Dialog = /*#__PURE__*/forwardRef(function Dialog(_ref, ref) {
|
|
|
114
122
|
|
|
115
123
|
// Apply preset-provided animation custom properties (e.g. the
|
|
116
124
|
// `--ds-dialog-ty` slide distance for `dialogSlideUpAndFade`). The
|
|
117
|
-
// cleanup
|
|
118
|
-
// custom properties on the element. Dialog presets do
|
|
119
|
-
// placement, so an empty placement is passed.
|
|
125
|
+
// cleanup restores the previous inline values so a preset change does
|
|
126
|
+
// not leave stale custom properties on the element. Dialog presets do
|
|
127
|
+
// not vary by placement, so an empty placement is passed.
|
|
120
128
|
useLayoutEffect(function () {
|
|
121
129
|
var dialog = ownRef.current;
|
|
122
|
-
if (!dialog || !(preset !== null && preset !== void 0 && preset.
|
|
130
|
+
if (!dialog || !(preset !== null && preset !== void 0 && preset.getStyles)) {
|
|
123
131
|
return;
|
|
124
132
|
}
|
|
125
|
-
|
|
126
|
-
|
|
133
|
+
return setStyle({
|
|
134
|
+
element: dialog,
|
|
135
|
+
styles: preset.getStyles({
|
|
136
|
+
placement: {}
|
|
137
|
+
})
|
|
127
138
|
});
|
|
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
139
|
}, [preset, isVisible]);
|
|
140
140
|
|
|
141
141
|
// Handle native Escape (cancel event)
|
|
@@ -177,12 +177,6 @@ export var Dialog = /*#__PURE__*/forwardRef(function Dialog(_ref, ref) {
|
|
|
177
177
|
});
|
|
178
178
|
}, [onClose, isVisible]);
|
|
179
179
|
|
|
180
|
-
// Atomic CSS (Compiled) deduplicates ::backdrop { background-color }
|
|
181
|
-
// into a single class, making it impossible to toggle between two values
|
|
182
|
-
// via cssMap entries. An ID-scoped <style> has higher specificity than
|
|
183
|
-
// any atomic class, so the override always wins.
|
|
184
|
-
var escapedId = CSS.escape(dialogId);
|
|
185
|
-
|
|
186
180
|
// Unmount the `<dialog>` once exit completes so it does not leave an
|
|
187
181
|
// empty `role="dialog"` element in the accessibility tree. On the next
|
|
188
182
|
// open the element remounts and the `[isOpen]` and `[onClose, isVisible]`
|
|
@@ -190,7 +184,7 @@ export var Dialog = /*#__PURE__*/forwardRef(function Dialog(_ref, ref) {
|
|
|
190
184
|
if (!isVisible) {
|
|
191
185
|
return null;
|
|
192
186
|
}
|
|
193
|
-
return /*#__PURE__*/React.createElement("dialog",
|
|
187
|
+
return /*#__PURE__*/React.createElement("dialog", {
|
|
194
188
|
ref: combinedRef,
|
|
195
189
|
id: dialogId
|
|
196
190
|
// `aria-modal` is intentionally NOT set: native `<dialog>.showModal()`
|
|
@@ -201,15 +195,9 @@ export var Dialog = /*#__PURE__*/forwardRef(function Dialog(_ref, ref) {
|
|
|
201
195
|
,
|
|
202
196
|
"aria-label": label,
|
|
203
197
|
"aria-labelledby": label ? undefined : labelledBy,
|
|
204
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
205
198
|
style: style,
|
|
206
199
|
onCancel: handleCancel,
|
|
207
|
-
"data-testid": testId
|
|
208
|
-
|
|
209
|
-
|
|
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])
|
|
211
|
-
}), shouldHideBackdrop &&
|
|
212
|
-
/*#__PURE__*/
|
|
213
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles
|
|
214
|
-
React.createElement("style", null, "#".concat(escapedId, "::backdrop{background-color:transparent}")), children);
|
|
200
|
+
"data-testid": testId,
|
|
201
|
+
className: ax([styles.dialog, shouldHideBackdrop ? backdropStyles.hidden : backdropStyles.root, preset && backdropStyles.motion, preset && dialogAnimationStyles.root, preset && dialogAnimationStyles[preset.name], consumerXcss])
|
|
202
|
+
}, children);
|
|
215
203
|
});
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { dialogMotion,
|
|
1
|
+
export { dialogMotion, dialogSlideUpAndFade, dialogFade } from '../dialog/animations';
|
|
2
|
+
export { popupMotion, slideAndFade, fade, scaleAndFade } from '../popover/animations';
|