@true-engineering/true-react-common-ui-kit 3.38.0 → 3.39.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/components/FlexibleTableCell/FlexibleTableCell.styles.d.ts +1 -1
- package/dist/components/FlexibleTable/types.d.ts +3 -1
- package/dist/true-react-common-ui-kit.js +15 -7
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +15 -7
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/package.json +1 -1
- package/src/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.styles.ts +4 -0
- package/src/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.tsx +11 -1
- package/src/components/FlexibleTable/types.ts +7 -1
package/package.json
CHANGED
|
@@ -65,9 +65,17 @@ export function FlexibleTableCell<
|
|
|
65
65
|
cellVerticalAlign,
|
|
66
66
|
shouldRenderDataId,
|
|
67
67
|
shouldRenderComponent = isNotEmpty,
|
|
68
|
+
onCellClick,
|
|
68
69
|
} = config[columnName] ?? {};
|
|
69
70
|
|
|
70
71
|
const isSticky = isOldSticky || position === 'sticky';
|
|
72
|
+
const isClickable = !isLoading && isNotEmpty(onCellClick);
|
|
73
|
+
|
|
74
|
+
const cellComponentProps: IValueComponentProps<Row, Row[keyof Row]> = {
|
|
75
|
+
...valueComponentProps,
|
|
76
|
+
value,
|
|
77
|
+
row,
|
|
78
|
+
};
|
|
71
79
|
|
|
72
80
|
const Table = TableRenders[renderMode];
|
|
73
81
|
|
|
@@ -77,6 +85,7 @@ export function FlexibleTableCell<
|
|
|
77
85
|
[classes.sticky]: isSticky,
|
|
78
86
|
[classes.second]: isSecond,
|
|
79
87
|
[classes.loading]: isLoading,
|
|
88
|
+
[classes.clickable]: isClickable,
|
|
80
89
|
})}
|
|
81
90
|
style={{
|
|
82
91
|
textAlign: cellAlign,
|
|
@@ -88,6 +97,7 @@ export function FlexibleTableCell<
|
|
|
88
97
|
left,
|
|
89
98
|
verticalAlign: cellVerticalAlign,
|
|
90
99
|
}}
|
|
100
|
+
onClick={isClickable ? (event) => onCellClick?.(event, cellComponentProps) : undefined}
|
|
91
101
|
{...addDataAttributes({ id: shouldRenderDataId ? columnName : undefined })}
|
|
92
102
|
>
|
|
93
103
|
{isLoading ? (
|
|
@@ -96,7 +106,7 @@ export function FlexibleTableCell<
|
|
|
96
106
|
</div>
|
|
97
107
|
) : (
|
|
98
108
|
applyAction(shouldRenderComponent, value, row, columnName) &&
|
|
99
|
-
applyAction(component,
|
|
109
|
+
applyAction(component, cellComponentProps)
|
|
100
110
|
)}
|
|
101
111
|
</Table.Cell>
|
|
102
112
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CSSProperties, ReactNode } from 'react';
|
|
1
|
+
import { CSSProperties, MouseEvent, ReactNode } from 'react';
|
|
2
2
|
import { IRenderNode } from '../../types';
|
|
3
3
|
|
|
4
4
|
export type IFlexibleTableRenderMode = 'table' | 'divs';
|
|
@@ -27,6 +27,11 @@ export interface IValueComponentProps<Values, Value> {
|
|
|
27
27
|
onSetNestedComponent: (component?: ReactNode) => void;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
export type ICellClickHandler<Values, Value> = (
|
|
31
|
+
event: MouseEvent,
|
|
32
|
+
cellComponentProps: IValueComponentProps<Values, Value>,
|
|
33
|
+
) => void;
|
|
34
|
+
|
|
30
35
|
export interface IFlexibleTableRowConfig<
|
|
31
36
|
Values extends ITableRow,
|
|
32
37
|
Key extends keyof Values,
|
|
@@ -52,6 +57,7 @@ export interface IFlexibleTableRowConfig<
|
|
|
52
57
|
* @default isNotEmpty
|
|
53
58
|
*/
|
|
54
59
|
shouldRenderComponent?: boolean | ((value: Values[Key], values: Values, key: Key) => boolean);
|
|
60
|
+
onCellClick?: ICellClickHandler<Values, Values[Key]>;
|
|
55
61
|
}
|
|
56
62
|
|
|
57
63
|
export type IFlexibleTableConfigType<
|