@true-engineering/true-react-common-ui-kit 3.1.1 → 3.4.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 +12 -0
- package/dist/components/AccountInfo/AccountInfo.d.ts +1 -0
- package/dist/components/AddButton/AddButton.d.ts +4 -1
- package/dist/components/Button/Button.d.ts +11 -29
- package/dist/components/Checkbox/Checkbox.d.ts +7 -5
- package/dist/components/CloseButton/CloseButton.d.ts +2 -1
- package/dist/components/DateInput/DateInput.d.ts +5 -2
- package/dist/components/DatePicker/DatePicker.d.ts +7 -5
- package/dist/components/Description/Description.d.ts +2 -0
- package/dist/components/FiltersPane/FiltersPane.d.ts +6 -3
- package/dist/components/FiltersPane/components/FilterWithDates/FilterWithDates.d.ts +3 -3
- package/dist/components/FiltersPane/components/FilterWithPeriod/FilterWithPeriod.d.ts +2 -2
- package/dist/components/FiltersPane/components/FilterWrapper/FilterWrapper.d.ts +1 -1
- package/dist/components/Flag/Flag.d.ts +1 -0
- package/dist/components/FlexibleTable/FlexibleTable.d.ts +7 -4
- package/dist/components/FlexibleTable/FlexibleTable.stories.d.ts +1 -1
- package/dist/components/FlexibleTable/FlexibleTable.styles.d.ts +1 -1
- package/dist/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.d.ts +4 -2
- package/dist/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.d.ts +6 -4
- package/dist/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.styles.d.ts +1 -1
- package/dist/components/IncrementInput/IncrementInput.d.ts +1 -0
- package/dist/components/Input/Input.d.ts +17 -23
- package/dist/components/Input/Input.stories.d.ts +1 -1
- package/dist/components/Input/types.d.ts +2 -0
- package/dist/components/List/List.d.ts +1 -1
- package/dist/components/List/components/ListItem/ListItem.d.ts +1 -1
- package/dist/components/Modal/Modal.d.ts +11 -1
- package/dist/components/MoreMenu/MoreMenu.d.ts +4 -5
- package/dist/components/MultiSelect/MultiSelect.d.ts +7 -2
- package/dist/components/MultiSelect/components/MultiSelectInput/MultiSelectInput.d.ts +1 -1
- package/dist/components/MultiSelectList/MultiSelectList.d.ts +3 -0
- package/dist/components/Notification/Notification.d.ts +2 -6
- package/dist/components/Notification/Notification.styles.d.ts +1 -1
- package/dist/components/NumberInput/NumberInput.d.ts +5 -1
- package/dist/components/PhoneInput/PhoneInput.d.ts +5 -1
- package/dist/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.d.ts +2 -2
- package/dist/components/RadioButton/RadioButton.d.ts +3 -1
- package/dist/components/Select/Select.d.ts +17 -12
- package/dist/components/Select/components/SelectList/SelectList.d.ts +6 -6
- package/dist/components/Select/components/SelectListItem/SelectListItem.d.ts +2 -2
- package/dist/components/SmartInput/SmartInput.d.ts +2 -0
- package/dist/components/SmartInput/SmartInput.stories.d.ts +1 -1
- package/dist/components/Switch/Switch.d.ts +6 -7
- package/dist/components/TextArea/TextArea.d.ts +13 -4
- package/dist/components/TextButton/TextButton.d.ts +1 -1
- package/dist/components/TextWithInfo/TextWithInfo.d.ts +2 -1
- package/dist/components/TextWithTooltip/TextWithTooltip.d.ts +7 -0
- package/dist/components/ThemedPreloader/ThemedPreloader.d.ts +2 -3
- package/dist/components/Toaster/Toaster.d.ts +5 -11
- package/dist/components/Tooltip/Tooltip.d.ts +2 -6
- package/dist/hooks/use-dropdown.d.ts +1 -1
- package/dist/true-react-common-ui-kit.js +138 -45
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +138 -45
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/package.json +1 -1
- package/src/components/AccountInfo/AccountInfo.tsx +1 -0
- package/src/components/AddButton/AddButton.tsx +6 -3
- package/src/components/Button/Button.tsx +11 -29
- package/src/components/Checkbox/Checkbox.tsx +12 -10
- package/src/components/CloseButton/CloseButton.tsx +2 -1
- package/src/components/DateInput/DateInput.tsx +6 -3
- package/src/components/DatePicker/DatePicker.tsx +10 -8
- package/src/components/Description/Description.tsx +2 -0
- package/src/components/FiltersPane/FiltersPane.tsx +6 -3
- package/src/components/FiltersPane/components/FilterWithDates/FilterWithDates.tsx +3 -3
- package/src/components/FiltersPane/components/FilterWithPeriod/FilterWithPeriod.tsx +2 -2
- package/src/components/FiltersPane/components/FilterWrapper/FilterWrapper.tsx +1 -1
- package/src/components/Flag/Flag.tsx +1 -0
- package/src/components/FlexibleTable/FlexibleTable.styles.ts +14 -0
- package/src/components/FlexibleTable/FlexibleTable.tsx +53 -33
- package/src/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.tsx +8 -3
- package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.styles.ts +2 -0
- package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.tsx +17 -8
- package/src/components/IncrementInput/IncrementInput.tsx +1 -0
- package/src/components/Input/Input.tsx +28 -41
- package/src/components/Input/types.ts +26 -0
- package/src/components/List/List.tsx +1 -1
- package/src/components/List/components/ListItem/ListItem.tsx +1 -1
- package/src/components/Modal/Modal.tsx +12 -2
- package/src/components/MoreMenu/MoreMenu.tsx +5 -6
- package/src/components/MultiSelect/MultiSelect.tsx +9 -4
- package/src/components/MultiSelect/components/MultiSelectInput/MultiSelectInput.tsx +1 -1
- package/src/components/MultiSelectList/MultiSelectList.tsx +3 -0
- package/src/components/Notification/Notification.tsx +2 -6
- package/src/components/NumberInput/NumberInput.tsx +5 -1
- package/src/components/PhoneInput/PhoneInput.tsx +6 -2
- package/src/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.tsx +2 -2
- package/src/components/RadioButton/RadioButton.tsx +5 -3
- package/src/components/Select/Select.tsx +18 -13
- package/src/components/Select/components/SelectList/SelectList.tsx +6 -6
- package/src/components/Select/components/SelectListItem/SelectListItem.tsx +2 -2
- package/src/components/SmartInput/SmartInput.tsx +11 -1
- package/src/components/Switch/Switch.tsx +8 -9
- package/src/components/TextArea/TextArea.tsx +16 -7
- package/src/components/TextButton/TextButton.tsx +1 -1
- package/src/components/TextWithInfo/TextWithInfo.tsx +2 -1
- package/src/components/TextWithTooltip/TextWithTooltip.tsx +8 -1
- package/src/components/ThemedPreloader/ThemedPreloader.tsx +2 -3
- package/src/components/Toaster/Toaster.tsx +5 -11
- package/src/components/Tooltip/Tooltip.tsx +2 -6
- package/src/hooks/use-dropdown.ts +1 -1
package/package.json
CHANGED
|
@@ -11,6 +11,7 @@ import { ANIMATION_TIMEOUT } from './constants';
|
|
|
11
11
|
import { useStyles, IAccountInfoStyles } from './AccountInfo.styles';
|
|
12
12
|
|
|
13
13
|
export interface IAccountInfoProps extends ICommonProps<IAccountInfoStyles> {
|
|
14
|
+
/** @default `<Icon type='avatar' />` */
|
|
14
15
|
avatar?: ReactNode;
|
|
15
16
|
accountName: ReactNode;
|
|
16
17
|
options: IListProps['items'];
|
|
@@ -8,19 +8,22 @@ import { useStyles, IAddButtonStyles } from './AddButton.styles';
|
|
|
8
8
|
|
|
9
9
|
export interface IAddButtonProps extends ICommonProps<IAddButtonStyles> {
|
|
10
10
|
text: string;
|
|
11
|
+
/** @default 'button' */
|
|
11
12
|
type?: 'submit' | 'button';
|
|
13
|
+
/** @default false */
|
|
12
14
|
isDisabled?: boolean;
|
|
15
|
+
/** @default false */
|
|
13
16
|
isFullWidth?: boolean;
|
|
14
|
-
onClick
|
|
17
|
+
onClick?: () => void | Promise<void>;
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
// TODO: Весьма сомнительный компонент
|
|
18
21
|
export const AddButton: FC<IAddButtonProps> = ({
|
|
19
22
|
text,
|
|
20
23
|
type = 'button',
|
|
21
|
-
isDisabled,
|
|
24
|
+
isDisabled = false,
|
|
22
25
|
onClick,
|
|
23
|
-
isFullWidth,
|
|
26
|
+
isFullWidth = false,
|
|
24
27
|
data,
|
|
25
28
|
testId,
|
|
26
29
|
tweakStyles,
|
|
@@ -11,29 +11,17 @@ import { useStyles, IButtonStyles, getPreloaderStyles } from './Button.styles';
|
|
|
11
11
|
|
|
12
12
|
export interface IButtonProps extends ICommonProps<IButtonStyles> {
|
|
13
13
|
children?: ReactNode;
|
|
14
|
-
/**
|
|
15
|
-
* @default `button`
|
|
16
|
-
*/
|
|
14
|
+
/** @default 'button' */
|
|
17
15
|
type?: ButtonHTMLAttributes<unknown>['type'];
|
|
18
|
-
/**
|
|
19
|
-
* @default `l`
|
|
20
|
-
*/
|
|
16
|
+
/** @default 'l' */
|
|
21
17
|
size?: IButtonSize;
|
|
22
|
-
/**
|
|
23
|
-
* @default `primary`
|
|
24
|
-
*/
|
|
18
|
+
/** @default 'primary' */
|
|
25
19
|
view?: IButtonView;
|
|
26
|
-
/**
|
|
27
|
-
* @default false
|
|
28
|
-
*/
|
|
20
|
+
/** @default false */
|
|
29
21
|
shouldSkipTabNavigation?: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* @default false
|
|
32
|
-
*/
|
|
22
|
+
/** @default false */
|
|
33
23
|
isDisabled?: boolean;
|
|
34
|
-
/**
|
|
35
|
-
* @default false
|
|
36
|
-
*/
|
|
24
|
+
/** @default false */
|
|
37
25
|
isFullWidth?: boolean;
|
|
38
26
|
/**
|
|
39
27
|
* Нужно ли убирать скругление у кнопки слева
|
|
@@ -45,21 +33,15 @@ export interface IButtonProps extends ICommonProps<IButtonStyles> {
|
|
|
45
33
|
* @default false
|
|
46
34
|
*/
|
|
47
35
|
isLoading?: boolean;
|
|
48
|
-
/**
|
|
49
|
-
* @default false
|
|
50
|
-
*/
|
|
36
|
+
/** @default false */
|
|
51
37
|
isActive?: boolean;
|
|
52
38
|
icon?: IIcon;
|
|
53
|
-
/**
|
|
54
|
-
* @default `left`
|
|
55
|
-
*/
|
|
39
|
+
/** @default 'left' */
|
|
56
40
|
iconPosition?: 'left' | 'right';
|
|
57
|
-
/**
|
|
58
|
-
* @default `dots`
|
|
59
|
-
*/
|
|
41
|
+
/** @default 'dots' */
|
|
60
42
|
preloaderType?: IThemedPreloaderProps['type'];
|
|
61
|
-
onClick
|
|
62
|
-
onMouseDown
|
|
43
|
+
onClick?: (event: MouseEvent<HTMLButtonElement>) => void | Promise<void>;
|
|
44
|
+
onMouseDown?: (event: MouseEvent<HTMLButtonElement>) => void | Promise<void>;
|
|
63
45
|
}
|
|
64
46
|
|
|
65
47
|
export const Button = forwardRef<HTMLButtonElement, IButtonProps>(
|
|
@@ -13,27 +13,29 @@ import { useStyles, ICheckboxStyles } from './Checkbox.styles';
|
|
|
13
13
|
export interface ICheckboxProps<V> extends ICommonProps<ICheckboxStyles> {
|
|
14
14
|
children?: ReactNode;
|
|
15
15
|
isChecked: boolean | undefined;
|
|
16
|
+
/** @default false */
|
|
16
17
|
isSemiChecked?: boolean;
|
|
18
|
+
/** @default false */
|
|
17
19
|
isDisabled?: boolean;
|
|
20
|
+
/** @default false */
|
|
18
21
|
isReadonly?: boolean;
|
|
22
|
+
/** @default false */
|
|
19
23
|
isInvalid?: boolean;
|
|
20
24
|
value: V;
|
|
21
|
-
/**
|
|
22
|
-
* @default `right`
|
|
23
|
-
*/
|
|
25
|
+
/** @default 'right' */
|
|
24
26
|
labelPosition?: 'right' | 'left';
|
|
25
|
-
onSelect(value: { value: V; isSelected: boolean })
|
|
27
|
+
onSelect: (value: { value: V; isSelected: boolean }) => void;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
export function Checkbox<V>({
|
|
29
31
|
children,
|
|
30
|
-
isDisabled,
|
|
31
|
-
isReadonly,
|
|
32
|
+
isDisabled = false,
|
|
33
|
+
isReadonly = false,
|
|
32
34
|
isChecked = false,
|
|
33
35
|
value,
|
|
34
36
|
data,
|
|
35
37
|
testId,
|
|
36
|
-
isSemiChecked,
|
|
38
|
+
isSemiChecked = false,
|
|
37
39
|
labelPosition = 'right',
|
|
38
40
|
tweakStyles,
|
|
39
41
|
onSelect,
|
|
@@ -45,9 +47,9 @@ export function Checkbox<V>({
|
|
|
45
47
|
const hasAction = !isDisabled && !isReadonly;
|
|
46
48
|
|
|
47
49
|
const onToggle = () => {
|
|
48
|
-
const
|
|
49
|
-
onSelect({ value, isSelected:
|
|
50
|
-
setIsSelected(
|
|
50
|
+
const isSelectedNext = !isSelected;
|
|
51
|
+
onSelect({ value, isSelected: isSelectedNext });
|
|
52
|
+
setIsSelected(isSelectedNext);
|
|
51
53
|
};
|
|
52
54
|
|
|
53
55
|
useEffect(() => {
|
|
@@ -6,8 +6,9 @@ import { Icon } from '../Icon';
|
|
|
6
6
|
import { useStyles, ICloseButtonStyles } from './CloseButton.styles';
|
|
7
7
|
|
|
8
8
|
export interface ICloseButtonProps extends ICommonProps<ICloseButtonStyles> {
|
|
9
|
+
/** @default 'close' */
|
|
9
10
|
iconType?: 'close' | 'close-large' | 'close-window';
|
|
10
|
-
onClose
|
|
11
|
+
onClose?: () => void;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export const CloseButton: FC<ICloseButtonProps> = ({
|
|
@@ -11,13 +11,16 @@ export interface IDateInputProps
|
|
|
11
11
|
extends Omit<IInputProps, 'value' | 'beforeMaskedStateChange' | 'onChange' | 'tweakStyles'>,
|
|
12
12
|
ICommonProps<IDateInputStyles> {
|
|
13
13
|
date?: string;
|
|
14
|
+
/** @default '' */
|
|
14
15
|
startDate?: string;
|
|
16
|
+
/** @default '' */
|
|
15
17
|
endDate?: string;
|
|
16
18
|
className?: string;
|
|
19
|
+
/** @default false */
|
|
17
20
|
isRange?: boolean;
|
|
18
|
-
onClick
|
|
21
|
+
onClick?: (event: MouseEvent<HTMLDivElement>) => void;
|
|
19
22
|
// react-datepicker ожидает event первым аргументом
|
|
20
|
-
onChange
|
|
23
|
+
onChange?: (event: FormEvent<HTMLInputElement>, value: string) => void;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
export const DateInput = forwardRef<HTMLInputElement, IDateInputProps>(
|
|
@@ -30,7 +33,7 @@ export const DateInput = forwardRef<HTMLInputElement, IDateInputProps>(
|
|
|
30
33
|
className,
|
|
31
34
|
placeholder,
|
|
32
35
|
data,
|
|
33
|
-
isRange,
|
|
36
|
+
isRange = false,
|
|
34
37
|
tweakStyles,
|
|
35
38
|
onClick,
|
|
36
39
|
onChange,
|
|
@@ -22,17 +22,19 @@ export interface IDatePickerProps extends IDatePickerBaseProps, ICommonProps<IDa
|
|
|
22
22
|
selectedDate?: Date | null;
|
|
23
23
|
locale: Locale;
|
|
24
24
|
months?: string[];
|
|
25
|
-
/**
|
|
26
|
-
* @default `dd.MM.yyyy`
|
|
27
|
-
*/
|
|
25
|
+
/** @default 'dd.MM.yyyy' */
|
|
28
26
|
dateFormat?: string;
|
|
27
|
+
/** @default 1 */
|
|
29
28
|
calendarStartDay?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
29
|
+
/** @default false */
|
|
30
30
|
isRange?: boolean;
|
|
31
|
+
/** @default false */
|
|
31
32
|
isInline?: boolean;
|
|
33
|
+
/** @default false */
|
|
32
34
|
shouldRenderPopperInBody?: boolean;
|
|
33
35
|
customInput?: FC<IDateInputProps>;
|
|
34
|
-
onChangeDate
|
|
35
|
-
onChangeRange
|
|
36
|
+
onChangeDate?: (date: Date | null, event?: SyntheticEvent) => void;
|
|
37
|
+
onChangeRange?: (date: IRange, event?: SyntheticEvent) => void;
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
export const DatePicker = forwardRef<ReactDatePicker, IDatePickerProps>(
|
|
@@ -50,14 +52,14 @@ export const DatePicker = forwardRef<ReactDatePicker, IDatePickerProps>(
|
|
|
50
52
|
dateFormat = DEFAULT_DATE_FORMAT,
|
|
51
53
|
monthsShown,
|
|
52
54
|
placeholder,
|
|
53
|
-
isRange,
|
|
54
|
-
isInline,
|
|
55
|
+
isRange = false,
|
|
56
|
+
isInline = false,
|
|
55
57
|
isDisabled,
|
|
56
58
|
isClearable,
|
|
57
59
|
strictParsing,
|
|
58
60
|
focusSelectedMonth,
|
|
59
61
|
disabledKeyboardNavigation,
|
|
60
|
-
shouldRenderPopperInBody,
|
|
62
|
+
shouldRenderPopperInBody = false,
|
|
61
63
|
allowSameDay = false,
|
|
62
64
|
shouldCloseOnSelect,
|
|
63
65
|
showPreviousMonths,
|
|
@@ -14,15 +14,18 @@ export interface IFiltersPaneProps<Values, Content = Values>
|
|
|
14
14
|
extends ICommonProps<IFiltersPaneStyles> {
|
|
15
15
|
filtersConfig: ConfigType<Values>;
|
|
16
16
|
enabledFilters?: Array<keyof ConfigType<Values>>;
|
|
17
|
+
/** @default {} */
|
|
17
18
|
values?: Partial<Values>;
|
|
18
19
|
search?: IFiltersPaneSearchProps<keyof Content>;
|
|
19
20
|
localeKey?: IFilterLocaleKey;
|
|
20
21
|
locale?: IPartialFilterLocale;
|
|
22
|
+
/** @default false */
|
|
21
23
|
isDisabled?: boolean;
|
|
24
|
+
/** @default true */
|
|
22
25
|
hasClearButton?: boolean;
|
|
23
|
-
onChangeFilters(values: Partial<Values>)
|
|
24
|
-
onSettingsButtonClick
|
|
25
|
-
onClear
|
|
26
|
+
onChangeFilters: (values: Partial<Values>) => void;
|
|
27
|
+
onSettingsButtonClick?: () => void;
|
|
28
|
+
onClear?: () => void;
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
export function FiltersPane<Values extends Record<string, unknown>, Content = Values>({
|
|
@@ -34,9 +34,9 @@ export interface IFilterWithDatesProps extends ICommonProps<IFilterWithDatesStyl
|
|
|
34
34
|
isClearable?: boolean;
|
|
35
35
|
startPickerProps?: IFilterWithDateDatePickerProps;
|
|
36
36
|
endPickerProps?: IFilterWithDateDatePickerProps;
|
|
37
|
-
onChange(val: IFilterWithDatesValue)
|
|
38
|
-
onStartBtnSubmit
|
|
39
|
-
onEndBtnSubmit()
|
|
37
|
+
onChange: (val: IFilterWithDatesValue) => void;
|
|
38
|
+
onStartBtnSubmit?: () => void;
|
|
39
|
+
onEndBtnSubmit: () => void;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export const FilterWithDates: FC<IFilterWithDatesProps> = ({
|
|
@@ -20,8 +20,8 @@ export interface IFilterWithPeriodProps extends ICommonProps<IFilterWithPeriodSt
|
|
|
20
20
|
localeKey?: IFilterLocaleKey;
|
|
21
21
|
locale?: IPartialFilterLocale;
|
|
22
22
|
periods?: IPeriodsList;
|
|
23
|
-
onChange(period?: IPeriod)
|
|
24
|
-
onClose
|
|
23
|
+
onChange: (period?: IPeriod) => void;
|
|
24
|
+
onClose?: () => void;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export const FilterWithPeriod: FC<IFilterWithPeriodProps> = ({
|
|
@@ -19,7 +19,7 @@ export interface IFilterWrapperProps<Values, Key extends keyof Values>
|
|
|
19
19
|
localeKey?: IFilterLocaleKey;
|
|
20
20
|
locale?: IPartialFilterLocale;
|
|
21
21
|
filtersPaneRef: RefObject<HTMLDivElement> | null;
|
|
22
|
-
onChange<V>(value: V)
|
|
22
|
+
onChange: <V>(value: V) => void;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export function FilterWrapper<Values, Key extends keyof Values>({
|
|
@@ -22,6 +22,14 @@ export const useStyles = createThemedStyles('FlexibleTable', {
|
|
|
22
22
|
maxHeight: '100%',
|
|
23
23
|
},
|
|
24
24
|
|
|
25
|
+
head: {},
|
|
26
|
+
|
|
27
|
+
body: {},
|
|
28
|
+
|
|
29
|
+
loaderRow: {},
|
|
30
|
+
|
|
31
|
+
loaderCell: {},
|
|
32
|
+
|
|
25
33
|
loader: {
|
|
26
34
|
position: 'sticky',
|
|
27
35
|
left: 0,
|
|
@@ -91,6 +99,12 @@ export const useStyles = createThemedStyles('FlexibleTable', {
|
|
|
91
99
|
paddingLeft: STICKY_SHADOW_PADDING,
|
|
92
100
|
},
|
|
93
101
|
|
|
102
|
+
nothingFoundRow: {},
|
|
103
|
+
|
|
104
|
+
nothingFound: {},
|
|
105
|
+
|
|
106
|
+
skeletonRow: {},
|
|
107
|
+
|
|
94
108
|
skeleton: {
|
|
95
109
|
height: 21,
|
|
96
110
|
padding: [14, 7],
|
|
@@ -25,14 +25,15 @@ export interface IFlexibleTableProps<Values extends Record<string, any>>
|
|
|
25
25
|
enabledColumns?: Array<keyof Values>;
|
|
26
26
|
activeRows?: number[];
|
|
27
27
|
config: IFlexibleTableConfigType<Values>;
|
|
28
|
+
/** @default false */
|
|
28
29
|
isHorizontallyScrollable?: boolean;
|
|
30
|
+
/** @default false */
|
|
29
31
|
isFirstColumnSticky?: boolean;
|
|
30
32
|
infinityScrollConfig?: IInfinityScrollConfig;
|
|
31
|
-
/**
|
|
32
|
-
* @default Индекс строки
|
|
33
|
-
*/
|
|
33
|
+
/** @default Индекс строки */
|
|
34
34
|
uniqueField?: keyof Values;
|
|
35
35
|
onHeadClick?: (column: keyof Values) => void;
|
|
36
|
+
/** @default false */
|
|
36
37
|
isLoading?: boolean;
|
|
37
38
|
// TODO: Заменить string на Generic Values[uniqueField]
|
|
38
39
|
onRowClick?: (id: string) => void;
|
|
@@ -40,6 +41,8 @@ export interface IFlexibleTableProps<Values extends Record<string, any>>
|
|
|
40
41
|
rowAttributes?: Array<keyof Values>;
|
|
41
42
|
refForScroll?: RefObject<HTMLDivElement>;
|
|
42
43
|
nothingFoundContent?: ReactNode;
|
|
44
|
+
/** @default 'table' */
|
|
45
|
+
renderMode?: 'table' | 'divs';
|
|
43
46
|
expandableRowComponent?: (item: Values, isOpen: boolean, close: () => void) => ReactNode;
|
|
44
47
|
}
|
|
45
48
|
|
|
@@ -51,11 +54,12 @@ export function FlexibleTable<Values extends Record<string, any>>({
|
|
|
51
54
|
config,
|
|
52
55
|
activeRows,
|
|
53
56
|
enabledColumns,
|
|
54
|
-
isHorizontallyScrollable,
|
|
55
|
-
isFirstColumnSticky,
|
|
57
|
+
isHorizontallyScrollable = false,
|
|
58
|
+
isFirstColumnSticky = false,
|
|
56
59
|
infinityScrollConfig,
|
|
57
60
|
uniqueField,
|
|
58
|
-
isLoading,
|
|
61
|
+
isLoading = false,
|
|
62
|
+
renderMode = 'table',
|
|
59
63
|
onHeadClick,
|
|
60
64
|
onRowHover,
|
|
61
65
|
onRowClick,
|
|
@@ -104,6 +108,12 @@ export function FlexibleTable<Values extends Record<string, any>>({
|
|
|
104
108
|
[getDataScrollAttributeSetter],
|
|
105
109
|
);
|
|
106
110
|
|
|
111
|
+
const shouldShowNothingFound =
|
|
112
|
+
!isArrayNotEmpty(content) &&
|
|
113
|
+
nothingFoundContent !== undefined &&
|
|
114
|
+
!infinityScrollConfig?.isLoading &&
|
|
115
|
+
(infinityScrollConfig?.isLastPage === undefined || infinityScrollConfig.isLastPage);
|
|
116
|
+
|
|
107
117
|
const ref = useMergedRefs([
|
|
108
118
|
refForScroll,
|
|
109
119
|
scrollRef,
|
|
@@ -166,11 +176,22 @@ export function FlexibleTable<Values extends Record<string, any>>({
|
|
|
166
176
|
};
|
|
167
177
|
}, [scrollRef, setIsScrolledAttribute, setHasScrollBarAttribute]);
|
|
168
178
|
|
|
179
|
+
const Table = renderMode === 'divs' ? 'div' : 'table';
|
|
180
|
+
const TableHead = renderMode === 'divs' ? 'div' : 'thead';
|
|
181
|
+
const TableBody = renderMode === 'divs' ? 'div' : 'tbody';
|
|
182
|
+
const TableRow = renderMode === 'divs' ? 'div' : 'tr';
|
|
183
|
+
const TableHeader = renderMode === 'divs' ? 'div' : 'th';
|
|
184
|
+
const TableCell = renderMode === 'divs' ? 'div' : 'td';
|
|
185
|
+
|
|
169
186
|
return (
|
|
170
187
|
<div ref={ref} className={clsx({ [classes.scroll]: isHorizontallyScrollable })}>
|
|
171
|
-
<
|
|
172
|
-
|
|
173
|
-
|
|
188
|
+
<Table
|
|
189
|
+
className={classes.root}
|
|
190
|
+
{...addDataTestId(testId)}
|
|
191
|
+
{...addDataAttributes({ ...data, isLoading })}
|
|
192
|
+
>
|
|
193
|
+
<TableHead className={classes.head}>
|
|
194
|
+
<TableRow className={classes.headerRow}>
|
|
174
195
|
{showedColumns.map((key, i) => {
|
|
175
196
|
const itemConfig = config?.[key];
|
|
176
197
|
|
|
@@ -182,7 +203,7 @@ export function FlexibleTable<Values extends Record<string, any>>({
|
|
|
182
203
|
}
|
|
183
204
|
|
|
184
205
|
return (
|
|
185
|
-
<
|
|
206
|
+
<TableHeader
|
|
186
207
|
className={clsx(classes.header, {
|
|
187
208
|
[classes.headerSticky]: isFirstColumnSticky && i === 0,
|
|
188
209
|
[classes.headerSecond]: isFirstColumnSticky && i === 1,
|
|
@@ -197,33 +218,31 @@ export function FlexibleTable<Values extends Record<string, any>>({
|
|
|
197
218
|
onClick={() => onHeadClick?.(key)}
|
|
198
219
|
>
|
|
199
220
|
{titleContent}
|
|
200
|
-
</
|
|
221
|
+
</TableHeader>
|
|
201
222
|
);
|
|
202
223
|
})}
|
|
203
|
-
</
|
|
204
|
-
</
|
|
205
|
-
<
|
|
224
|
+
</TableRow>
|
|
225
|
+
</TableHead>
|
|
226
|
+
<TableBody className={classes.body}>
|
|
206
227
|
{isLoading ? (
|
|
207
228
|
indexMap(6, (i) => (
|
|
208
|
-
<
|
|
229
|
+
<TableRow className={classes.skeletonRow} key={i}>
|
|
209
230
|
{showedColumns.map((_, j) => (
|
|
210
|
-
<
|
|
231
|
+
<TableCell className={classes.skeleton} key={j}>
|
|
211
232
|
<Skeleton />
|
|
212
|
-
</
|
|
233
|
+
</TableCell>
|
|
213
234
|
))}
|
|
214
|
-
</
|
|
235
|
+
</TableRow>
|
|
215
236
|
))
|
|
216
237
|
) : (
|
|
217
238
|
<>
|
|
218
|
-
{
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
</tr>
|
|
226
|
-
)}
|
|
239
|
+
{shouldShowNothingFound && (
|
|
240
|
+
<TableRow className={classes.nothingFoundRow}>
|
|
241
|
+
<TableCell className={classes.nothingFound} colSpan={showedColumns.length}>
|
|
242
|
+
{nothingFoundContent}
|
|
243
|
+
</TableCell>
|
|
244
|
+
</TableRow>
|
|
245
|
+
)}
|
|
227
246
|
|
|
228
247
|
{content.map((item, i) => (
|
|
229
248
|
<FlexibleTableRow
|
|
@@ -237,24 +256,25 @@ export function FlexibleTable<Values extends Record<string, any>>({
|
|
|
237
256
|
config={config}
|
|
238
257
|
key={isNotEmpty(uniqueField) ? item[uniqueField] : i}
|
|
239
258
|
rowAttributes={rowAttributes}
|
|
259
|
+
renderMode={renderMode}
|
|
240
260
|
tweakStyles={tweakTableRowStyles}
|
|
241
261
|
expandableRowComponent={expandableRowComponent}
|
|
242
262
|
/>
|
|
243
263
|
))}
|
|
244
264
|
|
|
245
265
|
{infinityScrollConfig !== undefined && !infinityScrollConfig.isLastPage && (
|
|
246
|
-
<
|
|
247
|
-
<
|
|
266
|
+
<TableRow className={classes.loaderRow}>
|
|
267
|
+
<TableCell className={classes.loaderCell} colSpan={showedColumns.length}>
|
|
248
268
|
<div ref={initIntersectionObserver} className={classes.loader}>
|
|
249
269
|
<ThemedPreloader type="dots" />
|
|
250
270
|
</div>
|
|
251
|
-
</
|
|
252
|
-
</
|
|
271
|
+
</TableCell>
|
|
272
|
+
</TableRow>
|
|
253
273
|
)}
|
|
254
274
|
</>
|
|
255
275
|
)}
|
|
256
|
-
</
|
|
257
|
-
</
|
|
276
|
+
</TableBody>
|
|
277
|
+
</Table>
|
|
258
278
|
</div>
|
|
259
279
|
);
|
|
260
280
|
}
|
|
@@ -11,18 +11,21 @@ export interface IFlexibleTableCellProps<Values extends Record<string, any>>
|
|
|
11
11
|
item: Values;
|
|
12
12
|
columnName: keyof Values;
|
|
13
13
|
config: IFlexibleTableConfigType<Values>;
|
|
14
|
+
/** @default 'table' */
|
|
15
|
+
renderMode?: 'table' | 'divs';
|
|
14
16
|
isFocusedRow?: boolean;
|
|
15
17
|
isSecond?: boolean;
|
|
16
18
|
isSticky?: boolean;
|
|
17
19
|
isNestedComponentExpanded: boolean;
|
|
18
20
|
isRowNestedComponentExpanded: boolean;
|
|
19
|
-
onSetNestedComponent(component?: ReactNode)
|
|
21
|
+
onSetNestedComponent: (component?: ReactNode) => void;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
export function FlexibleTableCell<Values extends Record<string, any>>({
|
|
23
25
|
item,
|
|
24
26
|
columnName,
|
|
25
27
|
config,
|
|
28
|
+
renderMode = 'table',
|
|
26
29
|
isFocusedRow,
|
|
27
30
|
isSecond,
|
|
28
31
|
isSticky,
|
|
@@ -38,8 +41,10 @@ export function FlexibleTableCell<Values extends Record<string, any>>({
|
|
|
38
41
|
|
|
39
42
|
const value = item[columnName];
|
|
40
43
|
|
|
44
|
+
const TableCell = renderMode === 'divs' ? 'div' : 'td';
|
|
45
|
+
|
|
41
46
|
return (
|
|
42
|
-
<
|
|
47
|
+
<TableCell
|
|
43
48
|
key={columnName as string}
|
|
44
49
|
className={clsx(classes.root, { [classes.sticky]: isSticky, [classes.second]: isSecond })}
|
|
45
50
|
style={{
|
|
@@ -64,6 +69,6 @@ export function FlexibleTableCell<Values extends Record<string, any>>({
|
|
|
64
69
|
: formatCellContent(value, config[columnName])}
|
|
65
70
|
</>
|
|
66
71
|
)}
|
|
67
|
-
</
|
|
72
|
+
</TableCell>
|
|
68
73
|
);
|
|
69
74
|
}
|
|
@@ -18,10 +18,12 @@ export interface IFlexibleTableRowProps<Values extends Record<string, any>>
|
|
|
18
18
|
config: IFlexibleTableConfigType<Values>;
|
|
19
19
|
enabledColumns?: Array<keyof Values>;
|
|
20
20
|
rowAttributes?: Array<keyof Values>;
|
|
21
|
-
|
|
21
|
+
/** @default 'table' */
|
|
22
|
+
renderMode?: 'table' | 'divs';
|
|
23
|
+
expandableRowComponent?: (item: Values, isOpen: boolean, close: () => void) => ReactNode;
|
|
22
24
|
// TODO: Заменить string на Generic Values[uniqueField]
|
|
23
|
-
onRowHover
|
|
24
|
-
onRowClick
|
|
25
|
+
onRowHover?: (id?: string) => void;
|
|
26
|
+
onRowClick?: (id: string) => void;
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
function FlexibleTableRowInner<Values extends Record<string, any>>({
|
|
@@ -32,6 +34,7 @@ function FlexibleTableRowInner<Values extends Record<string, any>>({
|
|
|
32
34
|
config,
|
|
33
35
|
enabledColumns,
|
|
34
36
|
rowAttributes,
|
|
37
|
+
renderMode = 'table',
|
|
35
38
|
tweakStyles,
|
|
36
39
|
expandableRowComponent,
|
|
37
40
|
onRowHover,
|
|
@@ -100,9 +103,12 @@ function FlexibleTableRowInner<Values extends Record<string, any>>({
|
|
|
100
103
|
const items = enabledColumns ?? Object.keys(config);
|
|
101
104
|
const isEditable = isNotEmpty(onRowClick) || isNotEmpty(onRowHover);
|
|
102
105
|
|
|
106
|
+
const TableRow = renderMode === 'divs' ? 'div' : 'tr';
|
|
107
|
+
const TableCell = renderMode === 'divs' ? 'div' : 'td';
|
|
108
|
+
|
|
103
109
|
return (
|
|
104
110
|
<>
|
|
105
|
-
<
|
|
111
|
+
<TableRow
|
|
106
112
|
className={clsx(classes.root, {
|
|
107
113
|
[classes.active]: isActive,
|
|
108
114
|
[classes.editable]: isEditable,
|
|
@@ -133,6 +139,7 @@ function FlexibleTableRowInner<Values extends Record<string, any>>({
|
|
|
133
139
|
item={item}
|
|
134
140
|
config={config}
|
|
135
141
|
tweakStyles={tweakTableCellStyles}
|
|
142
|
+
renderMode={renderMode}
|
|
136
143
|
isFocusedRow={isFocused}
|
|
137
144
|
isNestedComponentExpanded={nestedComponent.isOpen && nestedComponent.cellKey === key}
|
|
138
145
|
isRowNestedComponentExpanded={
|
|
@@ -141,12 +148,14 @@ function FlexibleTableRowInner<Values extends Record<string, any>>({
|
|
|
141
148
|
onSetNestedComponent={(component) => updateNestedComponent(component, key as string)}
|
|
142
149
|
/>
|
|
143
150
|
))}
|
|
144
|
-
</
|
|
151
|
+
</TableRow>
|
|
145
152
|
|
|
146
153
|
{nestedComponent.isOpen && (
|
|
147
|
-
<
|
|
148
|
-
<
|
|
149
|
-
|
|
154
|
+
<TableRow className={classes.root}>
|
|
155
|
+
<TableCell className={classes.nestedComponent} colSpan={items.length}>
|
|
156
|
+
{nestedComponent.component}
|
|
157
|
+
</TableCell>
|
|
158
|
+
</TableRow>
|
|
150
159
|
)}
|
|
151
160
|
</>
|
|
152
161
|
);
|
|
@@ -11,6 +11,7 @@ import { useStyles, IIncrementInputStyles, inputStyles } from './IncrementInput.
|
|
|
11
11
|
export interface IIncrementInputProps
|
|
12
12
|
extends Omit<INumberInputProps, 'canBeFloat' | 'precision' | 'tweakStyles'>,
|
|
13
13
|
ICommonProps<IIncrementInputStyles> {
|
|
14
|
+
/** @default 1 */
|
|
14
15
|
step?: number;
|
|
15
16
|
}
|
|
16
17
|
|