@vectara/vectara-ui 13.4.0 → 13.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.
@@ -19,6 +19,7 @@ export type BaseButtonProps = {
19
19
  href?: LinkProps["href"];
20
20
  target?: LinkProps["target"];
21
21
  track?: LinkProps["track"];
22
+ download?: LinkProps["download"];
22
23
  htmlFor?: string;
23
24
  tabIndex?: number;
24
25
  title?: string;
@@ -66,6 +66,6 @@ export const BaseButton = forwardRef((_a, ref) => {
66
66
  onMouseOver,
67
67
  onMouseOut,
68
68
  onMouseMove,
69
- tabIndex, ["type"]: isSubmit ? "submit" : "button", disabled: isDisabled }, rest);
69
+ tabIndex, type: isSubmit ? "submit" : "button", disabled: isDisabled }, rest);
70
70
  return (_jsxs("button", Object.assign({ className: classes }, props, { ref: ref }, { children: [iconContainer, children] })));
71
71
  });
@@ -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 classes = classNames("vuiCard", `vuiCard--${type}`, `vuiCard--${align}`, `vuiCard--${padding}`, {
17
- "vuiCard--interactive": interactive && !href,
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
+ }
@@ -15,10 +15,12 @@ import { LIGHT_THEME, DARK_THEME, toStyle } from "./Theme";
15
15
  const VuiContext = createContext(undefined);
16
16
  export const VuiContextProvider = ({ children, linkProvider, pathProvider, drawerTitle = "h2", theme = LIGHT_THEME, portalContainer = document.body, isThemeIsolated }) => {
17
17
  const createLink = (linkConfig) => {
18
- if (linkProvider)
19
- return linkProvider(linkConfig);
20
- const { className, href, onClick, children, ref } = linkConfig, rest = __rest(linkConfig, ["className", "href", "onClick", "children", "ref"]);
21
- return (_jsx("a", Object.assign({ className: className, href: href, onClick: onClick }, rest, { children: children })));
18
+ if (!linkProvider || linkConfig.download) {
19
+ const { className, href, onClick, children, ref } = linkConfig, rest = __rest(linkConfig, ["className", "href", "onClick", "children", "ref"]);
20
+ // To support downloads, we must use anchor tags, not a react-router Link.
21
+ return (_jsx("a", Object.assign({ className: className, href: href, onClick: onClick }, rest, { children: children })));
22
+ }
23
+ return linkProvider(linkConfig);
22
24
  };
23
25
  const getPath = () => {
24
26
  return pathProvider ? pathProvider() : window.location.pathname;
@@ -16,4 +16,5 @@ export type LinkProps = {
16
16
  tabIndex?: number;
17
17
  "data-testid"?: string;
18
18
  ref?: ForwardedRef<HTMLAnchorElement | null>;
19
+ download?: string;
19
20
  };
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vectara/vectara-ui",
3
- "version": "13.4.0",
3
+ "version": "13.6.0",
4
4
  "homepage": "./",
5
5
  "description": "Vectara's design system, codified as a React and Sass component library",
6
6
  "author": "Vectara",