@snack-uikit/notification 0.4.2 → 0.5.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.
Files changed (29) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +8 -8
  3. package/dist/components/NotificationCard/NotificationCard.d.ts +1 -4
  4. package/dist/components/NotificationCard/NotificationCard.js +4 -5
  5. package/dist/components/NotificationCard/components/NotificationCardFunction.js +1 -1
  6. package/dist/components/NotificationCard/constants.d.ts +7 -7
  7. package/dist/components/NotificationCard/constants.js +7 -8
  8. package/dist/components/NotificationCard/helpers.d.ts +1 -1
  9. package/dist/components/NotificationCard/helpers.js +6 -6
  10. package/dist/components/NotificationCard/types.d.ts +3 -0
  11. package/dist/components/NotificationCard/types.js +1 -0
  12. package/dist/components/NotificationPanel/NotificationPanel.d.ts +0 -5
  13. package/dist/components/NotificationPanel/NotificationPanel.js +1 -5
  14. package/dist/components/NotificationPanel/components/NotificationPanelBlank/NotificationPanelBlank.d.ts +0 -3
  15. package/dist/components/NotificationPanel/components/NotificationPanelBlank/NotificationPanelBlank.js +2 -3
  16. package/dist/components/NotificationPanel/components/NotificationPanelSettings/NotificationPanelSettings.js +1 -1
  17. package/dist/components/NotificationPanel/components/NotificationPanelSettings/NotificationPanelSettingsDroplist.js +1 -1
  18. package/dist/helperComponents/NotificationPanelPopover/NotificationPanelPopover.js +2 -2
  19. package/package.json +13 -13
  20. package/src/components/NotificationCard/NotificationCard.tsx +10 -15
  21. package/src/components/NotificationCard/components/NotificationCardFunction.tsx +2 -2
  22. package/src/components/NotificationCard/constants.ts +7 -7
  23. package/src/components/NotificationCard/helpers.tsx +7 -6
  24. package/src/components/NotificationCard/types.ts +5 -0
  25. package/src/components/NotificationPanel/NotificationPanel.tsx +2 -7
  26. package/src/components/NotificationPanel/components/NotificationPanelBlank/NotificationPanelBlank.tsx +4 -13
  27. package/src/components/NotificationPanel/components/NotificationPanelSettings/NotificationPanelSettings.tsx +1 -1
  28. package/src/components/NotificationPanel/components/NotificationPanelSettings/NotificationPanelSettingsDroplist.tsx +1 -1
  29. package/src/helperComponents/NotificationPanelPopover/NotificationPanelPopover.tsx +3 -3
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.5.0 (2023-12-14)
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+
12
+ * **FF-3729:** replace enum with unions ([910db4a](https://github.com/cloud-ru-tech/snack-uikit/commit/910db4aa8231ccbc58e538e5c5c1f461b1dec275))
13
+
14
+
15
+
16
+
6
17
  ## 0.4.2 (2023-12-07)
7
18
 
8
19
  ### Only dependencies have been changed
package/README.md CHANGED
@@ -17,7 +17,7 @@ const cards = [
17
17
  {
18
18
  id: 'cardId',
19
19
  label: ['Category', 'Subcategory'].join('・'),
20
- appearance: NotificationCard.appearances.ErrorCritical,
20
+ appearance: 'errorCritical',
21
21
  title: 'Title truncate two line',
22
22
  content: `Demo content.`,
23
23
  link: {
@@ -49,12 +49,12 @@ const cards = [
49
49
  }}
50
50
  chips={[
51
51
  {
52
- label: ChipFilter.All,
52
+ label: 'all',
53
53
  checked: true,
54
54
  onChange() { /* */ },
55
55
  },
56
56
  {
57
- label: ChipFilter.Unread,
57
+ label: 'unread',
58
58
  checked: false,
59
59
  onChange() { /* */ },
60
60
  },
@@ -85,7 +85,7 @@ const cards = [
85
85
  | content* | `ReactNode` | - | Контент уведомления |
86
86
  | title* | `string` | - | Заголовок уведомления |
87
87
  | id* | `string` | - | Идентификатор уведомления |
88
- | appearance | enum Appearance: `"neutral"`, `"error"`, `"errorCritical"`, `"warning"`, `"success"` | Appearance.Neutral | Тип уведомления |
88
+ | appearance | enum Appearance: `"neutral"`, `"error"`, `"errorCritical"`, `"warning"`, `"success"` | neutral | Тип уведомления |
89
89
  | label | `string` | - | Лейбл перед заголовком |
90
90
  | unread | `boolean` | - | Управление состоянием прочитано/не прочитано |
91
91
  | link | `Omit<LinkProps, "data-test-id" \| "size" \| "onColor" \| "onSurface">` | - | Ссылка |
@@ -115,10 +115,10 @@ const cards = [
115
115
  | hoverDelayClose | `number` | - | Задержка закрытия по ховеру |
116
116
  | offset | `number` | 0 | Отступ поповера от его триггер-элемента (в пикселях). |
117
117
  | closeOnEscapeKey | `boolean` | true | Закрывать ли по нажатию на кнопку `Esc` |
118
- | triggerClickByKeys | `boolean` | true | Вызывается ли попоповер по нажатию клавиш Enter/Space (при trigger = `Click`) |
118
+ | triggerClickByKeys | `boolean` | true | Вызывается ли попоповер по нажатию клавиш Enter/Space (при trigger = `click`) |
119
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"` | Placement.Top | Положение поповера относительно своего триггера (children). |
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
122
  | contentClassName | `string` | - | CSS-класс для элемента содержащего контент |
123
123
  ## NotificationPanel.Blank
124
124
  ### Props
@@ -127,7 +127,7 @@ const cards = [
127
127
  | title* | `ReactNode` | - | Заголовок |
128
128
  | description | `ReactNode` | - | Описание |
129
129
  | icon | `JSXElementConstructor<{ size?: number; className?: string; }>` | - | Иконка |
130
- | iconAppearance | enum Appearance: `"primary"`, `"neutral"`, `"red"`, `"orange"`, `"yellow"`, `"green"`, `"blue"`, `"violet"`, `"pink"` | - | Цвет обводки для иконки |
130
+ | iconAppearance | enum Appearance: `"neutral"`, `"primary"`, `"red"`, `"orange"`, `"yellow"`, `"green"`, `"blue"`, `"violet"`, `"pink"` | - | Цвет обводки для иконки |
131
131
  | className | `string` | - | CSS-класс |
132
132
 
133
133
 
@@ -2,7 +2,7 @@ import { MouseEventHandler, ReactNode } from 'react';
2
2
  import { ItemSingleProps } from '@snack-uikit/droplist';
3
3
  import { LinkProps } from '@snack-uikit/link';
4
4
  import { WithSupportProps } from '@snack-uikit/utils';
5
- import { Appearance } from './constants';
5
+ import { Appearance } from './types';
6
6
  export type NotificationCardProps = WithSupportProps<{
7
7
  /** Идентификатор уведомления */
8
8
  id: string;
@@ -31,6 +31,3 @@ export type NotificationCardProps = WithSupportProps<{
31
31
  }>;
32
32
  /** Компонент карточки уведомления */
33
33
  export declare function NotificationCard({ id, appearance, label, unread, title, content, link, date, onClick, actions, onVisible, className, ...rest }: NotificationCardProps): import("react/jsx-runtime").JSX.Element;
34
- export declare namespace NotificationCard {
35
- var appearances: typeof Appearance;
36
- }
@@ -17,15 +17,15 @@ import { TruncateString } from '@snack-uikit/truncate-string';
17
17
  import { Typography } from '@snack-uikit/typography';
18
18
  import { extractSupportProps } from '@snack-uikit/utils';
19
19
  import { NotificationCardFunction } from './components';
20
- import { Appearance, TEST_IDS } from './constants';
20
+ import { APPEARANCE, TEST_IDS } from './constants';
21
21
  import { getIcon } from './helpers';
22
22
  import styles from './styles.module.css';
23
23
  /** Компонент карточки уведомления */
24
24
  export function NotificationCard(_a) {
25
- var { id, appearance = Appearance.Neutral, label, unread, title, content, link, date, onClick, actions, onVisible, className } = _a, rest = __rest(_a, ["id", "appearance", "label", "unread", "title", "content", "link", "date", "onClick", "actions", "onVisible", "className"]);
25
+ var { id, appearance = APPEARANCE.Neutral, label, unread, title, content, link, date, onClick, actions, onVisible, className } = _a, rest = __rest(_a, ["id", "appearance", "label", "unread", "title", "content", "link", "date", "onClick", "actions", "onVisible", "className"]);
26
26
  const { icon, linkOnColor } = useMemo(() => ({
27
27
  icon: getIcon(appearance),
28
- linkOnColor: appearance === Appearance.ErrorCritical ? Link.onColors.Red : undefined,
28
+ linkOnColor: appearance === APPEARANCE.ErrorCritical ? 'red' : undefined,
29
29
  }), [appearance]);
30
30
  const [isDroplistOpen, setDroplistOpen] = useState(false);
31
31
  const cardRef = useRef(null);
@@ -55,6 +55,5 @@ export function NotificationCard(_a) {
55
55
  e.stopPropagation();
56
56
  (_a = link === null || link === void 0 ? void 0 : link.onClick) === null || _a === void 0 ? void 0 : _a.call(link, e);
57
57
  };
58
- return (_jsxs("div", Object.assign({ ref: cardRef, role: 'button', onClick: onClick, tabIndex: 0 }, extractSupportProps(rest), { "data-appearance": appearance, "data-unread": unread || undefined, "data-clickable": Boolean(onClick) || undefined, "data-droplist-open": isDroplistOpen || undefined, className: cn(styles.notificationCard, className) }, { children: [(actions === null || actions === void 0 ? void 0 : actions.length) && (_jsx(NotificationCardFunction, { actions: actions, open: isDroplistOpen, setDroplistOpen: setDroplistOpen })), label && (_jsx(Typography.LightLabelS, Object.assign({ tag: Typography.tags.div, className: styles.notificationCardLabel }, { children: _jsx(TruncateString, { maxLines: 1, text: label, "data-test-id": TEST_IDS.label }) }))), _jsxs("div", Object.assign({ className: styles.notificationCardTitle }, { children: [_jsx("div", Object.assign({ className: styles.notificationCardTitleIcon }, { children: icon })), _jsx(Typography.SansTitleS, Object.assign({ tag: Typography.tags.div, className: styles.notificationCardTitleText }, { children: _jsx(TruncateString, { maxLines: 2, text: title, "data-test-id": TEST_IDS.title }) }))] })), content && (_jsx(Typography.SansBodyS, Object.assign({ tag: Typography.tags.div, className: styles.notificationCardContent, "data-test-id": TEST_IDS.content }, { children: content }))), showFooter && (_jsxs("div", Object.assign({ className: styles.notificationCardFooter }, { children: [link && (_jsx(Link, Object.assign({}, link, { onClick: handleLinkClick, onColor: linkOnColor, onSurface: Link.onSurfaces.Decor, size: Link.sizes.S, "data-test-id": TEST_IDS.link }))), date && (_jsx(Typography.LightLabelS, Object.assign({ className: styles.notificationCardDate, "data-test-id": TEST_IDS.date }, { children: date })))] })))] })));
58
+ return (_jsxs("div", Object.assign({ ref: cardRef, role: 'button', onClick: onClick, tabIndex: 0 }, extractSupportProps(rest), { "data-appearance": appearance, "data-unread": unread || undefined, "data-clickable": Boolean(onClick) || undefined, "data-droplist-open": isDroplistOpen || undefined, className: cn(styles.notificationCard, className) }, { children: [(actions === null || actions === void 0 ? void 0 : actions.length) && (_jsx(NotificationCardFunction, { actions: actions, open: isDroplistOpen, setDroplistOpen: setDroplistOpen })), label && (_jsx(Typography.LightLabelS, Object.assign({ tag: 'div', className: styles.notificationCardLabel }, { children: _jsx(TruncateString, { maxLines: 1, text: label, "data-test-id": TEST_IDS.label }) }))), _jsxs("div", Object.assign({ className: styles.notificationCardTitle }, { children: [_jsx("div", Object.assign({ className: styles.notificationCardTitleIcon }, { children: icon })), _jsx(Typography.SansTitleS, Object.assign({ tag: 'div', className: styles.notificationCardTitleText }, { children: _jsx(TruncateString, { maxLines: 2, text: title, "data-test-id": TEST_IDS.title }) }))] })), content && (_jsx(Typography.SansBodyS, Object.assign({ tag: 'div', className: styles.notificationCardContent, "data-test-id": TEST_IDS.content }, { children: content }))), showFooter && (_jsxs("div", Object.assign({ className: styles.notificationCardFooter }, { children: [link && (_jsx(Link, Object.assign({}, link, { onClick: handleLinkClick, onColor: linkOnColor, onSurface: 'decor', size: 's', "data-test-id": TEST_IDS.link }))), date && (_jsx(Typography.LightLabelS, Object.assign({ className: styles.notificationCardDate, "data-test-id": TEST_IDS.date }, { children: date })))] })))] })));
59
59
  }
60
- NotificationCard.appearances = Appearance;
@@ -9,5 +9,5 @@ export function NotificationCardFunction({ actions, open, setDroplistOpen }) {
9
9
  const { firstElementRefCallback, triggerElementRef, handleDroplistFocusLeave, handleTriggerKeyDown, handleDroplistItemKeyDown, handleDroplistItemClick, } = Droplist.useKeyboardNavigation({
10
10
  setDroplistOpen,
11
11
  });
12
- return (_jsx("div", Object.assign({ className: styles.notificationCardFunction, "data-test-id": TEST_IDS.actions.wrapper }, { children: _jsx(Droplist, Object.assign({ open: open, onOpenChange: setDroplistOpen, placement: Droplist.placements.BottomEnd, firstElementRefCallback: firstElementRefCallback, onFocusLeave: handleDroplistFocusLeave, triggerRef: triggerElementRef, useScroll: true, triggerElement: _jsx(ButtonFunction, { size: ButtonFunction.sizes.S, icon: _jsx(KebabSVG, {}), onKeyDown: handleTriggerKeyDown, "data-test-id": TEST_IDS.actions.droplistTrigger }), "data-test-id": TEST_IDS.actions.droplist }, { children: actions.map(action => (_createElement(Droplist.ItemSingle, Object.assign({}, action, { key: action.option, onClick: e => handleDroplistItemClick(e, action.onClick), "data-test-id": TEST_IDS.actions.droplistAction, onKeyDown: handleDroplistItemKeyDown })))) })) })));
12
+ return (_jsx("div", Object.assign({ className: styles.notificationCardFunction, "data-test-id": TEST_IDS.actions.wrapper }, { children: _jsx(Droplist, Object.assign({ open: open, onOpenChange: setDroplistOpen, placement: 'bottom-end', firstElementRefCallback: firstElementRefCallback, onFocusLeave: handleDroplistFocusLeave, triggerRef: triggerElementRef, useScroll: true, triggerElement: _jsx(ButtonFunction, { size: 's', icon: _jsx(KebabSVG, {}), onKeyDown: handleTriggerKeyDown, "data-test-id": TEST_IDS.actions.droplistTrigger }), "data-test-id": TEST_IDS.actions.droplist }, { children: actions.map(action => (_createElement(Droplist.ItemSingle, Object.assign({}, action, { key: action.option, onClick: e => handleDroplistItemClick(e, action.onClick), "data-test-id": TEST_IDS.actions.droplistAction, onKeyDown: handleDroplistItemKeyDown })))) })) })));
13
13
  }
@@ -1,10 +1,10 @@
1
- export declare enum Appearance {
2
- Neutral = "neutral",
3
- Error = "error",
4
- ErrorCritical = "errorCritical",
5
- Warning = "warning",
6
- Success = "success"
7
- }
1
+ export declare const APPEARANCE: {
2
+ readonly Neutral: "neutral";
3
+ readonly Error: "error";
4
+ readonly ErrorCritical: "errorCritical";
5
+ readonly Warning: "warning";
6
+ readonly Success: "success";
7
+ };
8
8
  export declare const TEST_IDS: {
9
9
  label: string;
10
10
  title: string;
@@ -1,11 +1,10 @@
1
- export var Appearance;
2
- (function (Appearance) {
3
- Appearance["Neutral"] = "neutral";
4
- Appearance["Error"] = "error";
5
- Appearance["ErrorCritical"] = "errorCritical";
6
- Appearance["Warning"] = "warning";
7
- Appearance["Success"] = "success";
8
- })(Appearance || (Appearance = {}));
1
+ export const APPEARANCE = {
2
+ Neutral: 'neutral',
3
+ Error: 'error',
4
+ ErrorCritical: 'errorCritical',
5
+ Warning: 'warning',
6
+ Success: 'success',
7
+ };
9
8
  export const TEST_IDS = {
10
9
  label: 'notification-card__label',
11
10
  title: 'notification-card__title',
@@ -1,2 +1,2 @@
1
- import { Appearance } from './constants';
1
+ import { Appearance } from './types';
2
2
  export declare function getIcon(appearance: Appearance): import("react/jsx-runtime").JSX.Element | null;
@@ -1,16 +1,16 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { AlarmFilledSVG, CheckFilledSVG, CrossFilledSVG, InfoFilledSVG } from '@snack-uikit/icons';
3
- import { Appearance } from './constants';
3
+ import { APPEARANCE } from './constants';
4
4
  export function getIcon(appearance) {
5
5
  switch (appearance) {
6
- case Appearance.Success:
6
+ case APPEARANCE.Success:
7
7
  return _jsx(CheckFilledSVG, { size: 16 });
8
- case Appearance.Error:
9
- case Appearance.ErrorCritical:
8
+ case APPEARANCE.Error:
9
+ case APPEARANCE.ErrorCritical:
10
10
  return _jsx(CrossFilledSVG, { size: 16 });
11
- case Appearance.Warning:
11
+ case APPEARANCE.Warning:
12
12
  return _jsx(AlarmFilledSVG, { size: 16 });
13
- case Appearance.Neutral:
13
+ case APPEARANCE.Neutral:
14
14
  return _jsx(InfoFilledSVG, { size: 16 });
15
15
  default:
16
16
  return null;
@@ -0,0 +1,3 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+ import { APPEARANCE } from './constants';
3
+ export type Appearance = ValueOf<typeof APPEARANCE>;
@@ -0,0 +1 @@
1
+ export {};
@@ -31,11 +31,6 @@ export type NotificationPanelProps = {
31
31
  } & Omit<NotificationPanelPopoverProps, 'children' | 'content'>;
32
32
  /** Компонент панели для уведомлений */
33
33
  export declare function NotificationPanel({ title, triggerElement, settings, chips, readAllButton, footerButton, content, loading, skeletonsAmount, ...rest }: NotificationPanelProps): import("react/jsx-runtime").JSX.Element;
34
- export declare namespace NotificationPanel {
35
- var placements: typeof import("@snack-uikit/popover-private/dist/constants").Placement;
36
- var triggers: typeof import("@snack-uikit/popover-private/dist/constants").Trigger;
37
- var widthStrategies: typeof import("@snack-uikit/popover-private/dist/constants").PopoverWidthStrategy;
38
- }
39
34
  export declare namespace NotificationPanel {
40
35
  const Blank: typeof NotificationPanelBlank;
41
36
  type BlankProps = NotificationPanelBlankProps;
@@ -14,7 +14,6 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
14
14
  import { useMemo } from 'react';
15
15
  import { ButtonFunction } from '@snack-uikit/button';
16
16
  import { ChipToggle } from '@snack-uikit/chips';
17
- import { PopoverPrivate } from '@snack-uikit/popover-private';
18
17
  import { Scroll } from '@snack-uikit/scroll';
19
18
  import { SkeletonContextProvider, WithSkeleton } from '@snack-uikit/skeleton';
20
19
  import { TruncateString } from '@snack-uikit/truncate-string';
@@ -28,11 +27,8 @@ import styles from './styles.module.css';
28
27
  export function NotificationPanel(_a) {
29
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 (_jsx(NotificationPanelPopover, Object.assign({}, rest, { content: _jsxs(_Fragment, { children: [_jsxs("div", Object.assign({ className: styles.notificationPanelHeader }, { children: [_jsxs("div", Object.assign({ className: styles.notificationPanelHeadline }, { children: [_jsx(Typography.SansHeadlineS, Object.assign({ className: styles.notificationPanelTitle }, { children: _jsx(TruncateString, { text: title, "data-test-id": TEST_IDS.title }) })), settings && _jsx(NotificationPanelSettings, Object.assign({}, settings))] })), _jsxs("div", Object.assign({ className: styles.notificationPanelHeaderFunctions }, { children: [_jsx("div", Object.assign({ 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: ChipToggle.sizes.Xs, disabled: chip.disabled || loading })))) })), readAllButton && (_jsx(ButtonFunction, Object.assign({}, readAllButton, { disabled: readAllButton.disabled || loading, "data-test-id": TEST_IDS.readAll })))] }))] })), _jsx(Scroll, Object.assign({ size: Scroll.sizes.M, className: styles.notificationPanelBody }, { children: loading ? (_jsx(SkeletonContextProvider, Object.assign({ loading: loading || false }, { children: skeletons.map(skeleton => (_jsx(WithSkeleton, { skeleton: _jsx(NotificationCardSkeleton, {}) }, skeleton))) }))) : (content) })), !loading && footerButton && (_jsx("button", Object.assign({ className: styles.notificationPanelFooterButton, "data-test-id": TEST_IDS.footerButton }, { children: _jsx(Typography.SansLabelS, { children: footerButton.label }) })))] }) }, { children: triggerElement })));
30
+ return (_jsx(NotificationPanelPopover, Object.assign({}, rest, { content: _jsxs(_Fragment, { children: [_jsxs("div", Object.assign({ className: styles.notificationPanelHeader }, { children: [_jsxs("div", Object.assign({ className: styles.notificationPanelHeadline }, { children: [_jsx(Typography.SansHeadlineS, Object.assign({ className: styles.notificationPanelTitle }, { children: _jsx(TruncateString, { text: title, "data-test-id": TEST_IDS.title }) })), settings && _jsx(NotificationPanelSettings, Object.assign({}, settings))] })), _jsxs("div", Object.assign({ className: styles.notificationPanelHeaderFunctions }, { children: [_jsx("div", Object.assign({ 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, Object.assign({ size: 'm', className: styles.notificationPanelBody }, { children: loading ? (_jsx(SkeletonContextProvider, Object.assign({ loading: loading || false }, { children: skeletons.map(skeleton => (_jsx(WithSkeleton, { skeleton: _jsx(NotificationCardSkeleton, {}) }, skeleton))) }))) : (content) })), !loading && footerButton && (_jsx("button", Object.assign({ className: styles.notificationPanelFooterButton, "data-test-id": TEST_IDS.footerButton }, { children: _jsx(Typography.SansLabelS, { children: footerButton.label }) })))] }) }, { children: triggerElement })));
32
31
  }
33
- NotificationPanel.placements = PopoverPrivate.placements;
34
- NotificationPanel.triggers = PopoverPrivate.triggers;
35
- NotificationPanel.widthStrategies = PopoverPrivate.widthStrategies;
36
32
  (function (NotificationPanel) {
37
33
  NotificationPanel.Blank = NotificationPanelBlank;
38
34
  })(NotificationPanel || (NotificationPanel = {}));
@@ -15,6 +15,3 @@ export type NotificationPanelBlankProps = WithSupportProps<{
15
15
  }>;
16
16
  /** Компонента для "заглушки" вместо карточек в панели */
17
17
  export declare function NotificationPanelBlank({ icon, iconAppearance, title, description, className, ...rest }: NotificationPanelBlankProps): import("react/jsx-runtime").JSX.Element;
18
- export declare namespace NotificationPanelBlank {
19
- var iconAppearances: typeof import("@snack-uikit/icon-predefined/dist/constants").Appearance;
20
- }
@@ -18,7 +18,6 @@ import { TEST_IDS } from '../../constants';
18
18
  import styles from './styles.module.css';
19
19
  /** Компонента для "заглушки" вместо карточек в панели */
20
20
  export function NotificationPanelBlank(_a) {
21
- var { icon, iconAppearance = IconPredefined.appearances.Neutral, title, description, className } = _a, rest = __rest(_a, ["icon", "iconAppearance", "title", "description", "className"]);
22
- return (_jsxs("div", Object.assign({ className: cn(styles.notificationPanelBlank, className) }, extractSupportProps(rest), { children: [icon && (_jsx(IconPredefined, { icon: icon, appearance: iconAppearance, size: IconPredefined.sizes.L, "data-test-id": TEST_IDS.blank.icon })), _jsxs("div", Object.assign({ className: styles.notificationPanelBlankContent }, { children: [_jsx(Typography.SansTitleS, Object.assign({ tag: Typography.tags.div, className: styles.notificationPanelBlankTitle, "data-test-id": TEST_IDS.blank.title }, { children: title })), _jsx(Typography.SansBodyM, Object.assign({ tag: Typography.tags.div, className: styles.notificationPanelBlankDescription, "data-test-id": TEST_IDS.blank.description }, { children: description }))] }))] })));
21
+ var { icon, iconAppearance = 'neutral', title, description, className } = _a, rest = __rest(_a, ["icon", "iconAppearance", "title", "description", "className"]);
22
+ return (_jsxs("div", Object.assign({ className: cn(styles.notificationPanelBlank, className) }, extractSupportProps(rest), { children: [icon && _jsx(IconPredefined, { icon: icon, appearance: iconAppearance, size: 'l', "data-test-id": TEST_IDS.blank.icon }), _jsxs("div", Object.assign({ className: styles.notificationPanelBlankContent }, { children: [_jsx(Typography.SansTitleS, Object.assign({ tag: 'div', className: styles.notificationPanelBlankTitle, "data-test-id": TEST_IDS.blank.title }, { children: title })), _jsx(Typography.SansBodyM, Object.assign({ tag: 'div', className: styles.notificationPanelBlankDescription, "data-test-id": TEST_IDS.blank.description }, { children: description }))] }))] })));
23
23
  }
24
- NotificationPanelBlank.iconAppearances = IconPredefined.appearances;
@@ -4,7 +4,7 @@ import { KebabSVG } from '@snack-uikit/icons';
4
4
  import { TEST_IDS } from '../../constants';
5
5
  import { NotificationPanelSettingsDroplist } from './NotificationPanelSettingsDroplist';
6
6
  export function NotificationPanelSettings({ actions, button }) {
7
- const buttonProps = Object.assign(Object.assign({}, button), { size: ButtonSimple.sizes.S, icon: button.icon || _jsx(KebabSVG, {}), 'data-test-id': TEST_IDS.settings.droplistTrigger });
7
+ const buttonProps = Object.assign(Object.assign({}, button), { size: 's', icon: button.icon || _jsx(KebabSVG, {}), 'data-test-id': TEST_IDS.settings.droplistTrigger });
8
8
  if (!(actions === null || actions === void 0 ? void 0 : actions.length)) {
9
9
  return _jsx(ButtonSimple, Object.assign({}, buttonProps));
10
10
  }
@@ -9,5 +9,5 @@ export function NotificationPanelSettingsDroplist({ actions, button }) {
9
9
  const { firstElementRefCallback, triggerElementRef, handleDroplistFocusLeave, handleTriggerKeyDown, handleDroplistItemKeyDown, handleDroplistItemClick, } = Droplist.useKeyboardNavigation({
10
10
  setDroplistOpen,
11
11
  });
12
- return (_jsx(Droplist, Object.assign({ open: isDroplistOpen, onOpenChange: setDroplistOpen, firstElementRefCallback: firstElementRefCallback, onFocusLeave: handleDroplistFocusLeave, useScroll: true, triggerRef: triggerElementRef, triggerElement: _jsx(ButtonSimple, Object.assign({}, button, { onKeyDown: handleTriggerKeyDown })), placement: Droplist.placements.BottomEnd, "data-test-id": TEST_IDS.settings.droplist }, { children: actions.map(action => (_createElement(Droplist.ItemSingle, Object.assign({}, action, { key: action.option, onClick: e => handleDroplistItemClick(e, action.onClick), onKeyDown: handleDroplistItemKeyDown, "data-test-id": TEST_IDS.settings.droplistAction })))) })));
12
+ return (_jsx(Droplist, Object.assign({ open: isDroplistOpen, onOpenChange: setDroplistOpen, firstElementRefCallback: firstElementRefCallback, onFocusLeave: handleDroplistFocusLeave, useScroll: true, triggerRef: triggerElementRef, triggerElement: _jsx(ButtonSimple, Object.assign({}, button, { onKeyDown: handleTriggerKeyDown })), placement: 'bottom-end', "data-test-id": TEST_IDS.settings.droplist }, { children: actions.map(action => (_createElement(Droplist.ItemSingle, Object.assign({}, action, { key: action.option, onClick: e => handleDroplistItemClick(e, action.onClick), onKeyDown: handleDroplistItemKeyDown, "data-test-id": TEST_IDS.settings.droplistAction })))) })));
13
13
  }
@@ -14,9 +14,9 @@ import cn from 'classnames';
14
14
  import { PopoverPrivate } from '@snack-uikit/popover-private';
15
15
  import styles from './styles.module.css';
16
16
  export function NotificationPanelPopover(_a) {
17
- var { content, trigger = PopoverPrivate.triggers.Click, placement = PopoverPrivate.placements.BottomEnd, children, contentClassName } = _a, otherProps = __rest(_a, ["content", "trigger", "placement", "children", "contentClassName"]);
17
+ var { content, trigger = 'click', placement = 'bottom-end', children, contentClassName } = _a, otherProps = __rest(_a, ["content", "trigger", "placement", "children", "contentClassName"]);
18
18
  if (!children) {
19
19
  return null;
20
20
  }
21
- return (_jsx(PopoverPrivate, Object.assign({ fallbackPlacements: [], placement: placement, popoverContent: _jsx("div", Object.assign({ className: styles.notificationPanelPopoverWrap }, { children: _jsx("div", Object.assign({ className: cn(styles.notificationPanelPopover, contentClassName) }, { children: content })) })), trigger: trigger, hasArrow: false, heightStrategy: PopoverPrivate.heightStrategies.Lte }, otherProps, { children: children })));
21
+ return (_jsx(PopoverPrivate, Object.assign({ fallbackPlacements: [], placement: placement, popoverContent: _jsx("div", Object.assign({ className: styles.notificationPanelPopoverWrap }, { children: _jsx("div", Object.assign({ className: cn(styles.notificationPanelPopover, contentClassName) }, { children: content })) })), trigger: trigger, hasArrow: false, heightStrategy: 'lte' }, otherProps, { children: children })));
22
22
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Notification",
7
- "version": "0.4.2",
7
+ "version": "0.5.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -32,19 +32,19 @@
32
32
  "license": "Apache-2.0",
33
33
  "scripts": {},
34
34
  "dependencies": {
35
- "@snack-uikit/button": "0.14.1",
36
- "@snack-uikit/chips": "0.9.2",
37
- "@snack-uikit/droplist": "0.11.2",
38
- "@snack-uikit/icon-predefined": "0.3.1",
35
+ "@snack-uikit/button": "0.15.0",
36
+ "@snack-uikit/chips": "0.10.0",
37
+ "@snack-uikit/droplist": "0.12.0",
38
+ "@snack-uikit/icon-predefined": "0.4.0",
39
39
  "@snack-uikit/icons": "0.19.0",
40
- "@snack-uikit/link": "0.8.1",
41
- "@snack-uikit/popover-private": "0.11.1",
42
- "@snack-uikit/scroll": "0.4.1",
43
- "@snack-uikit/skeleton": "0.3.1",
44
- "@snack-uikit/truncate-string": "0.3.1",
45
- "@snack-uikit/typography": "0.5.1",
46
- "@snack-uikit/utils": "3.1.0",
40
+ "@snack-uikit/link": "0.9.0",
41
+ "@snack-uikit/popover-private": "0.12.0",
42
+ "@snack-uikit/scroll": "0.5.0",
43
+ "@snack-uikit/skeleton": "0.3.2",
44
+ "@snack-uikit/truncate-string": "0.4.0",
45
+ "@snack-uikit/typography": "0.6.0",
46
+ "@snack-uikit/utils": "3.2.0",
47
47
  "classnames": "2.3.2"
48
48
  },
49
- "gitHead": "e124e31699926810648702f97db72413d7ebd2b2"
49
+ "gitHead": "bd39c5e674f3b91b0e2487782a04b15034cf3d8b"
50
50
  }
@@ -8,9 +8,10 @@ import { Typography } from '@snack-uikit/typography';
8
8
  import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
9
9
 
10
10
  import { NotificationCardFunction } from './components';
11
- import { Appearance, TEST_IDS } from './constants';
11
+ import { APPEARANCE, TEST_IDS } from './constants';
12
12
  import { getIcon } from './helpers';
13
13
  import styles from './styles.module.scss';
14
+ import { Appearance } from './types';
14
15
 
15
16
  export type NotificationCardProps = WithSupportProps<{
16
17
  /** Идентификатор уведомления */
@@ -45,7 +46,7 @@ export type NotificationCardProps = WithSupportProps<{
45
46
  /** Компонент карточки уведомления */
46
47
  export function NotificationCard({
47
48
  id,
48
- appearance = Appearance.Neutral,
49
+ appearance = APPEARANCE.Neutral,
49
50
  label,
50
51
  unread,
51
52
  title,
@@ -58,10 +59,10 @@ export function NotificationCard({
58
59
  className,
59
60
  ...rest
60
61
  }: NotificationCardProps) {
61
- const { icon, linkOnColor } = useMemo(
62
+ const { icon, linkOnColor } = useMemo<{ icon: ReturnType<typeof getIcon>; linkOnColor: LinkProps['onColor'] }>(
62
63
  () => ({
63
64
  icon: getIcon(appearance),
64
- linkOnColor: appearance === Appearance.ErrorCritical ? Link.onColors.Red : undefined,
65
+ linkOnColor: appearance === APPEARANCE.ErrorCritical ? 'red' : undefined,
65
66
  }),
66
67
  [appearance],
67
68
  );
@@ -122,7 +123,7 @@ export function NotificationCard({
122
123
  )}
123
124
 
124
125
  {label && (
125
- <Typography.LightLabelS tag={Typography.tags.div} className={styles.notificationCardLabel}>
126
+ <Typography.LightLabelS tag='div' className={styles.notificationCardLabel}>
126
127
  <TruncateString maxLines={1} text={label} data-test-id={TEST_IDS.label} />
127
128
  </Typography.LightLabelS>
128
129
  )}
@@ -130,17 +131,13 @@ export function NotificationCard({
130
131
  <div className={styles.notificationCardTitle}>
131
132
  <div className={styles.notificationCardTitleIcon}>{icon}</div>
132
133
 
133
- <Typography.SansTitleS tag={Typography.tags.div} className={styles.notificationCardTitleText}>
134
+ <Typography.SansTitleS tag='div' className={styles.notificationCardTitleText}>
134
135
  <TruncateString maxLines={2} text={title} data-test-id={TEST_IDS.title} />
135
136
  </Typography.SansTitleS>
136
137
  </div>
137
138
 
138
139
  {content && (
139
- <Typography.SansBodyS
140
- tag={Typography.tags.div}
141
- className={styles.notificationCardContent}
142
- data-test-id={TEST_IDS.content}
143
- >
140
+ <Typography.SansBodyS tag='div' className={styles.notificationCardContent} data-test-id={TEST_IDS.content}>
144
141
  {content}
145
142
  </Typography.SansBodyS>
146
143
  )}
@@ -152,8 +149,8 @@ export function NotificationCard({
152
149
  {...link}
153
150
  onClick={handleLinkClick}
154
151
  onColor={linkOnColor}
155
- onSurface={Link.onSurfaces.Decor}
156
- size={Link.sizes.S}
152
+ onSurface='decor'
153
+ size='s'
157
154
  data-test-id={TEST_IDS.link}
158
155
  />
159
156
  )}
@@ -168,5 +165,3 @@ export function NotificationCard({
168
165
  </div>
169
166
  );
170
167
  }
171
-
172
- NotificationCard.appearances = Appearance;
@@ -30,14 +30,14 @@ export function NotificationCardFunction({ actions, open, setDroplistOpen }: Not
30
30
  <Droplist
31
31
  open={open}
32
32
  onOpenChange={setDroplistOpen}
33
- placement={Droplist.placements.BottomEnd}
33
+ placement='bottom-end'
34
34
  firstElementRefCallback={firstElementRefCallback}
35
35
  onFocusLeave={handleDroplistFocusLeave}
36
36
  triggerRef={triggerElementRef}
37
37
  useScroll
38
38
  triggerElement={
39
39
  <ButtonFunction
40
- size={ButtonFunction.sizes.S}
40
+ size='s'
41
41
  icon={<KebabSVG />}
42
42
  onKeyDown={handleTriggerKeyDown}
43
43
  data-test-id={TEST_IDS.actions.droplistTrigger}
@@ -1,10 +1,10 @@
1
- export enum Appearance {
2
- Neutral = 'neutral',
3
- Error = 'error',
4
- ErrorCritical = 'errorCritical',
5
- Warning = 'warning',
6
- Success = 'success',
7
- }
1
+ export const APPEARANCE = {
2
+ Neutral: 'neutral',
3
+ Error: 'error',
4
+ ErrorCritical: 'errorCritical',
5
+ Warning: 'warning',
6
+ Success: 'success',
7
+ } as const;
8
8
 
9
9
  export const TEST_IDS = {
10
10
  label: 'notification-card__label',
@@ -1,17 +1,18 @@
1
1
  import { AlarmFilledSVG, CheckFilledSVG, CrossFilledSVG, InfoFilledSVG } from '@snack-uikit/icons';
2
2
 
3
- import { Appearance } from './constants';
3
+ import { APPEARANCE } from './constants';
4
+ import { Appearance } from './types';
4
5
 
5
6
  export function getIcon(appearance: Appearance) {
6
7
  switch (appearance) {
7
- case Appearance.Success:
8
+ case APPEARANCE.Success:
8
9
  return <CheckFilledSVG size={16} />;
9
- case Appearance.Error:
10
- case Appearance.ErrorCritical:
10
+ case APPEARANCE.Error:
11
+ case APPEARANCE.ErrorCritical:
11
12
  return <CrossFilledSVG size={16} />;
12
- case Appearance.Warning:
13
+ case APPEARANCE.Warning:
13
14
  return <AlarmFilledSVG size={16} />;
14
- case Appearance.Neutral:
15
+ case APPEARANCE.Neutral:
15
16
  return <InfoFilledSVG size={16} />;
16
17
  default:
17
18
  return null;
@@ -0,0 +1,5 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+
3
+ import { APPEARANCE } from './constants';
4
+
5
+ export type Appearance = ValueOf<typeof APPEARANCE>;
@@ -2,7 +2,6 @@ import { MouseEventHandler, ReactNode, useMemo } from 'react';
2
2
 
3
3
  import { ButtonFunction, ButtonFunctionProps } from '@snack-uikit/button';
4
4
  import { ChipToggle, ChipToggleProps } from '@snack-uikit/chips';
5
- import { PopoverPrivate } from '@snack-uikit/popover-private';
6
5
  import { Scroll } from '@snack-uikit/scroll';
7
6
  import { SkeletonContextProvider, WithSkeleton } from '@snack-uikit/skeleton';
8
7
  import { TruncateString } from '@snack-uikit/truncate-string';
@@ -83,7 +82,7 @@ export function NotificationPanel({
83
82
  {...chip}
84
83
  key={chip.label}
85
84
  data-test-id={`${TEST_IDS.chip}-${chip.label}`}
86
- size={ChipToggle.sizes.Xs}
85
+ size='xs'
87
86
  disabled={chip.disabled || loading}
88
87
  />
89
88
  ))}
@@ -99,7 +98,7 @@ export function NotificationPanel({
99
98
  </div>
100
99
  </div>
101
100
 
102
- <Scroll size={Scroll.sizes.M} className={styles.notificationPanelBody}>
101
+ <Scroll size='m' className={styles.notificationPanelBody}>
103
102
  {loading ? (
104
103
  <SkeletonContextProvider loading={loading || false}>
105
104
  {skeletons.map(skeleton => (
@@ -124,10 +123,6 @@ export function NotificationPanel({
124
123
  );
125
124
  }
126
125
 
127
- NotificationPanel.placements = PopoverPrivate.placements;
128
- NotificationPanel.triggers = PopoverPrivate.triggers;
129
- NotificationPanel.widthStrategies = PopoverPrivate.widthStrategies;
130
-
131
126
  export namespace NotificationPanel {
132
127
  export const Blank: typeof NotificationPanelBlank = NotificationPanelBlank;
133
128
  export type BlankProps = NotificationPanelBlankProps;
@@ -24,7 +24,7 @@ export type NotificationPanelBlankProps = WithSupportProps<{
24
24
  /** Компонента для "заглушки" вместо карточек в панели */
25
25
  export function NotificationPanelBlank({
26
26
  icon,
27
- iconAppearance = IconPredefined.appearances.Neutral,
27
+ iconAppearance = 'neutral',
28
28
  title,
29
29
  description,
30
30
  className,
@@ -32,18 +32,11 @@ export function NotificationPanelBlank({
32
32
  }: NotificationPanelBlankProps) {
33
33
  return (
34
34
  <div className={cn(styles.notificationPanelBlank, className)} {...extractSupportProps(rest)}>
35
- {icon && (
36
- <IconPredefined
37
- icon={icon}
38
- appearance={iconAppearance}
39
- size={IconPredefined.sizes.L}
40
- data-test-id={TEST_IDS.blank.icon}
41
- />
42
- )}
35
+ {icon && <IconPredefined icon={icon} appearance={iconAppearance} size='l' data-test-id={TEST_IDS.blank.icon} />}
43
36
 
44
37
  <div className={styles.notificationPanelBlankContent}>
45
38
  <Typography.SansTitleS
46
- tag={Typography.tags.div}
39
+ tag='div'
47
40
  className={styles.notificationPanelBlankTitle}
48
41
  data-test-id={TEST_IDS.blank.title}
49
42
  >
@@ -51,7 +44,7 @@ export function NotificationPanelBlank({
51
44
  </Typography.SansTitleS>
52
45
 
53
46
  <Typography.SansBodyM
54
- tag={Typography.tags.div}
47
+ tag='div'
55
48
  className={styles.notificationPanelBlankDescription}
56
49
  data-test-id={TEST_IDS.blank.description}
57
50
  >
@@ -61,5 +54,3 @@ export function NotificationPanelBlank({
61
54
  </div>
62
55
  );
63
56
  }
64
-
65
- NotificationPanelBlank.iconAppearances = IconPredefined.appearances;
@@ -18,7 +18,7 @@ export type NotificationPanelSettingsProps = {
18
18
  export function NotificationPanelSettings({ actions, button }: NotificationPanelSettingsProps) {
19
19
  const buttonProps: ButtonSimpleProps = {
20
20
  ...button,
21
- size: ButtonSimple.sizes.S,
21
+ size: 's',
22
22
  icon: button.icon || <KebabSVG />,
23
23
  'data-test-id': TEST_IDS.settings.droplistTrigger,
24
24
  };
@@ -33,7 +33,7 @@ export function NotificationPanelSettingsDroplist({ actions, button }: Notificat
33
33
  useScroll
34
34
  triggerRef={triggerElementRef}
35
35
  triggerElement={<ButtonSimple {...button} onKeyDown={handleTriggerKeyDown} />}
36
- placement={Droplist.placements.BottomEnd}
36
+ placement='bottom-end'
37
37
  data-test-id={TEST_IDS.settings.droplist}
38
38
  >
39
39
  {actions.map(action => (
@@ -30,8 +30,8 @@ export type NotificationPanelPopoverProps = WithSupportProps<
30
30
 
31
31
  export function NotificationPanelPopover({
32
32
  content,
33
- trigger = PopoverPrivate.triggers.Click,
34
- placement = PopoverPrivate.placements.BottomEnd,
33
+ trigger = 'click',
34
+ placement = 'bottom-end',
35
35
  children,
36
36
  contentClassName,
37
37
  ...otherProps
@@ -51,7 +51,7 @@ export function NotificationPanelPopover({
51
51
  }
52
52
  trigger={trigger}
53
53
  hasArrow={false}
54
- heightStrategy={PopoverPrivate.heightStrategies.Lte}
54
+ heightStrategy='lte'
55
55
  {...otherProps}
56
56
  >
57
57
  {children}