@true-engineering/true-react-common-ui-kit 4.0.0-alpha1 → 4.0.0-alpha10
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 +11 -567
- package/dist/components/Button/Button.styles.d.ts +1 -1
- package/dist/components/Checkbox/Checkbox.styles.d.ts +1 -1
- package/dist/components/DatePicker/DatePicker.d.ts +2 -2
- package/dist/components/DatePicker/helpers.d.ts +3 -0
- package/dist/components/DatePicker/types.d.ts +3 -1
- package/dist/components/FiltersPane/FiltersPane.d.ts +4 -2
- package/dist/components/FiltersPane/FiltersPane.stories.d.ts +3 -3
- package/dist/components/FiltersPane/components/Filter/Filter.d.ts +2 -2
- package/dist/components/FiltersPane/components/Filter/helpers.d.ts +4 -0
- package/dist/components/FiltersPane/components/FilterInterval/FilterInterval.styles.d.ts +1 -1
- package/dist/components/FiltersPane/components/FilterSelect/FilterSelect.styles.d.ts +1 -1
- package/dist/components/FiltersPane/components/FilterValueView/FilterValueView.d.ts +3 -1
- package/dist/components/FiltersPane/components/FilterWithDates/FilterWithDates.styles.d.ts +2 -2
- package/dist/components/FiltersPane/components/FilterWrapper/FilterWrapper.d.ts +2 -2
- package/dist/components/FiltersPane/types.d.ts +15 -5
- package/dist/components/Flag/customFlags/customFlags.d.ts +10 -0
- package/dist/components/Flag/customFlags/index.d.ts +1 -0
- package/dist/components/FlexibleTable/FlexibleTable.d.ts +4 -2
- package/dist/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.d.ts +6 -6
- package/dist/components/FlexibleTable/constants.d.ts +18 -2
- package/dist/components/FlexibleTable/types.d.ts +1 -1
- package/dist/components/List/List.d.ts +1 -1
- package/dist/components/List/index.d.ts +2 -1
- package/dist/components/List/types.d.ts +4 -0
- package/dist/components/SearchInput/SearchInput.d.ts +2 -2
- package/dist/components/SearchInput/SearchInput.stories.d.ts +3 -12
- package/dist/components/SearchInput/SearchInput.styles.d.ts +3 -5
- package/dist/components/Select/Select.d.ts +5 -3
- package/dist/components/Select/Select.styles.d.ts +2 -2
- package/dist/components/Select/index.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.styles.d.ts +1 -1
- package/dist/components/WithMessages/WithMessages.styles.d.ts +1 -1
- package/dist/components/WithPopup/WithPopup.d.ts +21 -6
- package/dist/components/WithPopup/WithPopup.styles.d.ts +1 -1
- package/dist/components/WithPopup/helpers.d.ts +2 -0
- package/dist/components/WithPopup/types.d.ts +3 -0
- package/dist/components/WithTooltip/WithTooltip.styles.d.ts +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/use-merge.d.ts +1 -0
- package/dist/hooks/use-mixed-styles.d.ts +3 -1
- package/dist/hooks/use-tweak-styles.d.ts +5 -5
- package/dist/theme/Provider.d.ts +6 -3
- package/dist/theme/common.d.ts +4 -2
- package/dist/theme/create-themed-styles.d.ts +2 -0
- package/dist/theme/helpers.d.ts +9 -3
- package/dist/theme/index.d.ts +2 -0
- package/dist/theme/true-jss/ThemedStylesManager.d.ts +18 -0
- package/dist/theme/true-jss/TweakStylesManager.d.ts +34 -0
- package/dist/theme/true-jss/index.d.ts +2 -0
- package/dist/theme/true-jss/jss-context.d.ts +9 -0
- package/dist/theme/types.d.ts +4 -2
- package/dist/true-react-common-ui-kit.js +7059 -6128
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +6957 -6027
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/dist/types.d.ts +2 -1
- package/package.json +1 -1
- package/src/components/ControlWrapper/ControlWrapper.styles.ts +4 -4
- package/src/components/DatePicker/DatePicker.tsx +9 -4
- package/src/components/DatePicker/helpers.ts +13 -1
- package/src/components/DatePicker/types.ts +4 -1
- package/src/components/FiltersPane/FiltersPane.stories.tsx +4 -2
- package/src/components/FiltersPane/FiltersPane.tsx +14 -9
- package/src/components/FiltersPane/components/Filter/Filter.tsx +24 -17
- package/src/components/FiltersPane/components/Filter/helpers.ts +18 -0
- package/src/components/FiltersPane/components/FilterInterval/FilterInterval.styles.ts +1 -1
- package/src/components/FiltersPane/components/FilterInterval/FilterInterval.tsx +6 -1
- package/src/components/FiltersPane/components/FilterValueView/FilterValueView.tsx +27 -22
- package/src/components/FiltersPane/components/FilterWithDates/FilterWithDates.styles.ts +1 -0
- package/src/components/FiltersPane/components/FilterWithPeriod/FilterWithPeriod.tsx +1 -1
- package/src/components/FiltersPane/components/FilterWrapper/FilterWrapper.tsx +7 -5
- package/src/components/FiltersPane/types.ts +23 -5
- package/src/components/Flag/Flag.stories.tsx +2 -1
- package/src/components/Flag/Flag.styles.ts +4 -0
- package/src/components/Flag/Flag.tsx +23 -9
- package/src/components/Flag/customFlags/AB.svg +1 -0
- package/src/components/Flag/customFlags/OS.svg +1 -0
- package/src/components/Flag/customFlags/augment.d.ts +1 -0
- package/src/components/Flag/customFlags/customFlags.ts +13 -0
- package/src/components/Flag/customFlags/index.ts +1 -0
- package/src/components/FlexibleTable/FlexibleTable.tsx +13 -12
- package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.tsx +9 -8
- package/src/components/FlexibleTable/constants.ts +6 -3
- package/src/components/FlexibleTable/types.ts +1 -5
- package/src/components/IncrementInput/IncrementInput.styles.ts +1 -1
- package/src/components/Input/Input.tsx +2 -1
- package/src/components/Input/InputBase.tsx +1 -1
- package/src/components/List/List.tsx +5 -2
- package/src/components/List/index.ts +2 -1
- package/src/components/List/types.ts +5 -0
- package/src/components/PhoneInput/PhoneInput.stories.tsx +2 -1
- package/src/components/PhoneInput/PhoneInput.tsx +5 -2
- package/src/components/SearchInput/SearchInput.styles.ts +16 -29
- package/src/components/SearchInput/SearchInput.tsx +17 -30
- package/src/components/Select/Select.tsx +12 -2
- package/src/components/Select/components/SelectList/SelectList.tsx +1 -1
- package/src/components/Select/index.ts +1 -1
- package/src/components/TextArea/TextArea.tsx +3 -2
- package/src/components/Tooltip/Tooltip.styles.ts +2 -0
- package/src/components/Tooltip/Tooltip.tsx +1 -1
- package/src/components/WithPopup/WithPopup.stories.tsx +1 -0
- package/src/components/WithPopup/WithPopup.styles.ts +2 -0
- package/src/components/WithPopup/WithPopup.tsx +64 -16
- package/src/components/WithPopup/helpers.ts +9 -0
- package/src/components/WithPopup/types.ts +7 -0
- package/src/components/WithTooltip/WithTooltip.styles.ts +6 -0
- package/src/components/WithTooltip/WithTooltip.tsx +7 -2
- package/src/constants/phone-info.ts +20 -33
- package/src/helpers/phone.ts +19 -15
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-merge.ts +8 -0
- package/src/hooks/use-mixed-styles.ts +9 -11
- package/src/hooks/use-tweak-styles.ts +49 -27
- package/src/theme/Provider.tsx +10 -5
- package/src/theme/common.ts +5 -2
- package/src/theme/create-themed-styles.ts +78 -0
- package/src/theme/helpers.ts +39 -39
- package/src/theme/index.ts +2 -0
- package/src/theme/true-jss/ThemedStylesManager.ts +92 -0
- package/src/theme/true-jss/TweakStylesManager.ts +157 -0
- package/src/theme/true-jss/index.ts +2 -0
- package/src/theme/true-jss/jss-context.tsx +34 -0
- package/src/theme/types.ts +4 -2
- package/src/types.ts +2 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './customFlags';
|
|
@@ -34,10 +34,10 @@ export interface IFlexibleTableProps<
|
|
|
34
34
|
| 'uniqueField'
|
|
35
35
|
| 'rowAttributes'
|
|
36
36
|
| 'isFirstColumnSticky'
|
|
37
|
-
| 'isExpandableRowComponentInitiallyOpen'
|
|
38
37
|
| 'expandableRowComponent'
|
|
39
38
|
| 'onRowClick'
|
|
40
39
|
| 'onRowHover'
|
|
40
|
+
| 'rowRef'
|
|
41
41
|
> {
|
|
42
42
|
content: Row[];
|
|
43
43
|
/** @default 'table' */
|
|
@@ -62,6 +62,8 @@ export interface IFlexibleTableProps<
|
|
|
62
62
|
nothingFoundContent?: ReactNode;
|
|
63
63
|
/** @default true */
|
|
64
64
|
shouldRenderHeader?: boolean;
|
|
65
|
+
/** @default false */
|
|
66
|
+
isExpandableRowComponentInitiallyOpen?: boolean | ((row: Row, index: number) => boolean);
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
export function FlexibleTable<
|
|
@@ -88,6 +90,7 @@ export function FlexibleTable<
|
|
|
88
90
|
tweakStyles,
|
|
89
91
|
shouldRenderHeader = true,
|
|
90
92
|
onHeadClick,
|
|
93
|
+
isExpandableRowComponentInitiallyOpen: isRowInitiallyOpen,
|
|
91
94
|
...restProps
|
|
92
95
|
}: IFlexibleTableProps<Row, HeaderContent, UniqueField>): JSX.Element {
|
|
93
96
|
const classes = useStyles({ theme: tweakStyles });
|
|
@@ -105,11 +108,12 @@ export function FlexibleTable<
|
|
|
105
108
|
|
|
106
109
|
const hasInfiniteScroll = isNotEmpty(infinityScrollConfig);
|
|
107
110
|
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
>
|
|
111
|
+
const getTableRowProps = (
|
|
112
|
+
item: Row,
|
|
113
|
+
index: number,
|
|
114
|
+
): IFlexibleTableRowProps<Row, HeaderContent, UniqueField> => ({
|
|
112
115
|
...restProps,
|
|
116
|
+
item,
|
|
113
117
|
renderMode,
|
|
114
118
|
config,
|
|
115
119
|
columns,
|
|
@@ -118,7 +122,8 @@ export function FlexibleTable<
|
|
|
118
122
|
isFirstColumnSticky,
|
|
119
123
|
isFocusable: isRowFocusable,
|
|
120
124
|
tweakStyles: tweakTableRowStyles,
|
|
121
|
-
|
|
125
|
+
isExpandableRowComponentInitiallyOpen: applyAction(isRowInitiallyOpen, item, index),
|
|
126
|
+
});
|
|
122
127
|
|
|
123
128
|
const getDataScrollAttributeSetter = useCallback(
|
|
124
129
|
(key: string, setter: (el: HTMLDivElement) => boolean) => (el?: HTMLDivElement) => {
|
|
@@ -267,9 +272,7 @@ export function FlexibleTable<
|
|
|
267
272
|
)}
|
|
268
273
|
<Table.Body className={classes.body}>
|
|
269
274
|
{isLoading ? (
|
|
270
|
-
indexMap(6, (i) => (
|
|
271
|
-
<FlexibleTableRow {...tableRowProps} key={i} item={{} as Row} index={i} />
|
|
272
|
-
))
|
|
275
|
+
indexMap(6, (i) => <FlexibleTableRow {...getTableRowProps({} as Row, i)} key={i} />)
|
|
273
276
|
) : (
|
|
274
277
|
<>
|
|
275
278
|
{shouldShowNothingFound && (
|
|
@@ -282,11 +285,9 @@ export function FlexibleTable<
|
|
|
282
285
|
|
|
283
286
|
{content.map((item, i) => (
|
|
284
287
|
<FlexibleTableRow
|
|
285
|
-
{...
|
|
288
|
+
{...getTableRowProps(item, i)}
|
|
286
289
|
isActive={activeRowsSet.has(i)}
|
|
287
290
|
key={isNotEmpty(uniqueField) ? item[uniqueField] : i}
|
|
288
|
-
item={item}
|
|
289
|
-
index={i}
|
|
290
291
|
/>
|
|
291
292
|
))}
|
|
292
293
|
|
|
@@ -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
|
-
import {
|
|
3
|
+
import { 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,9 +19,8 @@ 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
|
-
index: number;
|
|
25
24
|
uniqueField?: UniqueField;
|
|
26
25
|
renderMode: IFlexibleTableRenderMode;
|
|
27
26
|
/** @default false */
|
|
@@ -37,7 +36,8 @@ export interface IFlexibleTableRowProps<
|
|
|
37
36
|
columns: Array<keyof Row & string>;
|
|
38
37
|
rowAttributes?: Array<keyof Row>;
|
|
39
38
|
/** @default false */
|
|
40
|
-
isExpandableRowComponentInitiallyOpen?: boolean
|
|
39
|
+
isExpandableRowComponentInitiallyOpen?: boolean;
|
|
40
|
+
rowRef?: RefCallback<HTMLTableRowElement>;
|
|
41
41
|
/** Возвращает React-элемент, который отрисуется под строкой при нажатии на неё */
|
|
42
42
|
expandableRowComponent?: (item: Row, isOpen: boolean, close: () => void) => ReactNode;
|
|
43
43
|
onRowHover?: (id?: Row[UniqueField]) => void;
|
|
@@ -50,7 +50,6 @@ function FlexibleTableRowInner<
|
|
|
50
50
|
UniqueField extends keyof Row,
|
|
51
51
|
>({
|
|
52
52
|
item,
|
|
53
|
-
index,
|
|
54
53
|
config,
|
|
55
54
|
columns,
|
|
56
55
|
uniqueField,
|
|
@@ -61,6 +60,7 @@ function FlexibleTableRowInner<
|
|
|
61
60
|
isLoading = false,
|
|
62
61
|
rowAttributes,
|
|
63
62
|
isExpandableRowComponentInitiallyOpen = false,
|
|
63
|
+
rowRef,
|
|
64
64
|
tweakStyles,
|
|
65
65
|
expandableRowComponent,
|
|
66
66
|
onRowHover,
|
|
@@ -76,7 +76,7 @@ function FlexibleTableRowInner<
|
|
|
76
76
|
|
|
77
77
|
const [isFocused, setFocused] = useState(false);
|
|
78
78
|
const [nestedComponent, setNestedComponent] = useState<INestedComponent>(() => ({
|
|
79
|
-
isOpen:
|
|
79
|
+
isOpen: isExpandableRowComponentInitiallyOpen,
|
|
80
80
|
}));
|
|
81
81
|
|
|
82
82
|
const isEditable = !isLoading && (isNotEmpty(onRowClick) || isNotEmpty(onRowHover));
|
|
@@ -139,6 +139,7 @@ function FlexibleTableRowInner<
|
|
|
139
139
|
return (
|
|
140
140
|
<>
|
|
141
141
|
<Table.Row
|
|
142
|
+
ref={rowRef}
|
|
142
143
|
className={clsx(classes.root, {
|
|
143
144
|
[classes.active]: isActive,
|
|
144
145
|
[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>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
|
+
import { getTestId } from '@true-engineering/true-react-platform-helpers';
|
|
2
3
|
import { useTweakStyles } from '../../hooks';
|
|
3
4
|
import { IWithMessagesProps, WithMessages } from '../WithMessages';
|
|
4
5
|
import { IInputBaseProps, InputBase } from './InputBase';
|
|
@@ -17,7 +18,7 @@ export const Input = forwardRef<HTMLInputElement, IInputProps>(
|
|
|
17
18
|
<WithMessages
|
|
18
19
|
errorMessage={errorMessage}
|
|
19
20
|
infoMessage={infoMessage}
|
|
20
|
-
testId={testId}
|
|
21
|
+
testId={getTestId(testId, 'wrapper')}
|
|
21
22
|
tweakStyles={tweakWithMessagesStyles}
|
|
22
23
|
>
|
|
23
24
|
<InputBase
|
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
import { addDataAttributes } from '../../helpers';
|
|
9
9
|
import { ICommonProps } from '../../types';
|
|
10
10
|
import { WithPopup } from '../WithPopup';
|
|
11
|
-
import { IListItemProps,
|
|
11
|
+
import { IListItemProps, ListItem } from './components';
|
|
12
|
+
import { IListItem } from './types';
|
|
12
13
|
import { useStyles, IListStyles, withPopupStyles } from './List.styles';
|
|
13
14
|
|
|
14
15
|
export interface IListProps extends ICommonProps<IListStyles> {
|
|
@@ -29,9 +30,11 @@ export const List: FC<IListProps> = ({ items, testId, data, tweakStyles, onClick
|
|
|
29
30
|
}
|
|
30
31
|
};
|
|
31
32
|
|
|
33
|
+
const filteredItems = items.filter(({ isHidden }) => !isHidden);
|
|
34
|
+
|
|
32
35
|
return (
|
|
33
36
|
<div className={classes.root} {...addDataTestId(testId)} {...addDataAttributes(data)}>
|
|
34
|
-
{
|
|
37
|
+
{filteredItems.map((item, i) => {
|
|
35
38
|
const itemProps: IListItemProps = {
|
|
36
39
|
testId: getTestId(testId, `item-${i}`),
|
|
37
40
|
...item,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export * from './List';
|
|
2
2
|
export type { IListStyles } from './List.styles';
|
|
3
|
-
export
|
|
3
|
+
export type { IListItem } from './types';
|
|
4
|
+
export { type IListItemStyles, type IListItemProps, ListItem } from './components';
|
|
@@ -26,7 +26,8 @@ export default {
|
|
|
26
26
|
const Template: ComponentStory<typeof PhoneInput> = (args) => {
|
|
27
27
|
const [value, setValue] = useState<IPhoneValue>({
|
|
28
28
|
dialCode: '7',
|
|
29
|
-
phoneNumber: '
|
|
29
|
+
phoneNumber: '9134567890',
|
|
30
|
+
countryCode: 'RU',
|
|
30
31
|
});
|
|
31
32
|
|
|
32
33
|
return <PhoneInput {...args} value={value} onChange={setValue} />;
|
|
@@ -76,7 +76,7 @@ export const PhoneInput: FC<IPhoneInputProps> = ({
|
|
|
76
76
|
|
|
77
77
|
const countryCode = useMemo(
|
|
78
78
|
() => value?.countryCode ?? getCountryCodeFromPhone(phoneWithCode),
|
|
79
|
-
[value.dialCode, value.phoneNumber],
|
|
79
|
+
[value.countryCode, value.dialCode, value.phoneNumber],
|
|
80
80
|
);
|
|
81
81
|
|
|
82
82
|
const handleClose = () => {
|
|
@@ -122,7 +122,10 @@ export const PhoneInput: FC<IPhoneInputProps> = ({
|
|
|
122
122
|
if (newPhoneInfo.countryCode !== countryCode) {
|
|
123
123
|
onChange(
|
|
124
124
|
{
|
|
125
|
-
phoneNumber:
|
|
125
|
+
phoneNumber:
|
|
126
|
+
newPhoneInfo.dialCode !== value.dialCode
|
|
127
|
+
? ''
|
|
128
|
+
: getPhoneObjFromString(phoneWithCode).phoneNumber,
|
|
126
129
|
dialCode: newPhoneInfo.dialCode,
|
|
127
130
|
countryCode: newPhoneInfo.countryCode,
|
|
128
131
|
},
|
|
@@ -1,44 +1,31 @@
|
|
|
1
|
-
import { colors, createThemedStyles, dimensions, ITweakStyles } from '../../theme';
|
|
2
1
|
import { IInputStyles } from '../Input';
|
|
3
2
|
|
|
4
|
-
const
|
|
3
|
+
export const inputStyles: IInputStyles = {
|
|
4
|
+
tweakControlWrapper: {
|
|
5
|
+
endIcon: {
|
|
6
|
+
position: 'absolute',
|
|
7
|
+
width: 40,
|
|
8
|
+
left: 0,
|
|
5
9
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
},
|
|
10
|
+
'&:last-child': {
|
|
11
|
+
paddingRight: 0,
|
|
12
|
+
},
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
left: 12,
|
|
16
|
-
height: '100%',
|
|
17
|
-
width: 20,
|
|
18
|
-
color: colors.GREY_ACTIVE,
|
|
19
|
-
zIndex: Z_INDEX.CONTROL_FOCUS + 1,
|
|
20
|
-
},
|
|
21
|
-
});
|
|
14
|
+
'&:not($activeIcon)': {
|
|
15
|
+
pointerEvents: 'none',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
22
18
|
|
|
23
|
-
export const inputStyles: IInputStyles = {
|
|
24
|
-
tweakControlWrapper: {
|
|
25
19
|
controlWrapper: {
|
|
26
20
|
borderColor: 'transparent',
|
|
27
|
-
borderRadius: 18,
|
|
28
|
-
paddingLeft: 0,
|
|
29
|
-
transitionProperty: 'background-color, border-color',
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
focused: {
|
|
33
|
-
backgroundColor: colors.CLASSIC_WHITE,
|
|
34
|
-
borderColor: colors.BORDER_MAIN,
|
|
35
21
|
},
|
|
36
22
|
},
|
|
37
|
-
|
|
38
23
|
inputContent: {
|
|
39
24
|
fontSize: 14,
|
|
40
25
|
paddingLeft: 44,
|
|
41
26
|
},
|
|
42
27
|
};
|
|
43
28
|
|
|
44
|
-
export
|
|
29
|
+
export interface ISearchInputStyles {
|
|
30
|
+
tweakInput?: IInputStyles;
|
|
31
|
+
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { addDataAttributes } from '../../helpers';
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { getTestId } from '@true-engineering/true-react-platform-helpers';
|
|
4
3
|
import { useTweakStyles } from '../../hooks';
|
|
5
4
|
import { ICommonProps } from '../../types';
|
|
6
|
-
import { Icon } from '../Icon';
|
|
7
5
|
import { IInputProps, Input } from '../Input';
|
|
8
|
-
import { inputStyles, ISearchInputStyles
|
|
6
|
+
import { inputStyles, ISearchInputStyles } from './SearchInput.styles';
|
|
9
7
|
|
|
10
8
|
export type ISearchInputProps = Omit<
|
|
11
9
|
IInputProps,
|
|
@@ -13,37 +11,26 @@ export type ISearchInputProps = Omit<
|
|
|
13
11
|
> &
|
|
14
12
|
ICommonProps<ISearchInputStyles>;
|
|
15
13
|
|
|
16
|
-
export const SearchInput
|
|
17
|
-
isClearable = true,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}) => {
|
|
25
|
-
const classes = useStyles({ theme: tweakStyles });
|
|
14
|
+
export const SearchInput = forwardRef<HTMLInputElement, ISearchInputProps>(
|
|
15
|
+
({ isClearable = true, placeholder, value, testId, tweakStyles, data, ...props }, ref) => {
|
|
16
|
+
const tweakInputStyles = useTweakStyles({
|
|
17
|
+
innerStyles: inputStyles,
|
|
18
|
+
tweakStyles,
|
|
19
|
+
className: 'tweakInput',
|
|
20
|
+
currentComponentName: 'SearchInput',
|
|
21
|
+
});
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
innerStyles: inputStyles,
|
|
29
|
-
tweakStyles,
|
|
30
|
-
className: 'tweakInput',
|
|
31
|
-
currentComponentName: 'SearchInput',
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<div className={classes.root} {...addDataTestId(testId)} {...addDataAttributes(data)}>
|
|
36
|
-
<div className={classes.icon}>
|
|
37
|
-
<Icon type="search" />
|
|
38
|
-
</div>
|
|
23
|
+
return (
|
|
39
24
|
<Input
|
|
25
|
+
ref={ref}
|
|
40
26
|
value={value}
|
|
41
27
|
placeholder={placeholder}
|
|
28
|
+
icon="search"
|
|
42
29
|
isClearable={isClearable}
|
|
43
30
|
testId={getTestId(testId, 'input')}
|
|
44
31
|
tweakStyles={tweakInputStyles}
|
|
45
32
|
{...props}
|
|
46
33
|
/>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
34
|
+
);
|
|
35
|
+
},
|
|
36
|
+
);
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
KeyboardEvent,
|
|
6
6
|
MouseEvent,
|
|
7
7
|
ReactNode,
|
|
8
|
+
Ref,
|
|
8
9
|
SyntheticEvent,
|
|
9
10
|
useCallback,
|
|
10
11
|
useEffect,
|
|
@@ -63,7 +64,11 @@ export interface ISelectProps<Value>
|
|
|
63
64
|
/** @default true */
|
|
64
65
|
shouldScrollToList?: boolean;
|
|
65
66
|
isMultiSelect?: false;
|
|
66
|
-
searchInput?: {
|
|
67
|
+
searchInput?: {
|
|
68
|
+
/** @default false */
|
|
69
|
+
shouldRenderInList?: boolean;
|
|
70
|
+
ref?: Ref<HTMLInputElement>;
|
|
71
|
+
} & Pick<ISearchInputProps, 'placeholder' | 'shouldFocusOnMount'>;
|
|
67
72
|
isOptionDisabled?: (option: Value) => boolean;
|
|
68
73
|
onChange: (value: Value | undefined, event: IChangeSelectEvent) => void; // подумать как возвращать индекс
|
|
69
74
|
onBlur?: (event: Event | SyntheticEvent) => void;
|
|
@@ -248,10 +253,14 @@ export function Select<Value>(
|
|
|
248
253
|
|
|
249
254
|
const handleListClose = useCallback(
|
|
250
255
|
(event: Event | SyntheticEvent) => {
|
|
256
|
+
if (!isListOpen) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
|
|
251
260
|
closeList();
|
|
252
261
|
onBlur?.(event);
|
|
253
262
|
},
|
|
254
|
-
[closeList, onBlur],
|
|
263
|
+
[isListOpen, closeList, onBlur],
|
|
255
264
|
);
|
|
256
265
|
|
|
257
266
|
const handleListOpen = () => {
|
|
@@ -581,6 +590,7 @@ export function Select<Value>(
|
|
|
581
590
|
errorMessage={errorMessage}
|
|
582
591
|
infoMessage={infoMessage}
|
|
583
592
|
tweakStyles={tweakWithMessagesStyles}
|
|
593
|
+
testId={getTestId(testId, 'wrapper')}
|
|
584
594
|
>
|
|
585
595
|
<div className={classes.root} onKeyDown={handleKeyDown} ref={root}>
|
|
586
596
|
<div
|
|
@@ -84,7 +84,7 @@ export function SelectList<Value>({
|
|
|
84
84
|
})}
|
|
85
85
|
>
|
|
86
86
|
{isHeaderNotEmpty && <div className={classes.listHeader}>{customListHeader}</div>}
|
|
87
|
-
<div className={classes.list} {...addDataTestId(testId)}>
|
|
87
|
+
<div className={classes.list} {...addDataTestId(testId)} tabIndex={-1}>
|
|
88
88
|
{isLoading ? (
|
|
89
89
|
<div className={clsx(classes.cell, classes.loading)}>{loadingLabel}</div>
|
|
90
90
|
) : (
|
|
@@ -2,6 +2,7 @@ import { ChangeEvent, FocusEvent, FormEvent, forwardRef, useState } from 'react'
|
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import {
|
|
4
4
|
addDataAttributes,
|
|
5
|
+
getTestId,
|
|
5
6
|
isNotEmpty,
|
|
6
7
|
isReactNodeNotEmpty,
|
|
7
8
|
isStringNotEmpty,
|
|
@@ -114,6 +115,7 @@ export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
|
|
|
114
115
|
errorMessage={errorMessage}
|
|
115
116
|
infoMessage={infoMessage}
|
|
116
117
|
tweakStyles={tweakWithMessagesStyles}
|
|
118
|
+
testId={getTestId(testId, 'wrapper')}
|
|
117
119
|
>
|
|
118
120
|
<ControlWrapper
|
|
119
121
|
label={label}
|
|
@@ -122,7 +124,6 @@ export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
|
|
|
122
124
|
isDisabled={isDisabled}
|
|
123
125
|
hasValue={hasValue}
|
|
124
126
|
isFullWidth
|
|
125
|
-
testId={testId}
|
|
126
127
|
{...controlProps}
|
|
127
128
|
>
|
|
128
129
|
<div
|
|
@@ -142,7 +143,7 @@ export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
|
|
|
142
143
|
onFocus={handleFocus}
|
|
143
144
|
onBlur={handleBlur}
|
|
144
145
|
onChange={handleChange}
|
|
145
|
-
{...addDataAttributes(data, testId
|
|
146
|
+
{...addDataAttributes(data, testId)}
|
|
146
147
|
/>
|
|
147
148
|
</div>
|
|
148
149
|
</ControlWrapper>
|
|
@@ -8,7 +8,7 @@ import { useStyles, ITooltipStyles } from './Tooltip.styles';
|
|
|
8
8
|
export interface ITooltipProps extends ICommonProps<ITooltipStyles> {
|
|
9
9
|
text: ReactNode;
|
|
10
10
|
/** @default 'tooltip' */
|
|
11
|
-
view?: 'tooltip' | 'hint';
|
|
11
|
+
view?: 'tooltip' | 'hint' | 'custom';
|
|
12
12
|
/** @default 'info' */
|
|
13
13
|
type?: 'info' | 'error';
|
|
14
14
|
}
|