@true-engineering/true-react-common-ui-kit 4.0.0-alpha3 → 4.0.0-alpha30

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 (221) hide show
  1. package/README.md +11 -607
  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 +4 -2
  5. package/dist/components/ControlWrapper/ControlWrapper.styles.d.ts +2 -1
  6. package/dist/components/ControlWrapper/helpers.d.ts +4 -0
  7. package/dist/components/ControlWrapper/index.d.ts +2 -0
  8. package/dist/components/ControlWrapper/types.d.ts +12 -0
  9. package/dist/components/DatePicker/DatePicker.d.ts +3 -3
  10. package/dist/components/DatePicker/DatePicker.styles.d.ts +1 -1
  11. package/dist/components/DatePicker/components/PopperContainer/PopperContainer.d.ts +2 -4
  12. package/dist/components/DatePicker/helpers.d.ts +3 -0
  13. package/dist/components/DatePicker/types.d.ts +5 -3
  14. package/dist/components/FiltersPane/FiltersPane.d.ts +7 -2
  15. package/dist/components/FiltersPane/components/Filter/Filter.d.ts +2 -2
  16. package/dist/components/FiltersPane/components/Filter/helpers.d.ts +4 -0
  17. package/dist/components/FiltersPane/components/FilterInterval/FilterInterval.styles.d.ts +1 -1
  18. package/dist/components/FiltersPane/components/FilterSelect/FilterSelect.styles.d.ts +1 -1
  19. package/dist/components/FiltersPane/components/FilterValueView/FilterValueView.d.ts +3 -1
  20. package/dist/components/FiltersPane/components/FilterWithDates/FilterWithDates.styles.d.ts +2 -2
  21. package/dist/components/FiltersPane/components/FilterWrapper/FilterWrapper.d.ts +2 -2
  22. package/dist/components/FiltersPane/components/FiltersPaneSearch/FiltersPaneSearch.styles.d.ts +1 -1
  23. package/dist/components/FiltersPane/types.d.ts +16 -5
  24. package/dist/components/Flag/customFlags/customFlags.d.ts +10 -0
  25. package/dist/components/Flag/customFlags/index.d.ts +1 -0
  26. package/dist/components/FlexibleTable/FlexibleTable.d.ts +4 -2
  27. package/dist/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.d.ts +4 -3
  28. package/dist/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.d.ts +6 -6
  29. package/dist/components/FlexibleTable/constants.d.ts +18 -2
  30. package/dist/components/FlexibleTable/types.d.ts +20 -12
  31. package/dist/components/Icon/icons-list.d.ts +1 -1
  32. package/dist/components/IconButton/IconButton.styles.d.ts +1 -1
  33. package/dist/components/IncrementInput/IncrementInput.styles.d.ts +1 -3
  34. package/dist/components/Input/Input.d.ts +3 -2
  35. package/dist/components/Input/InputBase.d.ts +2 -2
  36. package/dist/components/List/List.d.ts +1 -1
  37. package/dist/components/List/index.d.ts +2 -1
  38. package/dist/components/List/types.d.ts +4 -0
  39. package/dist/components/Modal/Modal.styles.d.ts +1 -1
  40. package/dist/components/Notification/Notification.styles.d.ts +1 -1
  41. package/dist/components/ScrollIntoViewIfNeeded/ScrollIntoViewIfNeeded.d.ts +1 -1
  42. package/dist/components/SearchInput/SearchInput.d.ts +2 -2
  43. package/dist/components/Select/Select.d.ts +5 -3
  44. package/dist/components/Select/Select.styles.d.ts +5 -5
  45. package/dist/components/Select/components/SelectListItem/SelectListItem.d.ts +2 -1
  46. package/dist/components/Select/index.d.ts +1 -1
  47. package/dist/components/Status/Status.styles.d.ts +3 -2
  48. package/dist/components/Status/constants.d.ts +0 -1
  49. package/dist/components/Status/index.d.ts +1 -0
  50. package/dist/components/Status/types.d.ts +5 -2
  51. package/dist/components/TextArea/TextArea.d.ts +4 -5
  52. package/dist/components/TextArea/TextArea.styles.d.ts +5 -4
  53. package/dist/components/TextArea/index.d.ts +1 -1
  54. package/dist/components/TextArea/types.d.ts +4 -2
  55. package/dist/components/TextButton/TextButton.styles.d.ts +1 -1
  56. package/dist/components/Tooltip/Tooltip.d.ts +1 -1
  57. package/dist/components/Tooltip/Tooltip.styles.d.ts +1 -1
  58. package/dist/components/WithMessages/WithMessages.styles.d.ts +1 -1
  59. package/dist/components/WithPopup/WithPopup.d.ts +11 -3
  60. package/dist/hooks/index.d.ts +2 -0
  61. package/dist/hooks/use-intersection-ref.d.ts +8 -0
  62. package/dist/hooks/use-merge.d.ts +1 -0
  63. package/dist/hooks/use-mixed-styles.d.ts +3 -1
  64. package/dist/hooks/use-tweak-styles.d.ts +5 -5
  65. package/dist/style.css +78 -142
  66. package/dist/theme/Provider.d.ts +6 -3
  67. package/dist/theme/create-themed-styles.d.ts +2 -0
  68. package/dist/theme/helpers.d.ts +9 -3
  69. package/dist/theme/index.d.ts +2 -0
  70. package/dist/theme/true-jss/ThemedStylesManager.d.ts +18 -0
  71. package/dist/theme/true-jss/TweakStylesManager.d.ts +34 -0
  72. package/dist/theme/true-jss/index.d.ts +2 -0
  73. package/dist/theme/true-jss/jss-context.d.ts +9 -0
  74. package/dist/theme/types.d.ts +5 -3
  75. package/dist/true-react-common-ui-kit.js +7593 -6483
  76. package/dist/true-react-common-ui-kit.js.map +1 -1
  77. package/dist/true-react-common-ui-kit.umd.cjs +7618 -6509
  78. package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
  79. package/dist/types.d.ts +10 -3
  80. package/package.json +4 -5
  81. package/src/components/ControlWrapper/ControlWrapper.stories.tsx +8 -3
  82. package/src/components/ControlWrapper/ControlWrapper.styles.ts +7 -6
  83. package/src/components/ControlWrapper/ControlWrapper.tsx +31 -20
  84. package/src/components/ControlWrapper/helpers.ts +11 -0
  85. package/src/components/ControlWrapper/index.ts +2 -0
  86. package/src/components/ControlWrapper/types.ts +16 -0
  87. package/src/components/DateInput/DateInput.stories.tsx +0 -1
  88. package/src/components/DatePicker/DatePicker.stories.tsx +24 -11
  89. package/src/components/DatePicker/DatePicker.styles.ts +3 -1
  90. package/src/components/DatePicker/DatePicker.tsx +18 -10
  91. package/src/components/DatePicker/components/PopperContainer/PopperContainer.tsx +4 -4
  92. package/src/components/DatePicker/helpers.ts +13 -1
  93. package/src/components/DatePicker/types.ts +9 -4
  94. package/src/components/FiltersPane/FiltersPane.stories.tsx +4 -2
  95. package/src/components/FiltersPane/FiltersPane.tsx +28 -19
  96. package/src/components/FiltersPane/components/Filter/Filter.tsx +36 -30
  97. package/src/components/FiltersPane/components/Filter/helpers.ts +18 -0
  98. package/src/components/FiltersPane/components/FilterSelect/FilterSelect.tsx +22 -23
  99. package/src/components/FiltersPane/components/FilterValueView/FilterValueView.tsx +27 -22
  100. package/src/components/FiltersPane/components/FilterWithDates/FilterWithDates.styles.ts +2 -1
  101. package/src/components/FiltersPane/components/FilterWithDates/FilterWithDates.tsx +3 -4
  102. package/src/components/FiltersPane/components/FilterWithPeriod/FilterWithPeriod.tsx +4 -3
  103. package/src/components/FiltersPane/components/FilterWrapper/FilterWrapper.tsx +14 -10
  104. package/src/components/FiltersPane/components/FiltersPaneSearch/FiltersPaneSearch.styles.ts +5 -0
  105. package/src/components/FiltersPane/components/FiltersPaneSearch/FiltersPaneSearch.tsx +16 -19
  106. package/src/components/FiltersPane/types.ts +24 -5
  107. package/src/components/Flag/Flag.stories.tsx +2 -1
  108. package/src/components/Flag/Flag.styles.ts +4 -0
  109. package/src/components/Flag/Flag.tsx +23 -9
  110. package/src/components/Flag/customFlags/AB.svg +1 -0
  111. package/src/components/Flag/customFlags/OS.svg +1 -0
  112. package/src/components/Flag/customFlags/augment.d.ts +1 -0
  113. package/src/components/Flag/customFlags/customFlags.ts +13 -0
  114. package/src/components/Flag/customFlags/index.ts +1 -0
  115. package/src/components/FlexibleTable/FlexibleTable.tsx +40 -63
  116. package/src/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.tsx +8 -5
  117. package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.tsx +13 -12
  118. package/src/components/FlexibleTable/constants.ts +6 -3
  119. package/src/components/FlexibleTable/types.ts +20 -16
  120. package/src/components/IncrementInput/IncrementInput.stories.tsx +2 -0
  121. package/src/components/IncrementInput/IncrementInput.styles.ts +31 -39
  122. package/src/components/IncrementInput/IncrementInput.tsx +28 -25
  123. package/src/components/Input/Input.stories.tsx +1 -6
  124. package/src/components/Input/Input.tsx +5 -3
  125. package/src/components/Input/InputBase.tsx +27 -25
  126. package/src/components/List/List.tsx +5 -2
  127. package/src/components/List/index.ts +2 -1
  128. package/src/components/List/types.ts +5 -0
  129. package/src/components/MultiSelectList/MultiSelectList.tsx +15 -11
  130. package/src/components/NumberInput/NumberInput.stories.tsx +5 -1
  131. package/src/components/PhoneInput/PhoneInput.stories.tsx +2 -1
  132. package/src/components/PhoneInput/PhoneInput.tsx +5 -2
  133. package/src/components/SearchInput/SearchInput.tsx +20 -29
  134. package/src/components/Select/CustomSelect.stories.tsx +1 -0
  135. package/src/components/Select/MultiSelect.stories.tsx +5 -0
  136. package/src/components/Select/Select.stories.tsx +6 -0
  137. package/src/components/Select/Select.styles.ts +5 -40
  138. package/src/components/Select/Select.tsx +36 -22
  139. package/src/components/Select/components/SelectList/SelectList.tsx +4 -2
  140. package/src/components/Select/components/SelectListItem/SelectListItem.tsx +5 -2
  141. package/src/components/Select/index.ts +1 -1
  142. package/src/components/Status/Status.stories.tsx +54 -1
  143. package/src/components/Status/Status.styles.ts +2 -37
  144. package/src/components/Status/constants.ts +0 -10
  145. package/src/components/Status/index.ts +1 -1
  146. package/src/components/Status/types.ts +7 -3
  147. package/src/components/TextArea/TextArea.stories.tsx +15 -1
  148. package/src/components/TextArea/TextArea.styles.ts +15 -8
  149. package/src/components/TextArea/TextArea.tsx +96 -62
  150. package/src/components/TextArea/index.ts +1 -1
  151. package/src/components/TextArea/types.ts +5 -5
  152. package/src/components/TextButton/TextButton.styles.ts +1 -0
  153. package/src/components/Tooltip/Tooltip.styles.ts +2 -0
  154. package/src/components/Tooltip/Tooltip.tsx +1 -1
  155. package/src/components/WithMessages/WithMessages.stories.tsx +1 -1
  156. package/src/components/WithPopup/WithPopup.tsx +36 -15
  157. package/src/constants/phone-info.ts +20 -33
  158. package/src/helpers/phone.ts +19 -15
  159. package/src/hooks/index.ts +2 -0
  160. package/src/hooks/use-intersection-ref.ts +30 -0
  161. package/src/hooks/use-merge.ts +8 -0
  162. package/src/hooks/use-mixed-styles.ts +9 -11
  163. package/src/hooks/use-tweak-styles.ts +49 -27
  164. package/src/theme/Provider.tsx +10 -5
  165. package/src/theme/create-themed-styles.ts +78 -0
  166. package/src/theme/helpers.ts +39 -39
  167. package/src/theme/index.ts +2 -0
  168. package/src/theme/true-jss/ThemedStylesManager.ts +92 -0
  169. package/src/theme/true-jss/TweakStylesManager.ts +157 -0
  170. package/src/theme/true-jss/index.ts +2 -0
  171. package/src/theme/true-jss/jss-context.tsx +34 -0
  172. package/src/theme/types.ts +5 -3
  173. package/src/types.ts +17 -4
  174. package/dist/components/AccountInfo/AccountInfo.stories.d.ts +0 -6
  175. package/dist/components/AddButton/AddButton.stories.d.ts +0 -6
  176. package/dist/components/Button/Button.stories.d.ts +0 -6
  177. package/dist/components/Checkbox/Checkbox.stories.d.ts +0 -8
  178. package/dist/components/CloseButton/CloseButton.stories.d.ts +0 -5
  179. package/dist/components/Colors/Colors.stories.d.ts +0 -5
  180. package/dist/components/ControlWrapper/ControlWrapper.stories.d.ts +0 -6
  181. package/dist/components/DateInput/DateInput.stories.d.ts +0 -7
  182. package/dist/components/DatePicker/DatePicker.stories.d.ts +0 -7
  183. package/dist/components/Description/Description.stories.d.ts +0 -16
  184. package/dist/components/FileInput/FileInput.stories.d.ts +0 -7
  185. package/dist/components/FileItem/FileItem.stories.d.ts +0 -8
  186. package/dist/components/FiltersPane/FiltersPane.stories.d.ts +0 -31
  187. package/dist/components/Flag/Flag.stories.d.ts +0 -12
  188. package/dist/components/FlexibleTable/FlexibleTable.stories.d.ts +0 -19
  189. package/dist/components/Icon/Icon.stories.d.ts +0 -6
  190. package/dist/components/IconButton/IconButton.stories.d.ts +0 -6
  191. package/dist/components/IncrementInput/IncrementInput.stories.d.ts +0 -6
  192. package/dist/components/Input/Input.stories.d.ts +0 -25
  193. package/dist/components/List/List.stories.d.ts +0 -5
  194. package/dist/components/Modal/Modal.stories.d.ts +0 -29
  195. package/dist/components/MoreMenu/MoreMenu.stories.d.ts +0 -6
  196. package/dist/components/MultiSelect/MultiSelect.stories.d.ts +0 -13
  197. package/dist/components/NewMoreMenu/NewMoreMenu.stories.d.ts +0 -12
  198. package/dist/components/Notification/Notification.stories.d.ts +0 -8
  199. package/dist/components/NumberInput/NumberInput.stories.d.ts +0 -7
  200. package/dist/components/PhoneInput/PhoneInput.stories.d.ts +0 -28
  201. package/dist/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.stories.d.ts +0 -5
  202. package/dist/components/RadioButton/RadioButton.stories.d.ts +0 -7
  203. package/dist/components/SearchInput/SearchInput.stories.d.ts +0 -6
  204. package/dist/components/Select/CustomSelect.stories.d.ts +0 -11
  205. package/dist/components/Select/MultiSelect.stories.d.ts +0 -15
  206. package/dist/components/Select/Select.stories.d.ts +0 -15
  207. package/dist/components/Selector/Selector.stories.d.ts +0 -7
  208. package/dist/components/Skeleton/Skeleton.stories.d.ts +0 -6
  209. package/dist/components/SmartInput/SmartInput.stories.d.ts +0 -18
  210. package/dist/components/Status/Status.stories.d.ts +0 -6
  211. package/dist/components/Switch/Switch.stories.d.ts +0 -16
  212. package/dist/components/TextArea/TextArea.stories.d.ts +0 -17
  213. package/dist/components/TextButton/TextButton.stories.d.ts +0 -6
  214. package/dist/components/TextWithInfo/TextWithInfo.stories.d.ts +0 -12
  215. package/dist/components/TextWithTooltip/TextWithTooltip.stories.d.ts +0 -24
  216. package/dist/components/ThemedPreloader/ThemedPreloader.stories.d.ts +0 -17
  217. package/dist/components/Toaster/Toaster.stories.d.ts +0 -5
  218. package/dist/components/Tooltip/Tooltip.stories.d.ts +0 -5
  219. package/dist/components/WithMessages/WithMessages.stories.d.ts +0 -7
  220. package/dist/components/WithPopup/WithPopup.stories.d.ts +0 -16
  221. package/dist/components/WithTooltip/WithTooltip.stories.d.ts +0 -6
@@ -1,41 +1,44 @@
1
1
  import { animations, colors, createThemedStyles, dimensions, ITweakStyles } from '../../theme';
2
2
  import { IInputStyles } from '../Input';
3
3
 
4
- export const BUTTONS_WIDTH = 36;
5
- export const BUTTONS_GAP = 2;
6
-
7
- export const useStyles = createThemedStyles('IncrementInput', {
8
- root: {
9
- display: 'flex',
10
- alignItems: 'center',
11
- position: 'relative',
4
+ export const inputStyles: IInputStyles = {
5
+ tweakControlWrapper: {
6
+ controlWrapper: {
7
+ '--increment-buttons-width': '36px',
8
+ '--increment-buttons-gap': '1px',
9
+ '--increment-buttons-margin': '1px',
10
+ '--increment-button-icon-size': '16px',
11
+ },
12
12
  },
13
+ };
13
14
 
15
+ export const useStyles = createThemedStyles('IncrementInput', {
14
16
  buttons: {
15
17
  display: 'flex',
16
18
  flexDirection: 'column',
17
- width: BUTTONS_WIDTH,
18
- position: 'absolute',
19
- right: BUTTONS_GAP,
20
- top: BUTTONS_GAP,
21
- bottom: BUTTONS_GAP,
19
+ height: 'calc(100% - var(--increment-buttons-margin) * 2)',
20
+ margin: 'var(--increment-buttons-margin)',
21
+ gap: 'var(--increment-buttons-gap)',
22
+ flexShrink: 0,
23
+ order: 1000, // сдвигаем кнопки на самый конец
24
+
22
25
  zIndex: dimensions.Z_INDEX.CONTROL_FOCUS + 1,
23
26
  },
24
27
 
25
28
  button: {
26
- width: '100%',
27
- height: (dimensions.CONTROL.HEIGHT - 5) / 2,
29
+ display: 'flex',
30
+ alignItems: 'center',
31
+ justifyContent: 'center',
32
+ width: 'var(--increment-buttons-width)',
33
+ flexGrow: 1,
34
+
35
+ cursor: 'pointer',
28
36
  border: 'none',
29
37
  outline: 'none',
38
+ color: colors.FONT_MEDIUM,
30
39
  backgroundColor: colors.GREY_BACKGROUND,
31
40
  transition: animations.defaultTransition,
32
- transitionProperty: 'background-color',
33
- color: colors.FONT_MEDIUM,
34
- cursor: 'pointer',
35
- display: 'flex',
36
- alignItems: 'center',
37
- justifyContent: 'center',
38
- padding: [0, 10],
41
+ transitionProperty: 'background-color, color',
39
42
 
40
43
  '&:hover, &:focus': {
41
44
  backgroundColor: colors.GREY_HOVER,
@@ -44,16 +47,12 @@ export const useStyles = createThemedStyles('IncrementInput', {
44
47
  '&:active': {
45
48
  backgroundColor: colors.GREY_ACTIVE,
46
49
  },
47
-
48
- '&:first-child': {
49
- marginBottom: 1,
50
- },
51
50
  },
52
51
 
53
52
  disabledButton: {
54
- backgroundColor: colors.CLASSIC_WHITE,
55
- color: colors.FONT_DISABLED,
56
53
  cursor: 'default',
54
+ color: colors.FONT_DISABLED,
55
+ backgroundColor: colors.CLASSIC_WHITE,
57
56
 
58
57
  '&:hover': {
59
58
  backgroundColor: colors.CLASSIC_WHITE,
@@ -61,18 +60,11 @@ export const useStyles = createThemedStyles('IncrementInput', {
61
60
  },
62
61
 
63
62
  errorButton: {},
64
- });
65
-
66
- export const inputStyles: IInputStyles = {
67
- input: {
68
- paddingRight: BUTTONS_WIDTH + BUTTONS_GAP,
69
- },
70
63
 
71
- tweakControlWrapper: {
72
- controls: {
73
- paddingRight: BUTTONS_WIDTH + BUTTONS_GAP,
74
- },
64
+ icon: {
65
+ width: 'var(--increment-button-icon-size)',
66
+ height: 'var(--increment-button-icon-size)',
75
67
  },
76
- };
68
+ });
77
69
 
78
70
  export type IIncrementInputStyles = ITweakStyles<typeof useStyles, { tweakInput: IInputStyles }>;
@@ -1,7 +1,7 @@
1
1
  import { FC, useEffect } from 'react';
2
2
  import clsx from 'clsx';
3
- import { addDataTestId, isNumberInteger } from '@true-engineering/true-react-platform-helpers';
4
- import { addDataAttributes, getNumberInRange, getNumberLength } from '../../helpers';
3
+ import { isNotEmpty, isNumberInteger } from '@true-engineering/true-react-platform-helpers';
4
+ import { getNumberInRange, getNumberLength } from '../../helpers';
5
5
  import { useTweakStyles } from '../../hooks';
6
6
  import { ICommonProps } from '../../types';
7
7
  import { Icon } from '../Icon';
@@ -22,8 +22,6 @@ export const IncrementInput: FC<IIncrementInputProps> = ({
22
22
  max,
23
23
  step = 1,
24
24
  intPartPrecision,
25
- data,
26
- testId,
27
25
  tweakStyles,
28
26
  isDisabled,
29
27
  isReadonly,
@@ -39,14 +37,15 @@ export const IncrementInput: FC<IIncrementInputProps> = ({
39
37
 
40
38
  const classes = useStyles({ theme: tweakStyles });
41
39
 
40
+ const isEditDisabled = isDisabled || isReadonly;
41
+
42
42
  const isIncreaseDisabled =
43
- isDisabled ||
44
- isReadonly ||
45
- (intPartPrecision !== undefined && getNumberLength((value ?? 0) + step) > intPartPrecision) ||
46
- (max !== undefined && value !== undefined && value >= max);
43
+ isEditDisabled ||
44
+ (isNotEmpty(intPartPrecision) && getNumberLength((value ?? 0) + step) > intPartPrecision) ||
45
+ (isNotEmpty(max) && isNotEmpty(value) && value >= max);
47
46
 
48
47
  const isDecreaseDisabled =
49
- isDisabled || isReadonly || (min !== undefined && value !== undefined ? value <= min : false);
48
+ isEditDisabled || (isNotEmpty(min) && isNotEmpty(value) && value <= min);
50
49
 
51
50
  const increment = (): void => {
52
51
  onChange(getNumberInRange((value ?? 0) + step, min, max));
@@ -63,19 +62,18 @@ export const IncrementInput: FC<IIncrementInputProps> = ({
63
62
  }, [step]);
64
63
 
65
64
  return (
66
- <div className={classes.root} {...addDataTestId(testId)} {...addDataAttributes(data)}>
67
- <NumberInput
68
- {...props}
69
- isInvalid={isInvalid}
70
- isDisabled={isDisabled}
71
- isReadonly={isReadonly}
72
- min={min}
73
- max={max}
74
- intPartPrecision={intPartPrecision}
75
- onChange={onChange}
76
- value={value}
77
- tweakStyles={tweakInputStyles}
78
- />
65
+ <NumberInput
66
+ {...props}
67
+ isInvalid={isInvalid}
68
+ isDisabled={isDisabled}
69
+ isReadonly={isReadonly}
70
+ min={min}
71
+ max={max}
72
+ intPartPrecision={intPartPrecision}
73
+ onChange={onChange}
74
+ value={value}
75
+ tweakStyles={tweakInputStyles}
76
+ >
79
77
  <div className={classes.buttons}>
80
78
  <button
81
79
  className={clsx(classes.button, {
@@ -86,8 +84,11 @@ export const IncrementInput: FC<IIncrementInputProps> = ({
86
84
  disabled={isIncreaseDisabled}
87
85
  onClick={increment}
88
86
  >
89
- <Icon type="plus" />
87
+ <div className={classes.icon}>
88
+ <Icon type="plus" />
89
+ </div>
90
90
  </button>
91
+
91
92
  <button
92
93
  className={clsx(classes.button, {
93
94
  [classes.disabledButton]: isDecreaseDisabled,
@@ -97,9 +98,11 @@ export const IncrementInput: FC<IIncrementInputProps> = ({
97
98
  disabled={isDecreaseDisabled}
98
99
  onClick={decrement}
99
100
  >
100
- <Icon type="minus" />
101
+ <div className={classes.icon}>
102
+ <Icon type="minus" />
103
+ </div>
101
104
  </button>
102
105
  </div>
103
- </div>
106
+ </NumberInput>
104
107
  );
105
108
  };
@@ -35,12 +35,7 @@ const Template: ComponentStory<typeof Input> = (args) => {
35
35
 
36
36
  return (
37
37
  <div style={{ width: 300 }}>
38
- <Input
39
- {...args}
40
- value={value}
41
- onChange={setValue}
42
- onIconClick={() => console.log('icon click')}
43
- />
38
+ <Input {...args} value={value} onChange={setValue} />
44
39
  </div>
45
40
  );
46
41
  };
@@ -1,10 +1,12 @@
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';
5
6
 
6
- export type IInputProps = IInputBaseProps &
7
- Pick<IWithMessagesProps, 'infoMessage' | 'errorMessage'>;
7
+ export interface IInputProps
8
+ extends IInputBaseProps,
9
+ Pick<IWithMessagesProps, 'infoMessage' | 'errorMessage'> {}
8
10
 
9
11
  export const Input = forwardRef<HTMLInputElement, IInputProps>(
10
12
  ({ infoMessage, errorMessage, isInvalid, testId, tweakStyles, ...inputProps }, ref) => {
@@ -17,7 +19,7 @@ export const Input = forwardRef<HTMLInputElement, IInputProps>(
17
19
  <WithMessages
18
20
  errorMessage={errorMessage}
19
21
  infoMessage={infoMessage}
20
- testId={testId}
22
+ testId={getTestId(testId, 'wrapper')}
21
23
  tweakStyles={tweakWithMessagesStyles}
22
24
  >
23
25
  <InputBase
@@ -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,30 +28,17 @@ 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'
34
35
  | 'icon'
36
+ | 'size'
35
37
  | 'groupPlacement'
36
38
  | 'isInvalid'
37
39
  | 'isRequired'
38
40
  | 'isLoading'
39
41
  | 'isDisabled'
40
- | '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'
55
42
  >,
56
43
  Pick<
57
44
  Partial<ReactInputMaskBaseProps>,
@@ -71,7 +58,7 @@ export interface IInputBaseProps
71
58
  isAutoSized?: boolean;
72
59
  /** @default false */
73
60
  shouldAlwaysShowPlaceholder?: boolean;
74
- onChange(value: string, event: IChangeInputEvent): void;
61
+ onChange: (value: string, event: IChangeInputEvent) => void;
75
62
  }
76
63
 
77
64
  export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
@@ -96,6 +83,7 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
96
83
  units,
97
84
  testId,
98
85
  tabIndex,
86
+ shouldAlwaysShowPlaceholder,
99
87
  onChange,
100
88
  onPaste,
101
89
  onFocus,
@@ -105,9 +93,16 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
105
93
  mask,
106
94
  maskPlaceholder,
107
95
  alwaysShowMask,
108
- shouldAlwaysShowPlaceholder,
109
96
  beforeMaskedStateChange,
110
- ...controlProps
97
+ // Пропсы ControlWrapper
98
+ data,
99
+ groupPlacement,
100
+ icon,
101
+ isLoading,
102
+ isRequired,
103
+ size,
104
+ children,
105
+ ...inputProps
111
106
  },
112
107
  ref,
113
108
  ) => {
@@ -123,7 +118,7 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
123
118
  const [unitsWidth, setUnitsWidth] = useState<number>();
124
119
 
125
120
  const inputRef = useRef<HTMLInputElement>(null);
126
- const mergedRef = mergeRefs([ref, inputRef]);
121
+ const mergedRef = useMergedRefs([ref, inputRef]);
127
122
 
128
123
  // Try to guess input-mode if possible
129
124
  const inputMode: IInputBaseProps['inputMode'] =
@@ -131,7 +126,7 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
131
126
  (['email', 'tel', 'url'].includes(type) ? (type as 'email' | 'tel' | 'url') : undefined);
132
127
 
133
128
  const hasFocus = isFocused || isActive;
134
- const hasValue = isNotEmpty(value) && value !== '';
129
+ const hasValue = isArrayLikeNotEmpty(value);
135
130
  const hasUnits = isReactNodeNotEmpty(units);
136
131
  const hasPlaceholder =
137
132
  (!isReactNodeNotEmpty(label) || hasFocus || shouldAlwaysShowPlaceholder) &&
@@ -194,7 +189,8 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
194
189
  onFocus: handleFocus,
195
190
  onBlur: handleBlur,
196
191
  onChange: handleChange,
197
- ...addDataTestId(testId, 'input'),
192
+ ...addDataTestId(testId),
193
+ ...inputProps,
198
194
  };
199
195
 
200
196
  useEffect(() => {
@@ -234,17 +230,23 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
234
230
  isDisabled={isDisabled}
235
231
  isFocused={hasFocus}
236
232
  isInvalid={isInvalid}
237
- hasValue={hasValue || hasPlaceholder}
233
+ hasValue={hasValue}
238
234
  isFullWidth={!isAutoSized}
239
235
  tweakStyles={tweakControlWrapperStyles}
240
236
  onClear={isClearable && hasValue ? handleInputClear : undefined}
241
- {...controlProps}
237
+ data={data}
238
+ groupPlacement={groupPlacement}
239
+ icon={icon}
240
+ isLoading={isLoading}
241
+ isRequired={isRequired}
242
+ size={size}
242
243
  >
243
244
  {hasUnits || isAutoSized ? (
244
245
  <div className={classes.autoSizeWrapper}>{inputContent}</div>
245
246
  ) : (
246
247
  inputContent
247
248
  )}
249
+ {children}
248
250
  </ControlWrapper>
249
251
  );
250
252
  },
@@ -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
+ }
@@ -1,8 +1,13 @@
1
1
  import { useEffect, useState, useMemo, useRef, useCallback, ReactNode } from 'react';
2
2
  import clsx from 'clsx';
3
3
  import { debounce } from 'ts-debounce';
4
- import { isArrayNotEmpty, isNotEmpty } from '@true-engineering/true-react-platform-helpers';
5
- import { addDataAttributes } from '../../helpers';
4
+ import {
5
+ addDataAttributes,
6
+ addDataTestId,
7
+ getTestId,
8
+ isArrayNotEmpty,
9
+ isNotEmpty,
10
+ } from '@true-engineering/true-react-platform-helpers';
6
11
  import { useIsMounted, useTweakStyles } from '../../hooks';
7
12
  import { ICommonProps } from '../../types';
8
13
  import { Button } from '../Button';
@@ -330,7 +335,7 @@ export function MultiSelectList<Value extends IMultiSelectListValues<Option>, Op
330
335
  !isLoading && (isArrayNotEmpty(allOptions) || isArrayNotEmpty(chosenValues));
331
336
 
332
337
  return (
333
- <div className={classes.root} {...addDataAttributes(data)}>
338
+ <div className={classes.root} {...addDataAttributes(data, testId)}>
334
339
  {isSearchEnabled && (
335
340
  <div className={classes.dropdownInput}>
336
341
  <SearchInput
@@ -339,16 +344,13 @@ export function MultiSelectList<Value extends IMultiSelectListValues<Option>, Op
339
344
  onChange={handleOnChange}
340
345
  tweakStyles={tweakSearchInputStyles}
341
346
  maxLength={searchMaxLength}
342
- testId={testId !== undefined ? `${testId}-search` : undefined}
347
+ testId={getTestId(testId, 'search')}
343
348
  shouldFocusOnMount
344
349
  />
345
350
  </div>
346
351
  )}
347
352
  {shouldShowOptionsList && (
348
- <div
349
- className={classes.list}
350
- data-testid={testId !== undefined ? `${testId}-list` : undefined}
351
- >
353
+ <div className={classes.list} {...addDataTestId(testId, 'list')}>
352
354
  {/* Выбранные */}
353
355
  {hasSelectedOptionsGroup && (
354
356
  <>
@@ -379,8 +381,9 @@ export function MultiSelectList<Value extends IMultiSelectListValues<Option>, Op
379
381
  value={val}
380
382
  tweakStyles={tweakCheckboxStyles}
381
383
  labelPosition={checkboxPosition === 'left' ? 'right' : 'left'}
384
+ data={{ id }}
382
385
  >
383
- <div className={classes.option} data-option={id}>
386
+ <div className={classes.option} {...addDataAttributes({ option: id })}>
384
387
  {view}
385
388
  </div>
386
389
  </Checkbox>
@@ -417,8 +420,9 @@ export function MultiSelectList<Value extends IMultiSelectListValues<Option>, Op
417
420
  value={val}
418
421
  tweakStyles={tweakCheckboxStyles}
419
422
  labelPosition={checkboxPosition === 'left' ? 'right' : 'left'}
423
+ data={{ id }}
420
424
  >
421
- <div className={classes.option} data-option={id}>
425
+ <div className={classes.option} {...addDataAttributes({ option: id })}>
422
426
  {view}
423
427
  </div>
424
428
  </Checkbox>
@@ -449,7 +453,7 @@ export function MultiSelectList<Value extends IMultiSelectListValues<Option>, Op
449
453
  onClick={handleClear}
450
454
  size="s"
451
455
  view="text"
452
- testId={testId !== undefined ? `${testId}-clear-button` : undefined}
456
+ testId={getTestId(testId, 'clear-button')}
453
457
  tweakStyles={tweakClearButtonStyles}
454
458
  >
455
459
  {translates.clear}
@@ -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
+ );
@@ -247,4 +247,5 @@ CustomSelect.args = {
247
247
  shouldScrollToList: true,
248
248
  canBeFlipped: false,
249
249
  scrollParent: 'document',
250
+ size: undefined,
250
251
  };
@@ -1,6 +1,7 @@
1
1
  import { ReactNode, useEffect, useState } from 'react';
2
2
  import { isStringNotEmpty } from '@true-engineering/true-react-platform-helpers';
3
3
  import { ComponentMeta, ComponentStory } from '@storybook/react';
4
+ import { iconsList } from '../Icon';
4
5
  import { IMultipleSelectProps, Select } from './Select';
5
6
 
6
7
  interface ObjectValue {
@@ -54,6 +55,8 @@ const objectOptions: ObjectValue[] = [
54
55
  { name: 'Artem', age: 23 },
55
56
  ];
56
57
 
58
+ const icons = [undefined, ...Object.keys(iconsList)];
59
+
57
60
  // Максимум не включается, минимум включается
58
61
  const getRandomInt = (min: number, max: number) =>
59
62
  Math.floor(Math.random() * (Math.floor(max) - Math.ceil(min))) + Math.ceil(min);
@@ -195,6 +198,7 @@ export default {
195
198
  control: 'inline-radio',
196
199
  options: ['strings', 'objects'],
197
200
  },
201
+ icon: { control: 'select', options: icons },
198
202
  },
199
203
  } as ComponentMeta<typeof SelectWithCustomProps>;
200
204
 
@@ -229,4 +233,5 @@ MultiSelect.args = {
229
233
  shouldScrollToList: true,
230
234
  canBeFlipped: false,
231
235
  scrollParent: 'document',
236
+ size: undefined,
232
237
  };