@atlaskit/top-layer 4.4.5 → 5.0.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 +50 -0
- package/README.md +13 -4
- package/dist/cjs/dialog/dialog-content.js +2 -0
- package/dist/cjs/entry-points/use-popover-id.js +5 -10
- package/dist/cjs/internal/anchor-positioning/apply-anchor-positioning.js +86 -0
- package/dist/cjs/internal/anchor-positioning/cross-axis-shift-margins.js +34 -0
- package/dist/cjs/internal/anchor-positioning/edge-margin.js +21 -0
- package/dist/cjs/internal/anchor-positioning/fit-margins.js +77 -0
- package/dist/cjs/internal/anchor-positioning/get-existing-anchor-name.js +18 -0
- package/dist/cjs/internal/{placement-to-position-area.js → anchor-positioning/placement-to-position-area.js} +11 -11
- package/dist/cjs/internal/anchor-positioning/placement-to-try-fallbacks.js +95 -0
- package/dist/cjs/internal/anchored-popover-size.js +345 -0
- package/dist/cjs/internal/get-aria-for-trigger.js +7 -13
- package/dist/cjs/internal/is-native-element-open.js +19 -0
- package/dist/cjs/internal/{anchor-positioning-fallback.js → javascript-fallback/anchor-positioning-fallback.js} +12 -33
- package/dist/cjs/internal/javascript-fallback/apply-javascript-fallback-positioning.js +297 -0
- package/dist/cjs/internal/javascript-fallback/resolve-css-length-to-pixels.js +90 -0
- package/dist/cjs/internal/javascript-fallback/warn-fallback-failure.js +19 -0
- package/dist/cjs/internal/resolve-placement.js +14 -6
- package/dist/cjs/internal/supports-anchor-positioning.js +17 -0
- package/dist/cjs/internal/supports-anchor-size.js +17 -0
- package/dist/cjs/internal/supports-css-declaration.js +25 -0
- package/dist/cjs/internal/surface-reset.js +5 -0
- package/dist/cjs/internal/use-anchored-popover-at-point.js +124 -0
- package/dist/cjs/internal/use-anchored-popover.js +277 -0
- package/dist/cjs/internal/use-animated-visibility.js +11 -23
- package/dist/cjs/popover/popover.compiled.css +4 -0
- package/dist/cjs/popover/popover.js +63 -61
- package/dist/cjs/testing/polyfill.js +6 -7
- package/dist/es2019/dialog/dialog-content.js +2 -0
- package/dist/es2019/entry-points/use-popover-id.js +6 -10
- package/dist/es2019/internal/anchor-positioning/apply-anchor-positioning.js +83 -0
- package/dist/es2019/internal/anchor-positioning/cross-axis-shift-margins.js +29 -0
- package/dist/es2019/internal/anchor-positioning/edge-margin.js +18 -0
- package/dist/es2019/internal/anchor-positioning/fit-margins.js +69 -0
- package/dist/es2019/internal/anchor-positioning/get-existing-anchor-name.js +12 -0
- package/dist/es2019/internal/{placement-to-position-area.js → anchor-positioning/placement-to-position-area.js} +9 -9
- package/dist/es2019/internal/anchor-positioning/placement-to-try-fallbacks.js +94 -0
- package/dist/es2019/internal/anchored-popover-size.js +343 -0
- package/dist/es2019/internal/get-aria-for-trigger.js +7 -13
- package/dist/es2019/internal/is-native-element-open.js +14 -0
- package/dist/es2019/internal/{anchor-positioning-fallback.js → javascript-fallback/anchor-positioning-fallback.js} +12 -33
- package/dist/es2019/internal/javascript-fallback/apply-javascript-fallback-positioning.js +291 -0
- package/dist/es2019/internal/javascript-fallback/resolve-css-length-to-pixels.js +87 -0
- package/dist/es2019/internal/javascript-fallback/warn-fallback-failure.js +14 -0
- package/dist/es2019/internal/resolve-placement.js +14 -6
- package/dist/es2019/internal/supports-anchor-positioning.js +12 -0
- package/dist/es2019/internal/supports-anchor-size.js +12 -0
- package/dist/es2019/internal/supports-css-declaration.js +20 -0
- package/dist/es2019/internal/surface-reset.js +1 -0
- package/dist/es2019/internal/use-anchored-popover-at-point.js +116 -0
- package/dist/es2019/internal/use-anchored-popover.js +265 -0
- package/dist/es2019/internal/use-animated-visibility.js +1 -14
- package/dist/es2019/popover/popover.compiled.css +4 -0
- package/dist/es2019/popover/popover.js +69 -61
- package/dist/es2019/testing/polyfill.js +6 -7
- package/dist/esm/dialog/dialog-content.js +2 -0
- package/dist/esm/entry-points/use-popover-id.js +6 -10
- package/dist/esm/internal/anchor-positioning/apply-anchor-positioning.js +80 -0
- package/dist/esm/internal/anchor-positioning/cross-axis-shift-margins.js +28 -0
- package/dist/esm/internal/anchor-positioning/edge-margin.js +15 -0
- package/dist/esm/internal/anchor-positioning/fit-margins.js +71 -0
- package/dist/esm/internal/anchor-positioning/get-existing-anchor-name.js +12 -0
- package/dist/esm/internal/{placement-to-position-area.js → anchor-positioning/placement-to-position-area.js} +11 -12
- package/dist/esm/internal/anchor-positioning/placement-to-try-fallbacks.js +89 -0
- package/dist/esm/internal/anchored-popover-size.js +338 -0
- package/dist/esm/internal/get-aria-for-trigger.js +7 -13
- package/dist/esm/internal/is-native-element-open.js +13 -0
- package/dist/esm/internal/{anchor-positioning-fallback.js → javascript-fallback/anchor-positioning-fallback.js} +12 -33
- package/dist/esm/internal/javascript-fallback/apply-javascript-fallback-positioning.js +290 -0
- package/dist/esm/internal/javascript-fallback/resolve-css-length-to-pixels.js +85 -0
- package/dist/esm/internal/javascript-fallback/warn-fallback-failure.js +13 -0
- package/dist/esm/internal/resolve-placement.js +14 -6
- package/dist/esm/internal/supports-anchor-positioning.js +12 -0
- package/dist/esm/internal/supports-anchor-size.js +12 -0
- package/dist/esm/internal/supports-css-declaration.js +19 -0
- package/dist/esm/internal/surface-reset.js +1 -0
- package/dist/esm/internal/use-anchored-popover-at-point.js +118 -0
- package/dist/esm/internal/use-anchored-popover.js +271 -0
- package/dist/esm/internal/use-animated-visibility.js +10 -22
- package/dist/esm/popover/popover.compiled.css +4 -0
- package/dist/esm/popover/popover.js +63 -61
- package/dist/esm/testing/polyfill.js +6 -7
- package/dist/types/entry-points/placement-map.d.ts +2 -2
- package/dist/types/entry-points/use-popover-id.d.ts +3 -7
- package/dist/types/internal/anchor-positioning/apply-anchor-positioning.d.ts +26 -0
- package/dist/types/internal/anchor-positioning/cross-axis-shift-margins.d.ts +19 -0
- package/dist/types/internal/anchor-positioning/edge-margin.d.ts +10 -0
- package/dist/types/internal/anchor-positioning/fit-margins.d.ts +30 -0
- package/dist/types/internal/anchor-positioning/get-existing-anchor-name.d.ts +8 -0
- package/dist/types/internal/{placement-to-position-area.d.ts → anchor-positioning/placement-to-position-area.d.ts} +10 -6
- package/dist/types/internal/anchor-positioning/placement-to-try-fallbacks.d.ts +30 -0
- package/dist/types/internal/anchored-popover-size.d.ts +126 -0
- package/dist/types/internal/get-aria-for-trigger.d.ts +13 -25
- package/dist/types/internal/is-native-element-open.d.ts +3 -0
- package/dist/types/internal/javascript-fallback/anchor-positioning-fallback.d.ts +36 -0
- package/dist/types/internal/javascript-fallback/apply-javascript-fallback-positioning.d.ts +15 -0
- package/dist/types/internal/javascript-fallback/resolve-css-length-to-pixels.d.ts +20 -0
- package/dist/types/internal/javascript-fallback/warn-fallback-failure.d.ts +7 -0
- package/dist/types/internal/resolve-placement.d.ts +18 -2
- package/dist/types/internal/supports-anchor-positioning.d.ts +5 -0
- package/dist/types/internal/supports-anchor-size.d.ts +5 -0
- package/dist/types/internal/supports-css-declaration.d.ts +11 -0
- package/dist/types/internal/surface-reset.d.ts +25 -0
- package/dist/types/internal/use-anchored-popover-at-point.d.ts +48 -0
- package/dist/types/internal/use-anchored-popover.d.ts +143 -0
- package/dist/types/popover/index.d.ts +2 -1
- package/dist/types/popover/popover.d.ts +1 -1
- package/dist/types/popover/types.d.ts +15 -17
- package/dist/types/testing/polyfill.d.ts +3 -3
- package/package.json +2 -2
- package/use-anchored-popover/package.json +10 -0
- package/use-anchored-popover-at-point/package.json +10 -0
- package/dist/cjs/internal/placement-to-try-fallbacks.js +0 -108
- package/dist/cjs/internal/resolve-css-length-to-pixels.js +0 -104
- package/dist/cjs/internal/use-anchor-position-at-point.js +0 -129
- package/dist/cjs/internal/use-anchor-position.js +0 -501
- package/dist/cjs/internal/use-width-from-anchor.js +0 -124
- package/dist/es2019/internal/placement-to-try-fallbacks.js +0 -108
- package/dist/es2019/internal/resolve-css-length-to-pixels.js +0 -101
- package/dist/es2019/internal/use-anchor-position-at-point.js +0 -124
- package/dist/es2019/internal/use-anchor-position.js +0 -480
- package/dist/es2019/internal/use-width-from-anchor.js +0 -120
- package/dist/esm/internal/placement-to-try-fallbacks.js +0 -103
- package/dist/esm/internal/resolve-css-length-to-pixels.js +0 -98
- package/dist/esm/internal/use-anchor-position-at-point.js +0 -124
- package/dist/esm/internal/use-anchor-position.js +0 -494
- package/dist/esm/internal/use-width-from-anchor.js +0 -118
- package/dist/types/internal/anchor-positioning-fallback.d.ts +0 -51
- package/dist/types/internal/placement-to-try-fallbacks.d.ts +0 -13
- package/dist/types/internal/resolve-css-length-to-pixels.d.ts +0 -20
- package/dist/types/internal/use-anchor-position-at-point.d.ts +0 -67
- package/dist/types/internal/use-anchor-position.d.ts +0 -87
- package/dist/types/internal/use-width-from-anchor.d.ts +0 -19
- package/use-anchor-position/package.json +0 -10
- package/use-anchor-position-at-point/package.json +0 -10
- package/use-width-from-anchor/package.json +0 -10
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { type RefObject } from 'react';
|
|
2
|
-
import { type TPlacementOptions } from './resolve-placement';
|
|
3
|
-
/**
|
|
4
|
-
* A point in viewport coordinates (CSS pixels) at which the synthetic
|
|
5
|
-
* anchor should be placed.
|
|
6
|
-
*
|
|
7
|
-
* Axis-named (`x`/`y`) rather than edge-named (`left`/`top`) so the
|
|
8
|
-
* shape is unambiguous in RTL writing modes - there is no ambiguity
|
|
9
|
-
* about whether a coordinate is logical (`inline-start`/`block-start`)
|
|
10
|
-
* or physical (`left`/`top`). Viewport coordinates are always
|
|
11
|
-
* physical, so we name them with the physical axis labels.
|
|
12
|
-
*/
|
|
13
|
-
export type TAnchorPoint = {
|
|
14
|
-
x: number;
|
|
15
|
-
y: number;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Positions a popover at a consumer-supplied viewport coordinate using a
|
|
19
|
-
* hidden synthetic anchor.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```tsx
|
|
23
|
-
* function PointPositionedPopover({ popoverRef, placement, mousePos }) {
|
|
24
|
-
* useAnchorPositionAtPoint({
|
|
25
|
-
* popoverRef,
|
|
26
|
-
* placement,
|
|
27
|
-
* isEnabled: Boolean(mousePos),
|
|
28
|
-
* getPoint: () => {
|
|
29
|
-
* if (!mousePos) return null;
|
|
30
|
-
* return { x: mousePos.clientX, y: mousePos.clientY };
|
|
31
|
-
* },
|
|
32
|
-
* });
|
|
33
|
-
* return <Popover ref={popoverRef}>...</Popover>;
|
|
34
|
-
* }
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export declare function useAnchorPositionAtPoint({ popoverRef, placement, getPoint, isEnabled, isOpen, }: {
|
|
38
|
-
/**
|
|
39
|
-
* Element being positioned. Passed to `useAnchorPosition`.
|
|
40
|
-
*/
|
|
41
|
-
popoverRef: RefObject<HTMLElement | null>;
|
|
42
|
-
/**
|
|
43
|
-
* Where the popover sits relative to the anchor.
|
|
44
|
-
*/
|
|
45
|
-
placement: TPlacementOptions;
|
|
46
|
-
/**
|
|
47
|
-
* Lazy callback returning the viewport coordinate to anchor at.
|
|
48
|
-
* Called once per activation (every `isEnabled: false → true`
|
|
49
|
-
* transition); the result is latched and not re-read.
|
|
50
|
-
*
|
|
51
|
-
* Return `null` to signal "no point yet" - the hook stays in a
|
|
52
|
-
* no-DOM state so another positioning strategy can own the popover.
|
|
53
|
-
*
|
|
54
|
-
* Read from a ref, so it does not need to be memoized.
|
|
55
|
-
*/
|
|
56
|
-
getPoint: () => TAnchorPoint | null;
|
|
57
|
-
/**
|
|
58
|
-
* When `false`, the hook is a no-op: no synthetic anchor is created
|
|
59
|
-
* and no positioning is applied. Defaults to `true`.
|
|
60
|
-
*/
|
|
61
|
-
isEnabled?: boolean;
|
|
62
|
-
/**
|
|
63
|
-
* Whether the popover is currently open. Forwarded to the inner
|
|
64
|
-
* `useAnchorPosition` so it re-runs across host remount cycles.
|
|
65
|
-
*/
|
|
66
|
-
isOpen: boolean;
|
|
67
|
-
}): void;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Anchor positioning for top-layer popovers. See
|
|
3
|
-
* `notes/architecture/positioning.md` for the full model.
|
|
4
|
-
*
|
|
5
|
-
* Two runtime paths: CSS Anchor Positioning (modern browsers) and a JS
|
|
6
|
-
* fallback that measures the trigger and writes `top`/`left`.
|
|
7
|
-
*
|
|
8
|
-
* Both paths honour `offset.gap` and `offset.crossAxisShift`. The
|
|
9
|
-
* CSS path passes the values through as strings; the JS fallback resolves
|
|
10
|
-
* them to pixels via a hidden DOM probe (see `resolveCssLengthToPixels`)
|
|
11
|
-
* so tokens, `calc()`, `var()`, etc all work. The JS fallback hides the
|
|
12
|
-
* popover with `opacity: 0` until the first measurement completes, so it
|
|
13
|
-
* is never painted at the wrong location.
|
|
14
|
-
*/
|
|
15
|
-
import { type RefObject } from 'react';
|
|
16
|
-
import { type TPlacementOptions } from '../internal/resolve-placement';
|
|
17
|
-
/**
|
|
18
|
-
* Hook that positions an element relative to an anchor element using
|
|
19
|
-
* CSS Anchor Positioning (with a JS fallback for older browsers).
|
|
20
|
-
*
|
|
21
|
-
* This hook is the positioning primitive. It has no knowledge of popovers,
|
|
22
|
-
* visibility, or animation. Compose it with `Popover` for anchor-positioned
|
|
23
|
-
* top-layer content.
|
|
24
|
-
*
|
|
25
|
-
* When CSS Anchor Positioning is supported, it sets CSS properties
|
|
26
|
-
* (`anchor-name`, `position-anchor`, `position-area`, `position-try-fallbacks`)
|
|
27
|
-
* directly on the elements via `el.style.setProperty()`.
|
|
28
|
-
*
|
|
29
|
-
* When not supported, it falls back to JavaScript-based positioning using
|
|
30
|
-
* `position: fixed` with measured coordinates, re-running on scroll (capture)
|
|
31
|
-
* and resize events.
|
|
32
|
-
*/
|
|
33
|
-
export declare function useAnchorPosition({ anchorRef, popoverRef, placement, forceFallbackPositioning, isEnabled, isOpen, }: {
|
|
34
|
-
/**
|
|
35
|
-
* Element to position relative to.
|
|
36
|
-
*/
|
|
37
|
-
anchorRef: RefObject<HTMLElement | null>;
|
|
38
|
-
/**
|
|
39
|
-
* Element being positioned (typically a popover).
|
|
40
|
-
*
|
|
41
|
-
* The popover host may be unmounted between opens (the `Popover`
|
|
42
|
-
* primitive unmounts after its exit animation). Pass `isOpen` so the
|
|
43
|
-
* positioning effect re-runs against the freshly mounted element on
|
|
44
|
-
* the next open. Without it, the effect's bound listeners and styles
|
|
45
|
-
* would target the previous (detached) element.
|
|
46
|
-
*/
|
|
47
|
-
popoverRef: RefObject<HTMLElement | null>;
|
|
48
|
-
/**
|
|
49
|
-
* Where to place the element relative to the anchor.
|
|
50
|
-
* `offset.gap` and `offset.crossAxisShift` are part of the
|
|
51
|
-
* placement object.
|
|
52
|
-
*
|
|
53
|
-
* All fields are optional. Omitted fields fall back to:
|
|
54
|
-
* - `axis`: `'block'`
|
|
55
|
-
* - `edge`: `'end'`
|
|
56
|
-
* - `align`: `'center'`
|
|
57
|
-
* - `offset.gap`: `token('space.100', '8px')`
|
|
58
|
-
* - `offset.crossAxisShift.value`: `'0px'`
|
|
59
|
-
* - `offset.crossAxisShift.direction`: `'forwards'`
|
|
60
|
-
*
|
|
61
|
-
* The full default placement (`{}`) renders the popover centered
|
|
62
|
-
* below the trigger with one `space.100` of gap and no cross-axis
|
|
63
|
-
* shift.
|
|
64
|
-
*
|
|
65
|
-
* `offset.gap` and `offset.crossAxisShift.value` accept either a
|
|
66
|
-
* number (pixels) or a CSS length string (eg `token('space.200')`).
|
|
67
|
-
*/
|
|
68
|
-
placement?: TPlacementOptions;
|
|
69
|
-
/**
|
|
70
|
-
* Forces the JavaScript positioning fallback even when the browser
|
|
71
|
-
* supports CSS Anchor Positioning. Useful for testing fallback
|
|
72
|
-
* behavior in any environment, including production.
|
|
73
|
-
*/
|
|
74
|
-
forceFallbackPositioning?: boolean;
|
|
75
|
-
/**
|
|
76
|
-
* When `false`, the hook is a no-op and applies no positioning.
|
|
77
|
-
* Defaults to `true`.
|
|
78
|
-
*/
|
|
79
|
-
isEnabled?: boolean;
|
|
80
|
-
/**
|
|
81
|
-
* Whether the popover is currently open. Drives a re-run of the
|
|
82
|
-
* positioning effect when the popover host element is unmounted
|
|
83
|
-
* and remounted across open cycles, so listeners and styles are
|
|
84
|
-
* always wired to the live host element.
|
|
85
|
-
*/
|
|
86
|
-
isOpen: boolean;
|
|
87
|
-
}): void;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { type RefObject } from 'react';
|
|
2
|
-
import type { TWidthFromAnchorMode } from '../popover/types';
|
|
3
|
-
/**
|
|
4
|
-
* Sets the width of a popover element relative to its anchor element.
|
|
5
|
-
*
|
|
6
|
-
* - `'match-anchor'` → `inline-size: anchor-size(self-inline)`, exact
|
|
7
|
-
* - `'min-anchor'` → `min-inline-size: anchor-size(self-inline)`, floor only
|
|
8
|
-
* - `'none'` → `min-inline-size: max-content`, content floor (default)
|
|
9
|
-
*
|
|
10
|
-
* `self-inline` is the inline axis of the element USING the function (the popover), never the
|
|
11
|
-
* anchor, so it matches the axis `inline-size` constrains. See
|
|
12
|
-
* `notes/decisions/width-from-anchor-floors.md`.
|
|
13
|
-
*/
|
|
14
|
-
export declare function useWidthFromAnchor({ mode, popoverRef, anchorRef, isOpen, }: {
|
|
15
|
-
mode: TWidthFromAnchorMode;
|
|
16
|
-
popoverRef: RefObject<HTMLElement | null>;
|
|
17
|
-
anchorRef: RefObject<HTMLElement | null>;
|
|
18
|
-
isOpen: boolean;
|
|
19
|
-
}): void;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@atlaskit/top-layer/use-anchor-position",
|
|
3
|
-
"main": "../dist/cjs/internal/use-anchor-position.js",
|
|
4
|
-
"module": "../dist/esm/internal/use-anchor-position.js",
|
|
5
|
-
"module:es2019": "../dist/es2019/internal/use-anchor-position.js",
|
|
6
|
-
"sideEffects": [
|
|
7
|
-
"*.compiled.css"
|
|
8
|
-
],
|
|
9
|
-
"types": "../dist/types/internal/use-anchor-position.d.ts"
|
|
10
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@atlaskit/top-layer/use-anchor-position-at-point",
|
|
3
|
-
"main": "../dist/cjs/internal/use-anchor-position-at-point.js",
|
|
4
|
-
"module": "../dist/esm/internal/use-anchor-position-at-point.js",
|
|
5
|
-
"module:es2019": "../dist/es2019/internal/use-anchor-position-at-point.js",
|
|
6
|
-
"sideEffects": [
|
|
7
|
-
"*.compiled.css"
|
|
8
|
-
],
|
|
9
|
-
"types": "../dist/types/internal/use-anchor-position-at-point.d.ts"
|
|
10
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@atlaskit/top-layer/use-width-from-anchor",
|
|
3
|
-
"main": "../dist/cjs/internal/use-width-from-anchor.js",
|
|
4
|
-
"module": "../dist/esm/internal/use-width-from-anchor.js",
|
|
5
|
-
"module:es2019": "../dist/es2019/internal/use-width-from-anchor.js",
|
|
6
|
-
"sideEffects": [
|
|
7
|
-
"*.compiled.css"
|
|
8
|
-
],
|
|
9
|
-
"types": "../dist/types/internal/use-width-from-anchor.d.ts"
|
|
10
|
-
}
|