@vectara/vectara-ui 1.0.1 → 1.0.2
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.
|
@@ -43,7 +43,7 @@ import { VuiOptionsButton } from "./optionsButton/OptionsButton";
|
|
|
43
43
|
import { VuiOptionsList } from "./optionsList/OptionsList";
|
|
44
44
|
import { VuiOptionsListItem } from "./optionsList/OptionsListItem";
|
|
45
45
|
import { OptionListItem } from "./optionsList/types";
|
|
46
|
-
import { VuiPopover } from "./popover/Popover";
|
|
46
|
+
import { VuiPopover, AnchorSide } from "./popover/Popover";
|
|
47
47
|
import { VuiPortal } from "./portal/Portal";
|
|
48
48
|
import { PROGRESS_BAR_COLOR, VuiProgressBar } from "./progressBar/ProgressBar";
|
|
49
49
|
import { VuiPrompt } from "./prompt/Prompt";
|
|
@@ -71,5 +71,5 @@ import { TEXT_COLOR, TEXT_SIZE, TITLE_SIZE } from "./typography/types";
|
|
|
71
71
|
import { VuiTitle } from "./typography/Title";
|
|
72
72
|
import { VuiToggle } from "./toggle/Toggle";
|
|
73
73
|
import { VuiTopicButton } from "./topicButton/TopicButton";
|
|
74
|
-
export type { AppContentPadding, ButtonColor, CalloutColor, ChatLanguage, ChatStyle, ChatTurn, CodeLanguage, InfoTableColumnAlign, InfoTableRow, InfoTableRowType, LinkProps, MenuItem, Notification, OptionListItem, RadioButtonConfig, SearchResult, Sections, SectionItem, TabSize, Tree, TreeItem };
|
|
74
|
+
export type { AnchorSide, AppContentPadding, ButtonColor, CalloutColor, ChatLanguage, ChatStyle, ChatTurn, CodeLanguage, InfoTableColumnAlign, InfoTableRow, InfoTableRowType, LinkProps, MenuItem, Notification, OptionListItem, RadioButtonConfig, SearchResult, Sections, SectionItem, TabSize, Tree, TreeItem };
|
|
75
75
|
export { BADGE_COLOR, BUTTON_COLOR, BUTTON_SIZE, CALLOUT_COLOR, CALLOUT_SIZE, ICON_COLOR, ICON_SIZE, PROGRESS_BAR_COLOR, SPACER_SIZE, SPINNER_COLOR, SPINNER_SIZE, TAB_SIZE, TEXT_COLOR, TEXT_SIZE, TITLE_SIZE, VuiAccordion, VuiAccountMenu, VuiAppContent, VuiAppHeader, VuiAppLayout, VuiAppSideNav, VuiBadge, VuiButtonPrimary, VuiButtonSecondary, VuiButtonTertiary, VuiIconButton, VuiCallout, VuiCard, VuiChat, VuiCheckbox, VuiCode, VuiContextProvider, VuiCopyButton, VuiDrawer, VuiFlexContainer, VuiFlexItem, VuiFormGroup, VuiGrid, VuiHorizontalRule, VuiIcon, VuiInfoTable, VuiLabel, VuiLink, VuiLinkInternal, VuiList, VuiMenu, VuiMenuItem, VuiModal, VuiNotifications, VuiNumberInput, VuiOptionsButton, VuiOptionsList, VuiOptionsListItem, VuiPasswordInput, VuiPopover, VuiPortal, VuiProgressBar, VuiPrompt, VuiRadioButton, VuiScreenBlock, VuiSearchInput, VuiSearchResult, VuiSearchSelect, VuiSelect, VuiSetting, VuiSpacer, VuiSpinner, VuiStatList, VuiStatus, VuiSummary, VuiSummaryCitation, VuiSuperRadioGroup, VuiTable, VuiTab, VuiTabbedRoutes, VuiTabs, VuiText, VuiTextArea, VuiTextColor, VuiTextInput, VuiTitle, VuiToggle, VuiTopicButton };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
export type AnchorSide = "left" | "right";
|
|
2
3
|
export type Props = {
|
|
3
4
|
button: React.ReactElement;
|
|
4
5
|
children?: React.ReactNode;
|
|
@@ -7,5 +8,6 @@ export type Props = {
|
|
|
7
8
|
isOpen: boolean;
|
|
8
9
|
setIsOpen: (isOpen: boolean) => void;
|
|
9
10
|
padding?: boolean;
|
|
11
|
+
anchorSide?: AnchorSide;
|
|
10
12
|
};
|
|
11
|
-
export declare const VuiPopover: ({ button: originalButton, children, className, header, isOpen, setIsOpen, padding, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare const VuiPopover: ({ button: originalButton, children, className, header, isOpen, setIsOpen, padding, anchorSide, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -14,17 +14,20 @@ import { cloneElement, useEffect, useRef, useState } from "react";
|
|
|
14
14
|
import classNames from "classnames";
|
|
15
15
|
import { VuiPortal } from "../portal/Portal";
|
|
16
16
|
import { FocusOn } from "react-focus-on";
|
|
17
|
-
const
|
|
17
|
+
const calculatePopoverPosition = (button, anchorSide) => {
|
|
18
18
|
if (!button)
|
|
19
19
|
return undefined;
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const buttonRect = button.getBoundingClientRect();
|
|
21
|
+
const top = buttonRect.bottom + 2 + document.documentElement.scrollTop;
|
|
22
|
+
const left = buttonRect.left;
|
|
23
|
+
if (anchorSide === "left") {
|
|
24
|
+
return { top: `${top}px`, left: `${left}px` };
|
|
25
|
+
}
|
|
26
|
+
const right = window.innerWidth - buttonRect.right;
|
|
27
|
+
return { top: `${top}px`, right: `${right}px` };
|
|
25
28
|
};
|
|
26
29
|
export const VuiPopover = (_a) => {
|
|
27
|
-
var { button: originalButton, children, className, header, isOpen, setIsOpen, padding } = _a, rest = __rest(_a, ["button", "children", "className", "header", "isOpen", "setIsOpen", "padding"]);
|
|
30
|
+
var { button: originalButton, children, className, header, isOpen, setIsOpen, padding, anchorSide = "right" } = _a, rest = __rest(_a, ["button", "children", "className", "header", "isOpen", "setIsOpen", "padding", "anchorSide"]);
|
|
28
31
|
const returnFocusElRef = useRef(null);
|
|
29
32
|
const buttonRef = useRef(null);
|
|
30
33
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -73,7 +76,7 @@ export const VuiPopover = (_a) => {
|
|
|
73
76
|
// Always keep menu position up to date. If we tried to cache this inside
|
|
74
77
|
// a useEffect based on isOpen then there'd be a flicker if the width
|
|
75
78
|
// of the button changes.
|
|
76
|
-
const position =
|
|
79
|
+
const position = calculatePopoverPosition(buttonRef.current, anchorSide);
|
|
77
80
|
const classes = classNames("vuiPopover", className);
|
|
78
81
|
const contentClasses = classNames("vuiPopoverContent", {
|
|
79
82
|
"vuiPopoverContent--padding": padding
|
|
@@ -87,5 +90,5 @@ export const VuiPopover = (_a) => {
|
|
|
87
90
|
// Enable scrolling of the page.
|
|
88
91
|
scrollLock: false,
|
|
89
92
|
// Enable scrolling of the page.
|
|
90
|
-
preventScrollOnFocus: false }, { children: _jsxs("div", Object.assign({ className: classes, style:
|
|
93
|
+
preventScrollOnFocus: false }, { children: _jsxs("div", Object.assign({ className: classes, style: position }, rest, { children: [header && typeof header === "string" ? _jsx("div", Object.assign({ className: "vuiPopoverTitle" }, { children: header })) : header, children && _jsx("div", Object.assign({ className: contentClasses }, { children: children }))] })) }))) })] }));
|
|
91
94
|
};
|
|
@@ -44,13 +44,15 @@ export const VuiSearchSelect = ({ children, title, isOpen, setIsOpen, options, s
|
|
|
44
44
|
updatedSelectedOptions.splice(index, 1);
|
|
45
45
|
}
|
|
46
46
|
onSelect(updatedSelectedOptions);
|
|
47
|
-
return;
|
|
48
47
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
else {
|
|
49
|
+
if (selectedOptions[0] === value) {
|
|
50
|
+
// If the user clicks on the selected option, deselect it.
|
|
51
|
+
onSelect([]);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
onSelect([value]);
|
|
55
|
+
}
|
|
54
56
|
};
|
|
55
57
|
// If onSearchChange is provided, we don't filter the options here because
|
|
56
58
|
// we assume the consumer has already filtered them.
|
package/package.json
CHANGED