@snack-uikit/modal 0.14.19 → 0.15.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 +11 -0
- package/README.md +1 -1
- package/dist/cjs/components/Modal/Modal.d.ts +3 -2
- package/dist/cjs/components/Modal/types.d.ts +7 -6
- package/dist/esm/components/Modal/Modal.d.ts +3 -2
- package/dist/esm/components/Modal/types.d.ts +7 -6
- package/package.json +3 -3
- package/src/components/Modal/Modal.tsx +8 -3
- package/src/components/Modal/types.ts +8 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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.15.0 (2025-03-06)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **SAEVO-161:** Allow custom link component integration. ([40ff813](https://github.com/cloud-ru-tech/snack-uikit/commit/40ff813a7d652e309df6d506c51b56a811c8edaa))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## 0.14.19 (2025-03-05)
|
|
7
18
|
|
|
8
19
|
### Only dependencies have been changed
|
package/README.md
CHANGED
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
| content | `ReactNode` | - | Содержимое модального окна |
|
|
66
66
|
| cancelButton | `Omit<ButtonOutlineProps, "data-test-id" \| "size">` | - | Кнопка отмены |
|
|
67
67
|
| additionalButton | `Omit<ButtonSimpleProps, "data-test-id" \| "size">` | - | Вторая кнопка действия |
|
|
68
|
-
| disclaimer | `{ text: string; link?:
|
|
68
|
+
| disclaimer | `{ text: string; link?: PickLinkProps<LinkElement, "text" \| "as">; }` | - | Небольшой текст под кнопками футера с возможностью передать дополнительно ссылку |
|
|
69
69
|
| truncate | `{ title?: number; subtitle?: number; }` | '{ <br>title: 1; <br>subtitle: 2; }' | Максимальное кол-во строк <br> - `title` - в заголовке <br> - `subtitle` - в подзаголовке |
|
|
70
70
|
| size | "s" \| "m" \| "l" | s | Размер |
|
|
71
71
|
| align | enum Align: `"vertical"`, `"default"`, `"center"` | default | Выравнивание, для разных размеров доступны разные значения <br> для size=`s` - все <br> для size=`m` - align=`default \| center` <br> для size=`l` - align=`default` |
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ElementType } from 'react';
|
|
1
2
|
import { ModalLProps, ModalMProps, ModalSProps } from './types';
|
|
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, truncate, className, ...rest }: ModalProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export type ModalProps<LinkElement extends ElementType = 'a'> = ModalSProps<LinkElement> | ModalMProps<LinkElement> | ModalLProps<LinkElement>;
|
|
4
|
+
export declare function Modal<LinkElement extends ElementType = 'a'>({ open, onClose, size, mode, align, title, titleTooltip, subtitle, picture: pictureProp, content, approveButton, cancelButton, additionalButton, disclaimer, truncate, className, ...rest }: ModalProps<LinkElement>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { ElementType } from 'react';
|
|
1
2
|
import { ButtonFilledProps, ButtonOutlineProps, ButtonSimpleProps } from '@snack-uikit/button';
|
|
2
|
-
import {
|
|
3
|
+
import { PickLinkProps } from '@snack-uikit/link';
|
|
3
4
|
import { ALIGN, SIZE } from '../../constants';
|
|
4
5
|
import { ModalBodyProps, ModalHeaderImage, ModalHeaderProps } from '../../helperComponents';
|
|
5
6
|
import { Align } from '../../types';
|
|
6
7
|
import { ModalCustomProps } from '../ModalCustom';
|
|
7
|
-
type BaseModalProps = Omit<ModalCustomProps, 'children' | 'size'> & {
|
|
8
|
+
type BaseModalProps<LinkElement extends ElementType = 'a'> = Omit<ModalCustomProps, 'children' | 'size'> & {
|
|
8
9
|
/** Заголовок модального окна */
|
|
9
10
|
title: string;
|
|
10
11
|
/** Всплывающая подсказка для заголовка */
|
|
@@ -22,7 +23,7 @@ type BaseModalProps = Omit<ModalCustomProps, 'children' | 'size'> & {
|
|
|
22
23
|
/** Небольшой текст под кнопками футера с возможностью передать дополнительно ссылку */
|
|
23
24
|
disclaimer?: {
|
|
24
25
|
text: string;
|
|
25
|
-
link?:
|
|
26
|
+
link?: PickLinkProps<LinkElement, 'text' | 'as'>;
|
|
26
27
|
};
|
|
27
28
|
/**
|
|
28
29
|
* Максимальное кол-во строк
|
|
@@ -35,7 +36,7 @@ type BaseModalProps = Omit<ModalCustomProps, 'children' | 'size'> & {
|
|
|
35
36
|
subtitle?: number;
|
|
36
37
|
};
|
|
37
38
|
};
|
|
38
|
-
export type ModalSProps = BaseModalProps & {
|
|
39
|
+
export type ModalSProps<LinkElement extends ElementType> = BaseModalProps<LinkElement> & {
|
|
39
40
|
/** Размер */
|
|
40
41
|
size?: typeof SIZE.S;
|
|
41
42
|
/**
|
|
@@ -46,13 +47,13 @@ export type ModalSProps = BaseModalProps & {
|
|
|
46
47
|
/** Можно передать иконку из пакета `@snack-uikit/icon-predefined`, или путь к картинке и атрибут `alt` */
|
|
47
48
|
picture?: ModalHeaderProps['picture'];
|
|
48
49
|
};
|
|
49
|
-
export type ModalMProps = BaseModalProps & {
|
|
50
|
+
export type ModalMProps<LinkElement extends ElementType> = BaseModalProps<LinkElement> & {
|
|
50
51
|
size?: typeof SIZE.M;
|
|
51
52
|
/** <br> для size=`m` - align=`default | center` */
|
|
52
53
|
align?: typeof ALIGN.Default | typeof ALIGN.Center;
|
|
53
54
|
picture?: ModalHeaderImage;
|
|
54
55
|
};
|
|
55
|
-
export type ModalLProps = BaseModalProps & {
|
|
56
|
+
export type ModalLProps<LinkElement extends ElementType> = BaseModalProps<LinkElement> & {
|
|
56
57
|
size?: typeof SIZE.L;
|
|
57
58
|
/** <br> для size=`l` - align=`default` */
|
|
58
59
|
align?: typeof ALIGN.Default;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ElementType } from 'react';
|
|
1
2
|
import { ModalLProps, ModalMProps, ModalSProps } from './types';
|
|
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, truncate, className, ...rest }: ModalProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export type ModalProps<LinkElement extends ElementType = 'a'> = ModalSProps<LinkElement> | ModalMProps<LinkElement> | ModalLProps<LinkElement>;
|
|
4
|
+
export declare function Modal<LinkElement extends ElementType = 'a'>({ open, onClose, size, mode, align, title, titleTooltip, subtitle, picture: pictureProp, content, approveButton, cancelButton, additionalButton, disclaimer, truncate, className, ...rest }: ModalProps<LinkElement>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { ElementType } from 'react';
|
|
1
2
|
import { ButtonFilledProps, ButtonOutlineProps, ButtonSimpleProps } from '@snack-uikit/button';
|
|
2
|
-
import {
|
|
3
|
+
import { PickLinkProps } from '@snack-uikit/link';
|
|
3
4
|
import { ALIGN, SIZE } from '../../constants';
|
|
4
5
|
import { ModalBodyProps, ModalHeaderImage, ModalHeaderProps } from '../../helperComponents';
|
|
5
6
|
import { Align } from '../../types';
|
|
6
7
|
import { ModalCustomProps } from '../ModalCustom';
|
|
7
|
-
type BaseModalProps = Omit<ModalCustomProps, 'children' | 'size'> & {
|
|
8
|
+
type BaseModalProps<LinkElement extends ElementType = 'a'> = Omit<ModalCustomProps, 'children' | 'size'> & {
|
|
8
9
|
/** Заголовок модального окна */
|
|
9
10
|
title: string;
|
|
10
11
|
/** Всплывающая подсказка для заголовка */
|
|
@@ -22,7 +23,7 @@ type BaseModalProps = Omit<ModalCustomProps, 'children' | 'size'> & {
|
|
|
22
23
|
/** Небольшой текст под кнопками футера с возможностью передать дополнительно ссылку */
|
|
23
24
|
disclaimer?: {
|
|
24
25
|
text: string;
|
|
25
|
-
link?:
|
|
26
|
+
link?: PickLinkProps<LinkElement, 'text' | 'as'>;
|
|
26
27
|
};
|
|
27
28
|
/**
|
|
28
29
|
* Максимальное кол-во строк
|
|
@@ -35,7 +36,7 @@ type BaseModalProps = Omit<ModalCustomProps, 'children' | 'size'> & {
|
|
|
35
36
|
subtitle?: number;
|
|
36
37
|
};
|
|
37
38
|
};
|
|
38
|
-
export type ModalSProps = BaseModalProps & {
|
|
39
|
+
export type ModalSProps<LinkElement extends ElementType> = BaseModalProps<LinkElement> & {
|
|
39
40
|
/** Размер */
|
|
40
41
|
size?: typeof SIZE.S;
|
|
41
42
|
/**
|
|
@@ -46,13 +47,13 @@ export type ModalSProps = BaseModalProps & {
|
|
|
46
47
|
/** Можно передать иконку из пакета `@snack-uikit/icon-predefined`, или путь к картинке и атрибут `alt` */
|
|
47
48
|
picture?: ModalHeaderProps['picture'];
|
|
48
49
|
};
|
|
49
|
-
export type ModalMProps = BaseModalProps & {
|
|
50
|
+
export type ModalMProps<LinkElement extends ElementType> = BaseModalProps<LinkElement> & {
|
|
50
51
|
size?: typeof SIZE.M;
|
|
51
52
|
/** <br> для size=`m` - align=`default | center` */
|
|
52
53
|
align?: typeof ALIGN.Default | typeof ALIGN.Center;
|
|
53
54
|
picture?: ModalHeaderImage;
|
|
54
55
|
};
|
|
55
|
-
export type ModalLProps = BaseModalProps & {
|
|
56
|
+
export type ModalLProps<LinkElement extends ElementType> = BaseModalProps<LinkElement> & {
|
|
56
57
|
size?: typeof SIZE.L;
|
|
57
58
|
/** <br> для size=`l` - align=`default` */
|
|
58
59
|
align?: typeof ALIGN.Default;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Modal",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.15.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@snack-uikit/button": "0.19.8",
|
|
40
40
|
"@snack-uikit/icon-predefined": "0.7.4",
|
|
41
41
|
"@snack-uikit/icons": "0.25.1",
|
|
42
|
-
"@snack-uikit/link": "0.
|
|
42
|
+
"@snack-uikit/link": "0.16.0",
|
|
43
43
|
"@snack-uikit/scroll": "0.9.4",
|
|
44
44
|
"@snack-uikit/tooltip": "0.16.5",
|
|
45
45
|
"@snack-uikit/truncate-string": "0.6.13",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/react-modal": "3.16.0"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "60f203360684328be8e6743048d0259574ded8b4"
|
|
55
55
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ElementType } from 'react';
|
|
2
|
+
|
|
1
3
|
import { ButtonFilled, ButtonOutline, ButtonSimple } from '@snack-uikit/button';
|
|
2
4
|
import { Link } from '@snack-uikit/link';
|
|
3
5
|
import { TruncateString } from '@snack-uikit/truncate-string';
|
|
@@ -9,9 +11,12 @@ import { ModalCustom } from '../ModalCustom';
|
|
|
9
11
|
import styles from './styles.module.scss';
|
|
10
12
|
import { ModalLProps, ModalMProps, ModalSProps } from './types';
|
|
11
13
|
|
|
12
|
-
export type ModalProps
|
|
14
|
+
export type ModalProps<LinkElement extends ElementType = 'a'> =
|
|
15
|
+
| ModalSProps<LinkElement>
|
|
16
|
+
| ModalMProps<LinkElement>
|
|
17
|
+
| ModalLProps<LinkElement>;
|
|
13
18
|
|
|
14
|
-
export function Modal({
|
|
19
|
+
export function Modal<LinkElement extends ElementType = 'a'>({
|
|
15
20
|
open,
|
|
16
21
|
onClose,
|
|
17
22
|
size = SIZE.S,
|
|
@@ -29,7 +34,7 @@ export function Modal({
|
|
|
29
34
|
truncate,
|
|
30
35
|
className,
|
|
31
36
|
...rest
|
|
32
|
-
}: ModalProps) {
|
|
37
|
+
}: ModalProps<LinkElement>) {
|
|
33
38
|
const aligns = getAlignProps({ align, size });
|
|
34
39
|
const buttonsSize = getButtonsSize({ align, size });
|
|
35
40
|
const picture = getPicture({ size, picture: pictureProp });
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import { ElementType } from 'react';
|
|
2
|
+
|
|
1
3
|
import { ButtonFilledProps, ButtonOutlineProps, ButtonSimpleProps } from '@snack-uikit/button';
|
|
2
|
-
import {
|
|
4
|
+
import { PickLinkProps } from '@snack-uikit/link';
|
|
3
5
|
|
|
4
6
|
import { ALIGN, SIZE } from '../../constants';
|
|
5
7
|
import { ModalBodyProps, ModalHeaderImage, ModalHeaderProps } from '../../helperComponents';
|
|
6
8
|
import { Align } from '../../types';
|
|
7
9
|
import { ModalCustomProps } from '../ModalCustom';
|
|
8
10
|
|
|
9
|
-
type BaseModalProps = Omit<ModalCustomProps, 'children' | 'size'> & {
|
|
11
|
+
type BaseModalProps<LinkElement extends ElementType = 'a'> = Omit<ModalCustomProps, 'children' | 'size'> & {
|
|
10
12
|
/** Заголовок модального окна */
|
|
11
13
|
title: string;
|
|
12
14
|
/** Всплывающая подсказка для заголовка */
|
|
@@ -24,7 +26,7 @@ type BaseModalProps = Omit<ModalCustomProps, 'children' | 'size'> & {
|
|
|
24
26
|
/** Небольшой текст под кнопками футера с возможностью передать дополнительно ссылку */
|
|
25
27
|
disclaimer?: {
|
|
26
28
|
text: string;
|
|
27
|
-
link?:
|
|
29
|
+
link?: PickLinkProps<LinkElement, 'text' | 'as'>;
|
|
28
30
|
};
|
|
29
31
|
/**
|
|
30
32
|
* Максимальное кол-во строк
|
|
@@ -38,7 +40,7 @@ type BaseModalProps = Omit<ModalCustomProps, 'children' | 'size'> & {
|
|
|
38
40
|
};
|
|
39
41
|
};
|
|
40
42
|
|
|
41
|
-
export type ModalSProps = BaseModalProps & {
|
|
43
|
+
export type ModalSProps<LinkElement extends ElementType> = BaseModalProps<LinkElement> & {
|
|
42
44
|
/** Размер */
|
|
43
45
|
size?: typeof SIZE.S;
|
|
44
46
|
/**
|
|
@@ -50,14 +52,14 @@ export type ModalSProps = BaseModalProps & {
|
|
|
50
52
|
picture?: ModalHeaderProps['picture'];
|
|
51
53
|
};
|
|
52
54
|
|
|
53
|
-
export type ModalMProps = BaseModalProps & {
|
|
55
|
+
export type ModalMProps<LinkElement extends ElementType> = BaseModalProps<LinkElement> & {
|
|
54
56
|
size?: typeof SIZE.M;
|
|
55
57
|
/** <br> для size=`m` - align=`default | center` */
|
|
56
58
|
align?: typeof ALIGN.Default | typeof ALIGN.Center;
|
|
57
59
|
picture?: ModalHeaderImage;
|
|
58
60
|
};
|
|
59
61
|
|
|
60
|
-
export type ModalLProps = BaseModalProps & {
|
|
62
|
+
export type ModalLProps<LinkElement extends ElementType> = BaseModalProps<LinkElement> & {
|
|
61
63
|
size?: typeof SIZE.L;
|
|
62
64
|
/** <br> для size=`l` - align=`default` */
|
|
63
65
|
align?: typeof ALIGN.Default;
|