@true-engineering/true-react-common-ui-kit 4.0.0-alpha44 → 4.0.0-alpha46

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 (210) hide show
  1. package/dist/components/AccountInfo/AccountInfo.styles.d.ts +1 -1
  2. package/dist/components/AddButton/AddButton.styles.d.ts +1 -1
  3. package/dist/components/Button/Button.d.ts +1 -1
  4. package/dist/components/Button/Button.styles.d.ts +1 -1
  5. package/dist/components/Checkbox/Checkbox.styles.d.ts +1 -1
  6. package/dist/components/CloseButton/CloseButton.styles.d.ts +1 -1
  7. package/dist/components/ControlWrapper/ControlWrapper.d.ts +2 -2
  8. package/dist/components/ControlWrapper/ControlWrapper.styles.d.ts +1 -1
  9. package/dist/components/ControlWrapper/constants.d.ts +1 -0
  10. package/dist/components/ControlWrapper/index.d.ts +1 -0
  11. package/dist/components/ControlWrapper/types.d.ts +3 -1
  12. package/dist/components/CssBaseline/CssBaseline.styles.d.ts +1 -1
  13. package/dist/components/DateInput/DateInput.d.ts +1 -2
  14. package/dist/components/DateInput/DateInput.styles.d.ts +1 -1
  15. package/dist/components/DateInput/constants.d.ts +1 -1
  16. package/dist/components/DatePicker/DatePicker.d.ts +2 -3
  17. package/dist/components/DatePicker/DatePicker.styles.d.ts +1 -1
  18. package/dist/components/DatePicker/components/DatePickerBase/DatePickerBase.d.ts +1 -1
  19. package/dist/components/DatePicker/components/DatePickerHeader/DatePickerHeader.styles.d.ts +1 -1
  20. package/dist/components/DatePicker/constants.d.ts +1 -1
  21. package/dist/components/DatePicker/types.d.ts +2 -2
  22. package/dist/components/Description/Description.styles.d.ts +1 -1
  23. package/dist/components/FileInput/FileInput.d.ts +1 -1
  24. package/dist/components/FileInput/FileInput.styles.d.ts +1 -1
  25. package/dist/components/FileItem/FileItem.styles.d.ts +1 -1
  26. package/dist/components/FiltersPane/FiltersPane.d.ts +0 -1
  27. package/dist/components/FiltersPane/FiltersPane.styles.d.ts +2 -2
  28. package/dist/components/FiltersPane/components/Filter/Filter.d.ts +1 -2
  29. package/dist/components/FiltersPane/components/FilterInterval/FilterInterval.styles.d.ts +3 -6
  30. package/dist/components/FiltersPane/components/FilterMultiSelect/FilterMultiSelect.d.ts +0 -1
  31. package/dist/components/FiltersPane/components/FilterSelect/FilterSelect.styles.d.ts +3 -6
  32. package/dist/components/FiltersPane/components/FilterValueView/FilterValueView.d.ts +1 -2
  33. package/dist/components/FiltersPane/components/FilterValueView/FilterValueView.styles.d.ts +1 -1
  34. package/dist/components/FiltersPane/components/FilterWithDates/FilterWithDates.styles.d.ts +5 -11
  35. package/dist/components/FiltersPane/components/FilterWithPeriod/FilterWithPeriod.styles.d.ts +1 -1
  36. package/dist/components/FiltersPane/components/FilterWrapper/FilterWrapper.d.ts +0 -1
  37. package/dist/components/FiltersPane/components/FilterWrapper/FilterWrapper.styles.d.ts +2 -2
  38. package/dist/components/FiltersPane/components/FiltersPaneSearch/FiltersPaneSearch.styles.d.ts +1 -1
  39. package/dist/components/FiltersPane/constants.d.ts +1 -1
  40. package/dist/components/FiltersPane/helpers.d.ts +1 -1
  41. package/dist/components/FiltersPane/types.d.ts +1 -1
  42. package/dist/components/Flag/Flag.styles.d.ts +1 -1
  43. package/dist/components/Flag/customFlags/customFlags.d.ts +2 -2
  44. package/dist/components/FlexibleTable/FlexibleTable.styles.d.ts +2 -2
  45. package/dist/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.styles.d.ts +1 -1
  46. package/dist/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.styles.d.ts +1 -1
  47. package/dist/components/FlexibleTable/helpers.d.ts +2 -2
  48. package/dist/components/FloatDocActions/FloatDocActions.styles.d.ts +1 -1
  49. package/dist/components/FloatDocActions/components/DocActions/DocActions.styles.d.ts +1 -1
  50. package/dist/components/Icon/Icon.styles.d.ts +1 -1
  51. package/dist/components/Icon/icons/index.d.ts +29 -29
  52. package/dist/components/IconButton/IconButton.d.ts +1 -2
  53. package/dist/components/IconButton/IconButton.styles.d.ts +1 -1
  54. package/dist/components/IncrementInput/IncrementInput.styles.d.ts +1 -1
  55. package/dist/components/Input/Input.d.ts +1 -2
  56. package/dist/components/Input/Input.styles.d.ts +1 -1
  57. package/dist/components/Input/InputBase.d.ts +1 -1
  58. package/dist/components/List/List.styles.d.ts +1 -1
  59. package/dist/components/List/components/ListItem/ListItem.styles.d.ts +1 -1
  60. package/dist/components/Modal/Modal.styles.d.ts +1 -1
  61. package/dist/components/MoreMenu/MoreMenu.styles.d.ts +1 -1
  62. package/dist/components/MultiSelect/MultiSelect.d.ts +0 -1
  63. package/dist/components/MultiSelect/MultiSelect.styles.d.ts +1 -1
  64. package/dist/components/MultiSelect/components/MultiSelectInput/MultiSelectInput.styles.d.ts +1 -1
  65. package/dist/components/MultiSelectList/MultiSelectList.styles.d.ts +1 -1
  66. package/dist/components/MultiSelectList/constants.d.ts +1 -1
  67. package/dist/components/MultiSelectList/helpers.d.ts +1 -1
  68. package/dist/components/NewMoreMenu/NewMoreMenu.styles.d.ts +1 -1
  69. package/dist/components/Notification/Notification.styles.d.ts +1 -1
  70. package/dist/components/NumberInput/NumberInput.d.ts +1 -2
  71. package/dist/components/NumberInput/helpers.d.ts +2 -2
  72. package/dist/components/PhoneInput/PhoneInput.styles.d.ts +1 -1
  73. package/dist/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.styles.d.ts +1 -1
  74. package/dist/components/RadioButton/RadioButton.styles.d.ts +1 -1
  75. package/dist/components/ScrollIntoViewIfNeeded/ScrollIntoViewIfNeeded.d.ts +3 -373
  76. package/dist/components/ScrollIntoViewIfNeeded/constants.d.ts +1 -1
  77. package/dist/components/SearchInput/SearchInput.d.ts +1 -2
  78. package/dist/components/Select/Select.d.ts +1 -1
  79. package/dist/components/Select/Select.styles.d.ts +12 -22
  80. package/dist/components/Select/components/SelectList/SelectList.d.ts +5 -5
  81. package/dist/components/Select/components/SelectList/SelectList.styles.d.ts +1 -1
  82. package/dist/components/Select/components/SelectListItem/SelectListItem.d.ts +2 -2
  83. package/dist/components/Select/helpers.d.ts +1 -1
  84. package/dist/components/Selector/Selector.d.ts +0 -1
  85. package/dist/components/Selector/Selector.styles.d.ts +1 -1
  86. package/dist/components/Skeleton/Skeleton.styles.d.ts +1 -1
  87. package/dist/components/SmartInput/SmartInput.d.ts +1 -1
  88. package/dist/components/Status/Status.styles.d.ts +1 -1
  89. package/dist/components/Status/types.d.ts +1 -1
  90. package/dist/components/Switch/Switch.styles.d.ts +1 -1
  91. package/dist/components/TextArea/TextArea.d.ts +1 -1
  92. package/dist/components/TextArea/TextArea.styles.d.ts +1 -1
  93. package/dist/components/TextButton/TextButton.d.ts +1 -1
  94. package/dist/components/TextButton/TextButton.styles.d.ts +1 -1
  95. package/dist/components/TextWithInfo/TextWithInfo.styles.d.ts +1 -1
  96. package/dist/components/TextWithTooltip/TextWithTooltip.styles.d.ts +1 -1
  97. package/dist/components/ThemedPreloader/ThemedPreloader.styles.d.ts +1 -1
  98. package/dist/components/ThemedPreloader/components/DotsPreloader/DotsPreloader.styles.d.ts +1 -1
  99. package/dist/components/ThemedPreloader/components/SvgPreloader/SvgPreloader.styles.d.ts +1 -1
  100. package/dist/components/Toaster/Toaster.styles.d.ts +1 -1
  101. package/dist/components/Tooltip/Tooltip.styles.d.ts +1 -1
  102. package/dist/components/WithMessages/WithMessages.d.ts +1 -1
  103. package/dist/components/WithMessages/WithMessages.styles.d.ts +1 -1
  104. package/dist/components/WithPopup/WithPopup.styles.d.ts +1 -1
  105. package/dist/components/WithPopup/types.d.ts +4 -4
  106. package/dist/components/index.d.ts +0 -1
  107. package/dist/constants/phone-info.d.ts +1 -1
  108. package/dist/helpers/misc.d.ts +2 -1
  109. package/dist/helpers/phone.d.ts +1 -1
  110. package/dist/hooks/use-dropdown.d.ts +3 -3
  111. package/dist/hooks/use-merge.d.ts +1 -1
  112. package/dist/hooks/use-mixed-styles.d.ts +3 -3
  113. package/dist/hooks/use-tweak-styles.d.ts +5 -5
  114. package/dist/theme/Provider.d.ts +2 -2
  115. package/dist/theme/common.d.ts +1 -1
  116. package/dist/theme/helpers.d.ts +3 -3
  117. package/dist/theme/true-jss/ThemedStylesManager.d.ts +1 -1
  118. package/dist/theme/true-jss/TweakStylesManager.d.ts +1 -1
  119. package/dist/theme/types.d.ts +1 -1
  120. package/dist/true-react-common-ui-kit.js +881 -733
  121. package/dist/true-react-common-ui-kit.js.map +1 -1
  122. package/dist/true-react-common-ui-kit.umd.cjs +881 -733
  123. package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
  124. package/dist/types.d.ts +4 -4
  125. package/package.json +14 -16
  126. package/src/components/AccountInfo/AccountInfo.stories.tsx +19 -27
  127. package/src/components/AddButton/AddButton.stories.tsx +14 -17
  128. package/src/components/Button/Button.stories.tsx +7 -24
  129. package/src/components/Checkbox/Checkbox.stories.tsx +24 -26
  130. package/src/components/Checkbox/types.ts +1 -1
  131. package/src/components/CloseButton/CloseButton.stories.tsx +5 -6
  132. package/src/components/Colors/Colors.stories.tsx +63 -3
  133. package/src/components/ControlWrapper/ControlWrapper.stories.tsx +43 -38
  134. package/src/components/ControlWrapper/ControlWrapper.tsx +2 -11
  135. package/src/components/ControlWrapper/constants.ts +11 -0
  136. package/src/components/ControlWrapper/index.ts +1 -0
  137. package/src/components/ControlWrapper/types.ts +4 -1
  138. package/src/components/DateInput/DateInput.stories.tsx +13 -30
  139. package/src/components/DatePicker/DatePicker.stories.tsx +15 -52
  140. package/src/components/Description/Description.stories.tsx +11 -16
  141. package/src/components/FileInput/FileInput.stories.tsx +59 -63
  142. package/src/components/FileItem/FileItem.stories.tsx +46 -45
  143. package/src/components/FiltersPane/FiltersPane.stories.tsx +27 -30
  144. package/src/components/FiltersPane/components/Filter/Filter.tsx +1 -1
  145. package/src/components/FiltersPane/components/Filter/helpers.ts +3 -3
  146. package/src/components/FiltersPane/types.ts +0 -2
  147. package/src/components/Flag/Flag.stories.tsx +15 -20
  148. package/src/components/Flag/Flag.tsx +2 -2
  149. package/src/components/FlexibleTable/FlexibleTable.stories.tsx +47 -50
  150. package/src/components/FloatDocActions/FloatDocActions.stories.tsx +18 -24
  151. package/src/components/Icon/Icon.stories.tsx +9 -5
  152. package/src/components/Icon/types.ts +1 -1
  153. package/src/components/IconButton/IconButton.stories.tsx +7 -11
  154. package/src/components/IncrementInput/IncrementInput.stories.tsx +25 -25
  155. package/src/components/Input/Input.stories.tsx +35 -61
  156. package/src/components/List/List.stories.tsx +22 -17
  157. package/src/components/List/List.styles.ts +2 -1
  158. package/src/components/Modal/Modal.stories.tsx +50 -59
  159. package/src/components/MoreMenu/MoreMenu.stories.tsx +24 -15
  160. package/src/components/MultiSelect/MultiSelect.stories.tsx +23 -20
  161. package/src/components/NewMoreMenu/NewMoreMenu.stories.tsx +42 -40
  162. package/src/components/Notification/Notification.stories.tsx +34 -32
  163. package/src/components/NumberInput/NumberInput.stories.tsx +27 -27
  164. package/src/components/PhoneInput/PhoneInput.stories.tsx +28 -54
  165. package/src/components/PhoneInput/PhoneInput.tsx +1 -1
  166. package/src/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.stories.tsx +5 -11
  167. package/src/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.tsx +1 -4
  168. package/src/components/RadioButton/RadioButton.stories.tsx +28 -31
  169. package/src/components/RadioButton/types.ts +1 -1
  170. package/src/components/ScrollIntoViewIfNeeded/ScrollIntoViewIfNeeded.ts +15 -9
  171. package/src/components/SearchInput/SearchInput.stories.tsx +14 -14
  172. package/src/components/Select/CustomSelect.stories.tsx +29 -33
  173. package/src/components/Select/MultiSelect.stories.tsx +41 -46
  174. package/src/components/Select/Select.stories.tsx +41 -46
  175. package/src/components/Select/Select.tsx +27 -27
  176. package/src/components/Select/components/SelectList/SelectList.tsx +4 -4
  177. package/src/components/Selector/Selector.stories.tsx +25 -27
  178. package/src/components/Selector/Selector.tsx +1 -2
  179. package/src/components/Skeleton/Skeleton.stories.tsx +13 -12
  180. package/src/components/SmartInput/SmartInput.stories.tsx +23 -23
  181. package/src/components/Status/Status.stories.tsx +29 -30
  182. package/src/components/Status/types.ts +1 -1
  183. package/src/components/Switch/Switch.stories.tsx +19 -26
  184. package/src/components/TextArea/TextArea.stories.tsx +32 -35
  185. package/src/components/TextArea/types.ts +1 -1
  186. package/src/components/TextButton/TextButton.stories.tsx +6 -16
  187. package/src/components/TextWithInfo/TextWithInfo.stories.tsx +13 -21
  188. package/src/components/TextWithTooltip/TextWithTooltip.stories.tsx +26 -25
  189. package/src/components/TextWithTooltip/TextWithTooltip.tsx +1 -2
  190. package/src/components/ThemedPreloader/ThemedPreloader.stories.tsx +12 -23
  191. package/src/components/Toaster/Toaster.stories.tsx +16 -14
  192. package/src/components/Tooltip/Tooltip.stories.tsx +5 -4
  193. package/src/components/WithMessages/WithMessages.stories.tsx +16 -20
  194. package/src/components/WithPopup/WithPopup.stories.tsx +27 -26
  195. package/src/components/WithTooltip/WithTooltip.stories.tsx +28 -28
  196. package/src/components/index.ts +0 -1
  197. package/src/helpers/misc.ts +8 -5
  198. package/src/helpers/popper-helpers.ts +0 -1
  199. package/src/theme/helpers.ts +3 -1
  200. package/src/theme/true-jss/ThemedStylesManager.ts +2 -1
  201. package/src/theme/true-jss/TweakStylesManager.ts +1 -2
  202. package/src/theme/types.ts +0 -1
  203. package/src/types.ts +0 -2
  204. package/dist/components/Colors/Colors.d.ts +0 -2
  205. package/dist/components/Colors/Colors.styles.d.ts +0 -1
  206. package/dist/components/Colors/index.d.ts +0 -1
  207. package/src/components/Colors/Colors.styles.ts +0 -36
  208. package/src/components/Colors/Colors.tsx +0 -26
  209. package/src/components/Colors/index.ts +0 -1
  210. package/src/components/Flag/customFlags/augment.d.ts +0 -1
@@ -1,23 +1,18 @@
1
- import { useState } from 'react';
2
- import { ComponentStory } from '@storybook/react';
1
+ import { FC, useState } from 'react';
2
+ import { type Meta } from '@storybook/react';
3
+ import { excludeStorybookParams } from '../../helpers';
3
4
  import { IExtendableProps } from '../../types';
4
- import { RadioButton } from './RadioButton';
5
+ import { IRadioButtonProps, RadioButton } from './RadioButton';
5
6
 
6
- const RADIO_SIZES = [undefined, 'micro'] as const;
7
-
8
- export default {
9
- title: 'Controls/RadioButton',
10
- component: RadioButton,
11
- };
7
+ const options = ['one', 'two', 'three'];
8
+ const SIZES = [undefined, 'micro'] as const;
12
9
 
13
10
  declare module './types' {
14
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
15
- export interface IRadioButtonSizes extends IExtendableProps<typeof RADIO_SIZES> {}
11
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
12
+ export interface IRadioButtonSizes extends IExtendableProps<typeof SIZES> {}
16
13
  }
17
14
 
18
- const options = ['one', 'two', 'three'];
19
-
20
- const Template: ComponentStory<typeof RadioButton> = (args) => {
15
+ const Story: FC<IRadioButtonProps<string>> = (args) => {
21
16
  const [activeIdx, setActiveIdx] = useState(0);
22
17
 
23
18
  return (
@@ -38,22 +33,24 @@ const Template: ComponentStory<typeof RadioButton> = (args) => {
38
33
  );
39
34
  };
40
35
 
41
- export const Default = Template.bind({});
42
-
43
- Default.args = {
44
- children: 'Label',
45
- size: undefined,
46
- // isChecked: false,
47
- isInvalid: false,
48
- isDisabled: false,
49
- };
50
-
51
- Default.argTypes = {
52
- size: { options: [undefined, ...RADIO_SIZES], control: 'inline-radio' },
53
- };
54
-
55
- Default.parameters = {
56
- controls: {
57
- exclude: ['data', 'value', 'groupName', 'isChecked', 'onChange'],
36
+ const meta: Meta<typeof Story> = {
37
+ title: 'Controls/RadioButton',
38
+ component: Story,
39
+ args: {
40
+ children: 'Label',
41
+ size: undefined,
42
+ isInvalid: false,
43
+ isDisabled: false,
44
+ },
45
+ argTypes: {
46
+ size: { options: [undefined, ...SIZES], control: 'inline-radio' },
47
+ },
48
+ parameters: {
49
+ controls: {
50
+ exclude: excludeStorybookParams(['value', 'groupName', 'isChecked']),
51
+ },
58
52
  },
59
53
  };
54
+
55
+ export default meta;
56
+ export const Default = {};
@@ -1,4 +1,4 @@
1
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
1
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
2
2
  export interface IRadioButtonSizes {}
3
3
 
4
4
  export type IRadioButtonSize = keyof IRadioButtonSizes;
@@ -1,4 +1,12 @@
1
- import { createElement, createRef, HTMLProps, PureComponent, ReactNode, RefObject } from 'react';
1
+ import {
2
+ createElement,
3
+ createRef,
4
+ DOMElement,
5
+ HTMLProps,
6
+ PureComponent,
7
+ ReactNode,
8
+ RefObject,
9
+ } from 'react';
2
10
  import scrollIntoViewIfNeeded, { StandardBehaviorOptions } from 'scroll-into-view-if-needed';
3
11
  import {
4
12
  ScrollIntoViewIfNeededDefaultElementType,
@@ -13,25 +21,25 @@ export interface IScrollIntoViewIfNeededProps extends HTMLProps<HTMLElement> {
13
21
  }
14
22
 
15
23
  export class ScrollIntoViewIfNeeded extends PureComponent<IScrollIntoViewIfNeededProps> {
16
- node: RefObject<HTMLElement> = createRef();
17
-
18
24
  public static defaultProps: IScrollIntoViewIfNeededProps = ScrollIntoViewIfNeededDefaultProps;
19
25
 
20
- componentDidMount() {
26
+ node: RefObject<HTMLElement> = createRef();
27
+
28
+ componentDidMount(): void {
21
29
  const { active } = this.props;
22
30
  if (active) {
23
31
  this.handleScrollIntoViewIfNeeded();
24
32
  }
25
33
  }
26
34
 
27
- componentDidUpdate({ active }: IScrollIntoViewIfNeededProps) {
35
+ componentDidUpdate({ active }: IScrollIntoViewIfNeededProps): void {
28
36
  const { active: isNowActive } = this.props;
29
37
  if (!active && isNowActive) {
30
38
  this.handleScrollIntoViewIfNeeded();
31
39
  }
32
40
  }
33
41
 
34
- handleScrollIntoViewIfNeeded = () => {
42
+ handleScrollIntoViewIfNeeded = (): void => {
35
43
  const { options } = this.props;
36
44
  const { current: node } = this.node;
37
45
 
@@ -40,7 +48,7 @@ export class ScrollIntoViewIfNeeded extends PureComponent<IScrollIntoViewIfNeede
40
48
  }
41
49
  };
42
50
 
43
- render() {
51
+ render(): DOMElement<any, any> {
44
52
  const { active, elementType, children, options, ...wrapperProps } = this.props;
45
53
 
46
54
  return createElement(
@@ -50,5 +58,3 @@ export class ScrollIntoViewIfNeeded extends PureComponent<IScrollIntoViewIfNeede
50
58
  );
51
59
  }
52
60
  }
53
-
54
- export default ScrollIntoViewIfNeeded;
@@ -1,13 +1,8 @@
1
- import { useState } from 'react';
2
- import { ComponentStory } from '@storybook/react';
3
- import { SearchInput } from './SearchInput';
1
+ import { FC, useState } from 'react';
2
+ import { type Meta } from '@storybook/react';
3
+ import { ISearchInputProps, SearchInput } from './SearchInput';
4
4
 
5
- export default {
6
- title: 'Inputs/SearchInput',
7
- component: SearchInput,
8
- };
9
-
10
- const Template: ComponentStory<typeof SearchInput> = (args) => {
5
+ const Story: FC<ISearchInputProps> = (args) => {
11
6
  const [value, setValue] = useState('');
12
7
  return (
13
8
  <div style={{ width: 320 }}>
@@ -16,9 +11,14 @@ const Template: ComponentStory<typeof SearchInput> = (args) => {
16
11
  );
17
12
  };
18
13
 
19
- export const Default = Template.bind({});
20
-
21
- Default.args = {
22
- placeholder: 'Поиск',
23
- isAutoSized: false,
14
+ const meta: Meta<typeof Story> = {
15
+ title: 'Inputs/SearchInput',
16
+ component: Story,
17
+ args: {
18
+ placeholder: 'Поиск',
19
+ isAutoSized: false,
20
+ },
24
21
  };
22
+
23
+ export default meta;
24
+ export const Default = {};
@@ -1,13 +1,13 @@
1
- import { useState } from 'react';
1
+ import { FC, useState } from 'react';
2
2
  import { createUseStyles } from 'react-jss';
3
3
  import { isStringNotEmpty } from '@true-engineering/true-react-platform-helpers';
4
- import { type ComponentMeta, type ComponentStory } from '@storybook/react';
4
+ import { type Meta } from '@storybook/react';
5
5
  import { Button, type IButtonStyles } from '../Button';
6
6
  import { type IInputStyles, Input } from '../Input';
7
7
  import { TextButton } from '../TextButton';
8
8
  import { type ISelectProps, Select } from './Select';
9
9
 
10
- interface ISelectWithCustomProps<Option> extends ISelectProps<Option> {
10
+ interface ISelectCustomProps<Option> extends ISelectProps<Option> {
11
11
  shouldUsePopper?: boolean;
12
12
  shouldRenderInBody?: boolean;
13
13
  shouldHideOnScroll?: boolean;
@@ -136,15 +136,15 @@ function CustomListFooter({ onReset, onClear }: ICustomListFooterProps) {
136
136
  );
137
137
  }
138
138
 
139
- function SelectWithCustomProps({
139
+ const Story: FC<ISelectCustomProps<string>> = ({
140
140
  noMatchesLabel,
141
141
  shouldUsePopper,
142
142
  shouldRenderInBody,
143
143
  shouldHideOnScroll,
144
144
  canBeFlipped,
145
145
  scrollParent,
146
- ...restProps
147
- }: ISelectWithCustomProps<string>) {
146
+ ...args
147
+ }) => {
148
148
  const classes = useSelectStyles();
149
149
  const [inputValue, setInputValue] = useState<string>();
150
150
  const [options, setOptions] = useState<string[]>([]);
@@ -185,7 +185,7 @@ function SelectWithCustomProps({
185
185
  );
186
186
 
187
187
  const props = {
188
- ...restProps,
188
+ ...args,
189
189
  onChange: setInputValue,
190
190
  value: inputValue,
191
191
  options,
@@ -214,38 +214,34 @@ function SelectWithCustomProps({
214
214
  }}
215
215
  />
216
216
  );
217
- }
217
+ };
218
218
 
219
- export default {
219
+ const meta: Meta<typeof Story> = {
220
220
  title: 'Controls/Select',
221
- component: SelectWithCustomProps,
221
+ component: Story,
222
+ args: {
223
+ label: 'Dropdown',
224
+ noMatchesLabel: 'No matches',
225
+ isInvalid: false,
226
+ errorMessage: '',
227
+ isDisabled: false,
228
+ isRequired: false,
229
+ isClearable: false,
230
+ shouldUsePopper: false,
231
+ shouldRenderInBody: false,
232
+ shouldHideOnScroll: false,
233
+ shouldScrollToList: true,
234
+ canBeFlipped: false,
235
+ scrollParent: 'document',
236
+ size: undefined,
237
+ },
222
238
  argTypes: {
223
239
  scrollParent: {
224
240
  options: ['document', 'auto'],
225
241
  control: { type: 'select' },
226
242
  },
227
243
  },
228
- } as ComponentMeta<typeof SelectWithCustomProps>;
229
-
230
- const Template: ComponentStory<typeof SelectWithCustomProps> = (args) => (
231
- <SelectWithCustomProps {...args} />
232
- );
233
-
234
- export const CustomSelect = Template.bind({});
235
-
236
- CustomSelect.args = {
237
- label: 'Dropdown',
238
- noMatchesLabel: 'No matches',
239
- isInvalid: false,
240
- errorMessage: '',
241
- isDisabled: false,
242
- isRequired: false,
243
- isClearable: false,
244
- shouldUsePopper: false,
245
- shouldRenderInBody: false,
246
- shouldHideOnScroll: false,
247
- shouldScrollToList: true,
248
- canBeFlipped: false,
249
- scrollParent: 'document',
250
- size: undefined,
251
244
  };
245
+
246
+ export default meta;
247
+ export const CustomSelect = {};
@@ -1,6 +1,7 @@
1
- import { ReactNode, useEffect, useState } from 'react';
1
+ import { ReactElement, ReactNode, useEffect, useState } from 'react';
2
2
  import { isStringNotEmpty } from '@true-engineering/true-react-platform-helpers';
3
- import { ComponentMeta, ComponentStory } from '@storybook/react';
3
+ import { type Meta } from '@storybook/react';
4
+ import { GROUP_PLACEMENTS } from '../ControlWrapper';
4
5
  import { iconsMap } from '../Icon';
5
6
  import { IMultipleSelectProps, Select } from './Select';
6
7
 
@@ -10,8 +11,6 @@ interface ObjectValue {
10
11
  isDisabled?: boolean;
11
12
  }
12
13
 
13
- const groupPlacements = [undefined, 'left', 'right', 'middle'];
14
-
15
14
  const genLetters = (qnt = 1): string =>
16
15
  Math.random()
17
16
  .toString(36)
@@ -61,7 +60,7 @@ const icons = [undefined, ...Object.keys(iconsMap)];
61
60
  const getRandomInt = (min: number, max: number) =>
62
61
  Math.floor(Math.random() * (Math.floor(max) - Math.ceil(min))) + Math.ceil(min);
63
62
 
64
- interface ISelectWithCustomProps<T> extends IMultipleSelectProps<T> {
63
+ interface ISelectCustomProps<T> extends IMultipleSelectProps<T> {
65
64
  valuesType: 'strings' | 'objects';
66
65
  shouldUseReactNodes?: boolean;
67
66
  shouldUsePopper?: boolean;
@@ -73,7 +72,7 @@ interface ISelectWithCustomProps<T> extends IMultipleSelectProps<T> {
73
72
  scrollParent?: 'document' | 'auto';
74
73
  }
75
74
 
76
- function SelectWithCustomProps<T>({
75
+ function Story<T>({
77
76
  valuesType,
78
77
  optionsMode,
79
78
  shouldUseReactNodes,
@@ -85,8 +84,8 @@ function SelectWithCustomProps<T>({
85
84
  canBeFlipped,
86
85
  scrollParent,
87
86
  noMatchesLabel,
88
- ...rest
89
- }: ISelectWithCustomProps<T>) {
87
+ ...args
88
+ }: ISelectCustomProps<T>): ReactElement {
90
89
  const [stringValue, setStringValue] = useState<string[]>();
91
90
 
92
91
  const stringHandler = (newValue?: string[]) => {
@@ -160,7 +159,7 @@ function SelectWithCustomProps<T>({
160
159
 
161
160
  return (
162
161
  <Select
163
- {...rest}
162
+ {...args}
164
163
  {...(props as unknown as IMultipleSelectProps<any>)}
165
164
  {...(shouldRenderSearchInputInList && {
166
165
  searchInput: { shouldRenderInList: true },
@@ -182,14 +181,41 @@ function SelectWithCustomProps<T>({
182
181
  );
183
182
  }
184
183
 
185
- export default {
184
+ const meta: Meta<typeof Story> = {
186
185
  title: 'Controls/Select',
187
- component: SelectWithCustomProps,
186
+ component: Story,
187
+ args: {
188
+ label: 'Dropdown',
189
+ noMatchesLabel: 'No matches',
190
+ isInvalid: false,
191
+ errorMessage: 'Error Text',
192
+ icon: 'filter',
193
+ defaultOptionLabel: '',
194
+ allOptionsLabel: 'Все опции',
195
+ isDisabled: false,
196
+ isRequired: false,
197
+ isClearable: false,
198
+ isLoading: false,
199
+ debounceTime: 400,
200
+ // custom options
201
+ shouldUseReactNodes: false,
202
+ valuesType: 'strings',
203
+ optionsMode: 'normal',
204
+ shouldUsePopper: false,
205
+ shouldRenderInBody: false,
206
+ shouldHideOnScroll: false,
207
+ shouldUseCustomIsDisabledFunction: false,
208
+ shouldRenderSearchInputInList: false,
209
+ shouldScrollToList: true,
210
+ canBeFlipped: false,
211
+ scrollParent: 'document',
212
+ size: undefined,
213
+ },
188
214
  argTypes: {
189
215
  debounceTime: {
190
216
  control: { type: 'range', min: 0, max: 1000, step: 100 },
191
217
  },
192
- groupPlacement: { control: 'select', options: groupPlacements },
218
+ groupPlacement: { options: [undefined, ...GROUP_PLACEMENTS], control: 'select' },
193
219
  optionsMode: {
194
220
  control: 'inline-radio',
195
221
  options: ['normal', 'search', 'dynamic'],
@@ -200,38 +226,7 @@ export default {
200
226
  },
201
227
  icon: { control: 'select', options: icons },
202
228
  },
203
- } as ComponentMeta<typeof SelectWithCustomProps>;
204
-
205
- const Template: ComponentStory<typeof SelectWithCustomProps> = (args) => (
206
- <SelectWithCustomProps {...args} />
207
- );
208
-
209
- export const MultiSelect = Template.bind({});
210
-
211
- MultiSelect.args = {
212
- label: 'Dropdown',
213
- noMatchesLabel: 'No matches',
214
- isInvalid: false,
215
- errorMessage: 'Error Text',
216
- icon: 'document',
217
- defaultOptionLabel: '',
218
- allOptionsLabel: 'Все опции',
219
- isDisabled: false,
220
- isRequired: false,
221
- isClearable: false,
222
- isLoading: false,
223
- debounceTime: 400,
224
- // custom options
225
- shouldUseReactNodes: false,
226
- valuesType: 'strings',
227
- optionsMode: 'normal',
228
- shouldUsePopper: false,
229
- shouldRenderInBody: false,
230
- shouldHideOnScroll: false,
231
- shouldUseCustomIsDisabledFunction: false,
232
- shouldRenderSearchInputInList: false,
233
- shouldScrollToList: true,
234
- canBeFlipped: false,
235
- scrollParent: 'document',
236
- size: undefined,
237
229
  };
230
+
231
+ export default meta;
232
+ export const MultiSelect = {};
@@ -1,6 +1,7 @@
1
- import { ReactNode, useEffect, useState } from 'react';
1
+ import { ReactElement, ReactNode, useEffect, useState } from 'react';
2
2
  import { isStringNotEmpty } from '@true-engineering/true-react-platform-helpers';
3
- import { ComponentMeta, ComponentStory } from '@storybook/react';
3
+ import { type Meta } from '@storybook/react';
4
+ import { GROUP_PLACEMENTS } from '../ControlWrapper';
4
5
  import { iconsMap } from '../Icon';
5
6
  import { ISelectProps, Select } from './Select';
6
7
 
@@ -10,8 +11,6 @@ interface ObjectValue {
10
11
  isDisabled?: boolean;
11
12
  }
12
13
 
13
- const groupPlacements = [undefined, 'left', 'right', 'middle'];
14
-
15
14
  const genLetters = (qnt = 1): string =>
16
15
  Math.random()
17
16
  .toString(36)
@@ -61,7 +60,7 @@ const icons = [undefined, ...Object.keys(iconsMap)];
61
60
  const getRandomInt = (min: number, max: number) =>
62
61
  Math.floor(Math.random() * (Math.floor(max) - Math.ceil(min))) + Math.ceil(min);
63
62
 
64
- interface ISelectWithCustomProps<T> extends ISelectProps<T> {
63
+ interface ISelectCustomProps<T> extends ISelectProps<T> {
65
64
  valuesType: 'strings' | 'objects';
66
65
  shouldUseReactNodes?: boolean;
67
66
  shouldUsePopper?: boolean;
@@ -73,7 +72,7 @@ interface ISelectWithCustomProps<T> extends ISelectProps<T> {
73
72
  scrollParent?: 'document' | 'auto';
74
73
  }
75
74
 
76
- function SelectWithCustomProps<T>({
75
+ function Story<T>({
77
76
  valuesType,
78
77
  optionsMode,
79
78
  shouldUseReactNodes,
@@ -85,8 +84,8 @@ function SelectWithCustomProps<T>({
85
84
  canBeFlipped,
86
85
  scrollParent,
87
86
  noMatchesLabel,
88
- ...rest
89
- }: ISelectWithCustomProps<T>) {
87
+ ...args
88
+ }: ISelectCustomProps<T>): ReactElement {
90
89
  const [stringValue, setStringValue] = useState<string>();
91
90
  const stringHandler = (newValue?: string) => {
92
91
  console.log('change');
@@ -158,7 +157,7 @@ function SelectWithCustomProps<T>({
158
157
 
159
158
  return (
160
159
  <Select
161
- {...rest}
160
+ {...args}
162
161
  {...(props as unknown as ISelectProps<any>)}
163
162
  {...(shouldRenderSearchInputInList && {
164
163
  searchInput: { shouldRenderInList: true },
@@ -179,14 +178,41 @@ function SelectWithCustomProps<T>({
179
178
  );
180
179
  }
181
180
 
182
- export default {
181
+ const meta: Meta<typeof Story> = {
183
182
  title: 'Controls/Select',
184
- component: SelectWithCustomProps,
183
+ component: Story,
184
+ args: {
185
+ label: 'Dropdown',
186
+ defaultOptionLabel: 'Default Option',
187
+ noMatchesLabel: 'No matches',
188
+ isInvalid: false,
189
+ errorMessage: 'Error Text',
190
+ isDisabled: false,
191
+ isReadonly: false,
192
+ isRequired: false,
193
+ isClearable: false,
194
+ isLoading: false,
195
+ debounceTime: 400,
196
+ icon: undefined,
197
+ // custom options
198
+ shouldUseReactNodes: false,
199
+ valuesType: 'strings',
200
+ optionsMode: 'normal',
201
+ shouldUsePopper: false,
202
+ shouldRenderInBody: false,
203
+ shouldHideOnScroll: false,
204
+ shouldUseCustomIsDisabledFunction: false,
205
+ shouldRenderSearchInputInList: false,
206
+ shouldScrollToList: true,
207
+ canBeFlipped: false,
208
+ scrollParent: 'document',
209
+ size: undefined,
210
+ },
185
211
  argTypes: {
186
212
  debounceTime: {
187
213
  control: { type: 'range', min: 0, max: 1000, step: 100 },
188
214
  },
189
- groupPlacement: { control: 'select', options: groupPlacements },
215
+ groupPlacement: { options: [undefined, ...GROUP_PLACEMENTS], control: 'select' },
190
216
  optionsMode: {
191
217
  control: 'inline-radio',
192
218
  options: ['normal', 'search', 'dynamic'],
@@ -197,38 +223,7 @@ export default {
197
223
  },
198
224
  icon: { control: 'select', options: icons },
199
225
  },
200
- } as ComponentMeta<typeof SelectWithCustomProps>;
201
-
202
- const Template: ComponentStory<typeof SelectWithCustomProps> = (args) => (
203
- <SelectWithCustomProps {...args} />
204
- );
205
-
206
- export const Default = Template.bind({});
207
-
208
- Default.args = {
209
- label: 'Dropdown',
210
- defaultOptionLabel: 'Default Option',
211
- noMatchesLabel: 'No matches',
212
- isInvalid: false,
213
- errorMessage: 'Error Text',
214
- isDisabled: false,
215
- isReadonly: false,
216
- isRequired: false,
217
- isClearable: false,
218
- isLoading: false,
219
- debounceTime: 400,
220
- icon: undefined,
221
- // custom options
222
- shouldUseReactNodes: false,
223
- valuesType: 'strings',
224
- optionsMode: 'normal',
225
- shouldUsePopper: false,
226
- shouldRenderInBody: false,
227
- shouldHideOnScroll: false,
228
- shouldUseCustomIsDisabledFunction: false,
229
- shouldRenderSearchInputInList: false,
230
- shouldScrollToList: true,
231
- canBeFlipped: false,
232
- scrollParent: 'document',
233
- size: undefined,
234
226
  };
227
+
228
+ export default meta;
229
+ export const Default = {};
@@ -61,7 +61,7 @@ export interface ISelectProps<Value>
61
61
  dropdownOptions?: IDropdownWithPopperOptions;
62
62
  /** @default 'chevron-down' */
63
63
  dropdownIcon?: IIcon;
64
- options: Value[] | Readonly<Value[]>;
64
+ options: Value[] | readonly Value[];
65
65
  value: Value | undefined;
66
66
  /** @default true */
67
67
  shouldScrollToList?: boolean;
@@ -280,32 +280,6 @@ export function Select<Value>(
280
280
  handleListOpen();
281
281
  };
282
282
 
283
- const handleBlur = (event: FocusEvent<HTMLInputElement>) => {
284
- // Когда что-то блокирует открытие листа, но блур все равно должен сработать
285
- // например minSymbolsCount
286
- if (isListOpen && !isOpen) {
287
- handleListClose(event);
288
- return;
289
- }
290
-
291
- if (
292
- !isNotEmpty(event.relatedTarget) ||
293
- !isNotEmpty(list.current) ||
294
- !isNotEmpty(inputWrapper.current)
295
- ) {
296
- return;
297
- }
298
-
299
- const isActionInsideSelect =
300
- hasExactParent(event.relatedTarget, list.current) ||
301
- hasExactParent(event.relatedTarget, inputWrapper.current);
302
-
303
- // Ничего не делаем, если клик был внутри селекта
304
- if (!isActionInsideSelect) {
305
- handleListClose(event);
306
- }
307
- };
308
-
309
283
  const handleChange = useCallback(
310
284
  (newValue: Value | IMultipleSelectValue<Value> | undefined, event: IChangeSelectEvent) => {
311
285
  // Тут беда с типами, сорри
@@ -484,6 +458,32 @@ export function Select<Value>(
484
458
  // Последняя проверка на случай, если мы че то ищем в опциях
485
459
  (optionsMode === 'normal' || hasEnoughSymbolsToSearch);
486
460
 
461
+ const handleBlur = (event: FocusEvent<HTMLInputElement>) => {
462
+ // Когда что-то блокирует открытие листа, но блур все равно должен сработать
463
+ // например minSymbolsCount
464
+ if (isListOpen && !isOpen) {
465
+ handleListClose(event);
466
+ return;
467
+ }
468
+
469
+ if (
470
+ !isNotEmpty(event.relatedTarget) ||
471
+ !isNotEmpty(list.current) ||
472
+ !isNotEmpty(inputWrapper.current)
473
+ ) {
474
+ return;
475
+ }
476
+
477
+ const isActionInsideSelect =
478
+ hasExactParent(event.relatedTarget, list.current) ||
479
+ hasExactParent(event.relatedTarget, inputWrapper.current);
480
+
481
+ // Ничего не делаем, если клик был внутри селекта
482
+ if (!isActionInsideSelect) {
483
+ handleListClose(event);
484
+ }
485
+ };
486
+
487
487
  // Эти значения ставятся в false по дефолту также в useDropdown
488
488
  const {
489
489
  shouldUsePopper = false,
@@ -1,4 +1,4 @@
1
- import { useMemo, type ReactNode } from 'react';
1
+ import { type ReactNode, useMemo } from 'react';
2
2
  import clsx from 'clsx';
3
3
  import {
4
4
  addDataTestId,
@@ -8,13 +8,13 @@ import {
8
8
  import { type ICommonProps } from '../../../../types';
9
9
  import { ScrollIntoViewIfNeeded } from '../../../ScrollIntoViewIfNeeded';
10
10
  import { ALL_OPTION_INDEX, DEFAULT_OPTION_INDEX } from '../../constants';
11
- import { SelectListItem, type ISelectListItemProps } from '../SelectListItem';
12
- import { useStyles, type ISelectListStyles } from './SelectList.styles';
11
+ import { type ISelectListItemProps, SelectListItem } from '../SelectListItem';
12
+ import { type ISelectListStyles, useStyles } from './SelectList.styles';
13
13
 
14
14
  export interface ISelectListProps<Value>
15
15
  extends ICommonProps<ISelectListStyles>,
16
16
  Pick<ISelectListItemProps, 'onToggleCheckbox' | 'onOptionSelect' | 'isMultiSelect'> {
17
- options: Value[] | Readonly<Value[]>;
17
+ options: Value[] | readonly Value[];
18
18
  focusedIndex?: number;
19
19
  activeValue?: Value | Value[];
20
20
  noMatchesLabel?: string;