@alfalab/core-components-table 2.5.11 → 2.6.1

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.
Files changed (145) hide show
  1. package/components/pagination/Component.js +1 -1
  2. package/components/pagination/index.css +14 -13
  3. package/components/pagination/select-field/index.css +4 -4
  4. package/components/pagination/select-field/index.js +1 -1
  5. package/components/table/Component.js +1 -1
  6. package/components/table/index.css +13 -11
  7. package/components/tbody/Component.js +1 -1
  8. package/components/tbody/index.css +2 -2
  9. package/components/tcell/Component.js +1 -1
  10. package/components/tcell/index.css +6 -6
  11. package/components/texpandable-row/Component.js +1 -1
  12. package/components/texpandable-row/index.css +9 -8
  13. package/components/thead/Component.js +1 -1
  14. package/components/thead/index.css +8 -7
  15. package/components/thead-cell/Component.js +1 -1
  16. package/components/thead-cell/index.css +11 -10
  17. package/components/trow/Component.js +1 -1
  18. package/components/trow/index.css +8 -8
  19. package/components/tsortable-head-cell/Component.js +1 -1
  20. package/components/tsortable-head-cell/index.css +10 -9
  21. package/cssm/components/pagination/index.module.css +5 -4
  22. package/cssm/components/table/index.module.css +6 -4
  23. package/cssm/components/texpandable-row/index.module.css +4 -3
  24. package/cssm/components/thead/index.module.css +2 -1
  25. package/cssm/components/thead-cell/index.module.css +2 -1
  26. package/cssm/components/tsortable-head-cell/index.module.css +2 -1
  27. package/esm/components/pagination/Component.js +1 -1
  28. package/esm/components/pagination/index.css +14 -13
  29. package/esm/components/pagination/select-field/index.css +4 -4
  30. package/esm/components/pagination/select-field/index.js +1 -1
  31. package/esm/components/table/Component.js +1 -1
  32. package/esm/components/table/index.css +13 -11
  33. package/esm/components/tbody/Component.js +1 -1
  34. package/esm/components/tbody/index.css +2 -2
  35. package/esm/components/tcell/Component.js +1 -1
  36. package/esm/components/tcell/index.css +6 -6
  37. package/esm/components/texpandable-row/Component.js +1 -1
  38. package/esm/components/texpandable-row/index.css +9 -8
  39. package/esm/components/thead/Component.js +1 -1
  40. package/esm/components/thead/index.css +8 -7
  41. package/esm/components/thead-cell/Component.js +1 -1
  42. package/esm/components/thead-cell/index.css +11 -10
  43. package/esm/components/trow/Component.js +1 -1
  44. package/esm/components/trow/index.css +8 -8
  45. package/esm/components/tsortable-head-cell/Component.js +1 -1
  46. package/esm/components/tsortable-head-cell/index.css +10 -9
  47. package/modern/components/pagination/Component.js +1 -1
  48. package/modern/components/pagination/index.css +14 -13
  49. package/modern/components/pagination/select-field/index.css +4 -4
  50. package/modern/components/pagination/select-field/index.js +1 -1
  51. package/modern/components/table/Component.js +1 -1
  52. package/modern/components/table/index.css +13 -11
  53. package/modern/components/tbody/Component.js +1 -1
  54. package/modern/components/tbody/index.css +2 -2
  55. package/modern/components/tcell/Component.js +1 -1
  56. package/modern/components/tcell/index.css +6 -6
  57. package/modern/components/texpandable-row/Component.js +1 -1
  58. package/modern/components/texpandable-row/index.css +9 -8
  59. package/modern/components/thead/Component.js +1 -1
  60. package/modern/components/thead/index.css +8 -7
  61. package/modern/components/thead-cell/Component.js +1 -1
  62. package/modern/components/thead-cell/index.css +11 -10
  63. package/modern/components/trow/Component.js +1 -1
  64. package/modern/components/trow/index.css +8 -8
  65. package/modern/components/tsortable-head-cell/Component.js +1 -1
  66. package/modern/components/tsortable-head-cell/index.css +10 -9
  67. package/moderncssm/component.d.ts +21 -0
  68. package/moderncssm/component.js +22 -0
  69. package/moderncssm/components/index.d.ts +9 -0
  70. package/moderncssm/components/index.js +9 -0
  71. package/moderncssm/components/pagination/Component.d.ts +26 -0
  72. package/moderncssm/components/pagination/Component.js +33 -0
  73. package/moderncssm/components/pagination/index.d.ts +1 -0
  74. package/moderncssm/components/pagination/index.js +1 -0
  75. package/moderncssm/components/pagination/index.module.css +44 -0
  76. package/moderncssm/components/pagination/select-field/index.d.ts +3 -0
  77. package/moderncssm/components/pagination/select-field/index.js +12 -0
  78. package/moderncssm/components/pagination/select-field/index.module.css +11 -0
  79. package/moderncssm/components/table/Component.d.ts +72 -0
  80. package/moderncssm/components/table/Component.js +32 -0
  81. package/moderncssm/components/table/index.d.ts +1 -0
  82. package/moderncssm/components/table/index.js +1 -0
  83. package/moderncssm/components/table/index.module.css +33 -0
  84. package/moderncssm/components/table/utils.d.ts +5 -0
  85. package/moderncssm/components/table/utils.js +17 -0
  86. package/moderncssm/components/table-context/index.d.ts +20 -0
  87. package/moderncssm/components/table-context/index.js +12 -0
  88. package/moderncssm/components/tbody/Component.d.ts +15 -0
  89. package/moderncssm/components/tbody/Component.js +7 -0
  90. package/moderncssm/components/tbody/index.d.ts +1 -0
  91. package/moderncssm/components/tbody/index.js +1 -0
  92. package/moderncssm/components/tbody/index.module.css +6 -0
  93. package/moderncssm/components/tcell/Component.d.ts +19 -0
  94. package/moderncssm/components/tcell/Component.js +17 -0
  95. package/moderncssm/components/tcell/index.d.ts +1 -0
  96. package/moderncssm/components/tcell/index.js +1 -0
  97. package/moderncssm/components/tcell/index.module.css +37 -0
  98. package/moderncssm/components/texpandable-row/Component.d.ts +12 -0
  99. package/moderncssm/components/texpandable-row/Component.js +24 -0
  100. package/moderncssm/components/texpandable-row/index.d.ts +1 -0
  101. package/moderncssm/components/texpandable-row/index.js +1 -0
  102. package/moderncssm/components/texpandable-row/index.module.css +21 -0
  103. package/moderncssm/components/thead/Component.d.ts +19 -0
  104. package/moderncssm/components/thead/Component.js +8 -0
  105. package/moderncssm/components/thead/index.d.ts +1 -0
  106. package/moderncssm/components/thead/index.js +1 -0
  107. package/moderncssm/components/thead/index.module.css +32 -0
  108. package/moderncssm/components/thead-cell/Component.d.ts +28 -0
  109. package/moderncssm/components/thead-cell/Component.js +15 -0
  110. package/moderncssm/components/thead-cell/index.d.ts +1 -0
  111. package/moderncssm/components/thead-cell/index.js +1 -0
  112. package/moderncssm/components/thead-cell/index.module.css +51 -0
  113. package/moderncssm/components/trow/Component.d.ts +29 -0
  114. package/moderncssm/components/trow/Component.js +11 -0
  115. package/moderncssm/components/trow/index.d.ts +1 -0
  116. package/moderncssm/components/trow/index.js +1 -0
  117. package/moderncssm/components/trow/index.module.css +33 -0
  118. package/moderncssm/components/tsortable-head-cell/Component.d.ts +10 -0
  119. package/moderncssm/components/tsortable-head-cell/Component.js +26 -0
  120. package/moderncssm/components/tsortable-head-cell/index.d.ts +1 -0
  121. package/moderncssm/components/tsortable-head-cell/index.js +1 -0
  122. package/moderncssm/components/tsortable-head-cell/index.module.css +41 -0
  123. package/moderncssm/components/tsortable-head-cell/sort-icon-asc.d.ts +5 -0
  124. package/moderncssm/components/tsortable-head-cell/sort-icon-asc.js +6 -0
  125. package/moderncssm/components/tsortable-head-cell/sort-icon-desc.d.ts +5 -0
  126. package/moderncssm/components/tsortable-head-cell/sort-icon-desc.js +6 -0
  127. package/moderncssm/components/tsortable-head-cell/sort-icon-unset.d.ts +5 -0
  128. package/moderncssm/components/tsortable-head-cell/sort-icon-unset.js +6 -0
  129. package/moderncssm/index.d.ts +1 -0
  130. package/moderncssm/index.js +1 -0
  131. package/moderncssm/typings.d.ts +2 -0
  132. package/moderncssm/typings.js +1 -0
  133. package/moderncssm/utils.d.ts +4 -0
  134. package/moderncssm/utils.js +8 -0
  135. package/package.json +6 -6
  136. package/src/components/pagination/index.module.css +5 -5
  137. package/src/components/pagination/select-field/index.module.css +1 -1
  138. package/src/components/table/index.module.css +5 -5
  139. package/src/components/tbody/index.module.css +1 -1
  140. package/src/components/tcell/index.module.css +1 -1
  141. package/src/components/texpandable-row/index.module.css +4 -4
  142. package/src/components/thead/index.module.css +2 -2
  143. package/src/components/thead-cell/index.module.css +2 -2
  144. package/src/components/trow/index.module.css +1 -1
  145. package/src/components/tsortable-head-cell/index.module.css +2 -2
@@ -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: var(--gap-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: var(--gap-0) var(--gap-8);
23
+ min-width: 32px
24
+ }
25
+
26
+ .tag.tag:last-child {
27
+ margin-right: var(--gap-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) var(--gap-0);
40
+ }
41
+
42
+ .option {
43
+ min-width: 208px;
44
+ }
@@ -0,0 +1,3 @@
1
+ import { SelectProps } from "@alfalab/core-components-select";
2
+ declare const CustomSelectField: SelectProps['Field'];
3
+ export { CustomSelectField };
@@ -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,11 @@
1
+ /* */
2
+
3
+ .field svg {
4
+ width: 18px;
5
+ height: 18px;
6
+ }
7
+
8
+ .open,
9
+ .open:hover {
10
+ background-color: var(--color-light-neutral-translucent-200-hover);
11
+ }
@@ -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: var(--gap-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-8);
12
+ overflow: auto;
13
+ }
14
+
15
+ .stickyHeader {
16
+ max-height: 100%;
17
+ }
18
+
19
+ .hasPagination {
20
+ padding-bottom: var(--gap-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: var(--gap-0);
33
+ }
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import React from 'react';
3
+ import { THeadCellProps } from "../thead-cell/index";
4
+ declare function findAllHeadCellsProps(children: React.ReactElement | React.ReactElement[]): THeadCellProps[];
5
+ export { findAllHeadCellsProps };
@@ -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,6 @@
1
+ /* */
2
+
3
+ .component {
4
+ width: 100%;
5
+ box-sizing: border-box;
6
+ }
@@ -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';
@@ -0,0 +1,21 @@
1
+ /* */
2
+
3
+ .row {
4
+ cursor: pointer;
5
+ }
6
+
7
+ .selected.expanded {
8
+ background-color: inherit;
9
+ }
10
+
11
+ .expanded:hover {
12
+ background-color: inherit;
13
+ }
14
+
15
+ .expandable td {
16
+ margin: var(--gap-0);
17
+ padding-top: var(--gap-0);
18
+ padding-bottom: var(--gap-0);
19
+ border: none;
20
+ height: auto;
21
+ }
@@ -0,0 +1,19 @@
1
+ /// <reference types="react" />
2
+ import React from 'react';
3
+ import { HTMLAttributes } from "react";
4
+ type THeadProps = HTMLAttributes<HTMLTableSectionElement> & {
5
+ /**
6
+ * Дополнительный класс
7
+ */
8
+ className?: string;
9
+ /**
10
+ * Дополнительный класс для tr
11
+ */
12
+ rowClassName?: string;
13
+ /**
14
+ * Идентификатор для систем автоматизированного тестирования
15
+ */
16
+ dataTestId?: string;
17
+ };
18
+ declare const THead: React.FC<THeadProps>;
19
+ export { THeadProps, THead };
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import cn from 'classnames';
3
+ import styles from './index.module.css';
4
+
5
+ const THead = ({ className, rowClassName, children, dataTestId, ...restProps }) => (React.createElement("thead", { className: cn(styles.component, className), "data-test-id": dataTestId, ...restProps },
6
+ React.createElement("tr", { className: cn(styles.row, rowClassName) }, children)));
7
+
8
+ export { THead };
@@ -0,0 +1 @@
1
+ export * from "./Component";
@@ -0,0 +1 @@
1
+ export { THead } from './Component.js';
@@ -0,0 +1,32 @@
1
+ /* */
2
+
3
+ .component {
4
+ position: relative;
5
+ width: 100%;
6
+ box-sizing: border-box
7
+ }
8
+
9
+ .component th:not(:last-child):not(:empty):after {
10
+ transition: opacity 0.2s;
11
+ position: absolute;
12
+ content: '';
13
+ display: block;
14
+
15
+ width: 1px;
16
+ right: var(--gap-0);
17
+ top: var(--gap-8);
18
+ bottom: var(--gap-8);
19
+ background-color: var(--color-light-neutral-400);
20
+ }
21
+
22
+ .component th:after {
23
+ opacity: 0;
24
+ }
25
+
26
+ .component:hover th:after {
27
+ opacity: 1;
28
+ }
29
+
30
+ .row {
31
+ height: 72px;
32
+ }
@@ -0,0 +1,28 @@
1
+ /// <reference types="react" />
2
+ import React from 'react';
3
+ import { ThHTMLAttributes } from "react";
4
+ import { TextAlignProperty } from "../../typings";
5
+ type THeadCellProps = ThHTMLAttributes<HTMLHeadingElement> & {
6
+ /**
7
+ * Дополнительный класс
8
+ */
9
+ className?: string;
10
+ /**
11
+ * Ширина колонки
12
+ */
13
+ width?: string | number;
14
+ /**
15
+ * Скрытие колонки
16
+ */
17
+ hidden?: boolean;
18
+ /**
19
+ * Выравнивание текста в колонке
20
+ */
21
+ textAlign?: TextAlignProperty;
22
+ /**
23
+ * Идентификатор для систем автоматизированного тестирования
24
+ */
25
+ dataTestId?: string;
26
+ };
27
+ declare const THeadCell: ({ children, className, dataTestId, style, width, textAlign, hidden, ...restProps }: THeadCellProps) => React.JSX.Element | null;
28
+ export { THeadCellProps, THeadCell };
@@ -0,0 +1,15 @@
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 THeadCell = ({ children, className, dataTestId, style, width, textAlign, hidden, ...restProps }) => {
7
+ const { compactHorizontal, stickyHeader } = useContext(TableContext);
8
+ if (hidden)
9
+ return null;
10
+ return (React.createElement("th", { className: cn(styles.component, className, compactHorizontal && styles.compactHorizontal, {
11
+ [styles.stickyHeader]: stickyHeader,
12
+ }), style: { ...style, width, textAlign }, "data-test-id": dataTestId, ...restProps }, children));
13
+ };
14
+
15
+ export { THeadCell };
@@ -0,0 +1 @@
1
+ export * from "./Component";