@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.
- package/.storybook/main.ts +14 -14
- package/.turbo/turbo-build.log +13 -495
- package/.turbo/turbo-type$colon$check.log +1 -756
- package/CHANGELOG.md +6 -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/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 +2 -2
- package/dist/index.mjs +150 -150
- 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 +12 -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/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
package/package.json
CHANGED
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
});
|
|
@@ -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 {
|
|
2
|
-
|
|
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
|
|
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
|
|
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
|
|
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> = {
|
|
@@ -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 @@
|
|
|
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
|
|
|
@@ -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';
|
|
@@ -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>;
|