@atlaskit/top-layer 0.11.0 → 0.12.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.
- package/CHANGELOG.md +24 -0
- package/dist/cjs/animations/presets.js +5 -0
- package/dist/cjs/entry-points/use-arrow-navigation.js +3 -2
- package/dist/cjs/internal/placement-to-position-area.js +43 -0
- package/dist/cjs/internal/placement-to-try-fallbacks.js +82 -0
- package/dist/cjs/internal/use-anchor-position.js +18 -131
- package/dist/cjs/internal/use-animated-visibility.js +84 -7
- package/dist/cjs/popover/popover.js +2 -0
- package/dist/cjs/popup/popup-content.js +55 -15
- package/dist/cjs/popup/popup-context.js +14 -33
- package/dist/cjs/popup/popup-provider.js +15 -0
- package/dist/cjs/popup/popup-trigger-function.js +9 -6
- package/dist/cjs/popup/popup-trigger.js +14 -9
- package/dist/cjs/popup/popup.js +7 -7
- package/dist/cjs/popup/use-maybe-popup-context.js +17 -0
- package/dist/cjs/popup/use-popup-context.js +20 -0
- package/dist/cjs/use-arrow-navigation/index.js +3 -2
- package/dist/cjs/use-arrow-navigation/is-at-current-menu-level.js +87 -0
- package/dist/cjs/use-arrow-navigation/use-arrow-navigation.js +0 -82
- package/dist/es2019/animations/presets.js +5 -0
- package/dist/es2019/entry-points/use-arrow-navigation.js +2 -1
- package/dist/es2019/internal/placement-to-position-area.js +40 -0
- package/dist/es2019/internal/placement-to-try-fallbacks.js +77 -0
- package/dist/es2019/internal/use-anchor-position.js +2 -116
- package/dist/es2019/internal/use-animated-visibility.js +84 -7
- package/dist/es2019/popover/popover.js +2 -0
- package/dist/es2019/popup/popup-content.js +55 -14
- package/dist/es2019/popup/popup-context.js +14 -30
- package/dist/es2019/popup/popup-provider.js +10 -0
- package/dist/es2019/popup/popup-trigger-function.js +8 -5
- package/dist/es2019/popup/popup-trigger.js +14 -8
- package/dist/es2019/popup/popup.js +4 -4
- package/dist/es2019/popup/use-maybe-popup-context.js +12 -0
- package/dist/es2019/popup/use-popup-context.js +15 -0
- package/dist/es2019/use-arrow-navigation/index.js +2 -1
- package/dist/es2019/use-arrow-navigation/is-at-current-menu-level.js +81 -0
- package/dist/es2019/use-arrow-navigation/use-arrow-navigation.js +0 -81
- package/dist/esm/animations/presets.js +5 -0
- package/dist/esm/entry-points/use-arrow-navigation.js +2 -1
- package/dist/esm/internal/placement-to-position-area.js +38 -0
- package/dist/esm/internal/placement-to-try-fallbacks.js +76 -0
- package/dist/esm/internal/use-anchor-position.js +16 -127
- package/dist/esm/internal/use-animated-visibility.js +84 -7
- package/dist/esm/popover/popover.js +2 -0
- package/dist/esm/popup/popup-content.js +55 -14
- package/dist/esm/popup/popup-context.js +14 -30
- package/dist/esm/popup/popup-provider.js +10 -0
- package/dist/esm/popup/popup-trigger-function.js +8 -5
- package/dist/esm/popup/popup-trigger.js +14 -8
- package/dist/esm/popup/popup.js +6 -6
- package/dist/esm/popup/use-maybe-popup-context.js +12 -0
- package/dist/esm/popup/use-popup-context.js +15 -0
- package/dist/esm/use-arrow-navigation/index.js +2 -1
- package/dist/esm/use-arrow-navigation/is-at-current-menu-level.js +81 -0
- package/dist/esm/use-arrow-navigation/use-arrow-navigation.js +0 -81
- package/dist/types/animations/types.d.ts +5 -1
- package/dist/types/entry-points/use-arrow-navigation.d.ts +2 -1
- package/dist/types/internal/placement-to-position-area.d.ts +21 -0
- package/dist/types/internal/placement-to-try-fallbacks.d.ts +36 -0
- package/dist/types/internal/use-anchor-position.d.ts +0 -55
- package/dist/types/internal/use-animated-visibility.d.ts +8 -2
- package/dist/types/popover/types.d.ts +8 -0
- package/dist/types/popup/popup-context.d.ts +25 -25
- package/dist/types/popup/popup-provider.d.ts +10 -0
- package/dist/types/popup/types.d.ts +12 -0
- package/dist/types/popup/use-maybe-popup-context.d.ts +8 -0
- package/dist/types/popup/use-popup-context.d.ts +7 -0
- package/dist/types/use-arrow-navigation/index.d.ts +2 -1
- package/dist/types/use-arrow-navigation/is-at-current-menu-level.d.ts +48 -0
- package/dist/types/use-arrow-navigation/use-arrow-navigation.d.ts +0 -48
- package/dist/types-ts4.5/animations/types.d.ts +5 -1
- package/dist/types-ts4.5/entry-points/use-arrow-navigation.d.ts +2 -1
- package/dist/types-ts4.5/internal/placement-to-position-area.d.ts +21 -0
- package/dist/types-ts4.5/internal/placement-to-try-fallbacks.d.ts +36 -0
- package/dist/types-ts4.5/internal/use-anchor-position.d.ts +0 -55
- package/dist/types-ts4.5/internal/use-animated-visibility.d.ts +8 -2
- package/dist/types-ts4.5/popover/types.d.ts +8 -0
- package/dist/types-ts4.5/popup/popup-context.d.ts +25 -25
- package/dist/types-ts4.5/popup/popup-provider.d.ts +10 -0
- package/dist/types-ts4.5/popup/types.d.ts +12 -0
- package/dist/types-ts4.5/popup/use-maybe-popup-context.d.ts +8 -0
- package/dist/types-ts4.5/popup/use-popup-context.d.ts +7 -0
- package/dist/types-ts4.5/use-arrow-navigation/index.d.ts +2 -1
- package/dist/types-ts4.5/use-arrow-navigation/is-at-current-menu-level.d.ts +48 -0
- package/dist/types-ts4.5/use-arrow-navigation/use-arrow-navigation.d.ts +0 -48
- package/package.json +2 -2
- package/dist/cjs/arrow/index.js +0 -131
- package/dist/cjs/arrow/types.js +0 -5
- package/dist/es2019/arrow/index.js +0 -269
- package/dist/es2019/arrow/types.js +0 -1
- package/dist/esm/arrow/index.js +0 -124
- package/dist/esm/arrow/types.js +0 -1
- package/dist/types/arrow/index.d.ts +0 -24
- package/dist/types/arrow/types.d.ts +0 -29
- package/dist/types-ts4.5/arrow/index.d.ts +0 -24
- package/dist/types-ts4.5/arrow/types.d.ts +0 -29
|
@@ -28,7 +28,11 @@ export type TAnimationPreset = {
|
|
|
28
28
|
placement: TPlacementOptions;
|
|
29
29
|
}) => Record<string, string>;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
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
|
};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { useArrowNavigation
|
|
1
|
+
export { useArrowNavigation } from '../use-arrow-navigation';
|
|
2
2
|
export type { TUseArrowNavigationArgs } from '../use-arrow-navigation';
|
|
3
|
+
export { isAtCurrentMenuLevel } from '../use-arrow-navigation/is-at-current-menu-level';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type TPlacementOptions } from '../internal/resolve-placement';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves placement options to CSS `position-area` syntax.
|
|
4
|
+
*
|
|
5
|
+
* The `align` field represents the *visual* alignment:
|
|
6
|
+
* - `align: 'start'` means "aligned to the trigger's start edge" (left in LTR for block axis)
|
|
7
|
+
* - `align: 'end'` means "aligned to the trigger's end edge"
|
|
8
|
+
* - `align: 'center'` means centered (single-axis position-area)
|
|
9
|
+
*
|
|
10
|
+
* CSS `position-area` uses `span-*` keywords which indicate the *expansion direction*.
|
|
11
|
+
* Visual start-alignment requires `span-{cross-axis}-end` (expand toward end = start-aligned).
|
|
12
|
+
* This function handles the inversion internally.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* placementToPositionArea({ placement: { axis: 'block', edge: 'end', align: 'center' } }) // → 'block-end'
|
|
16
|
+
* placementToPositionArea({ placement: { axis: 'block', edge: 'end', align: 'start' } }) // → 'block-end span-inline-end'
|
|
17
|
+
* placementToPositionArea({ placement: { axis: 'block', edge: 'end', align: 'end' } }) // → 'block-end span-inline-start'
|
|
18
|
+
*/
|
|
19
|
+
export declare function placementToPositionArea({ placement }: {
|
|
20
|
+
placement: TPlacementOptions;
|
|
21
|
+
}): string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type TPlacementOptions } from '../internal/resolve-placement';
|
|
2
|
+
/**
|
|
3
|
+
* Returns `position-try-fallbacks` value based on placement.
|
|
4
|
+
*
|
|
5
|
+
* For centered placements, includes cross-axis aligned position-area
|
|
6
|
+
* values so the browser can shift the popover along the cross-axis
|
|
7
|
+
* when the centered position would overflow the viewport edge.
|
|
8
|
+
*
|
|
9
|
+
* Fallback order for centered placements (e.g. `block-end`):
|
|
10
|
+
* 1. Same edge, start-aligned (shift for near-edge overflow)
|
|
11
|
+
* 2. Same edge, end-aligned (shift for far-edge overflow)
|
|
12
|
+
* 3. Flipped edge, centered
|
|
13
|
+
* 4. Flipped edge, start-aligned
|
|
14
|
+
* 5. Flipped edge, end-aligned
|
|
15
|
+
*
|
|
16
|
+
* For aligned placements (start/end), includes the same-edge centered
|
|
17
|
+
* position as fallbacks so the browser can try centering when the aligned
|
|
18
|
+
* position would overflow, before flipping to the opposite edge.
|
|
19
|
+
*
|
|
20
|
+
* **Why `flip-inline flip-block` (or `flip-block flip-inline`) is included:**
|
|
21
|
+
*
|
|
22
|
+
* When a popup is in a viewport corner (e.g. inline-end align-end at the
|
|
23
|
+
* top-right), flipping only the primary axis (`flip-inline`) moves the popup
|
|
24
|
+
* to the left but keeps the same cross-axis span direction (e.g. upward),
|
|
25
|
+
* which is still off-screen. The combined keyword `flip-inline flip-block`
|
|
26
|
+
* mirrors the popup diagonally. It flips BOTH the position-area AND both
|
|
27
|
+
* inline and block margins simultaneously, placing the popup at the
|
|
28
|
+
* diagonally opposite corner where there is always space.
|
|
29
|
+
*
|
|
30
|
+
* Named `position-area` entries (e.g. `inline-start span-block-end`) in
|
|
31
|
+
* `position-try-fallbacks` do NOT update margins, so only the `flip-*`
|
|
32
|
+
* tactic keywords correctly flip the gap margin along with the position.
|
|
33
|
+
*/
|
|
34
|
+
export declare function placementToTryFallbacks({ placement }: {
|
|
35
|
+
placement: TPlacementOptions;
|
|
36
|
+
}): string;
|
|
@@ -14,61 +14,6 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { type RefObject } from 'react';
|
|
16
16
|
import { type TPlacementOptions } from '../internal/resolve-placement';
|
|
17
|
-
/**
|
|
18
|
-
* Resolves placement options to CSS `position-area` syntax.
|
|
19
|
-
*
|
|
20
|
-
* The `align` field represents the *visual* alignment:
|
|
21
|
-
* - `align: 'start'` means "aligned to the trigger's start edge" (left in LTR for block axis)
|
|
22
|
-
* - `align: 'end'` means "aligned to the trigger's end edge"
|
|
23
|
-
* - `align: 'center'` means centered (single-axis position-area)
|
|
24
|
-
*
|
|
25
|
-
* CSS `position-area` uses `span-*` keywords which indicate the *expansion direction*.
|
|
26
|
-
* Visual start-alignment requires `span-{cross-axis}-end` (expand toward end = start-aligned).
|
|
27
|
-
* This function handles the inversion internally.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* placementToPositionArea({ placement: { axis: 'block', edge: 'end', align: 'center' } }) // → 'block-end'
|
|
31
|
-
* placementToPositionArea({ placement: { axis: 'block', edge: 'end', align: 'start' } }) // → 'block-end span-inline-end'
|
|
32
|
-
* placementToPositionArea({ placement: { axis: 'block', edge: 'end', align: 'end' } }) // → 'block-end span-inline-start'
|
|
33
|
-
*/
|
|
34
|
-
export declare function placementToPositionArea({ placement }: {
|
|
35
|
-
placement: TPlacementOptions;
|
|
36
|
-
}): string;
|
|
37
|
-
/**
|
|
38
|
-
* Returns `position-try-fallbacks` value based on placement.
|
|
39
|
-
*
|
|
40
|
-
* For centered placements, includes cross-axis aligned position-area
|
|
41
|
-
* values so the browser can shift the popover along the cross-axis
|
|
42
|
-
* when the centered position would overflow the viewport edge.
|
|
43
|
-
*
|
|
44
|
-
* Fallback order for centered placements (e.g. `block-end`):
|
|
45
|
-
* 1. Same edge, start-aligned (shift for near-edge overflow)
|
|
46
|
-
* 2. Same edge, end-aligned (shift for far-edge overflow)
|
|
47
|
-
* 3. Flipped edge, centered
|
|
48
|
-
* 4. Flipped edge, start-aligned
|
|
49
|
-
* 5. Flipped edge, end-aligned
|
|
50
|
-
*
|
|
51
|
-
* For aligned placements (start/end), includes the same-edge centered
|
|
52
|
-
* position as fallbacks so the browser can try centering when the aligned
|
|
53
|
-
* position would overflow, before flipping to the opposite edge.
|
|
54
|
-
*
|
|
55
|
-
* **Why `flip-inline flip-block` (or `flip-block flip-inline`) is included:**
|
|
56
|
-
*
|
|
57
|
-
* When a popup is in a viewport corner (e.g. inline-end align-end at the
|
|
58
|
-
* top-right), flipping only the primary axis (`flip-inline`) moves the popup
|
|
59
|
-
* to the left but keeps the same cross-axis span direction (e.g. upward),
|
|
60
|
-
* which is still off-screen. The combined keyword `flip-inline flip-block`
|
|
61
|
-
* mirrors the popup diagonally. It flips BOTH the position-area AND both
|
|
62
|
-
* inline and block margins simultaneously, placing the popup at the
|
|
63
|
-
* diagonally opposite corner where there is always space.
|
|
64
|
-
*
|
|
65
|
-
* Named `position-area` entries (e.g. `inline-start span-block-end`) in
|
|
66
|
-
* `position-try-fallbacks` do NOT update margins, so only the `flip-*`
|
|
67
|
-
* tactic keywords correctly flip the gap margin along with the position.
|
|
68
|
-
*/
|
|
69
|
-
export declare function placementToTryFallbacks({ placement }: {
|
|
70
|
-
placement: TPlacementOptions;
|
|
71
|
-
}): string;
|
|
72
17
|
/**
|
|
73
18
|
* Hook that positions an element relative to an anchor element using
|
|
74
19
|
* CSS Anchor Positioning (with a JS fallback for older browsers).
|
|
@@ -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
|
|
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
|
-
*
|
|
47
|
+
* The full lifecycle state of the popup.
|
|
48
|
+
*
|
|
49
|
+
* See `TPopupState` for the full state machine description.
|
|
31
50
|
*/
|
|
32
|
-
|
|
51
|
+
popupState: TPopupState;
|
|
33
52
|
/**
|
|
34
|
-
*
|
|
53
|
+
* Updates the popup lifecycle state. Called by `PopupContent` as animations
|
|
54
|
+
* begin and complete.
|
|
35
55
|
*/
|
|
36
|
-
|
|
56
|
+
setPopupState: (state: TPopupState) => void;
|
|
37
57
|
/**
|
|
38
58
|
* Consumer's onOpenChange callback, forwarded to the Popover.
|
|
39
59
|
*/
|
|
@@ -73,24 +93,4 @@ export type TPopupContextValue = {
|
|
|
73
93
|
*/
|
|
74
94
|
forceFallbackPositioning?: boolean;
|
|
75
95
|
};
|
|
76
|
-
|
|
77
|
-
* __Popup provider__
|
|
78
|
-
*
|
|
79
|
-
* Provides shared popup state (placement, popoverId, triggerRef,
|
|
80
|
-
* isOpen, onClose) to compound child components such as `Popup.Trigger` and
|
|
81
|
-
* `Popup.Content`.
|
|
82
|
-
*/
|
|
83
|
-
export declare const PopupProvider: React.Provider<TPopupContextValue | null>;
|
|
84
|
-
/**
|
|
85
|
-
* Returns the nearest `Popup` context value.
|
|
86
|
-
*
|
|
87
|
-
* Throws if called outside of a `<Popup>` compound component.
|
|
88
|
-
*/
|
|
89
|
-
export declare function usePopupContext(): TPopupContextValue;
|
|
90
|
-
/**
|
|
91
|
-
* Returns the popup context if available, or `null` when used outside `<Popup>`.
|
|
92
|
-
*
|
|
93
|
-
* Used by `PopupContent` to support standalone usage (e.g. tooltip)
|
|
94
|
-
* where values are passed as props instead of coming from a compound component.
|
|
95
|
-
*/
|
|
96
|
-
export declare function useMaybePopupContext(): TPopupContextValue | null;
|
|
96
|
+
export declare const PopupContext: React.Context<TPopupContextValue | null>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Provider } from 'react';
|
|
2
|
+
import { type TPopupContextValue } from './popup-context';
|
|
3
|
+
/**
|
|
4
|
+
* __Popup provider__
|
|
5
|
+
*
|
|
6
|
+
* Provides shared popup state (placement, popoverId, triggerRef,
|
|
7
|
+
* isOpen, onClose) to compound child components such as `Popup.Trigger` and
|
|
8
|
+
* `Popup.Content`.
|
|
9
|
+
*/
|
|
10
|
+
export declare const PopupProvider: Provider<TPopupContextValue | null>;
|
|
@@ -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.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type TPopupContextValue } from './popup-context';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the popup context if available, or `null` when used outside `<Popup>`.
|
|
4
|
+
*
|
|
5
|
+
* Used by `PopupContent` to support standalone usage (e.g. tooltip)
|
|
6
|
+
* where values are passed as props instead of coming from a compound component.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useMaybePopupContext(): TPopupContextValue | null;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { useArrowNavigation
|
|
1
|
+
export { useArrowNavigation } from './use-arrow-navigation';
|
|
2
2
|
export type { TUseArrowNavigationArgs } from './use-arrow-navigation';
|
|
3
|
+
export { isAtCurrentMenuLevel } from './is-at-current-menu-level';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true if the element belongs to the current menu level of the
|
|
3
|
+
* container, i.e. it is NOT inside a nested `role="menu"` sub-container.
|
|
4
|
+
*
|
|
5
|
+
* Uses `element.closest('[role="menu"]')` to determine the nearest menu
|
|
6
|
+
* scope. If the nearest scope is the container's own `role="menu"` element,
|
|
7
|
+
* the element belongs to this level. If it is a different (nested) menu,
|
|
8
|
+
* the element belongs to a child level and should be excluded.
|
|
9
|
+
*
|
|
10
|
+
* Supports two container patterns:
|
|
11
|
+
*
|
|
12
|
+
* **1. Container has `role="menu"` directly** (preferred, used by avatar-group):
|
|
13
|
+
* ```
|
|
14
|
+
* <div ref={containerRef} role="menu">
|
|
15
|
+
* <button role="menuitem" /> ← isAtCurrentMenuLevel → true
|
|
16
|
+
* <div role="menu"> ← nested sub-menu
|
|
17
|
+
* <button role="menuitem" /> ← isAtCurrentMenuLevel → false
|
|
18
|
+
* </div>
|
|
19
|
+
* </div>
|
|
20
|
+
* ```
|
|
21
|
+
* Uses the simple check: `element.closest('[role="menu"]') === container`
|
|
22
|
+
*
|
|
23
|
+
* **2. Container is a wrapper without `role="menu"`** (used by dropdown-menu,
|
|
24
|
+
* where `MenuGroup` owns `role="menu"` but does not accept a ref):
|
|
25
|
+
* ```
|
|
26
|
+
* <div ref={containerRef}> ← wrapper (no role="menu")
|
|
27
|
+
* <MenuGroup role="menu">
|
|
28
|
+
* <button role="menuitem" /> ← isAtCurrentMenuLevel → true
|
|
29
|
+
* <div role="menu"> ← nested sub-menu
|
|
30
|
+
* <button role="menuitem" /> ← isAtCurrentMenuLevel → false
|
|
31
|
+
* </div>
|
|
32
|
+
* </MenuGroup>
|
|
33
|
+
* </div>
|
|
34
|
+
* ```
|
|
35
|
+
* Falls back to walking the DOM to check that the element's closest
|
|
36
|
+
* `role="menu"` is the container's own menu (not doubly nested).
|
|
37
|
+
*
|
|
38
|
+
* Ideally all consumers should use pattern 1 (place the ref directly on the
|
|
39
|
+
* `role="menu"` element). Pattern 2 exists because `@atlaskit/menu`'s
|
|
40
|
+
* `MenuGroup` does not currently accept a ref. If `MenuGroup` gains ref
|
|
41
|
+
* support in the future, dropdown-menu should switch to pattern 1 and the
|
|
42
|
+
* fallback path can be removed.
|
|
43
|
+
*
|
|
44
|
+
* Used both as a `TFocusableFilter` (to scope getNextFocusable etc.) and as
|
|
45
|
+
* a guard to prevent parent menu handlers from acting on events that
|
|
46
|
+
* belong to a nested menu.
|
|
47
|
+
*/
|
|
48
|
+
export declare function isAtCurrentMenuLevel(element: Element, container: HTMLElement): boolean;
|
|
@@ -1,53 +1,5 @@
|
|
|
1
1
|
import { type RefObject } from 'react';
|
|
2
2
|
import { type TFocusableFilter } from '../focus';
|
|
3
|
-
/**
|
|
4
|
-
* Returns true if the element belongs to the current menu level of the
|
|
5
|
-
* container, i.e. it is NOT inside a nested `role="menu"` sub-container.
|
|
6
|
-
*
|
|
7
|
-
* Uses `element.closest('[role="menu"]')` to determine the nearest menu
|
|
8
|
-
* scope. If the nearest scope is the container's own `role="menu"` element,
|
|
9
|
-
* the element belongs to this level. If it is a different (nested) menu,
|
|
10
|
-
* the element belongs to a child level and should be excluded.
|
|
11
|
-
*
|
|
12
|
-
* Supports two container patterns:
|
|
13
|
-
*
|
|
14
|
-
* **1. Container has `role="menu"` directly** (preferred, used by avatar-group):
|
|
15
|
-
* ```
|
|
16
|
-
* <div ref={containerRef} role="menu">
|
|
17
|
-
* <button role="menuitem" /> ← isAtCurrentMenuLevel → true
|
|
18
|
-
* <div role="menu"> ← nested sub-menu
|
|
19
|
-
* <button role="menuitem" /> ← isAtCurrentMenuLevel → false
|
|
20
|
-
* </div>
|
|
21
|
-
* </div>
|
|
22
|
-
* ```
|
|
23
|
-
* Uses the simple check: `element.closest('[role="menu"]') === container`
|
|
24
|
-
*
|
|
25
|
-
* **2. Container is a wrapper without `role="menu"`** (used by dropdown-menu,
|
|
26
|
-
* where `MenuGroup` owns `role="menu"` but does not accept a ref):
|
|
27
|
-
* ```
|
|
28
|
-
* <div ref={containerRef}> ← wrapper (no role="menu")
|
|
29
|
-
* <MenuGroup role="menu">
|
|
30
|
-
* <button role="menuitem" /> ← isAtCurrentMenuLevel → true
|
|
31
|
-
* <div role="menu"> ← nested sub-menu
|
|
32
|
-
* <button role="menuitem" /> ← isAtCurrentMenuLevel → false
|
|
33
|
-
* </div>
|
|
34
|
-
* </MenuGroup>
|
|
35
|
-
* </div>
|
|
36
|
-
* ```
|
|
37
|
-
* Falls back to walking the DOM to check that the element's closest
|
|
38
|
-
* `role="menu"` is the container's own menu (not doubly nested).
|
|
39
|
-
*
|
|
40
|
-
* Ideally all consumers should use pattern 1 (place the ref directly on the
|
|
41
|
-
* `role="menu"` element). Pattern 2 exists because `@atlaskit/menu`'s
|
|
42
|
-
* `MenuGroup` does not currently accept a ref. If `MenuGroup` gains ref
|
|
43
|
-
* support in the future, dropdown-menu should switch to pattern 1 and the
|
|
44
|
-
* fallback path can be removed.
|
|
45
|
-
*
|
|
46
|
-
* Used both as a `TFocusableFilter` (to scope getNextFocusable etc.) and as
|
|
47
|
-
* a guard to prevent parent menu handlers from acting on events that
|
|
48
|
-
* belong to a nested menu.
|
|
49
|
-
*/
|
|
50
|
-
export declare function isAtCurrentMenuLevel(element: Element, container: HTMLElement): boolean;
|
|
51
3
|
/**
|
|
52
4
|
* Args for `useArrowNavigation`.
|
|
53
5
|
*
|
|
@@ -28,7 +28,11 @@ export type TAnimationPreset = {
|
|
|
28
28
|
placement: TPlacementOptions;
|
|
29
29
|
}) => Record<string, string>;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
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
|
};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { useArrowNavigation
|
|
1
|
+
export { useArrowNavigation } from '../use-arrow-navigation';
|
|
2
2
|
export type { TUseArrowNavigationArgs } from '../use-arrow-navigation';
|
|
3
|
+
export { isAtCurrentMenuLevel } from '../use-arrow-navigation/is-at-current-menu-level';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type TPlacementOptions } from '../internal/resolve-placement';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves placement options to CSS `position-area` syntax.
|
|
4
|
+
*
|
|
5
|
+
* The `align` field represents the *visual* alignment:
|
|
6
|
+
* - `align: 'start'` means "aligned to the trigger's start edge" (left in LTR for block axis)
|
|
7
|
+
* - `align: 'end'` means "aligned to the trigger's end edge"
|
|
8
|
+
* - `align: 'center'` means centered (single-axis position-area)
|
|
9
|
+
*
|
|
10
|
+
* CSS `position-area` uses `span-*` keywords which indicate the *expansion direction*.
|
|
11
|
+
* Visual start-alignment requires `span-{cross-axis}-end` (expand toward end = start-aligned).
|
|
12
|
+
* This function handles the inversion internally.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* placementToPositionArea({ placement: { axis: 'block', edge: 'end', align: 'center' } }) // → 'block-end'
|
|
16
|
+
* placementToPositionArea({ placement: { axis: 'block', edge: 'end', align: 'start' } }) // → 'block-end span-inline-end'
|
|
17
|
+
* placementToPositionArea({ placement: { axis: 'block', edge: 'end', align: 'end' } }) // → 'block-end span-inline-start'
|
|
18
|
+
*/
|
|
19
|
+
export declare function placementToPositionArea({ placement }: {
|
|
20
|
+
placement: TPlacementOptions;
|
|
21
|
+
}): string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type TPlacementOptions } from '../internal/resolve-placement';
|
|
2
|
+
/**
|
|
3
|
+
* Returns `position-try-fallbacks` value based on placement.
|
|
4
|
+
*
|
|
5
|
+
* For centered placements, includes cross-axis aligned position-area
|
|
6
|
+
* values so the browser can shift the popover along the cross-axis
|
|
7
|
+
* when the centered position would overflow the viewport edge.
|
|
8
|
+
*
|
|
9
|
+
* Fallback order for centered placements (e.g. `block-end`):
|
|
10
|
+
* 1. Same edge, start-aligned (shift for near-edge overflow)
|
|
11
|
+
* 2. Same edge, end-aligned (shift for far-edge overflow)
|
|
12
|
+
* 3. Flipped edge, centered
|
|
13
|
+
* 4. Flipped edge, start-aligned
|
|
14
|
+
* 5. Flipped edge, end-aligned
|
|
15
|
+
*
|
|
16
|
+
* For aligned placements (start/end), includes the same-edge centered
|
|
17
|
+
* position as fallbacks so the browser can try centering when the aligned
|
|
18
|
+
* position would overflow, before flipping to the opposite edge.
|
|
19
|
+
*
|
|
20
|
+
* **Why `flip-inline flip-block` (or `flip-block flip-inline`) is included:**
|
|
21
|
+
*
|
|
22
|
+
* When a popup is in a viewport corner (e.g. inline-end align-end at the
|
|
23
|
+
* top-right), flipping only the primary axis (`flip-inline`) moves the popup
|
|
24
|
+
* to the left but keeps the same cross-axis span direction (e.g. upward),
|
|
25
|
+
* which is still off-screen. The combined keyword `flip-inline flip-block`
|
|
26
|
+
* mirrors the popup diagonally. It flips BOTH the position-area AND both
|
|
27
|
+
* inline and block margins simultaneously, placing the popup at the
|
|
28
|
+
* diagonally opposite corner where there is always space.
|
|
29
|
+
*
|
|
30
|
+
* Named `position-area` entries (e.g. `inline-start span-block-end`) in
|
|
31
|
+
* `position-try-fallbacks` do NOT update margins, so only the `flip-*`
|
|
32
|
+
* tactic keywords correctly flip the gap margin along with the position.
|
|
33
|
+
*/
|
|
34
|
+
export declare function placementToTryFallbacks({ placement }: {
|
|
35
|
+
placement: TPlacementOptions;
|
|
36
|
+
}): string;
|
|
@@ -14,61 +14,6 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { type RefObject } from 'react';
|
|
16
16
|
import { type TPlacementOptions } from '../internal/resolve-placement';
|
|
17
|
-
/**
|
|
18
|
-
* Resolves placement options to CSS `position-area` syntax.
|
|
19
|
-
*
|
|
20
|
-
* The `align` field represents the *visual* alignment:
|
|
21
|
-
* - `align: 'start'` means "aligned to the trigger's start edge" (left in LTR for block axis)
|
|
22
|
-
* - `align: 'end'` means "aligned to the trigger's end edge"
|
|
23
|
-
* - `align: 'center'` means centered (single-axis position-area)
|
|
24
|
-
*
|
|
25
|
-
* CSS `position-area` uses `span-*` keywords which indicate the *expansion direction*.
|
|
26
|
-
* Visual start-alignment requires `span-{cross-axis}-end` (expand toward end = start-aligned).
|
|
27
|
-
* This function handles the inversion internally.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* placementToPositionArea({ placement: { axis: 'block', edge: 'end', align: 'center' } }) // → 'block-end'
|
|
31
|
-
* placementToPositionArea({ placement: { axis: 'block', edge: 'end', align: 'start' } }) // → 'block-end span-inline-end'
|
|
32
|
-
* placementToPositionArea({ placement: { axis: 'block', edge: 'end', align: 'end' } }) // → 'block-end span-inline-start'
|
|
33
|
-
*/
|
|
34
|
-
export declare function placementToPositionArea({ placement }: {
|
|
35
|
-
placement: TPlacementOptions;
|
|
36
|
-
}): string;
|
|
37
|
-
/**
|
|
38
|
-
* Returns `position-try-fallbacks` value based on placement.
|
|
39
|
-
*
|
|
40
|
-
* For centered placements, includes cross-axis aligned position-area
|
|
41
|
-
* values so the browser can shift the popover along the cross-axis
|
|
42
|
-
* when the centered position would overflow the viewport edge.
|
|
43
|
-
*
|
|
44
|
-
* Fallback order for centered placements (e.g. `block-end`):
|
|
45
|
-
* 1. Same edge, start-aligned (shift for near-edge overflow)
|
|
46
|
-
* 2. Same edge, end-aligned (shift for far-edge overflow)
|
|
47
|
-
* 3. Flipped edge, centered
|
|
48
|
-
* 4. Flipped edge, start-aligned
|
|
49
|
-
* 5. Flipped edge, end-aligned
|
|
50
|
-
*
|
|
51
|
-
* For aligned placements (start/end), includes the same-edge centered
|
|
52
|
-
* position as fallbacks so the browser can try centering when the aligned
|
|
53
|
-
* position would overflow, before flipping to the opposite edge.
|
|
54
|
-
*
|
|
55
|
-
* **Why `flip-inline flip-block` (or `flip-block flip-inline`) is included:**
|
|
56
|
-
*
|
|
57
|
-
* When a popup is in a viewport corner (e.g. inline-end align-end at the
|
|
58
|
-
* top-right), flipping only the primary axis (`flip-inline`) moves the popup
|
|
59
|
-
* to the left but keeps the same cross-axis span direction (e.g. upward),
|
|
60
|
-
* which is still off-screen. The combined keyword `flip-inline flip-block`
|
|
61
|
-
* mirrors the popup diagonally. It flips BOTH the position-area AND both
|
|
62
|
-
* inline and block margins simultaneously, placing the popup at the
|
|
63
|
-
* diagonally opposite corner where there is always space.
|
|
64
|
-
*
|
|
65
|
-
* Named `position-area` entries (e.g. `inline-start span-block-end`) in
|
|
66
|
-
* `position-try-fallbacks` do NOT update margins, so only the `flip-*`
|
|
67
|
-
* tactic keywords correctly flip the gap margin along with the position.
|
|
68
|
-
*/
|
|
69
|
-
export declare function placementToTryFallbacks({ placement }: {
|
|
70
|
-
placement: TPlacementOptions;
|
|
71
|
-
}): string;
|
|
72
17
|
/**
|
|
73
18
|
* Hook that positions an element relative to an anchor element using
|
|
74
19
|
* CSS Anchor Positioning (with a JS fallback for older browsers).
|
|
@@ -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
|
|
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).
|