@alfalab/core-components-table 2.5.10 → 2.6.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/components/pagination/Component.js +1 -1
- package/components/pagination/index.css +18 -13
- package/components/pagination/select-field/index.css +4 -4
- package/components/pagination/select-field/index.js +1 -1
- package/components/table/Component.js +1 -1
- package/components/table/index.css +9 -8
- package/components/tbody/Component.js +1 -1
- package/components/tbody/index.css +2 -2
- package/components/tcell/Component.js +1 -1
- package/components/tcell/index.css +15 -11
- package/components/texpandable-row/Component.js +1 -1
- package/components/texpandable-row/index.css +5 -5
- package/components/thead/Component.js +1 -1
- package/components/thead/index.css +9 -8
- package/components/thead-cell/Component.js +1 -1
- package/components/thead-cell/index.css +16 -12
- package/components/trow/Component.js +1 -1
- package/components/trow/index.css +8 -8
- package/components/tsortable-head-cell/Component.js +2 -2
- package/components/tsortable-head-cell/index.css +11 -10
- package/cssm/components/pagination/index.module.css +9 -4
- package/cssm/components/table/index.module.css +2 -1
- package/cssm/components/tcell/index.module.css +9 -5
- package/cssm/components/thead/index.module.css +3 -2
- package/cssm/components/thead-cell/index.module.css +7 -3
- package/cssm/components/tsortable-head-cell/Component.js +1 -1
- package/cssm/components/tsortable-head-cell/index.module.css +3 -2
- package/esm/components/pagination/Component.js +1 -1
- package/esm/components/pagination/index.css +18 -13
- package/esm/components/pagination/select-field/index.css +4 -4
- package/esm/components/pagination/select-field/index.js +1 -1
- package/esm/components/table/Component.js +1 -1
- package/esm/components/table/index.css +9 -8
- package/esm/components/tbody/Component.js +1 -1
- package/esm/components/tbody/index.css +2 -2
- package/esm/components/tcell/Component.js +1 -1
- package/esm/components/tcell/index.css +15 -11
- package/esm/components/texpandable-row/Component.js +1 -1
- package/esm/components/texpandable-row/index.css +5 -5
- package/esm/components/thead/Component.js +1 -1
- package/esm/components/thead/index.css +9 -8
- package/esm/components/thead-cell/Component.js +1 -1
- package/esm/components/thead-cell/index.css +16 -12
- package/esm/components/trow/Component.js +1 -1
- package/esm/components/trow/index.css +8 -8
- package/esm/components/tsortable-head-cell/Component.js +2 -2
- package/esm/components/tsortable-head-cell/index.css +11 -10
- package/modern/components/pagination/Component.js +1 -1
- package/modern/components/pagination/index.css +18 -13
- package/modern/components/pagination/select-field/index.css +4 -4
- package/modern/components/pagination/select-field/index.js +1 -1
- package/modern/components/table/Component.js +1 -1
- package/modern/components/table/index.css +9 -8
- package/modern/components/tbody/Component.js +1 -1
- package/modern/components/tbody/index.css +2 -2
- package/modern/components/tcell/Component.js +1 -1
- package/modern/components/tcell/index.css +15 -11
- package/modern/components/texpandable-row/Component.js +1 -1
- package/modern/components/texpandable-row/index.css +5 -5
- package/modern/components/thead/Component.js +1 -1
- package/modern/components/thead/index.css +9 -8
- package/modern/components/thead-cell/Component.js +1 -1
- package/modern/components/thead-cell/index.css +16 -12
- package/modern/components/trow/Component.js +1 -1
- package/modern/components/trow/index.css +8 -8
- package/modern/components/tsortable-head-cell/Component.js +2 -2
- package/modern/components/tsortable-head-cell/index.css +11 -10
- package/moderncssm/component.d.ts +21 -0
- package/moderncssm/component.js +22 -0
- package/moderncssm/components/index.d.ts +9 -0
- package/moderncssm/components/index.js +9 -0
- package/moderncssm/components/pagination/Component.d.ts +26 -0
- package/moderncssm/components/pagination/Component.js +33 -0
- package/moderncssm/components/pagination/index.d.ts +1 -0
- package/moderncssm/components/pagination/index.js +1 -0
- package/moderncssm/components/pagination/index.module.css +44 -0
- package/moderncssm/components/pagination/select-field/index.d.ts +3 -0
- package/moderncssm/components/pagination/select-field/index.js +12 -0
- package/moderncssm/components/pagination/select-field/index.module.css +11 -0
- package/moderncssm/components/table/Component.d.ts +72 -0
- package/moderncssm/components/table/Component.js +32 -0
- package/moderncssm/components/table/index.d.ts +1 -0
- package/moderncssm/components/table/index.js +1 -0
- package/moderncssm/components/table/index.module.css +33 -0
- package/moderncssm/components/table/utils.d.ts +5 -0
- package/moderncssm/components/table/utils.js +17 -0
- package/moderncssm/components/table-context/index.d.ts +20 -0
- package/moderncssm/components/table-context/index.js +12 -0
- package/moderncssm/components/tbody/Component.d.ts +15 -0
- package/moderncssm/components/tbody/Component.js +7 -0
- package/moderncssm/components/tbody/index.d.ts +1 -0
- package/moderncssm/components/tbody/index.js +1 -0
- package/moderncssm/components/tbody/index.module.css +6 -0
- package/moderncssm/components/tcell/Component.d.ts +19 -0
- package/moderncssm/components/tcell/Component.js +17 -0
- package/moderncssm/components/tcell/index.d.ts +1 -0
- package/moderncssm/components/tcell/index.js +1 -0
- package/moderncssm/components/tcell/index.module.css +37 -0
- package/moderncssm/components/texpandable-row/Component.d.ts +12 -0
- package/moderncssm/components/texpandable-row/Component.js +24 -0
- package/moderncssm/components/texpandable-row/index.d.ts +1 -0
- package/moderncssm/components/texpandable-row/index.js +1 -0
- package/moderncssm/components/texpandable-row/index.module.css +21 -0
- package/moderncssm/components/thead/Component.d.ts +19 -0
- package/moderncssm/components/thead/Component.js +8 -0
- package/moderncssm/components/thead/index.d.ts +1 -0
- package/moderncssm/components/thead/index.js +1 -0
- package/moderncssm/components/thead/index.module.css +32 -0
- package/moderncssm/components/thead-cell/Component.d.ts +28 -0
- package/moderncssm/components/thead-cell/Component.js +15 -0
- package/moderncssm/components/thead-cell/index.d.ts +1 -0
- package/moderncssm/components/thead-cell/index.js +1 -0
- package/moderncssm/components/thead-cell/index.module.css +51 -0
- package/moderncssm/components/trow/Component.d.ts +29 -0
- package/moderncssm/components/trow/Component.js +11 -0
- package/moderncssm/components/trow/index.d.ts +1 -0
- package/moderncssm/components/trow/index.js +1 -0
- package/moderncssm/components/trow/index.module.css +33 -0
- package/moderncssm/components/tsortable-head-cell/Component.d.ts +10 -0
- package/moderncssm/components/tsortable-head-cell/Component.js +26 -0
- package/moderncssm/components/tsortable-head-cell/index.d.ts +1 -0
- package/moderncssm/components/tsortable-head-cell/index.js +1 -0
- package/moderncssm/components/tsortable-head-cell/index.module.css +41 -0
- package/moderncssm/components/tsortable-head-cell/sort-icon-asc.d.ts +5 -0
- package/moderncssm/components/tsortable-head-cell/sort-icon-asc.js +6 -0
- package/moderncssm/components/tsortable-head-cell/sort-icon-desc.d.ts +5 -0
- package/moderncssm/components/tsortable-head-cell/sort-icon-desc.js +6 -0
- package/moderncssm/components/tsortable-head-cell/sort-icon-unset.d.ts +5 -0
- package/moderncssm/components/tsortable-head-cell/sort-icon-unset.js +6 -0
- package/moderncssm/index.d.ts +1 -0
- package/moderncssm/index.js +1 -0
- package/moderncssm/typings.d.ts +2 -0
- package/moderncssm/typings.js +1 -0
- package/moderncssm/utils.d.ts +4 -0
- package/moderncssm/utils.js +8 -0
- package/package.json +6 -6
- package/src/components/pagination/index.module.css +5 -5
- package/src/components/pagination/select-field/index.module.css +1 -1
- package/src/components/table/index.module.css +2 -2
- package/src/components/tbody/index.module.css +1 -1
- package/src/components/tcell/index.module.css +6 -6
- package/src/components/texpandable-row/index.module.css +1 -1
- package/src/components/thead/index.module.css +3 -3
- package/src/components/thead-cell/index.module.css +4 -4
- package/src/components/trow/index.module.css +1 -1
- package/src/components/tsortable-head-cell/Component.tsx +1 -1
- package/src/components/tsortable-head-cell/index.module.css +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: c0pmz */
|
|
2
2
|
:root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
3
3
|
} /* deprecated */ :root {
|
|
4
4
|
--color-light-neutral-700: #898991;
|
|
@@ -20,14 +20,15 @@
|
|
|
20
20
|
--gap-xs: 8px; /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
21
21
|
|
|
22
22
|
/* новые значения, используйте их */
|
|
23
|
+
--gap-8: var(--gap-xs);
|
|
23
24
|
} :root {
|
|
24
25
|
} :root {
|
|
25
|
-
} .
|
|
26
|
+
} .table__content_1wxe9 {
|
|
26
27
|
display: flex;
|
|
27
28
|
align-items: flex-start;
|
|
28
|
-
} .
|
|
29
|
+
} .table__icon_1wxe9 {
|
|
29
30
|
cursor: pointer;
|
|
30
|
-
margin-left: var(--gap-
|
|
31
|
+
margin-left: var(--gap-8);
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
34
|
* иконка сортировки должна быть выровнена по верхнему краю,
|
|
@@ -37,15 +38,15 @@
|
|
|
37
38
|
color: var(--color-light-neutral-700);
|
|
38
39
|
transition: color 0.2s ease;
|
|
39
40
|
flex-shrink: 0
|
|
40
|
-
} .
|
|
41
|
+
} .table__icon_1wxe9:hover {
|
|
41
42
|
color: var(--color-light-neutral-translucent-1300);
|
|
42
|
-
} .
|
|
43
|
+
} .table__reverse_1wxe9 {
|
|
43
44
|
flex-direction: row-reverse
|
|
44
|
-
} .
|
|
45
|
+
} .table__reverse_1wxe9 .table__icon_1wxe9 {
|
|
45
46
|
margin-left: 0;
|
|
46
|
-
margin-right: var(--gap-
|
|
47
|
-
} .
|
|
47
|
+
margin-right: var(--gap-8);
|
|
48
|
+
} .table__sorted_1wxe9 {
|
|
48
49
|
color: var(--color-light-status-info)
|
|
49
|
-
} .
|
|
50
|
+
} .table__sorted_1wxe9:hover {
|
|
50
51
|
color: var(--color-light-status-info);
|
|
51
52
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare const Table: import("react").ForwardRefExoticComponent<import("react").TableHTMLAttributes<HTMLTableElement> & {
|
|
3
|
+
compactView?: boolean | undefined;
|
|
4
|
+
compactHorizontal?: boolean | undefined;
|
|
5
|
+
className?: string | undefined;
|
|
6
|
+
children: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>[];
|
|
7
|
+
wrapper?: boolean | undefined;
|
|
8
|
+
pagination?: import("react").ReactNode;
|
|
9
|
+
dataTestId?: string | undefined;
|
|
10
|
+
stickyHeader?: boolean | undefined;
|
|
11
|
+
} & import("react").RefAttributes<HTMLTableElement>> & {
|
|
12
|
+
TBody: import("react").FC<import("./components/index").TBodyProps>;
|
|
13
|
+
THead: import("react").FC<import("./components/index").THeadProps>;
|
|
14
|
+
THeadCell: ({ children, className, dataTestId, style, width, textAlign, hidden, ...restProps }: import("./components/index").THeadCellProps) => import("react").JSX.Element | null;
|
|
15
|
+
TSortableHeadCell: ({ children, className, defaultIsSortedDesc, isSortedDesc, textAlign, onSort, ...restProps }: import("./components/index").TSortableHeadCellProps) => import("react").JSX.Element;
|
|
16
|
+
TCell: ({ className, style, dataTestId, children, index, ...restProps }: import("./components/index").TCellProps) => import("react").JSX.Element | null;
|
|
17
|
+
TRow: ({ children, className, selected, withoutBorder, dataTestId, ...restProps }: import("./components/index").TRowProps) => import("react").JSX.Element;
|
|
18
|
+
TExpandableRow: ({ className, selected, expanded, defaultExpanded, onToggle, renderContent, ...restProps }: import("./components/index").TExpandableRowProps) => import("react").JSX.Element;
|
|
19
|
+
Pagination: import("react").FC<import("./components/index").PaginationProps>;
|
|
20
|
+
};
|
|
21
|
+
export { Table };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Table as Table$1 } from './components/table/Component.js';
|
|
2
|
+
import { Pagination } from './components/pagination/Component.js';
|
|
3
|
+
import { THead } from './components/thead/Component.js';
|
|
4
|
+
import { THeadCell } from './components/thead-cell/Component.js';
|
|
5
|
+
import { TSortableHeadCell } from './components/tsortable-head-cell/Component.js';
|
|
6
|
+
import { TBody } from './components/tbody/Component.js';
|
|
7
|
+
import { TCell } from './components/tcell/Component.js';
|
|
8
|
+
import { TRow } from './components/trow/Component.js';
|
|
9
|
+
import { TExpandableRow } from './components/texpandable-row/Component.js';
|
|
10
|
+
|
|
11
|
+
const Table = Object.assign(Table$1, {
|
|
12
|
+
TBody,
|
|
13
|
+
THead,
|
|
14
|
+
THeadCell,
|
|
15
|
+
TSortableHeadCell,
|
|
16
|
+
TCell,
|
|
17
|
+
TRow,
|
|
18
|
+
TExpandableRow,
|
|
19
|
+
Pagination,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export { Table };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./table/index";
|
|
2
|
+
export * from "./pagination/index";
|
|
3
|
+
export * from "./thead/index";
|
|
4
|
+
export * from "./thead-cell/index";
|
|
5
|
+
export * from "./tsortable-head-cell/index";
|
|
6
|
+
export * from "./tbody/index";
|
|
7
|
+
export * from "./tcell/index";
|
|
8
|
+
export * from "./trow/index";
|
|
9
|
+
export * from "./texpandable-row/index";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { Table } from './table/Component.js';
|
|
2
|
+
export { Pagination } from './pagination/Component.js';
|
|
3
|
+
export { THead } from './thead/Component.js';
|
|
4
|
+
export { THeadCell } from './thead-cell/Component.js';
|
|
5
|
+
export { TSortableHeadCell } from './tsortable-head-cell/Component.js';
|
|
6
|
+
export { TBody } from './tbody/Component.js';
|
|
7
|
+
export { TCell } from './tcell/Component.js';
|
|
8
|
+
export { TRow } from './trow/Component.js';
|
|
9
|
+
export { TExpandableRow } from './texpandable-row/Component.js';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { PaginationProps as CorePaginationProps } from "@alfalab/core-components-pagination";
|
|
3
|
+
type PaginationProps = CorePaginationProps & {
|
|
4
|
+
/**
|
|
5
|
+
* Количество строк на страницу
|
|
6
|
+
*/
|
|
7
|
+
perPage?: number;
|
|
8
|
+
/**
|
|
9
|
+
* Возможные варианты разбивки
|
|
10
|
+
*/
|
|
11
|
+
possiblePerPage?: number[];
|
|
12
|
+
/**
|
|
13
|
+
* Обработчик переключения perPage
|
|
14
|
+
*/
|
|
15
|
+
onPerPageChange?: (perPage: number) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Скрывает переключатель количества строк на страницу
|
|
18
|
+
*/
|
|
19
|
+
hidePerPageSelect?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Идентификатор для систем автоматизированного тестирования
|
|
22
|
+
*/
|
|
23
|
+
dataTestId?: string;
|
|
24
|
+
};
|
|
25
|
+
declare const Pagination: FC<PaginationProps>;
|
|
26
|
+
export { PaginationProps, Pagination };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React, { useContext, useMemo, useCallback } from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { Pagination as Pagination$1 } from '@alfalab/core-components-pagination/moderncssm';
|
|
4
|
+
import { SelectDesktop } from '@alfalab/core-components-select/moderncssm/desktop';
|
|
5
|
+
import { TableContext } from '../table-context/index.js';
|
|
6
|
+
import { CustomSelectField } from './select-field/index.js';
|
|
7
|
+
import styles from './index.module.css';
|
|
8
|
+
|
|
9
|
+
const Pagination = ({ perPage = 25, possiblePerPage = [25, 50, 100], onPerPageChange = () => null, hidePerPageSelect = false, pagesCount, onPageChange = () => null, className, dataTestId, ...restPaginationProps }) => {
|
|
10
|
+
const { wrapperRef } = useContext(TableContext);
|
|
11
|
+
const options = useMemo(() => Array.from(new Set(possiblePerPage.concat(perPage)))
|
|
12
|
+
.sort((a, b) => a - b)
|
|
13
|
+
.map((value) => ({
|
|
14
|
+
key: value.toString(),
|
|
15
|
+
content: `Показывать по ${value}`,
|
|
16
|
+
})), [perPage, possiblePerPage]);
|
|
17
|
+
const handlePerPageChange = useCallback(({ selected }) => {
|
|
18
|
+
onPerPageChange(Number(selected?.key));
|
|
19
|
+
}, [onPerPageChange]);
|
|
20
|
+
const handlePageChange = useCallback((pageIndex) => {
|
|
21
|
+
onPageChange(pageIndex);
|
|
22
|
+
setTimeout(() => {
|
|
23
|
+
if (wrapperRef.current) {
|
|
24
|
+
wrapperRef.current.scrollIntoView();
|
|
25
|
+
}
|
|
26
|
+
}, 0);
|
|
27
|
+
}, [onPageChange, wrapperRef]);
|
|
28
|
+
return (React.createElement("div", { className: cn(styles.component, className), "data-test-id": dataTestId },
|
|
29
|
+
hidePerPageSelect === false && (React.createElement(SelectDesktop, { options: options, selected: perPage.toString(), onChange: handlePerPageChange, preventFlip: false, size: 's', className: styles.select, optionsListClassName: styles.menu, optionClassName: styles.option, Field: CustomSelectField })),
|
|
30
|
+
pagesCount > 1 && (React.createElement(Pagination$1, { pagesCount: pagesCount, onPageChange: handlePageChange, className: styles.pagination, ...restPaginationProps }))));
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { Pagination };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Component";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Pagination } from './Component.js';
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/* */
|
|
2
|
+
|
|
3
|
+
.component {
|
|
4
|
+
position: sticky;
|
|
5
|
+
left: 0;
|
|
6
|
+
display: flex;
|
|
7
|
+
justify-content: space-between;
|
|
8
|
+
align-items: flex-start;
|
|
9
|
+
width: 100%;
|
|
10
|
+
padding: var(--gap-24) var(--gap-16) var(--gap-32);
|
|
11
|
+
border-top: 1px solid var(--color-light-neutral-400);
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.pagesWrapper {
|
|
16
|
+
display: flex;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.tag.tag {
|
|
20
|
+
flex-shrink: 0;
|
|
21
|
+
margin-right: var(--gap-8);
|
|
22
|
+
padding: 0 var(--gap-8);
|
|
23
|
+
min-width: 32px
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.tag.tag:last-child {
|
|
27
|
+
margin-right: 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.tag.tag.tagActive {
|
|
31
|
+
cursor: default;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.pagination {
|
|
35
|
+
margin-left: auto;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.menu {
|
|
39
|
+
margin: var(--gap-4) 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.option {
|
|
43
|
+
min-width: 208px;
|
|
44
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { Button } from '@alfalab/core-components-button/moderncssm';
|
|
4
|
+
import styles from './index.module.css';
|
|
5
|
+
|
|
6
|
+
const CustomSelectField = ({ selected, innerProps, Arrow, open }) => {
|
|
7
|
+
const { ref, ...restInnerProps } = innerProps;
|
|
8
|
+
return (React.createElement("div", { ref: ref },
|
|
9
|
+
React.createElement(Button, { ...restInnerProps, size: 'xxs', view: 'transparent', className: cn(styles.field, { [styles.open]: open }), rightAddons: Arrow }, selected?.content)));
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { CustomSelectField };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ReactNode, TableHTMLAttributes } from "react";
|
|
4
|
+
type TableProps = TableHTMLAttributes<HTMLTableElement> & {
|
|
5
|
+
/**
|
|
6
|
+
* Компактный вид
|
|
7
|
+
*/
|
|
8
|
+
compactView?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Уменьшение горизонтальных паддингов
|
|
11
|
+
*/
|
|
12
|
+
compactHorizontal?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Дополнительный класс
|
|
15
|
+
*/
|
|
16
|
+
className?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Дочерние компоненты
|
|
19
|
+
*/
|
|
20
|
+
children: React.ReactElement | React.ReactElement[];
|
|
21
|
+
/**
|
|
22
|
+
* Оборачивает таблицу в стилизованный контейнер
|
|
23
|
+
*/
|
|
24
|
+
wrapper?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Слот для пагинации
|
|
27
|
+
*/
|
|
28
|
+
pagination?: ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* Идентификатор для систем автоматизированного тестирования
|
|
31
|
+
*/
|
|
32
|
+
dataTestId?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Если true то заголовок будет фиксироваться при скроле
|
|
35
|
+
*/
|
|
36
|
+
stickyHeader?: boolean;
|
|
37
|
+
};
|
|
38
|
+
declare const Table: React.ForwardRefExoticComponent<React.TableHTMLAttributes<HTMLTableElement> & {
|
|
39
|
+
/**
|
|
40
|
+
* Компактный вид
|
|
41
|
+
*/
|
|
42
|
+
compactView?: boolean | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Уменьшение горизонтальных паддингов
|
|
45
|
+
*/
|
|
46
|
+
compactHorizontal?: boolean | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Дополнительный класс
|
|
49
|
+
*/
|
|
50
|
+
className?: string | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Дочерние компоненты
|
|
53
|
+
*/
|
|
54
|
+
children: React.ReactElement | React.ReactElement[];
|
|
55
|
+
/**
|
|
56
|
+
* Оборачивает таблицу в стилизованный контейнер
|
|
57
|
+
*/
|
|
58
|
+
wrapper?: boolean | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Слот для пагинации
|
|
61
|
+
*/
|
|
62
|
+
pagination?: ReactNode;
|
|
63
|
+
/**
|
|
64
|
+
* Идентификатор для систем автоматизированного тестирования
|
|
65
|
+
*/
|
|
66
|
+
dataTestId?: string | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Если true то заголовок будет фиксироваться при скроле
|
|
69
|
+
*/
|
|
70
|
+
stickyHeader?: boolean | undefined;
|
|
71
|
+
} & React.RefAttributes<HTMLTableElement>>;
|
|
72
|
+
export { TableProps, Table };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React, { forwardRef, useRef, useMemo } from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { TableContext } from '../table-context/index.js';
|
|
4
|
+
import { findAllHeadCellsProps } from './utils.js';
|
|
5
|
+
import styles from './index.module.css';
|
|
6
|
+
|
|
7
|
+
const Table = forwardRef(({ className, children, compactView = false, compactHorizontal = false, wrapper = true, pagination, dataTestId, stickyHeader = false, ...restProps }, ref) => {
|
|
8
|
+
const wrapperRef = useRef(null);
|
|
9
|
+
const columnsConfiguration = useMemo(() => findAllHeadCellsProps(children).map((columnProps, index) => ({
|
|
10
|
+
width: columnProps.width,
|
|
11
|
+
textAlign: columnProps.textAlign,
|
|
12
|
+
hidden: columnProps.hidden,
|
|
13
|
+
index,
|
|
14
|
+
})), [children]);
|
|
15
|
+
/* eslint-disable react/jsx-no-constructed-context-values */
|
|
16
|
+
return (React.createElement(TableContext.Provider, { value: {
|
|
17
|
+
stickyHeader,
|
|
18
|
+
columnsConfiguration,
|
|
19
|
+
compactView,
|
|
20
|
+
compactHorizontal,
|
|
21
|
+
wrapperRef,
|
|
22
|
+
} },
|
|
23
|
+
React.createElement("div", { ref: wrapperRef, className: cn(styles.component, className, {
|
|
24
|
+
[styles.wrapper]: wrapper,
|
|
25
|
+
[styles.hasPagination]: !!pagination,
|
|
26
|
+
[styles.stickyHeader]: stickyHeader,
|
|
27
|
+
}), "data-test-id": dataTestId },
|
|
28
|
+
React.createElement("table", { ref: ref, className: styles.table, ...restProps }, children),
|
|
29
|
+
pagination)));
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export { Table };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Component";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Table } from './Component.js';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* */
|
|
2
|
+
|
|
3
|
+
.component {
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.wrapper {
|
|
8
|
+
padding: 0 var(--gap-16) var(--gap-16);
|
|
9
|
+
background: var(--color-light-base-bg-primary);
|
|
10
|
+
box-shadow: var(--shadow-xs-hard);
|
|
11
|
+
border-radius: var(--border-radius-m);
|
|
12
|
+
overflow: auto;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.stickyHeader {
|
|
16
|
+
max-height: 100%;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.hasPagination {
|
|
20
|
+
padding-bottom: 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.table {
|
|
24
|
+
width: 100%;
|
|
25
|
+
border-collapse: collapse;
|
|
26
|
+
box-sizing: border-box
|
|
27
|
+
|
|
28
|
+
/* TODO: Хак для выравнивания чекбокса */
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.table td:first-child label > *[class^='box'], .table th:first-child label > *[class^='box'] {
|
|
32
|
+
margin-top: 0;
|
|
33
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { isChildInstanceOf } from '../../utils.js';
|
|
3
|
+
import { THead } from '../thead/Component.js';
|
|
4
|
+
|
|
5
|
+
function findAllHeadCellsProps(children) {
|
|
6
|
+
const result = [];
|
|
7
|
+
React.Children.forEach(children, (child) => {
|
|
8
|
+
if (isChildInstanceOf(child, THead)) {
|
|
9
|
+
React.Children.forEach(child.props.children, (headChild) => {
|
|
10
|
+
result.push(headChild.props);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { findAllHeadCellsProps };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { RefObject } from "react";
|
|
4
|
+
import { TextAlignProperty } from "../../typings";
|
|
5
|
+
type ColumnConfiguration = {
|
|
6
|
+
width?: string | number;
|
|
7
|
+
textAlign?: TextAlignProperty;
|
|
8
|
+
hidden?: boolean;
|
|
9
|
+
index: number;
|
|
10
|
+
};
|
|
11
|
+
type TableContextType = {
|
|
12
|
+
columnsConfiguration: ColumnConfiguration[];
|
|
13
|
+
stickyHeader: boolean;
|
|
14
|
+
compactView: boolean;
|
|
15
|
+
compactHorizontal: boolean;
|
|
16
|
+
wrapperRef: RefObject<HTMLDivElement>;
|
|
17
|
+
};
|
|
18
|
+
declare const DEFAULT_TABLE_CONTEXT: TableContextType;
|
|
19
|
+
declare const TableContext: React.Context<TableContextType>;
|
|
20
|
+
export { ColumnConfiguration, TableContextType, DEFAULT_TABLE_CONTEXT, TableContext };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_TABLE_CONTEXT = {
|
|
4
|
+
columnsConfiguration: [],
|
|
5
|
+
compactView: false,
|
|
6
|
+
stickyHeader: false,
|
|
7
|
+
compactHorizontal: false,
|
|
8
|
+
wrapperRef: { current: null },
|
|
9
|
+
};
|
|
10
|
+
const TableContext = React.createContext(DEFAULT_TABLE_CONTEXT);
|
|
11
|
+
|
|
12
|
+
export { DEFAULT_TABLE_CONTEXT, TableContext };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { HTMLAttributes } from "react";
|
|
4
|
+
type TBodyProps = HTMLAttributes<HTMLTableSectionElement> & {
|
|
5
|
+
/**
|
|
6
|
+
* Дополнительный класс
|
|
7
|
+
*/
|
|
8
|
+
className?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Идентификатор для систем автоматизированного тестирования
|
|
11
|
+
*/
|
|
12
|
+
dataTestId?: string;
|
|
13
|
+
};
|
|
14
|
+
declare const TBody: React.FC<TBodyProps>;
|
|
15
|
+
export { TBodyProps, TBody };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import styles from './index.module.css';
|
|
4
|
+
|
|
5
|
+
const TBody = ({ className, children, dataTestId, ...restProps }) => (React.createElement("tbody", { className: cn(styles.component, className), "data-test-id": dataTestId, ...restProps }, children));
|
|
6
|
+
|
|
7
|
+
export { TBody };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Component";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TBody } from './Component.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { TdHTMLAttributes } from "react";
|
|
4
|
+
type TCellProps = TdHTMLAttributes<HTMLTableCellElement> & {
|
|
5
|
+
/**
|
|
6
|
+
* Дополнительный класс
|
|
7
|
+
*/
|
|
8
|
+
className?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Идентификатор для систем автоматизированного тестирования
|
|
11
|
+
*/
|
|
12
|
+
dataTestId?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Устанавливается автоматически и позволяет использовать конфиг для соответствующего индекса
|
|
15
|
+
*/
|
|
16
|
+
index?: number;
|
|
17
|
+
};
|
|
18
|
+
declare const TCell: ({ className, style, dataTestId, children, index, ...restProps }: TCellProps) => React.JSX.Element | null;
|
|
19
|
+
export { TCellProps, TCell };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { TableContext } from '../table-context/index.js';
|
|
4
|
+
import styles from './index.module.css';
|
|
5
|
+
|
|
6
|
+
const TCell = ({ className, style, dataTestId, children, index, ...restProps }) => {
|
|
7
|
+
const { columnsConfiguration, compactView, compactHorizontal } = useContext(TableContext);
|
|
8
|
+
const column = index === undefined ? null : columnsConfiguration[index];
|
|
9
|
+
const width = column?.width;
|
|
10
|
+
const textAlign = column?.textAlign;
|
|
11
|
+
const hidden = column?.hidden || false;
|
|
12
|
+
if (hidden)
|
|
13
|
+
return null;
|
|
14
|
+
return (React.createElement("td", { className: cn(styles.component, className, compactView && styles.compact, compactHorizontal && styles.compactHorizontal), style: { ...style, width, textAlign }, "data-test-id": dataTestId, ...restProps }, children));
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { TCell };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Component";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TCell } from './Component.js';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/* */
|
|
2
|
+
|
|
3
|
+
.component {
|
|
4
|
+
font-size: 14px;
|
|
5
|
+
line-height: 20px;
|
|
6
|
+
font-weight: 400;
|
|
7
|
+
|
|
8
|
+
color: var(--color-light-text-primary);
|
|
9
|
+
padding: var(--gap-24) var(--gap-12);
|
|
10
|
+
height: 72px;
|
|
11
|
+
border-top: 1px solid var(--color-light-neutral-400);
|
|
12
|
+
vertical-align: top;
|
|
13
|
+
box-sizing: border-box
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.component:first-child {
|
|
17
|
+
padding-left: var(--gap-16);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.component:last-child {
|
|
21
|
+
padding-right: var(--gap-16);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.compactHorizontal {
|
|
25
|
+
padding-left: 6px;
|
|
26
|
+
padding-right: 6px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.compact {
|
|
30
|
+
padding-top: var(--gap-8);
|
|
31
|
+
padding-bottom: var(--gap-8);
|
|
32
|
+
|
|
33
|
+
max-width: 0;
|
|
34
|
+
overflow: hidden;
|
|
35
|
+
text-overflow: ellipsis;
|
|
36
|
+
white-space: nowrap;
|
|
37
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
import { TRowProps } from "../trow/index";
|
|
5
|
+
type TExpandableRowProps = TRowProps & {
|
|
6
|
+
defaultExpanded?: boolean;
|
|
7
|
+
expanded?: boolean;
|
|
8
|
+
onToggle?: (expanded: boolean) => void;
|
|
9
|
+
renderContent: (expanded: boolean) => ReactNode;
|
|
10
|
+
};
|
|
11
|
+
declare const TExpandableRow: ({ className, selected, expanded, defaultExpanded, onToggle, renderContent, ...restProps }: TExpandableRowProps) => React.JSX.Element;
|
|
12
|
+
export { TExpandableRowProps, TExpandableRow };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { TRow } from '../trow/Component.js';
|
|
4
|
+
import styles from './index.module.css';
|
|
5
|
+
|
|
6
|
+
const TExpandableRow = ({ className, selected, expanded, defaultExpanded = false, onToggle = () => null, renderContent = () => null, ...restProps }) => {
|
|
7
|
+
const [expandedState, setExpandedState] = useState(defaultExpanded);
|
|
8
|
+
const uncontrolled = expanded === undefined;
|
|
9
|
+
const isExpanded = (uncontrolled ? expandedState : expanded);
|
|
10
|
+
const handleToggle = () => {
|
|
11
|
+
if (uncontrolled) {
|
|
12
|
+
setExpandedState(!isExpanded);
|
|
13
|
+
}
|
|
14
|
+
onToggle(isExpanded);
|
|
15
|
+
};
|
|
16
|
+
return (React.createElement(React.Fragment, null,
|
|
17
|
+
React.createElement(TRow, { className: cn(styles.row, className, {
|
|
18
|
+
[styles.selected]: selected,
|
|
19
|
+
[styles.expanded]: isExpanded,
|
|
20
|
+
}), selected: selected, onClick: handleToggle, ...restProps }),
|
|
21
|
+
React.createElement("tr", { className: cn(styles.expandable, { [styles.expanded]: isExpanded }) }, renderContent(isExpanded))));
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { TExpandableRow };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Component";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TExpandableRow } from './Component.js';
|