@max-ts/components 0.0.2 → 0.1.1

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 (216) hide show
  1. package/.storybook/main.ts +14 -14
  2. package/.turbo/turbo-build.log +11 -493
  3. package/.turbo/turbo-type$colon$check.log +1 -756
  4. package/CHANGELOG.md +12 -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/components/index.d.ts +14 -0
  75. package/dist/hooks/index.d.ts +1 -0
  76. package/dist/hooks/useToggle/index.d.ts +1 -0
  77. package/dist/hooks/useToggle/useToggle.d.ts +43 -0
  78. package/dist/index.js +183 -49
  79. package/dist/index.mjs +312 -178
  80. package/package.json +1 -1
  81. package/rslib.config.ts +26 -26
  82. package/src/components/Accordion/Accordion.stories.tsx +2 -0
  83. package/src/components/ActionCell/ActionCell.stories.tsx +1 -0
  84. package/src/components/ActionCell/MainAction/MainAction.tsx +1 -0
  85. package/src/components/AsyncAutocomplete/AsyncAutocomplete.stories.tsx +1 -0
  86. package/src/components/Autocomplete/Autocomplete.stories.tsx +1 -0
  87. package/src/components/Badge/Badge.stories.tsx +1 -0
  88. package/src/components/BottomDrawer/BottomDrawer.stories.tsx +2 -1
  89. package/src/components/Button/Button.stories.tsx +2 -1
  90. package/src/components/Button/Button.tsx +9 -10
  91. package/src/components/Button/useLogic/useLogic.ts +2 -5
  92. package/src/components/Checkbox/Checkbox.stories.tsx +1 -3
  93. package/src/components/CheckboxField/CheckboxField.stories.tsx +1 -0
  94. package/src/components/Chevron/Chevron.stories.tsx +1 -0
  95. package/src/components/CircularProgress/CircularProgress.stories.tsx +1 -0
  96. package/src/components/Collapse/Collapse.stories.tsx +1 -0
  97. package/src/components/ConfirmAction/ConfirmAction.stories.tsx +1 -3
  98. package/src/components/ConfirmDialog/ConfirmDialog.stories.tsx +69 -0
  99. package/src/components/ConfirmDialog/ConfirmDialog.tsx +83 -0
  100. package/src/components/ConfirmDialog/index.ts +1 -0
  101. package/src/components/ConfirmDialog/styles.ts +8 -0
  102. package/src/components/ConfirmDialog/useLogic/index.ts +1 -0
  103. package/src/components/ConfirmDialog/useLogic/useLogic.ts +23 -0
  104. package/src/components/ContentState/ContentState.stories.tsx +1 -0
  105. package/src/components/CopyTypography/CopyTypography.stories.tsx +1 -2
  106. package/src/components/DataGrid/DataGrid.stories.tsx +1 -0
  107. package/src/components/DataGridActionCell/DataGridActionCell.stories.tsx +1 -0
  108. package/src/components/DataGridPagination/DataGridPagination.stories.tsx +1 -0
  109. package/src/components/Description/Description.stories.tsx +1 -0
  110. package/src/components/DescriptionList/DescriptionList.stories.tsx +1 -0
  111. package/src/components/Dialog/Dialog.stories.tsx +1 -0
  112. package/src/components/DialogActions/DialogActions.stories.tsx +1 -3
  113. package/src/components/DialogContent/DialogContent.stories.tsx +1 -3
  114. package/src/components/DialogContentText/DialogContentText.stories.tsx +1 -0
  115. package/src/components/DialogHeader/DialogHeader.stories.tsx +1 -0
  116. package/src/components/Divider/Divider.stories.tsx +1 -0
  117. package/src/components/DropdownButton/DropdownButton.stories.tsx +191 -0
  118. package/src/components/DropdownButton/DropdownButton.tsx +46 -0
  119. package/src/components/DropdownButton/index.ts +1 -0
  120. package/src/components/ErrorBoundary/ErrorBoundary.stories.tsx +1 -0
  121. package/src/components/Filename/Filename.stories.tsx +244 -0
  122. package/src/components/Filename/Filename.tsx +57 -0
  123. package/src/components/Filename/index.ts +1 -0
  124. package/src/components/Filename/styles.ts +18 -0
  125. package/src/components/Filename/useLogic/index.ts +1 -0
  126. package/src/components/Filename/useLogic/useLogic.ts +36 -0
  127. package/src/components/Filename/useLogic/utils/findExtension/constants.ts +16 -0
  128. package/src/components/Filename/useLogic/utils/findExtension/findExtension.ts +17 -0
  129. package/src/components/Filename/useLogic/utils/findExtension/index.ts +1 -0
  130. package/src/components/Filename/useLogic/utils/index.ts +1 -0
  131. package/src/components/Filename/useLogic/utils/truncateString/constants.ts +1 -0
  132. package/src/components/Filename/useLogic/utils/truncateString/index.ts +1 -0
  133. package/src/components/Filename/useLogic/utils/truncateString/truncateString.ts +24 -0
  134. package/src/components/FormLabel/FormLabel.tsx +11 -0
  135. package/src/components/FormLabel/index.ts +1 -0
  136. package/src/components/FormLabel/styles.ts +6 -0
  137. package/src/components/GuidTypography/GuidTypography.stories.tsx +1 -0
  138. package/src/components/IconButton/IconButton.stories.tsx +1 -1
  139. package/src/components/IconButton/IconButton.tsx +11 -16
  140. package/src/components/IconButton/styles.ts +24 -24
  141. package/src/components/IconDropdownButton/IconDropdownButton.stories.tsx +1 -0
  142. package/src/components/InternalErrorPlaceholder/InternalErrorPlaceholder.stories.tsx +1 -0
  143. package/src/components/Link/Link.stories.tsx +1 -0
  144. package/src/components/List/List.stories.tsx +1 -0
  145. package/src/components/ListItem/ListItem.stories.tsx +1 -0
  146. package/src/components/ListItemButton/ListItemButton.stories.tsx +1 -0
  147. package/src/components/ListItemButton/ListItemButton.tsx +3 -9
  148. package/src/components/ListItemIcon/ListItemIcon.stories.tsx +1 -0
  149. package/src/components/ListItemText/ListItemText.stories.tsx +1 -0
  150. package/src/components/ListSubheader/ListSubheader.stories.tsx +1 -0
  151. package/src/components/Menu/Menu.stories.tsx +1 -0
  152. package/src/components/MenuItem/MenuItem.stories.tsx +1 -0
  153. package/src/components/MenuItem/MenuItem.tsx +1 -2
  154. package/src/components/MenuList/MenuList.stories.tsx +1 -0
  155. package/src/components/MenuList/types.ts +3 -8
  156. package/src/components/NavMenu/Item/ItemButton/ItemButton.tsx +1 -2
  157. package/src/components/NavMenu/NavMenu.stories.tsx +1 -0
  158. package/src/components/OutdatedReleasePlaceholder/OutdatedReleasePlaceholder.stories.tsx +1 -0
  159. package/src/components/OverflowTypography/OverflowTypography.stories.tsx +1 -8
  160. package/src/components/Pagination/Pagination.stories.tsx +1 -0
  161. package/src/components/Placeholder/Placeholder.stories.tsx +1 -0
  162. package/src/components/Popover/Popover.stories.tsx +1 -0
  163. package/src/components/ProgressBar/ProgressBar.stories.tsx +31 -0
  164. package/src/components/ProgressBar/ProgressBar.tsx +26 -0
  165. package/src/components/ProgressBar/index.ts +1 -0
  166. package/src/components/Radio/Icon/Icon.tsx +37 -0
  167. package/src/components/Radio/Icon/index.ts +1 -0
  168. package/src/components/Radio/Radio.stories.tsx +32 -0
  169. package/src/components/Radio/Radio.tsx +24 -0
  170. package/src/components/Radio/constants.ts +9 -0
  171. package/src/components/Radio/index.ts +1 -0
  172. package/src/components/Radio/styles.ts +70 -0
  173. package/src/components/RadioField/RadioField.stories.tsx +74 -0
  174. package/src/components/RadioField/RadioField.tsx +55 -0
  175. package/src/components/RadioField/index.ts +1 -0
  176. package/src/components/RadioField/styles.ts +10 -0
  177. package/src/components/RadioGroup/RadioGroup.stories.tsx +60 -0
  178. package/src/components/RadioGroup/RadioGroup.tsx +79 -0
  179. package/src/components/RadioGroup/RadioGroupContext/RadioGroupContext.ts +9 -0
  180. package/src/components/RadioGroup/RadioGroupContext/RadioGroupContextProvider/RadioGroupContextProvider.tsx +18 -0
  181. package/src/components/RadioGroup/RadioGroupContext/RadioGroupContextProvider/index.ts +1 -0
  182. package/src/components/RadioGroup/RadioGroupContext/index.ts +3 -0
  183. package/src/components/RadioGroup/index.ts +3 -0
  184. package/src/components/RadioGroupField/RadioGroupField.tsx +17 -0
  185. package/src/components/RadioGroupField/index.ts +1 -0
  186. package/src/components/Select/Select.stories.tsx +0 -4
  187. package/src/components/Skeleton/Skeleton.stories.tsx +78 -0
  188. package/src/components/Skeleton/Skeleton.tsx +31 -0
  189. package/src/components/Skeleton/index.ts +1 -0
  190. package/src/components/Skeleton/styles.ts +16 -0
  191. package/src/components/Switch/Switch.stories.tsx +179 -0
  192. package/src/components/Switch/Switch.tsx +14 -0
  193. package/src/components/Switch/index.ts +1 -0
  194. package/src/components/Switch/styles.ts +14 -0
  195. package/src/components/Tab/Tab.stories.tsx +53 -0
  196. package/src/components/Tab/Tab.tsx +20 -0
  197. package/src/components/Tab/index.ts +1 -0
  198. package/src/components/Tab/styles.ts +22 -0
  199. package/src/components/Tabs/Tabs.stories.tsx +74 -0
  200. package/src/components/Tabs/Tabs.tsx +27 -0
  201. package/src/components/Tabs/index.ts +1 -0
  202. package/src/components/Tabs/styles.ts +20 -0
  203. package/src/components/Tag/Tag.stories.tsx +1 -1
  204. package/src/components/TagBadge/TagBadge.stories.tsx +1 -5
  205. package/src/components/TextArea/TextArea.stories.tsx +81 -0
  206. package/src/components/TextArea/TextArea.tsx +8 -0
  207. package/src/components/TextArea/index.ts +1 -0
  208. package/src/components/TextField/TextField.stories.tsx +1 -4
  209. package/src/components/Tooltip/Tooltip.stories.tsx +1 -4
  210. package/src/components/Typography/Typography.stories.tsx +2 -4
  211. package/src/components/index.ts +28 -0
  212. package/src/hooks/index.ts +1 -0
  213. package/src/hooks/useToggle/index.ts +1 -0
  214. package/src/hooks/useToggle/useToggle.ts +76 -0
  215. package/test.tsx +1 -0
  216. package/tsconfig.json +3 -2
@@ -0,0 +1,74 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+
3
+ import { styled } from '@mui/material';
4
+ import React from 'react';
5
+ import { Container } from '../Container';
6
+ import { RadioField } from './RadioField';
7
+
8
+ /**
9
+ * RadioField - Составной компонент, инкапсулирует внутри логику отображения label, tooltip и т.п.
10
+ * Упрощает использование компонента Radio
11
+ *
12
+ * ### [Figma]()
13
+ * ### [Guide]()
14
+ */
15
+ const meta: Meta<typeof RadioField> = {
16
+ title: 'Components/Inputs/RadioField',
17
+ component: RadioField,
18
+ };
19
+
20
+ export default meta;
21
+
22
+ type Story = StoryObj<typeof RadioField>;
23
+
24
+ export const Interaction: Story = {
25
+ args: {
26
+ label: 'Лейбл',
27
+ isError: false,
28
+ required: false,
29
+ checked: false,
30
+ disabled: false,
31
+ disabledReason: 'Причина, по которой radio заблокирован',
32
+ },
33
+ parameters: {
34
+ docs: {
35
+ disable: true,
36
+ },
37
+ },
38
+ };
39
+
40
+ const BaseContainer = styled(Container)`
41
+ width: 300px;
42
+ min-height: 90px;
43
+ padding: ${({ theme }) => theme.spacing(2)};
44
+ `;
45
+
46
+ export const Example = () => (
47
+ <BaseContainer>
48
+ <RadioField value='foo' label='Radio label' />
49
+ </BaseContainer>
50
+ );
51
+
52
+ export const Required = () => (
53
+ <BaseContainer>
54
+ <RadioField value='foo' label='Radio label' required name='bar' />
55
+ </BaseContainer>
56
+ );
57
+
58
+ export const DisabledReason = () => (
59
+ <BaseContainer>
60
+ <RadioField
61
+ label='Radio label'
62
+ value='foo'
63
+ disabledReason='Причина, по которой radio заблокирован'
64
+ checked
65
+ disabled
66
+ />
67
+ </BaseContainer>
68
+ );
69
+
70
+ export const ErrorState = () => (
71
+ <BaseContainer>
72
+ <RadioField label='Radio label' value='foo' isError />
73
+ </BaseContainer>
74
+ );
@@ -0,0 +1,55 @@
1
+ import type { ReactNode } from 'react';
2
+
3
+ import type { FormControlLabelProps } from '../FormControlLabel';
4
+ import { Radio, type RadioProps } from '../Radio';
5
+ import { Tooltip } from '../Tooltip';
6
+
7
+ import { StyledFormControlLabel } from './styles';
8
+
9
+ export type RadioFieldProps = Omit<RadioProps, 'title' | 'LinkComponent'> & {
10
+ /**
11
+ * Радио лейбл
12
+ */
13
+ label: ReactNode;
14
+ /**
15
+ * Пропсы для FormControlLabel. Дают возможность конфигурации лейбла
16
+ */
17
+ formControlLabelProps?: Omit<FormControlLabelProps, 'control' | 'label'>;
18
+ /**
19
+ * Флаг состояния ошибки
20
+ */
21
+ isError?: boolean;
22
+ /**
23
+ * Причина дизейбла поля. Переданный текст будет отображаться в тултипе при наведении на задизейбленный radio-элемент
24
+ */
25
+ disabledReason?: ReactNode;
26
+ };
27
+
28
+ /**
29
+ * Составной компонент radio. Содержит label, tooltip и т.п.
30
+ */
31
+ export const RadioField = ({
32
+ id,
33
+ disabled,
34
+ label,
35
+ isError,
36
+ disabledReason,
37
+ formControlLabelProps,
38
+ ...restFieldProps
39
+ }: RadioFieldProps) => {
40
+ return (
41
+ <Tooltip
42
+ key={id}
43
+ title={disabled && disabledReason}
44
+ placement='bottom-start'
45
+ withoutContainer={false}
46
+ >
47
+ <StyledFormControlLabel
48
+ {...formControlLabelProps}
49
+ label={label}
50
+ control={<Radio {...restFieldProps} isError={isError} />}
51
+ disabled={disabled}
52
+ />
53
+ </Tooltip>
54
+ );
55
+ };
@@ -0,0 +1 @@
1
+ export * from './RadioField';
@@ -0,0 +1,10 @@
1
+ import { FormControlLabel, styled } from '@mui/material';
2
+
3
+ import type { FormControlLabelProps } from '../FormControlLabel';
4
+
5
+ export const StyledFormControlLabel = styled(
6
+ FormControlLabel,
7
+ )<FormControlLabelProps>`
8
+ margin-right: ${({ theme }) => theme.spacing(6)};
9
+ margin-left: -7px;
10
+ `;
@@ -0,0 +1,60 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+
3
+ import { RadioGroupField } from '../RadioGroupField';
4
+
5
+ import React from 'react';
6
+ import { RadioGroup } from './RadioGroup';
7
+
8
+ const meta: Meta<typeof RadioGroup> = {
9
+ title: 'Components/Inputs/RadioGroup',
10
+ component: RadioGroup,
11
+ };
12
+
13
+ export default meta;
14
+
15
+ type Story = StoryObj<typeof RadioGroup>;
16
+
17
+ export const Interaction: Story = {
18
+ args: {
19
+ groupLabel: 'Группа радио',
20
+ required: false,
21
+ isError: false,
22
+ errorText: 'Ошибка',
23
+ children: (
24
+ <>
25
+ <RadioGroupField label='Radio field 1' value='one' />
26
+ <RadioGroupField label='Radio field 2' value='two' />
27
+ <RadioGroupField label='Radio field 3' value='three' />
28
+ </>
29
+ ),
30
+ },
31
+ parameters: {
32
+ docs: {
33
+ disable: true,
34
+ },
35
+ },
36
+ };
37
+
38
+ export const Example = () => (
39
+ <RadioGroup groupLabel='Группа радио'>
40
+ <RadioGroupField label='Radio field 1' value='one' />
41
+ <RadioGroupField label='Radio field 2' value='two' />
42
+ <RadioGroupField label='Radio field 3' value='three' />
43
+ </RadioGroup>
44
+ );
45
+
46
+ export const ErrorState = () => (
47
+ <RadioGroup groupLabel='Группа радио' required isError errorText='Ошибка'>
48
+ <RadioGroupField label='Radio field 1' value='one' />
49
+ <RadioGroupField label='Radio field 2' value='two' />
50
+ <RadioGroupField label='Radio field 3' value='three' />
51
+ </RadioGroup>
52
+ );
53
+
54
+ export const Row = () => (
55
+ <RadioGroup groupLabel='Группа радио' row required>
56
+ <RadioGroupField label='Radio field 1' value='one' />
57
+ <RadioGroupField label='Radio field 2' value='two' />
58
+ <RadioGroupField label='Radio field 3' value='three' />
59
+ </RadioGroup>
60
+ );
@@ -0,0 +1,79 @@
1
+ import {
2
+ RadioGroup as MuiRadioGroup,
3
+ type RadioGroupProps as MuiRadioGroupProps,
4
+ } from '@mui/material';
5
+ import { type ReactNode, useId } from 'react';
6
+
7
+ import { FormControl, type FormControlProps } from '../FormControl';
8
+ import { FormLabel } from '../FormLabel';
9
+ import { Tooltip } from '../Tooltip';
10
+ import type { WithoutEmotionSpecific } from '../types';
11
+
12
+ import { RadioGroupContextProvider } from './RadioGroupContext';
13
+
14
+ export type RadioGroupProps = WithoutEmotionSpecific<MuiRadioGroupProps> & {
15
+ /**
16
+ * Флаг состояния ошибки
17
+ */
18
+ isError?: boolean;
19
+ /**
20
+ * Текстовая информация об ошибке, будет отображен в тултипе при isError: true
21
+ */
22
+ errorText?: ReactNode;
23
+ /**
24
+ * Лейбл для группы
25
+ */
26
+ groupLabel?: string;
27
+ /**
28
+ * Лейбл будет помечен как обязательный
29
+ */
30
+ required?: boolean;
31
+
32
+ /**
33
+ * Пропсы для управления FormControl
34
+ */
35
+ formControlProps?: Omit<FormControlProps, 'error'>;
36
+ };
37
+
38
+ /**
39
+ * Компонент RadioGroup с расширенным функционалом
40
+ */
41
+ export const RadioGroup = (props: RadioGroupProps) => {
42
+ const {
43
+ children,
44
+ groupLabel,
45
+ errorText,
46
+ isError,
47
+ required,
48
+ formControlProps,
49
+ row,
50
+ ...otherMuiRadioGroupProps
51
+ } = props;
52
+
53
+ const labelId = useId();
54
+
55
+ return (
56
+ <Tooltip
57
+ title={isError && errorText}
58
+ placement={'right-start'}
59
+ followCursor
60
+ >
61
+ <FormControl {...formControlProps}>
62
+ {groupLabel && (
63
+ <FormLabel id={labelId} required={required}>
64
+ {groupLabel}
65
+ </FormLabel>
66
+ )}
67
+ <MuiRadioGroup
68
+ {...otherMuiRadioGroupProps}
69
+ aria-labelledby={labelId}
70
+ row={row}
71
+ >
72
+ <RadioGroupContextProvider isError={isError}>
73
+ {children}
74
+ </RadioGroupContextProvider>
75
+ </MuiRadioGroup>
76
+ </FormControl>
77
+ </Tooltip>
78
+ );
79
+ };
@@ -0,0 +1,9 @@
1
+ import { createContext } from 'react';
2
+
3
+ export type RadioGroupContextProps = {
4
+ isError?: boolean;
5
+ };
6
+
7
+ export const RadioGroupContext = createContext<RadioGroupContextProps>({
8
+ isError: false,
9
+ });
@@ -0,0 +1,18 @@
1
+ import type { ReactNode } from 'react';
2
+
3
+ import {
4
+ RadioGroupContext,
5
+ type RadioGroupContextProps,
6
+ } from '../RadioGroupContext';
7
+
8
+ export type Props = RadioGroupContextProps & {
9
+ children: ReactNode;
10
+ };
11
+
12
+ export const RadioGroupContextProvider = ({ children, isError }: Props) => {
13
+ return (
14
+ <RadioGroupContext.Provider value={{ isError }}>
15
+ {children}
16
+ </RadioGroupContext.Provider>
17
+ );
18
+ };
@@ -0,0 +1 @@
1
+ export * from './RadioGroupContextProvider';
@@ -0,0 +1,3 @@
1
+ export * from './RadioGroupContext';
2
+
3
+ export * from './RadioGroupContextProvider';
@@ -0,0 +1,3 @@
1
+ export * from './RadioGroup';
2
+
3
+ export { RadioGroupContext } from './RadioGroupContext';
@@ -0,0 +1,17 @@
1
+ import { useContext } from 'react';
2
+
3
+ import { RadioField, type RadioFieldProps } from '../RadioField';
4
+ import { RadioGroupContext } from '../RadioGroup';
5
+
6
+ export type RadioGroupFieldProps = Omit<RadioFieldProps, 'isError'>;
7
+
8
+ /**
9
+ *
10
+ * Компонент RadioField, адаптирован под использование внутри RadioGroup,
11
+ * Использует контекст RadioGroupContext
12
+ */
13
+ export const RadioGroupField = (props: RadioGroupFieldProps) => {
14
+ const { isError } = useContext(RadioGroupContext);
15
+
16
+ return <RadioField {...props} isError={isError} />;
17
+ };
@@ -0,0 +1 @@
1
+ export * from './RadioGroupField';
@@ -12,10 +12,6 @@ import { MenuItem } from '../MenuItem';
12
12
 
13
13
  import { Select, type SelectProps } from './Select';
14
14
 
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)?node-id=8756%3A125130)
17
- * ### [Guide]()
18
- */
19
15
  const meta: Meta<typeof Select> = {
20
16
  title: 'Components/Inputs/Select',
21
17
  component: Select,
@@ -0,0 +1,78 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+
3
+ import { styled } from '@mui/material';
4
+ import { User } from 'lucide-react';
5
+ import React from 'react';
6
+ import { Skeleton } from './Skeleton';
7
+
8
+ const meta: Meta<typeof Skeleton> = {
9
+ title: 'Components/Skeleton',
10
+ component: Skeleton,
11
+ };
12
+
13
+ export default meta;
14
+
15
+ type Story = StoryObj<typeof Skeleton>;
16
+
17
+ export const Interaction: Story = {
18
+ args: {
19
+ variant: 'text',
20
+ },
21
+ parameters: {
22
+ docs: {
23
+ disable: true,
24
+ },
25
+ controls: {
26
+ expanded: true,
27
+ },
28
+ options: {
29
+ showPanel: true,
30
+ },
31
+ },
32
+ };
33
+
34
+ const Container = styled('div')`
35
+ width: 240px;
36
+ `;
37
+
38
+ export const Example = () => (
39
+ <>
40
+ <Container>
41
+ <Skeleton />
42
+ </Container>
43
+ </>
44
+ );
45
+
46
+ /**
47
+ * Скелетон имеет несколько вариантов отображения: text, rounded, circular
48
+ */
49
+
50
+ export const Variants = () => (
51
+ <Container>
52
+ <Skeleton variant='text' />
53
+ <Skeleton variant='circular' width={40} height={40} />
54
+ <Skeleton variant='rounded' width={210} height={60} />
55
+ </Container>
56
+ );
57
+
58
+ /**
59
+ * Пропс "component" позволяет изменить корневой элемент
60
+ */
61
+
62
+ export const Component = () => (
63
+ <Container>
64
+ <Skeleton variant='rounded' width={210} height={60} component='div' />
65
+ </Container>
66
+ );
67
+
68
+ /**
69
+ * При наличии children скелетон ориентируется на его размеры
70
+ */
71
+
72
+ export const WithChildren = () => (
73
+ <Container>
74
+ <Skeleton variant='circular'>
75
+ <User />
76
+ </Skeleton>
77
+ </Container>
78
+ );
@@ -0,0 +1,31 @@
1
+ import type { SkeletonProps as MuiSkeletonProps } from '@mui/material';
2
+ import type { ElementType } from 'react';
3
+
4
+ import type { WithoutEmotionSpecific } from '../types';
5
+
6
+ import { StyledSkeleton } from './styles';
7
+
8
+ export type SkeletonProps<
9
+ TComponent extends ElementType,
10
+ TComponentProps = object,
11
+ > = Omit<
12
+ WithoutEmotionSpecific<MuiSkeletonProps<TComponent, TComponentProps>>,
13
+ 'variant' | 'animation'
14
+ > & {
15
+ /**
16
+ * Компонент, используемый для корневого узла. Либо строка для использования элемента HTML, либо компонент
17
+ */
18
+ component?: TComponent;
19
+
20
+ /**
21
+ * Тип контента, который будет отображаться
22
+ */
23
+ variant?: 'text' | 'rounded' | 'circular';
24
+ };
25
+
26
+ export const Skeleton = <
27
+ TComponent extends ElementType = 'span',
28
+ TComponentProps = object,
29
+ >(
30
+ props: SkeletonProps<TComponent, TComponentProps>,
31
+ ) => <StyledSkeleton {...props} />;
@@ -0,0 +1 @@
1
+ export * from './Skeleton';
@@ -0,0 +1,16 @@
1
+ import { Skeleton, alpha, skeletonClasses, styled } from '@mui/material';
2
+
3
+ export const StyledSkeleton = styled(Skeleton)`
4
+ /* stylelint-disable-next-line */
5
+ background-color: ${({ theme }) => alpha(theme.palette.grey[900], 0.12)};
6
+
7
+ /* TODO: Заменить на значения из темы в рамках
8
+ https://track.astral.ru/soft/browse/UIKIT-1400 */
9
+ &.${skeletonClasses.text} {
10
+ border-radius: 4px;
11
+ }
12
+
13
+ &.${skeletonClasses.rounded} {
14
+ border-radius: 4px;
15
+ }
16
+ `;
@@ -0,0 +1,179 @@
1
+ import { Paper, styled } from '@mui/material';
2
+ import type { Meta, StoryObj } from '@storybook/react';
3
+
4
+ import { DialogActions } from '../DialogActions';
5
+ import { DialogContent } from '../DialogContent';
6
+ import { DialogTitle } from '../DialogTitle';
7
+ import { FormControlLabel } from '../FormControlLabel';
8
+ import { Typography } from '../Typography';
9
+
10
+ import React from 'react';
11
+ import { Container } from '../Container';
12
+ import { Switch } from './Switch';
13
+
14
+ /**
15
+ * Switch — переключатель — включает или выключает состояние отдельной настройки.
16
+ * Данный компонент можно использовать при необходимости включения/отключения какой-либо функции в сервисе.
17
+ *
18
+ * ### [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=574-76885)
19
+ * ### [Guide]()
20
+ */
21
+ const meta: Meta<typeof Switch> = {
22
+ title: 'Components/Switch',
23
+ component: Switch,
24
+ };
25
+
26
+ export default meta;
27
+
28
+ type Story = StoryObj<typeof Switch>;
29
+
30
+ export const Interaction: Story = {
31
+ args: {
32
+ color: 'primary',
33
+ },
34
+ parameters: {
35
+ docs: {
36
+ disable: true,
37
+ },
38
+ },
39
+ };
40
+
41
+ export const Example = () => {
42
+ return (
43
+ <>
44
+ <Paper style={{ width: 500 }}>
45
+ <DialogTitle variant='h5'>Настройки</DialogTitle>
46
+ <DialogContent>
47
+ <Container>
48
+ <Typography>Отображать отклоненные заявления</Typography>
49
+ <Switch size='small' />
50
+ </Container>
51
+ </DialogContent>
52
+ <DialogActions />
53
+ </Paper>
54
+ </>
55
+ );
56
+ };
57
+
58
+ /**
59
+ * Переключатель имеет два состояния: выключен и включен.
60
+ */
61
+ export const Types = () => (
62
+ <Container>
63
+ <Switch />
64
+ </Container>
65
+ );
66
+
67
+ export const Checked = () => (
68
+ <Container>
69
+ <Switch checked />
70
+ </Container>
71
+ );
72
+
73
+ export const Disabled = () => (
74
+ <Container>
75
+ <Switch disabled />
76
+ <Switch checked disabled />
77
+ </Container>
78
+ );
79
+
80
+ /**
81
+ * Компонент переключателя используется в интерфейсе с поясняющим текстом.
82
+ */
83
+ export const SwitchWithText = () => (
84
+ <Container gap={4}>
85
+ <FormControlLabel
86
+ control={<Switch />}
87
+ label={
88
+ <Typography variant='subtitle1' component='span'>
89
+ Text
90
+ </Typography>
91
+ }
92
+ />
93
+ <FormControlLabel
94
+ control={<Switch />}
95
+ label={
96
+ <Typography variant='subtitle1' component='span'>
97
+ Text
98
+ </Typography>
99
+ }
100
+ labelPlacement='start'
101
+ />
102
+
103
+ <FormControlLabel
104
+ control={<Switch />}
105
+ label={
106
+ <Typography variant='subtitle1' component='span'>
107
+ Text
108
+ </Typography>
109
+ }
110
+ />
111
+ <FormControlLabel
112
+ control={<Switch />}
113
+ disabled
114
+ label={
115
+ <Typography variant='subtitle1' component='span'>
116
+ Text
117
+ </Typography>
118
+ }
119
+ labelPlacement='start'
120
+ />
121
+
122
+ <FormControlLabel
123
+ control={<Switch checked />}
124
+ label={
125
+ <Typography variant='subtitle1' component='span'>
126
+ Text
127
+ </Typography>
128
+ }
129
+ />
130
+ <FormControlLabel
131
+ control={<Switch checked />}
132
+ label={
133
+ <Typography variant='subtitle1' component='span'>
134
+ Text
135
+ </Typography>
136
+ }
137
+ labelPlacement='start'
138
+ />
139
+
140
+ <FormControlLabel
141
+ control={<Switch checked />}
142
+ label={
143
+ <Typography variant='subtitle1' component='span'>
144
+ Text
145
+ </Typography>
146
+ }
147
+ disabled
148
+ />
149
+ <FormControlLabel
150
+ control={<Switch checked />}
151
+ label={
152
+ <Typography variant='subtitle1' component='span'>
153
+ Text
154
+ </Typography>
155
+ }
156
+ labelPlacement='start'
157
+ disabled
158
+ />
159
+ </Container>
160
+ );
161
+
162
+ /**
163
+ * Переключатель имеет несколько размеров: small, medium.
164
+ */
165
+ export const Sizes = () => (
166
+ <Container gap={4}>
167
+ <Switch size='small' />
168
+ <FormControlLabel control={<Switch size='small' />} label='Text' />
169
+ <Switch />
170
+ <FormControlLabel
171
+ control={<Switch />}
172
+ label={
173
+ <Typography variant='subtitle1' component='span'>
174
+ Text
175
+ </Typography>
176
+ }
177
+ />
178
+ </Container>
179
+ );
@@ -0,0 +1,14 @@
1
+ import type { SwitchProps as MuiSwitchProps } from '@mui/material';
2
+ import { forwardRef } from 'react';
3
+
4
+ import type { WithoutEmotionSpecific } from '../types';
5
+
6
+ import { StyledSwitch } from './styles';
7
+
8
+ export type SwitchProps = WithoutEmotionSpecific<MuiSwitchProps>;
9
+
10
+ export const Switch = forwardRef<HTMLButtonElement, SwitchProps>(
11
+ (props, ref) => {
12
+ return <StyledSwitch ref={ref} {...props} />;
13
+ },
14
+ );
@@ -0,0 +1 @@
1
+ export * from './Switch';