@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.
Files changed (126) hide show
  1. package/README.md +11 -567
  2. package/dist/components/Button/Button.styles.d.ts +1 -1
  3. package/dist/components/Checkbox/Checkbox.styles.d.ts +1 -1
  4. package/dist/components/DatePicker/DatePicker.d.ts +2 -2
  5. package/dist/components/DatePicker/helpers.d.ts +3 -0
  6. package/dist/components/DatePicker/types.d.ts +3 -1
  7. package/dist/components/FiltersPane/FiltersPane.d.ts +4 -2
  8. package/dist/components/FiltersPane/FiltersPane.stories.d.ts +3 -3
  9. package/dist/components/FiltersPane/components/Filter/Filter.d.ts +2 -2
  10. package/dist/components/FiltersPane/components/Filter/helpers.d.ts +4 -0
  11. package/dist/components/FiltersPane/components/FilterInterval/FilterInterval.styles.d.ts +1 -1
  12. package/dist/components/FiltersPane/components/FilterSelect/FilterSelect.styles.d.ts +1 -1
  13. package/dist/components/FiltersPane/components/FilterValueView/FilterValueView.d.ts +3 -1
  14. package/dist/components/FiltersPane/components/FilterWithDates/FilterWithDates.styles.d.ts +2 -2
  15. package/dist/components/FiltersPane/components/FilterWrapper/FilterWrapper.d.ts +2 -2
  16. package/dist/components/FiltersPane/types.d.ts +15 -5
  17. package/dist/components/Flag/customFlags/customFlags.d.ts +10 -0
  18. package/dist/components/Flag/customFlags/index.d.ts +1 -0
  19. package/dist/components/FlexibleTable/FlexibleTable.d.ts +4 -2
  20. package/dist/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.d.ts +6 -6
  21. package/dist/components/FlexibleTable/constants.d.ts +18 -2
  22. package/dist/components/FlexibleTable/types.d.ts +1 -1
  23. package/dist/components/List/List.d.ts +1 -1
  24. package/dist/components/List/index.d.ts +2 -1
  25. package/dist/components/List/types.d.ts +4 -0
  26. package/dist/components/SearchInput/SearchInput.d.ts +2 -2
  27. package/dist/components/SearchInput/SearchInput.stories.d.ts +3 -12
  28. package/dist/components/SearchInput/SearchInput.styles.d.ts +3 -5
  29. package/dist/components/Select/Select.d.ts +5 -3
  30. package/dist/components/Select/Select.styles.d.ts +2 -2
  31. package/dist/components/Select/index.d.ts +1 -1
  32. package/dist/components/Tooltip/Tooltip.d.ts +1 -1
  33. package/dist/components/Tooltip/Tooltip.styles.d.ts +1 -1
  34. package/dist/components/WithMessages/WithMessages.styles.d.ts +1 -1
  35. package/dist/components/WithPopup/WithPopup.d.ts +21 -6
  36. package/dist/components/WithPopup/WithPopup.styles.d.ts +1 -1
  37. package/dist/components/WithPopup/helpers.d.ts +2 -0
  38. package/dist/components/WithPopup/types.d.ts +3 -0
  39. package/dist/components/WithTooltip/WithTooltip.styles.d.ts +1 -0
  40. package/dist/hooks/index.d.ts +1 -0
  41. package/dist/hooks/use-merge.d.ts +1 -0
  42. package/dist/hooks/use-mixed-styles.d.ts +3 -1
  43. package/dist/hooks/use-tweak-styles.d.ts +5 -5
  44. package/dist/theme/Provider.d.ts +6 -3
  45. package/dist/theme/common.d.ts +4 -2
  46. package/dist/theme/create-themed-styles.d.ts +2 -0
  47. package/dist/theme/helpers.d.ts +9 -3
  48. package/dist/theme/index.d.ts +2 -0
  49. package/dist/theme/true-jss/ThemedStylesManager.d.ts +18 -0
  50. package/dist/theme/true-jss/TweakStylesManager.d.ts +34 -0
  51. package/dist/theme/true-jss/index.d.ts +2 -0
  52. package/dist/theme/true-jss/jss-context.d.ts +9 -0
  53. package/dist/theme/types.d.ts +4 -2
  54. package/dist/true-react-common-ui-kit.js +7059 -6128
  55. package/dist/true-react-common-ui-kit.js.map +1 -1
  56. package/dist/true-react-common-ui-kit.umd.cjs +6957 -6027
  57. package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
  58. package/dist/types.d.ts +2 -1
  59. package/package.json +1 -1
  60. package/src/components/ControlWrapper/ControlWrapper.styles.ts +4 -4
  61. package/src/components/DatePicker/DatePicker.tsx +9 -4
  62. package/src/components/DatePicker/helpers.ts +13 -1
  63. package/src/components/DatePicker/types.ts +4 -1
  64. package/src/components/FiltersPane/FiltersPane.stories.tsx +4 -2
  65. package/src/components/FiltersPane/FiltersPane.tsx +14 -9
  66. package/src/components/FiltersPane/components/Filter/Filter.tsx +24 -17
  67. package/src/components/FiltersPane/components/Filter/helpers.ts +18 -0
  68. package/src/components/FiltersPane/components/FilterInterval/FilterInterval.styles.ts +1 -1
  69. package/src/components/FiltersPane/components/FilterInterval/FilterInterval.tsx +6 -1
  70. package/src/components/FiltersPane/components/FilterValueView/FilterValueView.tsx +27 -22
  71. package/src/components/FiltersPane/components/FilterWithDates/FilterWithDates.styles.ts +1 -0
  72. package/src/components/FiltersPane/components/FilterWithPeriod/FilterWithPeriod.tsx +1 -1
  73. package/src/components/FiltersPane/components/FilterWrapper/FilterWrapper.tsx +7 -5
  74. package/src/components/FiltersPane/types.ts +23 -5
  75. package/src/components/Flag/Flag.stories.tsx +2 -1
  76. package/src/components/Flag/Flag.styles.ts +4 -0
  77. package/src/components/Flag/Flag.tsx +23 -9
  78. package/src/components/Flag/customFlags/AB.svg +1 -0
  79. package/src/components/Flag/customFlags/OS.svg +1 -0
  80. package/src/components/Flag/customFlags/augment.d.ts +1 -0
  81. package/src/components/Flag/customFlags/customFlags.ts +13 -0
  82. package/src/components/Flag/customFlags/index.ts +1 -0
  83. package/src/components/FlexibleTable/FlexibleTable.tsx +13 -12
  84. package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.tsx +9 -8
  85. package/src/components/FlexibleTable/constants.ts +6 -3
  86. package/src/components/FlexibleTable/types.ts +1 -5
  87. package/src/components/IncrementInput/IncrementInput.styles.ts +1 -1
  88. package/src/components/Input/Input.tsx +2 -1
  89. package/src/components/Input/InputBase.tsx +1 -1
  90. package/src/components/List/List.tsx +5 -2
  91. package/src/components/List/index.ts +2 -1
  92. package/src/components/List/types.ts +5 -0
  93. package/src/components/PhoneInput/PhoneInput.stories.tsx +2 -1
  94. package/src/components/PhoneInput/PhoneInput.tsx +5 -2
  95. package/src/components/SearchInput/SearchInput.styles.ts +16 -29
  96. package/src/components/SearchInput/SearchInput.tsx +17 -30
  97. package/src/components/Select/Select.tsx +12 -2
  98. package/src/components/Select/components/SelectList/SelectList.tsx +1 -1
  99. package/src/components/Select/index.ts +1 -1
  100. package/src/components/TextArea/TextArea.tsx +3 -2
  101. package/src/components/Tooltip/Tooltip.styles.ts +2 -0
  102. package/src/components/Tooltip/Tooltip.tsx +1 -1
  103. package/src/components/WithPopup/WithPopup.stories.tsx +1 -0
  104. package/src/components/WithPopup/WithPopup.styles.ts +2 -0
  105. package/src/components/WithPopup/WithPopup.tsx +64 -16
  106. package/src/components/WithPopup/helpers.ts +9 -0
  107. package/src/components/WithPopup/types.ts +7 -0
  108. package/src/components/WithTooltip/WithTooltip.styles.ts +6 -0
  109. package/src/components/WithTooltip/WithTooltip.tsx +7 -2
  110. package/src/constants/phone-info.ts +20 -33
  111. package/src/helpers/phone.ts +19 -15
  112. package/src/hooks/index.ts +1 -0
  113. package/src/hooks/use-merge.ts +8 -0
  114. package/src/hooks/use-mixed-styles.ts +9 -11
  115. package/src/hooks/use-tweak-styles.ts +49 -27
  116. package/src/theme/Provider.tsx +10 -5
  117. package/src/theme/common.ts +5 -2
  118. package/src/theme/create-themed-styles.ts +78 -0
  119. package/src/theme/helpers.ts +39 -39
  120. package/src/theme/index.ts +2 -0
  121. package/src/theme/true-jss/ThemedStylesManager.ts +92 -0
  122. package/src/theme/true-jss/TweakStylesManager.ts +157 -0
  123. package/src/theme/true-jss/index.ts +2 -0
  124. package/src/theme/true-jss/jss-context.tsx +34 -0
  125. package/src/theme/types.ts +4 -2
  126. package/src/types.ts +2 -1
@@ -0,0 +1,13 @@
1
+ import AB from './AB.svg?raw';
2
+ import OS from './OS.svg?raw';
3
+
4
+ export const customFlags = {
5
+ /**
6
+ * Абхазия
7
+ */
8
+ AB,
9
+ /**
10
+ * Южная осетия
11
+ */
12
+ OS,
13
+ };
@@ -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 tableRowProps: Omit<
109
- IFlexibleTableRowProps<Row, HeaderContent, UniqueField>,
110
- 'item' | 'index'
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
- {...tableRowProps}
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 { applyAction, isEmpty, isNotEmpty } from '@true-engineering/true-react-platform-helpers';
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 { ICommonProps, IDataAttributes } from '../../../../types';
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 Pick<ICommonProps<IFlexibleTableRowStyles>, 'tweakStyles'> {
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 | ((row: Row, index: number) => 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: applyAction(isExpandableRowComponentInitiallyOpen, item, index),
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 { IFlexibleTableRenderMode, IFlexibleTableRender } from './types';
1
+ import { IFlexibleTableRenderElement, IFlexibleTableRenderMode } from './types';
2
2
 
3
3
  export const DEFAULT_DATE_FORMAT = 'dd.MM.yyyy';
4
4
 
5
- export const TableRenders: Record<IFlexibleTableRenderMode, IFlexibleTableRender> = {
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>;
@@ -72,7 +72,7 @@ export const inputStyles: IInputStyles = {
72
72
  controls: {
73
73
  paddingRight: BUTTONS_WIDTH + BUTTONS_GAP,
74
74
  },
75
- }
75
+ },
76
76
  };
77
77
 
78
78
  export type IIncrementInputStyles = ITweakStyles<typeof useStyles, { tweakInput: IInputStyles }>;
@@ -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
@@ -194,7 +194,7 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
194
194
  onFocus: handleFocus,
195
195
  onBlur: handleBlur,
196
196
  onChange: handleChange,
197
- ...addDataTestId(testId, 'input'),
197
+ ...addDataTestId(testId),
198
198
  };
199
199
 
200
200
  useEffect(() => {
@@ -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, IListItemProps as IListItem, ListItem } from './components';
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
- {items.map((item, i) => {
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 { type IListItemStyles, type IListItemProps as IListItem, ListItem } from './components';
3
+ export type { IListItem } from './types';
4
+ export { type IListItemStyles, type IListItemProps, ListItem } from './components';
@@ -0,0 +1,5 @@
1
+ import { IListItemProps } from './components';
2
+
3
+ export interface IListItem extends IListItemProps {
4
+ isHidden?: boolean;
5
+ }
@@ -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: '1234567890',
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 { Z_INDEX } = dimensions;
3
+ export const inputStyles: IInputStyles = {
4
+ tweakControlWrapper: {
5
+ endIcon: {
6
+ position: 'absolute',
7
+ width: 40,
8
+ left: 0,
5
9
 
6
- export const useStyles = createThemedStyles('SearchInput', {
7
- root: {
8
- position: 'relative',
9
- },
10
+ '&:last-child': {
11
+ paddingRight: 0,
12
+ },
10
13
 
11
- icon: {
12
- display: 'flex',
13
- alignItems: 'center',
14
- position: 'absolute',
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 type ISearchInputStyles = ITweakStyles<typeof useStyles, { tweakInput: IInputStyles }>;
29
+ export interface ISearchInputStyles {
30
+ tweakInput?: IInputStyles;
31
+ }
@@ -1,11 +1,9 @@
1
- import { FC } from 'react';
2
- import { addDataTestId, getTestId } from '@true-engineering/true-react-platform-helpers';
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, useStyles } from './SearchInput.styles';
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: FC<ISearchInputProps> = ({
17
- isClearable = true,
18
- tweakStyles,
19
- placeholder,
20
- value,
21
- testId,
22
- data,
23
- ...props
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
- const tweakInputStyles = useTweakStyles({
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
- </div>
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?: { shouldRenderInList: true } & Pick<ISearchInputProps, 'placeholder'>;
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
  ) : (
@@ -1,4 +1,4 @@
1
1
  export * from './Select';
2
2
  export * from './types';
3
3
  export type { ISelectStyles } from './Select.styles';
4
- export type { ISelectListStyles } from './components';
4
+ export { type ISelectListStyles, SelectList } from './components';
@@ -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, 'control')}
146
+ {...addDataAttributes(data, testId)}
146
147
  />
147
148
  </div>
148
149
  </ControlWrapper>
@@ -32,6 +32,8 @@ export const useStyles = createThemedStyles('Tooltip', {
32
32
  letterSpacing: 0.2,
33
33
  },
34
34
 
35
+ custom: {},
36
+
35
37
  info: {},
36
38
 
37
39
  error: {
@@ -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
  }
@@ -91,6 +91,7 @@ Default.args = {
91
91
  shouldRenderInBody: true,
92
92
  shouldHideOnScroll: false,
93
93
  shouldStopPropagation: true,
94
+ shouldShowArrow: false,
94
95
  };
95
96
 
96
97
  Default.parameters = {
@@ -20,6 +20,8 @@ export const useStyles = createThemedStyles('WithPopup', {
20
20
  outline: 'none',
21
21
  },
22
22
 
23
+ arrow: {},
24
+
23
25
  animationEnd: {},
24
26
 
25
27
  animationStart: {},