@primer/components 0.0.0-2021116153325 → 0.0.0-2021116153548

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.
Files changed (63) hide show
  1. package/dist/browser.esm.js +2 -2
  2. package/dist/browser.esm.js.map +1 -1
  3. package/dist/browser.umd.js +2 -2
  4. package/dist/browser.umd.js.map +1 -1
  5. package/lib/ActionList/Item.js +3 -3
  6. package/lib/ActionList/List.js +2 -2
  7. package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +1 -1
  8. package/lib/Autocomplete/AutocompleteMenu.js +5 -10
  9. package/lib/Dialog/ConfirmationDialog.js +2 -2
  10. package/lib/Dialog/Dialog.js +2 -2
  11. package/lib/FilteredActionList/FilteredActionList.js +3 -10
  12. package/lib/Overlay.d.ts +1 -1
  13. package/lib/TextInputWithTokens.js +4 -4
  14. package/lib/behaviors/anchoredPosition.d.ts +89 -0
  15. package/lib/behaviors/anchoredPosition.js +316 -0
  16. package/lib/behaviors/focusTrap.d.ts +12 -0
  17. package/lib/behaviors/focusTrap.js +179 -0
  18. package/lib/behaviors/focusZone.d.ts +137 -0
  19. package/lib/behaviors/focusZone.js +578 -0
  20. package/lib/behaviors/scrollIntoViewingArea.d.ts +1 -0
  21. package/lib/behaviors/scrollIntoViewingArea.js +39 -0
  22. package/lib/hooks/useAnchoredPosition.d.ts +1 -1
  23. package/lib/hooks/useAnchoredPosition.js +2 -2
  24. package/lib/hooks/useFocusTrap.js +2 -2
  25. package/lib/hooks/useFocusZone.d.ts +1 -1
  26. package/lib/hooks/useFocusZone.js +2 -2
  27. package/lib/hooks/useOpenAndCloseFocus.js +2 -2
  28. package/lib/utils/iterateFocusableElements.d.ts +42 -0
  29. package/lib/utils/iterateFocusableElements.js +113 -0
  30. package/lib/utils/uniqueId.d.ts +1 -0
  31. package/lib/utils/uniqueId.js +12 -0
  32. package/lib/utils/userAgent.d.ts +1 -0
  33. package/lib/utils/userAgent.js +15 -0
  34. package/lib-esm/ActionList/Item.js +1 -1
  35. package/lib-esm/ActionList/List.js +1 -1
  36. package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +1 -1
  37. package/lib-esm/Autocomplete/AutocompleteMenu.js +4 -9
  38. package/lib-esm/Dialog/ConfirmationDialog.js +1 -1
  39. package/lib-esm/Dialog/Dialog.js +1 -1
  40. package/lib-esm/FilteredActionList/FilteredActionList.js +3 -9
  41. package/lib-esm/Overlay.d.ts +1 -1
  42. package/lib-esm/TextInputWithTokens.js +2 -2
  43. package/lib-esm/behaviors/anchoredPosition.d.ts +89 -0
  44. package/lib-esm/behaviors/anchoredPosition.js +309 -0
  45. package/lib-esm/behaviors/focusTrap.d.ts +12 -0
  46. package/lib-esm/behaviors/focusTrap.js +170 -0
  47. package/lib-esm/behaviors/focusZone.d.ts +137 -0
  48. package/lib-esm/behaviors/focusZone.js +560 -0
  49. package/lib-esm/behaviors/scrollIntoViewingArea.d.ts +1 -0
  50. package/lib-esm/behaviors/scrollIntoViewingArea.js +30 -0
  51. package/lib-esm/hooks/useAnchoredPosition.d.ts +1 -1
  52. package/lib-esm/hooks/useAnchoredPosition.js +1 -1
  53. package/lib-esm/hooks/useFocusTrap.js +1 -1
  54. package/lib-esm/hooks/useFocusZone.d.ts +1 -1
  55. package/lib-esm/hooks/useFocusZone.js +1 -1
  56. package/lib-esm/hooks/useOpenAndCloseFocus.js +1 -1
  57. package/lib-esm/utils/iterateFocusableElements.d.ts +42 -0
  58. package/lib-esm/utils/iterateFocusableElements.js +102 -0
  59. package/lib-esm/utils/uniqueId.d.ts +1 -0
  60. package/lib-esm/utils/uniqueId.js +5 -0
  61. package/lib-esm/utils/userAgent.d.ts +1 -0
  62. package/lib-esm/utils/userAgent.js +8 -0
  63. package/package.json +5 -2
@@ -7,7 +7,7 @@ exports.useFocusZone = useFocusZone;
7
7
 
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
 
10
- var _behaviors = require("@primer/behaviors");
10
+ var _focusZone = require("../behaviors/focusZone");
11
11
 
12
12
  var _useProvidedRefOrCreate = require("./useProvidedRefOrCreate");
13
13
 
@@ -32,7 +32,7 @@ function useFocusZone(settings = {}, dependencies = []) {
32
32
  const vanillaSettings = { ...settings,
33
33
  activeDescendantControl: (_activeDescendantCont = activeDescendantControlRef.current) !== null && _activeDescendantCont !== void 0 ? _activeDescendantCont : undefined
34
34
  };
35
- abortController.current = (0, _behaviors.focusZone)(containerRef.current, vanillaSettings);
35
+ abortController.current = (0, _focusZone.focusZone)(containerRef.current, vanillaSettings);
36
36
  return () => {
37
37
  var _abortController$curr;
38
38
 
@@ -7,7 +7,7 @@ exports.useOpenAndCloseFocus = useOpenAndCloseFocus;
7
7
 
8
8
  var _react = require("react");
9
9
 
10
- var _utils = require("@primer/behaviors/utils");
10
+ var _iterateFocusableElements = require("../utils/iterateFocusableElements");
11
11
 
12
12
  function useOpenAndCloseFocus({
13
13
  initialFocusRef,
@@ -25,7 +25,7 @@ function useOpenAndCloseFocus({
25
25
  if (initialFocusRef && initialFocusRef.current) {
26
26
  initialFocusRef.current.focus();
27
27
  } else if (containerRef.current) {
28
- const firstItem = (0, _utils.iterateFocusableElements)(containerRef.current).next().value;
28
+ const firstItem = (0, _iterateFocusableElements.iterateFocusableElements)(containerRef.current).next().value;
29
29
  firstItem === null || firstItem === void 0 ? void 0 : firstItem.focus();
30
30
  }
31
31
 
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Options to the focusable elements iterator
3
+ */
4
+ export interface IterateFocusableElements {
5
+ /**
6
+ * (Default: false) Iterate through focusable elements in reverse-order
7
+ */
8
+ reverse?: boolean;
9
+ /**
10
+ * (Default: false) Perform additional checks to determine tabbability
11
+ * which may adversely affect app performance.
12
+ */
13
+ strict?: boolean;
14
+ /**
15
+ * (Default: false) Only iterate tabbable elements, which is the subset
16
+ * of focusable elements that are part of the page's tab sequence.
17
+ */
18
+ onlyTabbable?: boolean;
19
+ }
20
+ /**
21
+ * Returns an iterator over all of the focusable elements within `container`.
22
+ * Note: If `container` is itself focusable it will be included in the results.
23
+ * @param container The container over which to find focusable elements.
24
+ * @param reverse If true, iterate backwards through focusable elements.
25
+ */
26
+ export declare function iterateFocusableElements(container: HTMLElement, options?: IterateFocusableElements): Generator<HTMLElement, undefined, undefined>;
27
+ /**
28
+ * Determines whether the given element is focusable. If `strict` is true, we may
29
+ * perform additional checks that require a reflow (less performant).
30
+ * @param elem
31
+ * @param strict
32
+ */
33
+ export declare function isFocusable(elem: HTMLElement, strict?: boolean): boolean;
34
+ /**
35
+ * Determines whether the given element is tabbable. If `strict` is true, we may
36
+ * perform additional checks that require a reflow (less performant). This check
37
+ * ensures that the element is focusable and that its tabindex is not explicitly
38
+ * set to "-1" (which makes it focusable, but removes it from the tab order).
39
+ * @param elem
40
+ * @param strict
41
+ */
42
+ export declare function isTabbable(elem: HTMLElement, strict?: boolean): boolean;
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.iterateFocusableElements = iterateFocusableElements;
7
+ exports.isFocusable = isFocusable;
8
+ exports.isTabbable = isTabbable;
9
+
10
+ /**
11
+ * Options to the focusable elements iterator
12
+ */
13
+
14
+ /**
15
+ * Returns an iterator over all of the focusable elements within `container`.
16
+ * Note: If `container` is itself focusable it will be included in the results.
17
+ * @param container The container over which to find focusable elements.
18
+ * @param reverse If true, iterate backwards through focusable elements.
19
+ */
20
+ function* iterateFocusableElements(container, options = {}) {
21
+ var _options$strict, _options$onlyTabbable;
22
+
23
+ const strict = (_options$strict = options.strict) !== null && _options$strict !== void 0 ? _options$strict : false;
24
+ const acceptFn = ((_options$onlyTabbable = options.onlyTabbable) !== null && _options$onlyTabbable !== void 0 ? _options$onlyTabbable : false) ? isTabbable : isFocusable;
25
+ const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
26
+ acceptNode: node => node instanceof HTMLElement && acceptFn(node, strict) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
27
+ });
28
+ let nextNode = null; // Allow the container to participate
29
+
30
+ if (!options.reverse && acceptFn(container, strict)) {
31
+ yield container;
32
+ } // If iterating in reverse, continue traversing down into the last child until we reach
33
+ // a leaf DOM node
34
+
35
+
36
+ if (options.reverse) {
37
+ let lastChild = walker.lastChild();
38
+
39
+ while (lastChild) {
40
+ nextNode = lastChild;
41
+ lastChild = walker.lastChild();
42
+ }
43
+ } else {
44
+ nextNode = walker.firstChild();
45
+ }
46
+
47
+ while (nextNode instanceof HTMLElement) {
48
+ yield nextNode;
49
+ nextNode = options.reverse ? walker.previousNode() : walker.nextNode();
50
+ } // Allow the container to participate (in reverse)
51
+
52
+
53
+ if (options.reverse && acceptFn(container, strict)) {
54
+ yield container;
55
+ }
56
+
57
+ return undefined;
58
+ }
59
+ /**
60
+ * Determines whether the given element is focusable. If `strict` is true, we may
61
+ * perform additional checks that require a reflow (less performant).
62
+ * @param elem
63
+ * @param strict
64
+ */
65
+
66
+
67
+ function isFocusable(elem, strict = false) {
68
+ // Certain conditions cause an element to never be focusable, even if they have tabindex="0"
69
+ const disabledAttrInert = ['BUTTON', 'INPUT', 'SELECT', 'TEXTAREA', 'OPTGROUP', 'OPTION', 'FIELDSET'].includes(elem.tagName) && elem.disabled;
70
+ const hiddenInert = elem.hidden;
71
+ const hiddenInputInert = elem instanceof HTMLInputElement && elem.type === 'hidden';
72
+
73
+ if (disabledAttrInert || hiddenInert || hiddenInputInert) {
74
+ return false;
75
+ } // Each of the conditions checked below require a reflow, thus are gated by the `strict`
76
+ // argument. If any are true, the element is not focusable, even if tabindex is set.
77
+
78
+
79
+ if (strict) {
80
+ const sizeInert = elem.offsetWidth === 0 || elem.offsetHeight === 0;
81
+ const visibilityInert = ['hidden', 'collapse'].includes(getComputedStyle(elem).visibility);
82
+ const clientRectsInert = elem.getClientRects().length === 0;
83
+
84
+ if (sizeInert || visibilityInert || clientRectsInert) {
85
+ return false;
86
+ }
87
+ } // Any element with `tabindex` explicitly set can be focusable, even if it's set to "-1"
88
+
89
+
90
+ if (elem.getAttribute('tabindex') != null) {
91
+ return true;
92
+ } // One last way `elem.tabIndex` can be wrong.
93
+
94
+
95
+ if (elem instanceof HTMLAnchorElement && elem.getAttribute('href') == null) {
96
+ return false;
97
+ }
98
+
99
+ return elem.tabIndex !== -1;
100
+ }
101
+ /**
102
+ * Determines whether the given element is tabbable. If `strict` is true, we may
103
+ * perform additional checks that require a reflow (less performant). This check
104
+ * ensures that the element is focusable and that its tabindex is not explicitly
105
+ * set to "-1" (which makes it focusable, but removes it from the tab order).
106
+ * @param elem
107
+ * @param strict
108
+ */
109
+
110
+
111
+ function isTabbable(elem, strict = false) {
112
+ return isFocusable(elem, strict) && elem.getAttribute('tabindex') !== '-1';
113
+ }
@@ -0,0 +1 @@
1
+ export declare function uniqueId(): string;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.uniqueId = uniqueId;
7
+ // Note: uniqueId may be unsafe in SSR contexts if it is used create DOM IDs or otherwise cause a hydration warning. Use useSSRSafeId instead.
8
+ let idSeed = 10000;
9
+
10
+ function uniqueId() {
11
+ return `__primer_id_${idSeed++}`;
12
+ }
@@ -0,0 +1 @@
1
+ export declare function isMacOS(): boolean;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isMacOS = isMacOS;
7
+ let isMac = undefined;
8
+
9
+ function isMacOS() {
10
+ if (isMac === undefined) {
11
+ isMac = /^mac/i.test(window.navigator.platform);
12
+ }
13
+
14
+ return isMac;
15
+ }
@@ -9,7 +9,7 @@ import styled from 'styled-components';
9
9
  import { StyledHeader } from './Header';
10
10
  import { StyledDivider } from './Divider';
11
11
  import { useTheme } from '../ThemeProvider';
12
- import { activeDescendantActivatedDirectly, activeDescendantActivatedIndirectly, isActiveDescendantAttribute } from '@primer/behaviors';
12
+ import { activeDescendantActivatedDirectly, activeDescendantActivatedIndirectly, isActiveDescendantAttribute } from '../behaviors/focusZone';
13
13
  import { useSSRSafeId } from '@react-aria/ssr';
14
14
 
15
15
  const getItemVariant = (variant = 'default', disabled) => {
@@ -6,7 +6,7 @@ import { Item } from './Item';
6
6
  import { Divider } from './Divider';
7
7
  import styled from 'styled-components';
8
8
  import { get } from '../constants';
9
- import { hasActiveDescendantAttribute } from '@primer/behaviors';
9
+ import { hasActiveDescendantAttribute } from '../behaviors/focusZone';
10
10
 
11
11
  /**
12
12
  * Asserts that the given value fulfills the `GroupedListProps` contract.
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { OverlayProps } from '../Overlay';
3
3
  import { FocusTrapHookSettings } from '../hooks/useFocusTrap';
4
4
  import { FocusZoneHookSettings } from '../hooks/useFocusZone';
5
- import type { PositionSettings } from '@primer/behaviors';
5
+ import { PositionSettings } from '../behaviors/anchoredPosition';
6
6
  interface AnchoredOverlayPropsWithAnchor {
7
7
  /**
8
8
  * A custom function component used to render the anchor element.
@@ -4,16 +4,11 @@ import { useFocusZone } from '../hooks/useFocusZone';
4
4
  import { Box, Spinner } from '../';
5
5
  import { AutocompleteContext } from './AutocompleteContext';
6
6
  import { PlusIcon } from '@primer/octicons-react';
7
- import { uniqueId } from '@primer/behaviors/utils';
8
- import { scrollIntoView } from '@primer/behaviors';
7
+ import { uniqueId } from '../utils/uniqueId';
8
+ import { scrollIntoViewingArea } from '../behaviors/scrollIntoViewingArea';
9
9
 
10
10
  const getDefaultSortFn = isItemSelectedFn => (itemIdA, itemIdB) => isItemSelectedFn(itemIdA) === isItemSelectedFn(itemIdB) ? 0 : isItemSelectedFn(itemIdA) ? -1 : 1;
11
11
 
12
- const menuScrollMargins = {
13
- startMargin: 0,
14
- endMargin: 8
15
- };
16
-
17
12
  function getDefaultItemFilter(filterValue) {
18
13
  return function (item, _i) {
19
14
  var _item$text;
@@ -139,9 +134,9 @@ function AutocompleteMenu(props) {
139
134
  }
140
135
 
141
136
  if (current && customScrollContainerRef && customScrollContainerRef.current && directlyActivated) {
142
- scrollIntoView(current, customScrollContainerRef.current, menuScrollMargins);
137
+ scrollIntoViewingArea(current, customScrollContainerRef.current);
143
138
  } else if (current && scrollContainerRef.current && directlyActivated) {
144
- scrollIntoView(current, scrollContainerRef.current, menuScrollMargins);
139
+ scrollIntoViewingArea(current, scrollContainerRef.current);
145
140
  }
146
141
  }
147
142
  }, [loading]);
@@ -5,7 +5,7 @@ import ReactDOM from 'react-dom';
5
5
  import styled from 'styled-components';
6
6
  import Box from '../Box';
7
7
  import { ThemeProvider, useTheme } from '../ThemeProvider';
8
- import { FocusKeys } from '@primer/behaviors';
8
+ import { FocusKeys } from '../behaviors/focusZone';
9
9
  import { get } from '../constants';
10
10
  import { Dialog } from '../Dialog/Dialog';
11
11
  import { useFocusZone } from '../hooks/useFocusZone';
@@ -11,7 +11,7 @@ import sx from '../sx';
11
11
  import StyledOcticon from '../StyledOcticon';
12
12
  import { XIcon } from '@primer/octicons-react';
13
13
  import { useFocusZone } from '../hooks/useFocusZone';
14
- import { FocusKeys } from '@primer/behaviors';
14
+ import { FocusKeys } from '../behaviors/focusZone';
15
15
  import Portal from '../Portal';
16
16
  import { useCombinedRefs } from '../hooks/useCombinedRefs';
17
17
  import { useSSRSafeId } from '@react-aria/ssr';
@@ -12,11 +12,7 @@ import styled from 'styled-components';
12
12
  import { get } from '../constants';
13
13
  import { useProvidedRefOrCreate } from '../hooks/useProvidedRefOrCreate';
14
14
  import useScrollFlash from '../hooks/useScrollFlash';
15
- import { scrollIntoView } from '@primer/behaviors';
16
- const menuScrollMargins = {
17
- startMargin: 0,
18
- endMargin: 8
19
- };
15
+ import { scrollIntoViewingArea } from '../behaviors/scrollIntoViewingArea';
20
16
  const StyledHeader = styled.div.withConfig({
21
17
  displayName: "FilteredActionList__StyledHeader",
22
18
  componentId: "sc-yg3jkv-0"
@@ -63,7 +59,7 @@ export function FilteredActionList({
63
59
  activeDescendantRef.current = current;
64
60
 
65
61
  if (current && scrollContainerRef.current && directlyActivated) {
66
- scrollIntoView(current, scrollContainerRef.current, menuScrollMargins);
62
+ scrollIntoViewingArea(current, scrollContainerRef.current);
67
63
  }
68
64
  }
69
65
  }, [// List ref isn't set while loading. Need to re-bind focus zone when it changes
@@ -71,9 +67,7 @@ export function FilteredActionList({
71
67
  useEffect(() => {
72
68
  // if items changed, we want to instantly move active descendant into view
73
69
  if (activeDescendantRef.current && scrollContainerRef.current) {
74
- scrollIntoView(activeDescendantRef.current, scrollContainerRef.current, { ...menuScrollMargins,
75
- behavior: 'auto'
76
- });
70
+ scrollIntoViewingArea(activeDescendantRef.current, scrollContainerRef.current, 'vertical', undefined, undefined, 'auto');
77
71
  }
78
72
  }, [items]);
79
73
  useScrollFlash(scrollContainerRef);
@@ -2,7 +2,7 @@ import React, { ComponentPropsWithRef } from 'react';
2
2
  import { AriaRole, Merge } from './utils/types';
3
3
  import { TouchOrMouseEvent } from './hooks';
4
4
  import { SxProp } from './sx';
5
- import type { AnchorSide } from '@primer/behaviors';
5
+ import { AnchorSide } from './behaviors/anchoredPosition';
6
6
  import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
7
7
  declare type StyledOverlayProps = {
8
8
  width?: keyof typeof widthMap;
@@ -2,7 +2,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
2
2
 
3
3
  import React, { useRef, useState } from 'react';
4
4
  import { omit } from '@styled-system/props';
5
- import { FocusKeys } from '@primer/behaviors';
5
+ import { FocusKeys } from './behaviors/focusZone';
6
6
  import { useCombinedRefs } from './hooks/useCombinedRefs';
7
7
  import { useFocusZone } from './hooks/useFocusZone';
8
8
  import Token from './Token/Token';
@@ -11,7 +11,7 @@ import UnstyledTextInput from './_UnstyledTextInput';
11
11
  import TextInputWrapper from './_TextInputWrapper';
12
12
  import Box from './Box';
13
13
  import Text from './Text';
14
- import { isFocusable } from '@primer/behaviors/utils'; // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
+ import { isFocusable } from './utils/iterateFocusableElements'; // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
15
 
16
16
  const overflowCountFontSizeMap = {
17
17
  small: 0,
@@ -0,0 +1,89 @@
1
+ export declare type AnchorAlignment = 'start' | 'center' | 'end';
2
+ export declare type AnchorSide = 'inside-top' | 'inside-bottom' | 'inside-left' | 'inside-right' | 'inside-center' | 'outside-top' | 'outside-bottom' | 'outside-left' | 'outside-right';
3
+ /**
4
+ * Settings that customize how a floating element is positioned
5
+ * with respect to an anchor element.
6
+ */
7
+ export interface PositionSettings {
8
+ /**
9
+ * Sets the side of the anchor element that the floating element should be
10
+ * pinned to. This side is given by a string starting with either "inside" or
11
+ * "outside", followed by a hyphen, followed by either "top", "right", "bottom",
12
+ * or "left". Additionally, "inside-center" is an allowed value.
13
+ *
14
+ * The first part of this string, "inside" or "outside", determines whether the
15
+ * floating element should be attempted to be placed "inside" the anchor element
16
+ * or "outside" of it. Using "inside" is useful for making it appear that the
17
+ * anchor _contains_ the floating element, and it can be used for implementing a
18
+ * dialog that is centered on the screen. The "outside" value is more common and
19
+ * can be used for tooltips, popovers, menus, etc.
20
+ *
21
+ * The second part of this string determines the _edge_ on the anchor element that
22
+ * the floating element will be anchored to. If side is "inside-center", then
23
+ * the floating element will be centered in the X-direction (while align is used
24
+ * to position it in the Y-direction).
25
+ * Note: "outside-center" is _not_ a valid value for this property.
26
+ */
27
+ side: AnchorSide;
28
+ /**
29
+ * Determines how the floating element should align with the anchor element. If
30
+ * set to "start", the floating element's first edge (top or left) will align
31
+ * with the anchor element's first edge. If set to "center", the floating
32
+ * element will be centered along the axis of the anchor edge. If set to "end",
33
+ * the floating element's last edge will align with the anchor element's last edge.
34
+ */
35
+ align: AnchorAlignment;
36
+ /**
37
+ * The number of pixels between the anchor edge and the floating element.
38
+ *
39
+ * Positive values move the floating element farther from the anchor element
40
+ * (for outside positioning) or further inside the anchor element (for inside
41
+ * positioning). Negative values have the opposite effect.
42
+ */
43
+ anchorOffset: number;
44
+ /**
45
+ * An additional offset, in pixels, to move the floating element from
46
+ * the aligning edge.
47
+ *
48
+ * Positive values move the floating element in the direction of center-
49
+ * alignment. Negative values move the floating element away from center-
50
+ * alignment. When align is "center", positive offsets move the floating
51
+ * element right (top or bottom anchor side) or down (left or right
52
+ * anchor side).
53
+ */
54
+ alignmentOffset: number;
55
+ /**
56
+ * If false, when the above settings result in rendering the floating element
57
+ * wholly or partially outside of the bounds of the containing element, attempt
58
+ * to adjust the settings to prevent this. Only applies to "outside" positioning.
59
+ *
60
+ * First, attempt to flip to the opposite edge of the anchor if the floating
61
+ * element is getting clipped in that direction. If flipping results in a
62
+ * similar clipping, try moving to the adjacent sides.
63
+ *
64
+ * Once we find a side that does not clip the overlay in its own dimension,
65
+ * check the rest of the sides to see if we need to adjust the alignment offset
66
+ * to fit in other dimensions.
67
+ *
68
+ * If we try all four sides and get clipped each time, settle for overflowing
69
+ * and use the "bottom" side, since the ability to scroll is most likely in
70
+ * this direction.
71
+ */
72
+ allowOutOfBounds: boolean;
73
+ }
74
+ export interface AnchorPosition {
75
+ top: number;
76
+ left: number;
77
+ anchorSide: AnchorSide;
78
+ }
79
+ /**
80
+ * Given a floating element and an anchor element, return coordinates for the top-left
81
+ * of the floating element in order to absolutely position it such that it appears
82
+ * near the anchor element.
83
+ *
84
+ * @param floatingElement Element intended to be positioned near or within an anchor
85
+ * @param anchorElement The element to serve as the position anchor
86
+ * @param settings Settings to determine the rules for positioning the floating element
87
+ * @returns {top: number, left: number} coordinates for the floating element
88
+ */
89
+ export declare function getAnchoredPosition(floatingElement: Element, anchorElement: Element | DOMRect, settings?: Partial<PositionSettings>): AnchorPosition;