@snack-uikit/drawer 0.7.2 → 0.7.3-preview-b7b8cddc.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/README.md
CHANGED
|
@@ -42,10 +42,11 @@
|
|
|
42
42
|
| image | `{ src: string; alt: string; }` | - | Изображение |
|
|
43
43
|
| subtitle | `string` | - | Подзаголовок |
|
|
44
44
|
| size | enum Size: `"s"`, `"m"`, `"l"` | - | Размер |
|
|
45
|
-
| approveButton | `Omit<ButtonFilledProps, "
|
|
46
|
-
| cancelButton | `Omit<ButtonOutlineProps, "
|
|
47
|
-
| additionalButton | `Omit<ButtonSimpleProps, "
|
|
45
|
+
| approveButton | `Omit<ButtonFilledProps, "size"> & { tooltip?: TooltipProps; }` | - | Основная кнопка |
|
|
46
|
+
| cancelButton | `Omit<ButtonOutlineProps, "size"> & { tooltip?: TooltipProps; }` | - | Кнопка отмены |
|
|
47
|
+
| additionalButton | `Omit<ButtonSimpleProps, "size"> & { tooltip?: TooltipProps; }` | - | Дополнительная кнопка |
|
|
48
48
|
| nestedDrawer | `ReactElement<DrawerProps, string \| JSXElementConstructor<any>>` | - | Вложенный Drawer |
|
|
49
|
+
| truncate | `{ title?: number; subtitle?: number; }` | '{ <br>title: 1; <br>subtitle: 2; }' | Максимальное кол-во строк <br> - `title` - в заголовке <br> - `subtitle` - в подзаголовке |
|
|
49
50
|
|
|
50
51
|
|
|
51
52
|
[//]: DOCUMENTATION_SECTION_END
|
|
@@ -12,19 +12,29 @@ export type DrawerProps = Omit<DrawerCustomProps, 'size' | 'children' | 'nestedD
|
|
|
12
12
|
/** Размер */
|
|
13
13
|
size?: Size;
|
|
14
14
|
/** Основная кнопка */
|
|
15
|
-
approveButton?: Omit<ButtonFilledProps, 'size'
|
|
15
|
+
approveButton?: Omit<ButtonFilledProps, 'size'> & {
|
|
16
16
|
tooltip?: TooltipProps;
|
|
17
17
|
};
|
|
18
18
|
/** Кнопка отмены */
|
|
19
|
-
cancelButton?: Omit<ButtonOutlineProps, 'size'
|
|
19
|
+
cancelButton?: Omit<ButtonOutlineProps, 'size'> & {
|
|
20
20
|
tooltip?: TooltipProps;
|
|
21
21
|
};
|
|
22
22
|
/** Дополнительная кнопка */
|
|
23
|
-
additionalButton?: Omit<ButtonSimpleProps, 'size'
|
|
23
|
+
additionalButton?: Omit<ButtonSimpleProps, 'size'> & {
|
|
24
24
|
tooltip?: TooltipProps;
|
|
25
25
|
};
|
|
26
26
|
/** Вложенный Drawer */
|
|
27
27
|
nestedDrawer?: ReactElement<DrawerProps>;
|
|
28
|
+
/**
|
|
29
|
+
* Максимальное кол-во строк
|
|
30
|
+
* <br> - `title` - в заголовке
|
|
31
|
+
* <br> - `subtitle` - в подзаголовке
|
|
32
|
+
* @default '{ <br>title: 1; <br>subtitle: 2; }'
|
|
33
|
+
*/
|
|
34
|
+
truncate?: {
|
|
35
|
+
title?: number;
|
|
36
|
+
subtitle?: number;
|
|
37
|
+
};
|
|
28
38
|
};
|
|
29
39
|
/** Готовый компонент Drawer */
|
|
30
|
-
export declare function Drawer({ title, titleTooltip, subtitle, image, content, approveButton, cancelButton, additionalButton, nestedDrawer, ...rest }: DrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
40
|
+
export declare function Drawer({ title, titleTooltip, subtitle, image, content, approveButton, cancelButton, additionalButton, nestedDrawer, truncate, ...rest }: DrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -17,7 +17,7 @@ import { WithTooltip } from '../../helperComponents/WithTooltip';
|
|
|
17
17
|
import { DrawerCustom } from '../DrawerCustom';
|
|
18
18
|
/** Готовый компонент Drawer */
|
|
19
19
|
export function Drawer(_a) {
|
|
20
|
-
var { title, titleTooltip, subtitle, image, content, approveButton, cancelButton, additionalButton, nestedDrawer } = _a, rest = __rest(_a, ["title", "titleTooltip", "subtitle", "image", "content", "approveButton", "cancelButton", "additionalButton", "nestedDrawer"]);
|
|
20
|
+
var { title, titleTooltip, subtitle, image, content, approveButton, cancelButton, additionalButton, nestedDrawer, truncate } = _a, rest = __rest(_a, ["title", "titleTooltip", "subtitle", "image", "content", "approveButton", "cancelButton", "additionalButton", "nestedDrawer", "truncate"]);
|
|
21
21
|
const needFooter = Boolean(approveButton) || Boolean(cancelButton) || Boolean(additionalButton);
|
|
22
|
-
return (_jsxs(DrawerCustom, Object.assign({}, rest, { push: Boolean(nestedDrawer) && { distance: NESTED_DRAWER_PUSH_DISTANCE }, children: [_jsx(DrawerCustom.Header, { title: _jsx(TruncateString, { text: title }), titleTooltip: titleTooltip, subtitle: subtitle, image: image, "data-test-id": TEST_IDS.header }), _jsx(DrawerCustom.Body, { content: content, "data-test-id": TEST_IDS.content }), needFooter && (_jsx(DrawerCustom.Footer, { "data-test-id": TEST_IDS.footer, actions: _jsxs(_Fragment, { children: [approveButton && (_jsx(WithTooltip, { tooltip: approveButton.tooltip, children: _jsx(ButtonFilled, Object.assign({
|
|
22
|
+
return (_jsxs(DrawerCustom, Object.assign({}, rest, { push: Boolean(nestedDrawer) && { distance: NESTED_DRAWER_PUSH_DISTANCE }, children: [_jsx(DrawerCustom.Header, { title: _jsx(TruncateString, { text: title, maxLines: (truncate === null || truncate === void 0 ? void 0 : truncate.title) || 1 }), titleTooltip: titleTooltip, subtitle: subtitle ? _jsx(TruncateString, { text: subtitle, maxLines: (truncate === null || truncate === void 0 ? void 0 : truncate.subtitle) || 2 }) : undefined, image: image, "data-test-id": TEST_IDS.header }), _jsx(DrawerCustom.Body, { content: content, "data-test-id": TEST_IDS.content }), needFooter && (_jsx(DrawerCustom.Footer, { "data-test-id": TEST_IDS.footer, actions: _jsxs(_Fragment, { children: [approveButton && (_jsx(WithTooltip, { tooltip: approveButton.tooltip, children: _jsx(ButtonFilled, Object.assign({ appearance: 'primary', size: 'm', "data-test-id": TEST_IDS.approveButton }, approveButton)) })), cancelButton && (_jsx(WithTooltip, { tooltip: cancelButton.tooltip, children: _jsx(ButtonOutline, Object.assign({ appearance: 'neutral', size: 'm', "data-test-id": TEST_IDS.cancelButton }, cancelButton)) })), additionalButton && (_jsx(WithTooltip, { tooltip: additionalButton.tooltip, children: _jsx(ButtonSimple, Object.assign({ appearance: 'neutral', size: 'm', "data-test-id": TEST_IDS.additionalButton }, additionalButton)) }))] }) })), nestedDrawer] })));
|
|
23
23
|
}
|
|
@@ -17,5 +17,5 @@ import styles from './styles.module.css';
|
|
|
17
17
|
/** Вспомогательный компонент для добавления "тела" в DrawerCustom */
|
|
18
18
|
export function DrawerBody(_a) {
|
|
19
19
|
var { content, className } = _a, rest = __rest(_a, ["content", "className"]);
|
|
20
|
-
return (_jsx(Scroll, Object.assign({ size: 'm', className: cn(styles.drawerBody, className) }, extractSupportProps(rest), { children: content })));
|
|
20
|
+
return (_jsx(Scroll, Object.assign({ size: 'm', barHideStrategy: 'never', className: cn(styles.drawerBody, className) }, extractSupportProps(rest), { children: content })));
|
|
21
21
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Drawer",
|
|
7
|
-
"version": "0.7.
|
|
7
|
+
"version": "0.7.3-preview-b7b8cddc.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"classnames": "2.3.2",
|
|
43
43
|
"rc-drawer": "6.4.1"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "51fcb0a1cb316542cb346cf07448b9acf6fb9215"
|
|
46
46
|
}
|
|
@@ -27,13 +27,23 @@ export type DrawerProps = Omit<DrawerCustomProps, 'size' | 'children' | 'nestedD
|
|
|
27
27
|
/** Размер */
|
|
28
28
|
size?: Size;
|
|
29
29
|
/** Основная кнопка */
|
|
30
|
-
approveButton?: Omit<ButtonFilledProps, 'size'
|
|
30
|
+
approveButton?: Omit<ButtonFilledProps, 'size'> & { tooltip?: TooltipProps };
|
|
31
31
|
/** Кнопка отмены */
|
|
32
|
-
cancelButton?: Omit<ButtonOutlineProps, 'size'
|
|
32
|
+
cancelButton?: Omit<ButtonOutlineProps, 'size'> & { tooltip?: TooltipProps };
|
|
33
33
|
/** Дополнительная кнопка */
|
|
34
|
-
additionalButton?: Omit<ButtonSimpleProps, 'size'
|
|
34
|
+
additionalButton?: Omit<ButtonSimpleProps, 'size'> & { tooltip?: TooltipProps };
|
|
35
35
|
/** Вложенный Drawer */
|
|
36
36
|
nestedDrawer?: ReactElement<DrawerProps>;
|
|
37
|
+
/**
|
|
38
|
+
* Максимальное кол-во строк
|
|
39
|
+
* <br> - `title` - в заголовке
|
|
40
|
+
* <br> - `subtitle` - в подзаголовке
|
|
41
|
+
* @default '{ <br>title: 1; <br>subtitle: 2; }'
|
|
42
|
+
*/
|
|
43
|
+
truncate?: {
|
|
44
|
+
title?: number;
|
|
45
|
+
subtitle?: number;
|
|
46
|
+
};
|
|
37
47
|
};
|
|
38
48
|
|
|
39
49
|
/** Готовый компонент Drawer */
|
|
@@ -47,6 +57,7 @@ export function Drawer({
|
|
|
47
57
|
cancelButton,
|
|
48
58
|
additionalButton,
|
|
49
59
|
nestedDrawer,
|
|
60
|
+
truncate,
|
|
50
61
|
...rest
|
|
51
62
|
}: DrawerProps) {
|
|
52
63
|
const needFooter = Boolean(approveButton) || Boolean(cancelButton) || Boolean(additionalButton);
|
|
@@ -54,9 +65,9 @@ export function Drawer({
|
|
|
54
65
|
return (
|
|
55
66
|
<DrawerCustom {...rest} push={Boolean(nestedDrawer) && { distance: NESTED_DRAWER_PUSH_DISTANCE }}>
|
|
56
67
|
<DrawerCustom.Header
|
|
57
|
-
title={<TruncateString text={title} />}
|
|
68
|
+
title={<TruncateString text={title} maxLines={truncate?.title || 1} />}
|
|
58
69
|
titleTooltip={titleTooltip}
|
|
59
|
-
subtitle={subtitle}
|
|
70
|
+
subtitle={subtitle ? <TruncateString text={subtitle} maxLines={truncate?.subtitle || 2} /> : undefined}
|
|
60
71
|
image={image}
|
|
61
72
|
data-test-id={TEST_IDS.header}
|
|
62
73
|
/>
|
|
@@ -70,19 +81,29 @@ export function Drawer({
|
|
|
70
81
|
<>
|
|
71
82
|
{approveButton && (
|
|
72
83
|
<WithTooltip tooltip={approveButton.tooltip}>
|
|
73
|
-
<ButtonFilled
|
|
84
|
+
<ButtonFilled
|
|
85
|
+
appearance='primary'
|
|
86
|
+
size='m'
|
|
87
|
+
data-test-id={TEST_IDS.approveButton}
|
|
88
|
+
{...approveButton}
|
|
89
|
+
/>
|
|
74
90
|
</WithTooltip>
|
|
75
91
|
)}
|
|
76
92
|
|
|
77
93
|
{cancelButton && (
|
|
78
94
|
<WithTooltip tooltip={cancelButton.tooltip}>
|
|
79
|
-
<ButtonOutline
|
|
95
|
+
<ButtonOutline appearance='neutral' size='m' data-test-id={TEST_IDS.cancelButton} {...cancelButton} />
|
|
80
96
|
</WithTooltip>
|
|
81
97
|
)}
|
|
82
98
|
|
|
83
99
|
{additionalButton && (
|
|
84
100
|
<WithTooltip tooltip={additionalButton.tooltip}>
|
|
85
|
-
<ButtonSimple
|
|
101
|
+
<ButtonSimple
|
|
102
|
+
appearance='neutral'
|
|
103
|
+
size='m'
|
|
104
|
+
data-test-id={TEST_IDS.additionalButton}
|
|
105
|
+
{...additionalButton}
|
|
106
|
+
/>
|
|
86
107
|
</WithTooltip>
|
|
87
108
|
)}
|
|
88
109
|
</>
|
|
@@ -16,7 +16,12 @@ export type DrawerBodyProps = WithSupportProps<{
|
|
|
16
16
|
/** Вспомогательный компонент для добавления "тела" в DrawerCustom */
|
|
17
17
|
export function DrawerBody({ content, className, ...rest }: DrawerBodyProps) {
|
|
18
18
|
return (
|
|
19
|
-
<Scroll
|
|
19
|
+
<Scroll
|
|
20
|
+
size='m'
|
|
21
|
+
barHideStrategy='never'
|
|
22
|
+
className={cn(styles.drawerBody, className)}
|
|
23
|
+
{...extractSupportProps(rest)}
|
|
24
|
+
>
|
|
20
25
|
{content}
|
|
21
26
|
</Scroll>
|
|
22
27
|
);
|