@snack-uikit/table 0.31.1 → 0.32.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/CHANGELOG.md +11 -0
- package/README.md +2 -0
- package/dist/cjs/components/Table/Table.d.ts +1 -1
- package/dist/cjs/components/Table/Table.js +101 -101
- package/dist/cjs/components/Table/styles.module.css +4 -3
- package/dist/cjs/components/types.d.ts +1 -0
- package/dist/cjs/helperComponents/Cells/BodyCell/BodyCell.d.ts +2 -1
- package/dist/cjs/helperComponents/Cells/BodyCell/BodyCell.js +4 -2
- package/dist/cjs/helperComponents/Cells/BodyCell/styles.module.css +8 -2
- package/dist/cjs/helperComponents/Cells/CopyCell/CopyCell.js +1 -1
- package/dist/cjs/helperComponents/Cells/HeaderCell/HeaderCell.d.ts +2 -1
- package/dist/cjs/helperComponents/Cells/HeaderCell/HeaderCell.js +4 -2
- package/dist/cjs/helperComponents/Cells/HeaderCell/styles.module.css +10 -1
- package/dist/cjs/helperComponents/Cells/StatusCell/styles.module.css +3 -3
- package/dist/cjs/helperComponents/Cells/TreeCell/TreeCell.d.ts +1 -1
- package/dist/cjs/helperComponents/Cells/TreeCell/TreeCell.js +28 -30
- package/dist/cjs/helperComponents/Cells/TreeCell/TreeLine/styles.module.css +2 -2
- package/dist/cjs/helperComponents/Cells/TreeCell/styles.module.css +16 -34
- package/dist/cjs/helperComponents/Rows/BodyRow.d.ts +3 -2
- package/dist/cjs/helperComponents/Rows/BodyRow.js +9 -4
- package/dist/cjs/helperComponents/Rows/HeaderRow.d.ts +2 -1
- package/dist/cjs/helperComponents/Rows/HeaderRow.js +11 -4
- package/dist/cjs/helperComponents/Rows/Row.d.ts +3 -3
- package/dist/cjs/helperComponents/Rows/Row.js +4 -2
- package/dist/cjs/helperComponents/Rows/styles.module.css +14 -6
- package/dist/cjs/helperComponents/TableEmptyState/styles.module.css +1 -1
- package/dist/esm/components/Table/Table.d.ts +1 -1
- package/dist/esm/components/Table/Table.js +15 -17
- package/dist/esm/components/Table/styles.module.css +4 -3
- package/dist/esm/components/types.d.ts +1 -0
- package/dist/esm/helperComponents/Cells/BodyCell/BodyCell.d.ts +2 -1
- package/dist/esm/helperComponents/Cells/BodyCell/BodyCell.js +2 -2
- package/dist/esm/helperComponents/Cells/BodyCell/styles.module.css +8 -2
- package/dist/esm/helperComponents/Cells/CopyCell/CopyCell.js +1 -1
- package/dist/esm/helperComponents/Cells/HeaderCell/HeaderCell.d.ts +2 -1
- package/dist/esm/helperComponents/Cells/HeaderCell/HeaderCell.js +2 -2
- package/dist/esm/helperComponents/Cells/HeaderCell/styles.module.css +10 -1
- package/dist/esm/helperComponents/Cells/StatusCell/styles.module.css +3 -3
- package/dist/esm/helperComponents/Cells/TreeCell/TreeCell.d.ts +1 -1
- package/dist/esm/helperComponents/Cells/TreeCell/TreeCell.js +26 -28
- package/dist/esm/helperComponents/Cells/TreeCell/TreeLine/TreeLine.js +2 -2
- package/dist/esm/helperComponents/Cells/TreeCell/TreeLine/styles.module.css +2 -2
- package/dist/esm/helperComponents/Cells/TreeCell/styles.module.css +16 -34
- package/dist/esm/helperComponents/Rows/BodyRow.d.ts +3 -2
- package/dist/esm/helperComponents/Rows/BodyRow.js +2 -2
- package/dist/esm/helperComponents/Rows/HeaderRow.d.ts +2 -1
- package/dist/esm/helperComponents/Rows/HeaderRow.js +2 -2
- package/dist/esm/helperComponents/Rows/Row.d.ts +3 -3
- package/dist/esm/helperComponents/Rows/Row.js +2 -2
- package/dist/esm/helperComponents/Rows/styles.module.css +14 -6
- package/dist/esm/helperComponents/TableEmptyState/styles.module.css +1 -1
- package/package.json +2 -2
- package/src/components/Table/Table.tsx +110 -117
- package/src/components/Table/styles.module.scss +4 -8
- package/src/components/types.ts +3 -0
- package/src/helperComponents/Cells/BodyCell/BodyCell.tsx +3 -1
- package/src/helperComponents/Cells/BodyCell/styles.module.scss +6 -1
- package/src/helperComponents/Cells/CopyCell/CopyCell.tsx +1 -1
- package/src/helperComponents/Cells/CopyCell/styles.module.scss +1 -1
- package/src/helperComponents/Cells/HeaderCell/HeaderCell.tsx +8 -2
- package/src/helperComponents/Cells/HeaderCell/styles.module.scss +9 -0
- package/src/helperComponents/Cells/StatusCell/styles.module.scss +9 -7
- package/src/helperComponents/Cells/TreeCell/TreeCell.tsx +51 -42
- package/src/helperComponents/Cells/TreeCell/TreeLine/TreeLine.tsx +2 -2
- package/src/helperComponents/Cells/TreeCell/TreeLine/styles.module.scss +8 -8
- package/src/helperComponents/Cells/TreeCell/styles.module.scss +36 -55
- package/src/helperComponents/Rows/BodyRow.tsx +7 -6
- package/src/helperComponents/Rows/HeaderRow.tsx +15 -6
- package/src/helperComponents/Rows/Row.tsx +10 -3
- package/src/helperComponents/Rows/styles.module.scss +30 -19
- package/src/helperComponents/TableEmptyState/styles.module.scss +1 -1
|
@@ -14,20 +14,13 @@
|
|
|
14
14
|
box-sizing: border-box;
|
|
15
15
|
width: 100%;
|
|
16
16
|
height: auto;
|
|
17
|
-
max-height: calc(
|
|
18
|
-
(var(--page-size, 10) * #{table.$size-table-line-height}) + #{table.$size-table-line-height} + #{table.$border-width-table} * 2
|
|
19
|
-
);
|
|
20
17
|
|
|
21
18
|
background-color: table.$sys-neutral-background1-level;
|
|
22
19
|
border-color: table.$sys-neutral-background1-level;
|
|
23
20
|
border-style: solid;
|
|
24
|
-
}
|
|
25
21
|
|
|
26
|
-
.scrollWrapper {
|
|
27
22
|
&[data-outline] {
|
|
28
|
-
|
|
29
|
-
border-color: table.$sys-neutral-decor-default;
|
|
30
|
-
}
|
|
23
|
+
border-color: table.$sys-neutral-decor-default;
|
|
31
24
|
}
|
|
32
25
|
}
|
|
33
26
|
|
|
@@ -59,7 +52,10 @@
|
|
|
59
52
|
}
|
|
60
53
|
|
|
61
54
|
.wrapper {
|
|
55
|
+
display: grid;
|
|
56
|
+
grid-template-rows: max-content minmax(auto, 100%) max-content;
|
|
62
57
|
max-width: 100%;
|
|
58
|
+
max-height: 100%;
|
|
63
59
|
}
|
|
64
60
|
|
|
65
61
|
.scrollStub {
|
package/src/components/types.ts
CHANGED
|
@@ -80,6 +80,9 @@ type BaseTableProps<TData extends object, TFilters extends FiltersState = Record
|
|
|
80
80
|
/** Включить нечеткий поиск */
|
|
81
81
|
enableFuzzySearch?: boolean;
|
|
82
82
|
|
|
83
|
+
/* Включает автоматическую высоту строк */
|
|
84
|
+
rowAutoHeight?: boolean;
|
|
85
|
+
|
|
83
86
|
/** Максимальное кол-во строк на страницу @default 10 */
|
|
84
87
|
pageSize?: number;
|
|
85
88
|
|
|
@@ -9,9 +9,10 @@ import styles from './styles.module.scss';
|
|
|
9
9
|
|
|
10
10
|
type BodyCellProps<TData> = Omit<CellProps, 'style' | 'children'> & {
|
|
11
11
|
cell: TableCell<TData, unknown>;
|
|
12
|
+
rowAutoHeight?: boolean;
|
|
12
13
|
};
|
|
13
14
|
|
|
14
|
-
export function BodyCell<TData>({ cell, className, ...props }: BodyCellProps<TData>) {
|
|
15
|
+
export function BodyCell<TData>({ cell, className, rowAutoHeight, ...props }: BodyCellProps<TData>) {
|
|
15
16
|
const columnDef: ColumnDefinition<TData> = cell.column.columnDef;
|
|
16
17
|
|
|
17
18
|
const style = useCellSizes(cell);
|
|
@@ -21,6 +22,7 @@ export function BodyCell<TData>({ cell, className, ...props }: BodyCellProps<TDa
|
|
|
21
22
|
{...props}
|
|
22
23
|
style={style}
|
|
23
24
|
className={cn(styles.tableBodyCell, className, columnDef.cellClassName)}
|
|
25
|
+
data-row-auto-height={rowAutoHeight || undefined}
|
|
24
26
|
data-align={columnDef.align}
|
|
25
27
|
data-no-padding={columnDef.noBodyCellPadding || undefined}
|
|
26
28
|
data-column-id={cell.column.id}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@use '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-table';
|
|
1
|
+
@use '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-table' as styles-tokens-table;
|
|
2
2
|
|
|
3
3
|
.tableBodyCell {
|
|
4
4
|
@include styles-tokens-table.composite-var(styles-tokens-table.$table-cells);
|
|
@@ -12,4 +12,9 @@
|
|
|
12
12
|
&[data-no-padding] {
|
|
13
13
|
padding: 0;
|
|
14
14
|
}
|
|
15
|
+
|
|
16
|
+
&:not([data-row-auto-height]) {
|
|
17
|
+
padding-top: 0;
|
|
18
|
+
padding-bottom: 0;
|
|
19
|
+
}
|
|
15
20
|
}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
&:hover {
|
|
19
|
-
margin-right: calc(0px - calc(styles-theme-variables.$dimension-4m + styles-theme-variables.$dimension-050m));
|
|
19
|
+
margin-right: calc(0px - calc(#{styles-theme-variables.$dimension-4m} + #{styles-theme-variables.$dimension-050m}));
|
|
20
20
|
|
|
21
21
|
.copyButton {
|
|
22
22
|
display: inline-flex;
|
|
@@ -15,9 +15,10 @@ import styles from './styles.module.scss';
|
|
|
15
15
|
type HeaderCellProps<TData> = Omit<CellProps, 'align' | 'children' | 'onClick' | 'style'> & {
|
|
16
16
|
header: Header<TData, unknown>;
|
|
17
17
|
pinPosition?: ColumnPinPosition;
|
|
18
|
+
rowAutoHeight?: boolean;
|
|
18
19
|
};
|
|
19
20
|
|
|
20
|
-
export function HeaderCell<TData>({ header, pinPosition, className }: HeaderCellProps<TData>) {
|
|
21
|
+
export function HeaderCell<TData>({ header, pinPosition, className, rowAutoHeight }: HeaderCellProps<TData>) {
|
|
21
22
|
const cellRef = useRef<HTMLDivElement>(null);
|
|
22
23
|
const isSortable = header.column.getCanSort();
|
|
23
24
|
const isResizable = header.column.getCanResize();
|
|
@@ -51,6 +52,7 @@ export function HeaderCell<TData>({ header, pinPosition, className }: HeaderCell
|
|
|
51
52
|
data-header-id={header.id}
|
|
52
53
|
data-resizing={isResizing || undefined}
|
|
53
54
|
data-pin-position={pinPosition || undefined}
|
|
55
|
+
data-row-auto-height={rowAutoHeight || undefined}
|
|
54
56
|
role='columnheader'
|
|
55
57
|
className={cn(styles.tableHeaderCell, className, columnDef.headerClassName)}
|
|
56
58
|
ref={cellRef}
|
|
@@ -58,7 +60,11 @@ export function HeaderCell<TData>({ header, pinPosition, className }: HeaderCell
|
|
|
58
60
|
<div className={styles.tableHeaderCellMain}>
|
|
59
61
|
{columnDef.header && (
|
|
60
62
|
<div className={styles.tableHeaderCellName}>
|
|
61
|
-
|
|
63
|
+
{rowAutoHeight ? (
|
|
64
|
+
flexRender(columnDef.header, header.getContext())
|
|
65
|
+
) : (
|
|
66
|
+
<TruncateString text={flexRender(columnDef.header, header.getContext()) as string} />
|
|
67
|
+
)}
|
|
62
68
|
</div>
|
|
63
69
|
)}
|
|
64
70
|
|
|
@@ -10,7 +10,7 @@ $appearances: 'primary', 'neutral', 'red', 'orange', 'yellow', 'green', 'blue',
|
|
|
10
10
|
box-sizing: border-box;
|
|
11
11
|
width: 100%;
|
|
12
12
|
height: 100%;
|
|
13
|
-
padding-right: styles-tokens-table.$space-table-cell-padding;
|
|
13
|
+
padding-right: styles-tokens-table.$space-table-cell-padding-horizontal;
|
|
14
14
|
|
|
15
15
|
&[data-no-label] {
|
|
16
16
|
padding-right: 0;
|
|
@@ -35,6 +35,7 @@ $appearances: 'primary', 'neutral', 'red', 'orange', 'yellow', 'green', 'blue',
|
|
|
35
35
|
|
|
36
36
|
box-sizing: border-box;
|
|
37
37
|
width: styles-tokens-table.$size-table-cell-status-indicator-horizontal;
|
|
38
|
+
height: calc(100% + #{styles-tokens-table.$border-width-table} * 2);
|
|
38
39
|
|
|
39
40
|
background-color: inherit;
|
|
40
41
|
|
|
@@ -50,6 +51,7 @@ $appearances: 'primary', 'neutral', 'red', 'orange', 'yellow', 'green', 'blue',
|
|
|
50
51
|
|
|
51
52
|
box-sizing: border-box;
|
|
52
53
|
width: 100%;
|
|
54
|
+
height: 100%;
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
@each $appearance in $appearances {
|
|
@@ -65,15 +67,15 @@ $appearances: 'primary', 'neutral', 'red', 'orange', 'yellow', 'green', 'blue',
|
|
|
65
67
|
|
|
66
68
|
&::after {
|
|
67
69
|
content: '';
|
|
68
|
-
|
|
70
|
+
|
|
69
71
|
position: absolute;
|
|
70
72
|
left:0;
|
|
71
|
-
|
|
73
|
+
|
|
72
74
|
width: 100%;
|
|
73
75
|
height: auto;
|
|
74
|
-
|
|
76
|
+
|
|
75
77
|
background-color: styles-tokens-table.$sys-neutral-decor-default;
|
|
76
|
-
|
|
78
|
+
|
|
77
79
|
animation: loading ease-in-out 0.8s infinite alternate;
|
|
78
80
|
}
|
|
79
81
|
}
|
|
@@ -82,14 +84,14 @@ $appearances: 'primary', 'neutral', 'red', 'orange', 'yellow', 'green', 'blue',
|
|
|
82
84
|
@keyframes loading {
|
|
83
85
|
0% {
|
|
84
86
|
top: 0;
|
|
85
|
-
bottom: calc(100% - styles-tokens-table.$dimension-050m);
|
|
87
|
+
bottom: calc(100% - #{styles-tokens-table.$dimension-050m});
|
|
86
88
|
}
|
|
87
89
|
50% {
|
|
88
90
|
top: 0;
|
|
89
91
|
bottom: 0;
|
|
90
92
|
}
|
|
91
93
|
100% {
|
|
92
|
-
top: calc(100% - styles-tokens-table.$dimension-050m);
|
|
94
|
+
top: calc(100% - #{styles-tokens-table.$dimension-050m});
|
|
93
95
|
bottom: 0;
|
|
94
96
|
}
|
|
95
97
|
}
|
|
@@ -33,7 +33,7 @@ type TreeColumnDef = BaseTreeColumnDef & {
|
|
|
33
33
|
|
|
34
34
|
type TreeColumnDefWithDescription<TData> = BaseTreeColumnDef & {
|
|
35
35
|
/** Заголовок колонки */
|
|
36
|
-
renderDescription
|
|
36
|
+
renderDescription?(cellValue: string, row: TData): string;
|
|
37
37
|
/** Рендер функция заголовка колонки */
|
|
38
38
|
header?: ColumnDefinition<TData>['header'];
|
|
39
39
|
};
|
|
@@ -62,16 +62,17 @@ export function getTreeColumnDef<TData>({
|
|
|
62
62
|
skipOnExport: false,
|
|
63
63
|
},
|
|
64
64
|
enableSorting: false,
|
|
65
|
-
header
|
|
66
|
-
cell: function
|
|
65
|
+
header,
|
|
66
|
+
cell: function TreeCell<TData>({ row, cell }: CellContext<TData, unknown>) {
|
|
67
67
|
const isExpanded = row.getIsExpanded();
|
|
68
68
|
const isExpandable = row.getCanExpand();
|
|
69
69
|
const isMultiSelect = row.getCanMultiSelect();
|
|
70
70
|
const parent = row.getParentRow();
|
|
71
71
|
const isRowsSelectionEnabled = row.getCanSelect();
|
|
72
|
-
const
|
|
72
|
+
const isAllSubRowsSelected = row.getIsAllSubRowsSelected();
|
|
73
73
|
const isSomeSubRowSelected = row.getIsSomeSelected();
|
|
74
74
|
const isRowSelected = row.getIsSelected();
|
|
75
|
+
const isLastChildRow = parent?.subRows.at(-1)?.id === row.id;
|
|
75
76
|
const depth = row.depth;
|
|
76
77
|
const { ref } = useCellResize(TREE_CELL_ID, cell);
|
|
77
78
|
|
|
@@ -89,56 +90,59 @@ export function getTreeColumnDef<TData>({
|
|
|
89
90
|
});
|
|
90
91
|
}, [row, depth]);
|
|
91
92
|
|
|
92
|
-
const lines =
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
93
|
+
const lines = useMemo(
|
|
94
|
+
() =>
|
|
95
|
+
Array.from({ length: depth }, (_, index) => (
|
|
96
|
+
<TreeLine
|
|
97
|
+
key={index}
|
|
98
|
+
visible={linesVisibilityByIndex.at(index)}
|
|
99
|
+
className={index !== 0 ? styles.line : styles.firstLine}
|
|
100
|
+
halfHeight={index === depth - 1 && isLastChildRow}
|
|
101
|
+
/>
|
|
102
|
+
)),
|
|
103
|
+
[depth, linesVisibilityByIndex, isLastChildRow],
|
|
104
|
+
);
|
|
101
105
|
|
|
102
106
|
useEffect(() => {
|
|
103
|
-
if (!isMultiSelect || !isExpandable) {
|
|
107
|
+
if (!isMultiSelect || !isExpandable || !isRowsSelectionEnabled) {
|
|
104
108
|
return;
|
|
105
109
|
}
|
|
106
|
-
|
|
110
|
+
|
|
111
|
+
if (isAllSubRowsSelected && !isRowSelected) {
|
|
107
112
|
row.toggleSelected(true, { selectChildren: false });
|
|
108
113
|
return;
|
|
109
114
|
}
|
|
110
|
-
|
|
115
|
+
|
|
116
|
+
if (isRowSelected && !isAllSubRowsSelected && isSomeSubRowSelected) {
|
|
111
117
|
row.toggleSelected(false, { selectChildren: false });
|
|
112
118
|
return;
|
|
113
119
|
}
|
|
114
|
-
}, [
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
const toggleClickHandler = useCallback(
|
|
129
|
-
(event: React.MouseEvent) => {
|
|
120
|
+
}, [
|
|
121
|
+
isAllSubRowsSelected,
|
|
122
|
+
isSomeSubRowSelected,
|
|
123
|
+
row,
|
|
124
|
+
isRowSelected,
|
|
125
|
+
isMultiSelect,
|
|
126
|
+
isExpandable,
|
|
127
|
+
isRowsSelectionEnabled,
|
|
128
|
+
]);
|
|
129
|
+
|
|
130
|
+
const toggleClickHandler: MouseEventHandler<HTMLElement> = useCallback(
|
|
131
|
+
event => {
|
|
130
132
|
event.stopPropagation();
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
row.toggleSelected(
|
|
133
|
+
|
|
134
|
+
if (isMultiSelect) {
|
|
135
|
+
const shouldToggleOn = !isAllSubRowsSelected && !isRowSelected;
|
|
136
|
+
const selectChildren = isAllSubRowsSelected || isSomeSubRowSelected || shouldToggleOn;
|
|
137
|
+
|
|
138
|
+
row.toggleSelected(shouldToggleOn, { selectChildren });
|
|
139
|
+
|
|
137
140
|
return;
|
|
138
141
|
}
|
|
139
|
-
|
|
142
|
+
|
|
143
|
+
row.toggleSelected(!isRowSelected, { selectChildren: false });
|
|
140
144
|
},
|
|
141
|
-
[
|
|
145
|
+
[isMultiSelect, row, isAllSubRowsSelected, isSomeSubRowSelected, isRowSelected],
|
|
142
146
|
);
|
|
143
147
|
|
|
144
148
|
const chevronClickHandler: MouseEventHandler<HTMLElement> = useCallback(
|
|
@@ -176,7 +180,12 @@ export function getTreeColumnDef<TData>({
|
|
|
176
180
|
data-expanded={isExpanded || undefined}
|
|
177
181
|
/>
|
|
178
182
|
)}
|
|
179
|
-
<div
|
|
183
|
+
<div
|
|
184
|
+
className={styles.treeNodeContent}
|
|
185
|
+
data-disabled={!isRowsSelectionEnabled || undefined}
|
|
186
|
+
data-selected={isRowSelected || undefined}
|
|
187
|
+
data-multiselect={isMultiSelect || undefined}
|
|
188
|
+
>
|
|
180
189
|
{showToggle && (
|
|
181
190
|
<div tabIndex={-1} className={styles.treeCheckboxWrap}>
|
|
182
191
|
{isMultiSelect ? (
|
|
@@ -185,7 +194,7 @@ export function getTreeColumnDef<TData>({
|
|
|
185
194
|
disabled={!isRowsSelectionEnabled}
|
|
186
195
|
checked={isRowSelected}
|
|
187
196
|
data-test-id={TEST_IDS.tree.checkbox}
|
|
188
|
-
indeterminate={isSomeSubRowSelected && !
|
|
197
|
+
indeterminate={isSomeSubRowSelected && !isAllSubRowsSelected}
|
|
189
198
|
/>
|
|
190
199
|
) : (
|
|
191
200
|
<Radio
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import cn from 'classnames';
|
|
2
2
|
|
|
3
3
|
import styles from './styles.module.scss';
|
|
4
4
|
|
|
@@ -12,7 +12,7 @@ export type TreeLineProps = {
|
|
|
12
12
|
export function TreeLine({ halfHeight, horizontal, visible, className }: TreeLineProps) {
|
|
13
13
|
return (
|
|
14
14
|
<div
|
|
15
|
-
className={
|
|
15
|
+
className={cn(styles.treeLine, className)}
|
|
16
16
|
data-horizontal={horizontal || undefined}
|
|
17
17
|
data-half-height={halfHeight || undefined}
|
|
18
18
|
data-visible={visible || undefined}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
@use '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-table';
|
|
1
|
+
@use '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-table' as table;
|
|
2
2
|
|
|
3
3
|
.treeLine {
|
|
4
4
|
width: 1px;
|
|
5
|
-
height:
|
|
5
|
+
height: 100%;
|
|
6
6
|
opacity: 0;
|
|
7
|
-
&[data-visible] {
|
|
8
|
-
opacity: 1;
|
|
9
|
-
background-color: styles-tokens-table.$sys-neutral-decor-default;
|
|
10
7
|
|
|
8
|
+
&[data-visible] {
|
|
9
|
+
opacity: 1;
|
|
10
|
+
background-color: table.$sys-neutral-decor-default;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
&[data-half-height] {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
align-self: start;
|
|
15
|
+
height: 50%;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
&[data-horizontal] {
|
|
19
|
-
width: calc(
|
|
19
|
+
width: calc(#{table.$size-markdown-table-cell-height} / 2);
|
|
20
20
|
height: 1px
|
|
21
21
|
}
|
|
22
22
|
}
|
|
@@ -2,23 +2,27 @@
|
|
|
2
2
|
@use '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-table' as table;
|
|
3
3
|
@use '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-tree' as tree;
|
|
4
4
|
|
|
5
|
+
.treeCellContainer {
|
|
6
|
+
position: relative;
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
height: 100%;
|
|
9
|
+
|
|
10
|
+
@include table.composite-var(table.$sans-body-m);
|
|
11
|
+
}
|
|
12
|
+
|
|
5
13
|
.treeCell {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: start;
|
|
9
17
|
|
|
10
|
-
|
|
11
|
-
|
|
18
|
+
width: fit-content;
|
|
19
|
+
height: 100%;
|
|
12
20
|
}
|
|
13
21
|
|
|
14
22
|
.cellUserToggleIcon {
|
|
15
|
-
cursor: pointer;
|
|
16
23
|
display: flex;
|
|
17
24
|
align-items: center;
|
|
18
25
|
box-sizing: border-box;
|
|
19
|
-
svg {
|
|
20
|
-
color: tree.$sys-neutral-text-support;
|
|
21
|
-
}
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
.treeNodeContent {
|
|
@@ -26,12 +30,13 @@
|
|
|
26
30
|
|
|
27
31
|
cursor: pointer;
|
|
28
32
|
|
|
29
|
-
|
|
30
33
|
display: flex;
|
|
31
34
|
align-items: center;
|
|
32
35
|
|
|
33
36
|
box-sizing: border-box;
|
|
34
|
-
height:
|
|
37
|
+
height: 100%;
|
|
38
|
+
|
|
39
|
+
color: tree.$sys-neutral-text-support;
|
|
35
40
|
|
|
36
41
|
&:focus-visible {
|
|
37
42
|
@include element.outline-inside-var(element.$container-focused-s);
|
|
@@ -43,64 +48,40 @@
|
|
|
43
48
|
cursor: default;
|
|
44
49
|
}
|
|
45
50
|
|
|
46
|
-
&[
|
|
51
|
+
&[data-disabled] {
|
|
47
52
|
cursor: not-allowed;
|
|
48
|
-
|
|
49
|
-
&::before {
|
|
50
|
-
display: none;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.treeNodeTitle, .treeNodeIcon {
|
|
54
|
-
color: tree.$sys-neutral-text-disabled;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
&[aria-selected='true']:not([data-multiselect]) {
|
|
59
|
-
opacity: tree.$opacity-a008;
|
|
60
|
-
background-color: tree.$sys-primary-accent-default;
|
|
61
|
-
|
|
62
|
-
&:hover {
|
|
63
|
-
opacity: tree.$opacity-a016;
|
|
64
|
-
}
|
|
53
|
+
color: tree.$sys-neutral-text-disabled;
|
|
65
54
|
}
|
|
66
55
|
}
|
|
67
56
|
|
|
68
57
|
.userContent {
|
|
69
|
-
cursor: pointer;
|
|
70
58
|
display: flex;
|
|
71
59
|
align-items: center;
|
|
72
|
-
svg {
|
|
73
|
-
color: tree.$sys-neutral-text-support;
|
|
74
|
-
}
|
|
75
60
|
}
|
|
76
|
-
.treeCellContainer {
|
|
77
|
-
position: relative;
|
|
78
|
-
overflow: hidden;
|
|
79
61
|
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
margin-left: calc(#{table.$dimension-4m} + #{table.$dimension-025m});
|
|
84
|
-
}
|
|
85
|
-
.firstLine {
|
|
86
|
-
margin-left: table.$dimension-2m
|
|
87
|
-
}
|
|
88
|
-
.cellExpandButton {
|
|
89
|
-
box-sizing: border-box;
|
|
62
|
+
.line {
|
|
63
|
+
margin-left: calc(#{table.$dimension-4m} + #{table.$dimension-025m});
|
|
64
|
+
}
|
|
90
65
|
|
|
66
|
+
.firstLine {
|
|
67
|
+
margin-left: table.$dimension-2m
|
|
68
|
+
}
|
|
91
69
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
70
|
+
.cellExpandButton {
|
|
71
|
+
box-sizing: border-box;
|
|
72
|
+
|
|
73
|
+
svg {
|
|
74
|
+
width: element.$icon-s !important; /* stylelint-disable-line declaration-no-important */
|
|
75
|
+
height: element.$icon-s !important; /* stylelint-disable-line declaration-no-important */
|
|
76
|
+
transition: transform 0.2s ease;
|
|
77
|
+
}
|
|
97
78
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
79
|
+
&[data-expanded] {
|
|
80
|
+
svg {
|
|
81
|
+
transform: rotate(90deg);
|
|
102
82
|
}
|
|
103
83
|
}
|
|
84
|
+
}
|
|
104
85
|
|
|
105
86
|
.treeCheckboxWrap {
|
|
106
87
|
@include tree.composite-var(tree.$tree-item-toggle-wrap);
|
|
@@ -6,7 +6,7 @@ import { BodyCell } from '../Cells';
|
|
|
6
6
|
import { RowContext } from '../contexts';
|
|
7
7
|
import { useRowCells } from '../hooks';
|
|
8
8
|
import { PinnedCells } from './PinnedCells';
|
|
9
|
-
import { Row } from './Row';
|
|
9
|
+
import { Row, RowProps } from './Row';
|
|
10
10
|
import styles from './styles.module.scss';
|
|
11
11
|
|
|
12
12
|
export type RowInfo<TData> = {
|
|
@@ -18,12 +18,12 @@ export type RowInfo<TData> = {
|
|
|
18
18
|
|
|
19
19
|
export type RowClickHandler<TData> = (e: MouseEvent<HTMLDivElement>, row: RowInfo<TData>) => void;
|
|
20
20
|
|
|
21
|
-
export type BodyRowProps<TData> = {
|
|
21
|
+
export type BodyRowProps<TData> = Pick<RowProps, 'rowAutoHeight'> & {
|
|
22
22
|
row: TableRow<TData>;
|
|
23
23
|
onRowClick?: RowClickHandler<TData>;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
export function BodyRow<TData>({ row, onRowClick }: BodyRowProps<TData>) {
|
|
26
|
+
export function BodyRow<TData>({ row, onRowClick, rowAutoHeight }: BodyRowProps<TData>) {
|
|
27
27
|
const { pinnedLeft, pinnedRight, unpinned } = useRowCells(row);
|
|
28
28
|
|
|
29
29
|
const [dropListOpened, setDropListOpen] = useState(false);
|
|
@@ -56,23 +56,24 @@ export function BodyRow<TData>({ row, onRowClick }: BodyRowProps<TData>) {
|
|
|
56
56
|
data-test-id={TEST_IDS.bodyRow}
|
|
57
57
|
data-row-id={row.id}
|
|
58
58
|
className={styles.bodyRow}
|
|
59
|
+
rowAutoHeight={rowAutoHeight}
|
|
59
60
|
>
|
|
60
61
|
{pinnedLeft && (
|
|
61
62
|
<PinnedCells position={COLUMN_PIN_POSITION.Left}>
|
|
62
63
|
{pinnedLeft.map(cell => (
|
|
63
|
-
<BodyCell key={cell.id} cell={cell} />
|
|
64
|
+
<BodyCell key={cell.id} cell={cell} rowAutoHeight={rowAutoHeight} />
|
|
64
65
|
))}
|
|
65
66
|
</PinnedCells>
|
|
66
67
|
)}
|
|
67
68
|
|
|
68
69
|
{unpinned.map(cell => (
|
|
69
|
-
<BodyCell key={cell.id} cell={cell} />
|
|
70
|
+
<BodyCell key={cell.id} cell={cell} rowAutoHeight={rowAutoHeight} />
|
|
70
71
|
))}
|
|
71
72
|
|
|
72
73
|
{pinnedRight && (
|
|
73
74
|
<PinnedCells position={COLUMN_PIN_POSITION.Right}>
|
|
74
75
|
{pinnedRight.map(cell => (
|
|
75
|
-
<BodyCell key={cell.id} cell={cell} />
|
|
76
|
+
<BodyCell key={cell.id} cell={cell} rowAutoHeight={rowAutoHeight} />
|
|
76
77
|
))}
|
|
77
78
|
</PinnedCells>
|
|
78
79
|
)}
|
|
@@ -2,32 +2,41 @@ import { COLUMN_PIN_POSITION, TEST_IDS } from '../../constants';
|
|
|
2
2
|
import { HeaderCell } from '../Cells';
|
|
3
3
|
import { useHeaderGroups } from '../hooks';
|
|
4
4
|
import { PinnedCells } from './PinnedCells';
|
|
5
|
-
import { Row } from './Row';
|
|
5
|
+
import { Row, RowProps } from './Row';
|
|
6
6
|
import styles from './styles.module.scss';
|
|
7
7
|
|
|
8
|
-
export function HeaderRow() {
|
|
8
|
+
export function HeaderRow({ rowAutoHeight }: Pick<RowProps, 'rowAutoHeight'>) {
|
|
9
9
|
const { leftPinned, unpinned, rightPinned } = useHeaderGroups();
|
|
10
10
|
|
|
11
11
|
return (
|
|
12
|
-
<Row className={styles.tableHeader} data-test-id={TEST_IDS.headerRow}>
|
|
12
|
+
<Row className={styles.tableHeader} data-test-id={TEST_IDS.headerRow} rowAutoHeight={rowAutoHeight}>
|
|
13
13
|
{leftPinned && (
|
|
14
14
|
<PinnedCells position={COLUMN_PIN_POSITION.Left}>
|
|
15
15
|
{leftPinned.map(headerGroup =>
|
|
16
16
|
headerGroup.headers.map(header =>
|
|
17
|
-
header.isPlaceholder ? null :
|
|
17
|
+
header.isPlaceholder ? null : (
|
|
18
|
+
<HeaderCell key={header.id} header={header} rowAutoHeight={rowAutoHeight} />
|
|
19
|
+
),
|
|
18
20
|
),
|
|
19
21
|
)}
|
|
20
22
|
</PinnedCells>
|
|
21
23
|
)}
|
|
22
24
|
|
|
23
|
-
{unpinned.map(headerGroup =>
|
|
25
|
+
{unpinned.map(headerGroup =>
|
|
26
|
+
headerGroup.headers.map(header => <HeaderCell key={header.id} header={header} rowAutoHeight={rowAutoHeight} />),
|
|
27
|
+
)}
|
|
24
28
|
|
|
25
29
|
{rightPinned && (
|
|
26
30
|
<PinnedCells position={COLUMN_PIN_POSITION.Right}>
|
|
27
31
|
{rightPinned.map(headerGroup =>
|
|
28
32
|
headerGroup.headers.map(header =>
|
|
29
33
|
header.isPlaceholder ? null : (
|
|
30
|
-
<HeaderCell
|
|
34
|
+
<HeaderCell
|
|
35
|
+
key={header.id}
|
|
36
|
+
header={header}
|
|
37
|
+
pinPosition={COLUMN_PIN_POSITION.Right}
|
|
38
|
+
rowAutoHeight={rowAutoHeight}
|
|
39
|
+
/>
|
|
31
40
|
),
|
|
32
41
|
),
|
|
33
42
|
)}
|
|
@@ -4,16 +4,23 @@ import { MouseEvent, ReactNode } from 'react';
|
|
|
4
4
|
import { DataAttributes } from '../types';
|
|
5
5
|
import styles from './styles.module.scss';
|
|
6
6
|
|
|
7
|
-
type RowProps = {
|
|
7
|
+
export type RowProps = {
|
|
8
8
|
children: ReactNode;
|
|
9
9
|
onClick?(e: MouseEvent<HTMLDivElement>): void;
|
|
10
10
|
className?: string;
|
|
11
|
+
rowAutoHeight?: boolean;
|
|
11
12
|
} & DataAttributes;
|
|
12
13
|
|
|
13
|
-
export function Row({ onClick, children, className, ...attributes }: RowProps) {
|
|
14
|
+
export function Row({ onClick, children, className, rowAutoHeight, ...attributes }: RowProps) {
|
|
14
15
|
return (
|
|
15
16
|
// eslint-disable-next-line jsx-a11y/interactive-supports-focus
|
|
16
|
-
<div
|
|
17
|
+
<div
|
|
18
|
+
onClick={onClick}
|
|
19
|
+
className={cn(styles.tableRow, className)}
|
|
20
|
+
data-auto-height={rowAutoHeight || undefined}
|
|
21
|
+
role='row'
|
|
22
|
+
{...attributes}
|
|
23
|
+
>
|
|
17
24
|
{children}
|
|
18
25
|
</div>
|
|
19
26
|
);
|