@snack-uikit/notification 0.5.5 → 0.6.1-preview-57c837e3.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.6.0 (2024-01-30)
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+
12
+ * **FF-4075:** change usage droplist to list package ([4ce6391](https://github.com/cloud-ru-tech/snack-uikit/commit/4ce63915e838a46a3776e8e21393695a37d2fdd3))
13
+
14
+
15
+
16
+
6
17
  ## 0.5.5 (2024-01-23)
7
18
 
8
19
  ### Only dependencies have been changed
package/README.md CHANGED
@@ -91,7 +91,7 @@ const cards = [
91
91
  | link | `Omit<LinkProps, "data-test-id" \| "appearance" \| "size" \| "textMode">` | - | Ссылка |
92
92
  | onClick | `MouseEventHandler<HTMLDivElement>` | - | Колбэк клика по карточке |
93
93
  | onVisible | `(cardId: string) => void` | - | Колбэк при попадании карточки в область видимости на 80% |
94
- | actions | `Pick<DroplistItemSingleProps, "onClick" \| "option" \| "caption" \| "description" \| "tagLabel" \| "disabled" \| "icon">[]` | - | Дополнительные действия у карточки |
94
+ | actions | `Action[]` | - | Дополнительные действия у карточки |
95
95
  | className | `string` | - | CSS-класс |
96
96
  ## NotificationPanel
97
97
  Компонент панели для уведомлений
@@ -1,8 +1,12 @@
1
- import { MouseEventHandler, ReactNode } from 'react';
2
- import { ItemSingleProps } from '@snack-uikit/droplist';
1
+ import { MouseEventHandler, ReactElement, ReactNode } from 'react';
3
2
  import { LinkProps } from '@snack-uikit/link';
3
+ import { BaseItemProps } from '@snack-uikit/list';
4
4
  import { WithSupportProps } from '@snack-uikit/utils';
5
5
  import { Appearance } from './types';
6
+ type Action = {
7
+ icon?: ReactElement;
8
+ tagLabel?: string;
9
+ } & Pick<BaseItemProps, 'content' | 'onClick' | 'disabled'>;
6
10
  export type NotificationCardProps = WithSupportProps<{
7
11
  /** Идентификатор уведомления */
8
12
  id: string;
@@ -25,9 +29,10 @@ export type NotificationCardProps = WithSupportProps<{
25
29
  /** Колбэк при попадании карточки в область видимости на 80% */
26
30
  onVisible?(cardId: string): void;
27
31
  /** Дополнительные действия у карточки */
28
- actions?: Pick<ItemSingleProps, 'option' | 'onClick' | 'disabled' | 'icon' | 'description' | 'caption' | 'tagLabel'>[];
32
+ actions?: Action[];
29
33
  /** CSS-класс */
30
34
  className?: string;
31
35
  }>;
32
36
  /** Компонент карточки уведомления */
33
37
  export declare function NotificationCard({ id, appearance, label, unread, title, content, link, date, onClick, actions, onVisible, className, ...rest }: NotificationCardProps): import("react/jsx-runtime").JSX.Element;
38
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { Dispatch, SetStateAction } from 'react';
2
- import { DroplistProps } from '@snack-uikit/droplist';
3
2
  import { NotificationCardProps } from '../NotificationCard';
4
- export type NotificationCardFunctionProps = Required<Pick<NotificationCardProps, 'actions'>> & Required<Pick<DroplistProps, 'open'>> & {
3
+ export type NotificationCardFunctionProps = Required<Pick<NotificationCardProps, 'actions'>> & {
4
+ open: boolean;
5
5
  setDroplistOpen: Dispatch<SetStateAction<boolean>>;
6
6
  };
7
7
  export declare function NotificationCardFunction({ actions, open, setDroplistOpen }: NotificationCardFunctionProps): import("react/jsx-runtime").JSX.Element;
@@ -1,13 +1,20 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { createElement as _createElement } from "react";
3
2
  import { ButtonFunction } from '@snack-uikit/button';
4
- import { Droplist } from '@snack-uikit/droplist';
5
3
  import { KebabSVG } from '@snack-uikit/icons';
4
+ import { Droplist } from '@snack-uikit/list';
5
+ import { Tag } from '@snack-uikit/tag';
6
6
  import { TEST_IDS } from '../constants';
7
7
  import styles from '../styles.module.css';
8
8
  export function NotificationCardFunction({ actions, open, setDroplistOpen }) {
9
- const { firstElementRefCallback, triggerElementRef, handleDroplistFocusLeave, handleTriggerKeyDown, handleDroplistItemKeyDown, handleDroplistItemClick, } = Droplist.useKeyboardNavigation({
10
- setDroplistOpen,
11
- });
12
- return (_jsx("div", { className: styles.notificationCardFunction, "data-test-id": TEST_IDS.actions.wrapper, children: _jsx(Droplist, { 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 })))) }) }));
9
+ return (_jsx("div", { className: styles.notificationCardFunction, "data-test-id": TEST_IDS.actions.wrapper, children: _jsx(Droplist, { trigger: 'clickAndFocusVisible', open: open, onOpenChange: setDroplistOpen, placement: 'bottom-end', scroll: true, "data-test-id": TEST_IDS.actions.droplist, items: actions.map(({ onClick, disabled, content, tagLabel, icon }) => ({
10
+ onClick: e => {
11
+ setDroplistOpen(false);
12
+ onClick === null || onClick === void 0 ? void 0 : onClick(e);
13
+ },
14
+ disabled,
15
+ content,
16
+ beforeContent: icon,
17
+ afterContent: tagLabel ? _jsx(Tag, { label: tagLabel }) : undefined,
18
+ 'data-test-id': TEST_IDS.actions.droplistAction,
19
+ })), children: _jsx(ButtonFunction, { size: 's', icon: _jsx(KebabSVG, {}), "data-test-id": TEST_IDS.actions.droplistTrigger }) }) }));
13
20
  }
@@ -1,8 +1,8 @@
1
1
  import { ButtonSimpleProps } from '@snack-uikit/button';
2
- import { ItemSingleProps } from '@snack-uikit/droplist';
2
+ import { Action } from './NotificationPanelSettingsDroplist';
3
3
  export type NotificationPanelSettingsProps = {
4
4
  /** Дополнительные действия панели */
5
- actions?: Pick<ItemSingleProps, 'option' | 'onClick' | 'disabled' | 'icon' | 'description' | 'caption' | 'tagLabel'>[];
5
+ actions?: Action[];
6
6
  /** Кнопка дополнительного действия панели */
7
7
  button: Omit<ButtonSimpleProps, 'label' | 'type' | 'size' | 'data-test-id'>;
8
8
  };
@@ -1,7 +1,12 @@
1
+ import { ReactElement } from 'react';
1
2
  import { ButtonSimpleProps } from '@snack-uikit/button';
2
- import { ItemSingleProps } from '@snack-uikit/droplist';
3
+ import { BaseItemProps } from '@snack-uikit/list';
4
+ export type Action = {
5
+ icon?: ReactElement;
6
+ tagLabel?: string;
7
+ } & Pick<BaseItemProps, 'content' | 'disabled' | 'onClick'>;
3
8
  type NotificationPanelSettingsDroplistProps = {
4
- actions: ItemSingleProps[];
9
+ actions: Action[];
5
10
  button: ButtonSimpleProps;
6
11
  };
7
12
  export declare function NotificationPanelSettingsDroplist({ actions, button }: NotificationPanelSettingsDroplistProps): import("react/jsx-runtime").JSX.Element;
@@ -1,13 +1,20 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { createElement as _createElement } from "react";
3
2
  import { useState } from 'react';
4
3
  import { ButtonSimple } from '@snack-uikit/button';
5
- import { Droplist } from '@snack-uikit/droplist';
4
+ import { Droplist } from '@snack-uikit/list';
5
+ import { Tag } from '@snack-uikit/tag';
6
6
  import { TEST_IDS } from '../../constants';
7
7
  export function NotificationPanelSettingsDroplist({ actions, button }) {
8
8
  const [isDroplistOpen, setDroplistOpen] = useState(false);
9
- const { firstElementRefCallback, triggerElementRef, handleDroplistFocusLeave, handleTriggerKeyDown, handleDroplistItemKeyDown, handleDroplistItemClick, } = Droplist.useKeyboardNavigation({
10
- setDroplistOpen,
11
- });
12
- return (_jsx(Droplist, { 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 })))) }));
9
+ return (_jsx(Droplist, { trigger: 'clickAndFocusVisible', open: isDroplistOpen, onOpenChange: setDroplistOpen, scroll: true, placement: 'bottom-end', "data-test-id": TEST_IDS.settings.droplist, items: actions.map(({ icon, content, tagLabel, disabled, onClick }) => ({
10
+ onClick: e => {
11
+ setDroplistOpen(false);
12
+ onClick === null || onClick === void 0 ? void 0 : onClick(e);
13
+ },
14
+ disabled,
15
+ content,
16
+ beforeContent: icon,
17
+ afterContent: tagLabel ? _jsx(Tag, { label: tagLabel }) : undefined,
18
+ 'data-test-id': TEST_IDS.settings.droplistAction,
19
+ })), children: _jsx(ButtonSimple, Object.assign({}, button)) }));
13
20
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Notification",
7
- "version": "0.5.5",
7
+ "version": "0.6.1-preview-57c837e3.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -33,18 +33,19 @@
33
33
  "scripts": {},
34
34
  "dependencies": {
35
35
  "@snack-uikit/button": "0.15.1",
36
- "@snack-uikit/chips": "0.10.5",
37
- "@snack-uikit/droplist": "0.12.5",
36
+ "@snack-uikit/chips": "0.10.6",
38
37
  "@snack-uikit/icon-predefined": "0.4.1",
39
38
  "@snack-uikit/icons": "0.20.0",
40
39
  "@snack-uikit/link": "0.10.1",
40
+ "@snack-uikit/list": "0.1.1-preview-57c837e3.0",
41
41
  "@snack-uikit/popover-private": "0.12.2",
42
42
  "@snack-uikit/scroll": "0.5.0",
43
43
  "@snack-uikit/skeleton": "0.3.2",
44
+ "@snack-uikit/tag": "0.6.4",
44
45
  "@snack-uikit/truncate-string": "0.4.5",
45
46
  "@snack-uikit/typography": "0.6.1",
46
47
  "@snack-uikit/utils": "3.2.0",
47
48
  "classnames": "2.3.2"
48
49
  },
49
- "gitHead": "c292f4c45173928f57cc5c9f3cb02efb26887b64"
50
+ "gitHead": "0539acbacf5bc065cdb55739e06f63366ac9178b"
50
51
  }
@@ -1,8 +1,8 @@
1
1
  import cn from 'classnames';
2
- import { MouseEventHandler, ReactNode, useEffect, useMemo, useRef, useState } from 'react';
2
+ import { MouseEventHandler, ReactElement, ReactNode, useEffect, useMemo, useRef, useState } from 'react';
3
3
 
4
- import { ItemSingleProps } from '@snack-uikit/droplist';
5
4
  import { Link, LinkProps } from '@snack-uikit/link';
5
+ import { BaseItemProps } from '@snack-uikit/list';
6
6
  import { TruncateString } from '@snack-uikit/truncate-string';
7
7
  import { Typography } from '@snack-uikit/typography';
8
8
  import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
@@ -13,6 +13,11 @@ import { getIcon } from './helpers';
13
13
  import styles from './styles.module.scss';
14
14
  import { Appearance } from './types';
15
15
 
16
+ type Action = {
17
+ icon?: ReactElement;
18
+ tagLabel?: string;
19
+ } & Pick<BaseItemProps, 'content' | 'onClick' | 'disabled'>;
20
+
16
21
  export type NotificationCardProps = WithSupportProps<{
17
22
  /** Идентификатор уведомления */
18
23
  id: string;
@@ -35,10 +40,7 @@ export type NotificationCardProps = WithSupportProps<{
35
40
  /** Колбэк при попадании карточки в область видимости на 80% */
36
41
  onVisible?(cardId: string): void;
37
42
  /** Дополнительные действия у карточки */
38
- actions?: Pick<
39
- ItemSingleProps,
40
- 'option' | 'onClick' | 'disabled' | 'icon' | 'description' | 'caption' | 'tagLabel'
41
- >[];
43
+ actions?: Action[];
42
44
  /** CSS-класс */
43
45
  className?: string;
44
46
  }>;
@@ -1,59 +1,42 @@
1
1
  import { Dispatch, SetStateAction } from 'react';
2
2
 
3
3
  import { ButtonFunction } from '@snack-uikit/button';
4
- import { Droplist, DroplistProps } from '@snack-uikit/droplist';
5
4
  import { KebabSVG } from '@snack-uikit/icons';
5
+ import { Droplist } from '@snack-uikit/list';
6
+ import { Tag } from '@snack-uikit/tag';
6
7
 
7
8
  import { TEST_IDS } from '../constants';
8
9
  import { NotificationCardProps } from '../NotificationCard';
9
10
  import styles from '../styles.module.scss';
10
11
 
11
- export type NotificationCardFunctionProps = Required<Pick<NotificationCardProps, 'actions'>> &
12
- Required<Pick<DroplistProps, 'open'>> & {
13
- setDroplistOpen: Dispatch<SetStateAction<boolean>>;
14
- };
12
+ export type NotificationCardFunctionProps = Required<Pick<NotificationCardProps, 'actions'>> & {
13
+ open: boolean;
14
+ setDroplistOpen: Dispatch<SetStateAction<boolean>>;
15
+ };
15
16
 
16
17
  export function NotificationCardFunction({ actions, open, setDroplistOpen }: NotificationCardFunctionProps) {
17
- const {
18
- firstElementRefCallback,
19
- triggerElementRef,
20
- handleDroplistFocusLeave,
21
- handleTriggerKeyDown,
22
- handleDroplistItemKeyDown,
23
- handleDroplistItemClick,
24
- } = Droplist.useKeyboardNavigation<HTMLButtonElement>({
25
- setDroplistOpen,
26
- });
27
-
28
18
  return (
29
19
  <div className={styles.notificationCardFunction} data-test-id={TEST_IDS.actions.wrapper}>
30
20
  <Droplist
21
+ trigger='clickAndFocusVisible'
31
22
  open={open}
32
23
  onOpenChange={setDroplistOpen}
33
24
  placement='bottom-end'
34
- firstElementRefCallback={firstElementRefCallback}
35
- onFocusLeave={handleDroplistFocusLeave}
36
- triggerRef={triggerElementRef}
37
- useScroll
38
- triggerElement={
39
- <ButtonFunction
40
- size='s'
41
- icon={<KebabSVG />}
42
- onKeyDown={handleTriggerKeyDown}
43
- data-test-id={TEST_IDS.actions.droplistTrigger}
44
- />
45
- }
25
+ scroll
46
26
  data-test-id={TEST_IDS.actions.droplist}
27
+ items={actions.map(({ onClick, disabled, content, tagLabel, icon }) => ({
28
+ onClick: e => {
29
+ setDroplistOpen(false);
30
+ onClick?.(e);
31
+ },
32
+ disabled,
33
+ content,
34
+ beforeContent: icon,
35
+ afterContent: tagLabel ? <Tag label={tagLabel} /> : undefined,
36
+ 'data-test-id': TEST_IDS.actions.droplistAction,
37
+ }))}
47
38
  >
48
- {actions.map(action => (
49
- <Droplist.ItemSingle
50
- {...action}
51
- key={action.option}
52
- onClick={e => handleDroplistItemClick(e, action.onClick)}
53
- data-test-id={TEST_IDS.actions.droplistAction}
54
- onKeyDown={handleDroplistItemKeyDown}
55
- />
56
- ))}
39
+ <ButtonFunction size='s' icon={<KebabSVG />} data-test-id={TEST_IDS.actions.droplistTrigger} />
57
40
  </Droplist>
58
41
  </div>
59
42
  );
@@ -1,16 +1,12 @@
1
1
  import { ButtonSimple, ButtonSimpleProps } from '@snack-uikit/button';
2
- import { ItemSingleProps } from '@snack-uikit/droplist';
3
2
  import { KebabSVG } from '@snack-uikit/icons';
4
3
 
5
4
  import { TEST_IDS } from '../../constants';
6
- import { NotificationPanelSettingsDroplist } from './NotificationPanelSettingsDroplist';
5
+ import { Action, NotificationPanelSettingsDroplist } from './NotificationPanelSettingsDroplist';
7
6
 
8
7
  export type NotificationPanelSettingsProps = {
9
8
  /** Дополнительные действия панели */
10
- actions?: Pick<
11
- ItemSingleProps,
12
- 'option' | 'onClick' | 'disabled' | 'icon' | 'description' | 'caption' | 'tagLabel'
13
- >[];
9
+ actions?: Action[];
14
10
  /** Кнопка дополнительного действия панели */
15
11
  button: Omit<ButtonSimpleProps, 'label' | 'type' | 'size' | 'data-test-id'>;
16
12
  };
@@ -1,50 +1,45 @@
1
- import { useState } from 'react';
1
+ import { ReactElement, useState } from 'react';
2
2
 
3
3
  import { ButtonSimple, ButtonSimpleProps } from '@snack-uikit/button';
4
- import { Droplist, ItemSingleProps } from '@snack-uikit/droplist';
4
+ import { BaseItemProps, Droplist } from '@snack-uikit/list';
5
+ import { Tag } from '@snack-uikit/tag';
5
6
 
6
7
  import { TEST_IDS } from '../../constants';
7
8
 
9
+ export type Action = {
10
+ icon?: ReactElement;
11
+ tagLabel?: string;
12
+ } & Pick<BaseItemProps, 'content' | 'disabled' | 'onClick'>;
13
+
8
14
  type NotificationPanelSettingsDroplistProps = {
9
- actions: ItemSingleProps[];
15
+ actions: Action[];
10
16
  button: ButtonSimpleProps;
11
17
  };
12
18
 
13
19
  export function NotificationPanelSettingsDroplist({ actions, button }: NotificationPanelSettingsDroplistProps) {
14
20
  const [isDroplistOpen, setDroplistOpen] = useState(false);
15
21
 
16
- const {
17
- firstElementRefCallback,
18
- triggerElementRef,
19
- handleDroplistFocusLeave,
20
- handleTriggerKeyDown,
21
- handleDroplistItemKeyDown,
22
- handleDroplistItemClick,
23
- } = Droplist.useKeyboardNavigation<HTMLButtonElement>({
24
- setDroplistOpen,
25
- });
26
-
27
22
  return (
28
23
  <Droplist
24
+ trigger='clickAndFocusVisible'
29
25
  open={isDroplistOpen}
30
26
  onOpenChange={setDroplistOpen}
31
- firstElementRefCallback={firstElementRefCallback}
32
- onFocusLeave={handleDroplistFocusLeave}
33
- useScroll
34
- triggerRef={triggerElementRef}
35
- triggerElement={<ButtonSimple {...button} onKeyDown={handleTriggerKeyDown} />}
27
+ scroll
36
28
  placement='bottom-end'
37
29
  data-test-id={TEST_IDS.settings.droplist}
30
+ items={actions.map(({ icon, content, tagLabel, disabled, onClick }) => ({
31
+ onClick: e => {
32
+ setDroplistOpen(false);
33
+ onClick?.(e);
34
+ },
35
+ disabled,
36
+ content,
37
+ beforeContent: icon,
38
+ afterContent: tagLabel ? <Tag label={tagLabel} /> : undefined,
39
+ 'data-test-id': TEST_IDS.settings.droplistAction,
40
+ }))}
38
41
  >
39
- {actions.map(action => (
40
- <Droplist.ItemSingle
41
- {...action}
42
- key={action.option}
43
- onClick={e => handleDroplistItemClick(e, action.onClick)}
44
- onKeyDown={handleDroplistItemKeyDown}
45
- data-test-id={TEST_IDS.settings.droplistAction}
46
- />
47
- ))}
42
+ <ButtonSimple {...button} />
48
43
  </Droplist>
49
44
  );
50
45
  }