@snack-uikit/notification 0.6.11-preview-357970fd.0 → 0.6.11

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,16 @@
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.6.11 (2024-02-08)
7
+
8
+ ### Only dependencies have been changed
9
+ * [@snack-uikit/chips@0.11.2](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/chips/CHANGELOG.md)
10
+ * [@snack-uikit/list@0.3.1](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/list/CHANGELOG.md)
11
+
12
+
13
+
14
+
15
+
6
16
  ## 0.6.10 (2024-02-07)
7
17
 
8
18
  ### Only dependencies have been changed
package/README.md CHANGED
@@ -98,17 +98,28 @@ const cards = [
98
98
  ### Props
99
99
  | name | type | default value | description |
100
100
  |------|------|---------------|-------------|
101
+ | triggerElement* | `ReactNode \| ChildrenFunction` | - | Элемент для открытия панели |
101
102
  | title* | `string` | - | Заголовок панели |
102
103
  | settings | `NotificationPanelSettingsProps` | - | Кнопка настроек и выпадающий список |
103
104
  | chips | `Omit<ChipToggleProps, "data-test-id" \| "size">[]` | - | Чипы для фильтрации |
104
105
  | readAllButton | `Omit<ButtonFunctionProps, "data-test-id"> & { onClick: MouseEventHandler<HTMLElement>; }` | - | Кнопка в "шапке" панели |
105
106
  | footerButton | `{ label: string; onClick: MouseEventHandler<HTMLButtonElement>; }` | - | Кнопка внизу панели |
106
- | className | `string` | - | CSS-класс |
107
107
  | loading | `boolean` | - | Состояние загрузки |
108
108
  | content | `ReactNode` | - | Контент для отрисовки (e.g NotificationCard \| NotificationPanel.Blank) |
109
109
  | skeletonsAmount | `number` | 2 | Количество скелетонов карточек для отображения при загрузке |
110
- | scrollRef | `RefObject<HTMLElement>` | - | Ссылка на элемент, обозначающий самый конец прокручиваемого списка |
111
- | scrollContainerRef | `RefObject<HTMLElement>` | - | Ссылка на контейнер, который скроллится |
110
+ | className | `string` | - | CSS-класс |
111
+ | triggerClassName | `string` | - | CSS-класс триггера |
112
+ | open | `boolean` | - | Управляет состоянием показан/не показан. |
113
+ | onOpenChange | `(isOpen: boolean) => void` | - | Колбек отображения компонента. Срабатывает при изменении состояния open. |
114
+ | hoverDelayOpen | `number` | - | Задержка открытия по ховеру |
115
+ | hoverDelayClose | `number` | - | Задержка закрытия по ховеру |
116
+ | offset | `number` | 0 | Отступ поповера от его триггер-элемента (в пикселях). |
117
+ | closeOnEscapeKey | `boolean` | true | Закрывать ли по нажатию на кнопку `Esc` |
118
+ | triggerClickByKeys | `boolean` | true | Вызывается ли попоповер по нажатию клавиш Enter/Space (при trigger = `click`) |
119
+ | triggerRef | `ForwardedRef<HTMLElement \| ReferenceType>` | - | Ref ссылка на триггер |
120
+ | trigger | enum Trigger: `"click"`, `"hover"`, `"focusVisible"`, `"focus"`, `"hoverAndFocusVisible"`, `"hoverAndFocus"`, `"clickAndFocusVisible"` | - | Условие отображения поповера: <br> - `click` - открывать по клику <br> - `hover` - открывать по ховеру <br> - `focusVisible` - открывать по focus-visible <br> - `focus` - открывать по фокусу <br> - `hoverAndFocusVisible` - открывать по ховеру и focus-visible <br> - `hoverAndFocus` - открывать по ховеру и фокусу <br> - `clickAndFocusVisible` - открывать по клику и focus-visible |
121
+ | placement | enum Placement: `"left"`, `"left-start"`, `"left-end"`, `"right"`, `"right-start"`, `"right-end"`, `"top"`, `"top-start"`, `"top-end"`, `"bottom"`, `"bottom-start"`, `"bottom-end"` | top | Положение поповера относительно своего триггера (children). |
122
+ | contentClassName | `string` | - | CSS-класс для элемента содержащего контент |
112
123
  ## NotificationPanel.Blank
113
124
  ### Props
114
125
  | name | type | default value | description |
@@ -1,10 +1,10 @@
1
- import { MouseEventHandler, ReactNode, RefObject } from 'react';
1
+ import { MouseEventHandler, ReactNode } from 'react';
2
2
  import { ButtonFunctionProps } from '@snack-uikit/button';
3
3
  import { ChipToggleProps } from '@snack-uikit/chips';
4
- import { WithSupportProps } from '@snack-uikit/utils';
4
+ import { NotificationPanelPopoverProps } from '../../helperComponents';
5
5
  import { NotificationPanelBlank, NotificationPanelBlankProps, NotificationPanelSettingsProps } from './components';
6
6
  export type { NotificationPanelBlankProps };
7
- export type NotificationPanelProps = WithSupportProps<{
7
+ export type NotificationPanelProps = {
8
8
  /** Заголовок панели */
9
9
  title: string;
10
10
  /** Кнопка настроек и выпадающий список */
@@ -15,25 +15,22 @@ export type NotificationPanelProps = WithSupportProps<{
15
15
  readAllButton?: Omit<ButtonFunctionProps, 'data-test-id'> & {
16
16
  onClick: ButtonFunctionProps['onClick'];
17
17
  };
18
+ /** Элемент для открытия панели */
19
+ triggerElement: NotificationPanelPopoverProps['children'];
18
20
  /** Кнопка внизу панели */
19
21
  footerButton?: {
20
22
  label: string;
21
23
  onClick: MouseEventHandler<HTMLButtonElement>;
22
24
  };
23
- className?: string;
24
25
  /** Состояние загрузки */
25
26
  loading?: boolean;
26
27
  /** Контент для отрисовки (e.g NotificationCard | NotificationPanel.Blank) */
27
28
  content?: ReactNode;
28
29
  /** Количество скелетонов карточек для отображения при загрузке */
29
30
  skeletonsAmount?: number;
30
- /** Ссылка на элемент, обозначающий самый конец прокручиваемого списка */
31
- scrollRef?: RefObject<HTMLElement>;
32
- /** Ссылка на контейнер, который скроллится */
33
- scrollContainerRef?: RefObject<HTMLElement>;
34
- }>;
31
+ } & Omit<NotificationPanelPopoverProps, 'children' | 'content'>;
35
32
  /** Компонент панели для уведомлений */
36
- export declare function NotificationPanel({ title, settings, chips, readAllButton, footerButton, content, loading, skeletonsAmount, scrollRef, scrollContainerRef, className, ...rest }: NotificationPanelProps): import("react/jsx-runtime").JSX.Element;
33
+ export declare function NotificationPanel({ title, triggerElement, settings, chips, readAllButton, footerButton, content, loading, skeletonsAmount, ...rest }: NotificationPanelProps): import("react/jsx-runtime").JSX.Element;
37
34
  export declare namespace NotificationPanel {
38
35
  const Blank: typeof NotificationPanelBlank;
39
36
  type BlankProps = NotificationPanelBlankProps;
@@ -10,8 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { createElement as _createElement } from "react";
13
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
- import cn from 'classnames';
13
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
15
14
  import { useMemo } from 'react';
16
15
  import { ButtonFunction } from '@snack-uikit/button';
17
16
  import { ChipToggle } from '@snack-uikit/chips';
@@ -19,18 +18,16 @@ import { Scroll } from '@snack-uikit/scroll';
19
18
  import { SkeletonContextProvider, WithSkeleton } from '@snack-uikit/skeleton';
20
19
  import { TruncateString } from '@snack-uikit/truncate-string';
21
20
  import { Typography } from '@snack-uikit/typography';
22
- import { extractSupportProps } from '@snack-uikit/utils';
21
+ import { NotificationPanelPopover } from '../../helperComponents';
23
22
  import { NotificationCardSkeleton } from '../NotificationCard/components';
24
23
  import { NotificationPanelBlank, NotificationPanelSettings, } from './components';
25
24
  import { TEST_IDS } from './constants';
26
25
  import styles from './styles.module.css';
27
26
  /** Компонент панели для уведомлений */
28
27
  export function NotificationPanel(_a) {
29
- var { title, settings, chips, readAllButton, footerButton, content, loading, skeletonsAmount = 2, scrollRef, scrollContainerRef, className } = _a, rest = __rest(_a, ["title", "settings", "chips", "readAllButton", "footerButton", "content", "loading", "skeletonsAmount", "scrollRef", "scrollContainerRef", "className"]);
28
+ var { title, triggerElement, settings, chips, readAllButton, footerButton, content, loading, skeletonsAmount = 2 } = _a, rest = __rest(_a, ["title", "triggerElement", "settings", "chips", "readAllButton", "footerButton", "content", "loading", "skeletonsAmount"]);
30
29
  const skeletons = useMemo(() => Array.from({ length: skeletonsAmount }, (_, i) => i), [skeletonsAmount]);
31
- return (_jsxs("div", Object.assign({ className: cn(styles.wrapper, className) }, extractSupportProps(rest), { children: [_jsxs("div", { className: styles.notificationPanelHeader, children: [_jsxs("div", { className: styles.notificationPanelHeadline, children: [_jsx(Typography.SansHeadlineS, { className: styles.notificationPanelTitle, children: _jsx(TruncateString, { text: title, "data-test-id": TEST_IDS.title }) }), settings && _jsx(NotificationPanelSettings, Object.assign({}, settings))] }), _jsxs("div", { className: styles.notificationPanelHeaderFunctions, children: [_jsx("div", { className: styles.notificationPanelChips, children: chips === null || chips === void 0 ? void 0 : chips.map(chip => (_createElement(ChipToggle, Object.assign({}, chip, { key: chip.label, "data-test-id": `${TEST_IDS.chip}-${chip.label}`, size: 'xs', disabled: chip.disabled || loading })))) }), readAllButton && (_jsx(ButtonFunction, Object.assign({}, readAllButton, { disabled: readAllButton.disabled || loading, "data-test-id": TEST_IDS.readAll })))] })] }), _jsxs(Scroll, { size: 'm', className: styles.notificationPanelBody, ref: scrollContainerRef, children: [content, loading && (_jsx(SkeletonContextProvider, { loading: loading || false, children: skeletons.map(skeleton => (_jsx(WithSkeleton, { skeleton: _jsx(NotificationCardSkeleton, {}) }, skeleton))) })), _jsx("div", { className: styles.scrollStub, ref: scrollRef })] }),
32
- // !loading &&
33
- footerButton && (_jsx("button", { className: styles.notificationPanelFooterButton, "data-test-id": TEST_IDS.footerButton, children: _jsx(Typography.SansLabelS, { children: footerButton.label }) }))] })));
30
+ return (_jsx(NotificationPanelPopover, Object.assign({}, rest, { content: _jsxs(_Fragment, { children: [_jsxs("div", { className: styles.notificationPanelHeader, children: [_jsxs("div", { className: styles.notificationPanelHeadline, children: [_jsx(Typography.SansHeadlineS, { className: styles.notificationPanelTitle, children: _jsx(TruncateString, { text: title, "data-test-id": TEST_IDS.title }) }), settings && _jsx(NotificationPanelSettings, Object.assign({}, settings))] }), _jsxs("div", { className: styles.notificationPanelHeaderFunctions, children: [_jsx("div", { className: styles.notificationPanelChips, children: chips === null || chips === void 0 ? void 0 : chips.map(chip => (_createElement(ChipToggle, Object.assign({}, chip, { key: chip.label, "data-test-id": `${TEST_IDS.chip}-${chip.label}`, size: 'xs', disabled: chip.disabled || loading })))) }), readAllButton && (_jsx(ButtonFunction, Object.assign({}, readAllButton, { disabled: readAllButton.disabled || loading, "data-test-id": TEST_IDS.readAll })))] })] }), _jsx(Scroll, { size: 'm', className: styles.notificationPanelBody, children: loading ? (_jsx(SkeletonContextProvider, { loading: loading || false, children: skeletons.map(skeleton => (_jsx(WithSkeleton, { skeleton: _jsx(NotificationCardSkeleton, {}) }, skeleton))) })) : (content) }), !loading && footerButton && (_jsx("button", { className: styles.notificationPanelFooterButton, "data-test-id": TEST_IDS.footerButton, children: _jsx(Typography.SansLabelS, { children: footerButton.label }) }))] }), children: triggerElement })));
34
31
  }
35
32
  (function (NotificationPanel) {
36
33
  NotificationPanel.Blank = NotificationPanelBlank;
@@ -94,10 +94,4 @@
94
94
  .notificationPanelFooterButton:active{
95
95
  color:var(--sys-neutral-text-main, #333333);
96
96
  border-color:var(--sys-neutral-decor-default, #dedede);
97
- }
98
-
99
- .wrapper{
100
- box-sizing:border-box;
101
- width:100%;
102
- height:100%;
103
97
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Notification",
7
- "version": "0.6.11-preview-357970fd.0",
7
+ "version": "0.6.11",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -33,11 +33,11 @@
33
33
  "scripts": {},
34
34
  "dependencies": {
35
35
  "@snack-uikit/button": "0.16.0",
36
- "@snack-uikit/chips": "0.11.1",
36
+ "@snack-uikit/chips": "0.11.2",
37
37
  "@snack-uikit/icon-predefined": "0.4.1",
38
38
  "@snack-uikit/icons": "0.20.1",
39
39
  "@snack-uikit/link": "0.11.1",
40
- "@snack-uikit/list": "0.3.1-preview-357970fd.0",
40
+ "@snack-uikit/list": "0.3.1",
41
41
  "@snack-uikit/popover-private": "0.13.0",
42
42
  "@snack-uikit/scroll": "0.5.0",
43
43
  "@snack-uikit/skeleton": "0.3.2",
@@ -47,5 +47,5 @@
47
47
  "@snack-uikit/utils": "3.2.0",
48
48
  "classnames": "2.3.2"
49
49
  },
50
- "gitHead": "2a29639b6595426f8870afc293553dd9ee12f188"
50
+ "gitHead": "eb20092ecd05743f00831dfa51a3f5db2416be8f"
51
51
  }
@@ -1,5 +1,4 @@
1
- import cn from 'classnames';
2
- import { MouseEventHandler, ReactNode, RefObject, useMemo } from 'react';
1
+ import { MouseEventHandler, ReactNode, useMemo } from 'react';
3
2
 
4
3
  import { ButtonFunction, ButtonFunctionProps } from '@snack-uikit/button';
5
4
  import { ChipToggle, ChipToggleProps } from '@snack-uikit/chips';
@@ -7,8 +6,8 @@ import { Scroll } from '@snack-uikit/scroll';
7
6
  import { SkeletonContextProvider, WithSkeleton } from '@snack-uikit/skeleton';
8
7
  import { TruncateString } from '@snack-uikit/truncate-string';
9
8
  import { Typography } from '@snack-uikit/typography';
10
- import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
11
9
 
10
+ import { NotificationPanelPopover, NotificationPanelPopoverProps } from '../../helperComponents';
12
11
  import { NotificationCardSkeleton } from '../NotificationCard/components';
13
12
  import {
14
13
  NotificationPanelBlank,
@@ -21,7 +20,7 @@ import styles from './styles.module.scss';
21
20
 
22
21
  export type { NotificationPanelBlankProps };
23
22
 
24
- export type NotificationPanelProps = WithSupportProps<{
23
+ export type NotificationPanelProps = {
25
24
  /** Заголовок панели */
26
25
  title: string;
27
26
  /** Кнопка настроек и выпадающий список */
@@ -32,27 +31,25 @@ export type NotificationPanelProps = WithSupportProps<{
32
31
  readAllButton?: Omit<ButtonFunctionProps, 'data-test-id'> & {
33
32
  onClick: ButtonFunctionProps['onClick'];
34
33
  };
34
+ /** Элемент для открытия панели */
35
+ triggerElement: NotificationPanelPopoverProps['children'];
35
36
  /** Кнопка внизу панели */
36
37
  footerButton?: {
37
38
  label: string;
38
39
  onClick: MouseEventHandler<HTMLButtonElement>;
39
40
  };
40
- className?: string;
41
41
  /** Состояние загрузки */
42
42
  loading?: boolean;
43
43
  /** Контент для отрисовки (e.g NotificationCard | NotificationPanel.Blank) */
44
44
  content?: ReactNode;
45
45
  /** Количество скелетонов карточек для отображения при загрузке */
46
46
  skeletonsAmount?: number;
47
- /** Ссылка на элемент, обозначающий самый конец прокручиваемого списка */
48
- scrollRef?: RefObject<HTMLElement>;
49
- /** Ссылка на контейнер, который скроллится */
50
- scrollContainerRef?: RefObject<HTMLElement>;
51
- }>;
47
+ } & Omit<NotificationPanelPopoverProps, 'children' | 'content'>;
52
48
 
53
49
  /** Компонент панели для уведомлений */
54
50
  export function NotificationPanel({
55
51
  title,
52
+ triggerElement,
56
53
  settings,
57
54
  chips,
58
55
  readAllButton,
@@ -60,69 +57,69 @@ export function NotificationPanel({
60
57
  content,
61
58
  loading,
62
59
  skeletonsAmount = 2,
63
- scrollRef,
64
- scrollContainerRef,
65
- className,
66
60
  ...rest
67
61
  }: NotificationPanelProps) {
68
62
  const skeletons = useMemo(() => Array.from({ length: skeletonsAmount }, (_, i) => i), [skeletonsAmount]);
69
63
 
70
64
  return (
71
- <div className={cn(styles.wrapper, className)} {...extractSupportProps(rest)}>
72
- <div className={styles.notificationPanelHeader}>
73
- <div className={styles.notificationPanelHeadline}>
74
- <Typography.SansHeadlineS className={styles.notificationPanelTitle}>
75
- <TruncateString text={title} data-test-id={TEST_IDS.title} />
76
- </Typography.SansHeadlineS>
65
+ <NotificationPanelPopover
66
+ {...rest}
67
+ content={
68
+ <>
69
+ <div className={styles.notificationPanelHeader}>
70
+ <div className={styles.notificationPanelHeadline}>
71
+ <Typography.SansHeadlineS className={styles.notificationPanelTitle}>
72
+ <TruncateString text={title} data-test-id={TEST_IDS.title} />
73
+ </Typography.SansHeadlineS>
77
74
 
78
- {settings && <NotificationPanelSettings {...settings} />}
79
- </div>
75
+ {settings && <NotificationPanelSettings {...settings} />}
76
+ </div>
80
77
 
81
- <div className={styles.notificationPanelHeaderFunctions}>
82
- <div className={styles.notificationPanelChips}>
83
- {chips?.map(chip => (
84
- <ChipToggle
85
- {...chip}
86
- key={chip.label}
87
- data-test-id={`${TEST_IDS.chip}-${chip.label}`}
88
- size='xs'
89
- disabled={chip.disabled || loading}
90
- />
91
- ))}
92
- </div>
93
-
94
- {readAllButton && (
95
- <ButtonFunction
96
- {...readAllButton}
97
- disabled={readAllButton.disabled || loading}
98
- data-test-id={TEST_IDS.readAll}
99
- />
100
- )}
101
- </div>
102
- </div>
78
+ <div className={styles.notificationPanelHeaderFunctions}>
79
+ <div className={styles.notificationPanelChips}>
80
+ {chips?.map(chip => (
81
+ <ChipToggle
82
+ {...chip}
83
+ key={chip.label}
84
+ data-test-id={`${TEST_IDS.chip}-${chip.label}`}
85
+ size='xs'
86
+ disabled={chip.disabled || loading}
87
+ />
88
+ ))}
89
+ </div>
103
90
 
104
- <Scroll size='m' className={styles.notificationPanelBody} ref={scrollContainerRef}>
105
- {content}
106
- {loading && (
107
- <SkeletonContextProvider loading={loading || false}>
108
- {skeletons.map(skeleton => (
109
- <WithSkeleton key={skeleton} skeleton={<NotificationCardSkeleton />} />
110
- ))}
111
- </SkeletonContextProvider>
112
- )}
91
+ {readAllButton && (
92
+ <ButtonFunction
93
+ {...readAllButton}
94
+ disabled={readAllButton.disabled || loading}
95
+ data-test-id={TEST_IDS.readAll}
96
+ />
97
+ )}
98
+ </div>
99
+ </div>
113
100
 
114
- <div className={styles.scrollStub} ref={scrollRef as RefObject<HTMLDivElement>} />
115
- </Scroll>
101
+ <Scroll size='m' className={styles.notificationPanelBody}>
102
+ {loading ? (
103
+ <SkeletonContextProvider loading={loading || false}>
104
+ {skeletons.map(skeleton => (
105
+ <WithSkeleton key={skeleton} skeleton={<NotificationCardSkeleton />} />
106
+ ))}
107
+ </SkeletonContextProvider>
108
+ ) : (
109
+ content
110
+ )}
111
+ </Scroll>
116
112
 
117
- {
118
- // !loading &&
119
- footerButton && (
120
- <button className={styles.notificationPanelFooterButton} data-test-id={TEST_IDS.footerButton}>
121
- <Typography.SansLabelS>{footerButton.label}</Typography.SansLabelS>
122
- </button>
123
- )
113
+ {!loading && footerButton && (
114
+ <button className={styles.notificationPanelFooterButton} data-test-id={TEST_IDS.footerButton}>
115
+ <Typography.SansLabelS>{footerButton.label}</Typography.SansLabelS>
116
+ </button>
117
+ )}
118
+ </>
124
119
  }
125
- </div>
120
+ >
121
+ {triggerElement}
122
+ </NotificationPanelPopover>
126
123
  );
127
124
  }
128
125
 
@@ -107,9 +107,3 @@
107
107
  border-color: $sys-neutral-decor-default;
108
108
  }
109
109
  }
110
-
111
- .wrapper {
112
- box-sizing: border-box;
113
- width: 100%;
114
- height: 100%;
115
- }