@vectara/vectara-ui 15.7.0 → 15.7.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.
@@ -44,8 +44,17 @@ export const VuiDrawer = (_a) => {
44
44
  onClose === null || onClose === void 0 ? void 0 : onClose();
45
45
  }, 0);
46
46
  };
47
+ // Handle outside clicks, but ignore clicks on notifications.
48
+ const handleClickOutside = (event) => {
49
+ const target = event.target;
50
+ // Check if the click is within a notification.
51
+ if (target.closest("[data-awareness='notification']")) {
52
+ return;
53
+ }
54
+ onCloseDelayed();
55
+ };
47
56
  const classes = classNames("vuiDrawer", `vuiDrawer--${color}`, className);
48
- return (_jsx(VuiPortal, { children: isOpen && (_jsx(VuiScreenBlock, { children: _jsx(FocusOn, Object.assign({ onEscapeKey: onCloseDelayed, onClickOutside: onCloseDelayed,
57
+ return (_jsx(VuiPortal, { children: isOpen && (_jsx(VuiScreenBlock, { children: _jsx(FocusOn, Object.assign({ onEscapeKey: onCloseDelayed, onClickOutside: handleClickOutside,
49
58
  // Enable manual focus return to work.
50
59
  returnFocus: false,
51
60
  // Enable focus on contents when it's open,
@@ -37,5 +37,7 @@ export const VuiNotification = ({ color, message, onDismiss, children, hasCopyBu
37
37
  icon = null;
38
38
  }
39
39
  const copyValue = code ? `${message}\n\n${code.content}` : message;
40
- return (_jsx("div", Object.assign({ className: classes, "data-testid": `notification-${color}` }, { children: _jsxs(VuiFlexContainer, Object.assign({ alignItems: "start", spacing: "s" }, { children: [_jsx(VuiFlexItem, Object.assign({ grow: 1 }, { children: _jsxs(VuiFlexContainer, Object.assign({ alignItems: "start", spacing: "xs" }, { children: [icon, _jsxs("div", { children: [_jsx(VuiText, Object.assign({ preserveWhiteSpace: true }, { children: _jsx(VuiTextColor, Object.assign({ color: color }, { children: message })) })), code && (_jsxs(_Fragment, { children: [_jsx(VuiSpacer, { size: "s" }), _jsx(VuiCode, Object.assign({ language: code.language }, { children: code.content }))] })), hasCopyButton && (_jsxs(_Fragment, { children: [_jsx(VuiSpacer, { size: "s" }), _jsx(VuiCopyButton, { value: copyValue, size: "s", label: "Copy notification" })] })), children && (_jsxs(_Fragment, { children: [_jsx(VuiSpacer, { size: "s" }), children] })), link && (_jsxs(_Fragment, { children: [_jsx(VuiSpacer, { size: "s" }), _jsx(VuiLink, Object.assign({}, link))] }))] })] })) })), _jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: _jsx(VuiIconButton, { "aria-label": "Dismiss message", size: "xs", color: "neutral", icon: _jsx(VuiIcon, { children: _jsx(BiX, {}) }), onClick: () => onDismiss(), "data-testid": `dismissNotificationButton-${color}` }) }))] })) })));
40
+ // data-awareness="notification" enables notifications to be closed when a drawer is open,
41
+ // without triggering the drawer to close.
42
+ return (_jsx("div", Object.assign({ className: classes, "data-testid": `notification-${color}`, "data-awareness": "notification" }, { children: _jsxs(VuiFlexContainer, Object.assign({ alignItems: "start", spacing: "s" }, { children: [_jsx(VuiFlexItem, Object.assign({ grow: 1 }, { children: _jsxs(VuiFlexContainer, Object.assign({ alignItems: "start", spacing: "xs" }, { children: [icon, _jsxs("div", { children: [_jsx(VuiText, Object.assign({ preserveWhiteSpace: true }, { children: _jsx(VuiTextColor, Object.assign({ color: color }, { children: message })) })), code && (_jsxs(_Fragment, { children: [_jsx(VuiSpacer, { size: "s" }), _jsx(VuiCode, Object.assign({ language: code.language }, { children: code.content }))] })), hasCopyButton && (_jsxs(_Fragment, { children: [_jsx(VuiSpacer, { size: "s" }), _jsx(VuiCopyButton, { value: copyValue, size: "s", label: "Copy notification" })] })), children && (_jsxs(_Fragment, { children: [_jsx(VuiSpacer, { size: "s" }), children] })), link && (_jsxs(_Fragment, { children: [_jsx(VuiSpacer, { size: "s" }), _jsx(VuiLink, Object.assign({}, link))] }))] })] })) })), _jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: _jsx(VuiIconButton, { "aria-label": "Dismiss message", size: "xs", color: "neutral", icon: _jsx(VuiIcon, { children: _jsx(BiX, {}) }), onClick: () => onDismiss(), "data-testid": `dismissNotificationButton-${color}` }) }))] })) })));
41
43
  };
@@ -1,6 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Toaster } from "sonner";
3
+ import { VuiPortal } from "../portal/Portal";
3
4
  export const VuiNotifications = (props) => {
4
5
  const finalProps = Object.assign({ position: "top-right" }, props);
5
- return _jsx(Toaster, Object.assign({}, finalProps));
6
+ // Render inside portal so notifications can appear above everything else, including drawers.
7
+ return (_jsx(VuiPortal, { children: _jsx(Toaster, Object.assign({}, finalProps)) }));
6
8
  };
@@ -178,7 +178,7 @@ export const VuiTable = (_a) => {
178
178
  _jsxs("div", Object.assign({ className: "vuiTableWrapper", inert: isDisabled ? "" : null, "data-testid": dataTestId }, { children: [isDisabled && _jsx("div", { className: "vuiTableBlock" }), (hasSearch ||
179
179
  customControls ||
180
180
  (hasBulkActions && selectedRows && selectedRows.length > 0) ||
181
- Boolean(onReload)) && (_jsxs(_Fragment, { children: [_jsxs(VuiFlexContainer, Object.assign({ spacing: "s", alignItems: "center", className: isHeaderSticky ? "vuiTableStickyHeader" : undefined, wrap: true }, { children: [onSelectRow && (_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false, className: "vuiTableHeader__responsiveSelectAllCheckbox" }, { children: _jsx(VuiCheckbox, Object.assign({ label: "Select all" }, selectAllCheckboxProps)) }))), selectedRows && selectedRows.length > 0 && hasBulkActions && (_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: _jsx(VuiTableBulkActions, { selectedRows: selectedRows, actions: bulkActions }) }))), hasSearch && (_jsx(VuiFlexItem, Object.assign({ grow: 1, shrink: false }, { children: _jsx(VuiTextInput, Object.assign({ fullWidth: true }, search)) }))), customControls && (_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: customControls }))), onReload && (_jsx(VuiFlexItem, Object.assign({ grow: 1, shrink: false }, { children: _jsx(VuiFlexContainer, Object.assign({ justifyContent: "end" }, { children: _jsx(VuiButtonSecondary, Object.assign({ color: "neutral", onClick: () => onReload(), "data-testid": reloadTestId }, { children: "Reload" })) })) })))] })), _jsx(VuiSpacer, { size: "s" })] })), _jsxs("table", Object.assign({ className: classes }, restProps, { children: [_jsx("thead", { children: _jsxs("tr", { children: [onSelectRow && (_jsx("th", Object.assign({ className: "vuiTableHeaderSelect" }, { children: _jsx(VuiTableCell, { children: _jsx(VuiCheckbox, Object.assign({}, selectAllCheckboxProps)) }) }))), columns.map((column) => {
181
+ Boolean(onReload)) && (_jsxs(_Fragment, { children: [_jsxs(VuiFlexContainer, Object.assign({ spacing: "s", alignItems: "center", className: isHeaderSticky ? "vuiTableStickyHeader" : undefined, wrap: true }, { children: [onSelectRow && isResponsive && (_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false, className: "vuiTableHeader__responsiveSelectAllCheckbox" }, { children: _jsx(VuiCheckbox, Object.assign({ label: "Select all" }, selectAllCheckboxProps)) }))), selectedRows && selectedRows.length > 0 && hasBulkActions && (_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: _jsx(VuiTableBulkActions, { selectedRows: selectedRows, actions: bulkActions }) }))), hasSearch && (_jsx(VuiFlexItem, Object.assign({ grow: 1, shrink: false }, { children: _jsx(VuiTextInput, Object.assign({ fullWidth: true }, search)) }))), customControls && (_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: customControls }))), onReload && (_jsx(VuiFlexItem, Object.assign({ grow: 1, shrink: false }, { children: _jsx(VuiFlexContainer, Object.assign({ justifyContent: "end" }, { children: _jsx(VuiButtonSecondary, Object.assign({ color: "neutral", onClick: () => onReload(), "data-testid": reloadTestId }, { children: "Reload" })) })) })))] })), _jsx(VuiSpacer, { size: "s" })] })), _jsxs("table", Object.assign({ className: classes }, restProps, { children: [_jsx("thead", { children: _jsxs("tr", { children: [onSelectRow && (_jsx("th", Object.assign({ className: "vuiTableHeaderSelect" }, { children: _jsx(VuiTableCell, { children: _jsx(VuiCheckbox, Object.assign({}, selectAllCheckboxProps)) }) }))), columns.map((column) => {
182
182
  const { name, width } = column;
183
183
  const styles = width ? { width } : undefined;
184
184
  return (_jsx("th", Object.assign({ style: styles }, { children: _jsx(VuiTableHeaderCell, { column: column, onSort: handleSort, sortDirection: sortColumn === name ? sortDirection : "none" }) }), name));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vectara/vectara-ui",
3
- "version": "15.7.0",
3
+ "version": "15.7.2",
4
4
  "homepage": "./",
5
5
  "description": "Vectara's design system, codified as a React and Sass component library",
6
6
  "author": "Vectara",
@@ -1,9 +1,11 @@
1
1
  import { useState } from "react";
2
2
  import {
3
+ addNotification,
3
4
  VuiButtonPrimary,
4
5
  VuiButtonSecondary,
5
6
  VuiDrawer,
6
7
  VuiFlexContainer,
8
+ VuiNotifications,
7
9
  VuiSpacer,
8
10
  VuiText,
9
11
  VuiToggle
@@ -51,6 +53,20 @@ export const PrimaryDrawer = () => {
51
53
  )
52
54
  }
53
55
  >
56
+ <VuiButtonSecondary
57
+ color="primary"
58
+ onClick={() => {
59
+ addNotification({
60
+ color: "primary",
61
+ message: "Just some information, FYI"
62
+ });
63
+ }}
64
+ >
65
+ Add notification
66
+ </VuiButtonSecondary>
67
+
68
+ <VuiSpacer size="m" />
69
+
54
70
  <VuiText>
55
71
  <p>I just thought you should know that your drawer is showing.</p>
56
72
  </VuiText>
@@ -186,6 +202,8 @@ export const PrimaryDrawer = () => {
186
202
  <FormGroup />
187
203
  <VuiSpacer size="l" />
188
204
  </VuiDrawer>
205
+
206
+ <VuiNotifications />
189
207
  </>
190
208
  );
191
209
  };