@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.
- package/.storybook/main.ts +14 -14
- package/.turbo/turbo-build.log +11 -493
- package/.turbo/turbo-type$colon$check.log +1 -756
- package/CHANGELOG.md +12 -0
- package/dist/components/Autocomplete/styles.d.ts +1 -1
- package/dist/components/Button/Button.d.ts +4 -4
- package/dist/components/Button/useLogic/useLogic.d.ts +1 -1
- package/dist/components/ConfirmDialog/ConfirmDialog.d.ts +37 -0
- package/dist/components/ConfirmDialog/index.d.ts +1 -0
- package/dist/components/ConfirmDialog/styles.d.ts +9 -0
- package/dist/components/ConfirmDialog/useLogic/index.d.ts +1 -0
- package/dist/components/ConfirmDialog/useLogic/useLogic.d.ts +10 -0
- package/dist/components/DataGrid/Row/NestedChildren/styles.d.ts +1 -1
- package/dist/components/DataGrid/Row/styles.d.ts +1 -1
- package/dist/components/DropdownButton/DropdownButton.d.ts +9 -0
- package/dist/components/DropdownButton/index.d.ts +1 -0
- package/dist/components/Filename/Filename.d.ts +21 -0
- package/dist/components/Filename/index.d.ts +1 -0
- package/dist/components/Filename/styles.d.ts +17 -0
- package/dist/components/Filename/useLogic/index.d.ts +1 -0
- package/dist/components/Filename/useLogic/useLogic.d.ts +16 -0
- package/dist/components/Filename/useLogic/utils/findExtension/constants.d.ts +1 -0
- package/dist/components/Filename/useLogic/utils/findExtension/findExtension.d.ts +1 -0
- package/dist/components/Filename/useLogic/utils/findExtension/index.d.ts +1 -0
- package/dist/components/Filename/useLogic/utils/index.d.ts +1 -0
- package/dist/components/Filename/useLogic/utils/truncateString/constants.d.ts +1 -0
- package/dist/components/Filename/useLogic/utils/truncateString/index.d.ts +1 -0
- package/dist/components/Filename/useLogic/utils/truncateString/truncateString.d.ts +4 -0
- package/dist/components/FormLabel/FormLabel.d.ts +4 -0
- package/dist/components/FormLabel/index.d.ts +1 -0
- package/dist/components/FormLabel/styles.d.ts +1 -0
- package/dist/components/IconButton/IconButton.d.ts +2 -2
- package/dist/components/IconButton/styles.d.ts +2 -2
- package/dist/components/ListItemButton/ListItemButton.d.ts +2 -2
- package/dist/components/MenuItem/MenuItem.d.ts +1 -1
- package/dist/components/MenuList/types.d.ts +2 -2
- package/dist/components/NavMenu/Item/ItemButton/ItemButton.d.ts +1 -1
- package/dist/components/NavMenu/Item/ItemButton/styles.d.ts +1 -1
- package/dist/components/ProgressBar/ProgressBar.d.ts +12 -0
- package/dist/components/ProgressBar/index.d.ts +1 -0
- package/dist/components/Radio/Icon/Icon.d.ts +6 -0
- package/dist/components/Radio/Icon/index.d.ts +1 -0
- package/dist/components/Radio/Radio.d.ts +9 -0
- package/dist/components/Radio/constants.d.ts +8 -0
- package/dist/components/Radio/index.d.ts +1 -0
- package/dist/components/Radio/styles.d.ts +5 -0
- package/dist/components/RadioField/RadioField.d.ts +25 -0
- package/dist/components/RadioField/index.d.ts +1 -0
- package/dist/components/RadioField/styles.d.ts +2 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +30 -0
- package/dist/components/RadioGroup/RadioGroupContext/RadioGroupContext.d.ts +4 -0
- package/dist/components/RadioGroup/RadioGroupContext/RadioGroupContextProvider/RadioGroupContextProvider.d.ts +6 -0
- package/dist/components/RadioGroup/RadioGroupContext/RadioGroupContextProvider/index.d.ts +1 -0
- package/dist/components/RadioGroup/RadioGroupContext/index.d.ts +2 -0
- package/dist/components/RadioGroup/index.d.ts +2 -0
- package/dist/components/RadioGroupField/RadioGroupField.d.ts +8 -0
- package/dist/components/RadioGroupField/index.d.ts +1 -0
- package/dist/components/SearchField/styles.d.ts +1 -1
- package/dist/components/Select/styles.d.ts +2 -2
- package/dist/components/Skeleton/Skeleton.d.ts +14 -0
- package/dist/components/Skeleton/index.d.ts +1 -0
- package/dist/components/Skeleton/styles.d.ts +1 -0
- package/dist/components/Switch/Switch.d.ts +4 -0
- package/dist/components/Switch/index.d.ts +1 -0
- package/dist/components/Switch/styles.d.ts +1 -0
- package/dist/components/Tab/Tab.d.ts +7 -0
- package/dist/components/Tab/index.d.ts +1 -0
- package/dist/components/Tab/styles.d.ts +1 -0
- package/dist/components/Tabs/Tabs.d.ts +13 -0
- package/dist/components/Tabs/index.d.ts +1 -0
- package/dist/components/Tabs/styles.d.ts +2 -0
- package/dist/components/TextArea/TextArea.d.ts +3 -0
- package/dist/components/TextArea/index.d.ts +1 -0
- package/dist/components/index.d.ts +14 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useToggle/index.d.ts +1 -0
- package/dist/hooks/useToggle/useToggle.d.ts +43 -0
- package/dist/index.js +183 -49
- package/dist/index.mjs +312 -178
- package/package.json +1 -1
- package/rslib.config.ts +26 -26
- package/src/components/Accordion/Accordion.stories.tsx +2 -0
- package/src/components/ActionCell/ActionCell.stories.tsx +1 -0
- package/src/components/ActionCell/MainAction/MainAction.tsx +1 -0
- package/src/components/AsyncAutocomplete/AsyncAutocomplete.stories.tsx +1 -0
- package/src/components/Autocomplete/Autocomplete.stories.tsx +1 -0
- package/src/components/Badge/Badge.stories.tsx +1 -0
- package/src/components/BottomDrawer/BottomDrawer.stories.tsx +2 -1
- package/src/components/Button/Button.stories.tsx +2 -1
- package/src/components/Button/Button.tsx +9 -10
- package/src/components/Button/useLogic/useLogic.ts +2 -5
- package/src/components/Checkbox/Checkbox.stories.tsx +1 -3
- package/src/components/CheckboxField/CheckboxField.stories.tsx +1 -0
- package/src/components/Chevron/Chevron.stories.tsx +1 -0
- package/src/components/CircularProgress/CircularProgress.stories.tsx +1 -0
- package/src/components/Collapse/Collapse.stories.tsx +1 -0
- package/src/components/ConfirmAction/ConfirmAction.stories.tsx +1 -3
- package/src/components/ConfirmDialog/ConfirmDialog.stories.tsx +69 -0
- package/src/components/ConfirmDialog/ConfirmDialog.tsx +83 -0
- package/src/components/ConfirmDialog/index.ts +1 -0
- package/src/components/ConfirmDialog/styles.ts +8 -0
- package/src/components/ConfirmDialog/useLogic/index.ts +1 -0
- package/src/components/ConfirmDialog/useLogic/useLogic.ts +23 -0
- package/src/components/ContentState/ContentState.stories.tsx +1 -0
- package/src/components/CopyTypography/CopyTypography.stories.tsx +1 -2
- package/src/components/DataGrid/DataGrid.stories.tsx +1 -0
- package/src/components/DataGridActionCell/DataGridActionCell.stories.tsx +1 -0
- package/src/components/DataGridPagination/DataGridPagination.stories.tsx +1 -0
- package/src/components/Description/Description.stories.tsx +1 -0
- package/src/components/DescriptionList/DescriptionList.stories.tsx +1 -0
- package/src/components/Dialog/Dialog.stories.tsx +1 -0
- package/src/components/DialogActions/DialogActions.stories.tsx +1 -3
- package/src/components/DialogContent/DialogContent.stories.tsx +1 -3
- package/src/components/DialogContentText/DialogContentText.stories.tsx +1 -0
- package/src/components/DialogHeader/DialogHeader.stories.tsx +1 -0
- package/src/components/Divider/Divider.stories.tsx +1 -0
- package/src/components/DropdownButton/DropdownButton.stories.tsx +191 -0
- package/src/components/DropdownButton/DropdownButton.tsx +46 -0
- package/src/components/DropdownButton/index.ts +1 -0
- package/src/components/ErrorBoundary/ErrorBoundary.stories.tsx +1 -0
- package/src/components/Filename/Filename.stories.tsx +244 -0
- package/src/components/Filename/Filename.tsx +57 -0
- package/src/components/Filename/index.ts +1 -0
- package/src/components/Filename/styles.ts +18 -0
- package/src/components/Filename/useLogic/index.ts +1 -0
- package/src/components/Filename/useLogic/useLogic.ts +36 -0
- package/src/components/Filename/useLogic/utils/findExtension/constants.ts +16 -0
- package/src/components/Filename/useLogic/utils/findExtension/findExtension.ts +17 -0
- package/src/components/Filename/useLogic/utils/findExtension/index.ts +1 -0
- package/src/components/Filename/useLogic/utils/index.ts +1 -0
- package/src/components/Filename/useLogic/utils/truncateString/constants.ts +1 -0
- package/src/components/Filename/useLogic/utils/truncateString/index.ts +1 -0
- package/src/components/Filename/useLogic/utils/truncateString/truncateString.ts +24 -0
- package/src/components/FormLabel/FormLabel.tsx +11 -0
- package/src/components/FormLabel/index.ts +1 -0
- package/src/components/FormLabel/styles.ts +6 -0
- package/src/components/GuidTypography/GuidTypography.stories.tsx +1 -0
- package/src/components/IconButton/IconButton.stories.tsx +1 -1
- package/src/components/IconButton/IconButton.tsx +11 -16
- package/src/components/IconButton/styles.ts +24 -24
- package/src/components/IconDropdownButton/IconDropdownButton.stories.tsx +1 -0
- package/src/components/InternalErrorPlaceholder/InternalErrorPlaceholder.stories.tsx +1 -0
- package/src/components/Link/Link.stories.tsx +1 -0
- package/src/components/List/List.stories.tsx +1 -0
- package/src/components/ListItem/ListItem.stories.tsx +1 -0
- package/src/components/ListItemButton/ListItemButton.stories.tsx +1 -0
- package/src/components/ListItemButton/ListItemButton.tsx +3 -9
- package/src/components/ListItemIcon/ListItemIcon.stories.tsx +1 -0
- package/src/components/ListItemText/ListItemText.stories.tsx +1 -0
- package/src/components/ListSubheader/ListSubheader.stories.tsx +1 -0
- package/src/components/Menu/Menu.stories.tsx +1 -0
- package/src/components/MenuItem/MenuItem.stories.tsx +1 -0
- package/src/components/MenuItem/MenuItem.tsx +1 -2
- package/src/components/MenuList/MenuList.stories.tsx +1 -0
- package/src/components/MenuList/types.ts +3 -8
- package/src/components/NavMenu/Item/ItemButton/ItemButton.tsx +1 -2
- package/src/components/NavMenu/NavMenu.stories.tsx +1 -0
- package/src/components/OutdatedReleasePlaceholder/OutdatedReleasePlaceholder.stories.tsx +1 -0
- package/src/components/OverflowTypography/OverflowTypography.stories.tsx +1 -8
- package/src/components/Pagination/Pagination.stories.tsx +1 -0
- package/src/components/Placeholder/Placeholder.stories.tsx +1 -0
- package/src/components/Popover/Popover.stories.tsx +1 -0
- package/src/components/ProgressBar/ProgressBar.stories.tsx +31 -0
- package/src/components/ProgressBar/ProgressBar.tsx +26 -0
- package/src/components/ProgressBar/index.ts +1 -0
- package/src/components/Radio/Icon/Icon.tsx +37 -0
- package/src/components/Radio/Icon/index.ts +1 -0
- package/src/components/Radio/Radio.stories.tsx +32 -0
- package/src/components/Radio/Radio.tsx +24 -0
- package/src/components/Radio/constants.ts +9 -0
- package/src/components/Radio/index.ts +1 -0
- package/src/components/Radio/styles.ts +70 -0
- package/src/components/RadioField/RadioField.stories.tsx +74 -0
- package/src/components/RadioField/RadioField.tsx +55 -0
- package/src/components/RadioField/index.ts +1 -0
- package/src/components/RadioField/styles.ts +10 -0
- package/src/components/RadioGroup/RadioGroup.stories.tsx +60 -0
- package/src/components/RadioGroup/RadioGroup.tsx +79 -0
- package/src/components/RadioGroup/RadioGroupContext/RadioGroupContext.ts +9 -0
- package/src/components/RadioGroup/RadioGroupContext/RadioGroupContextProvider/RadioGroupContextProvider.tsx +18 -0
- package/src/components/RadioGroup/RadioGroupContext/RadioGroupContextProvider/index.ts +1 -0
- package/src/components/RadioGroup/RadioGroupContext/index.ts +3 -0
- package/src/components/RadioGroup/index.ts +3 -0
- package/src/components/RadioGroupField/RadioGroupField.tsx +17 -0
- package/src/components/RadioGroupField/index.ts +1 -0
- package/src/components/Select/Select.stories.tsx +0 -4
- package/src/components/Skeleton/Skeleton.stories.tsx +78 -0
- package/src/components/Skeleton/Skeleton.tsx +31 -0
- package/src/components/Skeleton/index.ts +1 -0
- package/src/components/Skeleton/styles.ts +16 -0
- package/src/components/Switch/Switch.stories.tsx +179 -0
- package/src/components/Switch/Switch.tsx +14 -0
- package/src/components/Switch/index.ts +1 -0
- package/src/components/Switch/styles.ts +14 -0
- package/src/components/Tab/Tab.stories.tsx +53 -0
- package/src/components/Tab/Tab.tsx +20 -0
- package/src/components/Tab/index.ts +1 -0
- package/src/components/Tab/styles.ts +22 -0
- package/src/components/Tabs/Tabs.stories.tsx +74 -0
- package/src/components/Tabs/Tabs.tsx +27 -0
- package/src/components/Tabs/index.ts +1 -0
- package/src/components/Tabs/styles.ts +20 -0
- package/src/components/Tag/Tag.stories.tsx +1 -1
- package/src/components/TagBadge/TagBadge.stories.tsx +1 -5
- package/src/components/TextArea/TextArea.stories.tsx +81 -0
- package/src/components/TextArea/TextArea.tsx +8 -0
- package/src/components/TextArea/index.ts +1 -0
- package/src/components/TextField/TextField.stories.tsx +1 -4
- package/src/components/Tooltip/Tooltip.stories.tsx +1 -4
- package/src/components/Typography/Typography.stories.tsx +2 -4
- package/src/components/index.ts +28 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useToggle/index.ts +1 -0
- package/src/hooks/useToggle/useToggle.ts +76 -0
- package/test.tsx +1 -0
- package/tsconfig.json +3 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './FormLabel';
|
|
@@ -3,6 +3,7 @@ import type { Meta, StoryObj } from '@storybook/react';
|
|
|
3
3
|
import { CopyTypography } from '../CopyTypography';
|
|
4
4
|
|
|
5
5
|
import { styled } from '@mui/material';
|
|
6
|
+
import React from 'react';
|
|
6
7
|
import { GuidTypography } from './GuidTypography';
|
|
7
8
|
|
|
8
9
|
const meta: Meta<typeof GuidTypography> = {
|
|
@@ -3,8 +3,8 @@ import type { Meta, StoryObj } from '@storybook/react';
|
|
|
3
3
|
import { ActionCell, type Actions } from '../ActionCell';
|
|
4
4
|
import { DataGrid, type DataGridColumns } from '../DataGrid';
|
|
5
5
|
|
|
6
|
-
import { styled } from '@mui/material';
|
|
7
6
|
import { Download, Eye, Filter, Printer, Send } from 'lucide-react';
|
|
7
|
+
import React from 'react';
|
|
8
8
|
import { Container } from '../Container';
|
|
9
9
|
import { IconButton } from './IconButton';
|
|
10
10
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
2
|
|
|
3
3
|
import { type ButtonProps, ButtonVariants } from '../Button';
|
|
4
4
|
import {
|
|
@@ -8,22 +8,17 @@ import {
|
|
|
8
8
|
|
|
9
9
|
import { StyledButton } from './styles';
|
|
10
10
|
|
|
11
|
-
export type IconButtonProps<
|
|
12
|
-
RootComponent
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
loading?: boolean;
|
|
20
|
-
};
|
|
11
|
+
export type IconButtonProps<RootComponent extends React.ElementType> =
|
|
12
|
+
ButtonProps<RootComponent> & {
|
|
13
|
+
/**
|
|
14
|
+
* Флаг отображения индикатора загрузки
|
|
15
|
+
* @example <IconButton loading />
|
|
16
|
+
*/
|
|
17
|
+
loading?: boolean;
|
|
18
|
+
};
|
|
21
19
|
|
|
22
|
-
export const IconButton = <
|
|
23
|
-
RootComponent
|
|
24
|
-
AdditionalProps = object,
|
|
25
|
-
>(
|
|
26
|
-
props: IconButtonProps<RootComponent, AdditionalProps>,
|
|
20
|
+
export const IconButton = <RootComponent extends React.ElementType = 'button'>(
|
|
21
|
+
props: IconButtonProps<RootComponent>,
|
|
27
22
|
) => {
|
|
28
23
|
const {
|
|
29
24
|
variant = ButtonVariants.Contained,
|
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
import { styled } from '@mui/material';
|
|
2
|
-
import { Button,
|
|
2
|
+
import { Button, type ButtonProps, ButtonSizes } from '../Button';
|
|
3
3
|
|
|
4
4
|
type GetValueOptions = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
type?: string | undefined;
|
|
6
|
+
values: Record<string, string>;
|
|
7
|
+
defaultValue: string;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
const getValue = ({ type, values, defaultValue }: GetValueOptions) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
if (!type) {
|
|
12
|
+
return defaultValue;
|
|
13
|
+
}
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
return values[type] || defaultValue;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Получить значения для высоты кнопки в зависимости от size параметра
|
|
20
20
|
*/
|
|
21
21
|
export const getButtonHeight = (options: ButtonProps<'button'>): string =>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
getValue({
|
|
23
|
+
type: options.size,
|
|
24
|
+
values: {
|
|
25
|
+
[ButtonSizes.Large]: '40px',
|
|
26
|
+
},
|
|
27
|
+
defaultValue: '32px',
|
|
28
|
+
});
|
|
29
29
|
|
|
30
30
|
export const getButtonHeightMobile = (options: ButtonProps<'button'>): string =>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
getValue({
|
|
32
|
+
type: options.size,
|
|
33
|
+
values: {
|
|
34
|
+
[ButtonSizes.Small]: '36px',
|
|
35
|
+
},
|
|
36
|
+
defaultValue: '48px',
|
|
37
|
+
});
|
|
38
38
|
|
|
39
39
|
export const StyledButton = styled(Button, {
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
shouldForwardProp: (prop) =>
|
|
41
|
+
prop !== 'startIcon' && prop !== 'endIcon' && prop !== 'loading',
|
|
42
42
|
})`
|
|
43
43
|
pointer-events: ${({ loading }) => loading && 'none'};
|
|
44
44
|
|
|
@@ -6,6 +6,7 @@ import { IconButton } from '../IconButton';
|
|
|
6
6
|
import { MenuItem } from '../MenuItem';
|
|
7
7
|
|
|
8
8
|
import { EllipsisVertical, Pencil } from 'lucide-react';
|
|
9
|
+
import React from 'react';
|
|
9
10
|
import { IconDropdownButton } from './IconDropdownButton';
|
|
10
11
|
|
|
11
12
|
const meta: Meta<typeof IconDropdownButton> = {
|
|
@@ -10,6 +10,7 @@ import { ListItemText } from '../ListItemText';
|
|
|
10
10
|
import { ListSubheader } from '../ListSubheader';
|
|
11
11
|
|
|
12
12
|
import { House } from 'lucide-react';
|
|
13
|
+
import React from 'react';
|
|
13
14
|
import { ListItemButton } from './ListItemButton';
|
|
14
15
|
|
|
15
16
|
const meta: Meta<typeof ListItemButton> = {
|
|
@@ -11,11 +11,8 @@ import type { WithoutEmotionSpecific } from '../types';
|
|
|
11
11
|
export type ListItemButtonProps<
|
|
12
12
|
RootComponent extends
|
|
13
13
|
React.ElementType = ListItemButtonTypeMap['defaultComponent'],
|
|
14
|
-
AdditionalProps = object,
|
|
15
14
|
> = Omit<
|
|
16
|
-
WithoutEmotionSpecific<
|
|
17
|
-
MuiListItemButtonProps<RootComponent, AdditionalProps>
|
|
18
|
-
>,
|
|
15
|
+
WithoutEmotionSpecific<MuiListItemButtonProps<RootComponent>>,
|
|
19
16
|
'disableRipple'
|
|
20
17
|
> & {
|
|
21
18
|
tooltipPlacement?: TooltipProps['placement'];
|
|
@@ -34,11 +31,8 @@ export type ListItemButtonProps<
|
|
|
34
31
|
withoutContainer?: boolean;
|
|
35
32
|
};
|
|
36
33
|
|
|
37
|
-
export const ListItemButton = <
|
|
38
|
-
RootComponent
|
|
39
|
-
AdditionalProps,
|
|
40
|
-
>(
|
|
41
|
-
props: ListItemButtonProps<RootComponent, AdditionalProps>,
|
|
34
|
+
export const ListItemButton = <RootComponent extends React.ElementType>(
|
|
35
|
+
props: ListItemButtonProps<RootComponent>,
|
|
42
36
|
) => {
|
|
43
37
|
const {
|
|
44
38
|
disabledReason,
|
|
@@ -6,6 +6,7 @@ import { ListItemIcon } from '../ListItemIcon';
|
|
|
6
6
|
import { ListItemText } from '../ListItemText';
|
|
7
7
|
|
|
8
8
|
import { House } from 'lucide-react';
|
|
9
|
+
import React from 'react';
|
|
9
10
|
import { ListSubheader } from './ListSubheader';
|
|
10
11
|
|
|
11
12
|
const meta: Meta<typeof ListSubheader> = {
|
|
@@ -10,8 +10,7 @@ import type { WithoutEmotionSpecific } from '../types';
|
|
|
10
10
|
|
|
11
11
|
export type MenuItemProps<
|
|
12
12
|
RootComponent extends React.ElementType = MenuItemTypeMap['defaultComponent'],
|
|
13
|
-
|
|
14
|
-
> = WithoutEmotionSpecific<MuiMenuItemProps<RootComponent, AdditionalProps>> & {
|
|
13
|
+
> = WithoutEmotionSpecific<MuiMenuItemProps<RootComponent>> & {
|
|
15
14
|
/**
|
|
16
15
|
* Текст тултипа при заблокированном состоянии элемента меню
|
|
17
16
|
*/
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
MenuListTypeMap,
|
|
3
|
-
MenuListProps as MuiMenuListProps,
|
|
4
|
-
} from '@mui/material/MenuList';
|
|
1
|
+
import type { MenuListProps as MuiMenuListProps } from '@mui/material/MenuList';
|
|
5
2
|
|
|
6
3
|
import type { WithoutEmotionSpecific } from '../types';
|
|
7
4
|
|
|
8
|
-
export type MenuListProps<
|
|
9
|
-
RootComponent
|
|
10
|
-
AdditionalProps = object,
|
|
11
|
-
> = WithoutEmotionSpecific<MuiMenuListProps<RootComponent, AdditionalProps>>;
|
|
5
|
+
export type MenuListProps<RootComponent extends React.ElementType> =
|
|
6
|
+
WithoutEmotionSpecific<MuiMenuListProps<RootComponent>>;
|
|
@@ -14,8 +14,7 @@ import {
|
|
|
14
14
|
|
|
15
15
|
export type NavMenuItemButtonProps<
|
|
16
16
|
RootComponent extends ElementType = ElementType,
|
|
17
|
-
|
|
18
|
-
> = ListItemButtonProps<RootComponent, AdditionalProps> & {
|
|
17
|
+
> = ListItemButtonProps<RootComponent> & {
|
|
19
18
|
opened?: boolean;
|
|
20
19
|
collapsedIn: boolean;
|
|
21
20
|
selected?: boolean;
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import React from 'react';
|
|
2
3
|
|
|
3
4
|
import { styled } from '@mui/material';
|
|
4
5
|
import { OverflowTypography } from './OverflowTypography';
|
|
5
6
|
|
|
6
|
-
/**
|
|
7
|
-
* ##Мотивация
|
|
8
|
-
* Вариация [Typography](/story/components-data-display-typography--docs) элемента, с автоматической проверкой на переполнение текстового контента, и если есть переполнение, то тогда добавляется кастомизируемая обертка ```Tooltip```.
|
|
9
|
-
*
|
|
10
|
-
* ### [Figma]()
|
|
11
|
-
* ### [Guide]()
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
7
|
const meta: Meta<typeof OverflowTypography> = {
|
|
15
8
|
title: 'Components/Data Display/OverflowTypography',
|
|
16
9
|
component: OverflowTypography,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { ProgressBar } from './ProgressBar';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
Прогресс-бар — это индикатор, который отображает прогресс выполнения задачи.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const meta: Meta<typeof ProgressBar> = {
|
|
12
|
+
title: 'Components/ProgressBar',
|
|
13
|
+
component: ProgressBar,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type Story = StoryObj<typeof ProgressBar>;
|
|
17
|
+
|
|
18
|
+
export const Interaction: Story = {
|
|
19
|
+
args: {
|
|
20
|
+
value: 33,
|
|
21
|
+
},
|
|
22
|
+
parameters: {
|
|
23
|
+
docs: {
|
|
24
|
+
disable: true,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default meta;
|
|
30
|
+
|
|
31
|
+
export const Example = ({ value = 25 }) => <ProgressBar value={value} />;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { LinearProgress as MuiLinearProgress } from '@mui/material';
|
|
2
|
+
|
|
3
|
+
export type ProgressBarProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Текущий прогресс загрузки (от 0 до 100)
|
|
6
|
+
* @example <ProgressBar value={25} />
|
|
7
|
+
*/
|
|
8
|
+
value: number;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Название класса, применяется к корневому компоненту
|
|
12
|
+
*/
|
|
13
|
+
className?: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const ProgressBar = ({ className, value }: ProgressBarProps) => {
|
|
17
|
+
const clampedValue = Math.max(0, Math.min(value, 100));
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<MuiLinearProgress
|
|
21
|
+
className={className}
|
|
22
|
+
variant='determinate'
|
|
23
|
+
value={clampedValue}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ProgressBar';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { SvgIcon } from '@mui/material';
|
|
2
|
+
|
|
3
|
+
import { CHECKED_ICON_CLASSES, DEFAULT_ICON_CLASSES } from '../constants';
|
|
4
|
+
|
|
5
|
+
export const DefaultIcon = ({ ...props }) => (
|
|
6
|
+
<SvgIcon viewBox='0 0 24 24' {...props}>
|
|
7
|
+
<circle
|
|
8
|
+
cx='12'
|
|
9
|
+
cy='12'
|
|
10
|
+
r='10'
|
|
11
|
+
className={DEFAULT_ICON_CLASSES.outerCircle}
|
|
12
|
+
/>
|
|
13
|
+
<circle
|
|
14
|
+
cx='12'
|
|
15
|
+
cy='12'
|
|
16
|
+
r='8'
|
|
17
|
+
className={DEFAULT_ICON_CLASSES.innerCircle}
|
|
18
|
+
/>
|
|
19
|
+
</SvgIcon>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export const CheckedCircleIcon = ({ ...props }) => (
|
|
23
|
+
<SvgIcon viewBox='0 0 24 24' {...props}>
|
|
24
|
+
<circle
|
|
25
|
+
cx='12'
|
|
26
|
+
cy='12'
|
|
27
|
+
r='10'
|
|
28
|
+
className={CHECKED_ICON_CLASSES.outerCircle}
|
|
29
|
+
/>
|
|
30
|
+
<circle
|
|
31
|
+
cx='12'
|
|
32
|
+
cy='12'
|
|
33
|
+
r='4'
|
|
34
|
+
className={CHECKED_ICON_CLASSES.innerCircle}
|
|
35
|
+
/>
|
|
36
|
+
</SvgIcon>
|
|
37
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Icon';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Radio } from './Radio';
|
|
5
|
+
|
|
6
|
+
const meta: Meta<typeof Radio> = {
|
|
7
|
+
title: 'Components/Inputs/Radio',
|
|
8
|
+
component: Radio,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default meta;
|
|
12
|
+
|
|
13
|
+
type Story = StoryObj<typeof Radio>;
|
|
14
|
+
|
|
15
|
+
export const Interaction: Story = {
|
|
16
|
+
args: {
|
|
17
|
+
checked: false,
|
|
18
|
+
disabled: false,
|
|
19
|
+
isError: false,
|
|
20
|
+
},
|
|
21
|
+
parameters: {
|
|
22
|
+
docs: {
|
|
23
|
+
disable: true,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const Example = () => <Radio />;
|
|
29
|
+
|
|
30
|
+
export const Disabled = () => <Radio disabled />;
|
|
31
|
+
|
|
32
|
+
export const WithError = () => <Radio isError />;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { RadioProps as MuiRadioProps } from '@mui/material';
|
|
2
|
+
|
|
3
|
+
import type { WithoutEmotionSpecific } from '../types';
|
|
4
|
+
|
|
5
|
+
import { CheckedCircleIcon, DefaultIcon } from './Icon';
|
|
6
|
+
import { StyledRadio } from './styles';
|
|
7
|
+
|
|
8
|
+
export type RadioProps = Omit<
|
|
9
|
+
WithoutEmotionSpecific<MuiRadioProps>,
|
|
10
|
+
'size' | 'color'
|
|
11
|
+
> & {
|
|
12
|
+
/**
|
|
13
|
+
* Флаг для применения error стилей.
|
|
14
|
+
*/
|
|
15
|
+
isError?: boolean;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const Radio = ({
|
|
19
|
+
icon = <DefaultIcon />,
|
|
20
|
+
checkedIcon = <CheckedCircleIcon />,
|
|
21
|
+
...props
|
|
22
|
+
}: RadioProps) => {
|
|
23
|
+
return <StyledRadio icon={icon} checkedIcon={checkedIcon} {...props} />;
|
|
24
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const DEFAULT_ICON_CLASSES = {
|
|
2
|
+
innerCircle: 'RadioIcon-innerCircle',
|
|
3
|
+
outerCircle: 'RadioIcon-outerCircle',
|
|
4
|
+
} as const;
|
|
5
|
+
|
|
6
|
+
export const CHECKED_ICON_CLASSES = {
|
|
7
|
+
innerCircle: 'RadioCheckedIcon-innerCircle',
|
|
8
|
+
outerCircle: 'RadioCheckedIcon-outerCircle',
|
|
9
|
+
} as const;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Radio';
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Radio, css, styled } from '@mui/material';
|
|
2
|
+
|
|
3
|
+
import type { Theme } from '../../theme';
|
|
4
|
+
import { CHECKED_ICON_CLASSES, DEFAULT_ICON_CLASSES } from './constants';
|
|
5
|
+
|
|
6
|
+
type StyledRadioProps = {
|
|
7
|
+
isError?: boolean;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const getErrorStyles = (theme: Theme) => css`
|
|
11
|
+
&.MuiRadio-root:not(.Mui-disabled) {
|
|
12
|
+
color: ${theme.palette.red[800]};
|
|
13
|
+
|
|
14
|
+
&:hover {
|
|
15
|
+
& > svg {
|
|
16
|
+
color: ${theme.palette.red[700]};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
export const StyledRadio = styled(Radio, {
|
|
23
|
+
shouldForwardProp: (prop) => prop !== 'isError',
|
|
24
|
+
})<StyledRadioProps>`
|
|
25
|
+
padding: 5px;
|
|
26
|
+
|
|
27
|
+
color: ${({ theme }) => theme.palette.grey[300]};
|
|
28
|
+
|
|
29
|
+
border-radius: unset;
|
|
30
|
+
|
|
31
|
+
& > svg > .${DEFAULT_ICON_CLASSES.innerCircle} {
|
|
32
|
+
fill: ${({ theme }) => theme.palette.common.white};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&:hover {
|
|
36
|
+
background: none;
|
|
37
|
+
|
|
38
|
+
& > svg > .${DEFAULT_ICON_CLASSES.innerCircle} {
|
|
39
|
+
fill: ${({ theme }) => theme.palette.grey[100]};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&.Mui-disabled:not(.Mui-checked) {
|
|
44
|
+
color: ${({ theme }) => theme.palette.grey[200]};
|
|
45
|
+
|
|
46
|
+
& > svg > .${DEFAULT_ICON_CLASSES.innerCircle} {
|
|
47
|
+
fill: ${({ theme }) => theme.palette.grey[200]};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&.Mui-checked {
|
|
52
|
+
color: ${({ theme }) => theme.palette.primary.main};
|
|
53
|
+
|
|
54
|
+
&:hover {
|
|
55
|
+
& > svg {
|
|
56
|
+
color: ${({ theme }) => theme.palette.primary[700]};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
&.Mui-disabled {
|
|
61
|
+
color: ${({ theme }) => theme.palette.grey[400]};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
& > svg > .${CHECKED_ICON_CLASSES.innerCircle} {
|
|
65
|
+
fill: ${({ theme }) => theme.palette.common.white};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
${({ isError, theme }) => isError && getErrorStyles(theme)}
|
|
70
|
+
`;
|