@true-engineering/true-react-common-ui-kit 3.47.0 → 3.49.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,20 @@
11
11
 
12
12
  # Release Notes
13
13
 
14
+ ## 3.49.0
15
+
16
+ ### Changes
17
+
18
+ - **FiltersPane**: Добавлен `getSelectedValue` для удобного рендера значения в `custom`-фильтре с `valueViewType: 'multiple'`
19
+ - **FiltersPane**: Добавлен экспорт `ICustomComponentProps` для `CustomComponent` в `ICustomConfigItem`
20
+ - **FiltersPane**: Кастомный фильтр разделён на два типа `ICustomRangeConfigItem` и `ICustomMultipleConfigItem`
21
+
22
+ ## 3.48.0
23
+
24
+ ### Changes
25
+
26
+ - **FlexibleTable**: Добавлен rowRef
27
+
14
28
  ## 3.47.0
15
29
 
16
30
  ### Changes
@@ -54,20 +54,30 @@ export type IDateRangeConfigItem<Value> = IConfigItemBasicBase<Value> & {
54
54
  type: 'dateRange';
55
55
  dateFormat?: string;
56
56
  } & Omit<IFilterWithPeriodProps, 'value' | 'onChange' | 'setIsOpen'>;
57
- export type CustomComponent<Value> = FC<{
57
+ export interface ICustomComponentProps<Value> {
58
58
  value?: Value;
59
59
  onChange: (v?: Value) => void;
60
60
  onClose?: () => void;
61
61
  filter: ICustomConfigItem<Value>;
62
62
  localeKey?: IFilterLocaleKey;
63
63
  locale?: IPartialFilterLocale;
64
- }>;
65
- export interface ICustomConfigItem<Value> extends IConfigItemBasicBase<Value> {
66
- [key: string]: any;
64
+ }
65
+ export type CustomComponent<Value> = FC<ICustomComponentProps<Value>>;
66
+ export type ICustomValue<V> = V extends Array<infer T> ? T : never;
67
+ export interface ICustomRangeConfigItem<Value> extends IConfigItemBasicBase<Value> {
68
+ [key: string & {}]: any;
69
+ type: 'custom';
70
+ component: CustomComponent<Value>;
71
+ valueViewType?: 'range';
72
+ }
73
+ export interface ICustomMultipleConfigItem<Value> extends IConfigItemBasicBase<Value> {
74
+ [key: string & {}]: any;
67
75
  type: 'custom';
68
76
  component: CustomComponent<Value>;
69
- valueViewType?: 'range' | 'multiple';
77
+ valueViewType?: 'multiple';
78
+ getSelectedValue?: (v: ICustomValue<Value>) => ReactNode;
70
79
  }
80
+ export type ICustomConfigItem<Value> = ICustomRangeConfigItem<Value> | ICustomMultipleConfigItem<Value>;
71
81
  export type ConfigItem<Value> = ISelectConfigItem<Value> | IMultiSelectConfigItem<Value> | ICustomConfigItem<Value> | IDateRangeWithoutPeriodConfigItem<Value> | IDateRangeConfigItem<Value> | IIntervalConfigItem<Value> | IBooleanConfigItem<Value>;
72
82
  export type ConfigType<Values> = {
73
83
  [K in keyof Values]: ConfigItem<Values[K]>;
@@ -3,7 +3,7 @@ import { ICommonProps } from '../../types';
3
3
  import { IFlexibleTableRowProps } from './components';
4
4
  import { ITableRow, IFlexibleTableConfigType, IInfinityScrollConfig, IFlexibleTableRenderMode, IHeaderContent } from './types';
5
5
  import { IFlexibleTableStyles } from './FlexibleTable.styles';
6
- export interface IFlexibleTableProps<Row extends ITableRow, HeaderContent extends IHeaderContent<Row>, UniqueField extends keyof Row> extends ICommonProps<IFlexibleTableStyles>, Pick<IFlexibleTableRowProps<Row, HeaderContent, UniqueField>, 'uniqueField' | 'rowAttributes' | 'isFirstColumnSticky' | 'isExpandableRowComponentInitiallyOpen' | 'expandableRowComponent' | 'onRowClick' | 'onRowHover'> {
6
+ export interface IFlexibleTableProps<Row extends ITableRow, HeaderContent extends IHeaderContent<Row>, UniqueField extends keyof Row> extends ICommonProps<IFlexibleTableStyles>, Pick<IFlexibleTableRowProps<Row, HeaderContent, UniqueField>, 'uniqueField' | 'rowAttributes' | 'isFirstColumnSticky' | 'isExpandableRowComponentInitiallyOpen' | 'expandableRowComponent' | 'onRowClick' | 'onRowHover' | 'rowRef'> {
7
7
  content: Row[];
8
8
  /** @default 'table' */
9
9
  renderMode?: IFlexibleTableRenderMode;
@@ -1,8 +1,8 @@
1
- import { ReactNode } from 'react';
2
- import { ICommonProps } from '../../../../types';
1
+ import { ReactNode, RefCallback } from 'react';
2
+ import { ITweakStylesProps } from '../../../../types';
3
3
  import { ITableRow, IFlexibleTableConfigType, IFlexibleTableRenderMode, IHeaderContent } from '../../types';
4
4
  import { IFlexibleTableRowStyles } from './FlexibleTableRow.styles';
5
- export interface IFlexibleTableRowProps<Row extends ITableRow, HeaderContent extends IHeaderContent<Row>, UniqueField extends keyof Row> extends Pick<ICommonProps<IFlexibleTableRowStyles>, 'tweakStyles'> {
5
+ export interface IFlexibleTableRowProps<Row extends ITableRow, HeaderContent extends IHeaderContent<Row>, UniqueField extends keyof Row> extends ITweakStylesProps<IFlexibleTableRowStyles> {
6
6
  item: Row;
7
7
  index: number;
8
8
  uniqueField?: UniqueField;
@@ -21,11 +21,12 @@ export interface IFlexibleTableRowProps<Row extends ITableRow, HeaderContent ext
21
21
  rowAttributes?: Array<keyof Row>;
22
22
  /** @default false */
23
23
  isExpandableRowComponentInitiallyOpen?: boolean | ((row: Row, index: number) => boolean);
24
+ rowRef?: RefCallback<HTMLTableRowElement>;
24
25
  /** Возвращает React-элемент, который отрисуется под строкой при нажатии на неё */
25
26
  expandableRowComponent?: (item: Row, isOpen: boolean, close: () => void) => ReactNode;
26
27
  onRowHover?: (id?: Row[UniqueField]) => void;
27
28
  onRowClick?: (id: Row[UniqueField]) => void;
28
29
  }
29
- declare function FlexibleTableRowInner<Row extends ITableRow, HeaderContent extends IHeaderContent<Row>, UniqueField extends keyof Row>({ item, index, config, columns, uniqueField, renderMode, isActive, isFocusable, isFirstColumnSticky, isLoading, rowAttributes, isExpandableRowComponentInitiallyOpen, tweakStyles, expandableRowComponent, onRowHover, onRowClick, }: IFlexibleTableRowProps<Row, HeaderContent, UniqueField>): JSX.Element;
30
+ declare function FlexibleTableRowInner<Row extends ITableRow, HeaderContent extends IHeaderContent<Row>, UniqueField extends keyof Row>({ item, index, config, columns, uniqueField, renderMode, isActive, isFocusable, isFirstColumnSticky, isLoading, rowAttributes, isExpandableRowComponentInitiallyOpen, rowRef, tweakStyles, expandableRowComponent, onRowHover, onRowClick, }: IFlexibleTableRowProps<Row, HeaderContent, UniqueField>): JSX.Element;
30
31
  export declare const FlexibleTableRow: typeof FlexibleTableRowInner;
31
32
  export {};
@@ -1,3 +1,19 @@
1
- import { IFlexibleTableRenderMode, IFlexibleTableRender } from './types';
2
1
  export declare const DEFAULT_DATE_FORMAT = "dd.MM.yyyy";
3
- export declare const TableRenders: Record<IFlexibleTableRenderMode, IFlexibleTableRender>;
2
+ export declare const TableRenders: {
3
+ table: {
4
+ Root: "table";
5
+ Head: "thead";
6
+ Body: "tbody";
7
+ Row: "tr";
8
+ Header: "th";
9
+ Cell: "td";
10
+ };
11
+ divs: {
12
+ Root: "div";
13
+ Head: "div";
14
+ Body: "div";
15
+ Row: "div";
16
+ Header: "div";
17
+ Cell: "div";
18
+ };
19
+ };
@@ -1,7 +1,7 @@
1
1
  import { CSSProperties, MouseEvent, ReactNode } from 'react';
2
2
  import { IRenderNode } from '../../types';
3
3
  export type IFlexibleTableRenderMode = 'table' | 'divs';
4
- export type IFlexibleTableRender = Record<'Root' | 'Head' | 'Body' | 'Row' | 'Header' | 'Cell', keyof JSX.IntrinsicElements>;
4
+ export type IFlexibleTableRenderElement = 'Root' | 'Head' | 'Body' | 'Row' | 'Header' | 'Cell';
5
5
  export type ITableRow = Record<string, any>;
6
6
  export type IHeaderContent<T extends ITableRow> = Partial<Record<keyof T, unknown>>;
7
7
  export interface ITitleComponentProps<Value> {
@@ -19060,7 +19060,7 @@ function FilterValueView(param) {
19060
19060
  if (isEmpty(value)) {
19061
19061
  return /* @__PURE__ */ jsx(Fragment, {});
19062
19062
  }
19063
- if (filter.getSelectedValueView !== void 0) {
19063
+ if (isNotEmpty(filter.getSelectedValueView)) {
19064
19064
  return /* @__PURE__ */ jsx("span", {
19065
19065
  className: classes.text,
19066
19066
  children: filter.getSelectedValueView(value)
@@ -19129,22 +19129,6 @@ function FilterValueView(param) {
19129
19129
  children: intervals.join(" ")
19130
19130
  });
19131
19131
  }
19132
- if (isMultiple) {
19133
- return /* @__PURE__ */ jsx(Fragment, {
19134
- children: Array.isArray(value) && value.length > 0 && /* @__PURE__ */ jsxs(Fragment, {
19135
- children: [
19136
- /* @__PURE__ */ jsx("span", {
19137
- className: classes.text,
19138
- children: displayValue(value[0])
19139
- }),
19140
- /* @__PURE__ */ jsx("span", {
19141
- className: classes.count,
19142
- children: value.length > 1 && " (+".concat(value.length - 1, ")")
19143
- })
19144
- ]
19145
- })
19146
- });
19147
- }
19148
19132
  if (isDate) {
19149
19133
  var from = value.from, to = value.to, periodType = value.periodType, label = value.label;
19150
19134
  var hasFrom = from !== void 0 && from !== null;
@@ -19175,6 +19159,24 @@ function FilterValueView(param) {
19175
19159
  children: range.join(" ")
19176
19160
  });
19177
19161
  }
19162
+ if (isMultiple) {
19163
+ var _filter_getSelectedValue;
19164
+ var convertValue = (_filter_getSelectedValue = filter.getSelectedValue) !== null && _filter_getSelectedValue !== void 0 ? _filter_getSelectedValue : displayValue;
19165
+ return /* @__PURE__ */ jsx(Fragment, {
19166
+ children: Array.isArray(value) && value.length > 0 && /* @__PURE__ */ jsxs(Fragment, {
19167
+ children: [
19168
+ /* @__PURE__ */ jsx("span", {
19169
+ className: classes.text,
19170
+ children: convertValue(value[0])
19171
+ }),
19172
+ /* @__PURE__ */ jsx("span", {
19173
+ className: classes.count,
19174
+ children: value.length > 1 && " (+".concat(value.length - 1, ")")
19175
+ })
19176
+ ]
19177
+ })
19178
+ });
19179
+ }
19178
19180
  if (isRange && Array.isArray(value)) {
19179
19181
  var rangeValue = value;
19180
19182
  var rangeValueFrom = rangeValue[0];
@@ -26296,7 +26298,7 @@ function _unsupported_iterable_to_array$7(o, minLen) {
26296
26298
  return _array_like_to_array$7(o, minLen);
26297
26299
  }
26298
26300
  function FlexibleTableRowInner(param) {
26299
- var item = param.item, index = param.index, config = param.config, columns = param.columns, uniqueField = param.uniqueField, renderMode = param.renderMode, _param_isActive = param.isActive, isActive = _param_isActive === void 0 ? false : _param_isActive, _param_isFocusable = param.isFocusable, isFocusable = _param_isFocusable === void 0 ? false : _param_isFocusable, _param_isFirstColumnSticky = param.isFirstColumnSticky, isFirstColumnSticky = _param_isFirstColumnSticky === void 0 ? false : _param_isFirstColumnSticky, _param_isLoading = param.isLoading, isLoading = _param_isLoading === void 0 ? false : _param_isLoading, rowAttributes = param.rowAttributes, _param_isExpandableRowComponentInitiallyOpen = param.isExpandableRowComponentInitiallyOpen, isExpandableRowComponentInitiallyOpen = _param_isExpandableRowComponentInitiallyOpen === void 0 ? false : _param_isExpandableRowComponentInitiallyOpen, tweakStyles = param.tweakStyles, expandableRowComponent = param.expandableRowComponent, onRowHover = param.onRowHover, onRowClick = param.onRowClick;
26301
+ var item = param.item, index = param.index, config = param.config, columns = param.columns, uniqueField = param.uniqueField, renderMode = param.renderMode, _param_isActive = param.isActive, isActive = _param_isActive === void 0 ? false : _param_isActive, _param_isFocusable = param.isFocusable, isFocusable = _param_isFocusable === void 0 ? false : _param_isFocusable, _param_isFirstColumnSticky = param.isFirstColumnSticky, isFirstColumnSticky = _param_isFirstColumnSticky === void 0 ? false : _param_isFirstColumnSticky, _param_isLoading = param.isLoading, isLoading = _param_isLoading === void 0 ? false : _param_isLoading, rowAttributes = param.rowAttributes, _param_isExpandableRowComponentInitiallyOpen = param.isExpandableRowComponentInitiallyOpen, isExpandableRowComponentInitiallyOpen = _param_isExpandableRowComponentInitiallyOpen === void 0 ? false : _param_isExpandableRowComponentInitiallyOpen, rowRef = param.rowRef, tweakStyles = param.tweakStyles, expandableRowComponent = param.expandableRowComponent, onRowHover = param.onRowHover, onRowClick = param.onRowClick;
26300
26302
  var classes = useStyles$h({
26301
26303
  theme: tweakStyles
26302
26304
  });
@@ -26373,6 +26375,7 @@ function FlexibleTableRowInner(param) {
26373
26375
  return /* @__PURE__ */ jsxs(Fragment, {
26374
26376
  children: [
26375
26377
  /* @__PURE__ */ jsx(Table.Row, _object_spread_props$k(_object_spread$l({
26378
+ ref: rowRef,
26376
26379
  className: clsx(classes.root, (_obj2 = {}, _define_property$m(_obj2, classes.active, isActive), _define_property$m(_obj2, classes.editable, isEditable), _define_property$m(_obj2, classes.clickable, isClickable), _obj2))
26377
26380
  }, !isLoading && {
26378
26381
  onClick: handleRowClick,