@snack-uikit/modal 0.10.3 → 0.11.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/CHANGELOG.md +12 -0
- package/README.md +1 -0
- package/dist/components/Modal/Modal.d.ts +1 -1
- package/dist/components/Modal/Modal.js +2 -2
- package/dist/components/Modal/types.d.ts +10 -0
- package/dist/helperComponents/Body/Body.js +1 -1
- package/dist/helperComponents/Footer/styles.module.css +1 -1
- package/package.json +2 -2
- package/src/components/Modal/Modal.tsx +6 -2
- package/src/components/Modal/types.ts +10 -0
- package/src/helperComponents/Body/Body.tsx +1 -0
- package/src/helperComponents/Footer/styles.module.scss +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# 0.11.0 (2024-06-11)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **FF-4725:** add truncate prop ([b8ab633](https://github.com/cloud-ru-tech/snack-uikit/commit/b8ab633cfc672bcaea95b413a635956d96711f3e))
|
|
12
|
+
* **FF-4725:** set default footer appearances; add barHideStrategy never ([a1476a7](https://github.com/cloud-ru-tech/snack-uikit/commit/a1476a72af183c3293bb8aef313c2b5be62bb05b))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
## 0.10.3 (2024-06-11)
|
|
7
19
|
|
|
8
20
|
### Only dependencies have been changed
|
package/README.md
CHANGED
|
@@ -66,6 +66,7 @@
|
|
|
66
66
|
| cancelButton | `Omit<ButtonOutlineProps, "data-test-id" \| "size">` | - | Кнопка отмены |
|
|
67
67
|
| additionalButton | `Omit<ButtonSimpleProps, "data-test-id" \| "size">` | - | Вторая кнопка действия |
|
|
68
68
|
| disclaimer | `{ text: string; link?: Pick<LinkProps, "text" \| "href" \| "target" \| "external">; }` | - | Небольшой текст под кнопками футера с возможностью передать дополнительно ссылку |
|
|
69
|
+
| truncate | `{ title?: number; subtitle?: number; }` | '{ <br>title: 1; <br>subtitle: 2; }' | Максимальное кол-во строк <br> - `title` - в заголовке <br> - `subtitle` - в подзаголовке |
|
|
69
70
|
| size | "s" \| "m" \| "l" | s | Размер |
|
|
70
71
|
| align | enum Align: `"vertical"`, `"default"`, `"center"` | default | Выравнивание, для разных размеров доступны разные значения <br> для size=`s` - все <br> для size=`m` - align=`default \| center` <br> для size=`l` - align=`default` |
|
|
71
72
|
| picture | `JSXElementConstructor<{ size?: number; className?: string; }> \| ModalHeaderImage` | - | Можно передать иконку из пакета `@snack-uikit/icon-predefined`, или путь к картинке и атрибут `alt` |
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ModalLProps, ModalMProps, ModalSProps } from './types';
|
|
2
2
|
export type ModalProps = ModalSProps | ModalMProps | ModalLProps;
|
|
3
|
-
export declare function Modal({ open, onClose, size, mode, align, title, titleTooltip, subtitle, picture: pictureProp, content, approveButton, cancelButton, additionalButton, disclaimer, className, ...rest }: ModalProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare function Modal({ open, onClose, size, mode, align, title, titleTooltip, subtitle, picture: pictureProp, content, approveButton, cancelButton, additionalButton, disclaimer, truncate, className, ...rest }: ModalProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -19,9 +19,9 @@ import { getAlignProps, getButtonsSize, getPicture } from '../../utils';
|
|
|
19
19
|
import { ModalCustom } from '../ModalCustom';
|
|
20
20
|
import styles from './styles.module.css';
|
|
21
21
|
export function Modal(_a) {
|
|
22
|
-
var { open, onClose, size = SIZE.S, mode = MODE.Regular, align = ALIGN.Default, title, titleTooltip, subtitle, picture: pictureProp, content, approveButton, cancelButton, additionalButton, disclaimer, className } = _a, rest = __rest(_a, ["open", "onClose", "size", "mode", "align", "title", "titleTooltip", "subtitle", "picture", "content", "approveButton", "cancelButton", "additionalButton", "disclaimer", "className"]);
|
|
22
|
+
var { open, onClose, size = SIZE.S, mode = MODE.Regular, align = ALIGN.Default, title, titleTooltip, subtitle, picture: pictureProp, content, approveButton, cancelButton, additionalButton, disclaimer, truncate, className } = _a, rest = __rest(_a, ["open", "onClose", "size", "mode", "align", "title", "titleTooltip", "subtitle", "picture", "content", "approveButton", "cancelButton", "additionalButton", "disclaimer", "truncate", "className"]);
|
|
23
23
|
const aligns = getAlignProps({ align, size });
|
|
24
24
|
const buttonsSize = getButtonsSize({ align, size });
|
|
25
25
|
const picture = getPicture({ size, picture: pictureProp });
|
|
26
|
-
return (_jsxs(ModalCustom, Object.assign({ open: open, onClose: onClose, size: size, mode: mode, className: className }, rest, { children: [_jsx(ModalCustom.Header, { title: _jsx(TruncateString, { text: title }), titleTooltip: titleTooltip, subtitle: subtitle, picture: picture, align: aligns.header }), Boolean(content) && _jsx(ModalCustom.Body, { content: content, align: aligns.body }), _jsx(ModalCustom.Footer, { actions: _jsxs(_Fragment, { children: [_jsx(ButtonFilled, Object.assign({}, approveButton, { size: buttonsSize, className: styles.footerButton, "data-test-id": TEST_IDS.approveButton })), cancelButton && (_jsx(ButtonOutline, Object.assign({}, cancelButton, { size: buttonsSize, className: styles.footerButton, "data-test-id": TEST_IDS.cancelButton }))), additionalButton && (_jsx(ButtonSimple, Object.assign({}, additionalButton, { size: buttonsSize, className: styles.footerButton, "data-test-id": TEST_IDS.additionalButton })))] }), disclaimer: disclaimer && (_jsxs(_Fragment, { children: [_jsx(Typography.SansBodyS, { "data-test-id": TEST_IDS.disclaimerText, children: disclaimer.text }), disclaimer.link && (_jsx(Link, Object.assign({ external: true }, disclaimer.link, { size: 's', "data-test-id": TEST_IDS.disclaimerLink })))] })), align: aligns.footer, className: styles.modalFooter })] })));
|
|
26
|
+
return (_jsxs(ModalCustom, Object.assign({ open: open, onClose: onClose, size: size, mode: mode, className: className }, rest, { children: [_jsx(ModalCustom.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, picture: picture, align: aligns.header }), Boolean(content) && _jsx(ModalCustom.Body, { content: content, align: aligns.body }), _jsx(ModalCustom.Footer, { actions: _jsxs(_Fragment, { children: [_jsx(ButtonFilled, Object.assign({ appearance: 'primary' }, approveButton, { size: buttonsSize, className: styles.footerButton, "data-test-id": TEST_IDS.approveButton })), cancelButton && (_jsx(ButtonOutline, Object.assign({ appearance: 'neutral' }, cancelButton, { size: buttonsSize, className: styles.footerButton, "data-test-id": TEST_IDS.cancelButton }))), additionalButton && (_jsx(ButtonSimple, Object.assign({ appearance: 'neutral' }, additionalButton, { size: buttonsSize, className: styles.footerButton, "data-test-id": TEST_IDS.additionalButton })))] }), disclaimer: disclaimer && (_jsxs(_Fragment, { children: [_jsx(Typography.SansBodyS, { "data-test-id": TEST_IDS.disclaimerText, children: disclaimer.text }), disclaimer.link && (_jsx(Link, Object.assign({ external: true }, disclaimer.link, { size: 's', "data-test-id": TEST_IDS.disclaimerLink })))] })), align: aligns.footer, className: styles.modalFooter })] })));
|
|
27
27
|
}
|
|
@@ -24,6 +24,16 @@ type BaseModalProps = Omit<ModalCustomProps, 'children' | 'size'> & {
|
|
|
24
24
|
text: string;
|
|
25
25
|
link?: Pick<LinkProps, 'text' | 'href' | 'target' | 'external'>;
|
|
26
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* Максимальное кол-во строк
|
|
29
|
+
* <br> - `title` - в заголовке
|
|
30
|
+
* <br> - `subtitle` - в подзаголовке
|
|
31
|
+
* @default '{ <br>title: 1; <br>subtitle: 2; }'
|
|
32
|
+
*/
|
|
33
|
+
truncate?: {
|
|
34
|
+
title?: number;
|
|
35
|
+
subtitle?: number;
|
|
36
|
+
};
|
|
27
37
|
};
|
|
28
38
|
export type ModalSProps = BaseModalProps & {
|
|
29
39
|
/** Размер */
|
|
@@ -17,5 +17,5 @@ import { CONTENT_ALIGN, TEST_IDS } from '../../constants';
|
|
|
17
17
|
import styles from './styles.module.css';
|
|
18
18
|
export function ModalBody(_a) {
|
|
19
19
|
var { content, align = CONTENT_ALIGN.Default, className } = _a, rest = __rest(_a, ["content", "align", "className"]);
|
|
20
|
-
return (_jsx(Scroll, Object.assign({ size: 'm', className: cn(styles.modalBody, className) }, extractSupportProps(rest), { "data-align": align, "data-test-id": TEST_IDS.content, children: content })));
|
|
20
|
+
return (_jsx(Scroll, Object.assign({ size: 'm', barHideStrategy: 'never', className: cn(styles.modalBody, className) }, extractSupportProps(rest), { "data-align": align, "data-test-id": TEST_IDS.content, children: content })));
|
|
21
21
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Modal",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.11.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/react-modal": "3.16.0"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "f226092b402335a7839f0e476b7371fd21c2509c"
|
|
51
51
|
}
|
|
@@ -26,6 +26,7 @@ export function Modal({
|
|
|
26
26
|
cancelButton,
|
|
27
27
|
additionalButton,
|
|
28
28
|
disclaimer,
|
|
29
|
+
truncate,
|
|
29
30
|
className,
|
|
30
31
|
...rest
|
|
31
32
|
}: ModalProps) {
|
|
@@ -36,9 +37,9 @@ export function Modal({
|
|
|
36
37
|
return (
|
|
37
38
|
<ModalCustom open={open} onClose={onClose} size={size} mode={mode} className={className} {...rest}>
|
|
38
39
|
<ModalCustom.Header
|
|
39
|
-
title={<TruncateString text={title} />}
|
|
40
|
+
title={<TruncateString text={title} maxLines={truncate?.title || 1} />}
|
|
40
41
|
titleTooltip={titleTooltip}
|
|
41
|
-
subtitle={subtitle}
|
|
42
|
+
subtitle={subtitle ? <TruncateString text={subtitle} maxLines={truncate?.subtitle || 2} /> : undefined}
|
|
42
43
|
picture={picture}
|
|
43
44
|
align={aligns.header}
|
|
44
45
|
/>
|
|
@@ -49,6 +50,7 @@ export function Modal({
|
|
|
49
50
|
actions={
|
|
50
51
|
<>
|
|
51
52
|
<ButtonFilled
|
|
53
|
+
appearance='primary'
|
|
52
54
|
{...approveButton}
|
|
53
55
|
size={buttonsSize}
|
|
54
56
|
className={styles.footerButton}
|
|
@@ -57,6 +59,7 @@ export function Modal({
|
|
|
57
59
|
|
|
58
60
|
{cancelButton && (
|
|
59
61
|
<ButtonOutline
|
|
62
|
+
appearance='neutral'
|
|
60
63
|
{...cancelButton}
|
|
61
64
|
size={buttonsSize}
|
|
62
65
|
className={styles.footerButton}
|
|
@@ -66,6 +69,7 @@ export function Modal({
|
|
|
66
69
|
|
|
67
70
|
{additionalButton && (
|
|
68
71
|
<ButtonSimple
|
|
72
|
+
appearance='neutral'
|
|
69
73
|
{...additionalButton}
|
|
70
74
|
size={buttonsSize}
|
|
71
75
|
className={styles.footerButton}
|
|
@@ -26,6 +26,16 @@ type BaseModalProps = Omit<ModalCustomProps, 'children' | 'size'> & {
|
|
|
26
26
|
text: string;
|
|
27
27
|
link?: Pick<LinkProps, 'text' | 'href' | 'target' | 'external'>;
|
|
28
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* Максимальное кол-во строк
|
|
31
|
+
* <br> - `title` - в заголовке
|
|
32
|
+
* <br> - `subtitle` - в подзаголовке
|
|
33
|
+
* @default '{ <br>title: 1; <br>subtitle: 2; }'
|
|
34
|
+
*/
|
|
35
|
+
truncate?: {
|
|
36
|
+
title?: number;
|
|
37
|
+
subtitle?: number;
|
|
38
|
+
};
|
|
29
39
|
};
|
|
30
40
|
|
|
31
41
|
export type ModalSProps = BaseModalProps & {
|