@true-engineering/true-react-common-ui-kit 3.0.0-alpha.14 → 3.0.0-alpha.16

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.
@@ -7,7 +7,7 @@ export interface IFlexibleTableProps<Values extends Record<string, any>> extends
7
7
  headerContent?: Partial<Record<keyof Values, any>>;
8
8
  enabledColumns?: Array<keyof Values>;
9
9
  activeRows?: number[];
10
- config?: IFlexibleTableConfigType<Values>;
10
+ config: IFlexibleTableConfigType<Values>;
11
11
  isHorizontallyScrollable?: boolean;
12
12
  isFirstColumnSticky?: boolean;
13
13
  infinityScrollConfig?: IInfinityScrollConfig;
@@ -5,7 +5,7 @@ import { IFlexibleTableCellStyles } from './FlexibleTableCell.styles';
5
5
  export interface IFlexibleTableCellProps<Values extends Record<string, any>> extends Pick<ICommonProps<IFlexibleTableCellStyles>, 'tweakStyles'> {
6
6
  item: Values;
7
7
  columnName: keyof Values;
8
- config?: IFlexibleTableConfigType<Values>;
8
+ config: IFlexibleTableConfigType<Values>;
9
9
  isFocusedRow?: boolean;
10
10
  isSecond?: boolean;
11
11
  isSticky?: boolean;
@@ -7,7 +7,7 @@ export interface IFlexibleTableRowProps<Values extends Record<string, any>> exte
7
7
  uniqueField?: keyof Values;
8
8
  isFirstColumnSticky?: boolean;
9
9
  isActive: boolean;
10
- config?: IFlexibleTableConfigType<Values>;
10
+ config: IFlexibleTableConfigType<Values>;
11
11
  enabledColumns?: Array<keyof Values>;
12
12
  rowAttributes?: Array<keyof Values>;
13
13
  expandableRowComponent?(item: Values, isOpen: boolean, close: () => void): ReactNode;
@@ -1 +1,3 @@
1
+ import { IFlexibleTableConfigType } from './types';
1
2
  export declare const hasHorizontalScrollBar: (el: HTMLElement | null | undefined) => boolean;
3
+ export declare const formatCellContent: <Values>(value: unknown, config?: IFlexibleTableConfigType<Values>[keyof Values] | undefined) => string;
@@ -17,7 +17,7 @@ export declare type IFlexibleTableConfigType<Values> = {
17
17
  [Key in keyof Values]?: {
18
18
  title?: ReactNode;
19
19
  titleComponent?: ITitleComponent<unknown>;
20
- component?: IValueComponent<Values, Values[Key]>;
20
+ component?: IValueComponent<NonNullable<Values>, Values[Key]>;
21
21
  dateFormat?: string;
22
22
  minWidth?: string | number;
23
23
  width?: string | number;
@@ -21741,6 +21741,20 @@ var Flag = function(param) {
21741
21741
  });
21742
21742
  };
21743
21743
  var DEFAULT_DATE_FORMAT = "dd.MM.yyyy";
21744
+ function _instanceof(left2, right2) {
21745
+ if (right2 != null && typeof Symbol !== "undefined" && right2[Symbol.hasInstance]) {
21746
+ return !!right2[Symbol.hasInstance](left2);
21747
+ } else {
21748
+ return left2 instanceof right2;
21749
+ }
21750
+ }
21751
+ var hasHorizontalScrollBar = function(el) {
21752
+ return isNotEmpty(el) && el.scrollWidth !== el.clientWidth;
21753
+ };
21754
+ var _config_dateFormat;
21755
+ var formatCellContent = function(value, config) {
21756
+ return _instanceof(value, Date) ? format$1(value, (_config_dateFormat = config === null || config === void 0 ? void 0 : config.dateFormat) !== null && _config_dateFormat !== void 0 ? _config_dateFormat : DEFAULT_DATE_FORMAT) : String(value);
21757
+ };
21744
21758
  var STICKY_SHADOW_PADDING = 12;
21745
21759
  var useStyles$h = createThemedStyles("FlexibleTable", {
21746
21760
  root: {
@@ -21919,47 +21933,34 @@ function _define_property$i(obj, key, value) {
21919
21933
  }
21920
21934
  return obj;
21921
21935
  }
21922
- function _instanceof(left2, right2) {
21923
- if (right2 != null && typeof Symbol !== "undefined" && right2[Symbol.hasInstance]) {
21924
- return !!right2[Symbol.hasInstance](left2);
21925
- } else {
21926
- return left2 instanceof right2;
21927
- }
21928
- }
21929
21936
  function FlexibleTableCell(param) {
21930
21937
  var item = param.item, columnName = param.columnName, config = param.config, isFocusedRow = param.isFocusedRow, isSecond = param.isSecond, isSticky = param.isSticky, isNestedComponentExpanded = param.isNestedComponentExpanded, isRowNestedComponentExpanded = param.isRowNestedComponentExpanded, tweakStyles = param.tweakStyles, onSetNestedComponent = param.onSetNestedComponent;
21931
21938
  var classes = useStyles$g({
21932
21939
  theme: tweakStyles
21933
21940
  });
21934
- var itemConfig = config === null || config === void 0 ? void 0 : config[columnName];
21941
+ var _config_columnName;
21942
+ var _ref = (_config_columnName = config[columnName]) !== null && _config_columnName !== void 0 ? _config_columnName : {}, component = _ref.component, cellAlign = _ref.cellAlign, position = _ref.position, right2 = _ref.right, left2 = _ref.left, cellVerticalAlign = _ref.cellVerticalAlign;
21935
21943
  var value = item[columnName];
21936
- var content = null;
21937
- if (itemConfig === null || itemConfig === void 0 ? void 0 : itemConfig.component) {
21938
- var ValueComponent = itemConfig === null || itemConfig === void 0 ? void 0 : itemConfig.component;
21939
- content = ValueComponent({
21940
- value,
21941
- row: item,
21942
- isFocusedRow,
21943
- isNestedComponentExpanded,
21944
- isRowNestedComponentExpanded,
21945
- onSetNestedComponent
21946
- });
21947
- } else if (typeof value === "string" || typeof value === "number") {
21948
- content = value;
21949
- } else if (_instanceof(value, Date)) {
21950
- content = format$1(value, (itemConfig === null || itemConfig === void 0 ? void 0 : itemConfig.dateFormat) || DEFAULT_DATE_FORMAT);
21951
- }
21952
21944
  var _obj;
21953
21945
  return /* @__PURE__ */ jsx("td", {
21954
21946
  className: clsx(classes.root, (_obj = {}, _define_property$i(_obj, classes.sticky, isSticky), _define_property$i(_obj, classes.second, isSecond), _obj)),
21955
21947
  style: {
21956
- textAlign: itemConfig === null || itemConfig === void 0 ? void 0 : itemConfig.cellAlign,
21957
- position: isSticky ? "sticky" : itemConfig === null || itemConfig === void 0 ? void 0 : itemConfig.position,
21958
- right: itemConfig === null || itemConfig === void 0 ? void 0 : itemConfig.right,
21959
- left: isSticky ? 0 : itemConfig === null || itemConfig === void 0 ? void 0 : itemConfig.left,
21960
- verticalAlign: itemConfig === null || itemConfig === void 0 ? void 0 : itemConfig.cellVerticalAlign
21948
+ textAlign: cellAlign,
21949
+ position: isSticky ? "sticky" : position,
21950
+ right: right2,
21951
+ left: isSticky ? 0 : left2,
21952
+ verticalAlign: cellVerticalAlign
21961
21953
  },
21962
- children: content
21954
+ children: isNotEmpty(value) && /* @__PURE__ */ jsx(Fragment, {
21955
+ children: isNotEmpty(component) ? component({
21956
+ value,
21957
+ row: item,
21958
+ isFocusedRow,
21959
+ isNestedComponentExpanded,
21960
+ isRowNestedComponentExpanded,
21961
+ onSetNestedComponent
21962
+ }) : formatCellContent(value, config[columnName])
21963
+ })
21963
21964
  }, columnName);
21964
21965
  }
21965
21966
  var useStyles$f = createThemedStyles("FlexibleTableRow", {
@@ -22187,9 +22188,6 @@ function FlexibleTableRowInner(param) {
22187
22188
  });
22188
22189
  }
22189
22190
  var FlexibleTableRow = /* @__PURE__ */ memo(FlexibleTableRowInner);
22190
- var hasHorizontalScrollBar = function(el) {
22191
- return isNotEmpty(el) && el.scrollWidth !== el.clientWidth;
22192
- };
22193
22191
  function _array_like_to_array$8(arr, len) {
22194
22192
  if (len == null || len > arr.length)
22195
22193
  len = arr.length;
@@ -22343,17 +22341,17 @@ function FlexibleTable(param) {
22343
22341
  return;
22344
22342
  }
22345
22343
  var scrollHandler = function() {
22346
- return setIsHorizontallyScrolled(scrollContainer.scrollLeft > 0);
22344
+ setIsHorizontallyScrolled(scrollContainer.scrollLeft > 0);
22347
22345
  };
22348
22346
  var resizeHandler = function() {
22349
- return setHasScrollBar(hasHorizontalScrollBar(scrollContainer));
22347
+ setHasScrollBar(hasHorizontalScrollBar(scrollContainer));
22350
22348
  };
22351
22349
  resizeHandler();
22352
22350
  scrollContainer.addEventListener("scroll", scrollHandler);
22353
- document.addEventListener("resize", resizeHandler);
22351
+ window.addEventListener("resize", resizeHandler);
22354
22352
  return function() {
22355
22353
  scrollContainer.removeEventListener("scroll", scrollHandler);
22356
- document.removeEventListener("resize", resizeHandler);
22354
+ window.removeEventListener("resize", resizeHandler);
22357
22355
  };
22358
22356
  }, [
22359
22357
  ref