@true-engineering/true-react-common-ui-kit 2.0.0 → 2.1.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 +17 -0
- package/dist/components/Button/Button.d.ts +35 -0
- package/dist/components/Checkbox/Checkbox.d.ts +15 -2
- package/dist/components/DatePicker/DatePicker.d.ts +3 -4
- package/dist/components/DatePicker/types.d.ts +1 -1
- package/dist/components/FiltersPane/FilterSelect/FilterSelect.d.ts +12 -0
- package/dist/components/Input/Input.d.ts +17 -0
- package/dist/components/MoreMenu/MoreMenu.d.ts +3 -0
- package/dist/components/Notification/Notification.d.ts +6 -0
- package/dist/components/RadioButton/RadioButton.d.ts +4 -3
- package/dist/components/Switch/Switch.d.ts +10 -4
- package/dist/components/ThemedPreloader/ThemedPreloader.d.ts +3 -0
- package/dist/components/Toaster/Toaster.d.ts +13 -0
- package/dist/components/Tooltip/Tooltip.d.ts +6 -0
- package/dist/helpers/utils.d.ts +14 -0
- package/dist/true-react-common-ui-kit.js +19 -15
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +19 -15
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/dist/types.d.ts +3 -0
- package/package.json +1 -1
- package/src/components/Checkbox/Checkbox.tsx +3 -2
- package/src/components/DatePicker/DatePicker.tsx +2 -4
- package/src/components/DatePicker/types.ts +5 -0
- package/src/components/RadioButton/RadioButton.tsx +5 -4
- package/src/components/Select/Select.tsx +6 -2
- package/src/components/Switch/Switch.tsx +10 -16
package/dist/types.d.ts
CHANGED
|
@@ -24,6 +24,9 @@ export declare type UiKitHelpers = Record<string, Styles | (() => Styles)>;
|
|
|
24
24
|
export interface UiKitTheme {
|
|
25
25
|
name: string;
|
|
26
26
|
components?: Partial<Record<ComponentName, ComponentStyles<any, any>>>;
|
|
27
|
+
/**
|
|
28
|
+
* Для переопределения иконок, которые есть в UiKit
|
|
29
|
+
*/
|
|
27
30
|
icons?: Partial<Record<ICommonIcon, ISvgIcon>>;
|
|
28
31
|
complexIcons?: Partial<Record<IComplexIcon, string>>;
|
|
29
32
|
preloaders?: Partial<Record<IPreloaderSvgType, string>>;
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useState,
|
|
1
|
+
import { useEffect, useState, ReactNode } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import { Icon } from '../Icon';
|
|
4
4
|
import { useTheme } from '../../hooks';
|
|
@@ -13,6 +13,7 @@ import { CheckboxStyles, styles } from './Checkbox.styles';
|
|
|
13
13
|
|
|
14
14
|
export interface ICheckboxProps<V> extends ICommonProps {
|
|
15
15
|
tweakStyles?: CheckboxStyles;
|
|
16
|
+
children?: ReactNode;
|
|
16
17
|
isChecked?: boolean;
|
|
17
18
|
isSemiChecked?: boolean;
|
|
18
19
|
isDisabled?: boolean;
|
|
@@ -54,7 +55,7 @@ export function Checkbox<V>({
|
|
|
54
55
|
labelPosition = 'right',
|
|
55
56
|
tweakStyles,
|
|
56
57
|
onSelect,
|
|
57
|
-
}:
|
|
58
|
+
}: ICheckboxProps<V>): JSX.Element {
|
|
58
59
|
const { classes } = useTheme('Checkbox', styles, tweakStyles, {
|
|
59
60
|
size,
|
|
60
61
|
alignItems,
|
|
@@ -46,10 +46,6 @@ export interface IDatePickerProps extends IDatePickerBaseProps {
|
|
|
46
46
|
selectedDate?: Date | null;
|
|
47
47
|
locale: Locale;
|
|
48
48
|
months?: string[];
|
|
49
|
-
minDate?: Date | null;
|
|
50
|
-
maxDate?: Date | null;
|
|
51
|
-
endDate?: Date | null;
|
|
52
|
-
startDate?: Date | null;
|
|
53
49
|
topPosition?: number;
|
|
54
50
|
leftPosition?: number;
|
|
55
51
|
/**
|
|
@@ -91,6 +87,7 @@ export const DatePicker = forwardRef<ReactDatePicker, IDatePickerProps>(
|
|
|
91
87
|
isInline,
|
|
92
88
|
isDisabled,
|
|
93
89
|
isClearable,
|
|
90
|
+
strictParsing,
|
|
94
91
|
focusSelectedMonth,
|
|
95
92
|
disabledKeyboardNavigation,
|
|
96
93
|
shouldRenderPopperInBody,
|
|
@@ -305,6 +302,7 @@ export const DatePicker = forwardRef<ReactDatePicker, IDatePickerProps>(
|
|
|
305
302
|
popperModifiers={popperModifiers}
|
|
306
303
|
popperPlacement={popperPlacement}
|
|
307
304
|
selectsRange={isRange}
|
|
305
|
+
strictParsing={strictParsing}
|
|
308
306
|
preventOpenOnFocus={preventOpenOnFocus}
|
|
309
307
|
shouldCloseOnSelect={shouldCloseOnSelect}
|
|
310
308
|
customInputRef={customInputRef}
|
|
@@ -5,6 +5,10 @@ export type IRange = [Date | null, Date | null] | null;
|
|
|
5
5
|
|
|
6
6
|
export type IDatePickerBaseProps = Pick<
|
|
7
7
|
ReactDatePickerProps,
|
|
8
|
+
| 'startDate'
|
|
9
|
+
| 'endDate'
|
|
10
|
+
| 'minDate'
|
|
11
|
+
| 'maxDate'
|
|
8
12
|
| 'allowSameDay'
|
|
9
13
|
| 'disabledKeyboardNavigation'
|
|
10
14
|
| 'monthsShown'
|
|
@@ -24,6 +28,7 @@ export type IDatePickerBaseProps = Pick<
|
|
|
24
28
|
| 'renderCustomHeader'
|
|
25
29
|
| 'customInputRef'
|
|
26
30
|
| 'preventOpenOnFocus'
|
|
31
|
+
| 'strictParsing'
|
|
27
32
|
> &
|
|
28
33
|
Omit<
|
|
29
34
|
IDateInputProps,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import { useTheme } from '../../hooks';
|
|
4
4
|
import { addDataAttributes, isNotEmpty } from '../../helpers';
|
|
@@ -8,12 +8,13 @@ import { RadioButtonStyles, styles } from './RadioButton.styles';
|
|
|
8
8
|
|
|
9
9
|
export interface IRadioButtonProps<Value extends string> extends ICommonProps {
|
|
10
10
|
tweakStyles?: RadioButtonStyles;
|
|
11
|
+
children?: ReactNode;
|
|
11
12
|
value: Value;
|
|
12
13
|
groupName: string;
|
|
13
14
|
isChecked?: boolean;
|
|
14
15
|
isDisabled?: boolean;
|
|
15
16
|
isInvalid?: boolean;
|
|
16
|
-
onChange
|
|
17
|
+
onChange(value: Value): void | Promise<void>;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
export function RadioButton<Value extends string>({
|
|
@@ -23,10 +24,10 @@ export function RadioButton<Value extends string>({
|
|
|
23
24
|
isChecked,
|
|
24
25
|
isDisabled,
|
|
25
26
|
isInvalid,
|
|
26
|
-
onChange,
|
|
27
27
|
data,
|
|
28
28
|
tweakStyles,
|
|
29
|
-
|
|
29
|
+
onChange,
|
|
30
|
+
}: IRadioButtonProps<Value>): JSX.Element {
|
|
30
31
|
const { classes } = useTheme('RadioButton', styles, tweakStyles);
|
|
31
32
|
|
|
32
33
|
return (
|
|
@@ -500,13 +500,17 @@ export function Select<Value>(
|
|
|
500
500
|
});
|
|
501
501
|
|
|
502
502
|
useEffect(() => {
|
|
503
|
-
const val = isMultiSelect ? value?.[0] : value;
|
|
504
503
|
setFocusedListCellIndex(
|
|
505
504
|
optionsIndexesForNavigation.find(
|
|
506
|
-
(index) =>
|
|
505
|
+
(index) =>
|
|
506
|
+
isNotEmpty(strValue) &&
|
|
507
|
+
isNotEmpty(filteredOptions[index]) &&
|
|
508
|
+
convertToId(filteredOptions[index]) === convertToId(strValue),
|
|
507
509
|
) ?? optionsIndexesForNavigation[0],
|
|
508
510
|
);
|
|
511
|
+
}, [strValue, filteredOptions, optionsIndexesForNavigation, convertToId]);
|
|
509
512
|
|
|
513
|
+
useEffect(() => {
|
|
510
514
|
if (isOpen) {
|
|
511
515
|
onOpen?.();
|
|
512
516
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import { useTheme } from '../../hooks';
|
|
4
|
-
import { addDataAttributes, isNotEmpty } from '../../helpers';
|
|
4
|
+
import { addDataAttributes, addDataTestId, isNotEmpty } from '../../helpers';
|
|
5
5
|
import { ICommonProps } from '../../types';
|
|
6
6
|
|
|
7
7
|
import { styles, SwitchStyles } from './Switch.styles';
|
|
@@ -13,14 +13,11 @@ export interface ISwitchState<V = string> {
|
|
|
13
13
|
|
|
14
14
|
export interface ISwitchProps<V extends string> extends ICommonProps {
|
|
15
15
|
tweakStyles?: SwitchStyles;
|
|
16
|
+
children?: ReactNode;
|
|
16
17
|
value: V;
|
|
17
18
|
isChecked: boolean;
|
|
18
19
|
isDisabled?: boolean;
|
|
19
20
|
isInvalid?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated Use `children` instead
|
|
22
|
-
*/
|
|
23
|
-
label?: string;
|
|
24
21
|
/**
|
|
25
22
|
* @default `right`
|
|
26
23
|
*/
|
|
@@ -29,28 +26,25 @@ export interface ISwitchProps<V extends string> extends ICommonProps {
|
|
|
29
26
|
* @default `primary`
|
|
30
27
|
*/
|
|
31
28
|
color?: 'primary' | 'secondary';
|
|
32
|
-
onChange: (state: ISwitchState<V>) => void;
|
|
33
29
|
testId?: string;
|
|
30
|
+
onChange(state: ISwitchState<V>): void;
|
|
34
31
|
}
|
|
35
32
|
|
|
36
33
|
export const Switch = <V extends string>({
|
|
37
34
|
isDisabled,
|
|
38
35
|
isChecked,
|
|
39
36
|
isInvalid,
|
|
40
|
-
onChange,
|
|
41
37
|
value,
|
|
42
|
-
label,
|
|
43
38
|
children,
|
|
44
39
|
labelPosition = 'right',
|
|
45
40
|
color = 'primary',
|
|
46
41
|
data,
|
|
47
42
|
tweakStyles,
|
|
48
43
|
testId,
|
|
49
|
-
|
|
44
|
+
onChange,
|
|
45
|
+
}: ISwitchProps<V>): JSX.Element => {
|
|
50
46
|
const { classes } = useTheme('Switch', styles, tweakStyles);
|
|
51
47
|
|
|
52
|
-
const hasLabel = isNotEmpty(label);
|
|
53
|
-
const hasChild = isNotEmpty(children);
|
|
54
48
|
const handleChange = () => onChange({ name: value, isEnabled: !isChecked });
|
|
55
49
|
|
|
56
50
|
return (
|
|
@@ -60,8 +54,8 @@ export const Switch = <V extends string>({
|
|
|
60
54
|
[classes.checked]: isChecked,
|
|
61
55
|
[classes.invalid]: isInvalid,
|
|
62
56
|
})}
|
|
57
|
+
{...addDataTestId(testId)}
|
|
63
58
|
{...addDataAttributes(data)}
|
|
64
|
-
data-testid={testId}
|
|
65
59
|
>
|
|
66
60
|
<span className={classes.switch}>
|
|
67
61
|
<input
|
|
@@ -71,17 +65,17 @@ export const Switch = <V extends string>({
|
|
|
71
65
|
onChange={isDisabled ? undefined : handleChange}
|
|
72
66
|
checked={isChecked}
|
|
73
67
|
disabled={isDisabled}
|
|
74
|
-
|
|
68
|
+
{...addDataTestId(testId, 'input')}
|
|
75
69
|
/>
|
|
76
70
|
</span>
|
|
77
|
-
{(
|
|
71
|
+
{isNotEmpty(children) && (
|
|
78
72
|
<span
|
|
79
73
|
className={clsx(
|
|
80
74
|
classes.label,
|
|
81
75
|
classes[labelPosition === 'left' ? 'labelLeft' : 'labelRight'],
|
|
82
76
|
)}
|
|
83
77
|
>
|
|
84
|
-
{
|
|
78
|
+
{children}
|
|
85
79
|
</span>
|
|
86
80
|
)}
|
|
87
81
|
</label>
|