@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 +14 -0
- package/dist/components/FiltersPane/types.d.ts +15 -5
- package/dist/components/FlexibleTable/FlexibleTable.d.ts +1 -1
- package/dist/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.d.ts +5 -4
- package/dist/components/FlexibleTable/constants.d.ts +18 -2
- package/dist/components/FlexibleTable/types.d.ts +1 -1
- package/dist/true-react-common-ui-kit.js +21 -18
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +21 -18
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/package.json +1 -1
- package/src/components/FiltersPane/components/FilterValueView/FilterValueView.tsx +19 -17
- package/src/components/FiltersPane/types.ts +23 -5
- package/src/components/FlexibleTable/FlexibleTable.tsx +1 -0
- package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.tsx +6 -3
- package/src/components/FlexibleTable/constants.ts +6 -3
- package/src/components/FlexibleTable/types.ts +1 -5
package/package.json
CHANGED
|
@@ -29,7 +29,7 @@ export function FilterValueView<Values, Key extends keyof Values>({
|
|
|
29
29
|
return <></>;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
if (filter.getSelectedValueView
|
|
32
|
+
if (isNotEmpty(filter.getSelectedValueView)) {
|
|
33
33
|
return <span className={classes.text}>{filter.getSelectedValueView(value)}</span>;
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -94,7 +94,7 @@ export function FilterValueView<Values, Key extends keyof Values>({
|
|
|
94
94
|
const intervalValueFrom = intervalValue[0];
|
|
95
95
|
const intervalValueTo = intervalValue[1];
|
|
96
96
|
|
|
97
|
-
const intervals = [];
|
|
97
|
+
const intervals: string[] = [];
|
|
98
98
|
if (intervalValueFrom !== undefined) {
|
|
99
99
|
intervals.push(`${translates.from.toLowerCase()} ${String(intervalValueFrom)}`);
|
|
100
100
|
}
|
|
@@ -105,19 +105,6 @@ export function FilterValueView<Values, Key extends keyof Values>({
|
|
|
105
105
|
return <span className={classes.text}>{intervals.join(' ')}</span>;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
if (isMultiple) {
|
|
109
|
-
return (
|
|
110
|
-
<>
|
|
111
|
-
{Array.isArray(value) && value.length > 0 && (
|
|
112
|
-
<>
|
|
113
|
-
<span className={classes.text}>{displayValue(value[0])}</span>
|
|
114
|
-
<span className={classes.count}>{value.length > 1 && ` (+${value.length - 1})`}</span>
|
|
115
|
-
</>
|
|
116
|
-
)}
|
|
117
|
-
</>
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
108
|
if (isDate) {
|
|
122
109
|
const { from, to, periodType, label } = value as unknown as IPeriod;
|
|
123
110
|
const hasFrom = from !== undefined && from !== null;
|
|
@@ -127,7 +114,7 @@ export function FilterValueView<Values, Key extends keyof Values>({
|
|
|
127
114
|
return <span className={classes.text}>{displayValue(label)}</span>;
|
|
128
115
|
}
|
|
129
116
|
|
|
130
|
-
const range = [];
|
|
117
|
+
const range: string[] = [];
|
|
131
118
|
if (hasFrom) {
|
|
132
119
|
if (!hasTo) {
|
|
133
120
|
range.push(translates.from.toLowerCase());
|
|
@@ -146,12 +133,27 @@ export function FilterValueView<Values, Key extends keyof Values>({
|
|
|
146
133
|
return <span className={classes.text}>{range.join(' ')}</span>;
|
|
147
134
|
}
|
|
148
135
|
|
|
136
|
+
if (isMultiple) {
|
|
137
|
+
const convertValue = filter.getSelectedValue ?? displayValue;
|
|
138
|
+
|
|
139
|
+
return (
|
|
140
|
+
<>
|
|
141
|
+
{Array.isArray(value) && value.length > 0 && (
|
|
142
|
+
<>
|
|
143
|
+
<span className={classes.text}>{convertValue(value[0])}</span>
|
|
144
|
+
<span className={classes.count}>{value.length > 1 && ` (+${value.length - 1})`}</span>
|
|
145
|
+
</>
|
|
146
|
+
)}
|
|
147
|
+
</>
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
149
151
|
if (isRange && Array.isArray(value)) {
|
|
150
152
|
const rangeValue = value as unknown as number[];
|
|
151
153
|
const rangeValueFrom = rangeValue[0];
|
|
152
154
|
const rangeValueTo = rangeValue[1];
|
|
153
155
|
|
|
154
|
-
const range = [];
|
|
156
|
+
const range: string[] = [];
|
|
155
157
|
if (rangeValueFrom !== undefined) {
|
|
156
158
|
range.push(`${translates.from.toLowerCase()} ${String(rangeValueFrom)}`);
|
|
157
159
|
}
|
|
@@ -84,22 +84,40 @@ export type IDateRangeConfigItem<Value> = IConfigItemBasicBase<Value> & {
|
|
|
84
84
|
dateFormat?: string;
|
|
85
85
|
} & Omit<IFilterWithPeriodProps, 'value' | 'onChange' | 'setIsOpen'>;
|
|
86
86
|
|
|
87
|
-
export
|
|
87
|
+
export interface ICustomComponentProps<Value> {
|
|
88
88
|
value?: Value;
|
|
89
89
|
onChange: (v?: Value) => void;
|
|
90
90
|
onClose?: () => void;
|
|
91
91
|
filter: ICustomConfigItem<Value>;
|
|
92
92
|
localeKey?: IFilterLocaleKey;
|
|
93
93
|
locale?: IPartialFilterLocale;
|
|
94
|
-
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export type CustomComponent<Value> = FC<ICustomComponentProps<Value>>;
|
|
97
|
+
|
|
98
|
+
export type ICustomValue<V> = V extends Array<infer T> ? T : never;
|
|
99
|
+
|
|
100
|
+
export interface ICustomRangeConfigItem<Value> extends IConfigItemBasicBase<Value> {
|
|
101
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
102
|
+
[key: string & {}]: any;
|
|
103
|
+
type: 'custom';
|
|
104
|
+
component: CustomComponent<Value>;
|
|
105
|
+
valueViewType?: 'range';
|
|
106
|
+
}
|
|
95
107
|
|
|
96
|
-
export interface
|
|
97
|
-
|
|
108
|
+
export interface ICustomMultipleConfigItem<Value> extends IConfigItemBasicBase<Value> {
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
110
|
+
[key: string & {}]: any;
|
|
98
111
|
type: 'custom';
|
|
99
112
|
component: CustomComponent<Value>;
|
|
100
|
-
valueViewType?: '
|
|
113
|
+
valueViewType?: 'multiple';
|
|
114
|
+
getSelectedValue?: (v: ICustomValue<Value>) => ReactNode;
|
|
101
115
|
}
|
|
102
116
|
|
|
117
|
+
export type ICustomConfigItem<Value> =
|
|
118
|
+
| ICustomRangeConfigItem<Value>
|
|
119
|
+
| ICustomMultipleConfigItem<Value>;
|
|
120
|
+
|
|
103
121
|
export type ConfigItem<Value> =
|
|
104
122
|
| ISelectConfigItem<Value>
|
|
105
123
|
| IMultiSelectConfigItem<Value>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ReactNode, useState, memo, MouseEvent } from 'react';
|
|
1
|
+
import { ReactNode, useState, memo, MouseEvent, RefCallback } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import { applyAction, isEmpty, isNotEmpty } from '@true-engineering/true-react-platform-helpers';
|
|
4
4
|
import { addDataAttributes } from '../../../../helpers';
|
|
5
5
|
import { useTweakStyles } from '../../../../hooks';
|
|
6
|
-
import {
|
|
6
|
+
import { IDataAttributes, ITweakStylesProps } from '../../../../types';
|
|
7
7
|
import { TableRenders } from '../../constants';
|
|
8
8
|
import {
|
|
9
9
|
ITableRow,
|
|
@@ -19,7 +19,7 @@ export interface IFlexibleTableRowProps<
|
|
|
19
19
|
Row extends ITableRow,
|
|
20
20
|
HeaderContent extends IHeaderContent<Row>,
|
|
21
21
|
UniqueField extends keyof Row,
|
|
22
|
-
> extends
|
|
22
|
+
> extends ITweakStylesProps<IFlexibleTableRowStyles> {
|
|
23
23
|
item: Row;
|
|
24
24
|
index: number;
|
|
25
25
|
uniqueField?: UniqueField;
|
|
@@ -38,6 +38,7 @@ export interface IFlexibleTableRowProps<
|
|
|
38
38
|
rowAttributes?: Array<keyof Row>;
|
|
39
39
|
/** @default false */
|
|
40
40
|
isExpandableRowComponentInitiallyOpen?: boolean | ((row: Row, index: number) => boolean);
|
|
41
|
+
rowRef?: RefCallback<HTMLTableRowElement>;
|
|
41
42
|
/** Возвращает React-элемент, который отрисуется под строкой при нажатии на неё */
|
|
42
43
|
expandableRowComponent?: (item: Row, isOpen: boolean, close: () => void) => ReactNode;
|
|
43
44
|
onRowHover?: (id?: Row[UniqueField]) => void;
|
|
@@ -61,6 +62,7 @@ function FlexibleTableRowInner<
|
|
|
61
62
|
isLoading = false,
|
|
62
63
|
rowAttributes,
|
|
63
64
|
isExpandableRowComponentInitiallyOpen = false,
|
|
65
|
+
rowRef,
|
|
64
66
|
tweakStyles,
|
|
65
67
|
expandableRowComponent,
|
|
66
68
|
onRowHover,
|
|
@@ -139,6 +141,7 @@ function FlexibleTableRowInner<
|
|
|
139
141
|
return (
|
|
140
142
|
<>
|
|
141
143
|
<Table.Row
|
|
144
|
+
ref={rowRef}
|
|
142
145
|
className={clsx(classes.root, {
|
|
143
146
|
[classes.active]: isActive,
|
|
144
147
|
[classes.editable]: isEditable,
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IFlexibleTableRenderElement, IFlexibleTableRenderMode } from './types';
|
|
2
2
|
|
|
3
3
|
export const DEFAULT_DATE_FORMAT = 'dd.MM.yyyy';
|
|
4
4
|
|
|
5
|
-
export const TableRenders
|
|
5
|
+
export const TableRenders = {
|
|
6
6
|
table: { Root: 'table', Head: 'thead', Body: 'tbody', Row: 'tr', Header: 'th', Cell: 'td' },
|
|
7
7
|
divs: { Root: 'div', Head: 'div', Body: 'div', Row: 'div', Header: 'div', Cell: 'div' },
|
|
8
|
-
}
|
|
8
|
+
} satisfies Record<
|
|
9
|
+
IFlexibleTableRenderMode,
|
|
10
|
+
Record<IFlexibleTableRenderElement, keyof JSX.IntrinsicElements>
|
|
11
|
+
>;
|
|
@@ -2,11 +2,7 @@ import { CSSProperties, MouseEvent, ReactNode } from 'react';
|
|
|
2
2
|
import { IRenderNode } from '../../types';
|
|
3
3
|
|
|
4
4
|
export type IFlexibleTableRenderMode = 'table' | 'divs';
|
|
5
|
-
|
|
6
|
-
export type IFlexibleTableRender = Record<
|
|
7
|
-
'Root' | 'Head' | 'Body' | 'Row' | 'Header' | 'Cell',
|
|
8
|
-
keyof JSX.IntrinsicElements
|
|
9
|
-
>;
|
|
5
|
+
export type IFlexibleTableRenderElement = 'Root' | 'Head' | 'Body' | 'Row' | 'Header' | 'Cell';
|
|
10
6
|
|
|
11
7
|
// TODO: Заменить Record<string, any> на Record<string, unknown>
|
|
12
8
|
export type ITableRow = Record<string, any>;
|