@true-engineering/true-react-common-ui-kit 4.0.0-alpha17 → 4.0.0-alpha19

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@true-engineering/true-react-common-ui-kit",
3
- "version": "4.0.0-alpha17",
3
+ "version": "4.0.0-alpha19",
4
4
  "description": "True Engineering React UI Kit with theming support",
5
5
  "author": "True Engineering (https://trueengineering.ru)",
6
6
  "keywords": [
@@ -4,7 +4,7 @@ import { addDataAttributes } from '../../helpers';
4
4
  import { useTweakStyles } from '../../hooks';
5
5
  import { ICommonProps } from '../../types';
6
6
  import { Button } from '../Button';
7
- import { Icon } from '../Icon';
7
+ import { IIcon, renderIcon } from '../Icon';
8
8
  import { FilterWrapper, IFiltersPaneSearchProps, FiltersPaneSearch } from './components';
9
9
  import { getLocale } from './helpers';
10
10
  import { ConfigType, IFilterLocaleKey, IPartialFilterLocale } from './types';
@@ -25,6 +25,8 @@ export interface IFiltersPaneProps<Values extends Record<string, unknown>, Conte
25
25
  hasClearButton?: boolean;
26
26
  /** @default false */
27
27
  shouldRenderDataId?: boolean;
28
+ /** @default 'filter' */
29
+ settingsIcon?: IIcon;
28
30
  onChangeFilters: (values: Partial<Values>) => void;
29
31
  onSettingsButtonClick?: () => void;
30
32
  onClear?: () => void;
@@ -42,6 +44,7 @@ export function FiltersPane<Values extends Record<string, unknown>, Content = Va
42
44
  isDisabled = false,
43
45
  hasClearButton = true,
44
46
  shouldRenderDataId = false,
47
+ settingsIcon = 'filter',
45
48
  testId,
46
49
  onChangeFilters,
47
50
  onSettingsButtonClick,
@@ -107,9 +110,7 @@ export function FiltersPane<Values extends Record<string, unknown>, Content = Va
107
110
  {...addDataTestId(testId, 'settings-button')}
108
111
  onClick={!isDisabled ? onSettingsButtonClick : undefined}
109
112
  >
110
- <div className={classes.settingsIcon}>
111
- <Icon type="filter" />
112
- </div>
113
+ <div className={classes.settingsIcon}>{renderIcon(settingsIcon)}</div>
113
114
  </div>
114
115
  )}
115
116
  {/* Search */}
@@ -1,3 +1,4 @@
1
+ import { ReactNode, useCallback } from 'react';
1
2
  import clsx from 'clsx';
2
3
  import { applyAction, isNotEmpty } from '@true-engineering/true-react-platform-helpers';
3
4
  import { addDataAttributes } from '../../../../helpers';
@@ -20,14 +21,11 @@ export interface IFlexibleTableCellProps<
20
21
  > extends Pick<ICommonProps<IFlexibleTableCellStyles>, 'tweakStyles'>,
21
22
  Pick<
22
23
  IValueComponentProps<Row, unknown>,
23
- | 'isFocusedRow'
24
- | 'isActiveRow'
25
- | 'isNestedComponentExpanded'
26
- | 'isRowNestedComponentExpanded'
27
- | 'onSetNestedComponent'
24
+ 'isFocusedRow' | 'isActiveRow' | 'isNestedComponentExpanded' | 'isRowNestedComponentExpanded'
28
25
  > {
29
26
  row: Row;
30
27
  columnName: keyof Row;
28
+ updateNestedComponent: (component: ReactNode, cellKey: keyof Row) => void;
31
29
  config: IFlexibleTableConfigType<Row, HeaderContent>;
32
30
  renderMode: IFlexibleTableRenderMode;
33
31
  isSecond?: boolean;
@@ -46,6 +44,7 @@ export function FlexibleTableCell<
46
44
  isSecond,
47
45
  isSticky: isOldSticky,
48
46
  isLoading,
47
+ updateNestedComponent,
49
48
  tweakStyles,
50
49
  ...valueComponentProps
51
50
  }: IFlexibleTableCellProps<Row, HeaderContent>): JSX.Element {
@@ -73,6 +72,10 @@ export function FlexibleTableCell<
73
72
 
74
73
  const cellComponentProps: IValueComponentProps<Row, Row[keyof Row]> = {
75
74
  ...valueComponentProps,
75
+ onSetNestedComponent: useCallback(
76
+ (node) => updateNestedComponent(node, columnName),
77
+ [columnName, updateNestedComponent],
78
+ ),
76
79
  value,
77
80
  row,
78
81
  };
@@ -1,4 +1,4 @@
1
- import { ReactNode, useState, memo, MouseEvent, RefCallback } from 'react';
1
+ import { ReactNode, useState, memo, MouseEvent, RefCallback, useCallback } from 'react';
2
2
  import clsx from 'clsx';
3
3
  import { isEmpty, isNotEmpty } from '@true-engineering/true-react-platform-helpers';
4
4
  import { addDataAttributes } from '../../../../helpers';
@@ -75,7 +75,7 @@ function FlexibleTableRowInner<
75
75
  });
76
76
 
77
77
  const [isFocused, setFocused] = useState(false);
78
- const [nestedComponent, setNestedComponent] = useState<INestedComponent>(() => ({
78
+ const [nestedComponent, setNestedComponent] = useState<INestedComponent<keyof Row>>(() => ({
79
79
  isOpen: isExpandableRowComponentInitiallyOpen,
80
80
  }));
81
81
 
@@ -111,13 +111,13 @@ function FlexibleTableRowInner<
111
111
  setNestedComponent({ isOpen: false });
112
112
  };
113
113
 
114
- const updateNestedComponent = (component: ReactNode, cellKey: string) => {
114
+ const updateNestedComponent = useCallback((component: ReactNode, cellKey: keyof Row) => {
115
115
  if (isEmpty(component)) {
116
116
  closeNestedComponent();
117
117
  } else {
118
118
  setNestedComponent({ isOpen: true, component, cellKey });
119
119
  }
120
- };
120
+ }, []);
121
121
 
122
122
  const handleRowClick = () => {
123
123
  if (isNotEmpty(uniqueField)) {
@@ -174,7 +174,7 @@ function FlexibleTableRowInner<
174
174
  isRowNestedComponentExpanded={
175
175
  isNestedComponentExpanded && isEmpty(nestedComponentCellKey)
176
176
  }
177
- onSetNestedComponent={(component) => updateNestedComponent(component, key)}
177
+ updateNestedComponent={updateNestedComponent}
178
178
  />
179
179
  ))}
180
180
  </Table.Row>
@@ -36,16 +36,16 @@ export interface IFlexibleTableRowConfig<
36
36
  title?: IRenderNode<ITitleComponentProps<HeaderContent[Key]>>;
37
37
  component?: IRenderNode<IValueComponentProps<Values, NonNullable<Values[Key]>>>;
38
38
  dateFormat?: string;
39
- minWidth?: string | number;
40
- width?: string | number;
41
- maxWidth?: string | number;
39
+ minWidth?: CSSProperties['minWidth'];
40
+ width?: CSSProperties['width'];
41
+ maxWidth?: CSSProperties['maxWidth'];
42
42
  /** @default 'left' */
43
43
  titleAlign?: CSSProperties['textAlign'];
44
44
  cellAlign?: CSSProperties['textAlign'];
45
45
  cellVerticalAlign?: CSSProperties['verticalAlign'];
46
46
  position?: CSSProperties['position'];
47
- right?: number;
48
- left?: number;
47
+ right?: CSSProperties['right'];
48
+ left?: CSSProperties['left'];
49
49
  shouldRenderDataId?: boolean;
50
50
  /**
51
51
  * Проверка, нужно ли отрисовать component
@@ -71,8 +71,8 @@ export interface IInfinityScrollConfig {
71
71
  onInfinityScroll: (skip: number) => void;
72
72
  }
73
73
 
74
- export interface INestedComponent {
74
+ export interface INestedComponent<T extends PropertyKey = string> {
75
75
  isOpen: boolean;
76
76
  component?: ReactNode;
77
- cellKey?: string;
77
+ cellKey?: T;
78
78
  }