@vectara/vectara-ui 13.16.2 → 13.16.3

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.
@@ -10,5 +10,7 @@ export type Props = {
10
10
  onClickButton?: (e: React.MouseEvent<HTMLElement>) => void;
11
11
  padding?: boolean;
12
12
  anchorSide?: AnchorSide;
13
+ anchorOffsetX?: number;
14
+ anchorOffsetY?: number;
13
15
  };
14
- export declare const VuiPopover: ({ button: originalButton, children, className, header, isOpen, setIsOpen, padding, anchorSide, onClickButton, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
16
+ export declare const VuiPopover: ({ button: originalButton, children, className, header, isOpen, setIsOpen, padding, anchorSide, anchorOffsetX, anchorOffsetY, onClickButton, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
@@ -15,35 +15,35 @@ import classNames from "classnames";
15
15
  import { VuiPortal } from "../portal/Portal";
16
16
  import { FocusOn } from "react-focus-on";
17
17
  import { VuiItemsInput, VuiNumberInput, VuiTextInput } from "../form";
18
- const calculatePopoverPosition = (button, anchorSide) => {
18
+ const calculatePopoverPosition = (button, anchorOptions) => {
19
19
  if (!button)
20
20
  return undefined;
21
+ const { anchorSide, offsetX, offsetY } = anchorOptions;
21
22
  const { left, right, width, height, top, bottom } = button.getBoundingClientRect();
22
23
  if (anchorSide === "rightUp") {
23
24
  // Anchor popover to the right side of the button, extending upwards.
24
25
  const adjustedTop = top + height + document.documentElement.scrollTop;
25
- // TODO: Hardcoded offset is intended for use with VuiAppSideNav. Extract this into a configurable prop.
26
- const adjustedLeft = left + width + 26;
26
+ const adjustedLeft = left + width + offsetX;
27
27
  return { top: `${adjustedTop}px`, left: `${adjustedLeft}px` };
28
28
  }
29
29
  if (anchorSide === "leftUp") {
30
30
  // Anchor popover to the left side of the button, extending upwards.
31
31
  const adjustedTop = top + height + document.documentElement.scrollTop;
32
- const adjustedRight = document.documentElement.clientWidth - left + 26;
32
+ const adjustedRight = document.documentElement.clientWidth - left + offsetX;
33
33
  return { top: `${adjustedTop}px`, right: `${adjustedRight}px` };
34
34
  }
35
35
  if (anchorSide === "upLeft") {
36
36
  // Anchor popover above the button, aligned to the left edge.
37
- const adjustedBottom = document.documentElement.clientHeight - top + 2;
37
+ const adjustedBottom = document.documentElement.clientHeight - top + offsetY;
38
38
  return { bottom: `${adjustedBottom}px`, left: `${left}px` };
39
39
  }
40
40
  if (anchorSide === "upRight") {
41
41
  // Anchor popover above the button, aligned to the right edge.
42
- const adjustedBottom = document.documentElement.clientHeight - top + 2;
42
+ const adjustedBottom = document.documentElement.clientHeight - top + offsetY;
43
43
  const adjustedRight = document.documentElement.clientWidth - right;
44
44
  return { bottom: `${adjustedBottom}px`, right: `${adjustedRight}px` };
45
45
  }
46
- const adjustedTop = bottom + 2 + document.documentElement.scrollTop;
46
+ const adjustedTop = bottom + offsetY + document.documentElement.scrollTop;
47
47
  if (anchorSide === "left") {
48
48
  return { top: `${adjustedTop}px`, left: `${left}px` };
49
49
  }
@@ -52,7 +52,7 @@ const calculatePopoverPosition = (button, anchorSide) => {
52
52
  return { top: `${adjustedTop}px`, right: `${adjustedRight}px` };
53
53
  };
54
54
  export const VuiPopover = (_a) => {
55
- var { button: originalButton, children, className, header, isOpen, setIsOpen, padding, anchorSide = "right", onClickButton } = _a, rest = __rest(_a, ["button", "children", "className", "header", "isOpen", "setIsOpen", "padding", "anchorSide", "onClickButton"]);
55
+ var { button: originalButton, children, className, header, isOpen, setIsOpen, padding, anchorSide = "right", anchorOffsetX = 2, anchorOffsetY = 2, onClickButton } = _a, rest = __rest(_a, ["button", "children", "className", "header", "isOpen", "setIsOpen", "padding", "anchorSide", "anchorOffsetX", "anchorOffsetY", "onClickButton"]);
56
56
  const returnFocusElRef = useRef(null);
57
57
  const buttonRef = useRef(null);
58
58
  const [, setPositionMarker] = useState(0);
@@ -129,7 +129,11 @@ export const VuiPopover = (_a) => {
129
129
  // Always keep menu position up to date. If we tried to cache this inside
130
130
  // a useEffect based on isOpen then there'd be a flicker if the width
131
131
  // of the button changes.
132
- const position = calculatePopoverPosition(buttonRef.current, anchorSide);
132
+ const position = calculatePopoverPosition(buttonRef.current, {
133
+ anchorSide,
134
+ offsetX: anchorOffsetX,
135
+ offsetY: anchorOffsetY
136
+ });
133
137
  const classes = classNames("vuiPopover", className, {
134
138
  "vuiPopover-isLoaded": showTransition,
135
139
  "vuiPopover--rightUp": anchorSide === "rightUp",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vectara/vectara-ui",
3
- "version": "13.16.2",
3
+ "version": "13.16.3",
4
4
  "homepage": "./",
5
5
  "description": "Vectara's design system, codified as a React and Sass component library",
6
6
  "author": "Vectara",