@vectara/vectara-ui 13.3.1 → 13.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/button/IconButton.d.ts +1 -0
- package/lib/components/card/Card.d.ts +3 -1
- package/lib/components/card/Card.js +18 -4
- package/lib/components/card/_index.scss +47 -0
- package/lib/components/tooltip/Tooltip.d.ts +2 -1
- package/lib/components/tooltip/Tooltip.js +4 -2
- package/lib/styles/index.css +40 -0
- package/package.json +1 -1
|
@@ -21,6 +21,7 @@ type Props = {
|
|
|
21
21
|
tooltip?: {
|
|
22
22
|
darkTheme?: TooltipProps["darkTheme"];
|
|
23
23
|
position?: TooltipProps["position"];
|
|
24
|
+
usePortal?: TooltipProps["usePortal"];
|
|
24
25
|
};
|
|
25
26
|
};
|
|
26
27
|
export declare const VuiIconButton: import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<HTMLButtonElement | null>>;
|
|
@@ -10,6 +10,8 @@ type Props = {
|
|
|
10
10
|
ungrouped?: boolean;
|
|
11
11
|
fullHeight?: boolean;
|
|
12
12
|
isScrollable?: boolean;
|
|
13
|
+
isExpanded?: boolean;
|
|
14
|
+
onToggleExpansion?: () => void;
|
|
13
15
|
};
|
|
14
|
-
export declare const VuiCard: ({ type, header, body, align, interactive, href, className, padding, ungrouped, fullHeight, isScrollable, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare const VuiCard: ({ type, header, body, align, interactive, href, className, padding, ungrouped, fullHeight, isScrollable, isExpanded, onToggleExpansion, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
15
17
|
export {};
|
|
@@ -11,18 +11,32 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import classNames from "classnames";
|
|
14
|
+
import { BiChevronDown, BiChevronRight } from "react-icons/bi";
|
|
15
|
+
import { VuiFlexContainer } from "../flex/FlexContainer";
|
|
16
|
+
import { VuiFlexItem } from "../flex/FlexItem";
|
|
17
|
+
import { VuiIcon } from "../icon/Icon";
|
|
18
|
+
import { createId } from "../../utils/createId";
|
|
14
19
|
export const VuiCard = (_a) => {
|
|
15
|
-
var { type = "outlined", header, body, align = "left", interactive, href, className, padding = "s", ungrouped, fullHeight, isScrollable } = _a, rest = __rest(_a, ["type", "header", "body", "align", "interactive", "href", "className", "padding", "ungrouped", "fullHeight", "isScrollable"]);
|
|
16
|
-
const
|
|
17
|
-
|
|
20
|
+
var { type = "outlined", header, body, align = "left", interactive, href, className, padding = "s", ungrouped, fullHeight, isScrollable, isExpanded, onToggleExpansion } = _a, rest = __rest(_a, ["type", "header", "body", "align", "interactive", "href", "className", "padding", "ungrouped", "fullHeight", "isScrollable", "isExpanded", "onToggleExpansion"]);
|
|
21
|
+
const isExpandable = Boolean(onToggleExpansion);
|
|
22
|
+
const buttonId = createId();
|
|
23
|
+
const bodyId = createId();
|
|
24
|
+
const classes = classNames("vuiCard",
|
|
25
|
+
// for now, we only support outlined cards for expandable cards
|
|
26
|
+
`vuiCard--${isExpandable ? "outlined" : type}`, `vuiCard--${align}`, `vuiCard--${padding}`, {
|
|
27
|
+
"vuiCard--interactive": interactive && !href && !isExpandable,
|
|
18
28
|
"vuiCard--link": href,
|
|
19
29
|
"vuiCard--ungrouped": ungrouped,
|
|
20
|
-
"vuiCard--fullHeight": fullHeight
|
|
30
|
+
"vuiCard--fullHeight": fullHeight,
|
|
31
|
+
"vuiCard--expandable": isExpandable
|
|
21
32
|
}, className);
|
|
22
33
|
const bodyClasses = classNames("vuiCard__body", {
|
|
23
34
|
"vuiCard__body--withHeader": header,
|
|
24
35
|
"vuiCard__body--scrollable": isScrollable
|
|
25
36
|
});
|
|
37
|
+
if (isExpandable) {
|
|
38
|
+
return (_jsxs("div", Object.assign({ className: classes }, rest, { children: [header && (_jsx("button", Object.assign({ className: "vuiCard__expandableButton", onClick: onToggleExpansion, id: buttonId, "aria-controls": bodyId, "aria-expanded": isExpanded, type: "button" }, { children: _jsxs(VuiFlexContainer, Object.assign({ alignItems: "center", justifyContent: "start", spacing: "xs" }, { children: [_jsx(VuiIcon, Object.assign({ size: "m", color: "neutral", className: "vuiCard__expandableIcon" }, { children: isExpanded ? _jsx(BiChevronDown, {}) : _jsx(BiChevronRight, {}) })), _jsx(VuiFlexItem, Object.assign({ className: "vuiCard__expandableHeader", grow: 1 }, { children: header }))] })) }))), isExpanded && body && (_jsx("div", Object.assign({ className: bodyClasses, id: bodyId, "aria-labelledby": buttonId }, { children: body })))] })));
|
|
39
|
+
}
|
|
26
40
|
const headerContent = header && _jsx("div", Object.assign({ className: "vuiCard__header" }, { children: header }));
|
|
27
41
|
const bodyContent = body && _jsx("div", Object.assign({ className: bodyClasses }, { children: body }));
|
|
28
42
|
if (href) {
|
|
@@ -104,3 +104,50 @@
|
|
|
104
104
|
padding: $sizeXl $sizeXxl;
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
+
|
|
108
|
+
.vuiCard--expandable {
|
|
109
|
+
.vuiCard__expandableButton {
|
|
110
|
+
display: block;
|
|
111
|
+
width: 100%;
|
|
112
|
+
padding: $sizeM $sizeL;
|
|
113
|
+
text-align: left;
|
|
114
|
+
background: transparent;
|
|
115
|
+
border: none;
|
|
116
|
+
cursor: pointer;
|
|
117
|
+
transition: background-color $transitionSpeed;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.vuiCard__expandableButton:hover {
|
|
121
|
+
background-color: var(--vui-color-light-shade);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.vuiCard__expandableButton:focus {
|
|
125
|
+
outline: 2px solid var(--vui-color-primary);
|
|
126
|
+
outline-offset: -2px;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.vuiCard__expandableIcon {
|
|
130
|
+
transition: transform $transitionSpeed ease-in-out;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.vuiCard__expandableHeader {
|
|
134
|
+
text-align: inherit;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Size-specific expandable button padding
|
|
139
|
+
.vuiCard--expandable.vuiCard--s .vuiCard__expandableButton {
|
|
140
|
+
padding: $sizeM $sizeL;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.vuiCard--expandable.vuiCard--m .vuiCard__expandableButton {
|
|
144
|
+
padding: $sizeL $sizeXl;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.vuiCard--expandable.vuiCard--l .vuiCard__expandableButton {
|
|
148
|
+
padding: $sizeXl $sizeXxl;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.vuiCard--expandable.vuiCard--outlined .vuiCard__body {
|
|
152
|
+
border-top: 1px solid var(--vui-color-border-light);
|
|
153
|
+
}
|
|
@@ -4,5 +4,6 @@ export type Props = {
|
|
|
4
4
|
tip: React.ReactNode;
|
|
5
5
|
darkTheme?: boolean;
|
|
6
6
|
position?: TooltipRefProps["place"];
|
|
7
|
+
usePortal?: boolean;
|
|
7
8
|
};
|
|
8
|
-
export declare const VuiTooltip: ({ children, darkTheme, position, tip }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare const VuiTooltip: ({ children, darkTheme, position, tip, usePortal }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,10 +2,11 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { useState, cloneElement } from "react";
|
|
3
3
|
import { Tooltip } from "react-tooltip";
|
|
4
4
|
import { useVuiContext } from "../context/Context";
|
|
5
|
+
import { VuiPortal } from "../portal/Portal";
|
|
5
6
|
const generateTooltipId = () => {
|
|
6
7
|
return `tooltip-${Math.random().toString(36).slice(2, 9)}`;
|
|
7
8
|
};
|
|
8
|
-
export const VuiTooltip = ({ children, darkTheme, position, tip }) => {
|
|
9
|
+
export const VuiTooltip = ({ children, darkTheme, position, tip, usePortal }) => {
|
|
9
10
|
const { getThemeStyle } = useVuiContext();
|
|
10
11
|
const [id] = useState(generateTooltipId());
|
|
11
12
|
const target = cloneElement(children, {
|
|
@@ -15,7 +16,8 @@ export const VuiTooltip = ({ children, darkTheme, position, tip }) => {
|
|
|
15
16
|
// the light theme class in order to enable having a different theme than the
|
|
16
17
|
// parent.
|
|
17
18
|
const style = getThemeStyle(darkTheme ? "dark" : "light");
|
|
18
|
-
|
|
19
|
+
const tooltip = (_jsx(Tooltip, Object.assign({ id: id, offset: 10, className: "vuiTooltip", style: style, opacity: 1, place: position }, { children: tip })));
|
|
20
|
+
return (_jsxs(_Fragment, { children: [target, usePortal ? _jsx(VuiPortal, { children: tooltip }) : tooltip] }));
|
|
19
21
|
};
|
|
20
22
|
// This is a workaround for the issue with ResizeObserver in ReactTooltip.
|
|
21
23
|
// Without this, uncaught runtime errors are thrown: "ResizeObserver loop
|
package/lib/styles/index.css
CHANGED
|
@@ -1173,6 +1173,46 @@ fieldset {
|
|
|
1173
1173
|
padding: 32px 40px;
|
|
1174
1174
|
}
|
|
1175
1175
|
|
|
1176
|
+
.vuiCard--expandable .vuiCard__expandableButton {
|
|
1177
|
+
display: block;
|
|
1178
|
+
width: 100%;
|
|
1179
|
+
padding: 16px 24px;
|
|
1180
|
+
text-align: left;
|
|
1181
|
+
background: transparent;
|
|
1182
|
+
border: none;
|
|
1183
|
+
cursor: pointer;
|
|
1184
|
+
transition: background-color 0.2s;
|
|
1185
|
+
}
|
|
1186
|
+
.vuiCard--expandable .vuiCard__expandableButton:hover {
|
|
1187
|
+
background-color: var(--vui-color-light-shade);
|
|
1188
|
+
}
|
|
1189
|
+
.vuiCard--expandable .vuiCard__expandableButton:focus {
|
|
1190
|
+
outline: 2px solid var(--vui-color-primary);
|
|
1191
|
+
outline-offset: -2px;
|
|
1192
|
+
}
|
|
1193
|
+
.vuiCard--expandable .vuiCard__expandableIcon {
|
|
1194
|
+
transition: transform 0.2s ease-in-out;
|
|
1195
|
+
}
|
|
1196
|
+
.vuiCard--expandable .vuiCard__expandableHeader {
|
|
1197
|
+
text-align: inherit;
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
.vuiCard--expandable.vuiCard--s .vuiCard__expandableButton {
|
|
1201
|
+
padding: 16px 24px;
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
.vuiCard--expandable.vuiCard--m .vuiCard__expandableButton {
|
|
1205
|
+
padding: 24px 32px;
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
.vuiCard--expandable.vuiCard--l .vuiCard__expandableButton {
|
|
1209
|
+
padding: 32px 40px;
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
.vuiCard--expandable.vuiCard--outlined .vuiCard__body {
|
|
1213
|
+
border-top: 1px solid var(--vui-color-border-light);
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1176
1216
|
.vuiChatTurn {
|
|
1177
1217
|
position: relative;
|
|
1178
1218
|
left: 0;
|