@true-engineering/true-react-common-ui-kit 4.0.0-alpha2 → 4.0.0-alpha20

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 (209) 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/ControlWrapper/ControlWrapper.d.ts +2 -0
  5. package/dist/components/ControlWrapper/ControlWrapper.styles.d.ts +2 -1
  6. package/dist/components/ControlWrapper/index.d.ts +1 -0
  7. package/dist/components/ControlWrapper/types.d.ts +3 -0
  8. package/dist/components/DatePicker/DatePicker.d.ts +3 -3
  9. package/dist/components/DatePicker/DatePicker.styles.d.ts +1 -1
  10. package/dist/components/DatePicker/components/PopperContainer/PopperContainer.d.ts +2 -4
  11. package/dist/components/DatePicker/helpers.d.ts +3 -0
  12. package/dist/components/DatePicker/types.d.ts +5 -3
  13. package/dist/components/FiltersPane/FiltersPane.d.ts +7 -2
  14. package/dist/components/FiltersPane/components/Filter/Filter.d.ts +2 -2
  15. package/dist/components/FiltersPane/components/Filter/helpers.d.ts +4 -0
  16. package/dist/components/FiltersPane/components/FilterInterval/FilterInterval.styles.d.ts +1 -1
  17. package/dist/components/FiltersPane/components/FilterSelect/FilterSelect.styles.d.ts +1 -1
  18. package/dist/components/FiltersPane/components/FilterValueView/FilterValueView.d.ts +3 -1
  19. package/dist/components/FiltersPane/components/FilterWithDates/FilterWithDates.styles.d.ts +2 -2
  20. package/dist/components/FiltersPane/components/FilterWrapper/FilterWrapper.d.ts +2 -2
  21. package/dist/components/FiltersPane/types.d.ts +15 -5
  22. package/dist/components/Flag/customFlags/customFlags.d.ts +10 -0
  23. package/dist/components/Flag/customFlags/index.d.ts +1 -0
  24. package/dist/components/FlexibleTable/FlexibleTable.d.ts +4 -2
  25. package/dist/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.d.ts +4 -3
  26. package/dist/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.d.ts +6 -6
  27. package/dist/components/FlexibleTable/constants.d.ts +18 -2
  28. package/dist/components/FlexibleTable/types.d.ts +8 -8
  29. package/dist/components/Icon/icons-list.d.ts +1 -1
  30. package/dist/components/IconButton/IconButton.styles.d.ts +1 -1
  31. package/dist/components/Input/Input.d.ts +3 -2
  32. package/dist/components/Input/InputBase.d.ts +2 -2
  33. package/dist/components/List/List.d.ts +1 -1
  34. package/dist/components/List/index.d.ts +2 -1
  35. package/dist/components/List/types.d.ts +4 -0
  36. package/dist/components/Modal/Modal.styles.d.ts +1 -1
  37. package/dist/components/Notification/Notification.styles.d.ts +1 -1
  38. package/dist/components/ScrollIntoViewIfNeeded/ScrollIntoViewIfNeeded.d.ts +1 -1
  39. package/dist/components/SearchInput/SearchInput.d.ts +2 -2
  40. package/dist/components/Select/Select.d.ts +5 -3
  41. package/dist/components/Select/Select.styles.d.ts +4 -4
  42. package/dist/components/Select/index.d.ts +1 -1
  43. package/dist/components/Status/Status.styles.d.ts +3 -2
  44. package/dist/components/Status/constants.d.ts +0 -1
  45. package/dist/components/Status/index.d.ts +1 -0
  46. package/dist/components/Status/types.d.ts +5 -2
  47. package/dist/components/TextArea/TextArea.d.ts +2 -5
  48. package/dist/components/TextArea/TextArea.styles.d.ts +1 -2
  49. package/dist/components/TextArea/index.d.ts +0 -1
  50. package/dist/components/TextButton/TextButton.styles.d.ts +1 -1
  51. package/dist/components/Tooltip/Tooltip.d.ts +1 -1
  52. package/dist/components/Tooltip/Tooltip.styles.d.ts +1 -1
  53. package/dist/components/WithMessages/WithMessages.styles.d.ts +1 -1
  54. package/dist/components/WithPopup/WithPopup.d.ts +21 -6
  55. package/dist/components/WithPopup/WithPopup.styles.d.ts +1 -1
  56. package/dist/components/WithPopup/helpers.d.ts +2 -0
  57. package/dist/components/WithPopup/types.d.ts +3 -0
  58. package/dist/components/WithTooltip/WithTooltip.styles.d.ts +1 -0
  59. package/dist/hooks/index.d.ts +1 -0
  60. package/dist/hooks/use-merge.d.ts +1 -0
  61. package/dist/hooks/use-mixed-styles.d.ts +3 -1
  62. package/dist/hooks/use-tweak-styles.d.ts +5 -5
  63. package/dist/style.css +78 -142
  64. package/dist/theme/Provider.d.ts +6 -3
  65. package/dist/theme/common.d.ts +4 -2
  66. package/dist/theme/create-themed-styles.d.ts +2 -0
  67. package/dist/theme/helpers.d.ts +9 -3
  68. package/dist/theme/index.d.ts +2 -0
  69. package/dist/theme/true-jss/ThemedStylesManager.d.ts +18 -0
  70. package/dist/theme/true-jss/TweakStylesManager.d.ts +34 -0
  71. package/dist/theme/true-jss/index.d.ts +2 -0
  72. package/dist/theme/true-jss/jss-context.d.ts +9 -0
  73. package/dist/theme/types.d.ts +5 -3
  74. package/dist/true-react-common-ui-kit.js +7519 -6456
  75. package/dist/true-react-common-ui-kit.js.map +1 -1
  76. package/dist/true-react-common-ui-kit.umd.cjs +7455 -6393
  77. package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
  78. package/dist/types.d.ts +10 -3
  79. package/package.json +4 -5
  80. package/src/components/ControlWrapper/ControlWrapper.styles.ts +7 -6
  81. package/src/components/ControlWrapper/ControlWrapper.tsx +8 -2
  82. package/src/components/ControlWrapper/index.ts +1 -0
  83. package/src/components/ControlWrapper/types.ts +4 -0
  84. package/src/components/DatePicker/DatePicker.stories.tsx +2 -1
  85. package/src/components/DatePicker/DatePicker.styles.ts +3 -1
  86. package/src/components/DatePicker/DatePicker.tsx +12 -7
  87. package/src/components/DatePicker/components/PopperContainer/PopperContainer.tsx +4 -4
  88. package/src/components/DatePicker/helpers.ts +13 -1
  89. package/src/components/DatePicker/types.ts +9 -4
  90. package/src/components/FiltersPane/FiltersPane.stories.tsx +4 -2
  91. package/src/components/FiltersPane/FiltersPane.tsx +19 -13
  92. package/src/components/FiltersPane/components/Filter/Filter.tsx +24 -17
  93. package/src/components/FiltersPane/components/Filter/helpers.ts +18 -0
  94. package/src/components/FiltersPane/components/FilterValueView/FilterValueView.tsx +27 -22
  95. package/src/components/FiltersPane/components/FilterWithDates/FilterWithDates.styles.ts +1 -0
  96. package/src/components/FiltersPane/components/FilterWithDates/FilterWithDates.tsx +3 -4
  97. package/src/components/FiltersPane/components/FilterWithPeriod/FilterWithPeriod.tsx +1 -1
  98. package/src/components/FiltersPane/components/FilterWrapper/FilterWrapper.tsx +7 -5
  99. package/src/components/FiltersPane/types.ts +23 -5
  100. package/src/components/Flag/Flag.stories.tsx +2 -1
  101. package/src/components/Flag/Flag.styles.ts +4 -0
  102. package/src/components/Flag/Flag.tsx +23 -9
  103. package/src/components/Flag/customFlags/AB.svg +1 -0
  104. package/src/components/Flag/customFlags/OS.svg +1 -0
  105. package/src/components/Flag/customFlags/augment.d.ts +1 -0
  106. package/src/components/Flag/customFlags/customFlags.ts +13 -0
  107. package/src/components/Flag/customFlags/index.ts +1 -0
  108. package/src/components/FlexibleTable/FlexibleTable.tsx +13 -12
  109. package/src/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.tsx +8 -5
  110. package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.tsx +13 -12
  111. package/src/components/FlexibleTable/constants.ts +6 -3
  112. package/src/components/FlexibleTable/types.ts +8 -12
  113. package/src/components/Input/Input.tsx +5 -3
  114. package/src/components/Input/InputBase.tsx +27 -24
  115. package/src/components/List/List.tsx +5 -2
  116. package/src/components/List/index.ts +2 -1
  117. package/src/components/List/types.ts +5 -0
  118. package/src/components/NumberInput/NumberInput.stories.tsx +5 -1
  119. package/src/components/PhoneInput/PhoneInput.stories.tsx +2 -1
  120. package/src/components/PhoneInput/PhoneInput.tsx +5 -2
  121. package/src/components/SearchInput/SearchInput.tsx +20 -29
  122. package/src/components/Select/Select.tsx +12 -2
  123. package/src/components/Select/components/SelectList/SelectList.tsx +1 -1
  124. package/src/components/Select/index.ts +1 -1
  125. package/src/components/Status/Status.stories.tsx +54 -1
  126. package/src/components/Status/Status.styles.ts +2 -37
  127. package/src/components/Status/constants.ts +0 -10
  128. package/src/components/Status/index.ts +1 -1
  129. package/src/components/Status/types.ts +7 -3
  130. package/src/components/TextArea/TextArea.styles.ts +2 -6
  131. package/src/components/TextArea/TextArea.tsx +41 -20
  132. package/src/components/TextArea/index.ts +0 -1
  133. package/src/components/TextButton/TextButton.styles.ts +1 -0
  134. package/src/components/Tooltip/Tooltip.styles.ts +2 -0
  135. package/src/components/Tooltip/Tooltip.tsx +1 -1
  136. package/src/components/WithPopup/WithPopup.stories.tsx +1 -0
  137. package/src/components/WithPopup/WithPopup.styles.ts +2 -0
  138. package/src/components/WithPopup/WithPopup.tsx +64 -16
  139. package/src/components/WithPopup/helpers.ts +9 -0
  140. package/src/components/WithPopup/types.ts +7 -0
  141. package/src/components/WithTooltip/WithTooltip.styles.ts +6 -0
  142. package/src/components/WithTooltip/WithTooltip.tsx +7 -2
  143. package/src/constants/phone-info.ts +20 -33
  144. package/src/helpers/phone.ts +19 -15
  145. package/src/hooks/index.ts +1 -0
  146. package/src/hooks/use-merge.ts +8 -0
  147. package/src/hooks/use-mixed-styles.ts +9 -11
  148. package/src/hooks/use-tweak-styles.ts +49 -27
  149. package/src/theme/Provider.tsx +10 -5
  150. package/src/theme/common.ts +5 -2
  151. package/src/theme/create-themed-styles.ts +78 -0
  152. package/src/theme/helpers.ts +39 -39
  153. package/src/theme/index.ts +2 -0
  154. package/src/theme/true-jss/ThemedStylesManager.ts +92 -0
  155. package/src/theme/true-jss/TweakStylesManager.ts +157 -0
  156. package/src/theme/true-jss/index.ts +2 -0
  157. package/src/theme/true-jss/jss-context.tsx +34 -0
  158. package/src/theme/types.ts +5 -3
  159. package/src/types.ts +17 -4
  160. package/dist/components/AccountInfo/AccountInfo.stories.d.ts +0 -6
  161. package/dist/components/AddButton/AddButton.stories.d.ts +0 -6
  162. package/dist/components/Button/Button.stories.d.ts +0 -6
  163. package/dist/components/Checkbox/Checkbox.stories.d.ts +0 -8
  164. package/dist/components/CloseButton/CloseButton.stories.d.ts +0 -5
  165. package/dist/components/Colors/Colors.stories.d.ts +0 -5
  166. package/dist/components/ControlWrapper/ControlWrapper.stories.d.ts +0 -6
  167. package/dist/components/DateInput/DateInput.stories.d.ts +0 -7
  168. package/dist/components/DatePicker/DatePicker.stories.d.ts +0 -7
  169. package/dist/components/Description/Description.stories.d.ts +0 -16
  170. package/dist/components/FileInput/FileInput.stories.d.ts +0 -7
  171. package/dist/components/FileItem/FileItem.stories.d.ts +0 -8
  172. package/dist/components/FiltersPane/FiltersPane.stories.d.ts +0 -31
  173. package/dist/components/Flag/Flag.stories.d.ts +0 -12
  174. package/dist/components/FlexibleTable/FlexibleTable.stories.d.ts +0 -19
  175. package/dist/components/Icon/Icon.stories.d.ts +0 -6
  176. package/dist/components/IconButton/IconButton.stories.d.ts +0 -6
  177. package/dist/components/IncrementInput/IncrementInput.stories.d.ts +0 -6
  178. package/dist/components/Input/Input.stories.d.ts +0 -25
  179. package/dist/components/List/List.stories.d.ts +0 -5
  180. package/dist/components/Modal/Modal.stories.d.ts +0 -29
  181. package/dist/components/MoreMenu/MoreMenu.stories.d.ts +0 -6
  182. package/dist/components/MultiSelect/MultiSelect.stories.d.ts +0 -13
  183. package/dist/components/NewMoreMenu/NewMoreMenu.stories.d.ts +0 -12
  184. package/dist/components/Notification/Notification.stories.d.ts +0 -8
  185. package/dist/components/NumberInput/NumberInput.stories.d.ts +0 -7
  186. package/dist/components/PhoneInput/PhoneInput.stories.d.ts +0 -28
  187. package/dist/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.stories.d.ts +0 -5
  188. package/dist/components/RadioButton/RadioButton.stories.d.ts +0 -7
  189. package/dist/components/SearchInput/SearchInput.stories.d.ts +0 -6
  190. package/dist/components/Select/CustomSelect.stories.d.ts +0 -11
  191. package/dist/components/Select/MultiSelect.stories.d.ts +0 -15
  192. package/dist/components/Select/Select.stories.d.ts +0 -15
  193. package/dist/components/Selector/Selector.stories.d.ts +0 -7
  194. package/dist/components/Skeleton/Skeleton.stories.d.ts +0 -6
  195. package/dist/components/SmartInput/SmartInput.stories.d.ts +0 -18
  196. package/dist/components/Status/Status.stories.d.ts +0 -6
  197. package/dist/components/Switch/Switch.stories.d.ts +0 -16
  198. package/dist/components/TextArea/TextArea.stories.d.ts +0 -17
  199. package/dist/components/TextArea/types.d.ts +0 -2
  200. package/dist/components/TextButton/TextButton.stories.d.ts +0 -6
  201. package/dist/components/TextWithInfo/TextWithInfo.stories.d.ts +0 -12
  202. package/dist/components/TextWithTooltip/TextWithTooltip.stories.d.ts +0 -24
  203. package/dist/components/ThemedPreloader/ThemedPreloader.stories.d.ts +0 -17
  204. package/dist/components/Toaster/Toaster.stories.d.ts +0 -5
  205. package/dist/components/Tooltip/Tooltip.stories.d.ts +0 -5
  206. package/dist/components/WithMessages/WithMessages.stories.d.ts +0 -7
  207. package/dist/components/WithPopup/WithPopup.stories.d.ts +0 -16
  208. package/dist/components/WithTooltip/WithTooltip.stories.d.ts +0 -6
  209. package/src/components/TextArea/types.ts +0 -6
@@ -15,12 +15,12 @@ import InputMask, { Props as ReactInputMaskBaseProps } from 'react-input-mask';
15
15
  import clsx from 'clsx';
16
16
  import {
17
17
  addDataTestId,
18
+ isArrayLikeNotEmpty,
18
19
  isNotEmpty,
19
20
  isReactNodeNotEmpty,
20
21
  isStringNotEmpty,
21
- mergeRefs,
22
22
  } from '@true-engineering/true-react-platform-helpers';
23
- import { useTweakStyles } from '../../hooks';
23
+ import { useMergedRefs, useTweakStyles } from '../../hooks';
24
24
  import { IClickHandlerEvent, ICommonProps } from '../../types';
25
25
  import { ControlWrapper, IControlWrapperProps } from '../ControlWrapper';
26
26
  import { IChangeInputEvent } from './types';
@@ -28,6 +28,7 @@ import { IInputStyles, useStyles } from './Input.styles';
28
28
 
29
29
  export interface IInputBaseProps
30
30
  extends ICommonProps<IInputStyles>,
31
+ Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'size'>,
31
32
  Pick<
32
33
  IControlWrapperProps,
33
34
  | 'label'
@@ -38,20 +39,7 @@ export interface IInputBaseProps
38
39
  | 'isLoading'
39
40
  | 'isDisabled'
40
41
  | 'onIconClick'
41
- >,
42
- Pick<
43
- InputHTMLAttributes<HTMLInputElement>,
44
- | 'type'
45
- | 'inputMode'
46
- | 'autoComplete'
47
- | 'name'
48
- | 'maxLength'
49
- | 'tabIndex'
50
- | 'placeholder'
51
- | 'onFocus'
52
- | 'onBlur'
53
- | 'onPaste'
54
- | 'onKeyDown'
42
+ | 'size'
55
43
  >,
56
44
  Pick<
57
45
  Partial<ReactInputMaskBaseProps>,
@@ -71,7 +59,7 @@ export interface IInputBaseProps
71
59
  isAutoSized?: boolean;
72
60
  /** @default false */
73
61
  shouldAlwaysShowPlaceholder?: boolean;
74
- onChange(value: string, event: IChangeInputEvent): void;
62
+ onChange: (value: string, event: IChangeInputEvent) => void;
75
63
  }
76
64
 
77
65
  export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
@@ -96,6 +84,7 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
96
84
  units,
97
85
  testId,
98
86
  tabIndex,
87
+ shouldAlwaysShowPlaceholder,
99
88
  onChange,
100
89
  onPaste,
101
90
  onFocus,
@@ -105,9 +94,16 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
105
94
  mask,
106
95
  maskPlaceholder,
107
96
  alwaysShowMask,
108
- shouldAlwaysShowPlaceholder,
109
97
  beforeMaskedStateChange,
110
- ...controlProps
98
+ // Пропсы ControlWrapper
99
+ data,
100
+ groupPlacement,
101
+ icon,
102
+ isLoading,
103
+ isRequired,
104
+ size,
105
+ onIconClick,
106
+ ...inputProps
111
107
  },
112
108
  ref,
113
109
  ) => {
@@ -123,7 +119,7 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
123
119
  const [unitsWidth, setUnitsWidth] = useState<number>();
124
120
 
125
121
  const inputRef = useRef<HTMLInputElement>(null);
126
- const mergedRef = mergeRefs([ref, inputRef]);
122
+ const mergedRef = useMergedRefs([ref, inputRef]);
127
123
 
128
124
  // Try to guess input-mode if possible
129
125
  const inputMode: IInputBaseProps['inputMode'] =
@@ -131,7 +127,7 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
131
127
  (['email', 'tel', 'url'].includes(type) ? (type as 'email' | 'tel' | 'url') : undefined);
132
128
 
133
129
  const hasFocus = isFocused || isActive;
134
- const hasValue = isNotEmpty(value) && value !== '';
130
+ const hasValue = isArrayLikeNotEmpty(value);
135
131
  const hasUnits = isReactNodeNotEmpty(units);
136
132
  const hasPlaceholder =
137
133
  (!isReactNodeNotEmpty(label) || hasFocus || shouldAlwaysShowPlaceholder) &&
@@ -194,7 +190,8 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
194
190
  onFocus: handleFocus,
195
191
  onBlur: handleBlur,
196
192
  onChange: handleChange,
197
- ...addDataTestId(testId, 'input'),
193
+ ...addDataTestId(testId),
194
+ ...inputProps,
198
195
  };
199
196
 
200
197
  useEffect(() => {
@@ -234,11 +231,17 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
234
231
  isDisabled={isDisabled}
235
232
  isFocused={hasFocus}
236
233
  isInvalid={isInvalid}
237
- hasValue={hasValue || hasPlaceholder}
234
+ hasValue={hasValue}
238
235
  isFullWidth={!isAutoSized}
239
236
  tweakStyles={tweakControlWrapperStyles}
240
237
  onClear={isClearable && hasValue ? handleInputClear : undefined}
241
- {...controlProps}
238
+ data={data}
239
+ groupPlacement={groupPlacement}
240
+ icon={icon}
241
+ isLoading={isLoading}
242
+ isRequired={isRequired}
243
+ onIconClick={onIconClick}
244
+ size={size}
242
245
  >
243
246
  {hasUnits || isAutoSized ? (
244
247
  <div className={classes.autoSizeWrapper}>{inputContent}</div>
@@ -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
+ }
@@ -9,7 +9,11 @@ export default {
9
9
 
10
10
  const Template: ComponentStory<typeof NumberInput> = (args) => {
11
11
  const [value, setValue] = useState<number>();
12
- return <NumberInput {...args} value={value} onChange={(v) => setValue(v)} />;
12
+ return (
13
+ <div style={{ width: 300 }}>
14
+ <NumberInput {...args} value={value} onChange={(v) => setValue(v)} />
15
+ </div>
16
+ );
13
17
  };
14
18
 
15
19
  export const Default = Template.bind({});
@@ -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,5 +1,4 @@
1
- import { FC } from 'react';
2
- import { getTestId } from '@true-engineering/true-react-platform-helpers';
1
+ import { forwardRef } from 'react';
3
2
  import { useTweakStyles } from '../../hooks';
4
3
  import { ICommonProps } from '../../types';
5
4
  import { IInputProps, Input } from '../Input';
@@ -11,31 +10,23 @@ export type ISearchInputProps = Omit<
11
10
  > &
12
11
  ICommonProps<ISearchInputStyles>;
13
12
 
14
- export const SearchInput: FC<ISearchInputProps> = ({
15
- isClearable = true,
16
- placeholder,
17
- value,
18
- testId,
19
- tweakStyles,
20
- data,
21
- ...props
22
- }) => {
23
- const tweakInputStyles = useTweakStyles({
24
- innerStyles: inputStyles,
25
- tweakStyles,
26
- className: 'tweakInput',
27
- currentComponentName: 'SearchInput',
28
- });
13
+ export const SearchInput = forwardRef<HTMLInputElement, ISearchInputProps>(
14
+ ({ isClearable = true, tweakStyles, ...props }, ref) => {
15
+ const tweakInputStyles = useTweakStyles({
16
+ innerStyles: inputStyles,
17
+ tweakStyles,
18
+ className: 'tweakInput',
19
+ currentComponentName: 'SearchInput',
20
+ });
29
21
 
30
- return (
31
- <Input
32
- value={value}
33
- placeholder={placeholder}
34
- icon="search"
35
- isClearable={isClearable}
36
- testId={getTestId(testId, 'input')}
37
- tweakStyles={tweakInputStyles}
38
- {...props}
39
- />
40
- );
41
- };
22
+ return (
23
+ <Input
24
+ ref={ref}
25
+ icon="search"
26
+ isClearable={isClearable}
27
+ tweakStyles={tweakInputStyles}
28
+ {...props}
29
+ />
30
+ );
31
+ },
32
+ );
@@ -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';
@@ -1,18 +1,71 @@
1
1
  import { Status } from '.';
2
2
  import { ComponentStory } from '@storybook/react';
3
+ import { rgba } from '../../helpers';
4
+ import { IExtendableProps } from '../../types';
3
5
  import { iconsList, IIconType } from '../Icon';
4
6
  import { complexIcons } from '../Icon/complexIcons';
5
- import { STATUS_COLORS, STATUS_SIZES } from './constants';
7
+ import { STATUS_SIZES } from './constants';
6
8
  import { IStatusStyles } from './Status.styles';
7
9
 
10
+ export const STATUS_COLORS = [
11
+ 'green',
12
+ 'teal',
13
+ 'blue',
14
+ 'grey',
15
+ 'orange',
16
+ 'red',
17
+ 'violet',
18
+ 'custom',
19
+ ] as const;
20
+
8
21
  export default {
9
22
  title: 'Data Display/Status',
10
23
  component: Status,
11
24
  };
12
25
 
26
+ declare module './types' {
27
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
28
+ export interface IStatusColors extends IExtendableProps<typeof STATUS_COLORS> {}
29
+ }
30
+
13
31
  const icons = [undefined, ...Object.keys(iconsList), ...Object.keys(complexIcons)] as IIconType[];
14
32
 
15
33
  const customTweakStyles: IStatusStyles = {
34
+ green: {
35
+ '--status-background': rgba('#D4E3AC', 0.5),
36
+ '--status-color': '#6F990F',
37
+ },
38
+
39
+ blue: {
40
+ '--status-background': rgba('#AABFFC', 0.4),
41
+ '--status-color': '#4C6EBF',
42
+ },
43
+
44
+ grey: {
45
+ '--status-background': rgba('#95A0B3', 0.25),
46
+ '--status-color': '#7A869A',
47
+ },
48
+
49
+ orange: {
50
+ '--status-background': rgba('#FCD3A9', 0.5),
51
+ '--status-color': '#E5741C',
52
+ },
53
+
54
+ red: {
55
+ '--status-background': rgba('#F7949A', 0.25),
56
+ '--status-color': '#F14D56',
57
+ },
58
+
59
+ teal: {
60
+ '--status-background': rgba('#8CE3EA', 0.4),
61
+ '--status-color': '#0092A6',
62
+ },
63
+
64
+ violet: {
65
+ '--status-background': rgba('#BEABE0', 0.4),
66
+ '--status-color': '#7450B2',
67
+ },
68
+
16
69
  custom: {
17
70
  '--status-color': '#793472',
18
71
  '--status-background': '#F2B9ED',
@@ -1,5 +1,5 @@
1
- import { rgba } from '../../helpers';
2
1
  import { colors, createThemedStyles, ITweakStyles } from '../../theme';
2
+ import { IStatusColors } from './types';
3
3
 
4
4
  export const useStyles = createThemedStyles('Status', {
5
5
  root: {
@@ -102,42 +102,7 @@ export const useStyles = createThemedStyles('Status', {
102
102
  },
103
103
  },
104
104
 
105
- green: {
106
- '--status-background': rgba('#D4E3AC', 0.5),
107
- '--status-color': '#6F990F',
108
- },
109
-
110
- blue: {
111
- '--status-background': rgba('#AABFFC', 0.4),
112
- '--status-color': '#4C6EBF',
113
- },
114
-
115
- grey: {
116
- '--status-background': rgba('#95A0B3', 0.25),
117
- '--status-color': '#7A869A',
118
- },
119
-
120
- orange: {
121
- '--status-background': rgba('#FCD3A9', 0.5),
122
- '--status-color': '#E5741C',
123
- },
124
-
125
- red: {
126
- '--status-background': rgba('#F7949A', 0.25),
127
- '--status-color': '#F14D56',
128
- },
129
-
130
- teal: {
131
- '--status-background': rgba('#8CE3EA', 0.4),
132
- '--status-color': '#0092A6',
133
- },
134
-
135
- violet: {
136
- '--status-background': rgba('#BEABE0', 0.4),
137
- '--status-color': '#7450B2',
138
- },
139
-
140
105
  custom: {},
141
106
  });
142
107
 
143
- export type IStatusStyles = ITweakStyles<typeof useStyles>;
108
+ export type IStatusStyles = ITweakStyles<typeof useStyles, IStatusColors>;
@@ -1,11 +1 @@
1
- export const STATUS_COLORS = [
2
- 'green',
3
- 'teal',
4
- 'blue',
5
- 'grey',
6
- 'orange',
7
- 'red',
8
- 'violet',
9
- 'custom',
10
- ] as const;
11
1
  export const STATUS_SIZES = ['xs', 's', 'm'] as const;
@@ -1,3 +1,3 @@
1
1
  export * from './Status';
2
-
2
+ export * from './types';
3
3
  export type { IStatusStyles } from './Status.styles';
@@ -1,5 +1,9 @@
1
- import { STATUS_COLORS, STATUS_SIZES } from './constants';
2
-
3
- export type IStatusColor = (typeof STATUS_COLORS)[number];
1
+ import { IDefaultExtendableProps } from '../../types';
2
+ import type { STATUS_SIZES } from './constants';
4
3
 
5
4
  export type IStatusSize = (typeof STATUS_SIZES)[number];
5
+
6
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
7
+ export interface IStatusColors extends IDefaultExtendableProps {}
8
+
9
+ export type IStatusColor = keyof IStatusColors;
@@ -65,13 +65,9 @@ export const useStyles = createThemedStyles('TextArea', {
65
65
  symbolsCountError: {
66
66
  color: 'red',
67
67
  },
68
- });
69
68
 
70
- export const controlWrapperStyles: IControlWrapperStyles = {
71
- label: {
72
- top: 16,
73
- },
74
- };
69
+ withLabel: {},
70
+ });
75
71
 
76
72
  export type ITextAreaStyles = ITweakStyles<
77
73
  typeof useStyles,
@@ -1,7 +1,16 @@
1
- import { ChangeEvent, FocusEvent, FormEvent, forwardRef, useState } from 'react';
1
+ import {
2
+ ChangeEvent,
3
+ FocusEvent,
4
+ FormEvent,
5
+ forwardRef,
6
+ TextareaHTMLAttributes,
7
+ useState,
8
+ } from 'react';
2
9
  import clsx from 'clsx';
3
10
  import {
4
11
  addDataAttributes,
12
+ getTestId,
13
+ isArrayLikeNotEmpty,
5
14
  isNotEmpty,
6
15
  isReactNodeNotEmpty,
7
16
  isStringNotEmpty,
@@ -10,19 +19,19 @@ import { useTweakStyles } from '../../hooks';
10
19
  import { ICommonProps } from '../../types';
11
20
  import { ControlWrapper, IControlWrapperProps } from '../ControlWrapper';
12
21
  import { IWithMessagesProps, WithMessages } from '../WithMessages';
13
- import { ITextAreaHTMLBaseProps } from './types';
14
- import { controlWrapperStyles, ITextAreaStyles, useStyles } from './TextArea.styles';
22
+ import { ITextAreaStyles, useStyles } from './TextArea.styles';
15
23
 
16
24
  export interface ITextAreaProps
17
25
  extends ICommonProps<ITextAreaStyles>,
18
- Pick<IControlWrapperProps, 'label' | 'isInvalid' | 'isRequired' | 'isDisabled'>,
19
- Pick<IWithMessagesProps, 'infoMessage' | 'errorMessage'>,
20
- Pick<ITextAreaHTMLBaseProps, 'name' | 'maxLength' | 'rows' | 'onPaste' | 'onFocus' | 'onBlur'> {
26
+ Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'onChange'>,
27
+ Pick<
28
+ IControlWrapperProps,
29
+ 'label' | 'isInvalid' | 'isRequired' | 'isDisabled' | 'size' | 'groupPlacement'
30
+ >,
31
+ Pick<IWithMessagesProps, 'infoMessage' | 'errorMessage'> {
21
32
  value?: string;
22
33
  placeholder?: string;
23
34
  /** @default false */
24
- isDisabled?: boolean;
25
- /** @default false */
26
35
  isActive?: boolean;
27
36
  /**
28
37
  * Должна ли высота и ширина textarea подстраиваться под содержимое
@@ -46,17 +55,13 @@ export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
46
55
  (
47
56
  {
48
57
  value = DEFAULT_VALUE,
49
- label,
50
58
  placeholder,
51
- infoMessage,
52
- errorMessage,
53
59
  name,
54
60
  shouldFocusOnMount,
55
61
  hasCounter = true,
56
62
  shouldTrimAfterMaxLength,
57
63
  isAutoSized = true,
58
64
  shouldAlwaysShowPlaceholder,
59
- isDisabled,
60
65
  isActive,
61
66
  maxLength,
62
67
  rows,
@@ -67,7 +72,17 @@ export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
67
72
  onPaste,
68
73
  onFocus,
69
74
  onBlur,
70
- ...controlProps
75
+ // Пропсы WithMessages
76
+ infoMessage,
77
+ errorMessage,
78
+ // Пропсы ControlWrapper
79
+ label,
80
+ isDisabled,
81
+ isInvalid,
82
+ isRequired,
83
+ size,
84
+ groupPlacement,
85
+ ...textAreaProps
71
86
  },
72
87
  ref,
73
88
  ) => {
@@ -80,7 +95,6 @@ export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
80
95
  });
81
96
 
82
97
  const tweakControlWrapperStyles = useTweakStyles({
83
- innerStyles: controlWrapperStyles,
84
98
  tweakStyles,
85
99
  className: 'tweakControlWrapper',
86
100
  currentComponentName: 'TextArea',
@@ -89,8 +103,7 @@ export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
89
103
  const [isFocused, setFocused] = useState(false);
90
104
 
91
105
  const hasFocus = isFocused || isActive;
92
- // в hasValue нельзя использовать isStringNotEmpty из-за того что isStringNotEmpty делает trim
93
- const hasValue = value !== undefined && value !== '';
106
+ const hasValue = isArrayLikeNotEmpty(value);
94
107
  const hasLabel = isReactNodeNotEmpty(label);
95
108
  const hasPlaceholder =
96
109
  (!hasLabel || hasFocus || shouldAlwaysShowPlaceholder) && isStringNotEmpty(placeholder);
@@ -114,6 +127,7 @@ export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
114
127
  errorMessage={errorMessage}
115
128
  infoMessage={infoMessage}
116
129
  tweakStyles={tweakWithMessagesStyles}
130
+ testId={getTestId(testId, 'wrapper')}
117
131
  >
118
132
  <ControlWrapper
119
133
  label={label}
@@ -121,12 +135,17 @@ export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
121
135
  isFocused={hasFocus}
122
136
  isDisabled={isDisabled}
123
137
  hasValue={hasValue}
138
+ isInvalid={isInvalid}
139
+ isRequired={isRequired}
140
+ groupPlacement={groupPlacement}
141
+ size={size}
124
142
  isFullWidth
125
- testId={testId}
126
- {...controlProps}
127
143
  >
128
144
  <div
129
- className={clsx(classes.wrapper, { [classes.autoSized]: isAutoSized })}
145
+ className={clsx(classes.wrapper, {
146
+ [classes.autoSized]: isAutoSized,
147
+ [classes.withLabel]: hasLabel,
148
+ })}
130
149
  {...(isAutoSized && { 'data-value': value })}
131
150
  >
132
151
  <textarea
@@ -142,7 +161,9 @@ export const TextArea = forwardRef<HTMLTextAreaElement, ITextAreaProps>(
142
161
  onFocus={handleFocus}
143
162
  onBlur={handleBlur}
144
163
  onChange={handleChange}
145
- {...addDataAttributes(data, testId, 'control')}
164
+ autoFocus={shouldFocusOnMount}
165
+ {...addDataAttributes(data, testId)}
166
+ {...textAreaProps}
146
167
  />
147
168
  </div>
148
169
  </ControlWrapper>
@@ -1,3 +1,2 @@
1
1
  export * from './TextArea';
2
- export * from './types';
3
2
  export type { ITextAreaStyles } from './TextArea.styles';
@@ -7,6 +7,7 @@ export const useStyles = createThemedStyles('TextButton', {
7
7
  alignItems: 'center',
8
8
  height: 24,
9
9
  padding: 0,
10
+ position: 'relative',
10
11
  background: 'transparent',
11
12
  border: 'none',
12
13
  borderRadius: 0,
@@ -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
  }