@max-ts/components 0.0.2 → 0.1.0

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 (214) hide show
  1. package/.storybook/main.ts +14 -14
  2. package/.turbo/turbo-build.log +13 -495
  3. package/.turbo/turbo-type$colon$check.log +1 -756
  4. package/CHANGELOG.md +6 -0
  5. package/dist/components/Autocomplete/styles.d.ts +1 -1
  6. package/dist/components/Button/Button.d.ts +4 -4
  7. package/dist/components/Button/useLogic/useLogic.d.ts +1 -1
  8. package/dist/components/ConfirmDialog/ConfirmDialog.d.ts +37 -0
  9. package/dist/components/ConfirmDialog/index.d.ts +1 -0
  10. package/dist/components/ConfirmDialog/styles.d.ts +9 -0
  11. package/dist/components/ConfirmDialog/useLogic/index.d.ts +1 -0
  12. package/dist/components/ConfirmDialog/useLogic/useLogic.d.ts +10 -0
  13. package/dist/components/DataGrid/Row/NestedChildren/styles.d.ts +1 -1
  14. package/dist/components/DataGrid/Row/styles.d.ts +1 -1
  15. package/dist/components/DropdownButton/DropdownButton.d.ts +9 -0
  16. package/dist/components/DropdownButton/index.d.ts +1 -0
  17. package/dist/components/Filename/Filename.d.ts +21 -0
  18. package/dist/components/Filename/index.d.ts +1 -0
  19. package/dist/components/Filename/styles.d.ts +17 -0
  20. package/dist/components/Filename/useLogic/index.d.ts +1 -0
  21. package/dist/components/Filename/useLogic/useLogic.d.ts +16 -0
  22. package/dist/components/Filename/useLogic/utils/findExtension/constants.d.ts +1 -0
  23. package/dist/components/Filename/useLogic/utils/findExtension/findExtension.d.ts +1 -0
  24. package/dist/components/Filename/useLogic/utils/findExtension/index.d.ts +1 -0
  25. package/dist/components/Filename/useLogic/utils/index.d.ts +1 -0
  26. package/dist/components/Filename/useLogic/utils/truncateString/constants.d.ts +1 -0
  27. package/dist/components/Filename/useLogic/utils/truncateString/index.d.ts +1 -0
  28. package/dist/components/Filename/useLogic/utils/truncateString/truncateString.d.ts +4 -0
  29. package/dist/components/FormLabel/FormLabel.d.ts +4 -0
  30. package/dist/components/FormLabel/index.d.ts +1 -0
  31. package/dist/components/FormLabel/styles.d.ts +1 -0
  32. package/dist/components/IconButton/IconButton.d.ts +2 -2
  33. package/dist/components/IconButton/styles.d.ts +2 -2
  34. package/dist/components/ListItemButton/ListItemButton.d.ts +2 -2
  35. package/dist/components/MenuItem/MenuItem.d.ts +1 -1
  36. package/dist/components/MenuList/types.d.ts +2 -2
  37. package/dist/components/NavMenu/Item/ItemButton/ItemButton.d.ts +1 -1
  38. package/dist/components/NavMenu/Item/ItemButton/styles.d.ts +1 -1
  39. package/dist/components/ProgressBar/ProgressBar.d.ts +12 -0
  40. package/dist/components/ProgressBar/index.d.ts +1 -0
  41. package/dist/components/Radio/Icon/Icon.d.ts +6 -0
  42. package/dist/components/Radio/Icon/index.d.ts +1 -0
  43. package/dist/components/Radio/Radio.d.ts +9 -0
  44. package/dist/components/Radio/constants.d.ts +8 -0
  45. package/dist/components/Radio/index.d.ts +1 -0
  46. package/dist/components/Radio/styles.d.ts +5 -0
  47. package/dist/components/RadioField/RadioField.d.ts +25 -0
  48. package/dist/components/RadioField/index.d.ts +1 -0
  49. package/dist/components/RadioField/styles.d.ts +2 -0
  50. package/dist/components/RadioGroup/RadioGroup.d.ts +30 -0
  51. package/dist/components/RadioGroup/RadioGroupContext/RadioGroupContext.d.ts +4 -0
  52. package/dist/components/RadioGroup/RadioGroupContext/RadioGroupContextProvider/RadioGroupContextProvider.d.ts +6 -0
  53. package/dist/components/RadioGroup/RadioGroupContext/RadioGroupContextProvider/index.d.ts +1 -0
  54. package/dist/components/RadioGroup/RadioGroupContext/index.d.ts +2 -0
  55. package/dist/components/RadioGroup/index.d.ts +2 -0
  56. package/dist/components/RadioGroupField/RadioGroupField.d.ts +8 -0
  57. package/dist/components/RadioGroupField/index.d.ts +1 -0
  58. package/dist/components/SearchField/styles.d.ts +1 -1
  59. package/dist/components/Select/styles.d.ts +2 -2
  60. package/dist/components/Skeleton/Skeleton.d.ts +14 -0
  61. package/dist/components/Skeleton/index.d.ts +1 -0
  62. package/dist/components/Skeleton/styles.d.ts +1 -0
  63. package/dist/components/Switch/Switch.d.ts +4 -0
  64. package/dist/components/Switch/index.d.ts +1 -0
  65. package/dist/components/Switch/styles.d.ts +1 -0
  66. package/dist/components/Tab/Tab.d.ts +7 -0
  67. package/dist/components/Tab/index.d.ts +1 -0
  68. package/dist/components/Tab/styles.d.ts +1 -0
  69. package/dist/components/Tabs/Tabs.d.ts +13 -0
  70. package/dist/components/Tabs/index.d.ts +1 -0
  71. package/dist/components/Tabs/styles.d.ts +2 -0
  72. package/dist/components/TextArea/TextArea.d.ts +3 -0
  73. package/dist/components/TextArea/index.d.ts +1 -0
  74. package/dist/hooks/index.d.ts +1 -0
  75. package/dist/hooks/useToggle/index.d.ts +1 -0
  76. package/dist/hooks/useToggle/useToggle.d.ts +43 -0
  77. package/dist/index.js +2 -2
  78. package/dist/index.mjs +150 -150
  79. package/package.json +1 -1
  80. package/rslib.config.ts +26 -26
  81. package/src/components/Accordion/Accordion.stories.tsx +2 -0
  82. package/src/components/ActionCell/ActionCell.stories.tsx +1 -0
  83. package/src/components/ActionCell/MainAction/MainAction.tsx +1 -0
  84. package/src/components/AsyncAutocomplete/AsyncAutocomplete.stories.tsx +1 -0
  85. package/src/components/Autocomplete/Autocomplete.stories.tsx +1 -0
  86. package/src/components/Badge/Badge.stories.tsx +1 -0
  87. package/src/components/BottomDrawer/BottomDrawer.stories.tsx +2 -1
  88. package/src/components/Button/Button.stories.tsx +2 -1
  89. package/src/components/Button/Button.tsx +9 -10
  90. package/src/components/Button/useLogic/useLogic.ts +2 -5
  91. package/src/components/Checkbox/Checkbox.stories.tsx +1 -3
  92. package/src/components/CheckboxField/CheckboxField.stories.tsx +1 -0
  93. package/src/components/Chevron/Chevron.stories.tsx +1 -0
  94. package/src/components/CircularProgress/CircularProgress.stories.tsx +1 -0
  95. package/src/components/Collapse/Collapse.stories.tsx +1 -0
  96. package/src/components/ConfirmAction/ConfirmAction.stories.tsx +1 -3
  97. package/src/components/ConfirmDialog/ConfirmDialog.stories.tsx +69 -0
  98. package/src/components/ConfirmDialog/ConfirmDialog.tsx +83 -0
  99. package/src/components/ConfirmDialog/index.ts +1 -0
  100. package/src/components/ConfirmDialog/styles.ts +8 -0
  101. package/src/components/ConfirmDialog/useLogic/index.ts +1 -0
  102. package/src/components/ConfirmDialog/useLogic/useLogic.ts +23 -0
  103. package/src/components/ContentState/ContentState.stories.tsx +1 -0
  104. package/src/components/CopyTypography/CopyTypography.stories.tsx +1 -2
  105. package/src/components/DataGrid/DataGrid.stories.tsx +1 -0
  106. package/src/components/DataGridActionCell/DataGridActionCell.stories.tsx +1 -0
  107. package/src/components/DataGridPagination/DataGridPagination.stories.tsx +1 -0
  108. package/src/components/Description/Description.stories.tsx +1 -0
  109. package/src/components/DescriptionList/DescriptionList.stories.tsx +1 -0
  110. package/src/components/Dialog/Dialog.stories.tsx +1 -0
  111. package/src/components/DialogActions/DialogActions.stories.tsx +1 -3
  112. package/src/components/DialogContent/DialogContent.stories.tsx +1 -3
  113. package/src/components/DialogContentText/DialogContentText.stories.tsx +1 -0
  114. package/src/components/DialogHeader/DialogHeader.stories.tsx +1 -0
  115. package/src/components/Divider/Divider.stories.tsx +1 -0
  116. package/src/components/DropdownButton/DropdownButton.stories.tsx +191 -0
  117. package/src/components/DropdownButton/DropdownButton.tsx +46 -0
  118. package/src/components/DropdownButton/index.ts +1 -0
  119. package/src/components/ErrorBoundary/ErrorBoundary.stories.tsx +1 -0
  120. package/src/components/Filename/Filename.stories.tsx +244 -0
  121. package/src/components/Filename/Filename.tsx +57 -0
  122. package/src/components/Filename/index.ts +1 -0
  123. package/src/components/Filename/styles.ts +18 -0
  124. package/src/components/Filename/useLogic/index.ts +1 -0
  125. package/src/components/Filename/useLogic/useLogic.ts +36 -0
  126. package/src/components/Filename/useLogic/utils/findExtension/constants.ts +16 -0
  127. package/src/components/Filename/useLogic/utils/findExtension/findExtension.ts +17 -0
  128. package/src/components/Filename/useLogic/utils/findExtension/index.ts +1 -0
  129. package/src/components/Filename/useLogic/utils/index.ts +1 -0
  130. package/src/components/Filename/useLogic/utils/truncateString/constants.ts +1 -0
  131. package/src/components/Filename/useLogic/utils/truncateString/index.ts +1 -0
  132. package/src/components/Filename/useLogic/utils/truncateString/truncateString.ts +24 -0
  133. package/src/components/FormLabel/FormLabel.tsx +11 -0
  134. package/src/components/FormLabel/index.ts +1 -0
  135. package/src/components/FormLabel/styles.ts +6 -0
  136. package/src/components/GuidTypography/GuidTypography.stories.tsx +1 -0
  137. package/src/components/IconButton/IconButton.stories.tsx +1 -1
  138. package/src/components/IconButton/IconButton.tsx +11 -16
  139. package/src/components/IconButton/styles.ts +24 -24
  140. package/src/components/IconDropdownButton/IconDropdownButton.stories.tsx +1 -0
  141. package/src/components/InternalErrorPlaceholder/InternalErrorPlaceholder.stories.tsx +1 -0
  142. package/src/components/Link/Link.stories.tsx +1 -0
  143. package/src/components/List/List.stories.tsx +1 -0
  144. package/src/components/ListItem/ListItem.stories.tsx +1 -0
  145. package/src/components/ListItemButton/ListItemButton.stories.tsx +1 -0
  146. package/src/components/ListItemButton/ListItemButton.tsx +3 -9
  147. package/src/components/ListItemIcon/ListItemIcon.stories.tsx +1 -0
  148. package/src/components/ListItemText/ListItemText.stories.tsx +1 -0
  149. package/src/components/ListSubheader/ListSubheader.stories.tsx +1 -0
  150. package/src/components/Menu/Menu.stories.tsx +1 -0
  151. package/src/components/MenuItem/MenuItem.stories.tsx +1 -0
  152. package/src/components/MenuItem/MenuItem.tsx +1 -2
  153. package/src/components/MenuList/MenuList.stories.tsx +1 -0
  154. package/src/components/MenuList/types.ts +3 -8
  155. package/src/components/NavMenu/Item/ItemButton/ItemButton.tsx +1 -2
  156. package/src/components/NavMenu/NavMenu.stories.tsx +1 -0
  157. package/src/components/OutdatedReleasePlaceholder/OutdatedReleasePlaceholder.stories.tsx +1 -0
  158. package/src/components/OverflowTypography/OverflowTypography.stories.tsx +1 -8
  159. package/src/components/Pagination/Pagination.stories.tsx +1 -0
  160. package/src/components/Placeholder/Placeholder.stories.tsx +1 -0
  161. package/src/components/Popover/Popover.stories.tsx +1 -0
  162. package/src/components/ProgressBar/ProgressBar.stories.tsx +31 -0
  163. package/src/components/ProgressBar/ProgressBar.tsx +26 -0
  164. package/src/components/ProgressBar/index.ts +1 -0
  165. package/src/components/Radio/Icon/Icon.tsx +37 -0
  166. package/src/components/Radio/Icon/index.ts +1 -0
  167. package/src/components/Radio/Radio.stories.tsx +32 -0
  168. package/src/components/Radio/Radio.tsx +24 -0
  169. package/src/components/Radio/constants.ts +9 -0
  170. package/src/components/Radio/index.ts +1 -0
  171. package/src/components/Radio/styles.ts +70 -0
  172. package/src/components/RadioField/RadioField.stories.tsx +74 -0
  173. package/src/components/RadioField/RadioField.tsx +55 -0
  174. package/src/components/RadioField/index.ts +1 -0
  175. package/src/components/RadioField/styles.ts +10 -0
  176. package/src/components/RadioGroup/RadioGroup.stories.tsx +60 -0
  177. package/src/components/RadioGroup/RadioGroup.tsx +79 -0
  178. package/src/components/RadioGroup/RadioGroupContext/RadioGroupContext.ts +9 -0
  179. package/src/components/RadioGroup/RadioGroupContext/RadioGroupContextProvider/RadioGroupContextProvider.tsx +18 -0
  180. package/src/components/RadioGroup/RadioGroupContext/RadioGroupContextProvider/index.ts +1 -0
  181. package/src/components/RadioGroup/RadioGroupContext/index.ts +3 -0
  182. package/src/components/RadioGroup/index.ts +3 -0
  183. package/src/components/RadioGroupField/RadioGroupField.tsx +17 -0
  184. package/src/components/RadioGroupField/index.ts +1 -0
  185. package/src/components/Select/Select.stories.tsx +0 -4
  186. package/src/components/Skeleton/Skeleton.stories.tsx +78 -0
  187. package/src/components/Skeleton/Skeleton.tsx +31 -0
  188. package/src/components/Skeleton/index.ts +1 -0
  189. package/src/components/Skeleton/styles.ts +16 -0
  190. package/src/components/Switch/Switch.stories.tsx +179 -0
  191. package/src/components/Switch/Switch.tsx +14 -0
  192. package/src/components/Switch/index.ts +1 -0
  193. package/src/components/Switch/styles.ts +14 -0
  194. package/src/components/Tab/Tab.stories.tsx +53 -0
  195. package/src/components/Tab/Tab.tsx +20 -0
  196. package/src/components/Tab/index.ts +1 -0
  197. package/src/components/Tab/styles.ts +22 -0
  198. package/src/components/Tabs/Tabs.stories.tsx +74 -0
  199. package/src/components/Tabs/Tabs.tsx +27 -0
  200. package/src/components/Tabs/index.ts +1 -0
  201. package/src/components/Tabs/styles.ts +20 -0
  202. package/src/components/Tag/Tag.stories.tsx +1 -1
  203. package/src/components/TagBadge/TagBadge.stories.tsx +1 -5
  204. package/src/components/TextArea/TextArea.stories.tsx +81 -0
  205. package/src/components/TextArea/TextArea.tsx +12 -0
  206. package/src/components/TextArea/index.ts +1 -0
  207. package/src/components/TextField/TextField.stories.tsx +1 -4
  208. package/src/components/Tooltip/Tooltip.stories.tsx +1 -4
  209. package/src/components/Typography/Typography.stories.tsx +2 -4
  210. package/src/hooks/index.ts +1 -0
  211. package/src/hooks/useToggle/index.ts +1 -0
  212. package/src/hooks/useToggle/useToggle.ts +76 -0
  213. package/test.tsx +1 -0
  214. package/tsconfig.json +3 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@max-ts/components",
3
- "version": "0.0.2",
3
+ "version": "0.1.0",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "publishConfig": {
package/rslib.config.ts CHANGED
@@ -1,32 +1,32 @@
1
- import { resolve } from 'node:path';
2
1
  import { pluginReact } from '@rsbuild/plugin-react';
3
2
  import { defineConfig } from '@rslib/core';
4
3
  import { pluginDts } from 'rsbuild-plugin-dts';
5
4
 
6
5
  export default defineConfig({
7
- lib: [
8
- {
9
- format: 'cjs',
10
- bundle: true,
11
- dts: false,
12
- },
13
- {
14
- format: 'esm',
15
- bundle: true,
16
- dts: false,
17
- },
18
- ],
19
- source: {
20
- entry: {
21
- index: './src/index.ts',
22
- },
23
- },
24
- output: {
25
- cleanDistPath: true,
26
- minify: true,
27
- externals: ['react', 'react-dom'],
28
- target: 'web',
29
- injectStyles: true,
30
- },
31
- plugins: [pluginDts(), pluginReact()],
6
+ mode: 'production',
7
+ lib: [
8
+ {
9
+ format: 'cjs',
10
+ bundle: true,
11
+ dts: true,
12
+ },
13
+ {
14
+ format: 'esm',
15
+ bundle: true,
16
+ dts: true,
17
+ },
18
+ ],
19
+ source: {
20
+ entry: {
21
+ index: './src/index.ts',
22
+ },
23
+ },
24
+ output: {
25
+ cleanDistPath: true,
26
+ minify: true,
27
+ externals: ['react', 'react-dom'],
28
+ target: 'web',
29
+ injectStyles: true,
30
+ },
31
+ plugins: [pluginDts(), pluginReact()],
32
32
  });
@@ -7,6 +7,8 @@ import { Button } from '../Button';
7
7
  import { Container } from '../Container';
8
8
  import { Accordion } from './Accordion';
9
9
 
10
+ import type React from 'react';
11
+
10
12
  /**
11
13
  * Accordion - компонент, позволяющий скрывать контент под заголовком
12
14
  *
@@ -4,6 +4,7 @@ import { useEffect, useState } from 'react';
4
4
  import { DataGrid, type DataGridColumns } from '../DataGrid';
5
5
 
6
6
  import { Eye, Save, Send, Trash } from 'lucide-react';
7
+ import React from 'react';
7
8
  import { ActionCell, type Actions } from './ActionCell';
8
9
 
9
10
  /**
@@ -36,6 +36,7 @@ export const MainAction = <T,>({
36
36
  disabled={isDisabled || disabled}
37
37
  >
38
38
  {actions.map(
39
+ // @ts-ignore
39
40
  ({ name: nestedActionName, onClick: onClickNested, ...props }) => (
40
41
  <MenuItem
41
42
  {...props}
@@ -2,6 +2,7 @@ import type { Meta } from '@storybook/react';
2
2
  import { type SyntheticEvent, useState } from 'react';
3
3
 
4
4
  import { styled } from '@mui/material';
5
+ import React from 'react';
5
6
  import {
6
7
  AsyncAutocomplete,
7
8
  type AsyncAutocompleteProps,
@@ -7,6 +7,7 @@ import { Tag } from '../Tag';
7
7
  import { Tooltip } from '../Tooltip';
8
8
 
9
9
  import { styled } from '@mui/material';
10
+ import React from 'react';
10
11
  import { Autocomplete } from './Autocomplete';
11
12
 
12
13
  const meta: Meta<typeof Autocomplete> = {
@@ -3,6 +3,7 @@ import { useState } from 'react';
3
3
 
4
4
  import { Button } from '../Button';
5
5
 
6
+ import React from 'react';
6
7
  import { Container } from '../Container';
7
8
  import { Badge } from './Badge';
8
9
 
@@ -4,6 +4,7 @@ import { useState } from 'react';
4
4
  import { Button } from '../Button';
5
5
 
6
6
  import { styled } from '@mui/material';
7
+ import type React from 'react';
7
8
  import { Container } from '../Container';
8
9
  import { BottomDrawer } from './BottomDrawer';
9
10
 
@@ -18,7 +19,7 @@ const Row = styled('div')`
18
19
  `;
19
20
 
20
21
  const renderRows = (count: number) => {
21
- const rows = [];
22
+ const rows: React.ReactElement[] = [];
22
23
 
23
24
  for (let i = 0; i < count; i++) {
24
25
  rows.push(
@@ -8,6 +8,7 @@ import { DialogContent } from '../DialogContent';
8
8
  import { DialogTitle } from '../DialogTitle';
9
9
 
10
10
  import { ChevronDown, MessageCircle, ThumbsUp } from 'lucide-react';
11
+ import React from 'react';
11
12
  import { Container } from '../Container';
12
13
  import { Button } from './Button';
13
14
 
@@ -82,7 +83,7 @@ export const Disabled = () => (
82
83
  <Button disabled variant='link'>
83
84
  Link
84
85
  </Button>
85
- <Button disabled variant='text'>
86
+ <Button disabled variant='text' component={Link}>
86
87
  Text
87
88
  </Button>
88
89
  </ButtonsContainer>
@@ -1,5 +1,8 @@
1
- import type { ButtonProps as MuiButtonProps } from '@mui/material';
2
- import type { ReactNode } from 'react';
1
+ import type {
2
+ ButtonTypeMap,
3
+ ButtonProps as MuiButtonProps,
4
+ } from '@mui/material';
5
+ import type { ElementType, ReactNode } from 'react';
3
6
 
4
7
  import type { WithoutEmotionSpecific } from '../types';
5
8
 
@@ -9,11 +12,8 @@ import { ButtonColors, ButtonVariants } from './enums';
9
12
  import { StyledButton, StyledCircularProgress } from './styles';
10
13
  import { useLogic } from './useLogic';
11
14
 
12
- export type ButtonProps<
13
- RootComponent extends React.ElementType,
14
- AdditionalProps = object,
15
- > = Omit<
16
- WithoutEmotionSpecific<MuiButtonProps<RootComponent, AdditionalProps>>,
15
+ export type ButtonProps<RootComponent extends ElementType> = Omit<
16
+ WithoutEmotionSpecific<MuiButtonProps<RootComponent>>,
17
17
  'variant' | 'color'
18
18
  > & {
19
19
  /**
@@ -48,10 +48,9 @@ export type ButtonProps<
48
48
  };
49
49
 
50
50
  export const Button = <
51
- RootComponent extends React.ElementType,
52
- AdditionalProps,
51
+ RootComponent extends React.ElementType = ButtonTypeMap['defaultComponent'],
53
52
  >(
54
- props: ButtonProps<RootComponent, AdditionalProps>,
53
+ props: ButtonProps<RootComponent>,
55
54
  ) => {
56
55
  const { loadingIndicatorColor } = useLogic(props);
57
56
  const {
@@ -4,12 +4,9 @@ import { CircularProgressColors } from '../../CircularProgress/constants';
4
4
  import type { ButtonProps } from '../Button';
5
5
  import { ButtonVariants } from '../enums';
6
6
 
7
- export const useLogic = <
8
- RootComponent extends React.ElementType,
9
- AdditionalProps,
10
- >({
7
+ export const useLogic = <RootComponent extends React.ElementType>({
11
8
  variant,
12
- }: ButtonProps<RootComponent, AdditionalProps>) => {
9
+ }: ButtonProps<RootComponent>) => {
13
10
  const loadingIndicatorColor = useMemo(() => {
14
11
  if (variant !== ButtonVariants.Contained) {
15
12
  return CircularProgressColors.PRIMARY;
@@ -9,14 +9,12 @@ import { DialogTitle } from '../DialogTitle';
9
9
  import { FormControlLabel } from '../FormControlLabel';
10
10
  import { TextField } from '../TextField';
11
11
 
12
+ import React from 'react';
12
13
  import { Container } from '../Container';
13
14
  import { Checkbox } from './Checkbox';
14
15
 
15
16
  /**
16
17
  * Checkbox — это элемент графического пользовательского интерфейса, позволяющий пользователю управлять параметром с двумя состояниями — ☑ включено и ☐ отключено.
17
- *
18
- * ### [Figma](https://www.figma.com/design/3ghN4WjSgkKx5rETR64jqh/Sirius-Design-System-(АКТУАЛЬНО)?node-id=322-5837&t=NrGSkPDdR1WstBqT-0)
19
- * ### [Guide]()
20
18
  */
21
19
 
22
20
  const meta: Meta<typeof Checkbox> = {
@@ -1,5 +1,6 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
2
 
3
+ import React from 'react';
3
4
  import { CheckboxField } from './CheckboxField';
4
5
 
5
6
  const meta: Meta<typeof CheckboxField> = {
@@ -3,6 +3,7 @@ import { useState } from 'react';
3
3
 
4
4
  import { Button } from '../Button';
5
5
 
6
+ import React from 'react';
6
7
  import { Chevron } from './Chevron';
7
8
 
8
9
  const meta: Meta<typeof Chevron> = {
@@ -1,5 +1,6 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
2
 
3
+ import React from 'react';
3
4
  import { CircularProgress } from './CircularProgress';
4
5
 
5
6
  const meta: Meta<typeof CircularProgress> = {
@@ -8,6 +8,7 @@ import { ListItemIcon } from '../ListItemIcon';
8
8
  import { ListItemText } from '../ListItemText';
9
9
 
10
10
  import { House } from 'lucide-react';
11
+ import React from 'react';
11
12
  import { Collapse } from './Collapse';
12
13
 
13
14
  const meta: Meta<typeof Collapse> = {
@@ -3,13 +3,11 @@ import type { Meta, StoryObj } from '@storybook/react';
3
3
  import { IconButton } from '../IconButton';
4
4
 
5
5
  import { Trash } from 'lucide-react';
6
+ import React from 'react';
6
7
  import { ConfirmAction } from './ConfirmAction';
7
8
 
8
9
  /**
9
10
  * Используется для подтверждения действия пользователя.
10
- *
11
- * ### [Figma](https://www.figma.com/design/3ghN4WjSgkKx5rETR64jqh/Sirius-Design-System-(%D0%90%D0%9A%D0%A2%D0%A3%D0%90%D0%9B%D0%AC%D0%9D%D0%9E)?node-id=30167-461154&node-type=frame&t=GgA8Lk5RPtTzJk3I-0)
12
- * ### [Guide]()
13
11
  */
14
12
  const meta: Meta<typeof ConfirmAction> = {
15
13
  title: 'Components/ConfirmAction',
@@ -0,0 +1,69 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import React from 'react';
3
+
4
+ import { Button } from '../Button';
5
+
6
+ import { useToggle } from '../../hooks';
7
+ import { ConfirmDialog } from './ConfirmDialog';
8
+
9
+ /**
10
+ * Необходим для подтверждения действия пользователем.
11
+ */
12
+ const meta: Meta<typeof ConfirmDialog> = {
13
+ title: 'Components/ConfirmDialog',
14
+ component: ConfirmDialog,
15
+ };
16
+
17
+ export default meta;
18
+
19
+ type Story = StoryObj<typeof ConfirmDialog>;
20
+
21
+ export const Interaction: Story = {
22
+ args: {
23
+ open: true,
24
+ title: 'Подверждение',
25
+ onClose: () => {},
26
+ actions: {
27
+ confirm: {
28
+ text: 'Да',
29
+ },
30
+ },
31
+ },
32
+ parameters: {
33
+ docs: {
34
+ disable: true,
35
+ },
36
+ },
37
+ };
38
+
39
+ export const Example = () => {
40
+ const [isActive, handleOpen, handleClose] = useToggle();
41
+ const [loading, setLoading] = React.useState(false);
42
+
43
+ const handleConfirm = () => {
44
+ setLoading(true);
45
+
46
+ return setTimeout(() => {
47
+ setLoading(false);
48
+ handleClose();
49
+ }, 1000);
50
+ };
51
+
52
+ return (
53
+ <div>
54
+ <Button variant='contained' onClick={handleOpen}>
55
+ ConfirmDialog
56
+ </Button>
57
+ <ConfirmDialog
58
+ open={isActive}
59
+ title='Подверждение'
60
+ description='Вы подтверждаете действие?'
61
+ onClose={handleClose}
62
+ actions={{
63
+ confirm: { text: 'Да', onClick: handleConfirm, loading },
64
+ cancel: { text: 'Нет' },
65
+ }}
66
+ />
67
+ </div>
68
+ );
69
+ };
@@ -0,0 +1,83 @@
1
+ import type { ReactNode } from 'react';
2
+
3
+ import { Button, type ButtonProps } from '../Button';
4
+ import { Dialog, type DialogProps } from '../Dialog';
5
+ import { DialogActions } from '../DialogActions';
6
+ import { DialogContent } from '../DialogContent';
7
+ import { DialogContentText } from '../DialogContentText';
8
+
9
+ import { CancelButton } from './styles';
10
+ import { useLogic } from './useLogic';
11
+
12
+ export type ConfirmDialogProps = {
13
+ /**
14
+ * Заголовок диалога
15
+ */
16
+ title: string;
17
+ /**
18
+ * Вспомогательный текст
19
+ */
20
+ description?: ReactNode;
21
+ /**
22
+ * Функция для закрытия диалога
23
+ */
24
+ onClose: () => void;
25
+ /**
26
+ * Параметры кнопок действий
27
+ */
28
+ actions: {
29
+ /**
30
+ * Параметры кнопки подтверждения
31
+ * @example <ConfirmDialog actions={{ confirm: { text: 'Название кнопки' }}}
32
+ */
33
+ confirm: ButtonProps<'button'> & { text: string };
34
+ /**
35
+ * Параметры кнопки отмены. В качестве действия onClick по-умолчанию используется пропс onClose
36
+ * @example <ConfirmDialog actions={{ cancel: { text: 'Название кнопки' }}}
37
+ */
38
+ cancel?: ButtonProps<'button'> & { text: string };
39
+ };
40
+ } & Pick<
41
+ DialogProps,
42
+ | 'aria-labelledby'
43
+ | 'aria-describedby'
44
+ | 'disableBackdropClick'
45
+ | 'disablePortal'
46
+ | 'disableScrollLock'
47
+ | 'hideBackdrop'
48
+ | 'keepMounted'
49
+ | 'open'
50
+ >;
51
+
52
+ export const ConfirmDialog = (props: ConfirmDialogProps) => {
53
+ const { isShowCancelButton, cancelButtonProps } = useLogic(props);
54
+
55
+ const { open, title, description, actions, onClose, ...restProps } = props;
56
+
57
+ const { text: confirmText, ...confirmButtonProps } = actions.confirm;
58
+
59
+ const {
60
+ text: cancelText,
61
+ variant,
62
+ onClick,
63
+ ...restCancelProps
64
+ } = actions.cancel || {};
65
+
66
+ return (
67
+ <Dialog title={title} open={open} onClose={onClose} {...restProps}>
68
+ {description && (
69
+ <DialogContent>
70
+ <DialogContentText>{description}</DialogContentText>
71
+ </DialogContent>
72
+ )}
73
+ <DialogActions>
74
+ {isShowCancelButton && (
75
+ <CancelButton {...restCancelProps} {...cancelButtonProps}>
76
+ {cancelText}
77
+ </CancelButton>
78
+ )}
79
+ <Button {...confirmButtonProps}>{confirmText}</Button>
80
+ </DialogActions>
81
+ </Dialog>
82
+ );
83
+ };
@@ -0,0 +1 @@
1
+ export * from './ConfirmDialog';
@@ -0,0 +1,8 @@
1
+ import { styled } from '@mui/material';
2
+ import { Button } from '../Button';
3
+
4
+ export const CancelButton = styled(Button)`
5
+ ${({ theme }) => theme.breakpoints.down('sm')} {
6
+ order: 1;
7
+ }
8
+ `;
@@ -0,0 +1 @@
1
+ export * from './useLogic';
@@ -0,0 +1,23 @@
1
+ import { useViewportType } from '../../../hooks';
2
+ import type { ConfirmDialogProps } from '../ConfirmDialog';
3
+
4
+ type UseLogicParams = ConfirmDialogProps;
5
+
6
+ export const useLogic = ({ actions, onClose }: UseLogicParams) => {
7
+ const { isMobile } = useViewportType();
8
+ const { cancel } = actions;
9
+
10
+ const isShowCancelButton = Boolean(cancel);
11
+
12
+ const cancelVariant = isMobile ? 'light' : 'text';
13
+ const handleCancelClick = cancel?.onClick || onClose;
14
+
15
+ const { variant = cancelVariant } = cancel || {};
16
+
17
+ const cancelButtonProps = {
18
+ variant,
19
+ onClick: handleCancelClick,
20
+ };
21
+
22
+ return { isShowCancelButton, cancelButtonProps };
23
+ };
@@ -10,6 +10,7 @@ import { ConfigProvider } from '../ConfigProvider';
10
10
  import { TextField } from '../TextField';
11
11
 
12
12
  import { styled } from '@mui/material';
13
+ import React from 'react';
13
14
  import { Container } from '../Container';
14
15
  import { ContentState } from './ContentState';
15
16
 
@@ -5,11 +5,10 @@ import { Typography } from '../Typography';
5
5
  import { OverflowTypography } from '../OverflowTypography';
6
6
 
7
7
  import { styled } from '@mui/material';
8
+ import React from 'react';
8
9
  import { CopyTypography } from './CopyTypography';
9
10
 
10
11
  /**
11
- * ### [Figma]()
12
- * ### [Guide]()
13
12
  * Компонент позволяет скопировать содержимое в буфер обмена
14
13
  */
15
14
 
@@ -10,6 +10,7 @@ import {
10
10
  import { DataGridPagination } from '../DataGridPagination';
11
11
 
12
12
  import { Eye, Pencil, Send, Trash } from 'lucide-react';
13
+ import React from 'react';
13
14
  import { DataGrid } from './DataGrid';
14
15
  import {
15
16
  makeColumns,
@@ -5,6 +5,7 @@ import { useEffect, useMemo, useState } from 'react';
5
5
  import { DataGrid, type DataGridColumns } from '../DataGrid';
6
6
 
7
7
  import { Pencil, Save, Trash } from 'lucide-react';
8
+ import React from 'react';
8
9
  import {
9
10
  DataGridActionCell,
10
11
  type DataGridActionCellProps,
@@ -8,6 +8,7 @@ import {
8
8
  } from '../DataGrid';
9
9
 
10
10
  import { styled } from '@mui/material';
11
+ import React from 'react';
11
12
  import { SearchField } from '../SearchField';
12
13
  import { DataGridPagination } from './DataGridPagination';
13
14
  import { makeDataList, makeRandomDate } from './faker';
@@ -1,6 +1,7 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
2
 
3
3
  import { styled } from '@mui/material';
4
+ import React from 'react';
4
5
  import { Container } from '../Container';
5
6
  import { Description } from './Description';
6
7
 
@@ -4,6 +4,7 @@ import { Button } from '../Button';
4
4
  import { Typography } from '../Typography';
5
5
 
6
6
  import { styled } from '@mui/material';
7
+ import React from 'react';
7
8
  import { DescriptionList } from './DescriptionList';
8
9
  import type { DescriptionListItem } from './types';
9
10
 
@@ -8,6 +8,7 @@ import { DialogContentText } from '../DialogContentText';
8
8
  import { DialogHeader } from '../DialogHeader';
9
9
  import { Typography } from '../Typography';
10
10
 
11
+ import React from 'react';
11
12
  import { Container } from '../Container';
12
13
  import { DescriptionList, type DescriptionListItem } from '../DescriptionList';
13
14
  import { Tag } from '../Tag';
@@ -6,6 +6,7 @@ import { Dialog } from '../Dialog';
6
6
  import { DialogContent } from '../DialogContent';
7
7
  import { DialogContentText } from '../DialogContentText';
8
8
 
9
+ import React from 'react';
9
10
  import { Container } from '../Container';
10
11
  import { DialogActions } from './DialogActions';
11
12
 
@@ -13,9 +14,6 @@ type Story = StoryObj<typeof DialogActions>;
13
14
 
14
15
  /**
15
16
  * DialogActions используется для передачи в футер диалога компонентов для управления диалоговым окном.
16
- *
17
- * ### [Figma](https://www.figma.com/file/3ghN4WjSgkKx5rETR64jqh/Sirius-Design-System-(%D0%90%D0%9A%D0%A2%D0%A3%D0%90%D0%9B%D0%AC%D0%9D%D0%9E)?type=design&node-id=95-159&mode=design&t=5c0oZ9TMtlkNyOeB-0)
18
- * ### [Guide]()
19
17
  */
20
18
  const meta: Meta<typeof DialogActions> = {
21
19
  title: 'Components/Dialog/DialogActions',
@@ -6,15 +6,13 @@ import { Dialog } from '../Dialog';
6
6
  import { DialogActions } from '../DialogActions';
7
7
  import { DialogContentText } from '../DialogContentText';
8
8
 
9
+ import React from 'react';
9
10
  import { DialogContent } from './DialogContent';
10
11
 
11
12
  type Story = StoryObj<typeof DialogContent>;
12
13
 
13
14
  /**
14
15
  * Для размещения контента внутри Dialog используется DialogContent
15
- *
16
- * ### [Figma](https://www.figma.com/file/3ghN4WjSgkKx5rETR64jqh/Sirius-Design-System-(%D0%90%D0%9A%D0%A2%D0%A3%D0%90%D0%9B%D0%AC%D0%9D%D0%9E)?type=design&node-id=95-159&mode=design&t=5c0oZ9TMtlkNyOeB-0)
17
- * ### [Guide]()
18
16
  */
19
17
  const meta: Meta<typeof DialogContent> = {
20
18
  title: 'Components/Dialog/DialogContent',
@@ -6,6 +6,7 @@ import { Dialog } from '../Dialog';
6
6
  import { DialogActions } from '../DialogActions';
7
7
  import { DialogContent } from '../DialogContent';
8
8
 
9
+ import React from 'react';
9
10
  import { DialogContentText } from './DialogContentText';
10
11
 
11
12
  type Story = StoryObj<typeof DialogContent>;
@@ -9,6 +9,7 @@ import { DialogContentText } from '../DialogContentText';
9
9
 
10
10
  import { Tag } from '../Tag';
11
11
 
12
+ import React from 'react';
12
13
  import { Container } from '../Container';
13
14
  import { DialogHeader } from './DialogHeader';
14
15
 
@@ -6,6 +6,7 @@ import { ListItemButton } from '../ListItemButton';
6
6
  import { ListItemText } from '../ListItemText';
7
7
 
8
8
  import { styled } from '@mui/material';
9
+ import React from 'react';
9
10
  import { Container } from '../Container';
10
11
  import { Divider } from './Divider';
11
12