@vectara/vectara-ui 19.3.1 → 19.5.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 +2 -1
- package/lib/components/accountButton/AccountButton.js +2 -2
- package/lib/components/app/appSideNav/AppSideNavLink.d.ts +1 -0
- package/lib/components/app/appSideNav/AppSideNavLink.js +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 +39 -7
|
@@ -5,6 +5,7 @@ type Props = {
|
|
|
5
5
|
email: string;
|
|
6
6
|
info?: InfoListType;
|
|
7
7
|
options?: OptionListItem<string>[];
|
|
8
|
+
after?: React.ReactNode;
|
|
8
9
|
};
|
|
9
|
-
export declare const VuiAccountButton: ({ userName, email, info, options, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare const VuiAccountButton: ({ userName, email, info, options, after, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
export {};
|
|
@@ -24,13 +24,13 @@ const Button = forwardRef((_a, ref) => {
|
|
|
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
26
|
export const VuiAccountButton = (_a) => {
|
|
27
|
-
var { userName, email, info, options } = _a, rest = __rest(_a, ["userName", "email", "info", "options"]);
|
|
27
|
+
var { userName, email, info, options, after } = _a, rest = __rest(_a, ["userName", "email", "info", "options", "after"]);
|
|
28
28
|
const [isOpen, setIsOpen] = useState(false);
|
|
29
29
|
const areUnique = userName && email && userName !== email;
|
|
30
30
|
const primaryLabel = areUnique ? userName : email;
|
|
31
31
|
const secondaryLabel = areUnique ? email : null;
|
|
32
32
|
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: () => {
|
|
33
|
+
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
34
|
setIsOpen(false);
|
|
35
35
|
}, options: options })) })));
|
|
36
36
|
};
|
|
@@ -2,4 +2,5 @@ import { TreeItem } from "../types";
|
|
|
2
2
|
export declare const VuiAppSideNavLink: import("react").ForwardRefExoticComponent<Pick<TreeItem, "className" | "path" | "name" | "isSelected" | "iconBefore" | "iconAfter"> & {
|
|
3
3
|
onClick?: import("react").MouseEventHandler<HTMLElement> | undefined;
|
|
4
4
|
iconAfterAlignEnd?: boolean | undefined;
|
|
5
|
+
after?: React.ReactNode;
|
|
5
6
|
} & import("react").RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
|
|
@@ -17,12 +17,12 @@ import { VuiIcon } from "../../icon/Icon";
|
|
|
17
17
|
import { useVuiContext } from "../../context/Context";
|
|
18
18
|
import { forwardRef } from "react";
|
|
19
19
|
export const VuiAppSideNavLink = forwardRef((_a, ref) => {
|
|
20
|
-
var { path, onClick, name, iconBefore, iconAfter, isSelected, className, iconAfterAlignEnd } = _a, rest = __rest(_a, ["path", "onClick", "name", "iconBefore", "iconAfter", "isSelected", "className", "iconAfterAlignEnd"]);
|
|
20
|
+
var { path, onClick, name, iconBefore, iconAfter, after, isSelected, className, iconAfterAlignEnd } = _a, rest = __rest(_a, ["path", "onClick", "name", "iconBefore", "iconAfter", "after", "isSelected", "className", "iconAfterAlignEnd"]);
|
|
21
21
|
const { createLink, getPath } = useVuiContext();
|
|
22
22
|
const classes = classNames("vuiAppSideNavLink", {
|
|
23
23
|
"vuiAppSideNavLink--active": isSelected !== null && isSelected !== void 0 ? isSelected : path === getPath()
|
|
24
24
|
}, className);
|
|
25
|
-
const content = iconBefore || iconAfter ? (_jsxs(VuiFlexContainer, Object.assign({ alignItems: "center", spacing: "xxs" }, { children: [iconBefore && (_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: _jsx(VuiIcon, Object.assign({ size: "s" }, { children: iconBefore })) }))), _jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: name })), iconAfter && (_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false, className: iconAfterAlignEnd ? "vuiAppSideNavLink__iconAfter--alignEnd" : undefined }, { children: _jsx(VuiIcon, Object.assign({ size: "s" }, { children: iconAfter })) })))] }))) : (name);
|
|
25
|
+
const content = iconBefore || iconAfter ? (_jsxs(VuiFlexContainer, Object.assign({ alignItems: "center", spacing: "xxs" }, { children: [iconBefore && (_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: _jsx(VuiIcon, Object.assign({ size: "s" }, { children: iconBefore })) }))), _jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: name })), (iconAfter || after) && (_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false, className: iconAfterAlignEnd ? "vuiAppSideNavLink__iconAfter--alignEnd" : undefined }, { children: _jsxs(VuiFlexContainer, Object.assign({ alignItems: "center", spacing: "xxs" }, { children: [after, iconAfter && _jsx(VuiIcon, Object.assign({ size: "s" }, { children: iconAfter }))] })) })))] }))) : (name);
|
|
26
26
|
if (!path) {
|
|
27
27
|
return (_jsx("button", Object.assign({ className: classes, onClick: onClick, type: "button", ref: ref }, rest, { children: content })));
|
|
28
28
|
}
|
|
@@ -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,24 @@
|
|
|
1
|
-
import { BiLogOut, BiUser } from "react-icons/bi";
|
|
2
|
-
import {
|
|
1
|
+
import { BiLogOut, BiTransferAlt, BiUser } from "react-icons/bi";
|
|
2
|
+
import {
|
|
3
|
+
OptionListItem,
|
|
4
|
+
VuiAccountButton,
|
|
5
|
+
VuiButtonSecondary,
|
|
6
|
+
VuiCopyButton,
|
|
7
|
+
VuiFlexContainer,
|
|
8
|
+
VuiFlexItem,
|
|
9
|
+
VuiIcon
|
|
10
|
+
} from "../../../lib";
|
|
3
11
|
|
|
4
12
|
export const AccountButton = () => {
|
|
5
13
|
const options: OptionListItem<string>[] = [
|
|
6
14
|
{
|
|
7
|
-
value: "
|
|
8
|
-
label: "
|
|
15
|
+
value: "switch",
|
|
16
|
+
label: "Switch accounts",
|
|
9
17
|
color: "primary",
|
|
10
|
-
testId: "
|
|
18
|
+
testId: "switchOption",
|
|
11
19
|
icon: (
|
|
12
20
|
<VuiIcon>
|
|
13
|
-
<
|
|
21
|
+
<BiTransferAlt />
|
|
14
22
|
</VuiIcon>
|
|
15
23
|
)
|
|
16
24
|
},
|
|
@@ -42,5 +50,29 @@ export const AccountButton = () => {
|
|
|
42
50
|
}
|
|
43
51
|
];
|
|
44
52
|
|
|
45
|
-
return
|
|
53
|
+
return (
|
|
54
|
+
<VuiAccountButton
|
|
55
|
+
userName="Falcor"
|
|
56
|
+
email="falcor@neverendingstory.com"
|
|
57
|
+
options={options}
|
|
58
|
+
info={info}
|
|
59
|
+
after={
|
|
60
|
+
<div style={{ paddingTop: "12px" }}>
|
|
61
|
+
<VuiButtonSecondary
|
|
62
|
+
fullWidth
|
|
63
|
+
size="s"
|
|
64
|
+
color="neutral"
|
|
65
|
+
onClick={() => console.log("Clicked")}
|
|
66
|
+
icon={
|
|
67
|
+
<VuiIcon>
|
|
68
|
+
<BiUser />
|
|
69
|
+
</VuiIcon>
|
|
70
|
+
}
|
|
71
|
+
>
|
|
72
|
+
Manage account
|
|
73
|
+
</VuiButtonSecondary>
|
|
74
|
+
</div>
|
|
75
|
+
}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
46
78
|
};
|