@snack-uikit/notification 0.10.18 → 0.10.19-preview-9ca6ecbf.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
@@ -81,70 +81,24 @@ const cards = [
81
81
  ### Props
82
82
  | name | type | default value | description |
83
83
  |------|------|---------------|-------------|
84
- | date* | `string` | - | Дата уведомления |
85
- | content* | `ReactNode` | - | Контент уведомления |
86
- | title* | `string` | - | Заголовок уведомления |
87
- | id* | `string` | - | Идентификатор уведомления |
88
- | appearance | enum Appearance: `"neutral"`, `"error"`, `"errorCritical"`, `"warning"`, `"success"` | neutral | Тип уведомления |
89
- | label | `string` | - | Лейбл перед заголовком |
90
- | unread | `boolean` | - | Управление состоянием прочитано/не прочитано |
91
- | link | `Omit<LinkProps, "data-test-id" \| "appearance" \| "size" \| "textMode">` | - | Ссылка |
92
- | onClick | `MouseEventHandler<HTMLDivElement>` | - | Колбэк клика по карточке |
93
- | onVisible | `(cardId: string) => void` | - | Колбэк при попадании карточки в область видимости на 80% |
94
- | primaryButton | `Omit<ButtonTonalProps, "data-test-id" \| "appearance" \| "size">` | - | Кнопка главного действия у карточки |
95
- | secondaryButton | `Omit<ButtonSimpleProps, "data-test-id" \| "appearance" \| "size">` | - | Кнопка второстепенного действия у карточки |
96
- | actions | `Action[]` | - | Дополнительные действия у карточки |
97
- | className | `string` | - | CSS-класс |
98
84
  ## NotificationPanel
99
85
  Компонент панели для уведомлений
100
86
  ### Props
101
87
  | name | type | default value | description |
102
88
  |------|------|---------------|-------------|
103
- | title* | `string` | - | Заголовок панели |
104
- | settings | `NotificationPanelSettingsProps` | - | Кнопка настроек и выпадающий список |
105
- | chips | `Omit<ChipToggleProps, "data-test-id" \| "size">[]` | - | Чипы для фильтрации |
106
- | readAllButton | `Omit<ButtonFunctionProps, "data-test-id"> & { onClick: MouseEventHandler<HTMLElement>; }` | - | Кнопка в "шапке" панели |
107
- | footerButton | `{ label: string; onClick: MouseEventHandler<HTMLButtonElement>; }` | - | Кнопка внизу панели |
108
- | className | `string` | - | CSS-класс |
109
- | loading | `boolean` | - | Состояние загрузки |
110
- | content | `ReactNode` | - | Контент для отрисовки (e.g NotificationCard \| NotificationPanel.Blank) |
111
- | skeletonsAmount | `number` | 2 | Количество скелетонов карточек для отображения при загрузке |
112
- | scrollEndRef | `RefObject<HTMLDivElement>` | - | Ссылка на элемент, обозначающий самый конец прокручиваемого списка |
113
- | scrollContainerRef | `RefObject<HTMLElement>` | - | Ссылка на контейнер, который скроллится |
114
89
  ## NotificationPanel.Blank
115
90
  ### Props
116
91
  | name | type | default value | description |
117
92
  |------|------|---------------|-------------|
118
- | title | `string` | - | Заголовок |
119
- | className | `string` | - | CSS-класс |
120
- | icon | `Pick<IconPredefinedProps, "appearance" \| "icon" \| "decor">` | - | Иконка |
121
- | description | `ReactNode` | - | Подзаголовок |
122
93
  ## NotificationPanel.Divider
123
94
  ### Props
124
95
  | name | type | default value | description |
125
96
  |------|------|---------------|-------------|
126
- | text* | `string` | - | Текст разделителя |
127
- | className | `string` | - | CSS-класс |
128
97
  ## NotificationPanelPopover
129
98
  Компонент-обёртка для NotificationPanel для использования как выпадающий элемент
130
99
  ### Props
131
100
  | name | type | default value | description |
132
101
  |------|------|---------------|-------------|
133
- | content* | `ReactElement<NotificationPanelProps, typeof NotificationPanel>` | - | |
134
- | contentClassName | `string` | - | CSS-класс для элемента содержащего контент |
135
- | className | `string` | - | CSS-класс |
136
- | triggerClassName | `string` | - | CSS-класс триггера |
137
- | open | `boolean` | - | Управляет состоянием показан/не показан. |
138
- | onOpenChange | `(isOpen: boolean) => void` | - | Колбек отображения компонента. Срабатывает при изменении состояния open. |
139
- | hoverDelayOpen | `number` | - | Задержка открытия по ховеру |
140
- | hoverDelayClose | `number` | - | Задержка закрытия по ховеру |
141
- | offset | `number` | 0 | Отступ поповера от его триггер-элемента (в пикселях). |
142
- | children | `ReactNode \| ChildrenFunction` | - | Триггер поповера (подробнее читайте ниже) |
143
- | closeOnEscapeKey | `boolean` | true | Закрывать ли по нажатию на кнопку `Esc` |
144
- | triggerClickByKeys | `boolean` | true | Вызывается ли попоповер по нажатию клавиш Enter/Space (при trigger = `click`) |
145
- | triggerRef | `ForwardedRef<HTMLElement \| ReferenceType>` | - | Ref ссылка на триггер |
146
- | trigger | enum Trigger: `"click"`, `"hover"`, `"focusVisible"`, `"focus"`, `"hoverAndFocusVisible"`, `"hoverAndFocus"`, `"clickAndFocusVisible"` | click | Условие отображения поповера: <br> - `click` - открывать по клику <br> - `hover` - открывать по ховеру <br> - `focusVisible` - открывать по focus-visible <br> - `focus` - открывать по фокусу <br> - `hoverAndFocusVisible` - открывать по ховеру и focus-visible <br> - `hoverAndFocus` - открывать по ховеру и фокусу <br> - `clickAndFocusVisible` - открывать по клику и focus-visible |
147
- | placement | enum Placement: `"left"`, `"left-start"`, `"left-end"`, `"right"`, `"right-start"`, `"right-end"`, `"top"`, `"top-start"`, `"top-end"`, `"bottom"`, `"bottom-start"`, `"bottom-end"` | bottom-end | Положение поповера относительно своего триггера (children). |
148
102
 
149
103
 
150
104
  [//]: DOCUMENTATION_SECTION_END
@@ -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 { LinkProps } from '@snack-uikit/link';
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?: Omit<LinkProps, 'size' | 'appearance' | 'textMode' | 'data-test-id'>;
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 { LinkProps } from '@snack-uikit/link';
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?: Omit<LinkProps, 'size' | 'appearance' | 'textMode' | 'data-test-id'>;
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.10.18",
7
+ "version": "0.10.19-preview-9ca6ecbf.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -40,7 +40,7 @@
40
40
  "@snack-uikit/chips": "0.25.3",
41
41
  "@snack-uikit/icons": "0.24.2",
42
42
  "@snack-uikit/info-block": "0.6.13",
43
- "@snack-uikit/link": "0.15.9",
43
+ "@snack-uikit/link": "0.15.10-preview-9ca6ecbf.0",
44
44
  "@snack-uikit/list": "0.26.0",
45
45
  "@snack-uikit/popover-private": "0.14.5",
46
46
  "@snack-uikit/scroll": "0.9.3",
@@ -51,5 +51,5 @@
51
51
  "@snack-uikit/utils": "3.7.0",
52
52
  "classnames": "2.5.1"
53
53
  },
54
- "gitHead": "ad5274413320bf7880ba3c2d1124610281d0de81"
54
+ "gitHead": "5997fdf5027fd7d355a1e0396b3cedcb86795b6d"
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?: Omit<LinkProps, 'size' | 'appearance' | 'textMode' | 'data-test-id'>;
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'];