@vectara/vectara-ui 15.3.1 → 15.4.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/table/Table.js +4 -1
- package/lib/components/table/_index.scss +8 -0
- package/lib/components/table/types.d.ts +1 -0
- package/lib/styles/index.css +6 -0
- package/package.json +1 -1
- package/src/docs/pages/table/Table.tsx +15 -9
- package/src/docs/pages/table/createFakePeople.ts +20 -1
|
@@ -136,7 +136,10 @@ export const VuiTable = (_a) => {
|
|
|
136
136
|
onSelectRow(selectedRows);
|
|
137
137
|
} }) }) }))), columns.map((column) => {
|
|
138
138
|
const { name, render, className, testId } = column;
|
|
139
|
-
|
|
139
|
+
const cellClasses = classNames(className, {
|
|
140
|
+
"vuiTableCell--truncate": column.truncate
|
|
141
|
+
});
|
|
142
|
+
return (_jsx("td", Object.assign({ className: cellClasses, "data-testid": typeof testId === "function" ? testId(row) : testId }, { children: _jsx(VuiTableCell, Object.assign({ column: column }, { children: render ? render(row, rowIndex) : row[column.name] })) }), name));
|
|
140
143
|
}), (actions || hasExpandableRows) && (_jsx("td", Object.assign({ className: "vuiTableRowActions" }, { children: _jsxs(VuiFlexContainer, Object.assign({ alignItems: "center", justifyContent: "end", spacing: "xs" }, { children: [actions && (_jsx(VuiFlexItem, Object.assign({ grow: false }, { children: _jsx(VuiTableRowActions, { row: row, actions: actions, onToggle: (isSelected) => {
|
|
141
144
|
if (isSelected) {
|
|
142
145
|
setRowBeingActedUpon(row);
|
|
@@ -97,6 +97,14 @@ $tableResponsiveBreakpointSmall: 500px;
|
|
|
97
97
|
padding-right: $sizeXxl;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
// This enables truncated VuiText children to actually be truncated.
|
|
101
|
+
.vuiTableCell--truncate {
|
|
102
|
+
min-width: 0;
|
|
103
|
+
overflow: hidden;
|
|
104
|
+
white-space: nowrap;
|
|
105
|
+
text-overflow: ellipsis;
|
|
106
|
+
}
|
|
107
|
+
|
|
100
108
|
tbody tr:not(.vuiTableRowExpandedContent) {
|
|
101
109
|
position: relative;
|
|
102
110
|
column-gap: $sizeM;
|
|
@@ -10,5 +10,6 @@ export type Column<T> = {
|
|
|
10
10
|
render?: (row: T, rowIndex: number) => React.ReactNode;
|
|
11
11
|
className?: string;
|
|
12
12
|
testId?: string | ((row: T) => string);
|
|
13
|
+
truncate?: boolean;
|
|
13
14
|
};
|
|
14
15
|
export type OnSort = (column: string, direction: "asc" | "desc" | "none") => void;
|
package/lib/styles/index.css
CHANGED
|
@@ -5175,6 +5175,12 @@ h2.react-datepicker__current-month {
|
|
|
5175
5175
|
.vuiTable--responsive .vuiTableRow--hasActions {
|
|
5176
5176
|
padding-right: 40px;
|
|
5177
5177
|
}
|
|
5178
|
+
.vuiTable--responsive .vuiTableCell--truncate {
|
|
5179
|
+
min-width: 0;
|
|
5180
|
+
overflow: hidden;
|
|
5181
|
+
white-space: nowrap;
|
|
5182
|
+
text-overflow: ellipsis;
|
|
5183
|
+
}
|
|
5178
5184
|
.vuiTable--responsive tbody tr:not(.vuiTableRowExpandedContent) {
|
|
5179
5185
|
position: relative;
|
|
5180
5186
|
column-gap: 16px;
|
package/package.json
CHANGED
|
@@ -13,16 +13,9 @@ import {
|
|
|
13
13
|
VuiToggle
|
|
14
14
|
} from "../../../lib";
|
|
15
15
|
import { VuiTable } from "../../../lib/components/table/Table";
|
|
16
|
-
import { createFakePeople } from "./createFakePeople";
|
|
16
|
+
import { createFakePeople, Person } from "./createFakePeople";
|
|
17
17
|
import { BiError } from "react-icons/bi";
|
|
18
18
|
|
|
19
|
-
type Person = {
|
|
20
|
-
name: string;
|
|
21
|
-
id: string;
|
|
22
|
-
role: string[];
|
|
23
|
-
status: string;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
19
|
const ROWS_PER_PAGE = 20;
|
|
27
20
|
const people: Person[] = createFakePeople(152);
|
|
28
21
|
|
|
@@ -171,6 +164,20 @@ export const Table = () => {
|
|
|
171
164
|
}
|
|
172
165
|
}
|
|
173
166
|
},
|
|
167
|
+
{
|
|
168
|
+
name: "description",
|
|
169
|
+
header: {
|
|
170
|
+
render: () => {
|
|
171
|
+
return "Description";
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
render: (person: Person) => (
|
|
175
|
+
<VuiText truncate>
|
|
176
|
+
<p>{person.description}</p>
|
|
177
|
+
</VuiText>
|
|
178
|
+
),
|
|
179
|
+
truncate: true
|
|
180
|
+
},
|
|
174
181
|
{
|
|
175
182
|
name: "role",
|
|
176
183
|
header: {
|
|
@@ -424,7 +431,6 @@ export const Table = () => {
|
|
|
424
431
|
collapsedContent={
|
|
425
432
|
hasExpandableRows
|
|
426
433
|
? (person: Person) => (
|
|
427
|
-
|
|
428
434
|
<VuiText size="s">
|
|
429
435
|
<p>
|
|
430
436
|
<strong>Roles:</strong> {person.role.length > 0 ? person.role.join(", ") : "None assigned"}
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
export type Person = {
|
|
2
|
+
name: string;
|
|
3
|
+
id: string;
|
|
4
|
+
role: string[];
|
|
5
|
+
status: string;
|
|
6
|
+
description: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
1
9
|
const firstNames = [
|
|
2
10
|
"John",
|
|
3
11
|
"Jane",
|
|
@@ -56,6 +64,14 @@ const roles = [
|
|
|
56
64
|
"Marketing"
|
|
57
65
|
] as const;
|
|
58
66
|
|
|
67
|
+
const descriptions = [
|
|
68
|
+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
|
|
69
|
+
"Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
|
|
70
|
+
"Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",
|
|
71
|
+
"Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.",
|
|
72
|
+
"Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
|
|
73
|
+
] as const;
|
|
74
|
+
|
|
59
75
|
const statuses = ["Active", "Inactive", "Pending"] as const;
|
|
60
76
|
|
|
61
77
|
const getIndex = (max: number) => Math.floor(Math.random() * max);
|
|
@@ -82,6 +98,8 @@ const getRoles = () => {
|
|
|
82
98
|
|
|
83
99
|
const getStatus = () => statuses[getIndex(statuses.length)];
|
|
84
100
|
|
|
101
|
+
const getDescription = () => descriptions[getIndex(descriptions.length)];
|
|
102
|
+
|
|
85
103
|
export const createFakePeople = (count: number) => {
|
|
86
104
|
const fakePeople = [];
|
|
87
105
|
|
|
@@ -90,7 +108,8 @@ export const createFakePeople = (count: number) => {
|
|
|
90
108
|
name: getName(),
|
|
91
109
|
id: getId(),
|
|
92
110
|
role: getRoles(),
|
|
93
|
-
status: getStatus()
|
|
111
|
+
status: getStatus(),
|
|
112
|
+
description: getDescription()
|
|
94
113
|
});
|
|
95
114
|
}
|
|
96
115
|
|