@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/README.md
CHANGED
package/dist/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.styles.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ITweakStyles } from '../../../../theme';
|
|
2
|
-
export declare const useStyles: import("../../../../theme").IUseStyles<"root" | "sticky" | "loading" | "second" | "skeleton", unknown>;
|
|
2
|
+
export declare const useStyles: import("../../../../theme").IUseStyles<"root" | "sticky" | "loading" | "clickable" | "second" | "skeleton", unknown>;
|
|
3
3
|
export type IFlexibleTableCellStyles = ITweakStyles<typeof useStyles>;
|
|
@@ -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
|
export type IFlexibleTableRenderMode = 'table' | 'divs';
|
|
4
4
|
export type IFlexibleTableRender = Record<'Root' | 'Head' | 'Body' | 'Row' | 'Header' | 'Cell', keyof JSX.IntrinsicElements>;
|
|
@@ -16,6 +16,7 @@ export interface IValueComponentProps<Values, Value> {
|
|
|
16
16
|
isRowNestedComponentExpanded: boolean;
|
|
17
17
|
onSetNestedComponent: (component?: ReactNode) => void;
|
|
18
18
|
}
|
|
19
|
+
export type ICellClickHandler<Values, Value> = (event: MouseEvent, cellComponentProps: IValueComponentProps<Values, Value>) => void;
|
|
19
20
|
export interface IFlexibleTableRowConfig<Values extends ITableRow, Key extends keyof Values, HeaderContent extends IHeaderContent<Values> = IHeaderContent<Values>> {
|
|
20
21
|
title?: IRenderNode<ITitleComponentProps<HeaderContent[Key]>>;
|
|
21
22
|
component?: IRenderNode<IValueComponentProps<Values, NonNullable<Values[Key]>>>;
|
|
@@ -37,6 +38,7 @@ export interface IFlexibleTableRowConfig<Values extends ITableRow, Key extends k
|
|
|
37
38
|
* @default isNotEmpty
|
|
38
39
|
*/
|
|
39
40
|
shouldRenderComponent?: boolean | ((value: Values[Key], values: Values, key: Key) => boolean);
|
|
41
|
+
onCellClick?: ICellClickHandler<Values, Values[Key]>;
|
|
40
42
|
}
|
|
41
43
|
export type IFlexibleTableConfigType<Values extends ITableRow, HeaderContent extends IHeaderContent<Values> = IHeaderContent<Values>> = {
|
|
42
44
|
[Key in keyof Values]?: IFlexibleTableRowConfig<Values, Key, HeaderContent>;
|
|
@@ -25955,6 +25955,9 @@ var useStyles$i = createThemedStyles("FlexibleTableCell", {
|
|
|
25955
25955
|
loading: {},
|
|
25956
25956
|
skeleton: {
|
|
25957
25957
|
height: 21
|
|
25958
|
+
},
|
|
25959
|
+
clickable: {
|
|
25960
|
+
cursor: "pointer"
|
|
25958
25961
|
}
|
|
25959
25962
|
});
|
|
25960
25963
|
function _define_property$l(obj, key, value) {
|
|
@@ -26057,12 +26060,17 @@ function FlexibleTableCell(_param) {
|
|
|
26057
26060
|
});
|
|
26058
26061
|
var value = row[columnName];
|
|
26059
26062
|
var _config_columnName;
|
|
26060
|
-
var _ref = (_config_columnName = config[columnName]) !== null && _config_columnName !== void 0 ? _config_columnName : {}, _ref_component = _ref.component, component = _ref_component === void 0 ? formatCellContent(value, config[columnName]) : _ref_component, width = _ref.width, maxWidth = _ref.maxWidth, minWidth = _ref.minWidth, left2 = _ref.left, right2 = _ref.right, position = _ref.position, cellAlign = _ref.cellAlign, cellVerticalAlign = _ref.cellVerticalAlign, shouldRenderDataId = _ref.shouldRenderDataId, _ref_shouldRenderComponent = _ref.shouldRenderComponent, shouldRenderComponent = _ref_shouldRenderComponent === void 0 ? isNotEmpty : _ref_shouldRenderComponent;
|
|
26063
|
+
var _ref = (_config_columnName = config[columnName]) !== null && _config_columnName !== void 0 ? _config_columnName : {}, _ref_component = _ref.component, component = _ref_component === void 0 ? formatCellContent(value, config[columnName]) : _ref_component, width = _ref.width, maxWidth = _ref.maxWidth, minWidth = _ref.minWidth, left2 = _ref.left, right2 = _ref.right, position = _ref.position, cellAlign = _ref.cellAlign, cellVerticalAlign = _ref.cellVerticalAlign, shouldRenderDataId = _ref.shouldRenderDataId, _ref_shouldRenderComponent = _ref.shouldRenderComponent, shouldRenderComponent = _ref_shouldRenderComponent === void 0 ? isNotEmpty : _ref_shouldRenderComponent, onCellClick = _ref.onCellClick;
|
|
26061
26064
|
var isSticky = isOldSticky || position === "sticky";
|
|
26065
|
+
var isClickable = !isLoading && isNotEmpty(onCellClick);
|
|
26066
|
+
var cellComponentProps = _object_spread_props$j(_object_spread$k({}, valueComponentProps), {
|
|
26067
|
+
value,
|
|
26068
|
+
row
|
|
26069
|
+
});
|
|
26062
26070
|
var Table = TableRenders[renderMode];
|
|
26063
26071
|
var _obj2;
|
|
26064
26072
|
return /* @__PURE__ */ jsx(Table.Cell, _object_spread_props$j(_object_spread$k({
|
|
26065
|
-
className: clsx(classes.root, (_obj2 = {}, _define_property$l(_obj2, classes.sticky, isSticky), _define_property$l(_obj2, classes.second, isSecond), _define_property$l(_obj2, classes.loading, isLoading), _obj2)),
|
|
26073
|
+
className: clsx(classes.root, (_obj2 = {}, _define_property$l(_obj2, classes.sticky, isSticky), _define_property$l(_obj2, classes.second, isSecond), _define_property$l(_obj2, classes.loading, isLoading), _define_property$l(_obj2, classes.clickable, isClickable), _obj2)),
|
|
26066
26074
|
style: {
|
|
26067
26075
|
textAlign: cellAlign,
|
|
26068
26076
|
position: isSticky ? "sticky" : position,
|
|
@@ -26072,17 +26080,17 @@ function FlexibleTableCell(_param) {
|
|
|
26072
26080
|
right: right2,
|
|
26073
26081
|
left: left2,
|
|
26074
26082
|
verticalAlign: cellVerticalAlign
|
|
26075
|
-
}
|
|
26083
|
+
},
|
|
26084
|
+
onClick: isClickable ? function(event) {
|
|
26085
|
+
return onCellClick === null || onCellClick === void 0 ? void 0 : onCellClick(event, cellComponentProps);
|
|
26086
|
+
} : void 0
|
|
26076
26087
|
}, addDataAttributes({
|
|
26077
26088
|
id: shouldRenderDataId ? columnName : void 0
|
|
26078
26089
|
})), {
|
|
26079
26090
|
children: isLoading ? /* @__PURE__ */ jsx("div", {
|
|
26080
26091
|
className: classes.skeleton,
|
|
26081
26092
|
children: /* @__PURE__ */ jsx(Skeleton, {})
|
|
26082
|
-
}) : applyAction(shouldRenderComponent, value, row, columnName) && applyAction(component,
|
|
26083
|
-
value,
|
|
26084
|
-
row
|
|
26085
|
-
}))
|
|
26093
|
+
}) : applyAction(shouldRenderComponent, value, row, columnName) && applyAction(component, cellComponentProps)
|
|
26086
26094
|
}));
|
|
26087
26095
|
}
|
|
26088
26096
|
var useStyles$h = createThemedStyles("FlexibleTableRow", {
|