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

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 (73) hide show
  1. package/dist/components/ControlWrapper/ControlWrapper.d.ts +2 -2
  2. package/dist/components/ControlWrapper/constants.d.ts +1 -0
  3. package/dist/components/ControlWrapper/index.d.ts +1 -0
  4. package/dist/components/ControlWrapper/types.d.ts +2 -0
  5. package/dist/components/index.d.ts +0 -1
  6. package/dist/helpers/misc.d.ts +1 -0
  7. package/dist/true-react-common-ui-kit.js +169 -259
  8. package/dist/true-react-common-ui-kit.js.map +1 -1
  9. package/dist/true-react-common-ui-kit.umd.cjs +169 -259
  10. package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
  11. package/package.json +3 -6
  12. package/src/components/AccountInfo/AccountInfo.stories.tsx +19 -27
  13. package/src/components/AddButton/AddButton.stories.tsx +14 -17
  14. package/src/components/Button/Button.stories.tsx +7 -24
  15. package/src/components/Checkbox/Checkbox.stories.tsx +24 -26
  16. package/src/components/CloseButton/CloseButton.stories.tsx +5 -6
  17. package/src/components/Colors/Colors.stories.tsx +63 -3
  18. package/src/components/ControlWrapper/ControlWrapper.stories.tsx +43 -38
  19. package/src/components/ControlWrapper/ControlWrapper.tsx +2 -11
  20. package/src/components/ControlWrapper/constants.ts +11 -0
  21. package/src/components/ControlWrapper/index.ts +1 -0
  22. package/src/components/ControlWrapper/types.ts +3 -0
  23. package/src/components/DateInput/DateInput.stories.tsx +13 -30
  24. package/src/components/DatePicker/DatePicker.stories.tsx +15 -52
  25. package/src/components/Description/Description.stories.tsx +11 -16
  26. package/src/components/FileInput/FileInput.stories.tsx +59 -63
  27. package/src/components/FileItem/FileItem.stories.tsx +46 -45
  28. package/src/components/FiltersPane/FiltersPane.stories.tsx +27 -30
  29. package/src/components/Flag/Flag.stories.tsx +15 -20
  30. package/src/components/FlexibleTable/FlexibleTable.stories.tsx +47 -50
  31. package/src/components/FloatDocActions/FloatDocActions.stories.tsx +18 -24
  32. package/src/components/Icon/Icon.stories.tsx +9 -5
  33. package/src/components/IconButton/IconButton.stories.tsx +7 -11
  34. package/src/components/IncrementInput/IncrementInput.stories.tsx +25 -25
  35. package/src/components/Input/Input.stories.tsx +35 -61
  36. package/src/components/List/List.stories.tsx +22 -17
  37. package/src/components/List/List.styles.ts +2 -1
  38. package/src/components/Modal/Modal.stories.tsx +50 -59
  39. package/src/components/MoreMenu/MoreMenu.stories.tsx +24 -15
  40. package/src/components/MultiSelect/MultiSelect.stories.tsx +23 -20
  41. package/src/components/NewMoreMenu/NewMoreMenu.stories.tsx +42 -40
  42. package/src/components/Notification/Notification.stories.tsx +34 -32
  43. package/src/components/NumberInput/NumberInput.stories.tsx +27 -27
  44. package/src/components/PhoneInput/PhoneInput.stories.tsx +28 -54
  45. package/src/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.stories.tsx +5 -11
  46. package/src/components/RadioButton/RadioButton.stories.tsx +27 -30
  47. package/src/components/SearchInput/SearchInput.stories.tsx +14 -14
  48. package/src/components/Select/CustomSelect.stories.tsx +29 -33
  49. package/src/components/Select/MultiSelect.stories.tsx +40 -45
  50. package/src/components/Select/Select.stories.tsx +40 -45
  51. package/src/components/Selector/Selector.stories.tsx +25 -27
  52. package/src/components/Skeleton/Skeleton.stories.tsx +13 -12
  53. package/src/components/SmartInput/SmartInput.stories.tsx +23 -23
  54. package/src/components/Status/Status.stories.tsx +28 -29
  55. package/src/components/Switch/Switch.stories.tsx +19 -26
  56. package/src/components/TextArea/TextArea.stories.tsx +31 -34
  57. package/src/components/TextButton/TextButton.stories.tsx +6 -16
  58. package/src/components/TextWithInfo/TextWithInfo.stories.tsx +13 -21
  59. package/src/components/TextWithTooltip/TextWithTooltip.stories.tsx +26 -25
  60. package/src/components/ThemedPreloader/ThemedPreloader.stories.tsx +12 -23
  61. package/src/components/Toaster/Toaster.stories.tsx +16 -14
  62. package/src/components/Tooltip/Tooltip.stories.tsx +5 -4
  63. package/src/components/WithMessages/WithMessages.stories.tsx +16 -20
  64. package/src/components/WithPopup/WithPopup.stories.tsx +27 -26
  65. package/src/components/WithTooltip/WithTooltip.stories.tsx +28 -28
  66. package/src/components/index.ts +0 -1
  67. package/src/helpers/misc.ts +3 -0
  68. package/dist/components/Colors/Colors.d.ts +0 -2
  69. package/dist/components/Colors/Colors.styles.d.ts +0 -1
  70. package/dist/components/Colors/index.d.ts +0 -1
  71. package/src/components/Colors/Colors.styles.ts +0 -36
  72. package/src/components/Colors/Colors.tsx +0 -26
  73. package/src/components/Colors/index.ts +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@true-engineering/true-react-common-ui-kit",
3
- "version": "4.0.0-alpha44",
3
+ "version": "4.0.0-alpha45",
4
4
  "description": "True Engineering React UI Kit with theming support",
5
5
  "author": "True Engineering (https://trueengineering.ru)",
6
6
  "keywords": [
@@ -69,14 +69,11 @@
69
69
  },
70
70
  "devDependencies": {
71
71
  "@babel/core": "7.20.12",
72
- "@storybook/addon-essentials": "7.6.17",
73
- "@storybook/blocks": "7.6.17",
74
- "@storybook/react": "7.6.17",
75
- "@storybook/react-vite": "7.6.17",
76
- "@storybook/test": "7.6.17",
72
+ "@storybook/react": "9.1.10",
77
73
  "@swc/core": "^1.3.30",
78
74
  "@trivago/prettier-plugin-sort-imports": "4.3.0",
79
75
  "@types/lodash-es": "4.17.11",
76
+ "@types/node": "^24.7.2",
80
77
  "@types/react": "18.2.79",
81
78
  "@types/react-dom": "18.2.25",
82
79
  "@types/react-input-mask": "3.0.2",
@@ -1,32 +1,24 @@
1
- import { ComponentStory } from '@storybook/react';
2
- import { AccountInfo } from './AccountInfo';
1
+ import { FC } from 'react';
2
+ import { type Meta } from '@storybook/react';
3
+ import { excludeStorybookParams } from '../../helpers';
4
+ import { AccountInfo, IAccountInfoProps } from './AccountInfo';
3
5
 
4
- export default {
5
- title: 'Data Display/AccountInfo',
6
- component: AccountInfo,
7
- };
8
-
9
- const Template: ComponentStory<typeof AccountInfo> = (args) => (
10
- <div
11
- style={{
12
- display: 'flex',
13
- alignItems: 'center',
14
- justifyContent: 'center',
15
- width: 400,
16
- height: 200,
17
- border: '1px dotted rgba(0, 0, 0, 0.2)',
18
- }}
19
- >
20
- <AccountInfo {...args} options={[{ item: 'Logout', onClick: () => console.log('logout') }]} />
21
- </div>
6
+ const Story: FC<IAccountInfoProps> = (args) => (
7
+ <AccountInfo {...args} options={[{ item: 'Logout', onClick: () => console.log('logout') }]} />
22
8
  );
23
9
 
24
- export const Default = Template.bind({});
25
- Default.args = {
26
- accountName: 'Ivan Ivanov',
27
- };
28
- Default.parameters = {
29
- controls: {
30
- exclude: ['data', 'options', 'avatar'],
10
+ const meta: Meta<typeof Story> = {
11
+ title: 'Data Display/AccountInfo',
12
+ component: Story,
13
+ args: {
14
+ accountName: 'Ivan Ivanov',
15
+ },
16
+ parameters: {
17
+ controls: {
18
+ exclude: excludeStorybookParams(['avatar', 'options']),
19
+ },
31
20
  },
32
21
  };
22
+
23
+ export default meta;
24
+ export const Default = {};
@@ -1,21 +1,18 @@
1
- import { ComponentStory } from '@storybook/react';
2
- import { AddButton } from './AddButton';
1
+ import { FC } from 'react';
2
+ import { type Meta } from '@storybook/react';
3
+ import { AddButton, IAddButtonProps } from '../AddButton';
3
4
 
4
- export default {
5
- title: 'Buttons/AddButton',
6
- component: AddButton,
7
- };
8
-
9
- const Template: ComponentStory<typeof AddButton> = (args) => (
10
- <AddButton {...args} onClick={console.log} />
11
- );
5
+ const Story: FC<IAddButtonProps> = (args) => <AddButton {...args} onClick={console.log} />;
12
6
 
13
- export const Default = Template.bind({});
14
-
15
- Default.args = {
16
- text: 'Добавить билет',
17
- isDisabled: false,
18
- isFullWidth: false,
7
+ const meta: Meta<typeof Story> = {
8
+ title: 'Buttons/AddButton',
9
+ component: Story,
10
+ args: {
11
+ text: 'Добавить билет',
12
+ isDisabled: false,
13
+ isFullWidth: false,
14
+ },
19
15
  };
20
16
 
21
- Default.parameters = { controls: { exclude: ['onClick'] } };
17
+ export default meta;
18
+ export const Default = {};
@@ -1,13 +1,11 @@
1
- import { ComponentMeta, ComponentStory } from '@storybook/react';
1
+ import { type Meta } from '@storybook/react';
2
2
  import { iconsMap } from '../Icon';
3
3
  import { Button, IButtonProps } from './Button';
4
- import { BUTTON_SIZES, BUTTON_VIEWS } from './constants';
5
-
6
- const icons = [undefined, ...Object.keys(iconsMap)];
4
+ import { BUTTON_SIZES } from './constants';
7
5
 
8
6
  const preloaderTypes: Array<IButtonProps['preloaderType']> = ['dots', 'default', 'logo'];
9
7
 
10
- export default {
8
+ const meta: Meta<typeof Button> = {
11
9
  title: 'Buttons/Button',
12
10
  component: Button,
13
11
  args: {
@@ -24,26 +22,11 @@ export default {
24
22
  isFullWidth: false,
25
23
  },
26
24
  argTypes: {
27
- icon: { options: icons, control: 'select' },
25
+ icon: { options: [undefined, ...Object.keys(iconsMap)], control: 'select' },
28
26
  size: { options: BUTTON_SIZES, control: 'inline-radio' },
29
- view: { options: BUTTON_VIEWS, control: 'inline-radio' },
30
- iconPosition: { options: ['left', 'right'], control: 'inline-radio' },
31
27
  preloaderType: { options: preloaderTypes, control: 'inline-radio' },
32
28
  },
33
- parameters: {
34
- controls: {
35
- exclude: [
36
- 'data',
37
- 'testId',
38
- 'onClick',
39
- 'onMouseDown',
40
- 'tweakStyles',
41
- 'shouldSkipTabNavigation',
42
- ],
43
- },
44
- },
45
- } as ComponentMeta<typeof Button>;
29
+ };
46
30
 
47
- export const Default: ComponentStory<typeof Button> = (args) => (
48
- <Button {...args} key={args.size} />
49
- );
31
+ export default meta;
32
+ export const Default = {};
@@ -1,42 +1,48 @@
1
- import { useState, FC } from 'react';
2
- import type { Meta, StoryObj } 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 { Checkbox as CheckboxComponent, ICheckboxProps } from './Checkbox';
5
+ import { Checkbox, ICheckboxProps } from '../Checkbox';
5
6
 
6
- const CHECKBOX_SIZES = ['micro'] as const;
7
+ const SIZES = ['micro'] as const;
7
8
 
8
- const CheckboxComponentWithData: FC<ICheckboxProps<string>> = (props) => {
9
+ declare module './types' {
10
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
11
+ export interface ICheckboxSizes extends IExtendableProps<typeof SIZES> {}
12
+ }
13
+
14
+ const Story: FC<ICheckboxProps<string>> = (args) => {
9
15
  const [isChecked, setIsChecked] = useState(false);
10
16
  const [isSemiChecked, setIsSemiChecked] = useState(false);
11
17
 
12
18
  return (
13
19
  <div style={{ gap: 10, display: 'grid' }}>
14
- <CheckboxComponent
20
+ <Checkbox
15
21
  isChecked={isChecked}
16
22
  isSemiChecked={isSemiChecked}
17
23
  onSelect={({ isSelected }) => {
18
24
  setIsChecked(isSelected);
19
25
  setIsSemiChecked(false);
20
26
  }}
21
- {...props}
27
+ {...args}
22
28
  >
23
29
  Use wrapping paper
24
- </CheckboxComponent>
25
- <CheckboxComponent
30
+ </Checkbox>
31
+ <Checkbox
26
32
  value={undefined}
27
33
  isChecked={isSemiChecked}
28
34
  onSelect={({ isSelected }) => setIsSemiChecked(isSelected)}
29
- {...props}
35
+ {...args}
30
36
  >
31
37
  Is Semi Checked
32
- </CheckboxComponent>
38
+ </Checkbox>
33
39
  </div>
34
40
  );
35
41
  };
36
42
 
37
- const meta: Meta<typeof CheckboxComponentWithData> = {
43
+ const meta: Meta<typeof Story> = {
38
44
  title: 'Controls/Checkbox',
39
- component: CheckboxComponentWithData,
45
+ component: Story,
40
46
  args: {
41
47
  value: 'value',
42
48
  labelPosition: 'right',
@@ -45,23 +51,15 @@ const meta: Meta<typeof CheckboxComponentWithData> = {
45
51
  isDisabled: false,
46
52
  isReadonly: false,
47
53
  },
54
+ argTypes: {
55
+ size: { options: [undefined, ...SIZES], control: 'inline-radio' },
56
+ },
48
57
  parameters: {
49
58
  controls: {
50
- exclude: ['data', 'tweakStyles', 'testId', 'onSelect'],
59
+ exclude: excludeStorybookParams(['isChecked', 'isSemiChecked']),
51
60
  },
52
61
  },
53
- argTypes: {
54
- size: { options: [undefined, ...CHECKBOX_SIZES], control: 'inline-radio' },
55
- },
56
62
  };
57
63
 
58
- declare module './types' {
59
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
60
- export interface ICheckboxSizes extends IExtendableProps<typeof CHECKBOX_SIZES> {}
61
- }
62
-
63
64
  export default meta;
64
-
65
- type Story = StoryObj<typeof CheckboxComponent>;
66
-
67
- export const Default: Story = {};
65
+ export const Default = {};
@@ -1,11 +1,10 @@
1
- import { ComponentStory, ComponentMeta } from '@storybook/react';
1
+ import { type Meta } from '@storybook/react';
2
2
  import { CloseButton } from './CloseButton';
3
3
 
4
- export default {
4
+ const meta: Meta<typeof CloseButton> = {
5
5
  title: 'Buttons/CloseButton',
6
6
  component: CloseButton,
7
- args: {},
8
- argTypes: {},
9
- } as ComponentMeta<typeof CloseButton>;
7
+ };
10
8
 
11
- export const Default: ComponentStory<typeof CloseButton> = (args) => <CloseButton {...args} />;
9
+ export default meta;
10
+ export const Default = {};
@@ -1,7 +1,67 @@
1
- import { Colors } from './Colors';
1
+ import { FC } from 'react';
2
+ import { type Meta } from '@storybook/react';
3
+ import { createThemedStyles, useTheme } from '../../theme';
2
4
 
3
- export default {
5
+ const useStyles = createThemedStyles({
6
+ root: {
7
+ display: 'flex',
8
+ flexWrap: 'wrap',
9
+ },
10
+
11
+ colorCard: {
12
+ width: 120,
13
+ border: 'solid 1px #dde3ed',
14
+ borderRadius: 8,
15
+ color: '#222a37',
16
+ fontSize: 14,
17
+ margin: 6,
18
+ },
19
+
20
+ color: {
21
+ height: 120,
22
+ borderTopLeftRadius: 8,
23
+ borderTopRightRadius: 8,
24
+ },
25
+
26
+ colorName: {
27
+ marginBottom: 6,
28
+ padding: 6,
29
+ overflow: 'hidden',
30
+ },
31
+
32
+ hex: {
33
+ marginTop: 6,
34
+ textTransform: 'uppercase',
35
+ fontWeight: 'bold',
36
+ padding: [0, 6, 6],
37
+ },
38
+ });
39
+
40
+ const Story: FC = () => {
41
+ const classes = useStyles();
42
+ const theme = useTheme();
43
+ const { colors = {} } = theme;
44
+
45
+ return (
46
+ <div className={classes.root}>
47
+ {Object.entries(colors as Record<string, string>).map(([colorName, color]) => {
48
+ const name = colorName.split('_').join(' ').toLowerCase();
49
+ return (
50
+ <div key={colorName} className={classes.colorCard}>
51
+ <div className={classes.color} style={{ backgroundColor: color }} />
52
+ <div className={classes.colorName}>{`${name[0].toUpperCase()}${name.slice(1)}`}</div>
53
+ <div className={classes.hex}>{color}</div>
54
+ </div>
55
+ );
56
+ })}
57
+ </div>
58
+ );
59
+ };
60
+
61
+ const meta: Meta = {
4
62
  title: 'Data Display/Colors',
63
+ component: Story,
5
64
  };
6
65
 
7
- export const Default = (): JSX.Element => <Colors />;
66
+ export default meta;
67
+ export const Default = {};
@@ -1,50 +1,55 @@
1
+ import { FC } from 'react';
1
2
  import { doNothing } from '@true-engineering/true-react-platform-helpers';
2
- import { ComponentStory } from '@storybook/react';
3
+ import { type Meta } from '@storybook/react';
4
+ import { excludeStorybookParams } from '../../helpers';
5
+ import { IExtendableProps } from '../../types';
3
6
  import { Icon, iconsMap } from '../Icon';
4
- import { ControlWrapper } from './ControlWrapper';
7
+ import { ControlWrapper, IControlWrapperProps } from './ControlWrapper';
8
+ import { GROUP_PLACEMENTS } from './constants';
5
9
 
6
- export default {
7
- title: 'Controls/ControlWrapper',
8
- component: ControlWrapper,
9
- };
10
+ const SIZES = ['micro'] as const;
11
+
12
+ declare module './types' {
13
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
14
+ export interface IControlWrapperSizes extends IExtendableProps<typeof SIZES> {}
15
+ }
10
16
 
11
- const Template: ComponentStory<typeof ControlWrapper> = (args) => (
17
+ const Story: FC<IControlWrapperProps> = (args) => (
12
18
  <ControlWrapper {...args} onClear={doNothing}>
13
19
  <div style={{ minWidth: 200, height: 48 }} />
14
20
  </ControlWrapper>
15
21
  );
16
22
 
17
- export const Default = Template.bind({});
18
-
19
- Default.args = {
20
- isInvalid: false,
21
- label: 'Label',
22
- isFocused: false,
23
- isRequired: false,
24
- isLoading: false,
25
- isDisabled: false,
26
- hasValue: false,
27
- icon: [
28
- { iconComponent: <div>Бу</div>, onClick: () => console.log('close'), shouldResetSize: true },
29
- { iconComponent: <Icon type="plus" /> },
30
- { iconComponent: 'search', onClick: () => console.log('search') },
31
- ],
32
- };
33
-
34
- Default.argTypes = {
35
- icon: { control: 'select', options: [undefined, ...Object.keys(iconsMap)] },
36
- groupPlacement: {
37
- control: 'select',
38
- options: [
39
- 'top',
40
- 'bottom',
41
- 'top-left',
42
- 'top-right',
43
- 'bottom-left',
44
- 'bottom-right',
45
- 'left',
46
- 'right',
47
- 'middle',
23
+ const meta: Meta<typeof Story> = {
24
+ title: 'Controls/ControlWrapper',
25
+ component: Story,
26
+ args: {
27
+ label: 'Label',
28
+ isInvalid: false,
29
+ isFocused: false,
30
+ isRequired: false,
31
+ isLoading: false,
32
+ isDisabled: false,
33
+ hasValue: false,
34
+ isActive: false,
35
+ isFullWidth: false,
36
+ icon: [
37
+ { iconComponent: <div>Бу</div>, onClick: () => console.log('close'), shouldResetSize: true },
38
+ { iconComponent: <Icon type="plus" /> },
39
+ { iconComponent: 'search', onClick: () => console.log('search') },
48
40
  ],
49
41
  },
42
+ argTypes: {
43
+ size: { options: [undefined, ...SIZES], control: 'inline-radio' },
44
+ icon: { options: [undefined, ...Object.keys(iconsMap)], control: 'select' },
45
+ groupPlacement: { options: [undefined, ...GROUP_PLACEMENTS], control: 'select' },
46
+ },
47
+ parameters: {
48
+ controls: {
49
+ exclude: excludeStorybookParams(['children']),
50
+ },
51
+ },
50
52
  };
53
+
54
+ export default meta;
55
+ export const Default = {};
@@ -15,7 +15,7 @@ import { IClickHandlerEvent, ICommonProps } from '../../types';
15
15
  import { Icon, IIcon, renderIcon } from '../Icon';
16
16
  import { ThemedPreloader } from '../ThemedPreloader';
17
17
  import { convertToControlWrapperIcon } from './helpers';
18
- import { IControlWrapperIcon, IControlWrapperSize } from './types';
18
+ import { IControlWrapperIcon, IControlWrapperSize, IGroupPlacement } from './types';
19
19
  import { IControlWrapperStyles, useStyles } from './ControlWrapper.styles';
20
20
 
21
21
  export interface IControlWrapperProps extends ICommonProps<IControlWrapperStyles> {
@@ -23,16 +23,7 @@ export interface IControlWrapperProps extends ICommonProps<IControlWrapperStyles
23
23
  label?: ReactNode;
24
24
  icon?: IMaybeArray<IIcon | IControlWrapperIcon>;
25
25
  size?: IControlWrapperSize;
26
- groupPlacement?:
27
- | 'left'
28
- | 'right'
29
- | 'middle'
30
- | 'top'
31
- | 'bottom'
32
- | 'top-left'
33
- | 'top-right'
34
- | 'bottom-left'
35
- | 'bottom-right';
26
+ groupPlacement?: IGroupPlacement;
36
27
  /** @default false */
37
28
  isInvalid?: boolean;
38
29
  /** @default false */
@@ -0,0 +1,11 @@
1
+ export const GROUP_PLACEMENTS = [
2
+ 'left',
3
+ 'right',
4
+ 'middle',
5
+ 'top',
6
+ 'bottom',
7
+ 'top-left',
8
+ 'top-right',
9
+ 'bottom-left',
10
+ 'bottom-right',
11
+ ] as const;
@@ -1,4 +1,5 @@
1
1
  export * from './ControlWrapper';
2
2
  export * from './helpers';
3
+ export * from './constants';
3
4
  export * from './types';
4
5
  export type { IControlWrapperStyles } from './ControlWrapper.styles';
@@ -1,12 +1,15 @@
1
1
  import { type Key } from 'react';
2
2
  import { IClickHandlerEvent } from '../../types';
3
3
  import { IIcon } from '../Icon';
4
+ import { GROUP_PLACEMENTS } from './constants';
4
5
 
5
6
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
6
7
  export interface IControlWrapperSizes {}
7
8
 
8
9
  export type IControlWrapperSize = keyof IControlWrapperSizes;
9
10
 
11
+ export type IGroupPlacement = (typeof GROUP_PLACEMENTS)[number];
12
+
10
13
  // подумать над extend HTMLAttributes<HTMLDivElement>
11
14
  export interface IControlWrapperIcon {
12
15
  key?: Key;
@@ -1,14 +1,9 @@
1
- import { useEffect, useState } from 'react';
1
+ import { FC, useEffect, useState } from 'react';
2
2
  import { format, isValid } from 'date-fns';
3
- import { ComponentStory } from '@storybook/react';
4
- import { DateInput } from './DateInput';
3
+ import { type Meta } from '@storybook/react';
4
+ import { DateInput, IDateInputProps } from './DateInput';
5
5
 
6
- export default {
7
- title: 'Inputs/DateInput',
8
- component: DateInput,
9
- };
10
-
11
- const Template: ComponentStory<typeof DateInput> = ({ date, startDate, endDate, ...args }) => {
6
+ const Story: FC<IDateInputProps> = ({ date, startDate, endDate, ...args }) => {
12
7
  const [value, setValue] = useState(date);
13
8
 
14
9
  const startDateValue = isValid(startDate)
@@ -35,26 +30,14 @@ const Template: ComponentStory<typeof DateInput> = ({ date, startDate, endDate,
35
30
  );
36
31
  };
37
32
 
38
- export const Default = Template.bind({});
39
-
40
- Default.args = {
41
- date: '23.01.2023',
42
- startDate: undefined,
43
- endDate: undefined,
44
- isRange: false,
45
- };
46
-
47
- Default.parameters = {
48
- controls: {
49
- exclude: [
50
- 'data',
51
- 'testId',
52
- 'tabIndex',
53
- 'onChange',
54
- 'onFocus',
55
- 'onBlur',
56
- 'onPaste',
57
- 'onKeyDown',
58
- ],
33
+ const meta: Meta<typeof Story> = {
34
+ title: 'Inputs/DateInput',
35
+ component: Story,
36
+ args: {
37
+ date: '23.01.2023',
38
+ isRange: false,
59
39
  },
60
40
  };
41
+
42
+ export default meta;
43
+ export const Default = {};
@@ -1,7 +1,7 @@
1
- import { useState } from 'react';
1
+ import { FC, useState } from 'react';
2
2
  import { ru } from 'date-fns/locale';
3
- import { ComponentStory } from '@storybook/react';
4
- import { DatePicker } from './DatePicker';
3
+ import { type Meta } from '@storybook/react';
4
+ import { DatePicker, IDatePickerProps } from './DatePicker';
5
5
 
6
6
  const months = [
7
7
  'Январь',
@@ -18,19 +18,9 @@ const months = [
18
18
  'Декабрь',
19
19
  ];
20
20
 
21
- export default {
22
- title: 'Inputs/DatePicker',
23
- component: DatePicker,
24
- };
25
-
26
- const Template: ComponentStory<typeof DatePicker> = (args) => {
21
+ const Story: FC<IDatePickerProps> = (args) => {
27
22
  const [date, setDate] = useState<Date | null>(null);
28
23
 
29
- const [startDate, setStartDate] = useState<Date | null>(
30
- args.startDate ? new Date(args.startDate) : null,
31
- );
32
- const [endDate, setEndDate] = useState<Date | null>(args.endDate ? new Date(args.endDate) : null);
33
-
34
24
  return (
35
25
  <div
36
26
  style={{
@@ -50,52 +40,25 @@ const Template: ComponentStory<typeof DatePicker> = (args) => {
50
40
  testId="datepicker"
51
41
  months={months}
52
42
  selectedDate={date}
53
- startDate={startDate}
54
- endDate={endDate}
55
43
  minDate={new Date()}
56
44
  onChangeDate={setDate}
57
- onChangeRange={(dates) => {
58
- setStartDate(dates?.[0] ?? null);
59
- setEndDate(dates?.[1] ?? null);
60
- }}
61
45
  />
62
46
  </div>
63
47
  </div>
64
48
  );
65
49
  };
66
50
 
67
- export const Default = Template.bind({});
68
-
69
- Default.args = {
70
- label: 'Дата',
71
- isRange: false,
72
- isClearable: true,
73
- shouldRenderPopperInBody: false,
74
- popperPlacement: 'bottom-start',
75
- };
76
-
77
- Default.argTypes = {
78
- popperPlacement: {
79
- options: [
80
- 'bottom-start',
81
- 'bottom',
82
- 'bottom-end',
83
- 'top-start',
84
- 'top',
85
- 'top-end',
86
- 'right-start',
87
- 'right',
88
- 'right-end',
89
- 'left-start',
90
- 'left',
91
- 'left-end',
92
- ],
93
- control: 'select',
51
+ const meta: Meta<typeof Story> = {
52
+ title: 'Inputs/DatePicker',
53
+ component: Story,
54
+ args: {
55
+ label: 'Дата',
56
+ isRange: false,
57
+ isClearable: true,
58
+ shouldRenderPopperInBody: false,
59
+ popperPlacement: 'bottom-start',
94
60
  },
95
61
  };
96
62
 
97
- Default.parameters = {
98
- controls: {
99
- exclude: ['data', 'testId', 'tabIndex', 'onFocus', 'onBlur', 'onPaste', 'onKeyDown'],
100
- },
101
- };
63
+ export default meta;
64
+ export const Default = {};