@atlaskit/top-layer 1.6.0 → 1.7.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 (41) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +13 -0
  3. package/compass.yml +10 -1
  4. package/dist/cjs/dialog/dialog-content.compiled.css +0 -10
  5. package/dist/cjs/dialog/dialog-content.js +20 -28
  6. package/dist/cjs/entry-points/animations.js +1 -49
  7. package/dist/cjs/internal/use-animated-visibility.js +14 -17
  8. package/dist/cjs/internal/use-safari-escape-fix.js +62 -0
  9. package/dist/cjs/popover/animations.js +1 -147
  10. package/dist/cjs/popover/popover.compiled.css +1 -10
  11. package/dist/cjs/popover/popover.js +9 -12
  12. package/dist/cjs/testing/polyfill.js +3 -0
  13. package/dist/es2019/dialog/dialog-content.compiled.css +0 -10
  14. package/dist/es2019/dialog/dialog-content.js +20 -28
  15. package/dist/es2019/entry-points/animations.js +0 -2
  16. package/dist/es2019/internal/use-animated-visibility.js +14 -18
  17. package/dist/es2019/internal/use-safari-escape-fix.js +58 -0
  18. package/dist/es2019/popover/animations.js +1 -145
  19. package/dist/es2019/popover/popover.compiled.css +1 -10
  20. package/dist/es2019/popover/popover.js +8 -12
  21. package/dist/es2019/testing/polyfill.js +3 -0
  22. package/dist/esm/dialog/dialog-content.compiled.css +0 -10
  23. package/dist/esm/dialog/dialog-content.js +20 -28
  24. package/dist/esm/entry-points/animations.js +0 -2
  25. package/dist/esm/internal/use-animated-visibility.js +14 -18
  26. package/dist/esm/internal/use-safari-escape-fix.js +57 -0
  27. package/dist/esm/popover/animations.js +1 -144
  28. package/dist/esm/popover/popover.compiled.css +1 -10
  29. package/dist/esm/popover/popover.js +9 -12
  30. package/dist/esm/testing/polyfill.js +3 -0
  31. package/dist/types/dialog/types.d.ts +5 -5
  32. package/dist/types/entry-points/animations.d.ts +0 -2
  33. package/dist/types/internal/use-animated-visibility.d.ts +15 -33
  34. package/dist/types/internal/use-safari-escape-fix.d.ts +12 -0
  35. package/dist/types/popover/animations.d.ts +7 -52
  36. package/dist/types/popover/types.d.ts +6 -3
  37. package/package.json +6 -5
  38. package/dist/cjs/dialog/animations.js +0 -90
  39. package/dist/es2019/dialog/animations.js +0 -80
  40. package/dist/esm/dialog/animations.js +0 -82
  41. package/dist/types/dialog/animations.d.ts +0 -57
@@ -0,0 +1,12 @@
1
+ import { type RefObject } from 'react';
2
+ /**
3
+ * Safari-only guard: WebKit fires dialog `cancel` on Escape even when a child
4
+ * `auto`/`hint` popover consumed it, closing the dialog too.
5
+ * See notes/decisions/safari-escape-nested-popover-in-dialog.md
6
+ */
7
+ export declare function useSafariEscapeFix({ dialogRef, isVisible, }: {
8
+ dialogRef: RefObject<HTMLDialogElement | null>;
9
+ isVisible: boolean;
10
+ }): {
11
+ shouldIgnoreEscape: () => boolean;
12
+ };
@@ -1,52 +1,7 @@
1
- import type { TAnimationPreset } from '../internal/use-animated-visibility';
2
- export type TPopoverAnimationPresetName = 'motion' | 'slide-and-fade' | 'scale-and-fade' | 'fade';
3
- export type TPopoverAnimationPreset = TAnimationPreset<'popover', TPopoverAnimationPresetName>;
4
- export declare function popupMotion(): TPopoverAnimationPreset;
5
- /**
6
- * Directional slide + opacity animation.
7
- *
8
- * The popover slides in from the direction opposite its placement edge
9
- * (e.g. a `block-end` popover slides down from above).
10
- *
11
- * @param options.distance - Slide distance in pixels. Defaults to `4`.
12
- *
13
- * @example
14
- * ```tsx
15
- * import { slideAndFade } from '@atlaskit/top-layer/animations';
16
- *
17
- * // Default 4px slide (tooltip)
18
- * <Popover animate={slideAndFade()} />
19
- *
20
- * // Custom 8px slide (popup / dropdown)
21
- * <Popover animate={slideAndFade({ distance: 8 })} />
22
- * ```
23
- */
24
- export declare function slideAndFade(options?: {
25
- distance?: number;
26
- }): TPopoverAnimationPreset;
27
- /**
28
- * Simple opacity transition, no transform.
29
- *
30
- * Suitable for popup dialogs or content that does not need directional motion.
31
- *
32
- * @example
33
- * ```tsx
34
- * import { fade } from '@atlaskit/top-layer/animations';
35
- *
36
- * <Popover animate={fade()} />
37
- * ```
38
- */
39
- export declare function fade(): TPopoverAnimationPreset;
40
- /**
41
- * Scale from 0.95 + opacity transition.
42
- *
43
- * Suitable for menus, dropdowns, and select options.
44
- *
45
- * @example
46
- * ```tsx
47
- * import { scaleAndFade } from '@atlaskit/top-layer/animations';
48
- *
49
- * <Popover animate={scaleAndFade()} />
50
- * ```
51
- */
52
- export declare function scaleAndFade(): TPopoverAnimationPreset;
1
+ import { type TPlacementOptions } from '../internal/resolve-placement';
2
+ export declare function getPopupMotionStyles({ placement, }: {
3
+ placement: TPlacementOptions;
4
+ }): Array<{
5
+ property: string;
6
+ value: string;
7
+ }>;
@@ -2,7 +2,7 @@ import { type ReactNode } from 'react';
2
2
  import { type StrictXCSSProp } from '@atlaskit/css';
3
3
  import { type TPlacementOptions } from '../internal/resolve-placement';
4
4
  import { type TAriaRoleRequired, type TRoleRequiringAccessibleName, type TRoleWithImplicitName } from '../internal/role-types';
5
- import { type TPopoverAnimationPreset } from './animations';
5
+ import type { TAnimationConfig } from '../internal/use-animated-visibility';
6
6
  /**
7
7
  * The reason a popover was closed.
8
8
  *
@@ -36,14 +36,17 @@ type TPopoverBaseProps = {
36
36
  * Additional CSS styles applied to the popover root element.
37
37
  * Use to set `backgroundColor` to match the popup surface colour.
38
38
  */
39
- xcss?: StrictXCSSProp<'backgroundColor', never>;
39
+ xcss?: StrictXCSSProp<'animationName', '&:popover-open', {
40
+ requiredPseudos: '&:popover-open';
41
+ requiredProperties: never;
42
+ }>;
40
43
  /**
41
44
  * Animation preset for entry/exit transitions.
42
45
  *
43
46
  * Animations use `@starting-style` and `allow-discrete` for progressive
44
47
  * enhancement: browsers without support show/hide instantly.
45
48
  */
46
- animate?: false | TPopoverAnimationPreset;
49
+ animate?: boolean | TAnimationConfig;
47
50
  /**
48
51
  * Test ID applied to the popover element.
49
52
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/top-layer",
3
- "version": "1.6.0",
3
+ "version": "1.7.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",
@@ -29,7 +29,8 @@
29
29
  },
30
30
  "integrationTests": {
31
31
  "additionalBrowsers": [
32
- "desktop-firefox"
32
+ "desktop-firefox",
33
+ "desktop-webkit"
33
34
  ]
34
35
  }
35
36
  },
@@ -39,7 +40,7 @@
39
40
  "@atlaskit/ds-lib": "^8.0.0",
40
41
  "@atlaskit/layering": "^4.1.0",
41
42
  "@atlaskit/react-compiler-gating": "^0.2.0",
42
- "@atlaskit/tokens": "^15.5.0",
43
+ "@atlaskit/tokens": "^15.8.0",
43
44
  "@babel/runtime": "^7.0.0",
44
45
  "@compiled/react": "^0.20.0",
45
46
  "bind-event-listener": "^3.0.0",
@@ -55,11 +56,11 @@
55
56
  "@atlaskit/button": "^24.3.0",
56
57
  "@atlaskit/heading": "^6.2.0",
57
58
  "@atlaskit/lozenge": "^14.1.0",
58
- "@atlaskit/primitives": "^20.5.0",
59
+ "@atlaskit/primitives": "^20.6.0",
59
60
  "@atlaskit/ssr": "workspace:^",
60
61
  "@atlaskit/textfield": "^9.1.0",
61
62
  "@atlassian/ssr-tests": "workspace:^",
62
- "@atlassian/testing-library": "^0.10.0",
63
+ "@atlassian/testing-library": "^0.11.0",
63
64
  "@testing-library/jest-dom": "^6.4.5",
64
65
  "@testing-library/react": "^16.3.0",
65
66
  "@types/raf-schd": "^4.0.1",
@@ -1,90 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.dialogFade = dialogFade;
7
- exports.dialogMotion = dialogMotion;
8
- exports.dialogSlideUpAndFade = dialogSlideUpAndFade;
9
- // `custom` variant currently exists for typing reasons for Drawer
10
- // not indicative of final API
11
-
12
- /**
13
- * Dialog motion animation.
14
- *
15
- * Includes backdrop fade animation.
16
- *
17
- * @example
18
- * ```tsx
19
- * import { dialogMotion } from '@atlaskit/top-layer/animations';
20
- *
21
- * <Dialog animate={dialogMotion()} isOpen={isOpen} onClose={handleClose} label="...">
22
- * ...
23
- * </Dialog>
24
- * ```
25
- */
26
- // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
27
- function dialogMotion() {
28
- return {
29
- kind: 'dialog',
30
- name: 'motion'
31
- };
32
- }
33
-
34
- /**
35
- * Slide up + opacity animation for dialogs.
36
- *
37
- * Entry slides up from below; exit slides up and out (asymmetric).
38
- * Includes backdrop fade animation.
39
- *
40
- * @param options.distance - Slide distance in pixels. Defaults to `12`.
41
- *
42
- * @example
43
- * ```tsx
44
- * import { dialogSlideUpAndFade } from '@atlaskit/top-layer/animations';
45
- *
46
- * const animation = dialogSlideUpAndFade();
47
- * <Dialog animate={animation} isOpen={isOpen} onClose={handleClose} label="...">
48
- * ...
49
- * </Dialog>
50
- * ```
51
- */
52
- // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
53
- function dialogSlideUpAndFade(options) {
54
- var _options$distance;
55
- var distance = (_options$distance = options === null || options === void 0 ? void 0 : options.distance) !== null && _options$distance !== void 0 ? _options$distance : 12;
56
-
57
- // The configurable distance is applied via the `--ds-dialog-ty` custom property
58
- return {
59
- kind: 'dialog',
60
- name: 'slide-up-and-fade',
61
- getStyles: function getStyles() {
62
- return [{
63
- property: '--ds-dialog-ty',
64
- value: "".concat(distance, "px")
65
- }];
66
- }
67
- };
68
- }
69
-
70
- /**
71
- * Simple opacity transition for dialogs, no transform.
72
- *
73
- * Includes backdrop fade animation.
74
- *
75
- * @example
76
- * ```tsx
77
- * import { dialogFade } from '@atlaskit/top-layer/animations';
78
- *
79
- * <Dialog animate={dialogFade()} isOpen={isOpen} onClose={handleClose} label="...">
80
- * ...
81
- * </Dialog>
82
- * ```
83
- */
84
- // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
85
- function dialogFade() {
86
- return {
87
- kind: 'dialog',
88
- name: 'fade'
89
- };
90
- }
@@ -1,80 +0,0 @@
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
- const 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: () => [{
54
- property: '--ds-dialog-ty',
55
- value: `${distance}px`
56
- }]
57
- };
58
- }
59
-
60
- /**
61
- * Simple opacity transition for dialogs, no transform.
62
- *
63
- * Includes backdrop fade animation.
64
- *
65
- * @example
66
- * ```tsx
67
- * import { dialogFade } from '@atlaskit/top-layer/animations';
68
- *
69
- * <Dialog animate={dialogFade()} isOpen={isOpen} onClose={handleClose} label="...">
70
- * ...
71
- * </Dialog>
72
- * ```
73
- */
74
- // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
75
- export function dialogFade() {
76
- return {
77
- kind: 'dialog',
78
- name: 'fade'
79
- };
80
- }
@@ -1,82 +0,0 @@
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
- }
@@ -1,57 +0,0 @@
1
- import type { TAnimationPreset } from '../internal/use-animated-visibility';
2
- export type TDialogAnimationPresetName = 'motion' | 'slide-up-and-fade' | 'fade' | 'custom';
3
- export type TDialogAnimationPreset = TAnimationPreset<'dialog', TDialogAnimationPresetName>;
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
- export declare function dialogMotion(): TDialogAnimationPreset;
19
- /**
20
- * Slide up + opacity animation for dialogs.
21
- *
22
- * Entry slides up from below; exit slides up and out (asymmetric).
23
- * Includes backdrop fade animation.
24
- *
25
- * @param options.distance - Slide distance in pixels. Defaults to `12`.
26
- *
27
- * @example
28
- * ```tsx
29
- * import { dialogSlideUpAndFade } from '@atlaskit/top-layer/animations';
30
- *
31
- * const animation = dialogSlideUpAndFade();
32
- * <Dialog animate={animation} isOpen={isOpen} onClose={handleClose} label="...">
33
- * ...
34
- * </Dialog>
35
- * ```
36
- */
37
- export declare function dialogSlideUpAndFade(options?: {
38
- /**
39
- * Slide distance in pixels. Defaults to `12`.
40
- */
41
- distance?: number;
42
- }): TDialogAnimationPreset;
43
- /**
44
- * Simple opacity transition for dialogs, no transform.
45
- *
46
- * Includes backdrop fade animation.
47
- *
48
- * @example
49
- * ```tsx
50
- * import { dialogFade } from '@atlaskit/top-layer/animations';
51
- *
52
- * <Dialog animate={dialogFade()} isOpen={isOpen} onClose={handleClose} label="...">
53
- * ...
54
- * </Dialog>
55
- * ```
56
- */
57
- export declare function dialogFade(): TDialogAnimationPreset;