@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
|
@@ -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
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/top-layer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "Low-level layering primitives based on popover and dialog",
|
|
5
5
|
"homepage": "https://atlassian.design/components/top-layer",
|
|
6
6
|
"repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@atlaskit/css": "^0.19.0",
|
|
39
39
|
"@atlaskit/ds-lib": "^7.0.0",
|
|
40
40
|
"@atlaskit/layering": "^3.7.0",
|
|
41
|
-
"@atlaskit/tokens": "^13.
|
|
41
|
+
"@atlaskit/tokens": "^13.1.0",
|
|
42
42
|
"@babel/runtime": "^7.0.0",
|
|
43
43
|
"@compiled/react": "^0.20.0",
|
|
44
44
|
"bind-event-listener": "^3.0.0",
|
package/dist/cjs/arrow/index.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.arrow = void 0;
|
|
8
|
-
var _once = _interopRequireDefault(require("@atlaskit/ds-lib/once"));
|
|
9
|
-
var _resolvePlacement = require("../internal/resolve-placement");
|
|
10
|
-
var _useAnchorPosition = require("../internal/use-anchor-position");
|
|
11
|
-
/**
|
|
12
|
-
* CSS for popover arrows using the `clip-path: inset() margin-box` technique.
|
|
13
|
-
*
|
|
14
|
-
* How it works:
|
|
15
|
-
* 1. Four arrow shapes exist simultaneously as `::before` (top/bottom) and
|
|
16
|
-
* `::after` (left/right) hexagonal pseudo-elements.
|
|
17
|
-
* 2. `clip-path: inset(0) margin-box` clips the popover to its margin-box.
|
|
18
|
-
* 3. Margin on the anchor-facing side pushes the popover away, creating space
|
|
19
|
-
* where one arrow "escapes" the clip boundary and becomes visible.
|
|
20
|
-
* 4. `@position-try` rules change both `position-area` and `margin` when
|
|
21
|
-
* flipping, ensuring the correct arrow is always shown.
|
|
22
|
-
*
|
|
23
|
-
* Constraints:
|
|
24
|
-
* - `box-shadow` must be `none` (interferes with `clip-path: inset() margin-box`)
|
|
25
|
-
* - `::before` and `::after` are consumed - consumers cannot use them
|
|
26
|
-
* - Arrow pseudo-elements use `background: inherit` from the popover element
|
|
27
|
-
*
|
|
28
|
-
* @see https://goulet.dev/posts/tooltip-with-popover-and-anchor-positioning/
|
|
29
|
-
*/
|
|
30
|
-
var ARROW_CSS = "\n[data-ds-popover-arrow] {\n clip-path: inset(var(--ds-arrow-offset, 0px)) margin-box;\n box-shadow: none;\n}\n\n/* Top and Bottom arrows (vertical hexagon) */\n[data-ds-popover-arrow]::before {\n content: \"\";\n position: absolute;\n z-index: -1;\n background: inherit;\n left: 50%;\n transform: translateX(-50%);\n width: calc(var(--ds-arrow-size, 8px) * 2);\n height: calc(100% + var(--ds-arrow-size, 8px) * 2);\n top: calc(var(--ds-arrow-size, 8px) * -1);\n clip-path: polygon(\n 0 var(--ds-arrow-size, 8px),\n 50% 0,\n 100% var(--ds-arrow-size, 8px),\n 100% calc(100% - var(--ds-arrow-size, 8px)),\n 50% 100%,\n 0 calc(100% - var(--ds-arrow-size, 8px))\n );\n}\n\n/* Left and Right arrows (horizontal hexagon) */\n[data-ds-popover-arrow]::after {\n content: \"\";\n position: absolute;\n z-index: -1;\n background: inherit;\n top: 50%;\n transform: translateY(-50%);\n height: calc(var(--ds-arrow-size, 8px) * 2);\n width: calc(100% + var(--ds-arrow-size, 8px) * 2);\n left: calc(var(--ds-arrow-size, 8px) * -1);\n clip-path: polygon(\n var(--ds-arrow-size, 8px) 0,\n calc(100% - var(--ds-arrow-size, 8px)) 0,\n 100% 50%,\n calc(100% - var(--ds-arrow-size, 8px)) 100%,\n var(--ds-arrow-size, 8px) 100%,\n 0 50%\n );\n}\n\n/* \u2500\u2500 @position-try rules \u2500\u2500\n * One rule per possible position-area value.\n * Each sets the position-area and the correct margin direction\n * so the arrow on the anchor-facing side is revealed.\n *\n * Margin direction per edge:\n * block-start (above anchor) \u2192 margin-block-end (bottom, facing anchor)\n * block-end (below anchor) \u2192 margin-block-start (top, facing anchor)\n * inline-start (left of anchor) \u2192 margin-inline-end (right, facing anchor)\n * inline-end (right of anchor) \u2192 margin-inline-start (left, facing anchor)\n */\n\n/* Each rule sets two margins: the anchor-facing margin for the gap\n (via --ds-arrow-size) and one cross-axis margin for the shift\n (via one of --ds-cross-axis-shift-margin-start, --ds-cross-axis-shift-margin-end,\n --ds-cross-axis-shift-margin-block-start, or --ds-cross-axis-shift-margin-block-end). The\n side matches the popover's anchored cross-axis edge per align. Only\n one of the four properties is non-zero at a time; useAnchorPosition\n picks it. See notes/architecture/positioning.md for details. */\n/* Single-axis centered (align: center) */\n@position-try --ds-arrow-block-start {\n position-area: block-start;\n margin: 0;\n margin-block-end: var(--ds-arrow-size, 8px);\n margin-inline-start: var(--ds-cross-axis-shift-margin-start, 0px);\n}\n@position-try --ds-arrow-block-end {\n position-area: block-end;\n margin: 0;\n margin-block-start: var(--ds-arrow-size, 8px);\n margin-inline-start: var(--ds-cross-axis-shift-margin-start, 0px);\n}\n@position-try --ds-arrow-inline-start {\n position-area: inline-start;\n margin: 0;\n margin-inline-end: var(--ds-arrow-size, 8px);\n margin-block-start: var(--ds-cross-axis-shift-margin-block-start, 0px);\n}\n@position-try --ds-arrow-inline-end {\n position-area: inline-end;\n margin: 0;\n margin-inline-start: var(--ds-arrow-size, 8px);\n margin-block-start: var(--ds-cross-axis-shift-margin-block-start, 0px);\n}\n\n/* Block edge + inline span (align: start uses span-inline-end; align: end uses span-inline-start) */\n@position-try --ds-arrow-block-start-span-inline-start {\n position-area: block-start span-inline-start;\n margin: 0;\n margin-block-end: var(--ds-arrow-size, 8px);\n margin-inline-end: var(--ds-cross-axis-shift-margin-end, 0px);\n}\n@position-try --ds-arrow-block-start-span-inline-end {\n position-area: block-start span-inline-end;\n margin: 0;\n margin-block-end: var(--ds-arrow-size, 8px);\n margin-inline-start: var(--ds-cross-axis-shift-margin-start, 0px);\n}\n@position-try --ds-arrow-block-end-span-inline-start {\n position-area: block-end span-inline-start;\n margin: 0;\n margin-block-start: var(--ds-arrow-size, 8px);\n margin-inline-end: var(--ds-cross-axis-shift-margin-end, 0px);\n}\n@position-try --ds-arrow-block-end-span-inline-end {\n position-area: block-end span-inline-end;\n margin: 0;\n margin-block-start: var(--ds-arrow-size, 8px);\n margin-inline-start: var(--ds-cross-axis-shift-margin-start, 0px);\n}\n\n/* Inline edge + block span (align: start uses span-block-end; align: end uses span-block-start) */\n@position-try --ds-arrow-inline-start-span-block-start {\n position-area: inline-start span-block-start;\n margin: 0;\n margin-inline-end: var(--ds-arrow-size, 8px);\n margin-block-end: var(--ds-cross-axis-shift-margin-block-end, 0px);\n}\n@position-try --ds-arrow-inline-start-span-block-end {\n position-area: inline-start span-block-end;\n margin: 0;\n margin-inline-end: var(--ds-arrow-size, 8px);\n margin-block-start: var(--ds-cross-axis-shift-margin-block-start, 0px);\n}\n@position-try --ds-arrow-inline-end-span-block-start {\n position-area: inline-end span-block-start;\n margin: 0;\n margin-inline-start: var(--ds-arrow-size, 8px);\n margin-block-end: var(--ds-cross-axis-shift-margin-block-end, 0px);\n}\n@position-try --ds-arrow-inline-end-span-block-end {\n position-area: inline-end span-block-end;\n margin: 0;\n margin-inline-start: var(--ds-arrow-size, 8px);\n margin-block-start: var(--ds-cross-axis-shift-margin-block-start, 0px);\n}\n";
|
|
31
|
-
|
|
32
|
-
// ── Placement utilities ──
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Converts a `position-area` value to a CSS rule name by replacing spaces with hyphens
|
|
36
|
-
* and prepending `--ds-arrow-`.
|
|
37
|
-
*
|
|
38
|
-
* @example positionAreaToRuleName('block-end span-inline-start') → '--ds-arrow-block-end-span-inline-start'
|
|
39
|
-
*/
|
|
40
|
-
function positionAreaToRuleName(_ref) {
|
|
41
|
-
var positionArea = _ref.positionArea;
|
|
42
|
-
return "--ds-arrow-".concat(positionArea.replace(/ /g, '-'));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Returns `position-try-fallbacks` using named `@position-try` rules
|
|
47
|
-
* that change both `position-area` and `margin` when flipping.
|
|
48
|
-
*
|
|
49
|
-
* This is required for the arrow technique because built-in keywords
|
|
50
|
-
* (`flip-block`, `flip-inline`) only flip `position-area` - they do
|
|
51
|
-
* not update the margin direction needed to reveal the correct arrow.
|
|
52
|
-
*/
|
|
53
|
-
function getTryFallbacks(_ref2) {
|
|
54
|
-
var placement = _ref2.placement;
|
|
55
|
-
var _getPlacement = (0, _resolvePlacement.getPlacement)({
|
|
56
|
-
placement: placement
|
|
57
|
-
}),
|
|
58
|
-
axis = _getPlacement.axis,
|
|
59
|
-
edge = _getPlacement.edge,
|
|
60
|
-
align = _getPlacement.align;
|
|
61
|
-
if (align === 'center') {
|
|
62
|
-
// Single-axis: only flip the edge
|
|
63
|
-
var _flippedEdge = edge === 'start' ? 'end' : 'start';
|
|
64
|
-
return positionAreaToRuleName({
|
|
65
|
-
positionArea: (0, _useAnchorPosition.placementToPositionArea)({
|
|
66
|
-
placement: {
|
|
67
|
-
axis: axis,
|
|
68
|
-
edge: _flippedEdge
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// Compound placement: try flipping edge, alignment, and both
|
|
75
|
-
var flippedEdge = edge === 'start' ? 'end' : 'start';
|
|
76
|
-
var flippedAlign = align === 'start' ? 'end' : 'start';
|
|
77
|
-
return [positionAreaToRuleName({
|
|
78
|
-
positionArea: (0, _useAnchorPosition.placementToPositionArea)({
|
|
79
|
-
placement: {
|
|
80
|
-
axis: axis,
|
|
81
|
-
edge: flippedEdge,
|
|
82
|
-
align: align
|
|
83
|
-
}
|
|
84
|
-
})
|
|
85
|
-
}), positionAreaToRuleName({
|
|
86
|
-
positionArea: (0, _useAnchorPosition.placementToPositionArea)({
|
|
87
|
-
placement: {
|
|
88
|
-
axis: axis,
|
|
89
|
-
edge: edge,
|
|
90
|
-
align: flippedAlign
|
|
91
|
-
}
|
|
92
|
-
})
|
|
93
|
-
}), positionAreaToRuleName({
|
|
94
|
-
positionArea: (0, _useAnchorPosition.placementToPositionArea)({
|
|
95
|
-
placement: {
|
|
96
|
-
axis: axis,
|
|
97
|
-
edge: flippedEdge,
|
|
98
|
-
align: flippedAlign
|
|
99
|
-
}
|
|
100
|
-
})
|
|
101
|
-
})].join(', ');
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Creates an arrow preset for popover content.
|
|
106
|
-
*
|
|
107
|
-
* The returned object is passed to `PopoverContent`'s `arrow` prop.
|
|
108
|
-
* It carries the CSS string and fallback logic so that consumers who
|
|
109
|
-
* do not use arrows pay no bundle cost.
|
|
110
|
-
*
|
|
111
|
-
* The arrows inherit their background from the popover element.
|
|
112
|
-
* When `arrow` is active, `PopoverContent` does not reset `background`
|
|
113
|
-
* to `transparent`, allowing the UA default (`canvas`) or a consumer-set
|
|
114
|
-
* background to show through.
|
|
115
|
-
*
|
|
116
|
-
* @example
|
|
117
|
-
* ```tsx
|
|
118
|
-
* import { arrow } from '@atlaskit/top-layer/arrow';
|
|
119
|
-
*
|
|
120
|
-
* const myArrow = arrow();
|
|
121
|
-
*
|
|
122
|
-
* <Popup.Content arrow={myArrow} />
|
|
123
|
-
* ```
|
|
124
|
-
*/
|
|
125
|
-
var arrow = exports.arrow = (0, _once.default)(function () {
|
|
126
|
-
return {
|
|
127
|
-
name: 'arrow',
|
|
128
|
-
css: ARROW_CSS,
|
|
129
|
-
getTryFallbacks: getTryFallbacks
|
|
130
|
-
};
|
|
131
|
-
});
|
package/dist/cjs/arrow/types.js
DELETED
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
import once from '@atlaskit/ds-lib/once';
|
|
2
|
-
import { getPlacement } from '../internal/resolve-placement';
|
|
3
|
-
import { placementToPositionArea } from '../internal/use-anchor-position';
|
|
4
|
-
/**
|
|
5
|
-
* CSS for popover arrows using the `clip-path: inset() margin-box` technique.
|
|
6
|
-
*
|
|
7
|
-
* How it works:
|
|
8
|
-
* 1. Four arrow shapes exist simultaneously as `::before` (top/bottom) and
|
|
9
|
-
* `::after` (left/right) hexagonal pseudo-elements.
|
|
10
|
-
* 2. `clip-path: inset(0) margin-box` clips the popover to its margin-box.
|
|
11
|
-
* 3. Margin on the anchor-facing side pushes the popover away, creating space
|
|
12
|
-
* where one arrow "escapes" the clip boundary and becomes visible.
|
|
13
|
-
* 4. `@position-try` rules change both `position-area` and `margin` when
|
|
14
|
-
* flipping, ensuring the correct arrow is always shown.
|
|
15
|
-
*
|
|
16
|
-
* Constraints:
|
|
17
|
-
* - `box-shadow` must be `none` (interferes with `clip-path: inset() margin-box`)
|
|
18
|
-
* - `::before` and `::after` are consumed - consumers cannot use them
|
|
19
|
-
* - Arrow pseudo-elements use `background: inherit` from the popover element
|
|
20
|
-
*
|
|
21
|
-
* @see https://goulet.dev/posts/tooltip-with-popover-and-anchor-positioning/
|
|
22
|
-
*/
|
|
23
|
-
const ARROW_CSS = `
|
|
24
|
-
[data-ds-popover-arrow] {
|
|
25
|
-
clip-path: inset(var(--ds-arrow-offset, 0px)) margin-box;
|
|
26
|
-
box-shadow: none;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/* Top and Bottom arrows (vertical hexagon) */
|
|
30
|
-
[data-ds-popover-arrow]::before {
|
|
31
|
-
content: "";
|
|
32
|
-
position: absolute;
|
|
33
|
-
z-index: -1;
|
|
34
|
-
background: inherit;
|
|
35
|
-
left: 50%;
|
|
36
|
-
transform: translateX(-50%);
|
|
37
|
-
width: calc(var(--ds-arrow-size, 8px) * 2);
|
|
38
|
-
height: calc(100% + var(--ds-arrow-size, 8px) * 2);
|
|
39
|
-
top: calc(var(--ds-arrow-size, 8px) * -1);
|
|
40
|
-
clip-path: polygon(
|
|
41
|
-
0 var(--ds-arrow-size, 8px),
|
|
42
|
-
50% 0,
|
|
43
|
-
100% var(--ds-arrow-size, 8px),
|
|
44
|
-
100% calc(100% - var(--ds-arrow-size, 8px)),
|
|
45
|
-
50% 100%,
|
|
46
|
-
0 calc(100% - var(--ds-arrow-size, 8px))
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/* Left and Right arrows (horizontal hexagon) */
|
|
51
|
-
[data-ds-popover-arrow]::after {
|
|
52
|
-
content: "";
|
|
53
|
-
position: absolute;
|
|
54
|
-
z-index: -1;
|
|
55
|
-
background: inherit;
|
|
56
|
-
top: 50%;
|
|
57
|
-
transform: translateY(-50%);
|
|
58
|
-
height: calc(var(--ds-arrow-size, 8px) * 2);
|
|
59
|
-
width: calc(100% + var(--ds-arrow-size, 8px) * 2);
|
|
60
|
-
left: calc(var(--ds-arrow-size, 8px) * -1);
|
|
61
|
-
clip-path: polygon(
|
|
62
|
-
var(--ds-arrow-size, 8px) 0,
|
|
63
|
-
calc(100% - var(--ds-arrow-size, 8px)) 0,
|
|
64
|
-
100% 50%,
|
|
65
|
-
calc(100% - var(--ds-arrow-size, 8px)) 100%,
|
|
66
|
-
var(--ds-arrow-size, 8px) 100%,
|
|
67
|
-
0 50%
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/* ── @position-try rules ──
|
|
72
|
-
* One rule per possible position-area value.
|
|
73
|
-
* Each sets the position-area and the correct margin direction
|
|
74
|
-
* so the arrow on the anchor-facing side is revealed.
|
|
75
|
-
*
|
|
76
|
-
* Margin direction per edge:
|
|
77
|
-
* block-start (above anchor) → margin-block-end (bottom, facing anchor)
|
|
78
|
-
* block-end (below anchor) → margin-block-start (top, facing anchor)
|
|
79
|
-
* inline-start (left of anchor) → margin-inline-end (right, facing anchor)
|
|
80
|
-
* inline-end (right of anchor) → margin-inline-start (left, facing anchor)
|
|
81
|
-
*/
|
|
82
|
-
|
|
83
|
-
/* Each rule sets two margins: the anchor-facing margin for the gap
|
|
84
|
-
(via --ds-arrow-size) and one cross-axis margin for the shift
|
|
85
|
-
(via one of --ds-cross-axis-shift-margin-start, --ds-cross-axis-shift-margin-end,
|
|
86
|
-
--ds-cross-axis-shift-margin-block-start, or --ds-cross-axis-shift-margin-block-end). The
|
|
87
|
-
side matches the popover's anchored cross-axis edge per align. Only
|
|
88
|
-
one of the four properties is non-zero at a time; useAnchorPosition
|
|
89
|
-
picks it. See notes/architecture/positioning.md for details. */
|
|
90
|
-
/* Single-axis centered (align: center) */
|
|
91
|
-
@position-try --ds-arrow-block-start {
|
|
92
|
-
position-area: block-start;
|
|
93
|
-
margin: 0;
|
|
94
|
-
margin-block-end: var(--ds-arrow-size, 8px);
|
|
95
|
-
margin-inline-start: var(--ds-cross-axis-shift-margin-start, 0px);
|
|
96
|
-
}
|
|
97
|
-
@position-try --ds-arrow-block-end {
|
|
98
|
-
position-area: block-end;
|
|
99
|
-
margin: 0;
|
|
100
|
-
margin-block-start: var(--ds-arrow-size, 8px);
|
|
101
|
-
margin-inline-start: var(--ds-cross-axis-shift-margin-start, 0px);
|
|
102
|
-
}
|
|
103
|
-
@position-try --ds-arrow-inline-start {
|
|
104
|
-
position-area: inline-start;
|
|
105
|
-
margin: 0;
|
|
106
|
-
margin-inline-end: var(--ds-arrow-size, 8px);
|
|
107
|
-
margin-block-start: var(--ds-cross-axis-shift-margin-block-start, 0px);
|
|
108
|
-
}
|
|
109
|
-
@position-try --ds-arrow-inline-end {
|
|
110
|
-
position-area: inline-end;
|
|
111
|
-
margin: 0;
|
|
112
|
-
margin-inline-start: var(--ds-arrow-size, 8px);
|
|
113
|
-
margin-block-start: var(--ds-cross-axis-shift-margin-block-start, 0px);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/* Block edge + inline span (align: start uses span-inline-end; align: end uses span-inline-start) */
|
|
117
|
-
@position-try --ds-arrow-block-start-span-inline-start {
|
|
118
|
-
position-area: block-start span-inline-start;
|
|
119
|
-
margin: 0;
|
|
120
|
-
margin-block-end: var(--ds-arrow-size, 8px);
|
|
121
|
-
margin-inline-end: var(--ds-cross-axis-shift-margin-end, 0px);
|
|
122
|
-
}
|
|
123
|
-
@position-try --ds-arrow-block-start-span-inline-end {
|
|
124
|
-
position-area: block-start span-inline-end;
|
|
125
|
-
margin: 0;
|
|
126
|
-
margin-block-end: var(--ds-arrow-size, 8px);
|
|
127
|
-
margin-inline-start: var(--ds-cross-axis-shift-margin-start, 0px);
|
|
128
|
-
}
|
|
129
|
-
@position-try --ds-arrow-block-end-span-inline-start {
|
|
130
|
-
position-area: block-end span-inline-start;
|
|
131
|
-
margin: 0;
|
|
132
|
-
margin-block-start: var(--ds-arrow-size, 8px);
|
|
133
|
-
margin-inline-end: var(--ds-cross-axis-shift-margin-end, 0px);
|
|
134
|
-
}
|
|
135
|
-
@position-try --ds-arrow-block-end-span-inline-end {
|
|
136
|
-
position-area: block-end span-inline-end;
|
|
137
|
-
margin: 0;
|
|
138
|
-
margin-block-start: var(--ds-arrow-size, 8px);
|
|
139
|
-
margin-inline-start: var(--ds-cross-axis-shift-margin-start, 0px);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/* Inline edge + block span (align: start uses span-block-end; align: end uses span-block-start) */
|
|
143
|
-
@position-try --ds-arrow-inline-start-span-block-start {
|
|
144
|
-
position-area: inline-start span-block-start;
|
|
145
|
-
margin: 0;
|
|
146
|
-
margin-inline-end: var(--ds-arrow-size, 8px);
|
|
147
|
-
margin-block-end: var(--ds-cross-axis-shift-margin-block-end, 0px);
|
|
148
|
-
}
|
|
149
|
-
@position-try --ds-arrow-inline-start-span-block-end {
|
|
150
|
-
position-area: inline-start span-block-end;
|
|
151
|
-
margin: 0;
|
|
152
|
-
margin-inline-end: var(--ds-arrow-size, 8px);
|
|
153
|
-
margin-block-start: var(--ds-cross-axis-shift-margin-block-start, 0px);
|
|
154
|
-
}
|
|
155
|
-
@position-try --ds-arrow-inline-end-span-block-start {
|
|
156
|
-
position-area: inline-end span-block-start;
|
|
157
|
-
margin: 0;
|
|
158
|
-
margin-inline-start: var(--ds-arrow-size, 8px);
|
|
159
|
-
margin-block-end: var(--ds-cross-axis-shift-margin-block-end, 0px);
|
|
160
|
-
}
|
|
161
|
-
@position-try --ds-arrow-inline-end-span-block-end {
|
|
162
|
-
position-area: inline-end span-block-end;
|
|
163
|
-
margin: 0;
|
|
164
|
-
margin-inline-start: var(--ds-arrow-size, 8px);
|
|
165
|
-
margin-block-start: var(--ds-cross-axis-shift-margin-block-start, 0px);
|
|
166
|
-
}
|
|
167
|
-
`;
|
|
168
|
-
|
|
169
|
-
// ── Placement utilities ──
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Converts a `position-area` value to a CSS rule name by replacing spaces with hyphens
|
|
173
|
-
* and prepending `--ds-arrow-`.
|
|
174
|
-
*
|
|
175
|
-
* @example positionAreaToRuleName('block-end span-inline-start') → '--ds-arrow-block-end-span-inline-start'
|
|
176
|
-
*/
|
|
177
|
-
function positionAreaToRuleName({
|
|
178
|
-
positionArea
|
|
179
|
-
}) {
|
|
180
|
-
return `--ds-arrow-${positionArea.replace(/ /g, '-')}`;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Returns `position-try-fallbacks` using named `@position-try` rules
|
|
185
|
-
* that change both `position-area` and `margin` when flipping.
|
|
186
|
-
*
|
|
187
|
-
* This is required for the arrow technique because built-in keywords
|
|
188
|
-
* (`flip-block`, `flip-inline`) only flip `position-area` - they do
|
|
189
|
-
* not update the margin direction needed to reveal the correct arrow.
|
|
190
|
-
*/
|
|
191
|
-
function getTryFallbacks({
|
|
192
|
-
placement
|
|
193
|
-
}) {
|
|
194
|
-
const {
|
|
195
|
-
axis,
|
|
196
|
-
edge,
|
|
197
|
-
align
|
|
198
|
-
} = getPlacement({
|
|
199
|
-
placement
|
|
200
|
-
});
|
|
201
|
-
if (align === 'center') {
|
|
202
|
-
// Single-axis: only flip the edge
|
|
203
|
-
const flippedEdge = edge === 'start' ? 'end' : 'start';
|
|
204
|
-
return positionAreaToRuleName({
|
|
205
|
-
positionArea: placementToPositionArea({
|
|
206
|
-
placement: {
|
|
207
|
-
axis,
|
|
208
|
-
edge: flippedEdge
|
|
209
|
-
}
|
|
210
|
-
})
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// Compound placement: try flipping edge, alignment, and both
|
|
215
|
-
const flippedEdge = edge === 'start' ? 'end' : 'start';
|
|
216
|
-
const flippedAlign = align === 'start' ? 'end' : 'start';
|
|
217
|
-
return [positionAreaToRuleName({
|
|
218
|
-
positionArea: placementToPositionArea({
|
|
219
|
-
placement: {
|
|
220
|
-
axis,
|
|
221
|
-
edge: flippedEdge,
|
|
222
|
-
align
|
|
223
|
-
}
|
|
224
|
-
})
|
|
225
|
-
}), positionAreaToRuleName({
|
|
226
|
-
positionArea: placementToPositionArea({
|
|
227
|
-
placement: {
|
|
228
|
-
axis,
|
|
229
|
-
edge,
|
|
230
|
-
align: flippedAlign
|
|
231
|
-
}
|
|
232
|
-
})
|
|
233
|
-
}), positionAreaToRuleName({
|
|
234
|
-
positionArea: placementToPositionArea({
|
|
235
|
-
placement: {
|
|
236
|
-
axis,
|
|
237
|
-
edge: flippedEdge,
|
|
238
|
-
align: flippedAlign
|
|
239
|
-
}
|
|
240
|
-
})
|
|
241
|
-
})].join(', ');
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Creates an arrow preset for popover content.
|
|
246
|
-
*
|
|
247
|
-
* The returned object is passed to `PopoverContent`'s `arrow` prop.
|
|
248
|
-
* It carries the CSS string and fallback logic so that consumers who
|
|
249
|
-
* do not use arrows pay no bundle cost.
|
|
250
|
-
*
|
|
251
|
-
* The arrows inherit their background from the popover element.
|
|
252
|
-
* When `arrow` is active, `PopoverContent` does not reset `background`
|
|
253
|
-
* to `transparent`, allowing the UA default (`canvas`) or a consumer-set
|
|
254
|
-
* background to show through.
|
|
255
|
-
*
|
|
256
|
-
* @example
|
|
257
|
-
* ```tsx
|
|
258
|
-
* import { arrow } from '@atlaskit/top-layer/arrow';
|
|
259
|
-
*
|
|
260
|
-
* const myArrow = arrow();
|
|
261
|
-
*
|
|
262
|
-
* <Popup.Content arrow={myArrow} />
|
|
263
|
-
* ```
|
|
264
|
-
*/
|
|
265
|
-
export const arrow = once(() => ({
|
|
266
|
-
name: 'arrow',
|
|
267
|
-
css: ARROW_CSS,
|
|
268
|
-
getTryFallbacks
|
|
269
|
-
}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|