@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 CHANGED
@@ -11,6 +11,12 @@
11
11
 
12
12
  # Release Notes
13
13
 
14
+ ## 3.39.0
15
+
16
+ ### Changes
17
+
18
+ - **FlexibleTableCell**: Добавляет `onCellClick` в `config`
19
+
14
20
  ## 3.38.0
15
21
 
16
22
  ### Changes
@@ -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, _object_spread_props$j(_object_spread$k({}, valueComponentProps), {
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", {