@snack-uikit/table 0.39.6 → 0.39.7-preview-d42155c3.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/README.md +1 -3
- package/dist/cjs/helperComponents/Cells/TreeCell/TreeCell.d.ts +5 -5
- package/dist/cjs/helperComponents/Cells/TreeCell/TreeCell.js +2 -2
- package/dist/esm/helperComponents/Cells/TreeCell/TreeCell.d.ts +5 -5
- package/dist/esm/helperComponents/Cells/TreeCell/TreeCell.js +2 -2
- package/package.json +2 -2
- package/src/helperComponents/Cells/TreeCell/TreeCell.tsx +7 -7
package/README.md
CHANGED
|
@@ -117,7 +117,7 @@ const columnDefinitions: ColumnDefinition<TableData>[] = [
|
|
|
117
117
|
| name | type | default value | description |
|
|
118
118
|
|------|------|---------------|-------------|
|
|
119
119
|
| columnSettings* | `{ enableDrag?: boolean; enableSettingsMenu?: boolean; }` | - | |
|
|
120
|
-
| savedState* | `Pick<ToolbarPersistConfig<
|
|
120
|
+
| savedState* | `Pick<ToolbarPersistConfig<TFilters>, "serializer" \| "parser"> & { id: string; filterQueryKey?: string; resize?: boolean; columnSettings?: boolean; }` | - | |
|
|
121
121
|
| tableColumns* | `ColumnDefinition<TData>[]` | - | |
|
|
122
122
|
## useColumnSettings
|
|
123
123
|
### Props
|
|
@@ -168,8 +168,6 @@ const columnDefinitions: ColumnDefinition<TableData>[] = [
|
|
|
168
168
|
### Props
|
|
169
169
|
| name | type | default value | description |
|
|
170
170
|
|------|------|---------------|-------------|
|
|
171
|
-
| filter | `FiltersState` | - | |
|
|
172
|
-
| search | `string` | - | |
|
|
173
171
|
| pagination | `PaginationState \| PaginationParams` | - | |
|
|
174
172
|
| sorting | `SortingState` | - | |
|
|
175
173
|
## Table
|
|
@@ -2,7 +2,7 @@ import { CellContext } from '@tanstack/react-table';
|
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { RowAppearance } from '../../../components';
|
|
4
4
|
import { ColumnDefinition } from '../../../types';
|
|
5
|
-
type BaseTreeColumnDef = {
|
|
5
|
+
type BaseTreeColumnDef<TData> = {
|
|
6
6
|
/** Имя ключа соответствующее полю в data */
|
|
7
7
|
accessorKey: string;
|
|
8
8
|
/** Иконка элемента-родителя в открытом состоянии */
|
|
@@ -10,23 +10,23 @@ type BaseTreeColumnDef = {
|
|
|
10
10
|
/** Иконка элемента-родителя в закрытом состоянии */
|
|
11
11
|
collapsedIcon?: ReactNode;
|
|
12
12
|
/** Иконка дочернего */
|
|
13
|
-
icon?: ReactNode;
|
|
13
|
+
icon?: (ctx: CellContext<TData, unknown>) => ReactNode;
|
|
14
14
|
/** Иконка дочернего элемента */
|
|
15
15
|
showToggle?: boolean;
|
|
16
16
|
/** Минимальный размер ячейки */
|
|
17
17
|
minSize?: number;
|
|
18
18
|
};
|
|
19
|
-
type TreeColumnDef = BaseTreeColumnDef & {
|
|
19
|
+
type TreeColumnDef<TData> = BaseTreeColumnDef<TData> & {
|
|
20
20
|
header?: never;
|
|
21
21
|
cell?: never;
|
|
22
22
|
};
|
|
23
|
-
type TreeColumnDefWithDescription<TData> = BaseTreeColumnDef & {
|
|
23
|
+
type TreeColumnDefWithDescription<TData> = BaseTreeColumnDef<TData> & {
|
|
24
24
|
/** Заголовок колонки */
|
|
25
25
|
cell?(ctx: CellContext<TData, unknown>): ReactNode;
|
|
26
26
|
/** Рендер функция заголовка колонки */
|
|
27
27
|
header?: ColumnDefinition<TData>['header'];
|
|
28
28
|
};
|
|
29
|
-
export type TreeColumnDefinitionProps<TData> = TreeColumnDef | TreeColumnDefWithDescription<TData>;
|
|
29
|
+
export type TreeColumnDefinitionProps<TData> = TreeColumnDef<TData> | TreeColumnDefWithDescription<TData>;
|
|
30
30
|
type TreeColDefProps<TData> = TreeColumnDefinitionProps<TData> & {
|
|
31
31
|
enableSelection?: boolean;
|
|
32
32
|
rowSelectionAppearance?: RowAppearance;
|
|
@@ -26,7 +26,7 @@ function getTreeColumnDef(_ref) {
|
|
|
26
26
|
let _ref$showToggle = _ref.showToggle,
|
|
27
27
|
showToggle = _ref$showToggle === void 0 ? false : _ref$showToggle,
|
|
28
28
|
_ref$icon = _ref.icon,
|
|
29
|
-
icon = _ref$icon === void 0 ? (0, jsx_runtime_1.jsx)(icons_1.FileSVG, {
|
|
29
|
+
icon = _ref$icon === void 0 ? () => (0, jsx_runtime_1.jsx)(icons_1.FileSVG, {
|
|
30
30
|
size: 24
|
|
31
31
|
}) : _ref$icon,
|
|
32
32
|
_ref$expandedIcon = _ref.expandedIcon,
|
|
@@ -167,7 +167,7 @@ function getTreeColumnDef(_ref) {
|
|
|
167
167
|
}), (0, jsx_runtime_1.jsxs)("div", {
|
|
168
168
|
role: 'presentation',
|
|
169
169
|
className: styles_module_scss_1.default.userContent,
|
|
170
|
-
children: [!isExpandable && icon, renderCell ? renderCell(ctx) : (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, {
|
|
170
|
+
children: [!isExpandable && (icon === null || icon === void 0 ? void 0 : icon(ctx)), renderCell ? renderCell(ctx) : (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, {
|
|
171
171
|
text: value
|
|
172
172
|
})]
|
|
173
173
|
})]
|
|
@@ -2,7 +2,7 @@ import { CellContext } from '@tanstack/react-table';
|
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { RowAppearance } from '../../../components';
|
|
4
4
|
import { ColumnDefinition } from '../../../types';
|
|
5
|
-
type BaseTreeColumnDef = {
|
|
5
|
+
type BaseTreeColumnDef<TData> = {
|
|
6
6
|
/** Имя ключа соответствующее полю в data */
|
|
7
7
|
accessorKey: string;
|
|
8
8
|
/** Иконка элемента-родителя в открытом состоянии */
|
|
@@ -10,23 +10,23 @@ type BaseTreeColumnDef = {
|
|
|
10
10
|
/** Иконка элемента-родителя в закрытом состоянии */
|
|
11
11
|
collapsedIcon?: ReactNode;
|
|
12
12
|
/** Иконка дочернего */
|
|
13
|
-
icon?: ReactNode;
|
|
13
|
+
icon?: (ctx: CellContext<TData, unknown>) => ReactNode;
|
|
14
14
|
/** Иконка дочернего элемента */
|
|
15
15
|
showToggle?: boolean;
|
|
16
16
|
/** Минимальный размер ячейки */
|
|
17
17
|
minSize?: number;
|
|
18
18
|
};
|
|
19
|
-
type TreeColumnDef = BaseTreeColumnDef & {
|
|
19
|
+
type TreeColumnDef<TData> = BaseTreeColumnDef<TData> & {
|
|
20
20
|
header?: never;
|
|
21
21
|
cell?: never;
|
|
22
22
|
};
|
|
23
|
-
type TreeColumnDefWithDescription<TData> = BaseTreeColumnDef & {
|
|
23
|
+
type TreeColumnDefWithDescription<TData> = BaseTreeColumnDef<TData> & {
|
|
24
24
|
/** Заголовок колонки */
|
|
25
25
|
cell?(ctx: CellContext<TData, unknown>): ReactNode;
|
|
26
26
|
/** Рендер функция заголовка колонки */
|
|
27
27
|
header?: ColumnDefinition<TData>['header'];
|
|
28
28
|
};
|
|
29
|
-
export type TreeColumnDefinitionProps<TData> = TreeColumnDef | TreeColumnDefWithDescription<TData>;
|
|
29
|
+
export type TreeColumnDefinitionProps<TData> = TreeColumnDef<TData> | TreeColumnDefWithDescription<TData>;
|
|
30
30
|
type TreeColDefProps<TData> = TreeColumnDefinitionProps<TData> & {
|
|
31
31
|
enableSelection?: boolean;
|
|
32
32
|
rowSelectionAppearance?: RowAppearance;
|
|
@@ -11,7 +11,7 @@ import { TREE_CELL_ID } from './constants';
|
|
|
11
11
|
import styles from './styles.module.css';
|
|
12
12
|
import { TreeLine } from './TreeLine';
|
|
13
13
|
/** Вспомогательная функция для создания ячейки со статусом */
|
|
14
|
-
export function getTreeColumnDef({ showToggle = false, icon = _jsx(FileSVG, { size: 24 }), expandedIcon = _jsx(FolderOpenSVG, { size: 24 }), collapsedIcon = _jsx(FolderSVG, { size: 24 }), header, accessorKey, cell: renderCell, enableSelection, rowSelectionAppearance, minSize, }) {
|
|
14
|
+
export function getTreeColumnDef({ showToggle = false, icon = () => _jsx(FileSVG, { size: 24 }), expandedIcon = _jsx(FolderOpenSVG, { size: 24 }), collapsedIcon = _jsx(FolderSVG, { size: 24 }), header, accessorKey, cell: renderCell, enableSelection, rowSelectionAppearance, minSize, }) {
|
|
15
15
|
const cell = function TreeCell(ctx) {
|
|
16
16
|
var _a;
|
|
17
17
|
const { row, cell } = ctx;
|
|
@@ -84,7 +84,7 @@ export function getTreeColumnDef({ showToggle = false, icon = _jsx(FileSVG, { si
|
|
|
84
84
|
// @ts-ignore
|
|
85
85
|
cell.row.original[accessorKey]
|
|
86
86
|
: cell.getValue();
|
|
87
|
-
return (_jsx("div", { role: 'presentation', "data-test-id": TEST_IDS.tree.node, className: styles.treeCellContainer, onClick: toggleClickHandler, children: _jsxs("div", { className: styles.treeCell, ref: ref, children: [lines, Boolean(parent) && _jsx(TreeLine, { horizontal: true, visible: true }), isExpandable && (_jsx(ButtonFunction, { size: 'xs', "data-test-id": TEST_IDS.tree.chevron, icon: _jsx(ChevronRightSVG, {}), onClick: chevronClickHandler, className: styles.cellExpandButton, "data-expanded": isExpanded || undefined })), _jsxs("div", { className: styles.treeNodeContent, "data-disabled": !isRowsSelectionEnabled || undefined, "data-selected": isRowSelected || undefined, "data-multiselect": isMultiSelect || undefined, children: [showToggle && !isToggleHidden && (_jsx("div", { tabIndex: -1, className: styles.treeCheckboxWrap, children: isMultiSelect ? (_jsx(Checkbox, { size: 's', disabled: !isRowsSelectionEnabled, checked: isRowSelected, "data-test-id": TEST_IDS.tree.checkbox, indeterminate: isSomeSubRowSelected && !isAllSubRowsSelected })) : (_jsx(Radio, { size: 's', disabled: !isRowsSelectionEnabled, "data-test-id": TEST_IDS.tree.radio, checked: isRowSelected })) })), _jsxs("div", { role: 'presentation', onClick: chevronClickHandler, className: styles.cellUserToggleIcon, children: [isExpandable && isExpanded && expandedIcon, isExpandable && !isExpanded && collapsedIcon] }), _jsxs("div", { role: 'presentation', className: styles.userContent, children: [!isExpandable && icon, renderCell ? renderCell(ctx) : _jsx(TruncateString, { text: value })] })] })] }) }));
|
|
87
|
+
return (_jsx("div", { role: 'presentation', "data-test-id": TEST_IDS.tree.node, className: styles.treeCellContainer, onClick: toggleClickHandler, children: _jsxs("div", { className: styles.treeCell, ref: ref, children: [lines, Boolean(parent) && _jsx(TreeLine, { horizontal: true, visible: true }), isExpandable && (_jsx(ButtonFunction, { size: 'xs', "data-test-id": TEST_IDS.tree.chevron, icon: _jsx(ChevronRightSVG, {}), onClick: chevronClickHandler, className: styles.cellExpandButton, "data-expanded": isExpanded || undefined })), _jsxs("div", { className: styles.treeNodeContent, "data-disabled": !isRowsSelectionEnabled || undefined, "data-selected": isRowSelected || undefined, "data-multiselect": isMultiSelect || undefined, children: [showToggle && !isToggleHidden && (_jsx("div", { tabIndex: -1, className: styles.treeCheckboxWrap, children: isMultiSelect ? (_jsx(Checkbox, { size: 's', disabled: !isRowsSelectionEnabled, checked: isRowSelected, "data-test-id": TEST_IDS.tree.checkbox, indeterminate: isSomeSubRowSelected && !isAllSubRowsSelected })) : (_jsx(Radio, { size: 's', disabled: !isRowsSelectionEnabled, "data-test-id": TEST_IDS.tree.radio, checked: isRowSelected })) })), _jsxs("div", { role: 'presentation', onClick: chevronClickHandler, className: styles.cellUserToggleIcon, children: [isExpandable && isExpanded && expandedIcon, isExpandable && !isExpanded && collapsedIcon] }), _jsxs("div", { role: 'presentation', className: styles.userContent, children: [!isExpandable && (icon === null || icon === void 0 ? void 0 : icon(ctx)), renderCell ? renderCell(ctx) : _jsx(TruncateString, { text: value })] })] })] }) }));
|
|
88
88
|
};
|
|
89
89
|
return {
|
|
90
90
|
id: TREE_CELL_ID,
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Table",
|
|
7
|
-
"version": "0.39.
|
|
7
|
+
"version": "0.39.7-preview-d42155c3.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"@snack-uikit/locale": "*"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "2a708df60414ebeaeea543ae0dcfb6ed4863a479"
|
|
69
69
|
}
|
|
@@ -14,7 +14,7 @@ import { TREE_CELL_ID } from './constants';
|
|
|
14
14
|
import styles from './styles.module.scss';
|
|
15
15
|
import { TreeLine } from './TreeLine';
|
|
16
16
|
|
|
17
|
-
type BaseTreeColumnDef = {
|
|
17
|
+
type BaseTreeColumnDef<TData> = {
|
|
18
18
|
/** Имя ключа соответствующее полю в data */
|
|
19
19
|
accessorKey: string;
|
|
20
20
|
/** Иконка элемента-родителя в открытом состоянии */
|
|
@@ -22,26 +22,26 @@ type BaseTreeColumnDef = {
|
|
|
22
22
|
/** Иконка элемента-родителя в закрытом состоянии */
|
|
23
23
|
collapsedIcon?: ReactNode;
|
|
24
24
|
/** Иконка дочернего */
|
|
25
|
-
icon?: ReactNode;
|
|
25
|
+
icon?: (ctx: CellContext<TData, unknown>) => ReactNode;
|
|
26
26
|
/** Иконка дочернего элемента */
|
|
27
27
|
showToggle?: boolean;
|
|
28
28
|
/** Минимальный размер ячейки */
|
|
29
29
|
minSize?: number;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
type TreeColumnDef = BaseTreeColumnDef & {
|
|
32
|
+
type TreeColumnDef<TData> = BaseTreeColumnDef<TData> & {
|
|
33
33
|
header?: never;
|
|
34
34
|
cell?: never;
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
type TreeColumnDefWithDescription<TData> = BaseTreeColumnDef & {
|
|
37
|
+
type TreeColumnDefWithDescription<TData> = BaseTreeColumnDef<TData> & {
|
|
38
38
|
/** Заголовок колонки */
|
|
39
39
|
cell?(ctx: CellContext<TData, unknown>): ReactNode;
|
|
40
40
|
/** Рендер функция заголовка колонки */
|
|
41
41
|
header?: ColumnDefinition<TData>['header'];
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
export type TreeColumnDefinitionProps<TData> = TreeColumnDef | TreeColumnDefWithDescription<TData>;
|
|
44
|
+
export type TreeColumnDefinitionProps<TData> = TreeColumnDef<TData> | TreeColumnDefWithDescription<TData>;
|
|
45
45
|
|
|
46
46
|
type TreeColDefProps<TData> = TreeColumnDefinitionProps<TData> & {
|
|
47
47
|
enableSelection?: boolean;
|
|
@@ -51,7 +51,7 @@ type TreeColDefProps<TData> = TreeColumnDefinitionProps<TData> & {
|
|
|
51
51
|
/** Вспомогательная функция для создания ячейки со статусом */
|
|
52
52
|
export function getTreeColumnDef<TData>({
|
|
53
53
|
showToggle = false,
|
|
54
|
-
icon = <FileSVG size={24} />,
|
|
54
|
+
icon = () => <FileSVG size={24} />,
|
|
55
55
|
expandedIcon = <FolderOpenSVG size={24} />,
|
|
56
56
|
collapsedIcon = <FolderSVG size={24} />,
|
|
57
57
|
header,
|
|
@@ -214,7 +214,7 @@ export function getTreeColumnDef<TData>({
|
|
|
214
214
|
{isExpandable && !isExpanded && collapsedIcon}
|
|
215
215
|
</div>
|
|
216
216
|
<div role='presentation' className={styles.userContent}>
|
|
217
|
-
{!isExpandable && icon}
|
|
217
|
+
{!isExpandable && icon?.(ctx)}
|
|
218
218
|
|
|
219
219
|
{renderCell ? renderCell(ctx) : <TruncateString text={value} />}
|
|
220
220
|
</div>
|