@atlaskit/top-layer 0.1.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 +44 -0
- package/README.md +151 -0
- package/animations/package.json +17 -0
- package/arrow/package.json +17 -0
- package/create-close-event/package.json +17 -0
- package/dialog/package.json +17 -0
- package/dialog-scroll-lock/package.json +17 -0
- package/dist/cjs/animations/presets.js +199 -0
- package/dist/cjs/animations/types.js +5 -0
- package/dist/cjs/arrow/index.js +130 -0
- package/dist/cjs/arrow/types.js +5 -0
- package/dist/cjs/dialog/create-close-event.js +39 -0
- package/dist/cjs/dialog/dialog-content.compiled.css +14 -0
- package/dist/cjs/dialog/dialog-content.js +144 -0
- package/dist/cjs/dialog/index.js +19 -0
- package/dist/cjs/dialog/types.js +5 -0
- package/dist/cjs/dialog-scroll-lock/index.js +46 -0
- package/dist/cjs/entry-points/animations.js +36 -0
- package/dist/cjs/entry-points/arrow.js +12 -0
- package/dist/cjs/entry-points/create-close-event.js +19 -0
- package/dist/cjs/entry-points/dialog-scroll-lock.js +12 -0
- package/dist/cjs/entry-points/dialog.js +12 -0
- package/dist/cjs/entry-points/focus.js +24 -0
- package/dist/cjs/entry-points/placement-map.js +18 -0
- package/dist/cjs/entry-points/popover.js +12 -0
- package/dist/cjs/entry-points/popup-surface.js +12 -0
- package/dist/cjs/entry-points/popup.js +12 -0
- package/dist/cjs/entry-points/use-anchor-position.js +12 -0
- package/dist/cjs/entry-points/use-arrow-navigation.js +18 -0
- package/dist/cjs/entry-points/use-simple-light-dismiss.js +12 -0
- package/dist/cjs/focus/focus.js +115 -0
- package/dist/cjs/focus/index.js +24 -0
- package/dist/cjs/index.js +8 -0
- package/dist/cjs/internal/anchor-positioning-fallback.js +154 -0
- package/dist/cjs/internal/combine.js +29 -0
- package/dist/cjs/internal/ensure-preset-styles.js +34 -0
- package/dist/cjs/internal/reduced-motion.js +27 -0
- package/dist/cjs/internal/resolve-placement.js +24 -0
- package/dist/cjs/internal/role-types.js +66 -0
- package/dist/cjs/internal/set-style.js +42 -0
- package/dist/cjs/internal/slot.js +65 -0
- package/dist/cjs/internal/use-anchor-positioning.js +336 -0
- package/dist/cjs/internal/use-animated-visibility.js +169 -0
- package/dist/cjs/internal/use-animation-preset.js +24 -0
- package/dist/cjs/internal/use-focus-wrap.js +94 -0
- package/dist/cjs/internal/use-initial-focus.js +112 -0
- package/dist/cjs/internal/use-preset-styles.js +27 -0
- package/dist/cjs/placement-map/index.js +147 -0
- package/dist/cjs/popover/create-close-event.js +44 -0
- package/dist/cjs/popover/index.js +19 -0
- package/dist/cjs/popover/popover.compiled.css +13 -0
- package/dist/cjs/popover/popover.js +251 -0
- package/dist/cjs/popover/types.js +5 -0
- package/dist/cjs/popup/index.js +37 -0
- package/dist/cjs/popup/popup-content.js +201 -0
- package/dist/cjs/popup/popup-context.js +42 -0
- package/dist/cjs/popup/popup-surface.compiled.css +5 -0
- package/dist/cjs/popup/popup-surface.js +30 -0
- package/dist/cjs/popup/popup-trigger-function.js +74 -0
- package/dist/cjs/popup/popup-trigger.js +82 -0
- package/dist/cjs/popup/popup.js +70 -0
- package/dist/cjs/popup/types.js +5 -0
- package/dist/cjs/use-arrow-navigation/index.js +18 -0
- package/dist/cjs/use-arrow-navigation/use-arrow-navigation.js +245 -0
- package/dist/cjs/use-simple-light-dismiss/index.js +84 -0
- package/dist/es2019/animations/presets.js +375 -0
- package/dist/es2019/animations/types.js +1 -0
- package/dist/es2019/arrow/index.js +249 -0
- package/dist/es2019/arrow/types.js +1 -0
- package/dist/es2019/dialog/create-close-event.js +34 -0
- package/dist/es2019/dialog/dialog-content.compiled.css +14 -0
- package/dist/es2019/dialog/dialog-content.js +138 -0
- package/dist/es2019/dialog/index.js +2 -0
- package/dist/es2019/dialog/types.js +1 -0
- package/dist/es2019/dialog-scroll-lock/index.js +41 -0
- package/dist/es2019/entry-points/animations.js +1 -0
- package/dist/es2019/entry-points/arrow.js +1 -0
- package/dist/es2019/entry-points/create-close-event.js +2 -0
- package/dist/es2019/entry-points/dialog-scroll-lock.js +1 -0
- package/dist/es2019/entry-points/dialog.js +1 -0
- package/dist/es2019/entry-points/focus.js +1 -0
- package/dist/es2019/entry-points/placement-map.js +1 -0
- package/dist/es2019/entry-points/popover.js +1 -0
- package/dist/es2019/entry-points/popup-surface.js +1 -0
- package/dist/es2019/entry-points/popup.js +1 -0
- package/dist/es2019/entry-points/use-anchor-position.js +1 -0
- package/dist/es2019/entry-points/use-arrow-navigation.js +1 -0
- package/dist/es2019/entry-points/use-simple-light-dismiss.js +1 -0
- package/dist/es2019/focus/focus.js +107 -0
- package/dist/es2019/focus/index.js +1 -0
- package/dist/es2019/index.js +7 -0
- package/dist/es2019/internal/anchor-positioning-fallback.js +153 -0
- package/dist/es2019/internal/combine.js +18 -0
- package/dist/es2019/internal/ensure-preset-styles.js +29 -0
- package/dist/es2019/internal/reduced-motion.js +21 -0
- package/dist/es2019/internal/resolve-placement.js +19 -0
- package/dist/es2019/internal/role-types.js +61 -0
- package/dist/es2019/internal/set-style.js +39 -0
- package/dist/es2019/internal/slot.js +57 -0
- package/dist/es2019/internal/use-anchor-positioning.js +330 -0
- package/dist/es2019/internal/use-animated-visibility.js +159 -0
- package/dist/es2019/internal/use-animation-preset.js +18 -0
- package/dist/es2019/internal/use-focus-wrap.js +90 -0
- package/dist/es2019/internal/use-initial-focus.js +109 -0
- package/dist/es2019/internal/use-preset-styles.js +22 -0
- package/dist/es2019/placement-map/index.js +142 -0
- package/dist/es2019/popover/create-close-event.js +39 -0
- package/dist/es2019/popover/index.js +2 -0
- package/dist/es2019/popover/popover.compiled.css +13 -0
- package/dist/es2019/popover/popover.js +240 -0
- package/dist/es2019/popover/types.js +1 -0
- package/dist/es2019/popup/index.js +33 -0
- package/dist/es2019/popup/popup-content.js +192 -0
- package/dist/es2019/popup/popup-context.js +34 -0
- package/dist/es2019/popup/popup-surface.compiled.css +5 -0
- package/dist/es2019/popup/popup-surface.js +24 -0
- package/dist/es2019/popup/popup-trigger-function.js +69 -0
- package/dist/es2019/popup/popup-trigger.js +76 -0
- package/dist/es2019/popup/popup.js +56 -0
- package/dist/es2019/popup/types.js +1 -0
- package/dist/es2019/use-arrow-navigation/index.js +1 -0
- package/dist/es2019/use-arrow-navigation/use-arrow-navigation.js +238 -0
- package/dist/es2019/use-simple-light-dismiss/index.js +79 -0
- package/dist/esm/animations/presets.js +190 -0
- package/dist/esm/animations/types.js +1 -0
- package/dist/esm/arrow/index.js +123 -0
- package/dist/esm/arrow/types.js +1 -0
- package/dist/esm/dialog/create-close-event.js +33 -0
- package/dist/esm/dialog/dialog-content.compiled.css +14 -0
- package/dist/esm/dialog/dialog-content.js +135 -0
- package/dist/esm/dialog/index.js +2 -0
- package/dist/esm/dialog/types.js +1 -0
- package/dist/esm/dialog-scroll-lock/index.js +41 -0
- package/dist/esm/entry-points/animations.js +1 -0
- package/dist/esm/entry-points/arrow.js +1 -0
- package/dist/esm/entry-points/create-close-event.js +2 -0
- package/dist/esm/entry-points/dialog-scroll-lock.js +1 -0
- package/dist/esm/entry-points/dialog.js +1 -0
- package/dist/esm/entry-points/focus.js +1 -0
- package/dist/esm/entry-points/placement-map.js +1 -0
- package/dist/esm/entry-points/popover.js +1 -0
- package/dist/esm/entry-points/popup-surface.js +1 -0
- package/dist/esm/entry-points/popup.js +1 -0
- package/dist/esm/entry-points/use-anchor-position.js +1 -0
- package/dist/esm/entry-points/use-arrow-navigation.js +1 -0
- package/dist/esm/entry-points/use-simple-light-dismiss.js +1 -0
- package/dist/esm/focus/focus.js +107 -0
- package/dist/esm/focus/index.js +1 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/internal/anchor-positioning-fallback.js +147 -0
- package/dist/esm/internal/combine.js +23 -0
- package/dist/esm/internal/ensure-preset-styles.js +28 -0
- package/dist/esm/internal/reduced-motion.js +21 -0
- package/dist/esm/internal/resolve-placement.js +18 -0
- package/dist/esm/internal/role-types.js +60 -0
- package/dist/esm/internal/set-style.js +36 -0
- package/dist/esm/internal/slot.js +59 -0
- package/dist/esm/internal/use-anchor-positioning.js +323 -0
- package/dist/esm/internal/use-animated-visibility.js +162 -0
- package/dist/esm/internal/use-animation-preset.js +18 -0
- package/dist/esm/internal/use-focus-wrap.js +89 -0
- package/dist/esm/internal/use-initial-focus.js +107 -0
- package/dist/esm/internal/use-preset-styles.js +21 -0
- package/dist/esm/placement-map/index.js +141 -0
- package/dist/esm/popover/create-close-event.js +38 -0
- package/dist/esm/popover/index.js +2 -0
- package/dist/esm/popover/popover.compiled.css +13 -0
- package/dist/esm/popover/popover.js +242 -0
- package/dist/esm/popover/types.js +1 -0
- package/dist/esm/popup/index.js +33 -0
- package/dist/esm/popup/popup-content.js +192 -0
- package/dist/esm/popup/popup-context.js +34 -0
- package/dist/esm/popup/popup-surface.compiled.css +5 -0
- package/dist/esm/popup/popup-surface.js +23 -0
- package/dist/esm/popup/popup-trigger-function.js +69 -0
- package/dist/esm/popup/popup-trigger.js +74 -0
- package/dist/esm/popup/popup.js +61 -0
- package/dist/esm/popup/types.js +1 -0
- package/dist/esm/use-arrow-navigation/index.js +1 -0
- package/dist/esm/use-arrow-navigation/use-arrow-navigation.js +238 -0
- package/dist/esm/use-simple-light-dismiss/index.js +78 -0
- package/dist/types/animations/presets.d.ts +94 -0
- package/dist/types/animations/types.d.ts +42 -0
- package/dist/types/arrow/index.d.ts +24 -0
- package/dist/types/arrow/types.d.ts +29 -0
- package/dist/types/dialog/create-close-event.d.ts +24 -0
- package/dist/types/dialog/dialog-content.d.ts +20 -0
- package/dist/types/dialog/index.d.ts +3 -0
- package/dist/types/dialog/types.d.ts +92 -0
- package/dist/types/dialog-scroll-lock/index.d.ts +24 -0
- package/dist/types/entry-points/animations.d.ts +2 -0
- package/dist/types/entry-points/arrow.d.ts +2 -0
- package/dist/types/entry-points/create-close-event.d.ts +4 -0
- package/dist/types/entry-points/dialog-scroll-lock.d.ts +1 -0
- package/dist/types/entry-points/dialog.d.ts +2 -0
- package/dist/types/entry-points/focus.d.ts +2 -0
- package/dist/types/entry-points/placement-map.d.ts +2 -0
- package/dist/types/entry-points/popover.d.ts +2 -0
- package/dist/types/entry-points/popup-surface.d.ts +2 -0
- package/dist/types/entry-points/popup.d.ts +2 -0
- package/dist/types/entry-points/use-anchor-position.d.ts +1 -0
- package/dist/types/entry-points/use-arrow-navigation.d.ts +2 -0
- package/dist/types/entry-points/use-simple-light-dismiss.d.ts +2 -0
- package/dist/types/focus/focus.d.ts +42 -0
- package/dist/types/focus/index.d.ts +2 -0
- package/dist/types/index.d.ts +0 -0
- package/dist/types/internal/anchor-positioning-fallback.d.ts +24 -0
- package/dist/types/internal/combine.d.ts +14 -0
- package/dist/types/internal/ensure-preset-styles.d.ts +6 -0
- package/dist/types/internal/reduced-motion.d.ts +14 -0
- package/dist/types/internal/resolve-placement.d.ts +16 -0
- package/dist/types/internal/role-types.d.ts +62 -0
- package/dist/types/internal/set-style.d.ts +28 -0
- package/dist/types/internal/slot.d.ts +29 -0
- package/dist/types/internal/use-anchor-positioning.d.ts +95 -0
- package/dist/types/internal/use-animated-visibility.d.ts +74 -0
- package/dist/types/internal/use-animation-preset.d.ts +11 -0
- package/dist/types/internal/use-focus-wrap.d.ts +20 -0
- package/dist/types/internal/use-initial-focus.d.ts +21 -0
- package/dist/types/internal/use-preset-styles.d.ts +15 -0
- package/dist/types/placement-map/index.d.ts +55 -0
- package/dist/types/popover/create-close-event.d.ts +26 -0
- package/dist/types/popover/index.d.ts +3 -0
- package/dist/types/popover/popover.d.ts +22 -0
- package/dist/types/popover/types.d.ts +153 -0
- package/dist/types/popup/index.d.ts +34 -0
- package/dist/types/popup/popup-content.d.ts +14 -0
- package/dist/types/popup/popup-context.d.ts +96 -0
- package/dist/types/popup/popup-surface.d.ts +16 -0
- package/dist/types/popup/popup-trigger-function.d.ts +108 -0
- package/dist/types/popup/popup-trigger.d.ts +23 -0
- package/dist/types/popup/popup.d.ts +14 -0
- package/dist/types/popup/types.d.ts +289 -0
- package/dist/types/use-arrow-navigation/index.d.ts +2 -0
- package/dist/types/use-arrow-navigation/use-arrow-navigation.d.ts +136 -0
- package/dist/types/use-simple-light-dismiss/index.d.ts +45 -0
- package/dist/types-ts4.5/animations/presets.d.ts +94 -0
- package/dist/types-ts4.5/animations/types.d.ts +42 -0
- package/dist/types-ts4.5/arrow/index.d.ts +24 -0
- package/dist/types-ts4.5/arrow/types.d.ts +29 -0
- package/dist/types-ts4.5/dialog/create-close-event.d.ts +24 -0
- package/dist/types-ts4.5/dialog/dialog-content.d.ts +20 -0
- package/dist/types-ts4.5/dialog/index.d.ts +3 -0
- package/dist/types-ts4.5/dialog/types.d.ts +92 -0
- package/dist/types-ts4.5/dialog-scroll-lock/index.d.ts +24 -0
- package/dist/types-ts4.5/entry-points/animations.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/arrow.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/create-close-event.d.ts +4 -0
- package/dist/types-ts4.5/entry-points/dialog-scroll-lock.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/dialog.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/focus.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/placement-map.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/popover.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/popup-surface.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/popup.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/use-anchor-position.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/use-arrow-navigation.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/use-simple-light-dismiss.d.ts +2 -0
- package/dist/types-ts4.5/focus/focus.d.ts +42 -0
- package/dist/types-ts4.5/focus/index.d.ts +2 -0
- package/dist/types-ts4.5/index.d.ts +0 -0
- package/dist/types-ts4.5/internal/anchor-positioning-fallback.d.ts +24 -0
- package/dist/types-ts4.5/internal/combine.d.ts +14 -0
- package/dist/types-ts4.5/internal/ensure-preset-styles.d.ts +6 -0
- package/dist/types-ts4.5/internal/reduced-motion.d.ts +14 -0
- package/dist/types-ts4.5/internal/resolve-placement.d.ts +16 -0
- package/dist/types-ts4.5/internal/role-types.d.ts +62 -0
- package/dist/types-ts4.5/internal/set-style.d.ts +28 -0
- package/dist/types-ts4.5/internal/slot.d.ts +29 -0
- package/dist/types-ts4.5/internal/use-anchor-positioning.d.ts +95 -0
- package/dist/types-ts4.5/internal/use-animated-visibility.d.ts +74 -0
- package/dist/types-ts4.5/internal/use-animation-preset.d.ts +11 -0
- package/dist/types-ts4.5/internal/use-focus-wrap.d.ts +20 -0
- package/dist/types-ts4.5/internal/use-initial-focus.d.ts +21 -0
- package/dist/types-ts4.5/internal/use-preset-styles.d.ts +15 -0
- package/dist/types-ts4.5/placement-map/index.d.ts +55 -0
- package/dist/types-ts4.5/popover/create-close-event.d.ts +26 -0
- package/dist/types-ts4.5/popover/index.d.ts +3 -0
- package/dist/types-ts4.5/popover/popover.d.ts +22 -0
- package/dist/types-ts4.5/popover/types.d.ts +153 -0
- package/dist/types-ts4.5/popup/index.d.ts +34 -0
- package/dist/types-ts4.5/popup/popup-content.d.ts +14 -0
- package/dist/types-ts4.5/popup/popup-context.d.ts +96 -0
- package/dist/types-ts4.5/popup/popup-surface.d.ts +16 -0
- package/dist/types-ts4.5/popup/popup-trigger-function.d.ts +108 -0
- package/dist/types-ts4.5/popup/popup-trigger.d.ts +23 -0
- package/dist/types-ts4.5/popup/popup.d.ts +14 -0
- package/dist/types-ts4.5/popup/types.d.ts +289 -0
- package/dist/types-ts4.5/use-arrow-navigation/index.d.ts +2 -0
- package/dist/types-ts4.5/use-arrow-navigation/use-arrow-navigation.d.ts +136 -0
- package/dist/types-ts4.5/use-simple-light-dismiss/index.d.ts +45 -0
- package/focus/package.json +17 -0
- package/package.json +95 -0
- package/placement-map/package.json +17 -0
- package/popover/package.json +17 -0
- package/popup/package.json +17 -0
- package/popup-surface/package.json +17 -0
- package/use-anchor-position/package.json +17 -0
- package/use-arrow-navigation/package.json +17 -0
- package/use-simple-light-dismiss/package.json +17 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DialogScrollLock } from '../dialog-scroll-lock';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useAnchorPosition } from '../internal/use-anchor-positioning';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Focusable element selectors and navigation helpers.
|
|
3
|
+
*
|
|
4
|
+
* Uses CSS selectors to discover focusable elements within a container,
|
|
5
|
+
* avoiding the need for a manual registration system. Disabled elements
|
|
6
|
+
* (both HTML `disabled` attribute and `aria-disabled="true"`) and elements
|
|
7
|
+
* with `tabindex="-1"` are excluded automatically.
|
|
8
|
+
*
|
|
9
|
+
* All public functions accept an optional `filter` callback to further
|
|
10
|
+
* restrict which focusable elements are included.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* An optional callback to restrict which focusable elements are included.
|
|
14
|
+
* Return `true` to include the element, `false` to skip it.
|
|
15
|
+
*/
|
|
16
|
+
export type TFocusableFilter = (element: HTMLElement, container: HTMLElement) => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the first focusable element within the container.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getFirstFocusable({ container, filter, }: {
|
|
21
|
+
container: HTMLElement;
|
|
22
|
+
filter?: TFocusableFilter;
|
|
23
|
+
}): HTMLElement | null;
|
|
24
|
+
/**
|
|
25
|
+
* Returns the last focusable element within the container.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getLastFocusable({ container, filter, }: {
|
|
28
|
+
container: HTMLElement;
|
|
29
|
+
filter?: TFocusableFilter;
|
|
30
|
+
}): HTMLElement | null;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the next focusable element in the given direction relative to the
|
|
33
|
+
* currently focused element within the container. Wraps around at both ends.
|
|
34
|
+
*
|
|
35
|
+
* Returns `null` if there is no focused element within the container or if
|
|
36
|
+
* the focused element is not in the list of focusable elements.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getNextFocusable({ container, direction, filter, }: {
|
|
39
|
+
container: HTMLElement;
|
|
40
|
+
direction: 'forwards' | 'backwards';
|
|
41
|
+
filter?: TFocusableFilter;
|
|
42
|
+
}): HTMLElement | null;
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type TPlacement } from './resolve-placement';
|
|
2
|
+
/**
|
|
3
|
+
* JS fallback: compute popover position from trigger rect and viewport.
|
|
4
|
+
*
|
|
5
|
+
* Placement algorithm (from the document):
|
|
6
|
+
* - "block" placement: show above/below, picking the side with more space if flipping needed
|
|
7
|
+
* - "inline" placement: show left/right, picking the side with more space if flipping needed
|
|
8
|
+
* - "auto" placement: show on the edge with the most available space
|
|
9
|
+
*
|
|
10
|
+
* Re-runs on scroll (capture on window) and resize events.
|
|
11
|
+
*/
|
|
12
|
+
export declare function computeFallbackPosition({ triggerRect, popoverEl, placement, viewport, offset, }: {
|
|
13
|
+
triggerRect: DOMRect;
|
|
14
|
+
popoverEl: HTMLElement;
|
|
15
|
+
placement: TPlacement;
|
|
16
|
+
viewport: {
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
};
|
|
20
|
+
offset: number;
|
|
21
|
+
}): {
|
|
22
|
+
top: number;
|
|
23
|
+
left: number;
|
|
24
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Combine multiple cleanup functions into a single cleanup function.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* useEffect(() => {
|
|
7
|
+
* return combine(
|
|
8
|
+
* bind(window, { type: 'resize', listener: onResize }),
|
|
9
|
+
* bind(window, { type: 'scroll', listener: onScroll, options: { capture: true } }),
|
|
10
|
+
* );
|
|
11
|
+
* }, []);
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare function combine(...cleanupFns: ((() => void) | undefined)[]): () => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns `true` when the user prefers reduced motion.
|
|
3
|
+
*
|
|
4
|
+
* Safe for SSR (returns `false` when `window` is unavailable).
|
|
5
|
+
*
|
|
6
|
+
* The result is cached after the first call via `once`. This avoids
|
|
7
|
+
* calling `matchMedia` on every render. The trade-off is that if a user
|
|
8
|
+
* toggles the OS reduced-motion setting mid-session, the change won't
|
|
9
|
+
* take effect until the next page load. This is acceptable because
|
|
10
|
+
* toggling this system-level preference mid-session is extremely rare,
|
|
11
|
+
* and a page refresh is a reasonable expectation for system accessibility
|
|
12
|
+
* settings to take effect.
|
|
13
|
+
*/
|
|
14
|
+
export declare const prefersReducedMotion: () => boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fully-resolved placement (internal). All fields are required.
|
|
3
|
+
* Use getPlacement({ placement: partial }) to obtain from partial input.
|
|
4
|
+
*/
|
|
5
|
+
export type TPlacement = {
|
|
6
|
+
axis: 'block' | 'inline';
|
|
7
|
+
edge: 'start' | 'end';
|
|
8
|
+
align: 'start' | 'center' | 'end';
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Resolves a partial placement to its fully-specified form.
|
|
12
|
+
* Defaults: `axis: 'block'`, `edge: 'end'`, `align: 'center'`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getPlacement({ placement }: {
|
|
15
|
+
placement: Partial<TPlacement>;
|
|
16
|
+
}): TPlacement;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Valid values for the `aria-haspopup` attribute.
|
|
3
|
+
* Derived from the HTML spec — maps popover roles to what the trigger announces.
|
|
4
|
+
*/
|
|
5
|
+
export type TAriaHasPopupValue = 'dialog' | 'menu' | 'listbox' | 'tree' | 'grid' | true;
|
|
6
|
+
/**
|
|
7
|
+
* Roles that require an accessible name (`label` or `labelledBy`) per WCAG 4.1.2.
|
|
8
|
+
* Without a name, assistive technology cannot identify these landmarks.
|
|
9
|
+
*/
|
|
10
|
+
export type TRoleRequiringAccessibleName = 'dialog' | 'alertdialog' | 'menu';
|
|
11
|
+
/**
|
|
12
|
+
* Roles where the accessible name is derived from content or provided externally
|
|
13
|
+
* (e.g. a combobox labels its listbox, tooltip content IS the accessible name).
|
|
14
|
+
*/
|
|
15
|
+
export type TRoleWithImplicitName = 'tooltip' | 'listbox' | 'tree' | 'grid' | 'note' | 'status' | 'alert' | 'log';
|
|
16
|
+
type TAccessibleNameRequired = {
|
|
17
|
+
/**
|
|
18
|
+
* Accessible name via `aria-label`.
|
|
19
|
+
*/
|
|
20
|
+
label: string;
|
|
21
|
+
labelledBy?: string;
|
|
22
|
+
} | {
|
|
23
|
+
label?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Accessible name via `aria-labelledby`.
|
|
26
|
+
*/
|
|
27
|
+
labelledBy: string;
|
|
28
|
+
};
|
|
29
|
+
type TAccessibleNameOptional = {
|
|
30
|
+
label?: string;
|
|
31
|
+
labelledBy?: string;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* ARIA role props where a role is always required.
|
|
35
|
+
*
|
|
36
|
+
* Used by `TPopupContentProps` — popup content must always declare
|
|
37
|
+
* its role so assistive technology can identify the layer.
|
|
38
|
+
*/
|
|
39
|
+
export type TAriaRoleRequired = ({
|
|
40
|
+
role: TRoleRequiringAccessibleName;
|
|
41
|
+
} & TAccessibleNameRequired) | ({
|
|
42
|
+
role: TRoleWithImplicitName;
|
|
43
|
+
} & TAccessibleNameOptional);
|
|
44
|
+
/**
|
|
45
|
+
* ARIA role props where a role is optional.
|
|
46
|
+
*
|
|
47
|
+
* Used by `TPopoverProps` — the low-level primitive allows omitting
|
|
48
|
+
* the role for cases where it is set externally or not needed.
|
|
49
|
+
*/
|
|
50
|
+
export type TAriaRoleOptional = ({
|
|
51
|
+
role: TRoleRequiringAccessibleName;
|
|
52
|
+
} & TAccessibleNameRequired) | ({
|
|
53
|
+
role?: TRoleWithImplicitName;
|
|
54
|
+
} & TAccessibleNameOptional);
|
|
55
|
+
/**
|
|
56
|
+
* Maps a popover content role to the correct `aria-haspopup` value
|
|
57
|
+
* for its trigger element.
|
|
58
|
+
*/
|
|
59
|
+
export declare function roleToAriaHasPopup({ role, }: {
|
|
60
|
+
role: TRoleRequiringAccessibleName | TRoleWithImplicitName | undefined;
|
|
61
|
+
}): TAriaHasPopupValue;
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sets inline styles on an element and returns a cleanup function
|
|
3
|
+
* that removes only the styles that were applied.
|
|
4
|
+
*
|
|
5
|
+
* Uses `style.setProperty()` / `style.removeProperty()` so that
|
|
6
|
+
* hyphenated CSS property names (e.g. `position-area`, `anchor-name`)
|
|
7
|
+
* work correctly. These newer properties do not have camelCase
|
|
8
|
+
* mappings in `CSSStyleDeclaration` yet.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const cleanup = setStyle({ el: popover, styles: [
|
|
13
|
+
* { property: 'position-anchor', value: '--my-anchor' },
|
|
14
|
+
* { property: 'position-area', value: 'block-end' },
|
|
15
|
+
* { property: 'margin', value: '0' },
|
|
16
|
+
* ] });
|
|
17
|
+
*
|
|
18
|
+
* // Later: removes all three properties
|
|
19
|
+
* cleanup();
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function setStyle({ el, styles, }: {
|
|
23
|
+
el: HTMLElement;
|
|
24
|
+
styles: Array<{
|
|
25
|
+
property: string;
|
|
26
|
+
value: string;
|
|
27
|
+
}>;
|
|
28
|
+
}): () => void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ForwardRefExoticComponent, type ReactNode, type RefAttributes } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Extra DOM/event props are passed through to the cloned child.
|
|
4
|
+
*/
|
|
5
|
+
export type SlotProps = {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
} & Record<string, unknown>;
|
|
8
|
+
/**
|
|
9
|
+
* Merges props (including ref) onto a single React element child.
|
|
10
|
+
*
|
|
11
|
+
* A safer alternative to raw `cloneElement` that:
|
|
12
|
+
* 1. Guards with `isValidElement` — non-element children (strings,
|
|
13
|
+
* fragments, null) are returned as-is instead of crashing.
|
|
14
|
+
* 2. Merges refs via `mergeRefs` so both the caller's ref and the
|
|
15
|
+
* child's existing ref are honoured.
|
|
16
|
+
* 3. Spreads any additional props (ARIA attributes, event handlers, etc.)
|
|
17
|
+
* onto the child element.
|
|
18
|
+
*
|
|
19
|
+
* Event handlers (e.g. `onClick`) are **not** auto-merged — the caller's
|
|
20
|
+
* handler replaces the child's. Compose handlers before passing them in.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* <Slot ref={triggerRef} onClick={handleClick} aria-expanded={isOpen}>
|
|
25
|
+
* <button>Open</button>
|
|
26
|
+
* </Slot>
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare const Slot: ForwardRefExoticComponent<SlotProps & RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
import { type TArrowPreset } from '../arrow/types';
|
|
3
|
+
import { type TPlacementOptions } from '../popup/types';
|
|
4
|
+
export { getPlacement } from './resolve-placement';
|
|
5
|
+
/**
|
|
6
|
+
* Resolves placement options to CSS `position-area` syntax.
|
|
7
|
+
*
|
|
8
|
+
* The `align` field represents the *visual* alignment:
|
|
9
|
+
* - `align: 'start'` means "aligned to the trigger's start edge" (left in LTR for block axis)
|
|
10
|
+
* - `align: 'end'` means "aligned to the trigger's end edge"
|
|
11
|
+
* - `align: 'center'` means centered (single-axis position-area)
|
|
12
|
+
*
|
|
13
|
+
* CSS `position-area` uses `span-*` keywords which indicate the *expansion direction*.
|
|
14
|
+
* Visual start-alignment requires `span-{cross-axis}-end` (expand toward end = start-aligned).
|
|
15
|
+
* This function handles the inversion internally.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* placementToPositionArea({ placement: { axis: 'block', edge: 'end', align: 'center' } }) // → 'block-end'
|
|
19
|
+
* placementToPositionArea({ placement: { axis: 'block', edge: 'end', align: 'start' } }) // → 'block-end span-inline-end'
|
|
20
|
+
* placementToPositionArea({ placement: { axis: 'block', edge: 'end', align: 'end' } }) // → 'block-end span-inline-start'
|
|
21
|
+
*/
|
|
22
|
+
export declare function placementToPositionArea({ placement }: {
|
|
23
|
+
placement: TPlacementOptions;
|
|
24
|
+
}): string;
|
|
25
|
+
/**
|
|
26
|
+
* Returns `position-try-fallbacks` value based on placement.
|
|
27
|
+
*
|
|
28
|
+
* For centered placements, includes cross-axis aligned position-area
|
|
29
|
+
* values so the browser can shift the popover along the cross-axis
|
|
30
|
+
* when the centered position would overflow the viewport edge.
|
|
31
|
+
*
|
|
32
|
+
* Fallback order for centered placements (e.g. `block-end`):
|
|
33
|
+
* 1. Same edge, start-aligned (shift for near-edge overflow)
|
|
34
|
+
* 2. Same edge, end-aligned (shift for far-edge overflow)
|
|
35
|
+
* 3. Flipped edge, centered
|
|
36
|
+
* 4. Flipped edge, start-aligned
|
|
37
|
+
* 5. Flipped edge, end-aligned
|
|
38
|
+
*
|
|
39
|
+
* For aligned placements (start/end), includes the same-edge centered
|
|
40
|
+
* position as fallbacks so the browser can try centering when the aligned
|
|
41
|
+
* position would overflow, before flipping to the opposite edge.
|
|
42
|
+
*/
|
|
43
|
+
export declare function placementToTryFallbacks({ placement }: {
|
|
44
|
+
placement: TPlacementOptions;
|
|
45
|
+
}): string;
|
|
46
|
+
/**
|
|
47
|
+
* Hook that positions an element relative to an anchor element using
|
|
48
|
+
* CSS Anchor Positioning (with a JS fallback for older browsers).
|
|
49
|
+
*
|
|
50
|
+
* This hook is the positioning primitive — it has no knowledge of popovers,
|
|
51
|
+
* visibility, or animation. Compose it with `Popover` for anchor-positioned
|
|
52
|
+
* top-layer content.
|
|
53
|
+
*
|
|
54
|
+
* When CSS Anchor Positioning is supported, it sets CSS properties
|
|
55
|
+
* (`anchor-name`, `position-anchor`, `position-area`, `position-try-fallbacks`)
|
|
56
|
+
* directly on the elements via `el.style.setProperty()`.
|
|
57
|
+
*
|
|
58
|
+
* When not supported, it falls back to JavaScript-based positioning using
|
|
59
|
+
* `position: fixed` with measured coordinates, re-running on scroll (capture)
|
|
60
|
+
* and resize events.
|
|
61
|
+
*/
|
|
62
|
+
export declare function useAnchorPosition({ anchorRef, popoverRef, placement, offset, forceFallbackPositioning, arrow, }: {
|
|
63
|
+
/**
|
|
64
|
+
* Element to position relative to.
|
|
65
|
+
*/
|
|
66
|
+
anchorRef: RefObject<HTMLElement | null>;
|
|
67
|
+
/**
|
|
68
|
+
* Element being positioned (typically a popover).
|
|
69
|
+
*/
|
|
70
|
+
popoverRef: RefObject<HTMLElement | null>;
|
|
71
|
+
/**
|
|
72
|
+
* Where to place the element relative to the anchor.
|
|
73
|
+
*/
|
|
74
|
+
placement: TPlacementOptions;
|
|
75
|
+
/**
|
|
76
|
+
* Gap between the positioned element and the anchor, in pixels.
|
|
77
|
+
* Defaults to 8 (`space.100`). Tooltip uses 4.
|
|
78
|
+
*/
|
|
79
|
+
offset?: number;
|
|
80
|
+
/**
|
|
81
|
+
* Forces the JavaScript positioning fallback even when the browser
|
|
82
|
+
* supports CSS Anchor Positioning. Useful for testing fallback
|
|
83
|
+
* behavior in any environment, including production.
|
|
84
|
+
*/
|
|
85
|
+
forceFallbackPositioning?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Arrow preset from `@atlaskit/top-layer/arrow`. When provided, uses
|
|
88
|
+
* the preset's named `@position-try` rules (which update both
|
|
89
|
+
* `position-area` and `margin` on flip) and sets `--ds-arrow-size`.
|
|
90
|
+
*
|
|
91
|
+
* Pass `null` to disable. Has no effect in the JS fallback path —
|
|
92
|
+
* arrows are CSS-only.
|
|
93
|
+
*/
|
|
94
|
+
arrow?: TArrowPreset | null;
|
|
95
|
+
}): void;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
import { type TAnimationPreset } from '../animations/types';
|
|
3
|
+
type TUseAnimatedVisibilityArgs = {
|
|
4
|
+
/**
|
|
5
|
+
* Whether the element is logically open.
|
|
6
|
+
*/
|
|
7
|
+
isOpen: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Animation preset for entry/exit transitions.
|
|
10
|
+
* Pass `false` or `undefined` to disable animation.
|
|
11
|
+
*/
|
|
12
|
+
animate: TAnimationPreset | false | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Ref to the DOM element that plays the exit transition.
|
|
15
|
+
* Used to listen for `transitionend`.
|
|
16
|
+
*/
|
|
17
|
+
elementRef: RefObject<HTMLElement | null>;
|
|
18
|
+
/**
|
|
19
|
+
* Called after the exit animation completes (or immediately on close
|
|
20
|
+
* when there is no animation or reduced motion is active).
|
|
21
|
+
*/
|
|
22
|
+
onExitFinish?: () => void;
|
|
23
|
+
};
|
|
24
|
+
type TUseAnimatedVisibilityResult = {
|
|
25
|
+
/**
|
|
26
|
+
* Whether children should be rendered. Stays `true` during exit
|
|
27
|
+
* animations so content remains visible while transitioning out.
|
|
28
|
+
*/
|
|
29
|
+
showChildren: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Resolved animation preset (with CSS injected), or `null` if
|
|
32
|
+
* animation is disabled.
|
|
33
|
+
*/
|
|
34
|
+
preset: TAnimationPreset | null;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Manages the children mount/unmount lifecycle around CSS exit transitions.
|
|
38
|
+
*
|
|
39
|
+
* Used by both `Popover` and `Dialog` to share the same animation lifecycle
|
|
40
|
+
* logic. Those components own their own show/hide mechanisms (showPopover /
|
|
41
|
+
* hidePopover vs showModal / close) and event handling — this hook only
|
|
42
|
+
* manages the relationship between `isOpen` and when children are rendered.
|
|
43
|
+
*
|
|
44
|
+
* ## Problem
|
|
45
|
+
*
|
|
46
|
+
* We want to delay the unmount of children until a CSS exit transition has
|
|
47
|
+
* finished playing. If we unmount children the moment `isOpen` becomes
|
|
48
|
+
* `false`, the exit animation is never visible — the content just disappears.
|
|
49
|
+
*
|
|
50
|
+
* ## How it works
|
|
51
|
+
*
|
|
52
|
+
* `showChildren` tracks whether the consumer's children should be in the DOM.
|
|
53
|
+
* It does not mirror `isOpen` exactly — it intentionally lags behind during
|
|
54
|
+
* exit animations:
|
|
55
|
+
*
|
|
56
|
+
* ```
|
|
57
|
+
* isOpen: true ──────────────── false
|
|
58
|
+
* showChildren: true ──────────────── true ─── (exit animation) ─── false
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* Two close paths exist:
|
|
62
|
+
*
|
|
63
|
+
* 1. **Animated close** (`willAnimate === true`):
|
|
64
|
+
* `isOpen` goes `false` → `showChildren` stays `true` → the CSS exit
|
|
65
|
+
* transition plays → `transitionend` fires → `showChildren` → `false`
|
|
66
|
+
* → `onExitFinish` fires. A timeout fallback ensures we still unmount
|
|
67
|
+
* if `transitionend` never fires (e.g. browser quirks, zero-duration).
|
|
68
|
+
*
|
|
69
|
+
* 2. **Non-animated close** (`willAnimate === false`):
|
|
70
|
+
* `isOpen` goes `false` → `showChildren` → `false` synchronously during
|
|
71
|
+
* the same render → `onExitFinish` fires in a follow-up effect.
|
|
72
|
+
*/
|
|
73
|
+
export declare function useAnimatedVisibility({ isOpen, animate, elementRef, onExitFinish, }: TUseAnimatedVisibilityArgs): TUseAnimatedVisibilityResult;
|
|
74
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type TPresetWithCssAndName = {
|
|
2
|
+
css: string;
|
|
3
|
+
name: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Normalizes the `animate` prop to a preset (or null) and ensures its CSS
|
|
7
|
+
* is injected once into document.head. Used by PopupContent, Popover, and
|
|
8
|
+
* DialogContent so they don't duplicate this logic.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useAnimationPreset<T extends TPresetWithCssAndName>(animate: T | false | null | undefined): T | null;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps Tab/Shift+Tab focus within a popover element when its role
|
|
4
|
+
* semantically requires it (dialog, alertdialog).
|
|
5
|
+
*
|
|
6
|
+
* While the popover is open, Tab and Shift+Tab are intercepted
|
|
7
|
+
* (via `preventDefault`) and remapped to cycle through focusable
|
|
8
|
+
* elements within the container using wrapping navigation.
|
|
9
|
+
*
|
|
10
|
+
* Light dismiss (Escape, click outside) continues to work natively
|
|
11
|
+
* via `popover="auto"` — this hook only intercepts Tab.
|
|
12
|
+
*
|
|
13
|
+
* Always call this hook unconditionally. The listener is only
|
|
14
|
+
* attached when the role requires focus wrapping, and is cleaned
|
|
15
|
+
* up and re-evaluated when the role changes.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useFocusWrap({ elementRef, role, }: {
|
|
18
|
+
elementRef: RefObject<HTMLElement | null>;
|
|
19
|
+
role: string | undefined;
|
|
20
|
+
}): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Moves focus into a popover element when it opens, based on its ARIA role.
|
|
4
|
+
*
|
|
5
|
+
* This implements WCAG 2.4.3 (Focus Order) initial focus placement:
|
|
6
|
+
* - `dialog` / `alertdialog` → focus first focusable (or `[autofocus]`)
|
|
7
|
+
* - `menu` → focus first menu item
|
|
8
|
+
* - `listbox` → focus selected or first option
|
|
9
|
+
* - `tooltip` / no role → no focus movement
|
|
10
|
+
*
|
|
11
|
+
* The role is read from the element's `role` attribute (not passed as a prop),
|
|
12
|
+
* following the same pattern as `useFocusWrap`.
|
|
13
|
+
*
|
|
14
|
+
* Always call this hook unconditionally. Focus is only moved when `isOpen`
|
|
15
|
+
* transitions to `true` and the role requires it.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useInitialFocus({ elementRef, isOpen, role, }: {
|
|
18
|
+
elementRef: RefObject<HTMLElement | null>;
|
|
19
|
+
isOpen: boolean;
|
|
20
|
+
role: string | undefined;
|
|
21
|
+
}): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type TPresetWithCssAndName = {
|
|
2
|
+
css: string;
|
|
3
|
+
name: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Normalizes a preset prop to a value (or null) and ensures its CSS
|
|
7
|
+
* is injected once into `document.head`.
|
|
8
|
+
*
|
|
9
|
+
* Works with any preset that has `{ css, name }` — animation presets
|
|
10
|
+
* (TAnimationPreset) and arrow presets (TArrowPreset) both satisfy this shape.
|
|
11
|
+
*/
|
|
12
|
+
export declare function usePresetStyles<T extends TPresetWithCssAndName>({ preset, }: {
|
|
13
|
+
preset: T | false | null | undefined;
|
|
14
|
+
}): T | null;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type TPlacement } from '../internal/resolve-placement';
|
|
2
|
+
import { type TPlacementOptions } from '../popup/types';
|
|
3
|
+
/**
|
|
4
|
+
* Legacy Popper.js placement values (used by `@atlaskit/popper`, `@atlaskit/popup`,
|
|
5
|
+
* `@atlaskit/tooltip`, etc.).
|
|
6
|
+
*/
|
|
7
|
+
export type TLegacyPlacement = 'auto' | 'auto-start' | 'auto-end' | 'top' | 'top-start' | 'top-center' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-center' | 'bottom-end' | 'right' | 'right-start' | 'right-end' | 'left' | 'left-start' | 'left-end';
|
|
8
|
+
/**
|
|
9
|
+
* Maps legacy Popper.js placement values to the new object-based
|
|
10
|
+
* `Placement` values used by `@atlaskit/top-layer/popover`.
|
|
11
|
+
*
|
|
12
|
+
* **Mapping logic:**
|
|
13
|
+
*
|
|
14
|
+
* | Legacy (Popper.js) | New (Placement object) |
|
|
15
|
+
* | ------------------- | --------------------------------------------------- |
|
|
16
|
+
* | `top` | `{ axis: 'block', edge: 'start', align: 'center' }` |
|
|
17
|
+
* | `top-start` | `{ axis: 'block', edge: 'start', align: 'start' }` |
|
|
18
|
+
* | `top-end` | `{ axis: 'block', edge: 'start', align: 'end' }` |
|
|
19
|
+
* | `bottom` | `{ axis: 'block', edge: 'end', align: 'center' }` |
|
|
20
|
+
* | `bottom-start` | `{ axis: 'block', edge: 'end', align: 'start' }` |
|
|
21
|
+
* | `bottom-end` | `{ axis: 'block', edge: 'end', align: 'end' }` |
|
|
22
|
+
* | `right` | `{ axis: 'inline', edge: 'end', align: 'center' }` |
|
|
23
|
+
* | `right-start` | `{ axis: 'inline', edge: 'end', align: 'start' }` |
|
|
24
|
+
* | `right-end` | `{ axis: 'inline', edge: 'end', align: 'end' }` |
|
|
25
|
+
* | `left` | `{ axis: 'inline', edge: 'start', align: 'center' }` |
|
|
26
|
+
* | `left-start` | `{ axis: 'inline', edge: 'start', align: 'start' }` |
|
|
27
|
+
* | `left-end` | `{ axis: 'inline', edge: 'start', align: 'end' }` |
|
|
28
|
+
* | `auto` | `{ axis: 'block', edge: 'end', align: 'center' }` |
|
|
29
|
+
* | `auto-start` | `{ axis: 'block', edge: 'end', align: 'start' }` |
|
|
30
|
+
* | `auto-end` | `{ axis: 'block', edge: 'end', align: 'end' }` |
|
|
31
|
+
*
|
|
32
|
+
* The `position-try-fallbacks` CSS property handles flipping automatically.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { fromLegacyPlacement } from '@atlaskit/top-layer/placement-map';
|
|
37
|
+
*
|
|
38
|
+
* // In a migration from @atlaskit/popup:
|
|
39
|
+
* const oldPlacement: TLegacyPlacement = 'bottom-start';
|
|
40
|
+
* const newPlacement: TPlacementOptions = fromLegacyPlacement({ legacy: oldPlacement });
|
|
41
|
+
* // newPlacement === { axis: 'block', edge: 'end', align: 'start' }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
declare const placementMapping: Record<TLegacyPlacement, TPlacement>;
|
|
45
|
+
/**
|
|
46
|
+
* Convert a legacy Popper.js placement to the new CSS `position-area`-based Placement.
|
|
47
|
+
*/
|
|
48
|
+
export declare function fromLegacyPlacement({ legacy }: {
|
|
49
|
+
legacy: TLegacyPlacement;
|
|
50
|
+
}): TPlacementOptions;
|
|
51
|
+
/**
|
|
52
|
+
* The full mapping record, exposed for consumers that need to iterate or introspect.
|
|
53
|
+
*/
|
|
54
|
+
export { placementMapping };
|
|
55
|
+
export type { TPlacementOptions };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type TPopoverCloseReason } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a synthetic DOM event from a `TPopoverCloseReason`.
|
|
4
|
+
*
|
|
5
|
+
* Useful when bridging the Popover primitive's `onClose({ reason })` callback
|
|
6
|
+
* to a legacy API that expects a native DOM event — for example,
|
|
7
|
+
* `@atlaskit/inline-dialog`'s `onClose(event)` contract.
|
|
8
|
+
*
|
|
9
|
+
* - `'escape'` → `KeyboardEvent('keydown', { key: 'Escape' })`
|
|
10
|
+
* - `'light-dismiss'` → `MouseEvent('click')`
|
|
11
|
+
*
|
|
12
|
+
* For any other reason, a generic `Event('close')` is returned as a fallback.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* import { createPopoverCloseEvent } from '@atlaskit/top-layer/create-close-event';
|
|
17
|
+
* import { type TPopoverCloseReason } from '@atlaskit/top-layer/popover';
|
|
18
|
+
*
|
|
19
|
+
* function onPopoverClose({ reason }: { reason: TPopoverCloseReason }) {
|
|
20
|
+
* legacyOnClose(createPopoverCloseEvent({ reason }));
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function createPopoverCloseEvent({ reason, }: {
|
|
25
|
+
reason: TPopoverCloseReason;
|
|
26
|
+
}): KeyboardEvent | MouseEvent | Event;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { type TPopoverForwardedProps } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Unopinionated top-layer primitive.
|
|
9
|
+
*
|
|
10
|
+
* Manages only visibility (isOpen) and animation (animate). Has no knowledge
|
|
11
|
+
* of positioning — compose with `useAnchorPosition` for anchor positioning.
|
|
12
|
+
*
|
|
13
|
+
* Visibility is driven by the `isOpen` prop:
|
|
14
|
+
* - `isOpen={true}` → `showPopover()`, entry animation via `@starting-style`
|
|
15
|
+
* - `isOpen={false}` → `hidePopover()`, exit animation via `allow-discrete`
|
|
16
|
+
*
|
|
17
|
+
* For `mode="auto"`, the browser can dismiss the popover via light dismiss
|
|
18
|
+
* (Escape, click outside). When that happens, `onClose` is called and the
|
|
19
|
+
* consumer must set `isOpen` to `false`. The DOM owns the dismiss — React
|
|
20
|
+
* must follow.
|
|
21
|
+
*/
|
|
22
|
+
export declare const Popover: React.ForwardRefExoticComponent<TPopoverForwardedProps & React.RefAttributes<HTMLDivElement>>;
|