@alfalab/core-components-table 2.2.41 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Component-5e1b8383.d.ts +5 -0
- package/Component-63dec22f.d.ts +167 -0
- package/Component-89a3cf4c.d.ts +6 -0
- package/Component-bdb4c6b9.d.ts +12 -0
- package/Component-e81c389f.d.ts +5 -0
- package/Component-ebda875c.d.ts +12 -0
- package/Component.desktop-63dec22f.d.ts +6 -0
- package/Component.desktop-785df74d.d.ts +6 -0
- package/Component.mobile-d7e9f69d.d.ts +6 -0
- package/Component.mobile-ebda875c.d.ts +6 -0
- package/Component.responsive-785df74d.d.ts +26 -0
- package/Context-bdb4c6b9.d.ts +4 -0
- package/ResponsiveContext-baf4875b.d.ts +5 -0
- package/component-89a3cf4c.d.ts +44 -0
- package/component.d.ts +5 -5
- package/component.js +1 -1
- package/components/index.js +1 -1
- package/components/pagination/Component.js +3 -3
- package/components/pagination/index.css +8 -8
- package/components/pagination/index.js +1 -1
- 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 +7 -7
- package/components/tbody/Component.js +1 -1
- package/components/tbody/index.css +2 -2
- package/components/tcell/Component.d.ts +3 -2
- package/components/tcell/Component.js +1 -1
- package/components/tcell/index.css +6 -6
- package/components/texpandable-row/Component.d.ts +3 -2
- 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 +6 -6
- package/components/thead-cell/Component.d.ts +3 -2
- package/components/thead-cell/Component.js +1 -1
- package/components/thead-cell/index.css +10 -9
- package/components/trow/Component.d.ts +1 -1
- package/components/trow/Component.js +1 -1
- package/components/trow/index.css +8 -8
- package/components/tsortable-head-cell/Component.d.ts +2 -1
- package/components/tsortable-head-cell/Component.js +2 -2
- package/components/tsortable-head-cell/index.css +8 -10
- package/consts-f777ba1a.d.ts +2 -0
- package/cssm/Component-5e1b8383.d.ts +5 -0
- package/cssm/Component-63dec22f.d.ts +167 -0
- package/cssm/Component-89a3cf4c.d.ts +6 -0
- package/cssm/Component-bdb4c6b9.d.ts +12 -0
- package/cssm/Component-e81c389f.d.ts +5 -0
- package/cssm/Component-ebda875c.d.ts +12 -0
- package/cssm/Component.desktop-63dec22f.d.ts +6 -0
- package/cssm/Component.desktop-785df74d.d.ts +6 -0
- package/cssm/Component.mobile-d7e9f69d.d.ts +6 -0
- package/cssm/Component.mobile-ebda875c.d.ts +6 -0
- package/cssm/Component.responsive-785df74d.d.ts +26 -0
- package/cssm/Context-bdb4c6b9.d.ts +4 -0
- package/cssm/ResponsiveContext-baf4875b.d.ts +5 -0
- package/cssm/component-89a3cf4c.d.ts +44 -0
- package/cssm/component.d.ts +5 -5
- package/cssm/component.js +1 -1
- package/cssm/components/index.js +1 -1
- package/cssm/components/pagination/Component.js +2 -2
- package/cssm/components/pagination/index.js +1 -1
- package/cssm/components/tcell/Component.d.ts +3 -2
- package/cssm/components/texpandable-row/Component.d.ts +3 -2
- package/cssm/components/thead-cell/Component.d.ts +3 -2
- package/cssm/components/thead-cell/index.module.css +2 -1
- package/cssm/components/trow/Component.d.ts +1 -1
- package/cssm/components/tsortable-head-cell/Component.d.ts +2 -1
- package/cssm/components/tsortable-head-cell/Component.js +1 -1
- package/cssm/components/tsortable-head-cell/index.module.css +0 -2
- package/cssm/consts-f777ba1a.d.ts +2 -0
- package/cssm/desktop-63dec22f.d.ts +6 -0
- package/cssm/hook-5e1b8383.d.ts +75 -0
- package/cssm/hook-ebda875c.d.ts +48 -0
- package/cssm/index-136acbb1.d.ts +28 -0
- package/cssm/index-3109f463.d.ts +62 -0
- package/cssm/index-425c8522.d.ts +6 -0
- package/cssm/index-89a3cf4c.d.ts +3 -0
- package/cssm/index-bdb4c6b9.d.ts +2 -0
- package/cssm/index-c44170fe.d.ts +21 -0
- package/cssm/index-e81c389f.d.ts +3 -0
- package/cssm/index-ebda875c.d.ts +81 -0
- package/cssm/index-f12ee135.d.ts +3 -0
- package/cssm/index.js +1 -1
- package/cssm/mobile-96988a65.d.ts +2 -0
- package/cssm/types-425c8522.d.ts +259 -0
- package/cssm/types-ebda875c.d.ts +113 -0
- package/cssm/typings-5e1b8383.d.ts +550 -0
- package/cssm/typings-9211a437.d.ts +95 -0
- package/cssm/typings-bdb4c6b9.d.ts +52 -0
- package/cssm/utils-1574ad8b.d.ts +29 -0
- package/cssm/utils-49cc3c24.d.ts +8 -0
- package/cssm/utils-5e1b8383.d.ts +38 -0
- package/desktop-63dec22f.d.ts +6 -0
- package/esm/Component-5e1b8383.d.ts +5 -0
- package/esm/Component-63dec22f.d.ts +167 -0
- package/esm/Component-89a3cf4c.d.ts +6 -0
- package/esm/Component-bdb4c6b9.d.ts +12 -0
- package/esm/Component-e81c389f.d.ts +5 -0
- package/esm/Component-ebda875c.d.ts +12 -0
- package/esm/Component.desktop-63dec22f.d.ts +6 -0
- package/esm/Component.desktop-785df74d.d.ts +6 -0
- package/esm/Component.mobile-d7e9f69d.d.ts +6 -0
- package/esm/Component.mobile-ebda875c.d.ts +6 -0
- package/esm/Component.responsive-785df74d.d.ts +26 -0
- package/esm/Context-bdb4c6b9.d.ts +4 -0
- package/esm/ResponsiveContext-baf4875b.d.ts +5 -0
- package/esm/component-89a3cf4c.d.ts +44 -0
- package/esm/component.d.ts +5 -5
- package/esm/component.js +1 -1
- package/esm/components/index.js +1 -1
- package/esm/components/pagination/Component.js +3 -3
- package/esm/components/pagination/index.css +8 -8
- package/esm/components/pagination/index.js +1 -1
- 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 +7 -7
- package/esm/components/tbody/Component.js +1 -1
- package/esm/components/tbody/index.css +2 -2
- package/esm/components/tcell/Component.d.ts +3 -2
- package/esm/components/tcell/Component.js +1 -1
- package/esm/components/tcell/index.css +6 -6
- package/esm/components/texpandable-row/Component.d.ts +3 -2
- 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 +6 -6
- package/esm/components/thead-cell/Component.d.ts +3 -2
- package/esm/components/thead-cell/Component.js +1 -1
- package/esm/components/thead-cell/index.css +10 -9
- package/esm/components/trow/Component.d.ts +1 -1
- package/esm/components/trow/Component.js +1 -1
- package/esm/components/trow/index.css +8 -8
- package/esm/components/tsortable-head-cell/Component.d.ts +2 -1
- package/esm/components/tsortable-head-cell/Component.js +2 -2
- package/esm/components/tsortable-head-cell/index.css +8 -10
- package/esm/consts-f777ba1a.d.ts +2 -0
- package/esm/desktop-63dec22f.d.ts +6 -0
- package/esm/hook-5e1b8383.d.ts +75 -0
- package/esm/hook-ebda875c.d.ts +48 -0
- package/esm/index-136acbb1.d.ts +28 -0
- package/esm/index-3109f463.d.ts +62 -0
- package/esm/index-425c8522.d.ts +6 -0
- package/esm/index-89a3cf4c.d.ts +3 -0
- package/esm/index-bdb4c6b9.d.ts +2 -0
- package/esm/index-c44170fe.d.ts +21 -0
- package/esm/index-e81c389f.d.ts +3 -0
- package/esm/index-ebda875c.d.ts +81 -0
- package/esm/index-f12ee135.d.ts +3 -0
- package/esm/index.js +1 -1
- package/esm/mobile-96988a65.d.ts +2 -0
- package/esm/types-425c8522.d.ts +259 -0
- package/esm/types-ebda875c.d.ts +113 -0
- package/esm/typings-5e1b8383.d.ts +550 -0
- package/esm/typings-9211a437.d.ts +95 -0
- package/esm/typings-bdb4c6b9.d.ts +52 -0
- package/esm/utils-1574ad8b.d.ts +29 -0
- package/esm/utils-49cc3c24.d.ts +8 -0
- package/esm/utils-5e1b8383.d.ts +38 -0
- package/hook-5e1b8383.d.ts +75 -0
- package/hook-ebda875c.d.ts +48 -0
- package/index-136acbb1.d.ts +28 -0
- package/index-3109f463.d.ts +62 -0
- package/index-425c8522.d.ts +6 -0
- package/index-89a3cf4c.d.ts +3 -0
- package/index-bdb4c6b9.d.ts +2 -0
- package/index-c44170fe.d.ts +21 -0
- package/index-e81c389f.d.ts +3 -0
- package/index-ebda875c.d.ts +81 -0
- package/index-f12ee135.d.ts +3 -0
- package/index.js +1 -1
- package/mobile-96988a65.d.ts +2 -0
- package/modern/Component-5e1b8383.d.ts +5 -0
- package/modern/Component-63dec22f.d.ts +167 -0
- package/modern/Component-89a3cf4c.d.ts +6 -0
- package/modern/Component-bdb4c6b9.d.ts +12 -0
- package/modern/Component-e81c389f.d.ts +5 -0
- package/modern/Component-ebda875c.d.ts +12 -0
- package/modern/Component.desktop-63dec22f.d.ts +6 -0
- package/modern/Component.desktop-785df74d.d.ts +6 -0
- package/modern/Component.mobile-d7e9f69d.d.ts +6 -0
- package/modern/Component.mobile-ebda875c.d.ts +6 -0
- package/modern/Component.responsive-785df74d.d.ts +26 -0
- package/modern/Context-bdb4c6b9.d.ts +4 -0
- package/modern/ResponsiveContext-baf4875b.d.ts +5 -0
- package/modern/component-89a3cf4c.d.ts +44 -0
- package/modern/component.d.ts +5 -5
- package/modern/component.js +1 -1
- package/modern/components/index.js +1 -1
- package/modern/components/pagination/Component.js +3 -3
- package/modern/components/pagination/index.css +8 -8
- package/modern/components/pagination/index.js +1 -1
- 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 +7 -7
- package/modern/components/tbody/Component.js +1 -1
- package/modern/components/tbody/index.css +2 -2
- package/modern/components/tcell/Component.d.ts +3 -2
- package/modern/components/tcell/Component.js +1 -1
- package/modern/components/tcell/index.css +6 -6
- package/modern/components/texpandable-row/Component.d.ts +3 -2
- 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 +6 -6
- package/modern/components/thead-cell/Component.d.ts +3 -2
- package/modern/components/thead-cell/Component.js +1 -1
- package/modern/components/thead-cell/index.css +10 -9
- package/modern/components/trow/Component.d.ts +1 -1
- package/modern/components/trow/Component.js +1 -1
- package/modern/components/trow/index.css +8 -8
- package/modern/components/tsortable-head-cell/Component.d.ts +2 -1
- package/modern/components/tsortable-head-cell/Component.js +2 -2
- package/modern/components/tsortable-head-cell/index.css +8 -10
- package/modern/consts-f777ba1a.d.ts +2 -0
- package/modern/desktop-63dec22f.d.ts +6 -0
- package/modern/hook-5e1b8383.d.ts +75 -0
- package/modern/hook-ebda875c.d.ts +48 -0
- package/modern/index-136acbb1.d.ts +28 -0
- package/modern/index-3109f463.d.ts +62 -0
- package/modern/index-425c8522.d.ts +6 -0
- package/modern/index-89a3cf4c.d.ts +3 -0
- package/modern/index-bdb4c6b9.d.ts +2 -0
- package/modern/index-c44170fe.d.ts +21 -0
- package/modern/index-e81c389f.d.ts +3 -0
- package/modern/index-ebda875c.d.ts +81 -0
- package/modern/index-f12ee135.d.ts +3 -0
- package/modern/index.js +1 -1
- package/modern/mobile-96988a65.d.ts +2 -0
- package/modern/types-425c8522.d.ts +259 -0
- package/modern/types-ebda875c.d.ts +113 -0
- package/modern/typings-5e1b8383.d.ts +550 -0
- package/modern/typings-9211a437.d.ts +95 -0
- package/modern/typings-bdb4c6b9.d.ts +52 -0
- package/modern/utils-1574ad8b.d.ts +29 -0
- package/modern/utils-49cc3c24.d.ts +8 -0
- package/modern/utils-5e1b8383.d.ts +38 -0
- package/package.json +4 -4
- package/src/component.tsx +22 -0
- package/src/components/index.ts +9 -0
- package/src/components/pagination/Component.tsx +104 -0
- package/src/components/pagination/index.module.css +38 -0
- package/src/components/pagination/index.ts +1 -0
- package/src/components/pagination/select-field/index.module.css +13 -0
- package/src/components/pagination/select-field/index.tsx +25 -0
- package/src/components/table/Component.tsx +109 -0
- package/src/components/table/index.module.css +35 -0
- package/src/components/table/index.ts +1 -0
- package/src/components/table/utils.ts +19 -0
- package/src/components/table-context/index.tsx +28 -0
- package/src/components/tbody/Component.tsx +22 -0
- package/src/components/tbody/index.module.css +6 -0
- package/src/components/tbody/index.ts +1 -0
- package/src/components/tcell/Component.tsx +56 -0
- package/src/components/tcell/index.module.css +35 -0
- package/src/components/tcell/index.ts +1 -0
- package/src/components/texpandable-row/Component.tsx +58 -0
- package/src/components/texpandable-row/index.module.css +25 -0
- package/src/components/texpandable-row/index.ts +1 -0
- package/src/components/thead/Component.tsx +33 -0
- package/src/components/thead/index.module.css +32 -0
- package/src/components/thead/index.ts +1 -0
- package/src/components/thead-cell/Component.tsx +67 -0
- package/src/components/thead-cell/index.module.css +47 -0
- package/src/components/thead-cell/index.ts +1 -0
- package/src/components/trow/Component.tsx +56 -0
- package/src/components/trow/index.module.css +35 -0
- package/src/components/trow/index.ts +1 -0
- package/src/components/tsortable-head-cell/Component.tsx +50 -0
- package/src/components/tsortable-head-cell/index.module.css +41 -0
- package/src/components/tsortable-head-cell/index.ts +1 -0
- package/src/components/tsortable-head-cell/sort-icon-asc.tsx +16 -0
- package/src/components/tsortable-head-cell/sort-icon-desc.tsx +16 -0
- package/src/components/tsortable-head-cell/sort-icon-unset.tsx +16 -0
- package/src/index.ts +1 -0
- package/src/typings.ts +8 -0
- package/src/utils.ts +6 -0
- package/types-425c8522.d.ts +259 -0
- package/types-ebda875c.d.ts +113 -0
- package/typings-5e1b8383.d.ts +550 -0
- package/typings-9211a437.d.ts +95 -0
- package/typings-bdb4c6b9.d.ts +52 -0
- package/utils-1574ad8b.d.ts +29 -0
- package/utils-49cc3c24.d.ts +8 -0
- package/utils-5e1b8383.d.ts +38 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React, { ReactNode, useState } from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
|
|
4
|
+
import { TRow, TRowProps } from '../trow';
|
|
5
|
+
|
|
6
|
+
import styles from './index.module.css';
|
|
7
|
+
|
|
8
|
+
export type TExpandableRowProps = TRowProps & {
|
|
9
|
+
defaultExpanded?: boolean;
|
|
10
|
+
|
|
11
|
+
expanded?: boolean;
|
|
12
|
+
|
|
13
|
+
onToggle?: (expanded: boolean) => void;
|
|
14
|
+
|
|
15
|
+
renderContent: (expanded: boolean) => ReactNode;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const TExpandableRow = ({
|
|
19
|
+
className,
|
|
20
|
+
selected,
|
|
21
|
+
expanded,
|
|
22
|
+
defaultExpanded = false,
|
|
23
|
+
onToggle = () => null,
|
|
24
|
+
renderContent = () => null,
|
|
25
|
+
...restProps
|
|
26
|
+
}: TExpandableRowProps) => {
|
|
27
|
+
const [expandedState, setExpandedState] = useState<boolean>(defaultExpanded);
|
|
28
|
+
|
|
29
|
+
const uncontrolled = expanded === undefined;
|
|
30
|
+
|
|
31
|
+
const isExpanded = (uncontrolled ? expandedState : expanded) as boolean;
|
|
32
|
+
|
|
33
|
+
const handleToggle = () => {
|
|
34
|
+
if (uncontrolled) {
|
|
35
|
+
setExpandedState(!isExpanded);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
onToggle(isExpanded);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<React.Fragment>
|
|
43
|
+
<TRow
|
|
44
|
+
className={cn(styles.row, className, {
|
|
45
|
+
[styles.selected]: selected,
|
|
46
|
+
[styles.expanded]: isExpanded,
|
|
47
|
+
})}
|
|
48
|
+
selected={selected}
|
|
49
|
+
onClick={handleToggle}
|
|
50
|
+
{...restProps}
|
|
51
|
+
/>
|
|
52
|
+
|
|
53
|
+
<tr className={cn(styles.expandable, { [styles.expanded]: isExpanded })}>
|
|
54
|
+
{renderContent(isExpanded)}
|
|
55
|
+
</tr>
|
|
56
|
+
</React.Fragment>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
@import '@alfalab/core-components-themes/src/default.css';
|
|
2
|
+
|
|
3
|
+
.row {
|
|
4
|
+
cursor: pointer;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.selected.expanded {
|
|
8
|
+
background-color: inherit;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.expanded {
|
|
12
|
+
&:hover {
|
|
13
|
+
background-color: inherit;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.expandable {
|
|
18
|
+
& td {
|
|
19
|
+
margin: 0;
|
|
20
|
+
padding-top: 0;
|
|
21
|
+
padding-bottom: 0;
|
|
22
|
+
border: none;
|
|
23
|
+
height: auto;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Component';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React, { HTMLAttributes } from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
|
|
4
|
+
import styles from './index.module.css';
|
|
5
|
+
|
|
6
|
+
export type THeadProps = HTMLAttributes<HTMLTableSectionElement> & {
|
|
7
|
+
/**
|
|
8
|
+
* Дополнительный класс
|
|
9
|
+
*/
|
|
10
|
+
className?: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Дополнительный класс для tr
|
|
14
|
+
*/
|
|
15
|
+
rowClassName?: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Идентификатор для систем автоматизированного тестирования
|
|
19
|
+
*/
|
|
20
|
+
dataTestId?: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const THead: React.FC<THeadProps> = ({
|
|
24
|
+
className,
|
|
25
|
+
rowClassName,
|
|
26
|
+
children,
|
|
27
|
+
dataTestId,
|
|
28
|
+
...restProps
|
|
29
|
+
}) => (
|
|
30
|
+
<thead className={cn(styles.component, className)} data-test-id={dataTestId} {...restProps}>
|
|
31
|
+
<tr className={cn(styles.row, rowClassName)}>{children}</tr>
|
|
32
|
+
</thead>
|
|
33
|
+
);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
@import '@alfalab/core-components-themes/src/default.css';
|
|
2
|
+
|
|
3
|
+
.component {
|
|
4
|
+
position: relative;
|
|
5
|
+
width: 100%;
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
|
|
8
|
+
& th:not(:last-child):not(:empty):after {
|
|
9
|
+
transition: opacity 0.2s;
|
|
10
|
+
position: absolute;
|
|
11
|
+
content: '';
|
|
12
|
+
display: block;
|
|
13
|
+
|
|
14
|
+
width: 1px;
|
|
15
|
+
right: 0;
|
|
16
|
+
top: var(--gap-xs);
|
|
17
|
+
bottom: var(--gap-xs);
|
|
18
|
+
background-color: var(--color-light-graphic-quaternary);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
& th:after {
|
|
22
|
+
opacity: 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&:hover th:after {
|
|
26
|
+
opacity: 1;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.row {
|
|
31
|
+
height: 72px;
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Component';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React, { ThHTMLAttributes, useContext } from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
|
|
4
|
+
import { TextAlignProperty } from '../../typings';
|
|
5
|
+
import { TableContext } from '../table-context';
|
|
6
|
+
|
|
7
|
+
import styles from './index.module.css';
|
|
8
|
+
|
|
9
|
+
export type THeadCellProps = ThHTMLAttributes<HTMLHeadingElement> & {
|
|
10
|
+
/**
|
|
11
|
+
* Дополнительный класс
|
|
12
|
+
*/
|
|
13
|
+
className?: string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Ширина колонки
|
|
17
|
+
*/
|
|
18
|
+
width?: string | number;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Скрытие колонки
|
|
22
|
+
*/
|
|
23
|
+
hidden?: boolean;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Выравнивание текста в колонке
|
|
27
|
+
*/
|
|
28
|
+
textAlign?: TextAlignProperty;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Идентификатор для систем автоматизированного тестирования
|
|
32
|
+
*/
|
|
33
|
+
dataTestId?: string;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const THeadCell = ({
|
|
37
|
+
children,
|
|
38
|
+
className,
|
|
39
|
+
dataTestId,
|
|
40
|
+
style,
|
|
41
|
+
width,
|
|
42
|
+
textAlign,
|
|
43
|
+
hidden,
|
|
44
|
+
...restProps
|
|
45
|
+
}: THeadCellProps) => {
|
|
46
|
+
const { compactHorizontal, stickyHeader } = useContext(TableContext);
|
|
47
|
+
|
|
48
|
+
if (hidden) return null;
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<th
|
|
52
|
+
className={cn(
|
|
53
|
+
styles.component,
|
|
54
|
+
className,
|
|
55
|
+
compactHorizontal && styles.compactHorizontal,
|
|
56
|
+
{
|
|
57
|
+
[styles.stickyHeader]: stickyHeader,
|
|
58
|
+
},
|
|
59
|
+
)}
|
|
60
|
+
style={{ ...style, width, textAlign }}
|
|
61
|
+
data-test-id={dataTestId}
|
|
62
|
+
{...restProps}
|
|
63
|
+
>
|
|
64
|
+
{children}
|
|
65
|
+
</th>
|
|
66
|
+
);
|
|
67
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
@import '@alfalab/core-components-themes/src/default.css';
|
|
2
|
+
|
|
3
|
+
.component {
|
|
4
|
+
@mixin paragraph_caps;
|
|
5
|
+
|
|
6
|
+
line-height: 20px;
|
|
7
|
+
text-align: left;
|
|
8
|
+
color: var(--color-light-text-primary);
|
|
9
|
+
padding: var(--gap-2xl) var(--gap-s) var(--gap-2xs);
|
|
10
|
+
border-bottom: 1px solid var(--color-light-border-primary);
|
|
11
|
+
background: var(--color-light-bg-primary);
|
|
12
|
+
vertical-align: top;
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
|
|
15
|
+
&:first-child {
|
|
16
|
+
padding-left: var(--gap-m);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&:last-child {
|
|
20
|
+
padding-right: var(--gap-m);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&:not(.stickyHeader) {
|
|
24
|
+
position: relative;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.sortable {
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.sorted {
|
|
33
|
+
color: var(--color-light-text-primary);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.stickyHeader {
|
|
37
|
+
top: 0;
|
|
38
|
+
position: sticky;
|
|
39
|
+
box-shadow: inset 0 -1px 0 0 rgba(11, 31, 53, 0.16);
|
|
40
|
+
border: none;
|
|
41
|
+
z-index: 1;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.compactHorizontal {
|
|
45
|
+
padding-left: 6px;
|
|
46
|
+
padding-right: 6px;
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Component';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React, { HTMLAttributes } from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
|
|
4
|
+
import { TCell, TCellProps } from '../tcell';
|
|
5
|
+
|
|
6
|
+
import styles from './index.module.css';
|
|
7
|
+
|
|
8
|
+
type TCellElement = React.ReactElement<TCellProps, typeof TCell>;
|
|
9
|
+
|
|
10
|
+
export type TRowProps = HTMLAttributes<HTMLTableRowElement> & {
|
|
11
|
+
/**
|
|
12
|
+
* Компоненты ячеек
|
|
13
|
+
*/
|
|
14
|
+
children: TCellElement | TCellElement[];
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Дополнительный класс
|
|
18
|
+
*/
|
|
19
|
+
className?: string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Стиль выбранной строки
|
|
23
|
+
*/
|
|
24
|
+
selected?: boolean;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Убирает нижнюю границу
|
|
28
|
+
*/
|
|
29
|
+
withoutBorder?: boolean;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Идентификатор для систем автоматизированного тестирования
|
|
33
|
+
*/
|
|
34
|
+
dataTestId?: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const TRow = ({
|
|
38
|
+
children,
|
|
39
|
+
className,
|
|
40
|
+
selected,
|
|
41
|
+
withoutBorder,
|
|
42
|
+
dataTestId,
|
|
43
|
+
...restProps
|
|
44
|
+
}: TRowProps) => (
|
|
45
|
+
<tr
|
|
46
|
+
className={cn(styles.component, className, {
|
|
47
|
+
[styles.clickable]: typeof restProps.onClick !== 'undefined',
|
|
48
|
+
[styles.selected]: selected,
|
|
49
|
+
[styles.withoutBorder]: withoutBorder,
|
|
50
|
+
})}
|
|
51
|
+
data-test-id={dataTestId}
|
|
52
|
+
{...restProps}
|
|
53
|
+
>
|
|
54
|
+
{React.Children.map(children, (child, index) => React.cloneElement(child, { index }))}
|
|
55
|
+
</tr>
|
|
56
|
+
);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
@import '@alfalab/core-components-themes/src/default.css';
|
|
2
|
+
|
|
3
|
+
.component {
|
|
4
|
+
padding-top: 1px;
|
|
5
|
+
width: 100%;
|
|
6
|
+
transition: background-color 0.2s;
|
|
7
|
+
box-sizing: border-box;
|
|
8
|
+
background: var(--color-light-bg-primary);
|
|
9
|
+
|
|
10
|
+
&:first-child td {
|
|
11
|
+
border-top: 0;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.withoutBorder {
|
|
16
|
+
& td {
|
|
17
|
+
border: none;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.clickable {
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
|
|
24
|
+
&:hover {
|
|
25
|
+
background-color: var(--color-light-bg-secondary);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.selected {
|
|
30
|
+
background-color: #f2f8ff; /* нет цвета в палитре */
|
|
31
|
+
|
|
32
|
+
&:hover {
|
|
33
|
+
background-color: var(--color-static-graphic-solitude);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Component';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
|
|
4
|
+
import { THeadCell, THeadCellProps } from '../thead-cell';
|
|
5
|
+
|
|
6
|
+
import { SortIconAsc } from './sort-icon-asc';
|
|
7
|
+
import { SortIconDesc } from './sort-icon-desc';
|
|
8
|
+
import { SortIconUnset } from './sort-icon-unset';
|
|
9
|
+
|
|
10
|
+
import styles from './index.module.css';
|
|
11
|
+
|
|
12
|
+
export type TSortableHeadCellProps = THeadCellProps & {
|
|
13
|
+
isSortedDesc?: boolean;
|
|
14
|
+
defaultIsSortedDesc?: boolean;
|
|
15
|
+
onSort?: () => void;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const TSortableHeadCell = ({
|
|
19
|
+
children,
|
|
20
|
+
className,
|
|
21
|
+
defaultIsSortedDesc,
|
|
22
|
+
isSortedDesc,
|
|
23
|
+
textAlign,
|
|
24
|
+
onSort,
|
|
25
|
+
...restProps
|
|
26
|
+
}: TSortableHeadCellProps) => {
|
|
27
|
+
const SortIcon = useMemo(() => {
|
|
28
|
+
let value = isSortedDesc;
|
|
29
|
+
|
|
30
|
+
if (value === undefined) value = defaultIsSortedDesc;
|
|
31
|
+
|
|
32
|
+
if (typeof value === 'boolean') return value ? SortIconDesc : SortIconAsc;
|
|
33
|
+
|
|
34
|
+
return SortIconUnset;
|
|
35
|
+
}, [defaultIsSortedDesc, isSortedDesc]);
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<THeadCell className={className} {...restProps}>
|
|
39
|
+
<div className={cn(styles.content, { [styles.reverse]: textAlign === 'right' })}>
|
|
40
|
+
{children}
|
|
41
|
+
<SortIcon
|
|
42
|
+
onClick={onSort}
|
|
43
|
+
className={cn(styles.icon, {
|
|
44
|
+
[styles.sorted]: isSortedDesc !== undefined,
|
|
45
|
+
})}
|
|
46
|
+
/>
|
|
47
|
+
</div>
|
|
48
|
+
</THeadCell>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
@import '@alfalab/core-components-themes/src/default.css';
|
|
2
|
+
|
|
3
|
+
.content {
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: flex-start;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.icon {
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
margin-left: var(--gap-xs);
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* иконка сортировки должна быть выровнена по верхнему краю,
|
|
14
|
+
* т.к. текст может быть в две строки
|
|
15
|
+
*/
|
|
16
|
+
margin-top: 1px;
|
|
17
|
+
color: var(--color-light-graphic-secondary);
|
|
18
|
+
transition: color 0.2s ease;
|
|
19
|
+
flex-shrink: 0;
|
|
20
|
+
|
|
21
|
+
&:hover {
|
|
22
|
+
color: var(--color-light-graphic-primary);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.reverse {
|
|
27
|
+
flex-direction: row-reverse;
|
|
28
|
+
|
|
29
|
+
& .icon {
|
|
30
|
+
margin-left: 0;
|
|
31
|
+
margin-right: var(--gap-xs);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.sorted {
|
|
36
|
+
color: var(--color-light-graphic-link);
|
|
37
|
+
|
|
38
|
+
&:hover {
|
|
39
|
+
color: var(--color-light-graphic-link);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Component';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React, { SVGProps } from 'react';
|
|
2
|
+
|
|
3
|
+
export const SortIconAsc: React.FC<SVGProps<SVGSVGElement>> = (props) => (
|
|
4
|
+
<svg
|
|
5
|
+
width='18'
|
|
6
|
+
height='18'
|
|
7
|
+
viewBox='0 0 18 18'
|
|
8
|
+
fill='currentColor'
|
|
9
|
+
xmlns='http://www.w3.org/2000/svg'
|
|
10
|
+
focusable='false'
|
|
11
|
+
role='img'
|
|
12
|
+
{...props}
|
|
13
|
+
>
|
|
14
|
+
<path d='M3.00004 10C3.00004 10 11.4477 10 12 10C12 9.33333 12.0001 8.16667 12.0001 7.5H3.0001C3.00006 8 3.0001 9.5 3.00004 10ZM3.0001 3.5C3.00003 4.16667 3 5.33333 3 6H9C9 5.33333 9 4.16667 9 3.5C9 3.5 3.55238 3.5 3.0001 3.5ZM3.00009 14C3.21041 14 15 14 15 14C15 13.5 15 12 15 11.5C15 11.5 3.55238 11.5 3.00009 11.5C3 12 3 13.5 3.00009 14Z' />
|
|
15
|
+
</svg>
|
|
16
|
+
);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React, { SVGProps } from 'react';
|
|
2
|
+
|
|
3
|
+
export const SortIconDesc: React.FC<SVGProps<SVGSVGElement>> = (props) => (
|
|
4
|
+
<svg
|
|
5
|
+
width='18'
|
|
6
|
+
height='18'
|
|
7
|
+
viewBox='0 0 18 18'
|
|
8
|
+
fill='currentColor'
|
|
9
|
+
xmlns='http://www.w3.org/2000/svg'
|
|
10
|
+
focusable='false'
|
|
11
|
+
role='img'
|
|
12
|
+
{...props}
|
|
13
|
+
>
|
|
14
|
+
<path d='M3.00004 10C3.00004 10 11.4477 10 12 10C12 9.33333 12.0001 8.16667 12.0001 7.5H3.0001C3.00006 8 3.0001 9.5 3.00004 10ZM3.0001 3.5C3.00003 4.16667 3 5.33333 3 6H15C15 5.33333 15 4.16667 15 3.5C15 3.5 3.55238 3.5 3.0001 3.5ZM3.00009 14C3.21041 14 9 14 9 14C9 13.5 9 12 9 11.5C9 11.5 3.55238 11.5 3.00009 11.5C3 12 3 13.5 3.00009 14Z' />
|
|
15
|
+
</svg>
|
|
16
|
+
);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React, { SVGProps } from 'react';
|
|
2
|
+
|
|
3
|
+
export const SortIconUnset: React.FC<SVGProps<SVGSVGElement>> = (props) => (
|
|
4
|
+
<svg
|
|
5
|
+
width='18'
|
|
6
|
+
height='18'
|
|
7
|
+
viewBox='0 0 18 18'
|
|
8
|
+
fill='currentColor'
|
|
9
|
+
xmlns='http://www.w3.org/2000/svg'
|
|
10
|
+
focusable='false'
|
|
11
|
+
role='img'
|
|
12
|
+
{...props}
|
|
13
|
+
>
|
|
14
|
+
<path d='M3 10C3 10 10.4477 10 11 10C11 9.33333 11.0001 8.16667 11.0001 7.5H3.00006C3.00002 8 3.00006 9.5 3 10ZM3.0001 3.5C3.00003 4.16667 3 5.33333 3 6H15C15 5.33333 15 4.16667 15 3.5C15 3.5 3.55238 3.5 3.0001 3.5ZM3 14C3.21032 14 14 14 14 14C14 13.5 14 12 14 11.5C14 11.5 3.55228 11.5 3 11.5C2.99991 12 2.99991 13.5 3 14Z' />
|
|
15
|
+
</svg>
|
|
16
|
+
);
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './component';
|
package/src/typings.ts
ADDED
package/src/utils.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
export function isChildInstanceOf<P>(child: React.ReactElement, Component: React.ComponentType<P>) {
|
|
4
|
+
// мы не можем полагаться на child.type === Component, см. https://github.com/gaearon/react-hot-loader/issues/304
|
|
5
|
+
return child.type === React.createElement(Component).type;
|
|
6
|
+
}
|