@atlaskit/top-layer 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/animations/presets.js +5 -0
  3. package/dist/cjs/internal/use-animated-visibility.js +84 -7
  4. package/dist/cjs/popover/popover.js +2 -0
  5. package/dist/cjs/popup/popup-content.js +53 -13
  6. package/dist/cjs/popup/popup-context.js +17 -0
  7. package/dist/cjs/popup/popup-trigger-function.js +7 -4
  8. package/dist/cjs/popup/popup-trigger.js +12 -7
  9. package/dist/cjs/popup/popup.js +5 -5
  10. package/dist/es2019/animations/presets.js +5 -0
  11. package/dist/es2019/internal/use-animated-visibility.js +84 -7
  12. package/dist/es2019/popover/popover.js +2 -0
  13. package/dist/es2019/popup/popup-content.js +53 -13
  14. package/dist/es2019/popup/popup-context.js +18 -0
  15. package/dist/es2019/popup/popup-trigger-function.js +7 -4
  16. package/dist/es2019/popup/popup-trigger.js +12 -7
  17. package/dist/es2019/popup/popup.js +3 -3
  18. package/dist/esm/animations/presets.js +5 -0
  19. package/dist/esm/internal/use-animated-visibility.js +84 -7
  20. package/dist/esm/popover/popover.js +2 -0
  21. package/dist/esm/popup/popup-content.js +53 -13
  22. package/dist/esm/popup/popup-context.js +18 -0
  23. package/dist/esm/popup/popup-trigger-function.js +7 -4
  24. package/dist/esm/popup/popup-trigger.js +12 -7
  25. package/dist/esm/popup/popup.js +5 -5
  26. package/dist/types/animations/types.d.ts +5 -1
  27. package/dist/types/internal/use-animated-visibility.d.ts +8 -2
  28. package/dist/types/popover/types.d.ts +8 -0
  29. package/dist/types/popup/popup-context.d.ts +24 -4
  30. package/dist/types/popup/types.d.ts +12 -0
  31. package/dist/types-ts4.5/animations/types.d.ts +5 -1
  32. package/dist/types-ts4.5/internal/use-animated-visibility.d.ts +8 -2
  33. package/dist/types-ts4.5/popover/types.d.ts +8 -0
  34. package/dist/types-ts4.5/popup/popup-context.d.ts +24 -4
  35. package/dist/types-ts4.5/popup/types.d.ts +12 -0
  36. package/package.json +1 -1
@@ -11,10 +11,16 @@ type TUseAnimatedVisibilityArgs = {
11
11
  */
12
12
  animate: TAnimationPreset | false | undefined;
13
13
  /**
14
- * Ref to the DOM element that plays the exit transition.
14
+ * Ref to the DOM element that plays the entry/exit transitions.
15
15
  * Used to listen for `transitionend`.
16
16
  */
17
17
  elementRef: RefObject<HTMLElement | null>;
18
+ /**
19
+ * Called after the entry animation completes (or immediately on open
20
+ * when there is no animation or reduced motion is active).
21
+ * This includes initial mount with `isOpen=true`.
22
+ */
23
+ onEnterFinish?: () => void;
18
24
  /**
19
25
  * Called after the exit animation completes (or immediately on close
20
26
  * when there is no animation or reduced motion is active).
@@ -70,5 +76,5 @@ type TUseAnimatedVisibilityResult = {
70
76
  * `isOpen` goes `false` → `showChildren` → `false` synchronously during
71
77
  * the same render → `onExitFinish` fires in a follow-up effect.
72
78
  */
73
- export declare function useAnimatedVisibility({ isOpen, animate, elementRef, onExitFinish, }: TUseAnimatedVisibilityArgs): TUseAnimatedVisibilityResult;
79
+ export declare function useAnimatedVisibility({ isOpen, animate, elementRef, onEnterFinish, onExitFinish, }: TUseAnimatedVisibilityArgs): TUseAnimatedVisibilityResult;
74
80
  export {};
@@ -105,6 +105,14 @@ type TPopoverBaseProps = {
105
105
  * This does NOT control positioning. Use `useAnchorPosition` for that.
106
106
  */
107
107
  placement?: TPlacementOptions;
108
+ /**
109
+ * Called after the entry animation completes (or immediately on open when
110
+ * there is no animation or reduced motion is active).
111
+ *
112
+ * Use this for external lifecycle coordination — e.g. notifying a manager
113
+ * that the show sequence is finished.
114
+ */
115
+ onEnterFinish?: () => void;
108
116
  /**
109
117
  * Called after the exit animation completes (or immediately on close when
110
118
  * there is no animation or reduced motion is active).
@@ -2,6 +2,23 @@ import React, { type MutableRefObject, type RefObject } from 'react';
2
2
  import { type TAriaHasPopupValue } from '../internal/role-types';
3
3
  import { type TPopoverCloseReason } from '../popover/types';
4
4
  import { type TPlacementOptions } from './types';
5
+ /**
6
+ * Represents the lifecycle state of the popup.
7
+ *
8
+ * - `'closed'`: fully closed, not visible, no animation playing.
9
+ * - `'animating-open'`: entry animation is playing (popup is opening but not yet settled).
10
+ * - `'open'`: fully open, browser popover is showing, entry animation complete.
11
+ * - `'animating-closed'`: exit animation is playing (popup is closing but still visible).
12
+ *
13
+ * Used to derive `aria-expanded` on the trigger:
14
+ * - `aria-expanded` is `true` in `'animating-open'`, `'open'`, and `'animating-closed'`.
15
+ *
16
+ * This avoids screen readers announcing the popup as closed while it is
17
+ * still visually present on screen during animations, and prevents consumers
18
+ * that conditionally show/hide trigger UI based on `aria-expanded` from hiding
19
+ * the trigger (and thus the popup anchor) mid-animation.
20
+ */
21
+ export type TPopupState = 'closed' | 'animating-open' | 'open' | 'animating-closed';
5
22
  export type TPopupContextValue = {
6
23
  /**
7
24
  * Auto-generated ID for the popover content element (used for aria-controls).
@@ -27,13 +44,16 @@ export type TPopupContextValue = {
27
44
  */
28
45
  popoverRef: RefObject<HTMLDivElement | null>;
29
46
  /**
30
- * Whether the popover is currently open.
47
+ * The full lifecycle state of the popup.
48
+ *
49
+ * See `TPopupState` for the full state machine description.
31
50
  */
32
- isOpen: boolean;
51
+ popupState: TPopupState;
33
52
  /**
34
- * Set the open state (internal context sync).
53
+ * Updates the popup lifecycle state. Called by `PopupContent` as animations
54
+ * begin and complete.
35
55
  */
36
- setIsOpen: (open: boolean) => void;
56
+ setPopupState: (state: TPopupState) => void;
37
57
  /**
38
58
  * Consumer's onOpenChange callback, forwarded to the Popover.
39
59
  */
@@ -258,6 +258,18 @@ type TPopupContentBaseProps = {
258
258
  * ```
259
259
  */
260
260
  isOpen?: boolean;
261
+ /**
262
+ * Called after the entry animation completes (or immediately on open when
263
+ * there is no animation). Use this for lifecycle coordination that must
264
+ * happen after the popup has fully animated in.
265
+ */
266
+ onEnterFinish?: () => void;
267
+ /**
268
+ * Called after the exit animation completes (or immediately on close when
269
+ * there is no animation). Use this for lifecycle coordination that must
270
+ * happen after the popup has fully animated out.
271
+ */
272
+ onExitFinish?: () => void;
261
273
  };
262
274
  /**
263
275
  * Popup content props.
@@ -28,7 +28,11 @@ export type TAnimationPreset = {
28
28
  placement: TPlacementOptions;
29
29
  }) => Record<string, string>;
30
30
  /**
31
- * Exit duration in ms (for `transitionend` fallback timeout).
31
+ * Entry duration in ms (for `transitionend` fallback timeout on open).
32
+ */
33
+ enterDurationMs: number;
34
+ /**
35
+ * Exit duration in ms (for `transitionend` fallback timeout on close).
32
36
  */
33
37
  exitDurationMs: number;
34
38
  };
@@ -11,10 +11,16 @@ type TUseAnimatedVisibilityArgs = {
11
11
  */
12
12
  animate: TAnimationPreset | false | undefined;
13
13
  /**
14
- * Ref to the DOM element that plays the exit transition.
14
+ * Ref to the DOM element that plays the entry/exit transitions.
15
15
  * Used to listen for `transitionend`.
16
16
  */
17
17
  elementRef: RefObject<HTMLElement | null>;
18
+ /**
19
+ * Called after the entry animation completes (or immediately on open
20
+ * when there is no animation or reduced motion is active).
21
+ * This includes initial mount with `isOpen=true`.
22
+ */
23
+ onEnterFinish?: () => void;
18
24
  /**
19
25
  * Called after the exit animation completes (or immediately on close
20
26
  * when there is no animation or reduced motion is active).
@@ -70,5 +76,5 @@ type TUseAnimatedVisibilityResult = {
70
76
  * `isOpen` goes `false` → `showChildren` → `false` synchronously during
71
77
  * the same render → `onExitFinish` fires in a follow-up effect.
72
78
  */
73
- export declare function useAnimatedVisibility({ isOpen, animate, elementRef, onExitFinish, }: TUseAnimatedVisibilityArgs): TUseAnimatedVisibilityResult;
79
+ export declare function useAnimatedVisibility({ isOpen, animate, elementRef, onEnterFinish, onExitFinish, }: TUseAnimatedVisibilityArgs): TUseAnimatedVisibilityResult;
74
80
  export {};
@@ -105,6 +105,14 @@ type TPopoverBaseProps = {
105
105
  * This does NOT control positioning. Use `useAnchorPosition` for that.
106
106
  */
107
107
  placement?: TPlacementOptions;
108
+ /**
109
+ * Called after the entry animation completes (or immediately on open when
110
+ * there is no animation or reduced motion is active).
111
+ *
112
+ * Use this for external lifecycle coordination — e.g. notifying a manager
113
+ * that the show sequence is finished.
114
+ */
115
+ onEnterFinish?: () => void;
108
116
  /**
109
117
  * Called after the exit animation completes (or immediately on close when
110
118
  * there is no animation or reduced motion is active).
@@ -2,6 +2,23 @@ import React, { type MutableRefObject, type RefObject } from 'react';
2
2
  import { type TAriaHasPopupValue } from '../internal/role-types';
3
3
  import { type TPopoverCloseReason } from '../popover/types';
4
4
  import { type TPlacementOptions } from './types';
5
+ /**
6
+ * Represents the lifecycle state of the popup.
7
+ *
8
+ * - `'closed'`: fully closed, not visible, no animation playing.
9
+ * - `'animating-open'`: entry animation is playing (popup is opening but not yet settled).
10
+ * - `'open'`: fully open, browser popover is showing, entry animation complete.
11
+ * - `'animating-closed'`: exit animation is playing (popup is closing but still visible).
12
+ *
13
+ * Used to derive `aria-expanded` on the trigger:
14
+ * - `aria-expanded` is `true` in `'animating-open'`, `'open'`, and `'animating-closed'`.
15
+ *
16
+ * This avoids screen readers announcing the popup as closed while it is
17
+ * still visually present on screen during animations, and prevents consumers
18
+ * that conditionally show/hide trigger UI based on `aria-expanded` from hiding
19
+ * the trigger (and thus the popup anchor) mid-animation.
20
+ */
21
+ export type TPopupState = 'closed' | 'animating-open' | 'open' | 'animating-closed';
5
22
  export type TPopupContextValue = {
6
23
  /**
7
24
  * Auto-generated ID for the popover content element (used for aria-controls).
@@ -27,13 +44,16 @@ export type TPopupContextValue = {
27
44
  */
28
45
  popoverRef: RefObject<HTMLDivElement | null>;
29
46
  /**
30
- * Whether the popover is currently open.
47
+ * The full lifecycle state of the popup.
48
+ *
49
+ * See `TPopupState` for the full state machine description.
31
50
  */
32
- isOpen: boolean;
51
+ popupState: TPopupState;
33
52
  /**
34
- * Set the open state (internal context sync).
53
+ * Updates the popup lifecycle state. Called by `PopupContent` as animations
54
+ * begin and complete.
35
55
  */
36
- setIsOpen: (open: boolean) => void;
56
+ setPopupState: (state: TPopupState) => void;
37
57
  /**
38
58
  * Consumer's onOpenChange callback, forwarded to the Popover.
39
59
  */
@@ -258,6 +258,18 @@ type TPopupContentBaseProps = {
258
258
  * ```
259
259
  */
260
260
  isOpen?: boolean;
261
+ /**
262
+ * Called after the entry animation completes (or immediately on open when
263
+ * there is no animation). Use this for lifecycle coordination that must
264
+ * happen after the popup has fully animated in.
265
+ */
266
+ onEnterFinish?: () => void;
267
+ /**
268
+ * Called after the exit animation completes (or immediately on close when
269
+ * there is no animation). Use this for lifecycle coordination that must
270
+ * happen after the popup has fully animated out.
271
+ */
272
+ onExitFinish?: () => void;
261
273
  };
262
274
  /**
263
275
  * Popup content props.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/top-layer",
3
- "version": "0.11.0",
3
+ "version": "0.12.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",