@atlaskit/top-layer 1.5.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/compass.yml +10 -1
  3. package/dist/cjs/dialog/dialog-content.compiled.css +7 -25
  4. package/dist/cjs/dialog/dialog-content.js +16 -51
  5. package/dist/cjs/entry-points/animations.js +1 -48
  6. package/dist/cjs/internal/use-animated-visibility.js +35 -6
  7. package/dist/cjs/popover/animations.js +50 -0
  8. package/dist/cjs/popover/popover.compiled.css +7 -14
  9. package/dist/cjs/popover/popover.js +19 -31
  10. package/dist/cjs/testing/polyfill.js +3 -0
  11. package/dist/es2019/dialog/dialog-content.compiled.css +7 -25
  12. package/dist/es2019/dialog/dialog-content.js +15 -48
  13. package/dist/es2019/entry-points/animations.js +0 -1
  14. package/dist/es2019/internal/use-animated-visibility.js +35 -6
  15. package/dist/es2019/popover/animations.js +46 -0
  16. package/dist/es2019/popover/popover.compiled.css +7 -14
  17. package/dist/es2019/popover/popover.js +18 -28
  18. package/dist/es2019/testing/polyfill.js +3 -0
  19. package/dist/esm/dialog/dialog-content.compiled.css +7 -25
  20. package/dist/esm/dialog/dialog-content.js +16 -51
  21. package/dist/esm/entry-points/animations.js +0 -1
  22. package/dist/esm/internal/use-animated-visibility.js +35 -6
  23. package/dist/esm/popover/animations.js +44 -0
  24. package/dist/esm/popover/popover.compiled.css +7 -14
  25. package/dist/esm/popover/popover.js +19 -31
  26. package/dist/esm/testing/polyfill.js +3 -0
  27. package/dist/types/dialog/types.d.ts +5 -5
  28. package/dist/types/entry-points/animations.d.ts +0 -2
  29. package/dist/types/internal/use-animated-visibility.d.ts +16 -5
  30. package/dist/types/popover/animations.d.ts +7 -0
  31. package/dist/types/popover/types.d.ts +7 -4
  32. package/package.json +30 -12
  33. package/dist/cjs/animations/presets.js +0 -298
  34. package/dist/cjs/animations/types.js +0 -5
  35. package/dist/es2019/animations/presets.js +0 -285
  36. package/dist/es2019/animations/types.js +0 -1
  37. package/dist/esm/animations/presets.js +0 -285
  38. package/dist/esm/animations/types.js +0 -1
  39. package/dist/types/animations/presets.d.ts +0 -128
  40. package/dist/types/animations/types.d.ts +0 -34
@@ -1,285 +0,0 @@
1
- import { getPlacement } from '../internal/resolve-placement';
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
22
-
23
- function getPopupMotionProperties(_ref) {
24
- var placement = _ref.placement;
25
- var _getPlacement = getPlacement({
26
- placement: placement
27
- }),
28
- axis = _getPlacement.axis,
29
- edge = _getPlacement.edge;
30
- if (axis === 'block' && edge === 'start') {
31
- return {
32
- '--ds-popover-motion-enter': "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)",
33
- '--ds-popover-motion-exit': "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)"
34
- };
35
- }
36
- if (axis === 'inline' && edge === 'start') {
37
- return {
38
- '--ds-popover-motion-enter': "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)",
39
- '--ds-popover-motion-exit': "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)"
40
- };
41
- }
42
- if (axis === 'inline' && edge === 'end') {
43
- return {
44
- '--ds-popover-motion-enter': "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)",
45
- '--ds-popover-motion-exit': "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)"
46
- };
47
- }
48
- // Default: block/end (popover below trigger)
49
- return {
50
- '--ds-popover-motion-enter': "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)",
51
- '--ds-popover-motion-exit': "var(--ds-popup-exit-bottom, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutBottom8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
52
- };
53
- }
54
-
55
- // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
56
- export function popupMotion() {
57
- return {
58
- name: 'popup-motion',
59
- enterDurationMs: animationDurations.popupMotion.enter,
60
- exitDurationMs: animationDurations.popupMotion.exit,
61
- getProperties: function getProperties(_ref2) {
62
- var placement = _ref2.placement;
63
- return getPopupMotionProperties({
64
- placement: placement
65
- });
66
- }
67
- };
68
- }
69
-
70
- // slideAndFade
71
-
72
- function getSlideAndFadeProperties(_ref3) {
73
- var placement = _ref3.placement,
74
- distance = _ref3.distance;
75
- var pos = "".concat(distance, "px");
76
- var neg = "-".concat(distance, "px");
77
- var _getPlacement2 = getPlacement({
78
- placement: placement
79
- }),
80
- axis = _getPlacement2.axis,
81
- edge = _getPlacement2.edge;
82
- if (axis === 'block' && edge === 'start') {
83
- return {
84
- '--ds-popover-tx': '0',
85
- '--ds-popover-ty': pos
86
- };
87
- }
88
- if (axis === 'block' && edge === 'end') {
89
- return {
90
- '--ds-popover-tx': '0',
91
- '--ds-popover-ty': neg
92
- };
93
- }
94
- if (axis === 'inline' && edge === 'start') {
95
- return {
96
- '--ds-popover-tx': pos,
97
- '--ds-popover-ty': '0'
98
- };
99
- }
100
- if (axis === 'inline' && edge === 'end') {
101
- return {
102
- '--ds-popover-tx': neg,
103
- '--ds-popover-ty': '0'
104
- };
105
- }
106
- return {
107
- '--ds-popover-tx': '0',
108
- '--ds-popover-ty': neg
109
- };
110
- }
111
-
112
- /**
113
- * Directional slide + opacity animation.
114
- *
115
- * The popover slides in from the direction opposite its placement edge
116
- * (e.g. a `block-end` popover slides down from above).
117
- *
118
- * @param options.distance - Slide distance in pixels. Defaults to `4`.
119
- *
120
- * @example
121
- * ```tsx
122
- * import { slideAndFade } from '@atlaskit/top-layer/animations';
123
- *
124
- * // Default 4px slide (tooltip)
125
- * <Popover animate={slideAndFade()} />
126
- *
127
- * // Custom 8px slide (popup / dropdown)
128
- * <Popover animate={slideAndFade({ distance: 8 })} />
129
- * ```
130
- */
131
- // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
132
- export function slideAndFade(options) {
133
- var _options$distance;
134
- var distance = (_options$distance = options === null || options === void 0 ? void 0 : options.distance) !== null && _options$distance !== void 0 ? _options$distance : 4;
135
- return {
136
- name: 'slide-and-fade',
137
- getProperties: function getProperties(_ref4) {
138
- var placement = _ref4.placement;
139
- return getSlideAndFadeProperties({
140
- placement: placement,
141
- distance: distance
142
- });
143
- },
144
- enterDurationMs: animationDurations.popoverTransition.enter,
145
- exitDurationMs: animationDurations.popoverTransition.exit
146
- };
147
- }
148
-
149
- // fade
150
-
151
- /**
152
- * Simple opacity transition, no transform.
153
- *
154
- * Suitable for popup dialogs or content that does not need directional motion.
155
- *
156
- * @example
157
- * ```tsx
158
- * import { fade } from '@atlaskit/top-layer/animations';
159
- *
160
- * <Popover animate={fade()} />
161
- * ```
162
- */
163
- // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
164
- export function fade() {
165
- return {
166
- name: 'fade',
167
- enterDurationMs: animationDurations.popoverTransition.enter,
168
- exitDurationMs: animationDurations.popoverTransition.exit
169
- };
170
- }
171
-
172
- // scaleAndFade
173
-
174
- /**
175
- * Scale from 0.95 + opacity transition.
176
- *
177
- * Suitable for menus, dropdowns, and select options.
178
- *
179
- * @example
180
- * ```tsx
181
- * import { scaleAndFade } from '@atlaskit/top-layer/animations';
182
- *
183
- * <Popover animate={scaleAndFade()} />
184
- * ```
185
- */
186
- // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
187
- export function scaleAndFade() {
188
- return {
189
- name: 'scale-and-fade',
190
- enterDurationMs: animationDurations.popoverTransition.enter,
191
- exitDurationMs: animationDurations.popoverTransition.exit
192
- };
193
- }
194
-
195
- // dialogMotion
196
-
197
- /**
198
- * Dialog motion animation.
199
- *
200
- * Includes backdrop fade animation.
201
- *
202
- * @example
203
- * ```tsx
204
- * import { dialogMotion } from '@atlaskit/top-layer/animations';
205
- *
206
- * <Dialog animate={dialogMotion()} isOpen={isOpen} onClose={handleClose} label="...">
207
- * ...
208
- * </Dialog>
209
- * ```
210
- */
211
- // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
212
- export function dialogMotion() {
213
- // Bare preset name; `Dialog` prefixes it via `data-ds-dialog-{name}`.
214
- return {
215
- name: 'motion',
216
- enterDurationMs: animationDurations.dialogMotion.enter,
217
- exitDurationMs: animationDurations.dialogMotion.exit
218
- };
219
- }
220
-
221
- // dialogSlideUpAndFade
222
-
223
- /**
224
- * Slide up + opacity animation for dialogs.
225
- *
226
- * Entry slides up from below; exit slides up and out (asymmetric).
227
- * Includes backdrop fade animation.
228
- *
229
- * @param options.distance - Slide distance in pixels. Defaults to `12`.
230
- *
231
- * @example
232
- * ```tsx
233
- * import { dialogSlideUpAndFade } from '@atlaskit/top-layer/animations';
234
- *
235
- * const animation = dialogSlideUpAndFade();
236
- * <Dialog animate={animation} isOpen={isOpen} onClose={handleClose} label="...">
237
- * ...
238
- * </Dialog>
239
- * ```
240
- */
241
- // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
242
- export function dialogSlideUpAndFade(options) {
243
- var _options$distance2;
244
- var distance = (_options$distance2 = options === null || options === void 0 ? void 0 : options.distance) !== null && _options$distance2 !== void 0 ? _options$distance2 : 12;
245
-
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.
249
- return {
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
- };
259
- }
260
-
261
- // dialogFade
262
-
263
- /**
264
- * Simple opacity transition for dialogs, no transform.
265
- *
266
- * Includes backdrop fade animation.
267
- *
268
- * @example
269
- * ```tsx
270
- * import { dialogFade } from '@atlaskit/top-layer/animations';
271
- *
272
- * <Dialog animate={dialogFade()} isOpen={isOpen} onClose={handleClose} label="...">
273
- * ...
274
- * </Dialog>
275
- * ```
276
- */
277
- // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
278
- export function dialogFade() {
279
- // Bare preset name; `Dialog` prefixes it via `data-ds-dialog-{name}`.
280
- return {
281
- name: 'fade',
282
- enterDurationMs: animationDurations.dialogTransition.enter,
283
- exitDurationMs: animationDurations.dialogTransition.exit
284
- };
285
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,128 +0,0 @@
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
- };
20
- export declare function popupMotion(): TAnimationPreset;
21
- type TSlideAndFadeOptions = {
22
- /**
23
- * Slide distance in pixels. Defaults to `4`.
24
- */
25
- distance?: number;
26
- };
27
- /**
28
- * Directional slide + opacity animation.
29
- *
30
- * The popover slides in from the direction opposite its placement edge
31
- * (e.g. a `block-end` popover slides down from above).
32
- *
33
- * @param options.distance - Slide distance in pixels. Defaults to `4`.
34
- *
35
- * @example
36
- * ```tsx
37
- * import { slideAndFade } from '@atlaskit/top-layer/animations';
38
- *
39
- * // Default 4px slide (tooltip)
40
- * <Popover animate={slideAndFade()} />
41
- *
42
- * // Custom 8px slide (popup / dropdown)
43
- * <Popover animate={slideAndFade({ distance: 8 })} />
44
- * ```
45
- */
46
- export declare function slideAndFade(options?: TSlideAndFadeOptions): TAnimationPreset;
47
- /**
48
- * Simple opacity transition, no transform.
49
- *
50
- * Suitable for popup dialogs or content that does not need directional motion.
51
- *
52
- * @example
53
- * ```tsx
54
- * import { fade } from '@atlaskit/top-layer/animations';
55
- *
56
- * <Popover animate={fade()} />
57
- * ```
58
- */
59
- export declare function fade(): TAnimationPreset;
60
- /**
61
- * Scale from 0.95 + opacity transition.
62
- *
63
- * Suitable for menus, dropdowns, and select options.
64
- *
65
- * @example
66
- * ```tsx
67
- * import { scaleAndFade } from '@atlaskit/top-layer/animations';
68
- *
69
- * <Popover animate={scaleAndFade()} />
70
- * ```
71
- */
72
- export declare function scaleAndFade(): TAnimationPreset;
73
- /**
74
- * Dialog motion animation.
75
- *
76
- * Includes backdrop fade animation.
77
- *
78
- * @example
79
- * ```tsx
80
- * import { dialogMotion } from '@atlaskit/top-layer/animations';
81
- *
82
- * <Dialog animate={dialogMotion()} isOpen={isOpen} onClose={handleClose} label="...">
83
- * ...
84
- * </Dialog>
85
- * ```
86
- */
87
- export declare function dialogMotion(): TAnimationPreset;
88
- type TDialogSlideUpAndFadeOptions = {
89
- /**
90
- * Slide distance in pixels. Defaults to `12`.
91
- */
92
- distance?: number;
93
- };
94
- /**
95
- * Slide up + opacity animation for dialogs.
96
- *
97
- * Entry slides up from below; exit slides up and out (asymmetric).
98
- * Includes backdrop fade animation.
99
- *
100
- * @param options.distance - Slide distance in pixels. Defaults to `12`.
101
- *
102
- * @example
103
- * ```tsx
104
- * import { dialogSlideUpAndFade } from '@atlaskit/top-layer/animations';
105
- *
106
- * const animation = dialogSlideUpAndFade();
107
- * <Dialog animate={animation} isOpen={isOpen} onClose={handleClose} label="...">
108
- * ...
109
- * </Dialog>
110
- * ```
111
- */
112
- export declare function dialogSlideUpAndFade(options?: TDialogSlideUpAndFadeOptions): TAnimationPreset;
113
- /**
114
- * Simple opacity transition for dialogs, no transform.
115
- *
116
- * Includes backdrop fade animation.
117
- *
118
- * @example
119
- * ```tsx
120
- * import { dialogFade } from '@atlaskit/top-layer/animations';
121
- *
122
- * <Dialog animate={dialogFade()} isOpen={isOpen} onClose={handleClose} label="...">
123
- * ...
124
- * </Dialog>
125
- * ```
126
- */
127
- export declare function dialogFade(): TAnimationPreset;
128
- export {};
@@ -1,34 +0,0 @@
1
- import type { TPlacementOptions } from '../internal/resolve-placement';
2
- /**
3
- * A self-contained animation preset for top-layer elements.
4
- *
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
- *
9
- * The actual Compiled styles are kept static and component-local so the
10
- * Compiled transform can extract them at build time.
11
- */
12
- export type TAnimationPreset = {
13
- /**
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`).
16
- */
17
- name: string;
18
- /**
19
- * Per-placement CSS custom properties (e.g. directional offset for
20
- * `slideAndFade`). Only used by presets that vary by placement or by a
21
- * configurable distance.
22
- */
23
- getProperties?: (args: {
24
- placement: TPlacementOptions;
25
- }) => Record<string, string>;
26
- /**
27
- * Entry duration in ms (for `transitionend` fallback timeout on open).
28
- */
29
- enterDurationMs: number;
30
- /**
31
- * Exit duration in ms (for `transitionend` fallback timeout on close).
32
- */
33
- exitDurationMs: number;
34
- };