@true-engineering/true-react-common-ui-kit 3.50.1 → 3.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/components/FlexibleTable/FlexibleTable.d.ts +4 -2
- package/dist/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.d.ts +2 -3
- package/dist/true-react-common-ui-kit.js +23 -22
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +23 -22
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/package.json +1 -1
- package/src/components/FlexibleTable/FlexibleTable.tsx +12 -12
- package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.tsx +3 -5
package/package.json
CHANGED
|
@@ -34,7 +34,6 @@ export interface IFlexibleTableProps<
|
|
|
34
34
|
| 'uniqueField'
|
|
35
35
|
| 'rowAttributes'
|
|
36
36
|
| 'isFirstColumnSticky'
|
|
37
|
-
| 'isExpandableRowComponentInitiallyOpen'
|
|
38
37
|
| 'expandableRowComponent'
|
|
39
38
|
| 'onRowClick'
|
|
40
39
|
| 'onRowHover'
|
|
@@ -63,6 +62,8 @@ export interface IFlexibleTableProps<
|
|
|
63
62
|
nothingFoundContent?: ReactNode;
|
|
64
63
|
/** @default true */
|
|
65
64
|
shouldRenderHeader?: boolean;
|
|
65
|
+
/** @default false */
|
|
66
|
+
isExpandableRowComponentInitiallyOpen?: boolean | ((row: Row, index: number) => boolean);
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
export function FlexibleTable<
|
|
@@ -89,6 +90,7 @@ export function FlexibleTable<
|
|
|
89
90
|
tweakStyles,
|
|
90
91
|
shouldRenderHeader = true,
|
|
91
92
|
onHeadClick,
|
|
93
|
+
isExpandableRowComponentInitiallyOpen: isRowInitiallyOpen,
|
|
92
94
|
...restProps
|
|
93
95
|
}: IFlexibleTableProps<Row, HeaderContent, UniqueField>): JSX.Element {
|
|
94
96
|
const classes = useStyles({ theme: tweakStyles });
|
|
@@ -106,11 +108,12 @@ export function FlexibleTable<
|
|
|
106
108
|
|
|
107
109
|
const hasInfiniteScroll = isNotEmpty(infinityScrollConfig);
|
|
108
110
|
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
>
|
|
111
|
+
const getTableRowProps = (
|
|
112
|
+
item: Row,
|
|
113
|
+
index: number,
|
|
114
|
+
): IFlexibleTableRowProps<Row, HeaderContent, UniqueField> => ({
|
|
113
115
|
...restProps,
|
|
116
|
+
item,
|
|
114
117
|
renderMode,
|
|
115
118
|
config,
|
|
116
119
|
columns,
|
|
@@ -119,7 +122,8 @@ export function FlexibleTable<
|
|
|
119
122
|
isFirstColumnSticky,
|
|
120
123
|
isFocusable: isRowFocusable,
|
|
121
124
|
tweakStyles: tweakTableRowStyles,
|
|
122
|
-
|
|
125
|
+
isExpandableRowComponentInitiallyOpen: applyAction(isRowInitiallyOpen, item, index),
|
|
126
|
+
});
|
|
123
127
|
|
|
124
128
|
const getDataScrollAttributeSetter = useCallback(
|
|
125
129
|
(key: string, setter: (el: HTMLDivElement) => boolean) => (el?: HTMLDivElement) => {
|
|
@@ -268,9 +272,7 @@ export function FlexibleTable<
|
|
|
268
272
|
)}
|
|
269
273
|
<Table.Body className={classes.body}>
|
|
270
274
|
{isLoading ? (
|
|
271
|
-
indexMap(6, (i) => (
|
|
272
|
-
<FlexibleTableRow {...tableRowProps} key={i} item={{} as Row} index={i} />
|
|
273
|
-
))
|
|
275
|
+
indexMap(6, (i) => <FlexibleTableRow {...getTableRowProps({} as Row, i)} key={i} />)
|
|
274
276
|
) : (
|
|
275
277
|
<>
|
|
276
278
|
{shouldShowNothingFound && (
|
|
@@ -283,11 +285,9 @@ export function FlexibleTable<
|
|
|
283
285
|
|
|
284
286
|
{content.map((item, i) => (
|
|
285
287
|
<FlexibleTableRow
|
|
286
|
-
{...
|
|
288
|
+
{...getTableRowProps(item, i)}
|
|
287
289
|
isActive={activeRowsSet.has(i)}
|
|
288
290
|
key={isNotEmpty(uniqueField) ? item[uniqueField] : i}
|
|
289
|
-
item={item}
|
|
290
|
-
index={i}
|
|
291
291
|
/>
|
|
292
292
|
))}
|
|
293
293
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode, useState, memo, MouseEvent, RefCallback } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
-
import {
|
|
3
|
+
import { isEmpty, isNotEmpty } from '@true-engineering/true-react-platform-helpers';
|
|
4
4
|
import { addDataAttributes } from '../../../../helpers';
|
|
5
5
|
import { useTweakStyles } from '../../../../hooks';
|
|
6
6
|
import { IDataAttributes, ITweakStylesProps } from '../../../../types';
|
|
@@ -21,7 +21,6 @@ export interface IFlexibleTableRowProps<
|
|
|
21
21
|
UniqueField extends keyof Row,
|
|
22
22
|
> extends ITweakStylesProps<IFlexibleTableRowStyles> {
|
|
23
23
|
item: Row;
|
|
24
|
-
index: number;
|
|
25
24
|
uniqueField?: UniqueField;
|
|
26
25
|
renderMode: IFlexibleTableRenderMode;
|
|
27
26
|
/** @default false */
|
|
@@ -37,7 +36,7 @@ export interface IFlexibleTableRowProps<
|
|
|
37
36
|
columns: Array<keyof Row & string>;
|
|
38
37
|
rowAttributes?: Array<keyof Row>;
|
|
39
38
|
/** @default false */
|
|
40
|
-
isExpandableRowComponentInitiallyOpen?: boolean
|
|
39
|
+
isExpandableRowComponentInitiallyOpen?: boolean;
|
|
41
40
|
rowRef?: RefCallback<HTMLTableRowElement>;
|
|
42
41
|
/** Возвращает React-элемент, который отрисуется под строкой при нажатии на неё */
|
|
43
42
|
expandableRowComponent?: (item: Row, isOpen: boolean, close: () => void) => ReactNode;
|
|
@@ -51,7 +50,6 @@ function FlexibleTableRowInner<
|
|
|
51
50
|
UniqueField extends keyof Row,
|
|
52
51
|
>({
|
|
53
52
|
item,
|
|
54
|
-
index,
|
|
55
53
|
config,
|
|
56
54
|
columns,
|
|
57
55
|
uniqueField,
|
|
@@ -78,7 +76,7 @@ function FlexibleTableRowInner<
|
|
|
78
76
|
|
|
79
77
|
const [isFocused, setFocused] = useState(false);
|
|
80
78
|
const [nestedComponent, setNestedComponent] = useState<INestedComponent>(() => ({
|
|
81
|
-
isOpen:
|
|
79
|
+
isOpen: isExpandableRowComponentInitiallyOpen,
|
|
82
80
|
}));
|
|
83
81
|
|
|
84
82
|
const isEditable = !isLoading && (isNotEmpty(onRowClick) || isNotEmpty(onRowHover));
|