@vectara/vectara-ui 17.1.0 → 17.2.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.
|
@@ -21,7 +21,7 @@ export const VuiTableBulkActions = ({ selectedRows, actions }) => {
|
|
|
21
21
|
const [isOpen, setIsOpen] = useState(false);
|
|
22
22
|
let content;
|
|
23
23
|
if (actions.length === 1) {
|
|
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
|
+
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), icon: actions[0].icon }, { children: `${actions[0].label} (${selectedRows.length})` })));
|
|
25
25
|
}
|
|
26
26
|
else {
|
|
27
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: () => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReactElement } from "react";
|
|
1
2
|
import { ButtonColor } from "../button/types";
|
|
2
3
|
import { Row } from "./types";
|
|
3
4
|
export type Action<T> = {
|
|
@@ -7,6 +8,7 @@ export type Action<T> = {
|
|
|
7
8
|
href?: (row: T) => string | undefined;
|
|
8
9
|
testId?: string;
|
|
9
10
|
color?: ButtonColor;
|
|
11
|
+
icon?: ReactElement | null;
|
|
10
12
|
};
|
|
11
13
|
export type Props<T> = {
|
|
12
14
|
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, color } = action;
|
|
12
|
+
const { label, isDisabled, onClick, href, testId, color, icon } = 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, color });
|
|
14
|
+
acc.push({ label, onClick, href: href === null || href === void 0 ? void 0 : href(row), value: row, testId, color, icon });
|
|
15
15
|
}
|
|
16
16
|
return acc;
|
|
17
17
|
}, []);
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from "../../../lib";
|
|
15
15
|
import { VuiTable } from "../../../lib/components/table/Table";
|
|
16
16
|
import { createFakePeople, Person } from "./createFakePeople";
|
|
17
|
-
import { BiError } from "react-icons/bi";
|
|
17
|
+
import { BiError, BiTrash } from "react-icons/bi";
|
|
18
18
|
|
|
19
19
|
const ROWS_PER_PAGE = 20;
|
|
20
20
|
const people: Person[] = createFakePeople(152);
|
|
@@ -238,7 +238,12 @@ export const Table = () => {
|
|
|
238
238
|
console.log("Delete", person);
|
|
239
239
|
},
|
|
240
240
|
testId: "deleteAction",
|
|
241
|
-
color: "danger" as const
|
|
241
|
+
color: "danger" as const,
|
|
242
|
+
icon: (
|
|
243
|
+
<VuiIcon color="danger">
|
|
244
|
+
<BiTrash />
|
|
245
|
+
</VuiIcon>
|
|
246
|
+
)
|
|
242
247
|
}
|
|
243
248
|
];
|
|
244
249
|
|
|
@@ -295,7 +300,12 @@ export const Table = () => {
|
|
|
295
300
|
onClick: (people: Person[]) => {
|
|
296
301
|
console.log("Delete", people);
|
|
297
302
|
},
|
|
298
|
-
color: "danger" as const
|
|
303
|
+
color: "danger" as const,
|
|
304
|
+
icon: (
|
|
305
|
+
<VuiIcon color="danger">
|
|
306
|
+
<BiTrash />
|
|
307
|
+
</VuiIcon>
|
|
308
|
+
)
|
|
299
309
|
}
|
|
300
310
|
]
|
|
301
311
|
}
|