@vectara/vectara-ui 17.0.1 → 17.1.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.
@@ -17,13 +17,14 @@ import { VuiPopover } from "../popover/Popover";
17
17
  import { VuiIcon } from "../icon/Icon";
18
18
  import { VuiButtonSecondary } from "../button/ButtonSecondary";
19
19
  export const VuiTableBulkActions = ({ selectedRows, actions }) => {
20
+ var _a;
20
21
  const [isOpen, setIsOpen] = useState(false);
21
22
  let content;
22
23
  if (actions.length === 1) {
23
- content = (_jsx(VuiButtonSecondary, Object.assign({ color: "neutral", size: "m", "data-testid": actions[0].testId, onClick: () => actions[0].onClick && actions[0].onClick(selectedRows) }, { children: actions[0].label })));
24
+ content = (_jsx(VuiButtonSecondary, Object.assign({ color: (_a = actions[0].color) !== null && _a !== void 0 ? _a : "neutral", size: "m", "data-testid": actions[0].testId, onClick: () => actions[0].onClick && actions[0].onClick(selectedRows) }, { children: `${actions[0].label} (${selectedRows.length})` })));
24
25
  }
25
26
  else {
26
- content = (_jsx(VuiPopover, Object.assign({ isOpen: isOpen, setIsOpen: () => setIsOpen(!isOpen), button: _jsxs(VuiButtonSecondary, Object.assign({ color: "neutral", size: "m", "data-testid": "bulkActionsMenuButton", icon: _jsx(VuiIcon, { children: _jsx(BiCaretDown, {}) }) }, { children: [selectedRows.length, " selected"] })) }, { children: _jsx(VuiOptionsList, { onSelectOption: () => {
27
+ content = (_jsx(VuiPopover, Object.assign({ isOpen: isOpen, setIsOpen: () => setIsOpen(!isOpen), button: _jsxs(VuiButtonSecondary, Object.assign({ color: "primary", size: "m", "data-testid": "bulkActionsMenuButton", icon: _jsx(VuiIcon, { children: _jsx(BiCaretDown, {}) }) }, { children: [selectedRows.length, " selected"] })) }, { children: _jsx(VuiOptionsList, { onSelectOption: () => {
27
28
  setIsOpen(false);
28
29
  }, options: actions.map((_a) => {
29
30
  var { href } = _a, action = __rest(_a, ["href"]);
@@ -1,3 +1,4 @@
1
+ import { ButtonColor } from "../button/types";
1
2
  import { Row } from "./types";
2
3
  export type Action<T> = {
3
4
  label: string;
@@ -5,6 +6,7 @@ export type Action<T> = {
5
6
  onClick?: (row: T) => void;
6
7
  href?: (row: T) => string | undefined;
7
8
  testId?: string;
9
+ color?: ButtonColor;
8
10
  };
9
11
  export type Props<T> = {
10
12
  row: any;
@@ -9,9 +9,9 @@ export const VuiTableRowActions = ({ row, actions, onToggle, testId }) => {
9
9
  const [isOpen, setIsOpen] = useState(false);
10
10
  // Filter out disabled actions.
11
11
  const actionOptions = actions.reduce((acc, action) => {
12
- const { label, isDisabled, onClick, href, testId } = action;
12
+ const { label, isDisabled, onClick, href, testId, color } = action;
13
13
  if (!(isDisabled === null || isDisabled === void 0 ? void 0 : isDisabled(row))) {
14
- acc.push({ label, onClick, href: href === null || href === void 0 ? void 0 : href(row), value: row, testId });
14
+ acc.push({ label, onClick, href: href === null || href === void 0 ? void 0 : href(row), value: row, testId, color });
15
15
  }
16
16
  return acc;
17
17
  }, []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vectara/vectara-ui",
3
- "version": "17.0.1",
3
+ "version": "17.1.0",
4
4
  "homepage": "./",
5
5
  "description": "Vectara's design system, codified as a React and Sass component library",
6
6
  "author": "Vectara",
@@ -227,17 +227,18 @@ export const Table = () => {
227
227
  },
228
228
  testId: "editAction"
229
229
  },
230
+ {
231
+ label: "Search",
232
+ href: (person: Person) => `https://www.google.com/search?q=${person.name}`,
233
+ testId: "searchAction"
234
+ },
230
235
  {
231
236
  label: "Delete",
232
237
  onClick: (person: Person) => {
233
238
  console.log("Delete", person);
234
239
  },
235
- testId: "deleteAction"
236
- },
237
- {
238
- label: "Search",
239
- href: (person: Person) => `https://www.google.com/search?q=${person.name}`,
240
- testId: "searchAction"
240
+ testId: "deleteAction",
241
+ color: "danger" as const
241
242
  }
242
243
  ];
243
244
 
@@ -293,7 +294,8 @@ export const Table = () => {
293
294
  label: "Delete",
294
295
  onClick: (people: Person[]) => {
295
296
  console.log("Delete", people);
296
- }
297
+ },
298
+ color: "danger" as const
297
299
  }
298
300
  ]
299
301
  }