@vectara/vectara-ui 17.1.0 → 17.3.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.
@@ -6,6 +6,7 @@ type Props = {
6
6
  label?: string;
7
7
  padding?: KvTablePadding;
8
8
  align?: KvTableAlign;
9
+ "data-testid"?: string;
9
10
  };
10
- export declare const VuiKvTable: ({ items, keyHeader, valueHeader, label, padding, align }: Props) => import("react/jsx-runtime").JSX.Element;
11
+ export declare const VuiKvTable: ({ items, keyHeader, valueHeader, label, padding, align, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
11
12
  export {};
@@ -1,3 +1,14 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
1
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
13
  import classNames from "classnames";
3
14
  function normalizeItems(items) {
@@ -18,9 +29,10 @@ const alignToClassMap = {
18
29
  middle: "vuiKvTable--alignMiddle",
19
30
  bottom: "vuiKvTable--alignBottom"
20
31
  };
21
- export const VuiKvTable = ({ items, keyHeader, valueHeader, label, padding = "xs", align = "middle" }) => {
32
+ export const VuiKvTable = (_a) => {
33
+ var { items, keyHeader, valueHeader, label, padding = "xs", align = "middle" } = _a, rest = __rest(_a, ["items", "keyHeader", "valueHeader", "label", "padding", "align"]);
22
34
  const hasHeader = keyHeader !== undefined || valueHeader !== undefined;
23
35
  const classes = classNames("vuiKvTable", paddingToClassMap[padding], alignToClassMap[align]);
24
36
  const normalizedItems = normalizeItems(items);
25
- return (_jsxs("table", Object.assign({ className: classes, "aria-label": label }, { children: [hasHeader && (_jsx("thead", { children: _jsxs("tr", { children: [keyHeader !== undefined && _jsx("th", { children: keyHeader }), valueHeader !== undefined && _jsx("th", { children: valueHeader })] }) })), _jsx("tbody", { children: normalizedItems.map((item, i) => (_jsxs("tr", { children: [_jsx("th", Object.assign({ scope: "row", className: "vuiKvTableCell--key" }, { children: item.key })), _jsx("td", Object.assign({ className: "vuiKvTableCell--value" }, { children: item.value }))] }, i))) })] })));
37
+ return (_jsxs("dl", Object.assign({ className: classes, "aria-label": label }, rest, { children: [hasHeader && (_jsxs("div", Object.assign({ className: "vuiKvTableRow vuiKvTableRow--header" }, { children: [_jsx("dt", Object.assign({ className: "vuiKvTableCell--key" }, { children: keyHeader })), _jsx("dd", Object.assign({ className: "vuiKvTableCell--value" }, { children: valueHeader }))] }))), normalizedItems.map((item, i) => (_jsxs("div", Object.assign({ className: "vuiKvTableRow" }, { children: [_jsx("dt", Object.assign({ className: "vuiKvTableCell--key" }, { children: item.key })), _jsx("dd", Object.assign({ className: "vuiKvTableCell--value" }, { children: item.value }))] }), i)))] })));
26
38
  };
@@ -1,85 +1,82 @@
1
1
  .vuiKvTable {
2
+ display: table;
2
3
  width: 100%;
3
4
  table-layout: auto;
4
5
  border: 1px solid var(--vui-color-border-light);
6
+ border-collapse: collapse;
7
+ }
5
8
 
6
- thead {
7
- background-color: var(--vui-color-light-shade);
8
- border-bottom: 1px solid var(--vui-color-border-light);
9
- }
10
-
11
- thead th {
12
- font-size: $fontSizeSmall;
13
- font-weight: $fontWeightBold;
14
- padding: $sizeXs $sizeS;
15
- text-align: left;
16
- }
17
-
18
- tbody tr {
19
- border-bottom: 1px solid var(--vui-color-border-light);
20
-
21
- &:last-child {
22
- border-bottom: none;
23
- }
24
- }
9
+ .vuiKvTableRow {
10
+ display: table-row;
11
+ }
25
12
 
26
- td {
27
- font-size: $fontSizeStandard;
28
- }
13
+ .vuiKvTableRow--header {
14
+ background-color: var(--vui-color-light-shade);
29
15
  }
30
16
 
31
17
  // Key cell: row header, subdued color, natural (non-wrapping) width.
32
18
  .vuiKvTableCell--key {
19
+ display: table-cell;
33
20
  color: var(--vui-color-subdued-shade);
34
21
  white-space: nowrap;
35
22
  font-weight: $fontWeightNormal;
36
23
  font-size: $fontSizeStandard;
37
24
  text-align: left;
25
+ border-bottom: 1px solid var(--vui-color-border-light);
38
26
  }
39
27
 
40
28
  // Value cell: consumes all remaining width in auto-layout table.
41
29
  .vuiKvTableCell--value {
30
+ display: table-cell;
42
31
  width: 100%;
32
+ font-size: $fontSizeStandard;
33
+ border-bottom: 1px solid var(--vui-color-border-light);
43
34
  }
44
35
 
45
- .vuiKvTable--paddingXxs {
46
- td,
47
- .vuiKvTableCell--key {
48
- padding: $sizeXxs $sizeS;
49
- }
36
+ .vuiKvTableRow:last-child .vuiKvTableCell--key,
37
+ .vuiKvTableRow:last-child .vuiKvTableCell--value {
38
+ border-bottom: none;
50
39
  }
51
40
 
52
- .vuiKvTable--paddingXs {
53
- td,
54
- .vuiKvTableCell--key {
55
- padding: $sizeXs $sizeS;
56
- }
41
+ .vuiKvTable--paddingXxs .vuiKvTableCell--key,
42
+ .vuiKvTable--paddingXxs .vuiKvTableCell--value {
43
+ padding: $sizeXxs $sizeS;
57
44
  }
58
45
 
59
- .vuiKvTable--paddingS {
60
- td,
61
- .vuiKvTableCell--key {
62
- padding: $sizeS $sizeS;
63
- }
46
+ .vuiKvTable--paddingXs .vuiKvTableCell--key,
47
+ .vuiKvTable--paddingXs .vuiKvTableCell--value {
48
+ padding: $sizeXs $sizeS;
64
49
  }
65
50
 
66
- .vuiKvTable--alignTop {
67
- td,
68
- .vuiKvTableCell--key {
69
- vertical-align: top;
70
- }
51
+ .vuiKvTable--paddingS .vuiKvTableCell--key,
52
+ .vuiKvTable--paddingS .vuiKvTableCell--value {
53
+ padding: $sizeS $sizeS;
71
54
  }
72
55
 
73
- .vuiKvTable--alignMiddle {
74
- td,
75
- .vuiKvTableCell--key {
76
- vertical-align: middle;
77
- }
56
+ .vuiKvTable--alignTop .vuiKvTableCell--key,
57
+ .vuiKvTable--alignTop .vuiKvTableCell--value {
58
+ vertical-align: top;
78
59
  }
79
60
 
80
- .vuiKvTable--alignBottom {
81
- td,
82
- .vuiKvTableCell--key {
83
- vertical-align: bottom;
84
- }
61
+ .vuiKvTable--alignMiddle .vuiKvTableCell--key,
62
+ .vuiKvTable--alignMiddle .vuiKvTableCell--value {
63
+ vertical-align: middle;
64
+ }
65
+
66
+ .vuiKvTable--alignBottom .vuiKvTableCell--key,
67
+ .vuiKvTable--alignBottom .vuiKvTableCell--value {
68
+ vertical-align: bottom;
69
+ }
70
+
71
+ // Header row overrides: match the original thead th appearance regardless of
72
+ // the table's padding variant.
73
+ .vuiKvTableRow--header .vuiKvTableCell--key,
74
+ .vuiKvTableRow--header .vuiKvTableCell--value {
75
+ color: inherit;
76
+ font-size: $fontSizeSmall;
77
+ font-weight: $fontWeightBold;
78
+ padding: $sizeXs $sizeS;
79
+ text-align: left;
80
+ vertical-align: middle;
81
+ white-space: normal;
85
82
  }
@@ -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
  }, []);
@@ -26,11 +26,11 @@ $tableResponsiveBreakpointSmall: 500px;
26
26
  width: 100%;
27
27
  table-layout: fixed;
28
28
 
29
- thead {
29
+ & > thead {
30
30
  border-bottom: 1px solid var(--vui-color-border-medium);
31
31
  }
32
32
 
33
- tbody tr {
33
+ & > tbody > tr {
34
34
  border-bottom: 1px solid var(--vui-color-border-light);
35
35
 
36
36
  &.vuiTableRow-isBeingActedUpon,
@@ -60,13 +60,13 @@ $tableResponsiveBreakpointSmall: 500px;
60
60
  }
61
61
  }
62
62
 
63
- th {
63
+ & > thead > tr > th {
64
64
  font-size: $fontSizeStandard;
65
65
  font-weight: $fontWeightBold;
66
66
  padding: $sizeXxs;
67
67
  }
68
68
 
69
- td {
69
+ & > tbody > tr > td {
70
70
  font-size: $fontSizeStandard;
71
71
  padding: $sizeXxs;
72
72
  vertical-align: middle;
@@ -193,19 +193,19 @@ $tableResponsiveBreakpointSmall: 500px;
193
193
  }
194
194
 
195
195
  .vuiTable--verticalAlignTop {
196
- tbody td {
196
+ & > tbody > tr > td {
197
197
  vertical-align: top;
198
198
  }
199
199
  }
200
200
 
201
201
  .vuiTable--verticalAlignMiddle {
202
- tbody td {
202
+ & > tbody > tr > td {
203
203
  vertical-align: middle;
204
204
  }
205
205
  }
206
206
 
207
207
  .vuiTable--verticalAlignBottom {
208
- tbody td {
208
+ & > tbody > tr > td {
209
209
  vertical-align: bottom;
210
210
  }
211
211
  }
@@ -310,5 +310,5 @@ $tableResponsiveBreakpointSmall: 500px;
310
310
  }
311
311
 
312
312
  .vuiTable .vuiTableRowExpandedContent__cell {
313
- padding: $sizeL $sizeXl;
313
+ padding: $sizeS $sizeM;
314
314
  }
@@ -3932,72 +3932,84 @@ h2.react-datepicker__current-month {
3932
3932
  }
3933
3933
 
3934
3934
  .vuiKvTable {
3935
+ display: table;
3935
3936
  width: 100%;
3936
3937
  table-layout: auto;
3937
3938
  border: 1px solid var(--vui-color-border-light);
3939
+ border-collapse: collapse;
3938
3940
  }
3939
- .vuiKvTable thead {
3940
- background-color: var(--vui-color-light-shade);
3941
- border-bottom: 1px solid var(--vui-color-border-light);
3942
- }
3943
- .vuiKvTable thead th {
3944
- font-size: 12px;
3945
- font-weight: 600;
3946
- padding: 8px 12px;
3947
- text-align: left;
3948
- }
3949
- .vuiKvTable tbody tr {
3950
- border-bottom: 1px solid var(--vui-color-border-light);
3951
- }
3952
- .vuiKvTable tbody tr:last-child {
3953
- border-bottom: none;
3941
+
3942
+ .vuiKvTableRow {
3943
+ display: table-row;
3954
3944
  }
3955
- .vuiKvTable td {
3956
- font-size: 14px;
3945
+
3946
+ .vuiKvTableRow--header {
3947
+ background-color: var(--vui-color-light-shade);
3957
3948
  }
3958
3949
 
3959
3950
  .vuiKvTableCell--key {
3951
+ display: table-cell;
3960
3952
  color: var(--vui-color-subdued-shade);
3961
3953
  white-space: nowrap;
3962
3954
  font-weight: 400;
3963
3955
  font-size: 14px;
3964
3956
  text-align: left;
3957
+ border-bottom: 1px solid var(--vui-color-border-light);
3965
3958
  }
3966
3959
 
3967
3960
  .vuiKvTableCell--value {
3961
+ display: table-cell;
3968
3962
  width: 100%;
3963
+ font-size: 14px;
3964
+ border-bottom: 1px solid var(--vui-color-border-light);
3969
3965
  }
3970
3966
 
3971
- .vuiKvTable--paddingXxs td,
3972
- .vuiKvTable--paddingXxs .vuiKvTableCell--key {
3967
+ .vuiKvTableRow:last-child .vuiKvTableCell--key,
3968
+ .vuiKvTableRow:last-child .vuiKvTableCell--value {
3969
+ border-bottom: none;
3970
+ }
3971
+
3972
+ .vuiKvTable--paddingXxs .vuiKvTableCell--key,
3973
+ .vuiKvTable--paddingXxs .vuiKvTableCell--value {
3973
3974
  padding: 4px 12px;
3974
3975
  }
3975
3976
 
3976
- .vuiKvTable--paddingXs td,
3977
- .vuiKvTable--paddingXs .vuiKvTableCell--key {
3977
+ .vuiKvTable--paddingXs .vuiKvTableCell--key,
3978
+ .vuiKvTable--paddingXs .vuiKvTableCell--value {
3978
3979
  padding: 8px 12px;
3979
3980
  }
3980
3981
 
3981
- .vuiKvTable--paddingS td,
3982
- .vuiKvTable--paddingS .vuiKvTableCell--key {
3982
+ .vuiKvTable--paddingS .vuiKvTableCell--key,
3983
+ .vuiKvTable--paddingS .vuiKvTableCell--value {
3983
3984
  padding: 12px 12px;
3984
3985
  }
3985
3986
 
3986
- .vuiKvTable--alignTop td,
3987
- .vuiKvTable--alignTop .vuiKvTableCell--key {
3987
+ .vuiKvTable--alignTop .vuiKvTableCell--key,
3988
+ .vuiKvTable--alignTop .vuiKvTableCell--value {
3988
3989
  vertical-align: top;
3989
3990
  }
3990
3991
 
3991
- .vuiKvTable--alignMiddle td,
3992
- .vuiKvTable--alignMiddle .vuiKvTableCell--key {
3992
+ .vuiKvTable--alignMiddle .vuiKvTableCell--key,
3993
+ .vuiKvTable--alignMiddle .vuiKvTableCell--value {
3993
3994
  vertical-align: middle;
3994
3995
  }
3995
3996
 
3996
- .vuiKvTable--alignBottom td,
3997
- .vuiKvTable--alignBottom .vuiKvTableCell--key {
3997
+ .vuiKvTable--alignBottom .vuiKvTableCell--key,
3998
+ .vuiKvTable--alignBottom .vuiKvTableCell--value {
3998
3999
  vertical-align: bottom;
3999
4000
  }
4000
4001
 
4002
+ .vuiKvTableRow--header .vuiKvTableCell--key,
4003
+ .vuiKvTableRow--header .vuiKvTableCell--value {
4004
+ color: inherit;
4005
+ font-size: 12px;
4006
+ font-weight: 600;
4007
+ padding: 8px 12px;
4008
+ text-align: left;
4009
+ vertical-align: middle;
4010
+ white-space: normal;
4011
+ }
4012
+
4001
4013
  .vuiLink {
4002
4014
  color: var(--vui-color-primary-shade) !important;
4003
4015
  text-decoration: none;
@@ -5457,39 +5469,39 @@ h2.react-datepicker__current-month {
5457
5469
  width: 100%;
5458
5470
  table-layout: fixed;
5459
5471
  }
5460
- .vuiTable thead {
5472
+ .vuiTable > thead {
5461
5473
  border-bottom: 1px solid var(--vui-color-border-medium);
5462
5474
  }
5463
- .vuiTable tbody tr {
5475
+ .vuiTable > tbody > tr {
5464
5476
  border-bottom: 1px solid var(--vui-color-border-light);
5465
5477
  }
5466
- .vuiTable tbody tr.vuiTableRow-isBeingActedUpon, .vuiTable tbody tr:not(.vuiTableRow--inert):hover {
5478
+ .vuiTable > tbody > tr.vuiTableRow-isBeingActedUpon, .vuiTable > tbody > tr:not(.vuiTableRow--inert):hover {
5467
5479
  background-color: rgba(var(--vui-color-light-shade-rgb), 0.25);
5468
5480
  box-shadow: rgba(60, 64, 67, 0.3) 0px 1px 2px 0px, rgba(60, 64, 67, 0.15) 0px 2px 6px 2px;
5469
5481
  border-bottom-color: transparent;
5470
5482
  }
5471
- .vuiTable tbody tr:last-child {
5483
+ .vuiTable > tbody > tr:last-child {
5472
5484
  border-bottom: 1px solid var(--vui-color-border-medium);
5473
5485
  }
5474
- .vuiTable tbody tr .vuiTableCell__label {
5486
+ .vuiTable > tbody > tr .vuiTableCell__label {
5475
5487
  display: none;
5476
5488
  max-inline-size: 100%;
5477
5489
  overflow: hidden;
5478
5490
  text-overflow: ellipsis;
5479
5491
  white-space: nowrap;
5480
5492
  }
5481
- .vuiTable tbody tr .vuiTableCell {
5493
+ .vuiTable > tbody > tr .vuiTableCell {
5482
5494
  height: 100%;
5483
5495
  display: flex;
5484
5496
  align-items: center;
5485
5497
  justify-content: flex-start;
5486
5498
  }
5487
- .vuiTable th {
5499
+ .vuiTable > thead > tr > th {
5488
5500
  font-size: 14px;
5489
5501
  font-weight: 600;
5490
5502
  padding: 4px;
5491
5503
  }
5492
- .vuiTable td {
5504
+ .vuiTable > tbody > tr > td {
5493
5505
  font-size: 14px;
5494
5506
  padding: 4px;
5495
5507
  vertical-align: middle;
@@ -5585,15 +5597,15 @@ h2.react-datepicker__current-month {
5585
5597
  grid-template-columns: 1fr;
5586
5598
  }
5587
5599
  }
5588
- .vuiTable--verticalAlignTop tbody td {
5600
+ .vuiTable--verticalAlignTop > tbody > tr > td {
5589
5601
  vertical-align: top;
5590
5602
  }
5591
5603
 
5592
- .vuiTable--verticalAlignMiddle tbody td {
5604
+ .vuiTable--verticalAlignMiddle > tbody > tr > td {
5593
5605
  vertical-align: middle;
5594
5606
  }
5595
5607
 
5596
- .vuiTable--verticalAlignBottom tbody td {
5608
+ .vuiTable--verticalAlignBottom > tbody > tr > td {
5597
5609
  vertical-align: bottom;
5598
5610
  }
5599
5611
 
@@ -5692,7 +5704,7 @@ h2.react-datepicker__current-month {
5692
5704
  }
5693
5705
 
5694
5706
  .vuiTable .vuiTableRowExpandedContent__cell {
5695
- padding: 24px 32px;
5707
+ padding: 12px 16px;
5696
5708
  }
5697
5709
 
5698
5710
  .vuiTabs--open {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vectara/vectara-ui",
3
- "version": "17.1.0",
3
+ "version": "17.3.0",
4
4
  "homepage": "./",
5
5
  "description": "Vectara's design system, codified as a React and Sass component library",
6
6
  "author": "Vectara",
@@ -3,6 +3,7 @@ import { VuiKvTable } from "../../../lib";
3
3
  export const Simple = () => {
4
4
  return (
5
5
  <VuiKvTable
6
+ data-testid="simpleKvTable"
6
7
  label="Span details"
7
8
  items={{
8
9
  span_id: "b7ad6b7169203331",
@@ -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
  }
@@ -432,7 +442,7 @@ export const Table = () => {
432
442
  isResponsive={isResponsive}
433
443
  collapsedContent={
434
444
  hasExpandableRows
435
- ? (person: Person) => (
445
+ ? () => (
436
446
  <VuiTable
437
447
  isResponsive={false}
438
448
  idField="color"