@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.
Files changed (288) hide show
  1. package/Component-5e1b8383.d.ts +5 -0
  2. package/Component-63dec22f.d.ts +167 -0
  3. package/Component-89a3cf4c.d.ts +6 -0
  4. package/Component-bdb4c6b9.d.ts +12 -0
  5. package/Component-e81c389f.d.ts +5 -0
  6. package/Component-ebda875c.d.ts +12 -0
  7. package/Component.desktop-63dec22f.d.ts +6 -0
  8. package/Component.desktop-785df74d.d.ts +6 -0
  9. package/Component.mobile-d7e9f69d.d.ts +6 -0
  10. package/Component.mobile-ebda875c.d.ts +6 -0
  11. package/Component.responsive-785df74d.d.ts +26 -0
  12. package/Context-bdb4c6b9.d.ts +4 -0
  13. package/ResponsiveContext-baf4875b.d.ts +5 -0
  14. package/component-89a3cf4c.d.ts +44 -0
  15. package/component.d.ts +5 -5
  16. package/component.js +1 -1
  17. package/components/index.js +1 -1
  18. package/components/pagination/Component.js +3 -3
  19. package/components/pagination/index.css +8 -8
  20. package/components/pagination/index.js +1 -1
  21. package/components/pagination/select-field/index.css +4 -4
  22. package/components/pagination/select-field/index.js +1 -1
  23. package/components/table/Component.js +1 -1
  24. package/components/table/index.css +7 -7
  25. package/components/tbody/Component.js +1 -1
  26. package/components/tbody/index.css +2 -2
  27. package/components/tcell/Component.d.ts +3 -2
  28. package/components/tcell/Component.js +1 -1
  29. package/components/tcell/index.css +6 -6
  30. package/components/texpandable-row/Component.d.ts +3 -2
  31. package/components/texpandable-row/Component.js +1 -1
  32. package/components/texpandable-row/index.css +5 -5
  33. package/components/thead/Component.js +1 -1
  34. package/components/thead/index.css +6 -6
  35. package/components/thead-cell/Component.d.ts +3 -2
  36. package/components/thead-cell/Component.js +1 -1
  37. package/components/thead-cell/index.css +10 -9
  38. package/components/trow/Component.d.ts +1 -1
  39. package/components/trow/Component.js +1 -1
  40. package/components/trow/index.css +8 -8
  41. package/components/tsortable-head-cell/Component.d.ts +2 -1
  42. package/components/tsortable-head-cell/Component.js +2 -2
  43. package/components/tsortable-head-cell/index.css +8 -10
  44. package/consts-f777ba1a.d.ts +2 -0
  45. package/cssm/Component-5e1b8383.d.ts +5 -0
  46. package/cssm/Component-63dec22f.d.ts +167 -0
  47. package/cssm/Component-89a3cf4c.d.ts +6 -0
  48. package/cssm/Component-bdb4c6b9.d.ts +12 -0
  49. package/cssm/Component-e81c389f.d.ts +5 -0
  50. package/cssm/Component-ebda875c.d.ts +12 -0
  51. package/cssm/Component.desktop-63dec22f.d.ts +6 -0
  52. package/cssm/Component.desktop-785df74d.d.ts +6 -0
  53. package/cssm/Component.mobile-d7e9f69d.d.ts +6 -0
  54. package/cssm/Component.mobile-ebda875c.d.ts +6 -0
  55. package/cssm/Component.responsive-785df74d.d.ts +26 -0
  56. package/cssm/Context-bdb4c6b9.d.ts +4 -0
  57. package/cssm/ResponsiveContext-baf4875b.d.ts +5 -0
  58. package/cssm/component-89a3cf4c.d.ts +44 -0
  59. package/cssm/component.d.ts +5 -5
  60. package/cssm/component.js +1 -1
  61. package/cssm/components/index.js +1 -1
  62. package/cssm/components/pagination/Component.js +2 -2
  63. package/cssm/components/pagination/index.js +1 -1
  64. package/cssm/components/tcell/Component.d.ts +3 -2
  65. package/cssm/components/texpandable-row/Component.d.ts +3 -2
  66. package/cssm/components/thead-cell/Component.d.ts +3 -2
  67. package/cssm/components/thead-cell/index.module.css +2 -1
  68. package/cssm/components/trow/Component.d.ts +1 -1
  69. package/cssm/components/tsortable-head-cell/Component.d.ts +2 -1
  70. package/cssm/components/tsortable-head-cell/Component.js +1 -1
  71. package/cssm/components/tsortable-head-cell/index.module.css +0 -2
  72. package/cssm/consts-f777ba1a.d.ts +2 -0
  73. package/cssm/desktop-63dec22f.d.ts +6 -0
  74. package/cssm/hook-5e1b8383.d.ts +75 -0
  75. package/cssm/hook-ebda875c.d.ts +48 -0
  76. package/cssm/index-136acbb1.d.ts +28 -0
  77. package/cssm/index-3109f463.d.ts +62 -0
  78. package/cssm/index-425c8522.d.ts +6 -0
  79. package/cssm/index-89a3cf4c.d.ts +3 -0
  80. package/cssm/index-bdb4c6b9.d.ts +2 -0
  81. package/cssm/index-c44170fe.d.ts +21 -0
  82. package/cssm/index-e81c389f.d.ts +3 -0
  83. package/cssm/index-ebda875c.d.ts +81 -0
  84. package/cssm/index-f12ee135.d.ts +3 -0
  85. package/cssm/index.js +1 -1
  86. package/cssm/mobile-96988a65.d.ts +2 -0
  87. package/cssm/types-425c8522.d.ts +259 -0
  88. package/cssm/types-ebda875c.d.ts +113 -0
  89. package/cssm/typings-5e1b8383.d.ts +550 -0
  90. package/cssm/typings-9211a437.d.ts +95 -0
  91. package/cssm/typings-bdb4c6b9.d.ts +52 -0
  92. package/cssm/utils-1574ad8b.d.ts +29 -0
  93. package/cssm/utils-49cc3c24.d.ts +8 -0
  94. package/cssm/utils-5e1b8383.d.ts +38 -0
  95. package/desktop-63dec22f.d.ts +6 -0
  96. package/esm/Component-5e1b8383.d.ts +5 -0
  97. package/esm/Component-63dec22f.d.ts +167 -0
  98. package/esm/Component-89a3cf4c.d.ts +6 -0
  99. package/esm/Component-bdb4c6b9.d.ts +12 -0
  100. package/esm/Component-e81c389f.d.ts +5 -0
  101. package/esm/Component-ebda875c.d.ts +12 -0
  102. package/esm/Component.desktop-63dec22f.d.ts +6 -0
  103. package/esm/Component.desktop-785df74d.d.ts +6 -0
  104. package/esm/Component.mobile-d7e9f69d.d.ts +6 -0
  105. package/esm/Component.mobile-ebda875c.d.ts +6 -0
  106. package/esm/Component.responsive-785df74d.d.ts +26 -0
  107. package/esm/Context-bdb4c6b9.d.ts +4 -0
  108. package/esm/ResponsiveContext-baf4875b.d.ts +5 -0
  109. package/esm/component-89a3cf4c.d.ts +44 -0
  110. package/esm/component.d.ts +5 -5
  111. package/esm/component.js +1 -1
  112. package/esm/components/index.js +1 -1
  113. package/esm/components/pagination/Component.js +3 -3
  114. package/esm/components/pagination/index.css +8 -8
  115. package/esm/components/pagination/index.js +1 -1
  116. package/esm/components/pagination/select-field/index.css +4 -4
  117. package/esm/components/pagination/select-field/index.js +1 -1
  118. package/esm/components/table/Component.js +1 -1
  119. package/esm/components/table/index.css +7 -7
  120. package/esm/components/tbody/Component.js +1 -1
  121. package/esm/components/tbody/index.css +2 -2
  122. package/esm/components/tcell/Component.d.ts +3 -2
  123. package/esm/components/tcell/Component.js +1 -1
  124. package/esm/components/tcell/index.css +6 -6
  125. package/esm/components/texpandable-row/Component.d.ts +3 -2
  126. package/esm/components/texpandable-row/Component.js +1 -1
  127. package/esm/components/texpandable-row/index.css +5 -5
  128. package/esm/components/thead/Component.js +1 -1
  129. package/esm/components/thead/index.css +6 -6
  130. package/esm/components/thead-cell/Component.d.ts +3 -2
  131. package/esm/components/thead-cell/Component.js +1 -1
  132. package/esm/components/thead-cell/index.css +10 -9
  133. package/esm/components/trow/Component.d.ts +1 -1
  134. package/esm/components/trow/Component.js +1 -1
  135. package/esm/components/trow/index.css +8 -8
  136. package/esm/components/tsortable-head-cell/Component.d.ts +2 -1
  137. package/esm/components/tsortable-head-cell/Component.js +2 -2
  138. package/esm/components/tsortable-head-cell/index.css +8 -10
  139. package/esm/consts-f777ba1a.d.ts +2 -0
  140. package/esm/desktop-63dec22f.d.ts +6 -0
  141. package/esm/hook-5e1b8383.d.ts +75 -0
  142. package/esm/hook-ebda875c.d.ts +48 -0
  143. package/esm/index-136acbb1.d.ts +28 -0
  144. package/esm/index-3109f463.d.ts +62 -0
  145. package/esm/index-425c8522.d.ts +6 -0
  146. package/esm/index-89a3cf4c.d.ts +3 -0
  147. package/esm/index-bdb4c6b9.d.ts +2 -0
  148. package/esm/index-c44170fe.d.ts +21 -0
  149. package/esm/index-e81c389f.d.ts +3 -0
  150. package/esm/index-ebda875c.d.ts +81 -0
  151. package/esm/index-f12ee135.d.ts +3 -0
  152. package/esm/index.js +1 -1
  153. package/esm/mobile-96988a65.d.ts +2 -0
  154. package/esm/types-425c8522.d.ts +259 -0
  155. package/esm/types-ebda875c.d.ts +113 -0
  156. package/esm/typings-5e1b8383.d.ts +550 -0
  157. package/esm/typings-9211a437.d.ts +95 -0
  158. package/esm/typings-bdb4c6b9.d.ts +52 -0
  159. package/esm/utils-1574ad8b.d.ts +29 -0
  160. package/esm/utils-49cc3c24.d.ts +8 -0
  161. package/esm/utils-5e1b8383.d.ts +38 -0
  162. package/hook-5e1b8383.d.ts +75 -0
  163. package/hook-ebda875c.d.ts +48 -0
  164. package/index-136acbb1.d.ts +28 -0
  165. package/index-3109f463.d.ts +62 -0
  166. package/index-425c8522.d.ts +6 -0
  167. package/index-89a3cf4c.d.ts +3 -0
  168. package/index-bdb4c6b9.d.ts +2 -0
  169. package/index-c44170fe.d.ts +21 -0
  170. package/index-e81c389f.d.ts +3 -0
  171. package/index-ebda875c.d.ts +81 -0
  172. package/index-f12ee135.d.ts +3 -0
  173. package/index.js +1 -1
  174. package/mobile-96988a65.d.ts +2 -0
  175. package/modern/Component-5e1b8383.d.ts +5 -0
  176. package/modern/Component-63dec22f.d.ts +167 -0
  177. package/modern/Component-89a3cf4c.d.ts +6 -0
  178. package/modern/Component-bdb4c6b9.d.ts +12 -0
  179. package/modern/Component-e81c389f.d.ts +5 -0
  180. package/modern/Component-ebda875c.d.ts +12 -0
  181. package/modern/Component.desktop-63dec22f.d.ts +6 -0
  182. package/modern/Component.desktop-785df74d.d.ts +6 -0
  183. package/modern/Component.mobile-d7e9f69d.d.ts +6 -0
  184. package/modern/Component.mobile-ebda875c.d.ts +6 -0
  185. package/modern/Component.responsive-785df74d.d.ts +26 -0
  186. package/modern/Context-bdb4c6b9.d.ts +4 -0
  187. package/modern/ResponsiveContext-baf4875b.d.ts +5 -0
  188. package/modern/component-89a3cf4c.d.ts +44 -0
  189. package/modern/component.d.ts +5 -5
  190. package/modern/component.js +1 -1
  191. package/modern/components/index.js +1 -1
  192. package/modern/components/pagination/Component.js +3 -3
  193. package/modern/components/pagination/index.css +8 -8
  194. package/modern/components/pagination/index.js +1 -1
  195. package/modern/components/pagination/select-field/index.css +4 -4
  196. package/modern/components/pagination/select-field/index.js +1 -1
  197. package/modern/components/table/Component.js +1 -1
  198. package/modern/components/table/index.css +7 -7
  199. package/modern/components/tbody/Component.js +1 -1
  200. package/modern/components/tbody/index.css +2 -2
  201. package/modern/components/tcell/Component.d.ts +3 -2
  202. package/modern/components/tcell/Component.js +1 -1
  203. package/modern/components/tcell/index.css +6 -6
  204. package/modern/components/texpandable-row/Component.d.ts +3 -2
  205. package/modern/components/texpandable-row/Component.js +1 -1
  206. package/modern/components/texpandable-row/index.css +5 -5
  207. package/modern/components/thead/Component.js +1 -1
  208. package/modern/components/thead/index.css +6 -6
  209. package/modern/components/thead-cell/Component.d.ts +3 -2
  210. package/modern/components/thead-cell/Component.js +1 -1
  211. package/modern/components/thead-cell/index.css +10 -9
  212. package/modern/components/trow/Component.d.ts +1 -1
  213. package/modern/components/trow/Component.js +1 -1
  214. package/modern/components/trow/index.css +8 -8
  215. package/modern/components/tsortable-head-cell/Component.d.ts +2 -1
  216. package/modern/components/tsortable-head-cell/Component.js +2 -2
  217. package/modern/components/tsortable-head-cell/index.css +8 -10
  218. package/modern/consts-f777ba1a.d.ts +2 -0
  219. package/modern/desktop-63dec22f.d.ts +6 -0
  220. package/modern/hook-5e1b8383.d.ts +75 -0
  221. package/modern/hook-ebda875c.d.ts +48 -0
  222. package/modern/index-136acbb1.d.ts +28 -0
  223. package/modern/index-3109f463.d.ts +62 -0
  224. package/modern/index-425c8522.d.ts +6 -0
  225. package/modern/index-89a3cf4c.d.ts +3 -0
  226. package/modern/index-bdb4c6b9.d.ts +2 -0
  227. package/modern/index-c44170fe.d.ts +21 -0
  228. package/modern/index-e81c389f.d.ts +3 -0
  229. package/modern/index-ebda875c.d.ts +81 -0
  230. package/modern/index-f12ee135.d.ts +3 -0
  231. package/modern/index.js +1 -1
  232. package/modern/mobile-96988a65.d.ts +2 -0
  233. package/modern/types-425c8522.d.ts +259 -0
  234. package/modern/types-ebda875c.d.ts +113 -0
  235. package/modern/typings-5e1b8383.d.ts +550 -0
  236. package/modern/typings-9211a437.d.ts +95 -0
  237. package/modern/typings-bdb4c6b9.d.ts +52 -0
  238. package/modern/utils-1574ad8b.d.ts +29 -0
  239. package/modern/utils-49cc3c24.d.ts +8 -0
  240. package/modern/utils-5e1b8383.d.ts +38 -0
  241. package/package.json +4 -4
  242. package/src/component.tsx +22 -0
  243. package/src/components/index.ts +9 -0
  244. package/src/components/pagination/Component.tsx +104 -0
  245. package/src/components/pagination/index.module.css +38 -0
  246. package/src/components/pagination/index.ts +1 -0
  247. package/src/components/pagination/select-field/index.module.css +13 -0
  248. package/src/components/pagination/select-field/index.tsx +25 -0
  249. package/src/components/table/Component.tsx +109 -0
  250. package/src/components/table/index.module.css +35 -0
  251. package/src/components/table/index.ts +1 -0
  252. package/src/components/table/utils.ts +19 -0
  253. package/src/components/table-context/index.tsx +28 -0
  254. package/src/components/tbody/Component.tsx +22 -0
  255. package/src/components/tbody/index.module.css +6 -0
  256. package/src/components/tbody/index.ts +1 -0
  257. package/src/components/tcell/Component.tsx +56 -0
  258. package/src/components/tcell/index.module.css +35 -0
  259. package/src/components/tcell/index.ts +1 -0
  260. package/src/components/texpandable-row/Component.tsx +58 -0
  261. package/src/components/texpandable-row/index.module.css +25 -0
  262. package/src/components/texpandable-row/index.ts +1 -0
  263. package/src/components/thead/Component.tsx +33 -0
  264. package/src/components/thead/index.module.css +32 -0
  265. package/src/components/thead/index.ts +1 -0
  266. package/src/components/thead-cell/Component.tsx +67 -0
  267. package/src/components/thead-cell/index.module.css +47 -0
  268. package/src/components/thead-cell/index.ts +1 -0
  269. package/src/components/trow/Component.tsx +56 -0
  270. package/src/components/trow/index.module.css +35 -0
  271. package/src/components/trow/index.ts +1 -0
  272. package/src/components/tsortable-head-cell/Component.tsx +50 -0
  273. package/src/components/tsortable-head-cell/index.module.css +41 -0
  274. package/src/components/tsortable-head-cell/index.ts +1 -0
  275. package/src/components/tsortable-head-cell/sort-icon-asc.tsx +16 -0
  276. package/src/components/tsortable-head-cell/sort-icon-desc.tsx +16 -0
  277. package/src/components/tsortable-head-cell/sort-icon-unset.tsx +16 -0
  278. package/src/index.ts +1 -0
  279. package/src/typings.ts +8 -0
  280. package/src/utils.ts +6 -0
  281. package/types-425c8522.d.ts +259 -0
  282. package/types-ebda875c.d.ts +113 -0
  283. package/typings-5e1b8383.d.ts +550 -0
  284. package/typings-9211a437.d.ts +95 -0
  285. package/typings-bdb4c6b9.d.ts +52 -0
  286. package/utils-1574ad8b.d.ts +29 -0
  287. package/utils-49cc3c24.d.ts +8 -0
  288. 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
@@ -0,0 +1,8 @@
1
+ export type TextAlignProperty =
2
+ | 'center'
3
+ | 'end'
4
+ | 'justify'
5
+ | 'left'
6
+ | 'match-parent'
7
+ | 'right'
8
+ | 'start';
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
+ }