@atlaskit/top-layer 0.12.2 → 0.14.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 +31 -0
- package/README.md +61 -34
- package/dist/cjs/animations/presets.js +4 -4
- package/dist/cjs/entry-points/focus.js +6 -4
- package/dist/cjs/entry-points/get-aria-for-trigger.js +12 -0
- package/dist/cjs/entry-points/popover-surface.js +12 -0
- package/dist/cjs/entry-points/use-anchor-position-at-point.js +12 -0
- package/dist/cjs/entry-points/use-popover-id.js +21 -0
- package/dist/cjs/focus/get-first-focusable.js +19 -0
- package/dist/cjs/focus/get-focusables.js +30 -0
- package/dist/cjs/focus/get-last-focusable.js +19 -0
- package/dist/cjs/focus/get-next-focusable.js +43 -0
- package/dist/cjs/focus/is-in-same-layer.js +23 -0
- package/dist/cjs/focus/is-nested-layer-focused.js +32 -0
- package/dist/cjs/focus/selectors.js +19 -0
- package/dist/cjs/focus/types.js +1 -0
- package/dist/cjs/internal/get-aria-for-trigger.js +88 -0
- package/dist/cjs/internal/role-to-aria-has-popup.js +37 -0
- package/dist/cjs/internal/role-types.js +2 -35
- package/dist/cjs/internal/should-focus-into-popover.js +19 -0
- package/dist/cjs/internal/slot.js +1 -1
- package/dist/cjs/internal/use-anchor-position-at-point.js +127 -0
- package/dist/cjs/internal/use-anchor-position.js +36 -16
- package/dist/cjs/internal/use-focus-wrap.js +8 -5
- package/dist/cjs/internal/use-initial-focus.js +4 -4
- package/dist/cjs/placement-map/index.js +2 -2
- package/dist/cjs/placement-map/legacy-placements.js +2 -101
- package/dist/cjs/placement-map/placement-mapping.js +103 -0
- package/dist/cjs/popover/popover.js +79 -80
- package/dist/cjs/popover-surface/index.js +12 -0
- package/dist/cjs/{popup/popup-surface.js → popover-surface/popover-surface.js} +9 -12
- package/dist/cjs/testing/polyfill.js +9 -6
- package/dist/cjs/use-arrow-navigation/use-arrow-navigation.js +7 -5
- package/dist/es2019/animations/presets.js +4 -4
- package/dist/es2019/entry-points/focus.js +3 -1
- package/dist/es2019/entry-points/get-aria-for-trigger.js +1 -0
- package/dist/es2019/entry-points/popover-surface.js +1 -0
- package/dist/es2019/entry-points/use-anchor-position-at-point.js +1 -0
- package/dist/es2019/entry-points/use-popover-id.js +15 -0
- package/dist/es2019/focus/get-first-focusable.js +14 -0
- package/dist/es2019/focus/get-focusables.js +19 -0
- package/dist/es2019/focus/get-last-focusable.js +14 -0
- package/dist/es2019/focus/get-next-focusable.js +38 -0
- package/dist/es2019/focus/is-in-same-layer.js +18 -0
- package/dist/es2019/focus/is-nested-layer-focused.js +28 -0
- package/dist/es2019/focus/selectors.js +11 -0
- package/dist/es2019/focus/types.js +0 -0
- package/dist/es2019/internal/get-aria-for-trigger.js +84 -0
- package/dist/es2019/internal/role-to-aria-has-popup.js +32 -0
- package/dist/es2019/internal/role-types.js +0 -33
- package/dist/es2019/internal/should-focus-into-popover.js +14 -0
- package/dist/es2019/internal/slot.js +1 -1
- package/dist/es2019/internal/use-anchor-position-at-point.js +122 -0
- package/dist/es2019/internal/use-anchor-position.js +21 -14
- package/dist/es2019/internal/use-focus-wrap.js +4 -1
- package/dist/es2019/internal/use-initial-focus.js +1 -1
- package/dist/es2019/placement-map/index.js +1 -1
- package/dist/es2019/placement-map/legacy-placements.js +1 -100
- package/dist/es2019/placement-map/placement-mapping.js +97 -0
- package/dist/es2019/popover/popover.js +79 -80
- package/dist/es2019/popover-surface/index.js +1 -0
- package/dist/es2019/popover-surface/popover-surface.js +27 -0
- package/dist/es2019/testing/polyfill.js +9 -6
- package/dist/es2019/use-arrow-navigation/use-arrow-navigation.js +3 -1
- package/dist/esm/animations/presets.js +4 -4
- package/dist/esm/entry-points/focus.js +3 -1
- package/dist/esm/entry-points/get-aria-for-trigger.js +1 -0
- package/dist/esm/entry-points/popover-surface.js +1 -0
- package/dist/esm/entry-points/use-anchor-position-at-point.js +1 -0
- package/dist/esm/entry-points/use-popover-id.js +15 -0
- package/dist/esm/focus/get-first-focusable.js +13 -0
- package/dist/esm/focus/get-focusables.js +24 -0
- package/dist/esm/focus/get-last-focusable.js +13 -0
- package/dist/esm/focus/get-next-focusable.js +37 -0
- package/dist/esm/focus/is-in-same-layer.js +17 -0
- package/dist/esm/focus/is-nested-layer-focused.js +27 -0
- package/dist/esm/focus/selectors.js +13 -0
- package/dist/esm/focus/types.js +0 -0
- package/dist/esm/internal/get-aria-for-trigger.js +83 -0
- package/dist/esm/internal/role-to-aria-has-popup.js +31 -0
- package/dist/esm/internal/role-types.js +2 -34
- package/dist/esm/internal/should-focus-into-popover.js +13 -0
- package/dist/esm/internal/slot.js +1 -1
- package/dist/esm/internal/use-anchor-position-at-point.js +122 -0
- package/dist/esm/internal/use-anchor-position.js +36 -16
- package/dist/esm/internal/use-focus-wrap.js +4 -1
- package/dist/esm/internal/use-initial-focus.js +1 -1
- package/dist/esm/placement-map/index.js +1 -1
- package/dist/esm/placement-map/legacy-placements.js +1 -100
- package/dist/esm/placement-map/placement-mapping.js +97 -0
- package/dist/esm/popover/popover.js +79 -80
- package/dist/esm/popover-surface/index.js +1 -0
- package/dist/esm/popover-surface/popover-surface.js +26 -0
- package/dist/esm/testing/polyfill.js +9 -6
- package/dist/esm/use-arrow-navigation/use-arrow-navigation.js +3 -1
- package/dist/types/animations/presets.d.ts +4 -4
- package/dist/types/animations/types.d.ts +1 -1
- package/dist/types/dialog/types.d.ts +0 -8
- package/dist/types/entry-points/focus.d.ts +4 -2
- package/dist/types/entry-points/get-aria-for-trigger.d.ts +1 -0
- package/dist/types/entry-points/popover-surface.d.ts +2 -0
- package/dist/types/entry-points/popover.d.ts +1 -1
- package/dist/types/entry-points/use-anchor-position-at-point.d.ts +1 -0
- package/dist/types/entry-points/use-popover-id.d.ts +11 -0
- package/dist/types/focus/get-first-focusable.d.ts +8 -0
- package/dist/types/focus/get-focusables.d.ts +13 -0
- package/dist/types/focus/get-last-focusable.d.ts +8 -0
- package/dist/types/focus/get-next-focusable.d.ts +13 -0
- package/dist/types/focus/is-in-same-layer.d.ts +8 -0
- package/dist/types/focus/is-nested-layer-focused.d.ts +8 -0
- package/dist/types/focus/selectors.d.ts +4 -0
- package/dist/types/focus/types.d.ts +5 -0
- package/dist/types/internal/get-aria-for-trigger.d.ts +86 -0
- package/dist/types/internal/role-to-aria-has-popup.d.ts +13 -0
- package/dist/types/internal/role-types.d.ts +0 -12
- package/dist/types/internal/should-focus-into-popover.d.ts +8 -0
- package/dist/types/internal/slot.d.ts +2 -2
- package/dist/types/internal/use-anchor-position-at-point.d.ts +62 -0
- package/dist/types/internal/use-anchor-position.d.ts +6 -1
- package/dist/types/placement-map/index.d.ts +1 -1
- package/dist/types/placement-map/legacy-placements.d.ts +0 -12
- package/dist/types/placement-map/placement-mapping.d.ts +13 -0
- package/dist/types/popover/index.d.ts +1 -1
- package/dist/types/popover/popover.d.ts +6 -13
- package/dist/types/popover/types.d.ts +6 -5
- package/dist/types/popover-surface/index.d.ts +2 -0
- package/dist/types/popover-surface/popover-surface.d.ts +21 -0
- package/dist/types/use-arrow-navigation/use-arrow-navigation.d.ts +1 -1
- package/dist/types-ts4.5/animations/presets.d.ts +4 -4
- package/dist/types-ts4.5/animations/types.d.ts +1 -1
- package/dist/types-ts4.5/dialog/types.d.ts +0 -8
- package/dist/types-ts4.5/entry-points/focus.d.ts +4 -2
- package/dist/types-ts4.5/entry-points/get-aria-for-trigger.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/popover-surface.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/popover.d.ts +1 -1
- package/dist/types-ts4.5/entry-points/use-anchor-position-at-point.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/use-popover-id.d.ts +11 -0
- package/dist/types-ts4.5/focus/get-first-focusable.d.ts +8 -0
- package/dist/types-ts4.5/focus/get-focusables.d.ts +13 -0
- package/dist/types-ts4.5/focus/get-last-focusable.d.ts +8 -0
- package/dist/types-ts4.5/focus/get-next-focusable.d.ts +13 -0
- package/dist/types-ts4.5/focus/is-in-same-layer.d.ts +8 -0
- package/dist/types-ts4.5/focus/is-nested-layer-focused.d.ts +8 -0
- package/dist/types-ts4.5/focus/selectors.d.ts +4 -0
- package/dist/types-ts4.5/focus/types.d.ts +5 -0
- package/dist/types-ts4.5/internal/get-aria-for-trigger.d.ts +86 -0
- package/dist/types-ts4.5/internal/role-to-aria-has-popup.d.ts +13 -0
- package/dist/types-ts4.5/internal/role-types.d.ts +0 -12
- package/dist/types-ts4.5/internal/should-focus-into-popover.d.ts +8 -0
- package/dist/types-ts4.5/internal/slot.d.ts +2 -2
- package/dist/types-ts4.5/internal/use-anchor-position-at-point.d.ts +62 -0
- package/dist/types-ts4.5/internal/use-anchor-position.d.ts +6 -1
- package/dist/types-ts4.5/placement-map/index.d.ts +1 -1
- package/dist/types-ts4.5/placement-map/legacy-placements.d.ts +0 -12
- package/dist/types-ts4.5/placement-map/placement-mapping.d.ts +13 -0
- package/dist/types-ts4.5/popover/index.d.ts +1 -1
- package/dist/types-ts4.5/popover/popover.d.ts +6 -13
- package/dist/types-ts4.5/popover/types.d.ts +6 -5
- package/dist/types-ts4.5/popover-surface/index.d.ts +2 -0
- package/dist/types-ts4.5/popover-surface/popover-surface.d.ts +21 -0
- package/dist/types-ts4.5/use-arrow-navigation/use-arrow-navigation.d.ts +1 -1
- package/get-aria-for-trigger/package.json +17 -0
- package/package.json +3 -3
- package/popover-surface/package.json +17 -0
- package/use-anchor-position-at-point/package.json +17 -0
- package/use-popover-id/package.json +17 -0
- package/dist/cjs/entry-points/popup-surface.js +0 -12
- package/dist/cjs/entry-points/popup.js +0 -12
- package/dist/cjs/focus/focus.js +0 -169
- package/dist/cjs/focus/index.js +0 -24
- package/dist/cjs/popup/index.js +0 -37
- package/dist/cjs/popup/popup-content.js +0 -214
- package/dist/cjs/popup/popup-context.js +0 -25
- package/dist/cjs/popup/popup-provider.js +0 -15
- package/dist/cjs/popup/popup-trigger-function.js +0 -80
- package/dist/cjs/popup/popup-trigger.js +0 -66
- package/dist/cjs/popup/popup.js +0 -81
- package/dist/cjs/popup/types.js +0 -5
- package/dist/cjs/popup/use-maybe-popup-context.js +0 -17
- package/dist/cjs/popup/use-popup-context.js +0 -20
- package/dist/es2019/entry-points/popup-surface.js +0 -1
- package/dist/es2019/entry-points/popup.js +0 -1
- package/dist/es2019/focus/focus.js +0 -158
- package/dist/es2019/focus/index.js +0 -1
- package/dist/es2019/popup/index.js +0 -33
- package/dist/es2019/popup/popup-content.js +0 -206
- package/dist/es2019/popup/popup-context.js +0 -20
- package/dist/es2019/popup/popup-provider.js +0 -10
- package/dist/es2019/popup/popup-surface.js +0 -30
- package/dist/es2019/popup/popup-trigger-function.js +0 -75
- package/dist/es2019/popup/popup-trigger.js +0 -61
- package/dist/es2019/popup/popup.js +0 -67
- package/dist/es2019/popup/types.js +0 -1
- package/dist/es2019/popup/use-maybe-popup-context.js +0 -12
- package/dist/es2019/popup/use-popup-context.js +0 -15
- package/dist/esm/entry-points/popup-surface.js +0 -1
- package/dist/esm/entry-points/popup.js +0 -1
- package/dist/esm/focus/focus.js +0 -160
- package/dist/esm/focus/index.js +0 -1
- package/dist/esm/popup/index.js +0 -33
- package/dist/esm/popup/popup-content.js +0 -206
- package/dist/esm/popup/popup-context.js +0 -20
- package/dist/esm/popup/popup-provider.js +0 -10
- package/dist/esm/popup/popup-surface.js +0 -29
- package/dist/esm/popup/popup-trigger-function.js +0 -75
- package/dist/esm/popup/popup-trigger.js +0 -59
- package/dist/esm/popup/popup.js +0 -72
- package/dist/esm/popup/types.js +0 -1
- package/dist/esm/popup/use-maybe-popup-context.js +0 -12
- package/dist/esm/popup/use-popup-context.js +0 -15
- package/dist/types/entry-points/popup-surface.d.ts +0 -2
- package/dist/types/entry-points/popup.d.ts +0 -2
- package/dist/types/focus/focus.d.ts +0 -50
- package/dist/types/focus/index.d.ts +0 -2
- package/dist/types/popup/index.d.ts +0 -34
- package/dist/types/popup/popup-content.d.ts +0 -14
- package/dist/types/popup/popup-context.d.ts +0 -96
- package/dist/types/popup/popup-provider.d.ts +0 -10
- package/dist/types/popup/popup-surface.d.ts +0 -22
- package/dist/types/popup/popup-trigger-function.d.ts +0 -112
- package/dist/types/popup/popup-trigger.d.ts +0 -14
- package/dist/types/popup/popup.d.ts +0 -14
- package/dist/types/popup/types.d.ts +0 -321
- package/dist/types/popup/use-maybe-popup-context.d.ts +0 -8
- package/dist/types/popup/use-popup-context.d.ts +0 -7
- package/dist/types-ts4.5/entry-points/popup-surface.d.ts +0 -2
- package/dist/types-ts4.5/entry-points/popup.d.ts +0 -2
- package/dist/types-ts4.5/focus/focus.d.ts +0 -50
- package/dist/types-ts4.5/focus/index.d.ts +0 -2
- package/dist/types-ts4.5/popup/index.d.ts +0 -34
- package/dist/types-ts4.5/popup/popup-content.d.ts +0 -14
- package/dist/types-ts4.5/popup/popup-context.d.ts +0 -96
- package/dist/types-ts4.5/popup/popup-provider.d.ts +0 -10
- package/dist/types-ts4.5/popup/popup-surface.d.ts +0 -22
- package/dist/types-ts4.5/popup/popup-trigger-function.d.ts +0 -112
- package/dist/types-ts4.5/popup/popup-trigger.d.ts +0 -14
- package/dist/types-ts4.5/popup/popup.d.ts +0 -14
- package/dist/types-ts4.5/popup/types.d.ts +0 -321
- package/dist/types-ts4.5/popup/use-maybe-popup-context.d.ts +0 -8
- package/dist/types-ts4.5/popup/use-popup-context.d.ts +0 -7
- package/popup/package.json +0 -17
- package/popup-surface/package.json +0 -17
- /package/dist/cjs/{popup/popup-surface.compiled.css → popover-surface/popover-surface.compiled.css} +0 -0
- /package/dist/es2019/{popup/popup-surface.compiled.css → popover-surface/popover-surface.compiled.css} +0 -0
- /package/dist/esm/{popup/popup-surface.compiled.css → popover-surface/popover-surface.compiled.css} +0 -0
package/dist/esm/popup/popup.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import React, { useCallback, useId, useRef, useState } from 'react';
|
|
3
|
-
import { PopupProvider } from './popup-provider';
|
|
4
|
-
/**
|
|
5
|
-
* Popup compound: trigger + popover content.
|
|
6
|
-
*
|
|
7
|
-
* Use when a button opens anchored content (dropdown, menu, dialog).
|
|
8
|
-
* The browser manages visibility via `togglePopover()`; the consumer
|
|
9
|
-
* never manages `isOpen`. For custom trigger lifecycles (hover, timers,
|
|
10
|
-
* external state), use `Popover` directly instead.
|
|
11
|
-
*
|
|
12
|
-
* Provides context (triggerRef, placement, isOpen, onClose, mode) that
|
|
13
|
-
* `Popup.Content` reads and forwards to the underlying `Popover`.
|
|
14
|
-
*/
|
|
15
|
-
export function PopupRoot(props) {
|
|
16
|
-
var _props$placement, _props$mode;
|
|
17
|
-
var children = props.children,
|
|
18
|
-
testId = props.testId,
|
|
19
|
-
forceFallbackPositioning = props.forceFallbackPositioning,
|
|
20
|
-
onOpenChange = props.onOpenChange;
|
|
21
|
-
// `{}` resolves to "below the trigger, centered, with `space.100` gap"
|
|
22
|
-
// inside `useAnchorPosition`, which is the common case.
|
|
23
|
-
var placement = (_props$placement = props.placement) !== null && _props$placement !== void 0 ? _props$placement : {};
|
|
24
|
-
var mode = (_props$mode = props.mode) !== null && _props$mode !== void 0 ? _props$mode : 'auto';
|
|
25
|
-
|
|
26
|
-
// `TPopupProps` discriminates on `mode`: `manual` types `onClose` as
|
|
27
|
-
// `never`, so for manual consumers `props.onClose` is always `undefined`
|
|
28
|
-
// here. No runtime guard needed; the type contract carries the rule.
|
|
29
|
-
var onClose = props.onClose;
|
|
30
|
-
var id = useId();
|
|
31
|
-
// `useId()` returns IDs containing colons (`:r1:`), which are invalid
|
|
32
|
-
// in CSS selectors and `popover` target attributes. `replaceAll` is
|
|
33
|
-
// not in our browser matrix.
|
|
34
|
-
var sanitizedId = id.replace(/:/g, '');
|
|
35
|
-
var popoverId = "popover-".concat(sanitizedId);
|
|
36
|
-
var triggerRef = useRef(null);
|
|
37
|
-
var popoverRef = useRef(null);
|
|
38
|
-
var _useState = useState('closed'),
|
|
39
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
40
|
-
popupState = _useState2[0],
|
|
41
|
-
setPopupState = _useState2[1];
|
|
42
|
-
// Initial seed before `Popup.Content`'s layout effect resolves the
|
|
43
|
-
// real role on first paint.
|
|
44
|
-
var _useState3 = useState('dialog'),
|
|
45
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
46
|
-
ariaHasPopup = _useState4[0],
|
|
47
|
-
setAriaHasPopup = _useState4[1];
|
|
48
|
-
var handleClose = useCallback(function (args) {
|
|
49
|
-
onClose === null || onClose === void 0 || onClose(args);
|
|
50
|
-
}, [onClose]);
|
|
51
|
-
var contextValue = {
|
|
52
|
-
popoverId: popoverId,
|
|
53
|
-
placement: placement,
|
|
54
|
-
// `null` when the consumer did not supply a handler (manual mode, or
|
|
55
|
-
// auto/hint without a light-dismiss handler). `Popup.Content` reads
|
|
56
|
-
// this to decide whether to forward an `onClose` to `Popover`.
|
|
57
|
-
onClose: onClose ? handleClose : null,
|
|
58
|
-
triggerRef: triggerRef,
|
|
59
|
-
popoverRef: popoverRef,
|
|
60
|
-
popupState: popupState,
|
|
61
|
-
setPopupState: setPopupState,
|
|
62
|
-
onOpenChange: onOpenChange,
|
|
63
|
-
mode: mode,
|
|
64
|
-
ariaHasPopup: ariaHasPopup,
|
|
65
|
-
setAriaHasPopup: setAriaHasPopup,
|
|
66
|
-
testId: testId,
|
|
67
|
-
forceFallbackPositioning: forceFallbackPositioning
|
|
68
|
-
};
|
|
69
|
-
return /*#__PURE__*/React.createElement(PopupProvider, {
|
|
70
|
-
value: contextValue
|
|
71
|
-
}, children);
|
|
72
|
-
}
|
package/dist/esm/popup/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { useContext } from 'react';
|
|
2
|
-
import { PopupContext } from './popup-context';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Returns the popup context if available, or `null` when used outside `<Popup>`.
|
|
6
|
-
*
|
|
7
|
-
* Used by `PopupContent` to support standalone usage (e.g. tooltip)
|
|
8
|
-
* where values are passed as props instead of coming from a compound component.
|
|
9
|
-
*/
|
|
10
|
-
export function useMaybePopupContext() {
|
|
11
|
-
return useContext(PopupContext);
|
|
12
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { useContext } from 'react';
|
|
2
|
-
import { PopupContext } from './popup-context';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Returns the nearest `Popup` context value.
|
|
6
|
-
*
|
|
7
|
-
* Throws if called outside of a `<Popup>` compound component.
|
|
8
|
-
*/
|
|
9
|
-
export function usePopupContext() {
|
|
10
|
-
var ctx = useContext(PopupContext);
|
|
11
|
-
if (ctx === null) {
|
|
12
|
-
throw new Error('@atlaskit/top-layer: Popup compound components must be used within <Popup>.');
|
|
13
|
-
}
|
|
14
|
-
return ctx;
|
|
15
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
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
|
-
* Returns `true` when `document.activeElement` is inside a nested top-layer
|
|
14
|
-
* descendant of `container` (a `[popover]`, `<dialog>`, `[role="dialog"]` or
|
|
15
|
-
* `[role="alertdialog"]` that is itself a descendant of `container`).
|
|
16
|
-
*/
|
|
17
|
-
export declare function isNestedLayerFocused({ container }: {
|
|
18
|
-
container: HTMLElement;
|
|
19
|
-
}): boolean;
|
|
20
|
-
/**
|
|
21
|
-
* An optional callback to restrict which focusable elements are included.
|
|
22
|
-
* Return `true` to include the element, `false` to skip it.
|
|
23
|
-
*/
|
|
24
|
-
export type TFocusableFilter = (element: HTMLElement, container: HTMLElement) => boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Returns the first focusable element within the container.
|
|
27
|
-
*/
|
|
28
|
-
export declare function getFirstFocusable({ container, filter, }: {
|
|
29
|
-
container: HTMLElement;
|
|
30
|
-
filter?: TFocusableFilter;
|
|
31
|
-
}): HTMLElement | null;
|
|
32
|
-
/**
|
|
33
|
-
* Returns the last focusable element within the container.
|
|
34
|
-
*/
|
|
35
|
-
export declare function getLastFocusable({ container, filter, }: {
|
|
36
|
-
container: HTMLElement;
|
|
37
|
-
filter?: TFocusableFilter;
|
|
38
|
-
}): HTMLElement | null;
|
|
39
|
-
/**
|
|
40
|
-
* Returns the next focusable element in the given direction relative to the
|
|
41
|
-
* currently focused element within the container. Wraps around at both ends.
|
|
42
|
-
*
|
|
43
|
-
* Returns `null` if there is no focused element within the container or if
|
|
44
|
-
* the focused element is not in the list of focusable elements.
|
|
45
|
-
*/
|
|
46
|
-
export declare function getNextFocusable({ container, direction, filter, }: {
|
|
47
|
-
container: HTMLElement;
|
|
48
|
-
direction: 'forwards' | 'backwards';
|
|
49
|
-
filter?: TFocusableFilter;
|
|
50
|
-
}): HTMLElement | null;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { PopupRoot } from './popup';
|
|
2
|
-
import { PopupContent } from './popup-content';
|
|
3
|
-
import { PopupSurface } from './popup-surface';
|
|
4
|
-
import { PopupTrigger } from './popup-trigger';
|
|
5
|
-
import { PopupTriggerFunction } from './popup-trigger-function';
|
|
6
|
-
/**
|
|
7
|
-
* Compound component for rendering content in the browser's top layer
|
|
8
|
-
* using the native Popover API (`popover="auto"`).
|
|
9
|
-
* Placement is owned by this compound: root provides it via context, Content applies it
|
|
10
|
-
* (CSS Anchor Positioning or JS fallback).
|
|
11
|
-
*
|
|
12
|
-
* For default overlay styling (background, shadow, border-radius), see `PopupSurface` in the package examples.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```tsx
|
|
16
|
-
* <Popup placement={{ edge: 'end' }} onClose={handleClose}>
|
|
17
|
-
* <Popup.Trigger>
|
|
18
|
-
* <button>Open</button>
|
|
19
|
-
* </Popup.Trigger>
|
|
20
|
-
* <Popup.Content role="dialog" label="My popup">
|
|
21
|
-
* Content goes here
|
|
22
|
-
* </Popup.Content>
|
|
23
|
-
* </Popup>
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
declare const Popup: typeof PopupRoot & {
|
|
27
|
-
Trigger: typeof PopupTrigger;
|
|
28
|
-
TriggerFunction: typeof PopupTriggerFunction;
|
|
29
|
-
Content: typeof PopupContent;
|
|
30
|
-
Surface: typeof PopupSurface;
|
|
31
|
-
};
|
|
32
|
-
export { Popup };
|
|
33
|
-
export type { TPlacementOptions, TPopupProps, TPopupContentProps, TPopupRole, TPopupSurfaceProps, TPopupTriggerProps, } from './types';
|
|
34
|
-
export type { TTriggerFunctionRenderProps } from './popup-trigger-function';
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jsxRuntime classic
|
|
3
|
-
* @jsx jsx
|
|
4
|
-
*/
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { type TPopupContentProps } from './types';
|
|
7
|
-
/**
|
|
8
|
-
* Thin context wrapper that composes `Popover` + `useAnchorPosition`.
|
|
9
|
-
*
|
|
10
|
-
* Used inside the `<Popup>` compound - reads triggerRef, placement, isOpen,
|
|
11
|
-
* and onClose from context. For standalone usage (tooltip, spotlight, flag),
|
|
12
|
-
* use `Popover` + `useAnchorPosition` directly.
|
|
13
|
-
*/
|
|
14
|
-
export declare const PopupContent: React.ForwardRefExoticComponent<TPopupContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import React, { type MutableRefObject, type RefObject } from 'react';
|
|
2
|
-
import { type TAriaHasPopupValue } from '../internal/role-types';
|
|
3
|
-
import { type TPopoverCloseReason } from '../popover/types';
|
|
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';
|
|
22
|
-
export type TPopupContextValue = {
|
|
23
|
-
/**
|
|
24
|
-
* Auto-generated ID for the popover content element (used for aria-controls).
|
|
25
|
-
*/
|
|
26
|
-
popoverId: string;
|
|
27
|
-
/**
|
|
28
|
-
* Requested placement.
|
|
29
|
-
*/
|
|
30
|
-
placement: TPlacementOptions;
|
|
31
|
-
/**
|
|
32
|
-
* Called when the popover is dismissed via light dismiss.
|
|
33
|
-
* `null` when mode is 'manual' (no light dismiss).
|
|
34
|
-
*/
|
|
35
|
-
onClose: ((args: {
|
|
36
|
-
reason: TPopoverCloseReason;
|
|
37
|
-
}) => void) | null;
|
|
38
|
-
/**
|
|
39
|
-
* Mutable ref to the trigger element (set by Popup.Trigger / Popup.TriggerFunction).
|
|
40
|
-
*/
|
|
41
|
-
triggerRef: MutableRefObject<HTMLElement | null>;
|
|
42
|
-
/**
|
|
43
|
-
* Ref to the popover content element (set by Popup.Content).
|
|
44
|
-
*/
|
|
45
|
-
popoverRef: RefObject<HTMLDivElement | null>;
|
|
46
|
-
/**
|
|
47
|
-
* The full lifecycle state of the popup.
|
|
48
|
-
*
|
|
49
|
-
* See `TPopupState` for the full state machine description.
|
|
50
|
-
*/
|
|
51
|
-
popupState: TPopupState;
|
|
52
|
-
/**
|
|
53
|
-
* Updates the popup lifecycle state. Called by `PopupContent` as animations
|
|
54
|
-
* begin and complete.
|
|
55
|
-
*/
|
|
56
|
-
setPopupState: (state: TPopupState) => void;
|
|
57
|
-
/**
|
|
58
|
-
* Consumer's onOpenChange callback, forwarded to the Popover.
|
|
59
|
-
*/
|
|
60
|
-
onOpenChange?: (args: {
|
|
61
|
-
isOpen: boolean;
|
|
62
|
-
element: HTMLDivElement;
|
|
63
|
-
}) => void;
|
|
64
|
-
/**
|
|
65
|
-
* Native popover mode. Flows from the Popup root to Content via context.
|
|
66
|
-
*/
|
|
67
|
-
mode: 'auto' | 'hint' | 'manual';
|
|
68
|
-
/**
|
|
69
|
-
* The `aria-haspopup` value derived from the content's role.
|
|
70
|
-
*
|
|
71
|
-
* Set by `Popup.Content` via `setAriaHasPopup` when it renders.
|
|
72
|
-
* Read by `Popup.Trigger` / `Popup.TriggerFunction` to set
|
|
73
|
-
* the correct `aria-haspopup` on the trigger element.
|
|
74
|
-
*
|
|
75
|
-
* This flows the content's role to the trigger without requiring
|
|
76
|
-
* the consumer to specify the role in two places. The trigger
|
|
77
|
-
* renders with the default ('dialog') on first paint; Content's
|
|
78
|
-
* layout effect updates it before the browser paints.
|
|
79
|
-
*/
|
|
80
|
-
ariaHasPopup: TAriaHasPopupValue;
|
|
81
|
-
/**
|
|
82
|
-
* Updates `ariaHasPopup` - called by Content on mount/role change.
|
|
83
|
-
*/
|
|
84
|
-
setAriaHasPopup: (value: TAriaHasPopupValue) => void;
|
|
85
|
-
/**
|
|
86
|
-
* Test ID prefix.
|
|
87
|
-
*/
|
|
88
|
-
testId?: string;
|
|
89
|
-
/**
|
|
90
|
-
* Forces the JavaScript positioning fallback even when the browser
|
|
91
|
-
* supports CSS Anchor Positioning. Useful for testing fallback
|
|
92
|
-
* behavior in any environment, including production.
|
|
93
|
-
*/
|
|
94
|
-
forceFallbackPositioning?: boolean;
|
|
95
|
-
};
|
|
96
|
-
export declare const PopupContext: React.Context<TPopupContextValue | null>;
|
|
@@ -1,10 +0,0 @@
|
|
|
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>;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jsxRuntime classic
|
|
3
|
-
* @jsx jsx
|
|
4
|
-
*/
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { type TPopupSurfaceProps } from './types';
|
|
7
|
-
/**
|
|
8
|
-
* Optional styled wrapper for popup content.
|
|
9
|
-
*
|
|
10
|
-
* Adds default visual styling (background, border-radius, box-shadow)
|
|
11
|
-
* using design tokens. Consumers who want fully custom styling
|
|
12
|
-
* should use `Popup.Content` without wrapping in `PopupSurface`.
|
|
13
|
-
*
|
|
14
|
-
* Exposed as `Popup.Surface` on the compound component.
|
|
15
|
-
*
|
|
16
|
-
* **Presentational primitive - `children`-only by design.** This component
|
|
17
|
-
* intentionally exposes no `style`, `className`, `xcss`, `id`, or `ref`
|
|
18
|
-
* props. If you need any of those, render your own wrapper element inside
|
|
19
|
-
* `Popup.Content` instead - `PopupSurface` is the no-config "give me the
|
|
20
|
-
* default ADS overlay look" surface, nothing more.
|
|
21
|
-
*/
|
|
22
|
-
export declare function PopupSurface({ children }: TPopupSurfaceProps): React.ReactElement;
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import React, { type ReactNode, type RefCallback } from 'react';
|
|
2
|
-
import { type TAriaHasPopupValue } from '../internal/role-types';
|
|
3
|
-
/**
|
|
4
|
-
* Props passed to the `TriggerFunction` render-prop child.
|
|
5
|
-
*/
|
|
6
|
-
export type TTriggerFunctionRenderProps = {
|
|
7
|
-
/**
|
|
8
|
-
* Ref callback to attach to the trigger element. Sets `triggerRef` in
|
|
9
|
-
* popup context for anchor positioning and `togglePopover`.
|
|
10
|
-
*/
|
|
11
|
-
ref: RefCallback<HTMLElement>;
|
|
12
|
-
/**
|
|
13
|
-
* Whether the popover content is currently visible.
|
|
14
|
-
* Use for `aria-expanded` and conditional styling.
|
|
15
|
-
*/
|
|
16
|
-
isOpen: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* ID of the popover content element. Use for `aria-controls`.
|
|
19
|
-
*/
|
|
20
|
-
popoverId: string;
|
|
21
|
-
/**
|
|
22
|
-
* Toggle the popover open/closed via the native Popover API.
|
|
23
|
-
*
|
|
24
|
-
* Calling `toggle()` invokes `popoverEl.togglePopover()` on the
|
|
25
|
-
* underlying content element. This hides the imperative DOM API
|
|
26
|
-
* behind a stable function reference.
|
|
27
|
-
*/
|
|
28
|
-
toggle: () => void;
|
|
29
|
-
/**
|
|
30
|
-
* Pre-composed ARIA attributes for the trigger element.
|
|
31
|
-
*
|
|
32
|
-
* Spread these onto your trigger: `{...ariaAttributes}`.
|
|
33
|
-
*
|
|
34
|
-
* Contains:
|
|
35
|
-
* - `aria-expanded`: whether the popover is open
|
|
36
|
-
* - `aria-controls`: ID of the popover content
|
|
37
|
-
* - `aria-haspopup`: derived from the content's ARIA role via context
|
|
38
|
-
*
|
|
39
|
-
* **Note on `aria-haspopup`:** When the content's role maps to a specific
|
|
40
|
-
* popup type (`'menu'`, `'dialog'`, `'listbox'`, etc.), the corresponding
|
|
41
|
-
* string value is emitted. For non-popup roles (`tooltip`, `note`,
|
|
42
|
-
* `status`, `alert`, `log`) the value is `undefined`, so React drops the
|
|
43
|
-
* attribute entirely - these triggers should not announce a popup.
|
|
44
|
-
*
|
|
45
|
-
* The value type (`TAriaHasPopupValue`) is internal and may narrow further
|
|
46
|
-
* in future minor versions. Do **not** extract it via `Parameters<…>`.
|
|
47
|
-
* Spread `ariaAttributes` directly onto the trigger; do not destructure
|
|
48
|
-
* and re-type.
|
|
49
|
-
*/
|
|
50
|
-
ariaAttributes: {
|
|
51
|
-
'aria-expanded': boolean;
|
|
52
|
-
'aria-controls': string;
|
|
53
|
-
'aria-haspopup': TAriaHasPopupValue;
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
type TPopupTriggerFunctionProps = {
|
|
57
|
-
/**
|
|
58
|
-
* Render-prop function that receives trigger props.
|
|
59
|
-
*
|
|
60
|
-
* Unlike `Popup.Trigger`, this does not use `cloneElement`. The consumer
|
|
61
|
-
* is responsible for spreading ref, ARIA attributes, and attaching `toggle`
|
|
62
|
-
* to the appropriate event(s).
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* ```tsx
|
|
66
|
-
* <Popup.TriggerFunction>
|
|
67
|
-
* {({ ref, toggle, ariaAttributes }) => (
|
|
68
|
-
* <button ref={ref} onClick={toggle} {...ariaAttributes}>
|
|
69
|
-
* Open menu
|
|
70
|
-
* </button>
|
|
71
|
-
* )}
|
|
72
|
-
* </Popup.TriggerFunction>
|
|
73
|
-
* ```
|
|
74
|
-
*
|
|
75
|
-
* **Note:** This sub-component uses a render-prop pattern and is not
|
|
76
|
-
* compatible with React Server Components (RSC). It must be used
|
|
77
|
-
* inside a client component boundary (`'use client'`).
|
|
78
|
-
*/
|
|
79
|
-
children: (props: TTriggerFunctionRenderProps) => ReactNode;
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* Render-prop alternative to `Popup.Trigger`.
|
|
83
|
-
*
|
|
84
|
-
* Use when you need full control over the trigger element. For example,
|
|
85
|
-
* to compose your own trigger with custom event handlers, wrap a third-party
|
|
86
|
-
* component, or build a trigger from multiple elements.
|
|
87
|
-
*
|
|
88
|
-
* `Popup.Trigger` uses `cloneElement` internally, which limits composability.
|
|
89
|
-
* `Popup.TriggerFunction` hands you the raw props and lets you wire them up.
|
|
90
|
-
*
|
|
91
|
-
* **Note:** This sub-component uses a render-prop pattern and is not
|
|
92
|
-
* compatible with React Server Components (RSC). It must be used inside
|
|
93
|
-
* a client component boundary (`'use client'`).
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* ```tsx
|
|
97
|
-
* <Popup placement={{ edge: 'end' }} onClose={handleClose}>
|
|
98
|
-
* <Popup.TriggerFunction>
|
|
99
|
-
* {({ ref, toggle, ariaAttributes }) => (
|
|
100
|
-
* <button ref={ref} onClick={toggle} {...ariaAttributes}>
|
|
101
|
-
* Open
|
|
102
|
-
* </button>
|
|
103
|
-
* )}
|
|
104
|
-
* </Popup.TriggerFunction>
|
|
105
|
-
* <Popup.Content role="dialog" label="My popup">
|
|
106
|
-
* Content
|
|
107
|
-
* </Popup.Content>
|
|
108
|
-
* </Popup>
|
|
109
|
-
* ```
|
|
110
|
-
*/
|
|
111
|
-
export declare function PopupTriggerFunction({ children }: TPopupTriggerFunctionProps): React.ReactNode;
|
|
112
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
2
|
-
import { type TPopupTriggerProps } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Wraps a single trigger element via `cloneElement`. Attaches aria
|
|
5
|
-
* attributes, the toggle handler, and the anchor-name. `aria-haspopup`
|
|
6
|
-
* is derived from `Popup.Content`'s role via context.
|
|
7
|
-
*
|
|
8
|
-
* Child constraints: must be a single ref-forwarding element. The child's
|
|
9
|
-
* `onClick` is composed (runs after); other event handlers are NOT.
|
|
10
|
-
* Children using Compiled's `css` prop swallow injected props - use
|
|
11
|
-
* `Popup.TriggerFunction` for these cases or any time you need handler
|
|
12
|
-
* composition.
|
|
13
|
-
*/
|
|
14
|
-
export declare function PopupTrigger({ children }: TPopupTriggerProps): ReactNode;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type TPopupProps } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Popup compound: trigger + popover content.
|
|
5
|
-
*
|
|
6
|
-
* Use when a button opens anchored content (dropdown, menu, dialog).
|
|
7
|
-
* The browser manages visibility via `togglePopover()`; the consumer
|
|
8
|
-
* never manages `isOpen`. For custom trigger lifecycles (hover, timers,
|
|
9
|
-
* external state), use `Popover` directly instead.
|
|
10
|
-
*
|
|
11
|
-
* Provides context (triggerRef, placement, isOpen, onClose, mode) that
|
|
12
|
-
* `Popup.Content` reads and forwards to the underlying `Popover`.
|
|
13
|
-
*/
|
|
14
|
-
export declare function PopupRoot(props: TPopupProps): React.ReactElement;
|