@snack-uikit/notification 0.10.24 → 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
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.11.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.10.24 (2025-03-05)
|
|
7
18
|
|
|
8
19
|
### Only dependencies have been changed
|
package/README.md
CHANGED
|
@@ -88,7 +88,7 @@ const cards = [
|
|
|
88
88
|
| appearance | enum Appearance: `"neutral"`, `"error"`, `"errorCritical"`, `"warning"`, `"success"` | neutral | Тип уведомления |
|
|
89
89
|
| label | `string` | - | Лейбл перед заголовком |
|
|
90
90
|
| unread | `boolean` | - | Управление состоянием прочитано/не прочитано |
|
|
91
|
-
| link | `
|
|
91
|
+
| link | `PickLinkProps<LinkElement, "text" \| "insideText" \| "truncateVariant">` | - | Ссылка |
|
|
92
92
|
| onClick | `MouseEventHandler<HTMLDivElement>` | - | Колбэк клика по карточке |
|
|
93
93
|
| onVisible | `(cardId: string) => void` | - | Колбэк при попадании карточки в область видимости на 80% |
|
|
94
94
|
| primaryButton | `Omit<ButtonTonalProps, "data-test-id" \| "appearance" \| "size">` | - | Кнопка главного действия у карточки |
|
|
@@ -133,13 +133,13 @@ const cards = [
|
|
|
133
133
|
| content* | `ReactElement<NotificationPanelProps, typeof NotificationPanel>` | - | |
|
|
134
134
|
| contentClassName | `string` | - | CSS-класс для элемента содержащего контент |
|
|
135
135
|
| className | `string` | - | CSS-класс |
|
|
136
|
+
| children | `ReactNode \| ChildrenFunction` | - | Триггер поповера (подробнее читайте ниже) |
|
|
136
137
|
| triggerClassName | `string` | - | CSS-класс триггера |
|
|
137
138
|
| open | `boolean` | - | Управляет состоянием показан/не показан. |
|
|
138
139
|
| onOpenChange | `(isOpen: boolean) => void` | - | Колбек отображения компонента. Срабатывает при изменении состояния open. |
|
|
139
140
|
| hoverDelayOpen | `number` | - | Задержка открытия по ховеру |
|
|
140
141
|
| hoverDelayClose | `number` | - | Задержка закрытия по ховеру |
|
|
141
142
|
| offset | `number` | 0 | Отступ поповера от его триггер-элемента (в пикселях). |
|
|
142
|
-
| children | `ReactNode \| ChildrenFunction` | - | Триггер поповера (подробнее читайте ниже) |
|
|
143
143
|
| closeOnEscapeKey | `boolean` | true | Закрывать ли по нажатию на кнопку `Esc` |
|
|
144
144
|
| triggerClickByKeys | `boolean` | true | Вызывается ли попоповер по нажатию клавиш Enter/Space (при trigger = `click`) |
|
|
145
145
|
| triggerRef | `ForwardedRef<HTMLElement \| ReferenceType>` | - | Ref ссылка на триггер |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MouseEventHandler, ReactElement, ReactNode } from 'react';
|
|
1
|
+
import { ElementType, MouseEventHandler, ReactElement, ReactNode } from 'react';
|
|
2
2
|
import { ButtonSimpleProps, ButtonTonalProps } from '@snack-uikit/button';
|
|
3
|
-
import {
|
|
3
|
+
import { PickLinkProps } from '@snack-uikit/link';
|
|
4
4
|
import { BaseItemProps } from '@snack-uikit/list';
|
|
5
5
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
6
6
|
import { Appearance } from './types';
|
|
@@ -8,7 +8,7 @@ type Action = {
|
|
|
8
8
|
icon?: ReactElement;
|
|
9
9
|
tagLabel?: string;
|
|
10
10
|
} & Pick<BaseItemProps, 'content' | 'onClick' | 'disabled'>;
|
|
11
|
-
export type NotificationCardProps = WithSupportProps<{
|
|
11
|
+
export type NotificationCardProps<LinkElement extends ElementType = 'a'> = WithSupportProps<{
|
|
12
12
|
/** Идентификатор уведомления */
|
|
13
13
|
id: string;
|
|
14
14
|
/** Тип уведомления */
|
|
@@ -22,7 +22,7 @@ export type NotificationCardProps = WithSupportProps<{
|
|
|
22
22
|
/** Контент уведомления */
|
|
23
23
|
content: ReactNode;
|
|
24
24
|
/** Ссылка */
|
|
25
|
-
link?:
|
|
25
|
+
link?: PickLinkProps<LinkElement, 'text' | 'insideText' | 'truncateVariant'>;
|
|
26
26
|
/** Дата уведомления */
|
|
27
27
|
date: string;
|
|
28
28
|
/** Колбэк клика по карточке */
|
|
@@ -39,5 +39,5 @@ export type NotificationCardProps = WithSupportProps<{
|
|
|
39
39
|
className?: string;
|
|
40
40
|
}>;
|
|
41
41
|
/** Компонент карточки уведомления */
|
|
42
|
-
export declare function NotificationCard({ id, appearance, label, unread, title, content, link, date, onClick, primaryButton, secondaryButton, actions, onVisible, className, ...rest }: NotificationCardProps): import("react/jsx-runtime").JSX.Element;
|
|
42
|
+
export declare function NotificationCard<LinkElement extends ElementType = 'a'>({ id, appearance, label, unread, title, content, link, date, onClick, primaryButton, secondaryButton, actions, onVisible, className, ...rest }: NotificationCardProps<LinkElement>): import("react/jsx-runtime").JSX.Element;
|
|
43
43
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MouseEventHandler, ReactElement, ReactNode } from 'react';
|
|
1
|
+
import { ElementType, MouseEventHandler, ReactElement, ReactNode } from 'react';
|
|
2
2
|
import { ButtonSimpleProps, ButtonTonalProps } from '@snack-uikit/button';
|
|
3
|
-
import {
|
|
3
|
+
import { PickLinkProps } from '@snack-uikit/link';
|
|
4
4
|
import { BaseItemProps } from '@snack-uikit/list';
|
|
5
5
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
6
6
|
import { Appearance } from './types';
|
|
@@ -8,7 +8,7 @@ type Action = {
|
|
|
8
8
|
icon?: ReactElement;
|
|
9
9
|
tagLabel?: string;
|
|
10
10
|
} & Pick<BaseItemProps, 'content' | 'onClick' | 'disabled'>;
|
|
11
|
-
export type NotificationCardProps = WithSupportProps<{
|
|
11
|
+
export type NotificationCardProps<LinkElement extends ElementType = 'a'> = WithSupportProps<{
|
|
12
12
|
/** Идентификатор уведомления */
|
|
13
13
|
id: string;
|
|
14
14
|
/** Тип уведомления */
|
|
@@ -22,7 +22,7 @@ export type NotificationCardProps = WithSupportProps<{
|
|
|
22
22
|
/** Контент уведомления */
|
|
23
23
|
content: ReactNode;
|
|
24
24
|
/** Ссылка */
|
|
25
|
-
link?:
|
|
25
|
+
link?: PickLinkProps<LinkElement, 'text' | 'insideText' | 'truncateVariant'>;
|
|
26
26
|
/** Дата уведомления */
|
|
27
27
|
date: string;
|
|
28
28
|
/** Колбэк клика по карточке */
|
|
@@ -39,5 +39,5 @@ export type NotificationCardProps = WithSupportProps<{
|
|
|
39
39
|
className?: string;
|
|
40
40
|
}>;
|
|
41
41
|
/** Компонент карточки уведомления */
|
|
42
|
-
export declare function NotificationCard({ id, appearance, label, unread, title, content, link, date, onClick, primaryButton, secondaryButton, actions, onVisible, className, ...rest }: NotificationCardProps): import("react/jsx-runtime").JSX.Element;
|
|
42
|
+
export declare function NotificationCard<LinkElement extends ElementType = 'a'>({ id, appearance, label, unread, title, content, link, date, onClick, primaryButton, secondaryButton, actions, onVisible, className, ...rest }: NotificationCardProps<LinkElement>): import("react/jsx-runtime").JSX.Element;
|
|
43
43
|
export {};
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Notification",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.11.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@snack-uikit/chips": "0.26.1",
|
|
41
41
|
"@snack-uikit/icons": "0.25.1",
|
|
42
42
|
"@snack-uikit/info-block": "0.6.16",
|
|
43
|
-
"@snack-uikit/link": "0.
|
|
43
|
+
"@snack-uikit/link": "0.16.0",
|
|
44
44
|
"@snack-uikit/list": "0.27.0",
|
|
45
45
|
"@snack-uikit/popover-private": "0.14.6",
|
|
46
46
|
"@snack-uikit/scroll": "0.9.4",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"@snack-uikit/utils": "3.8.0",
|
|
52
52
|
"classnames": "2.5.1"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "60f203360684328be8e6743048d0259574ded8b4"
|
|
55
55
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import cn from 'classnames';
|
|
2
|
-
import { MouseEventHandler, ReactElement, ReactNode, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { ElementType, MouseEventHandler, ReactElement, ReactNode, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
|
|
4
4
|
import { ButtonSimple, ButtonSimpleProps, ButtonTonal, ButtonTonalProps } from '@snack-uikit/button';
|
|
5
|
-
import { Link, LinkProps } from '@snack-uikit/link';
|
|
5
|
+
import { Link, LinkProps, PickLinkProps } from '@snack-uikit/link';
|
|
6
6
|
import { BaseItemProps } from '@snack-uikit/list';
|
|
7
7
|
import { TruncateString } from '@snack-uikit/truncate-string';
|
|
8
8
|
import { Typography } from '@snack-uikit/typography';
|
|
@@ -19,7 +19,7 @@ type Action = {
|
|
|
19
19
|
tagLabel?: string;
|
|
20
20
|
} & Pick<BaseItemProps, 'content' | 'onClick' | 'disabled'>;
|
|
21
21
|
|
|
22
|
-
export type NotificationCardProps = WithSupportProps<{
|
|
22
|
+
export type NotificationCardProps<LinkElement extends ElementType = 'a'> = WithSupportProps<{
|
|
23
23
|
/** Идентификатор уведомления */
|
|
24
24
|
id: string;
|
|
25
25
|
/** Тип уведомления */
|
|
@@ -33,7 +33,7 @@ export type NotificationCardProps = WithSupportProps<{
|
|
|
33
33
|
/** Контент уведомления */
|
|
34
34
|
content: ReactNode;
|
|
35
35
|
/** Ссылка */
|
|
36
|
-
link?:
|
|
36
|
+
link?: PickLinkProps<LinkElement, 'text' | 'insideText' | 'truncateVariant'>;
|
|
37
37
|
/** Дата уведомления */
|
|
38
38
|
date: string;
|
|
39
39
|
/** Колбэк клика по карточке */
|
|
@@ -51,7 +51,7 @@ export type NotificationCardProps = WithSupportProps<{
|
|
|
51
51
|
}>;
|
|
52
52
|
|
|
53
53
|
/** Компонент карточки уведомления */
|
|
54
|
-
export function NotificationCard({
|
|
54
|
+
export function NotificationCard<LinkElement extends ElementType = 'a'>({
|
|
55
55
|
id,
|
|
56
56
|
appearance = APPEARANCE.Neutral,
|
|
57
57
|
label,
|
|
@@ -67,7 +67,7 @@ export function NotificationCard({
|
|
|
67
67
|
onVisible,
|
|
68
68
|
className,
|
|
69
69
|
...rest
|
|
70
|
-
}: NotificationCardProps) {
|
|
70
|
+
}: NotificationCardProps<LinkElement>) {
|
|
71
71
|
const { icon, linkOnColor, buttonAppearance } = useMemo<{
|
|
72
72
|
icon: ReturnType<typeof getIcon>;
|
|
73
73
|
linkOnColor: LinkProps['appearance'];
|