@vectara/vectara-ui 19.4.0 → 19.6.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/lib/components/accountButton/AccountButton.d.ts +5 -1
- package/lib/components/accountButton/AccountButton.js +8 -5
- package/lib/components/index.d.ts +2 -2
- package/lib/components/infoMenu/InfoMenu.d.ts +2 -1
- package/lib/components/infoMenu/InfoMenu.js +3 -3
- package/package.json +1 -1
- package/src/docs/pages/accountButton/AccountButton.tsx +44 -7
|
@@ -5,6 +5,10 @@ type Props = {
|
|
|
5
5
|
email: string;
|
|
6
6
|
info?: InfoListType;
|
|
7
7
|
options?: OptionListItem<string>[];
|
|
8
|
+
after?: React.ReactNode;
|
|
8
9
|
};
|
|
9
|
-
export
|
|
10
|
+
export type AccountButtonHandle = {
|
|
11
|
+
closeMenu: () => void;
|
|
12
|
+
};
|
|
13
|
+
export declare const VuiAccountButton: import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<AccountButtonHandle>>;
|
|
10
14
|
export {};
|
|
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import { forwardRef, useState } from "react";
|
|
13
|
+
import { forwardRef, useImperativeHandle, useState } from "react";
|
|
14
14
|
import { BiExpandVertical } from "react-icons/bi";
|
|
15
15
|
import classNames from "classnames";
|
|
16
16
|
import { VuiIcon } from "../icon/Icon";
|
|
@@ -23,14 +23,17 @@ const Button = forwardRef((_a, ref) => {
|
|
|
23
23
|
});
|
|
24
24
|
return (_jsx("button", Object.assign({ className: classes, type: "button" }, rest, { ref: ref, "aria-expanded": isSelected, "aria-haspopup": "menu" }, { children: children })));
|
|
25
25
|
});
|
|
26
|
-
export const VuiAccountButton = (_a) => {
|
|
27
|
-
var { userName, email, info, options } = _a, rest = __rest(_a, ["userName", "email", "info", "options"]);
|
|
26
|
+
export const VuiAccountButton = forwardRef((_a, ref) => {
|
|
27
|
+
var { userName, email, info, options, after } = _a, rest = __rest(_a, ["userName", "email", "info", "options", "after"]);
|
|
28
28
|
const [isOpen, setIsOpen] = useState(false);
|
|
29
|
+
useImperativeHandle(ref, () => ({
|
|
30
|
+
closeMenu: () => setIsOpen(false)
|
|
31
|
+
}));
|
|
29
32
|
const areUnique = userName && email && userName !== email;
|
|
30
33
|
const primaryLabel = areUnique ? userName : email;
|
|
31
34
|
const secondaryLabel = areUnique ? email : null;
|
|
32
35
|
const button = (_jsxs(Button, Object.assign({ isSelected: isOpen }, rest, { children: [_jsxs("div", Object.assign({ className: "vuiAccountButton__labels" }, { children: [_jsx("div", Object.assign({ className: "vuiAccountButton__primaryLabel" }, { children: primaryLabel })), secondaryLabel && _jsx("div", Object.assign({ className: "vuiAccountButton__secondaryLabel" }, { children: secondaryLabel }))] })), _jsx(VuiIcon, Object.assign({ size: "s", color: "neutral", className: "vuiAccountButton__icon" }, { children: _jsx(BiExpandVertical, {}) }))] })));
|
|
33
|
-
return (_jsx(VuiInfoMenu, Object.assign({ isOpen: isOpen, setIsOpen: setIsOpen, button: button, info: info, anchorSide: "rightUp" }, { children: options && (_jsx(VuiOptionsList, { size: "l", onSelectOption: () => {
|
|
36
|
+
return (_jsx(VuiInfoMenu, Object.assign({ isOpen: isOpen, setIsOpen: setIsOpen, button: button, info: info, infoAfter: after, anchorSide: "rightUp" }, { children: options && (_jsx(VuiOptionsList, { size: "l", onSelectOption: () => {
|
|
34
37
|
setIsOpen(false);
|
|
35
38
|
}, options: options })) })));
|
|
36
|
-
};
|
|
39
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VuiAccordion } from "./accordion/Accordion";
|
|
2
|
-
import { VuiAccountButton } from "./accountButton/AccountButton";
|
|
2
|
+
import { VuiAccountButton, AccountButtonHandle } from "./accountButton/AccountButton";
|
|
3
3
|
import { VuiAppContent } from "./app/AppContent";
|
|
4
4
|
import { VuiAppHeader } from "./app/AppHeader";
|
|
5
5
|
import { VuiAppLayout } from "./app/AppLayout";
|
|
@@ -116,5 +116,5 @@ import { VuiInfoTooltip } from "./tooltip/InfoTooltip";
|
|
|
116
116
|
import { VuiTopicButton } from "./topicButton/TopicButton";
|
|
117
117
|
import { copyToClipboard } from "../utils/copyToClipboard";
|
|
118
118
|
import { toRgb, toRgba } from "./context/Theme";
|
|
119
|
-
export type { AnchorSide, AppContentPadding, BarChartSeries, ComposedSeries, LineChartSeries, LineChartVariant, ScatterSeries, ButtonColor, CalloutColor, ChatLanguage, ChatStyle, ChatTurn, CheckboxConfig, CodeEditorColorConfig, CodeEditorError, CodeLanguage, ComposerFileError, ComposerShortcutApi, ComposerShortcutHandler, ComposerSubmission, InfoListItemType, InfoListType, InfoTableColumnAlign, InfoTableRow, InfoTableRowType, KvTableAlign, KvTableItem, KvTableItems, KvTablePadding, LinkProps, MenuItem, OptionListItem, Pagination, PatchColor, RadioButtonConfig, SearchResult, SearchSuggestion, Sections, SectionItem, SpansRow, Stat, StepStatus, StepSize, Steps, StepsVertical, StepVerticalStatus, TabNavigatorRoute, TabSize, Tree, TreeItem };
|
|
119
|
+
export type { AnchorSide, AppContentPadding, BarChartSeries, ComposedSeries, LineChartSeries, LineChartVariant, ScatterSeries, ButtonColor, CalloutColor, ChatLanguage, ChatStyle, ChatTurn, CheckboxConfig, CodeEditorColorConfig, CodeEditorError, CodeLanguage, ComposerFileError, ComposerShortcutApi, ComposerShortcutHandler, ComposerSubmission, InfoListItemType, InfoListType, InfoTableColumnAlign, InfoTableRow, InfoTableRowType, KvTableAlign, KvTableItem, KvTableItems, KvTablePadding, LinkProps, MenuItem, OptionListItem, Pagination, PatchColor, RadioButtonConfig, SearchResult, SearchSuggestion, Sections, SectionItem, SpansRow, Stat, StepStatus, StepSize, Steps, StepsVertical, StepVerticalStatus, TabNavigatorRoute, TabSize, Tree, TreeItem, AccountButtonHandle };
|
|
120
120
|
export { BADGE_COLOR, BUTTON_COLOR, BUTTON_SIZE, CHART_PALETTE, CALLOUT_COLOR, CALLOUT_SIZE, DURATION_BAR_COLOR, ICON_COLOR, ICON_SIZE, ICON_TYPE, PATCH_COLOR, PROGRESS_BAR_COLOR, SPACER_SIZE, SPINNER_COLOR, SKELETON_COLOR, SPINNER_SIZE, TAB_SIZE, TEXT_COLOR, TEXT_SIZE, TITLE_SIZE, addNotification, copyToClipboard, generateTokensProvider, toRgb, toRgba, VuiAccordion, VuiAccountButton, VuiAppContent, VuiAppHeader, VuiAppLayout, VuiAppSideNav, VuiAppSideNavLink, VuiAppSideNavGroup, VuiBadge, VuiBarChart, VuiComposedChart, VuiLineChart, VuiPieChart, VuiScatterChart, VuiSparkline, VuiTreeMap, VuiButtonPrimary, VuiButtonSecondary, VuiButtonTertiary, VuiIconButton, VuiCallout, VuiCard, VuiChat, VuiCheckbox, VuiChip, VuiCode, VuiCodeEditor, VuiComposer, VuiComplexConfigurationButton, VuiContextProvider, VuiCopyButton, VuiDatePicker, VuiDateRangePicker, VuiDrawer, VuiDurationBar, VuiErrorBoundary, VuiFileDropTarget, VuiFlexContainer, VuiFlexItem, VuiFormGroup, VuiGrid, VuiGridItem, VuiHorizontalRule, VuiIcon, VuiImage, VuiImagePreview, VuiInfoList, VuiInfoListItem, VuiInfoMenu, VuiInfoTable, VuiInfoTooltip, VuiKvTable, VuiInProgress, VuiItemsInput, VuiLabel, VuiLink, VuiLinkInternal, VuiList, VuiMenu, VuiMenuItem, VuiMenuList, VuiMenuListButton, VuiModal, VuiNotifications, VuiNumberInput, VuiOptionsButton, VuiOptionsList, VuiOptionsListItem, VuiPagination, VuiPanel, VuiPasswordInput, VuiPatch, VuiPopover, VuiPortal, VuiProgressBar, VuiPrompt, VuiRadioButton, VuiScreenBlock, VuiSearchInput, VuiSearchResult, VuiSearchSelect, VuiSelect, VuiSetting, VuiSideList, VuiSideListButton, VuiSimpleCard, VuiSimpleGrid, VuiSpacer, VuiSpans, VuiSpinner, VuiStat, VuiStatList, VuiStatus, VuiSteps, VuiStepsVertical, VuiSummary, VuiSkeleton, VuiSummaryCitation, VuiSuperCheckboxGroup, VuiSuperRadioGroup, VuiTable, VuiTab, VuiTabbedRoutes, VuiTabs, VuiTabsNavigator, VuiText, VuiTextArea, VuiTextColor, VuiTextInput, VuiTimeline, VuiTimelineItem, VuiTitle, VuiToggle, VuiTooltip, VuiTopicButton };
|
|
@@ -2,6 +2,7 @@ import { InfoListType } from "../infoList/InfoList";
|
|
|
2
2
|
import { Props as PopoverProps } from "../popover/Popover";
|
|
3
3
|
type Props = PopoverProps & {
|
|
4
4
|
info?: InfoListType;
|
|
5
|
+
infoAfter?: React.ReactNode;
|
|
5
6
|
};
|
|
6
|
-
export declare const VuiInfoMenu: ({ isOpen, setIsOpen, button, info, children, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare const VuiInfoMenu: ({ isOpen, setIsOpen, button, info, infoAfter, children, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
7
8
|
export {};
|
|
@@ -9,11 +9,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { VuiInfoList } from "../infoList/InfoList";
|
|
14
14
|
import { VuiPopover } from "../popover/Popover";
|
|
15
15
|
export const VuiInfoMenu = (_a) => {
|
|
16
|
-
var { isOpen, setIsOpen, button, info, children } = _a, rest = __rest(_a, ["isOpen", "setIsOpen", "button", "info", "children"]);
|
|
16
|
+
var { isOpen, setIsOpen, button, info, infoAfter, children } = _a, rest = __rest(_a, ["isOpen", "setIsOpen", "button", "info", "infoAfter", "children"]);
|
|
17
17
|
return (_jsx(VuiPopover, Object.assign({ className: "vuiInfoMenu", isOpen: isOpen, setIsOpen: () => setIsOpen(!isOpen), button: button, header: info &&
|
|
18
|
-
info.length > 0 && (
|
|
18
|
+
info.length > 0 && (_jsxs("div", Object.assign({ className: "vuiInfoMenuHeader" }, { children: [_jsx(VuiInfoList, { info: info }), infoAfter] }))) }, rest, { children: children })));
|
|
19
19
|
};
|
package/package.json
CHANGED
|
@@ -1,16 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useRef } from "react";
|
|
2
|
+
import { BiLogOut, BiTransferAlt, BiUser } from "react-icons/bi";
|
|
3
|
+
import {
|
|
4
|
+
OptionListItem,
|
|
5
|
+
VuiAccountButton,
|
|
6
|
+
AccountButtonHandle,
|
|
7
|
+
VuiButtonSecondary,
|
|
8
|
+
VuiCopyButton,
|
|
9
|
+
VuiFlexContainer,
|
|
10
|
+
VuiFlexItem,
|
|
11
|
+
VuiIcon
|
|
12
|
+
} from "../../../lib";
|
|
3
13
|
|
|
4
14
|
export const AccountButton = () => {
|
|
15
|
+
const accountButtonRef = useRef<AccountButtonHandle>(null);
|
|
16
|
+
|
|
5
17
|
const options: OptionListItem<string>[] = [
|
|
6
18
|
{
|
|
7
|
-
value: "
|
|
8
|
-
label: "
|
|
19
|
+
value: "switch",
|
|
20
|
+
label: "Switch accounts",
|
|
9
21
|
color: "primary",
|
|
10
|
-
testId: "
|
|
22
|
+
testId: "switchOption",
|
|
11
23
|
icon: (
|
|
12
24
|
<VuiIcon>
|
|
13
|
-
<
|
|
25
|
+
<BiTransferAlt />
|
|
14
26
|
</VuiIcon>
|
|
15
27
|
)
|
|
16
28
|
},
|
|
@@ -42,5 +54,30 @@ export const AccountButton = () => {
|
|
|
42
54
|
}
|
|
43
55
|
];
|
|
44
56
|
|
|
45
|
-
return
|
|
57
|
+
return (
|
|
58
|
+
<VuiAccountButton
|
|
59
|
+
ref={accountButtonRef}
|
|
60
|
+
userName="Falcor"
|
|
61
|
+
email="falcor@neverendingstory.com"
|
|
62
|
+
options={options}
|
|
63
|
+
info={info}
|
|
64
|
+
after={
|
|
65
|
+
<div style={{ paddingTop: "12px" }}>
|
|
66
|
+
<VuiButtonSecondary
|
|
67
|
+
fullWidth
|
|
68
|
+
size="s"
|
|
69
|
+
color="neutral"
|
|
70
|
+
onClick={() => accountButtonRef.current?.closeMenu()}
|
|
71
|
+
icon={
|
|
72
|
+
<VuiIcon>
|
|
73
|
+
<BiUser />
|
|
74
|
+
</VuiIcon>
|
|
75
|
+
}
|
|
76
|
+
>
|
|
77
|
+
Manage account
|
|
78
|
+
</VuiButtonSecondary>
|
|
79
|
+
</div>
|
|
80
|
+
}
|
|
81
|
+
/>
|
|
82
|
+
);
|
|
46
83
|
};
|