@cloud-ru/ds-uikit-product-notification 2.0.31 → 2.0.32-preview-04e34550.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 +7 -1
- package/dist/cjs/components/NotificationCard/NotificationCard.d.ts +3 -2
- package/dist/cjs/components/NotificationCard/NotificationCard.js +2 -2
- package/dist/cjs/components/NotificationPanel/components/NotificationCardStack/NotificationCardStack.d.ts +3 -2
- package/dist/cjs/components/NotificationPanel/components/NotificationCardStack/NotificationCardStack.js +2 -2
- package/dist/cjs/components/NotificationPanel/components/NotificationPanelSettings/NotificationPanelSettings.d.ts +3 -2
- package/dist/cjs/components/NotificationPanel/components/NotificationPanelSettings/NotificationPanelSettings.js +2 -2
- package/dist/cjs/components/NotificationPanel/components/NotificationPanelSettings/NotificationPanelSettingsDroplist.d.ts +3 -2
- package/dist/cjs/components/NotificationPanel/components/NotificationPanelSettings/NotificationPanelSettingsDroplist.js +2 -2
- package/dist/cjs/helperComponents/ActionsButton/ActionsButton.d.ts +3 -2
- package/dist/cjs/helperComponents/ActionsButton/ActionsButton.js +2 -2
- package/dist/esm/components/NotificationCard/NotificationCard.d.ts +3 -2
- package/dist/esm/components/NotificationCard/NotificationCard.js +2 -2
- package/dist/esm/components/NotificationPanel/components/NotificationCardStack/NotificationCardStack.d.ts +3 -2
- package/dist/esm/components/NotificationPanel/components/NotificationCardStack/NotificationCardStack.js +2 -2
- package/dist/esm/components/NotificationPanel/components/NotificationPanelSettings/NotificationPanelSettings.d.ts +3 -2
- package/dist/esm/components/NotificationPanel/components/NotificationPanelSettings/NotificationPanelSettings.js +2 -2
- package/dist/esm/components/NotificationPanel/components/NotificationPanelSettings/NotificationPanelSettingsDroplist.d.ts +3 -2
- package/dist/esm/components/NotificationPanel/components/NotificationPanelSettings/NotificationPanelSettingsDroplist.js +2 -2
- package/dist/esm/helperComponents/ActionsButton/ActionsButton.d.ts +3 -2
- package/dist/esm/helperComponents/ActionsButton/ActionsButton.js +2 -2
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +19 -19
- package/src/components/NotificationCard/NotificationCard.tsx +41 -34
- package/src/components/NotificationPanel/components/NotificationCardStack/NotificationCardStack.tsx +21 -14
- package/src/components/NotificationPanel/components/NotificationPanelSettings/NotificationPanelSettings.tsx +17 -3
- package/src/components/NotificationPanel/components/NotificationPanelSettings/NotificationPanelSettingsDroplist.tsx +10 -3
- package/src/helperComponents/ActionsButton/ActionsButton.tsx +6 -2
package/README.md
CHANGED
|
@@ -196,7 +196,9 @@ export function DeployFailureCard() {
|
|
|
196
196
|
| `data-test-id` | `string` | — | |
|
|
197
197
|
| `date` | `string` | — | Дата уведомления |
|
|
198
198
|
| `description` | `ReactNode` | — | Описание уведомления — вторичный текст под заголовком |
|
|
199
|
+
| `groupItemRender` | `((props: GroupItemRenderProps) => ReactNode)` | — | Рендер-функция заголовка группы вместо дефолтной разметки `Separator`. <br/> Не задана — заголовок/разделитель рисуются как раньше. |
|
|
199
200
|
| `id` | `string` | — | Идентификатор уведомления |
|
|
201
|
+
| `itemRender` | `((props: ItemRenderProps) => ReactNode)` | — | Рендер-функция оболочки строки вместо дефолтной разметки `BaseItem`. <br/> Не задана — строка рисуется как раньше. `itemWrapRender` по-прежнему оборачивает результат. |
|
|
200
202
|
| `label` | `string` | — | Лейбл перед заголовком |
|
|
201
203
|
| `link` | `PickLinkProps` | — | Ссылка (рендерится как `<a href>` через `@cloud-ru/ds-link`) |
|
|
202
204
|
| `onClick` | `MouseEventHandler<HTMLDivElement>` | — | Колбэк клика по карточке. Делает карточку кликабельной (`role='button'`, фокус с клавиатуры). <br/> Активация по карточке срабатывает только при фокусе на самой карточке — вложенные кнопки, <br/> ссылка и меню действий активируются независимо. |
|
|
@@ -705,7 +707,7 @@ export function PanelScenario() {
|
|
|
705
707
|
| `scrollContainerRef` | `RefObject<HTMLElement>` | — | Ссылка на контейнер, который скроллится |
|
|
706
708
|
| `scrollEndRef` | `RefObject<HTMLDivElement>` | — | Ссылка на элемент, обозначающий самый конец прокручиваемого списка |
|
|
707
709
|
| `segments` | `SegmentControlProps` | — | Сегменты для фильтрации |
|
|
708
|
-
| `settings` | `NotificationPanelSettingsProps` | — | Кнопка настроек и выпадающий список |
|
|
710
|
+
| `settings` | `DroplistListProps` \| `DroplistMobileSlots` \| `EmptyState` \| `NotificationPanelSettingsProps` \| `PublicListContextType` \| `ScrollProps` \| `SelectionState` | — | Кнопка настроек и выпадающий список |
|
|
709
711
|
| `showBlackout` | `boolean` | `true` | Отображение темной подложки |
|
|
710
712
|
| `skeletonsAmount` | `number` | `2` | Количество скелетонов карточек для отображения при загрузке |
|
|
711
713
|
| `title` | `string` | — | Заголовок панели |
|
|
@@ -729,6 +731,8 @@ export function PanelScenario() {
|
|
|
729
731
|
|------|------|---------|-------------|
|
|
730
732
|
| `actions` | `Action` | — | Дополнительные действия панели |
|
|
731
733
|
| `button` | `ButtonProps` | — | Кнопка дополнительного действия панели |
|
|
734
|
+
| `groupItemRender` | `((props: GroupItemRenderProps) => ReactNode) \| undefined` | — | Рендер-функция заголовка группы вместо дефолтной разметки `Separator`. <br/> Не задана — заголовок/разделитель рисуются как раньше. |
|
|
735
|
+
| `itemRender` | `((props: ItemRenderProps) => ReactNode) \| undefined` | — | Рендер-функция оболочки строки вместо дефолтной разметки `BaseItem`. <br/> Не задана — строка рисуется как раньше. `itemWrapRender` по-прежнему оборачивает результат. |
|
|
732
736
|
| `size` | `"m"` \| `"s"` | — | |
|
|
733
737
|
|
|
734
738
|
#### NotificationPanel.Stack
|
|
@@ -741,6 +745,8 @@ export function PanelScenario() {
|
|
|
741
745
|
| `children` | `Iterable<ReactNode>` | — | Карточки в стопке, видна первая карточка, остальные схлопываются под нее. |
|
|
742
746
|
| `data-test-id` | `string` | — | |
|
|
743
747
|
| `defaultOpen` | `boolean` | — | Состояние открыт/закрыт по умолчанию |
|
|
748
|
+
| `groupItemRender` | `((props: GroupItemRenderProps) => ReactNode)` | — | Рендер-функция заголовка группы вместо дефолтной разметки `Separator`. <br/> Не задана — заголовок/разделитель рисуются как раньше. |
|
|
749
|
+
| `itemRender` | `((props: ItemRenderProps) => ReactNode)` | — | Рендер-функция оболочки строки вместо дефолтной разметки `BaseItem`. <br/> Не задана — строка рисуется как раньше. `itemWrapRender` по-прежнему оборачивает результат. |
|
|
744
750
|
| `onOpenChanged` | `((open: boolean) => void)` | — | Колбек смены состояния открыт/закрыт |
|
|
745
751
|
| `title` | `string` | — | Заголовок стопки карточек |
|
|
746
752
|
| `unread` | `boolean` | — | Состояние непрочитанных карточек |
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ButtonProps } from '@cloud-ru/ds-button';
|
|
2
2
|
import { PickLinkProps } from '@cloud-ru/ds-link';
|
|
3
|
+
import { DroplistProps } from '@cloud-ru/ds-list';
|
|
3
4
|
import { WithSupportProps } from '@cloud-ru/ds-utils';
|
|
4
5
|
import { MouseEventHandler, ReactNode } from 'react';
|
|
5
6
|
import { Action, Appearance } from '../../types';
|
|
@@ -37,7 +38,7 @@ export type NotificationCardProps = WithSupportProps<{
|
|
|
37
38
|
actions?: Action[];
|
|
38
39
|
/** CSS-класс */
|
|
39
40
|
className?: string;
|
|
40
|
-
}
|
|
41
|
+
} & Pick<DroplistProps, 'itemRender' | 'groupItemRender'>>;
|
|
41
42
|
/** Карточка уведомления */
|
|
42
|
-
export declare function NotificationCard({ id, appearance, label, unread, title, description, link, date, onClick, primaryButton, secondaryButton, actions, onVisible, className, ...rest }: NotificationCardProps): import("react/jsx-runtime").JSX.Element;
|
|
43
|
+
export declare function NotificationCard({ id, appearance, label, unread, title, description, link, date, onClick, primaryButton, secondaryButton, actions, onVisible, className, itemRender, groupItemRender, ...rest }: NotificationCardProps): import("react/jsx-runtime").JSX.Element;
|
|
43
44
|
export {};
|
|
@@ -21,7 +21,7 @@ const helpers_1 = require("./helpers");
|
|
|
21
21
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
22
22
|
const VISIBILITY_THRESHOLD = 0.8;
|
|
23
23
|
/** Карточка уведомления */
|
|
24
|
-
function NotificationCard({ id, appearance = constants_1.APPEARANCE.Default, label, unread, title, description, link, date, onClick, primaryButton, secondaryButton, actions, onVisible, className, ...rest }) {
|
|
24
|
+
function NotificationCard({ id, appearance = constants_1.APPEARANCE.Default, label, unread, title, description, link, date, onClick, primaryButton, secondaryButton, actions, onVisible, className, itemRender, groupItemRender, ...rest }) {
|
|
25
25
|
const icon = (0, react_1.useMemo)(() => (0, helpers_1.getIcon)(appearance), [appearance]);
|
|
26
26
|
const [isDroplistOpen, setDroplistOpen] = (0, react_1.useState)(false);
|
|
27
27
|
const cardRef = (0, react_1.useRef)(null);
|
|
@@ -74,7 +74,7 @@ function NotificationCard({ id, appearance = constants_1.APPEARANCE.Default, lab
|
|
|
74
74
|
cardRef.current?.click();
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
|
-
return ((0, jsx_runtime_1.jsxs)("div", { role: 'button', tabIndex: 0, ref: cardRef, onKeyDown: handleKeyDown, onClick: onClick, ...(0, utils_1.extractSupportProps)(rest), "data-appearance": appearance, "data-unread": unread || undefined, "data-clickable": Boolean(onClick) || undefined, "data-droplist-open": isDroplistOpen || undefined, className: (0, classnames_1.default)(styles_module_scss_1.default.notificationCard, className), children: [(0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.stateLayer, "data-state": 'emptyNeutralOnBackground', "aria-hidden": true }), unread && (0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.visuallyHidden, children: "\u041D\u0435\u043F\u0440\u043E\u0447\u0438\u0442\u0430\u043D\u043D\u043E\u0435 \u0443\u0432\u0435\u0434\u043E\u043C\u043B\u0435\u043D\u0438\u0435" }), actions?.length ? ((0, jsx_runtime_1.jsx)(ActionsButton_1.ActionsButton, { className: styles_module_scss_1.default.notificationCardFunction, actions: actions, open: isDroplistOpen, setDroplistOpen: setDroplistOpen, icon: (0, jsx_runtime_1.jsx)(system_1.KebabSVG, {}), triggerAriaLabel: '\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u044F \u0441 \u0443\u0432\u0435\u0434\u043E\u043C\u043B\u0435\u043D\u0438\u0435\u043C', testIds: constants_1.TEST_IDS.card.actions })) : null, label && ((0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: 'body', size: 's', as: 'div', className: styles_module_scss_1.default.notificationCardLabel, children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { maxLines: 1, text: label, "data-test-id": constants_1.TEST_IDS.card.label }) })), (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.notificationCardTitle, children: [(0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.notificationCardTitleIcon, role: 'img', "aria-label": (0, helpers_1.getAppearanceLabel)(appearance), children: icon }), (0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: 'label', size: 'l', as: 'div', className: styles_module_scss_1.default.notificationCardTitleText, children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { maxLines: 2, text: title, "data-test-id": constants_1.TEST_IDS.card.title }) })] }), description != null && description !== '' && ((0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: 'body', size: 's', as: 'div', className: styles_module_scss_1.default.notificationCardContent, "data-test-id": constants_1.TEST_IDS.card.description, children: description })), (primaryButton || secondaryButton) && (
|
|
77
|
+
return ((0, jsx_runtime_1.jsxs)("div", { role: 'button', tabIndex: 0, ref: cardRef, onKeyDown: handleKeyDown, onClick: onClick, ...(0, utils_1.extractSupportProps)(rest), "data-appearance": appearance, "data-unread": unread || undefined, "data-clickable": Boolean(onClick) || undefined, "data-droplist-open": isDroplistOpen || undefined, className: (0, classnames_1.default)(styles_module_scss_1.default.notificationCard, className), children: [(0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.stateLayer, "data-state": 'emptyNeutralOnBackground', "aria-hidden": true }), unread && (0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.visuallyHidden, children: "\u041D\u0435\u043F\u0440\u043E\u0447\u0438\u0442\u0430\u043D\u043D\u043E\u0435 \u0443\u0432\u0435\u0434\u043E\u043C\u043B\u0435\u043D\u0438\u0435" }), actions?.length ? ((0, jsx_runtime_1.jsx)(ActionsButton_1.ActionsButton, { className: styles_module_scss_1.default.notificationCardFunction, actions: actions, open: isDroplistOpen, setDroplistOpen: setDroplistOpen, icon: (0, jsx_runtime_1.jsx)(system_1.KebabSVG, {}), triggerAriaLabel: '\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u044F \u0441 \u0443\u0432\u0435\u0434\u043E\u043C\u043B\u0435\u043D\u0438\u0435\u043C', testIds: constants_1.TEST_IDS.card.actions, itemRender: itemRender, groupItemRender: groupItemRender })) : null, label && ((0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: 'body', size: 's', as: 'div', className: styles_module_scss_1.default.notificationCardLabel, children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { maxLines: 1, text: label, "data-test-id": constants_1.TEST_IDS.card.label }) })), (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.notificationCardTitle, children: [(0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.notificationCardTitleIcon, role: 'img', "aria-label": (0, helpers_1.getAppearanceLabel)(appearance), children: icon }), (0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: 'label', size: 'l', as: 'div', className: styles_module_scss_1.default.notificationCardTitleText, children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { maxLines: 2, text: title, "data-test-id": constants_1.TEST_IDS.card.title }) })] }), description != null && description !== '' && ((0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: 'body', size: 's', as: 'div', className: styles_module_scss_1.default.notificationCardContent, "data-test-id": constants_1.TEST_IDS.card.description, children: description })), (primaryButton || secondaryButton) && (
|
|
78
78
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
79
79
|
(0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.notificationCardButtons, onClick: utils_2.stopPropagationClick, children: [secondaryButton && ((0, jsx_runtime_1.jsx)(button_1.Button, { ...secondaryButton, view: 'simple', appearance: 'neutral', size: 'm', "data-test-id": constants_1.TEST_IDS.card.secondaryButton })), primaryButton && ((0, jsx_runtime_1.jsx)(button_1.Button, { ...primaryButton, view: 'tonal', appearance: 'neutral', size: 'm', "data-test-id": constants_1.TEST_IDS.card.primaryButton }))] })), showFooter && ((0, jsx_runtime_1.jsxs)(typography_1.Typography, { variant: 'body', size: 's', as: 'div', className: styles_module_scss_1.default.notificationCardFooter, children: [link && (0, jsx_runtime_1.jsx)(link_1.Link, { ...link, onClick: handleLinkClick, appearance: 'primary', "data-test-id": constants_1.TEST_IDS.card.link }), date && ((0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: 'body', size: 's', as: 'span', className: styles_module_scss_1.default.notificationCardDate, "data-test-id": constants_1.TEST_IDS.card.date, children: date }))] })), unread && ((0, jsx_runtime_1.jsx)(status_1.StatusIndicator, { className: styles_module_scss_1.default.statusIndicator, size: '3xs', appearance: 'green', "data-test-id": constants_1.TEST_IDS.card.statusIndicator }))] }));
|
|
80
80
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DroplistProps } from '@cloud-ru/ds-list';
|
|
1
2
|
import { WithSupportProps } from '@cloud-ru/ds-utils';
|
|
2
3
|
import { ReactNode } from 'react';
|
|
3
4
|
import { Action } from '../../../../types';
|
|
@@ -14,5 +15,5 @@ export type NotificationCardStackProps = WithSupportProps<{
|
|
|
14
15
|
actions?: Action[];
|
|
15
16
|
/** Состояние непрочитанных карточек */
|
|
16
17
|
unread?: boolean;
|
|
17
|
-
}
|
|
18
|
-
export declare function NotificationCardStack({ children, defaultOpen, onOpenChanged, title, actions, unread, ...rest }: NotificationCardStackProps): import("react/jsx-runtime").JSX.Element | null;
|
|
18
|
+
} & Pick<DroplistProps, 'itemRender' | 'groupItemRender'>>;
|
|
19
|
+
export declare function NotificationCardStack({ children, defaultOpen, onOpenChanged, title, actions, unread, itemRender, groupItemRender, ...rest }: NotificationCardStackProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -18,7 +18,7 @@ const hooks_1 = require("./hooks");
|
|
|
18
18
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
19
19
|
const utils_2 = require("./utils");
|
|
20
20
|
const ANIMATION_DURATION = 0.3;
|
|
21
|
-
function NotificationCardStack({ children, defaultOpen, onOpenChanged, title, actions, unread, ...rest }) {
|
|
21
|
+
function NotificationCardStack({ children, defaultOpen, onOpenChanged, title, actions, unread, itemRender, groupItemRender, ...rest }) {
|
|
22
22
|
const [actionsOpen, setActionsOpen] = (0, react_1.useState)(false);
|
|
23
23
|
const { open, toggleOpen, isVisible } = (0, hooks_1.useAnimatedOpening)({
|
|
24
24
|
defaultOpen,
|
|
@@ -39,5 +39,5 @@ function NotificationCardStack({ children, defaultOpen, onOpenChanged, title, ac
|
|
|
39
39
|
onClick: toggleOpen,
|
|
40
40
|
unread: unread || componentProps.unread,
|
|
41
41
|
}));
|
|
42
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.container, style: { '--snack-notification-stack-animation-duration': `${ANIMATION_DURATION}s` }, "data-test-id": constants_1.TEST_IDS.panel.cardStack.wrapper, ...(0, utils_1.extractSupportProps)(rest), children: [(0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.header, "data-test-id": constants_1.TEST_IDS.panel.cardStack.headline, children: [(0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: 'label', size: 'l', as: 'div', className: styles_module_scss_1.default.title, onClick: toggleOpen, "aria-expanded": open, children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { "data-test-id": constants_1.TEST_IDS.panel.cardStack.title, text: title }) }), (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.right, children: [actions && actions.length > 0 && ((0, jsx_runtime_1.jsx)(ActionsButton_1.ActionsButton, { actions: actions, open: actionsOpen, setDroplistOpen: setActionsOpen, icon: (0, jsx_runtime_1.jsx)(system_1.KebabSVG, {}), triggerAriaLabel: '\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u044F \u0441\u043E \u0441\u0442\u043E\u043F\u043A\u043E\u0439', testIds: constants_1.TEST_IDS.panel.cardStack.actions })), (0, jsx_runtime_1.jsx)(button_1.Button, { view: 'function', appearance: 'neutral', size: 'm', onClick: toggleOpen, "aria-label": open ? 'Свернуть стопку' : 'Развернуть стопку', "aria-expanded": open, "data-test-id": constants_1.TEST_IDS.panel.cardStack.openButton, icon: open ? (0, jsx_runtime_1.jsx)(system_1.ChevronUpSVG, {}) : (0, jsx_runtime_1.jsx)(system_1.ChevronDownSVG, {}) })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.cards, children: [(0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.first, children: [(0, jsx_runtime_1.jsx)(StackTail_1.StackTail, { open: open, count: stack.length }), firstCardElement] }), (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.stack, "data-open": open || undefined, "data-tail-size": stack.length, children: (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.animationContainer, children: isVisible ? stack : [] }) })] })] }));
|
|
42
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.container, style: { '--snack-notification-stack-animation-duration': `${ANIMATION_DURATION}s` }, "data-test-id": constants_1.TEST_IDS.panel.cardStack.wrapper, ...(0, utils_1.extractSupportProps)(rest), children: [(0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.header, "data-test-id": constants_1.TEST_IDS.panel.cardStack.headline, children: [(0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: 'label', size: 'l', as: 'div', className: styles_module_scss_1.default.title, onClick: toggleOpen, "aria-expanded": open, children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { "data-test-id": constants_1.TEST_IDS.panel.cardStack.title, text: title }) }), (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.right, children: [actions && actions.length > 0 && ((0, jsx_runtime_1.jsx)(ActionsButton_1.ActionsButton, { actions: actions, open: actionsOpen, setDroplistOpen: setActionsOpen, icon: (0, jsx_runtime_1.jsx)(system_1.KebabSVG, {}), triggerAriaLabel: '\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u044F \u0441\u043E \u0441\u0442\u043E\u043F\u043A\u043E\u0439', testIds: constants_1.TEST_IDS.panel.cardStack.actions, itemRender: itemRender, groupItemRender: groupItemRender })), (0, jsx_runtime_1.jsx)(button_1.Button, { view: 'function', appearance: 'neutral', size: 'm', onClick: toggleOpen, "aria-label": open ? 'Свернуть стопку' : 'Развернуть стопку', "aria-expanded": open, "data-test-id": constants_1.TEST_IDS.panel.cardStack.openButton, icon: open ? (0, jsx_runtime_1.jsx)(system_1.ChevronUpSVG, {}) : (0, jsx_runtime_1.jsx)(system_1.ChevronDownSVG, {}) })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.cards, children: [(0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.first, children: [(0, jsx_runtime_1.jsx)(StackTail_1.StackTail, { open: open, count: stack.length }), firstCardElement] }), (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.stack, "data-open": open || undefined, "data-tail-size": stack.length, children: (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.animationContainer, children: isVisible ? stack : [] }) })] })] }));
|
|
43
43
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ButtonProps } from '@cloud-ru/ds-button';
|
|
2
|
+
import { DroplistProps } from '@cloud-ru/ds-list';
|
|
2
3
|
import { ElementType } from 'react';
|
|
3
4
|
import { Action } from '../../../../types';
|
|
4
5
|
export type NotificationPanelSettingsProps = {
|
|
@@ -7,6 +8,6 @@ export type NotificationPanelSettingsProps = {
|
|
|
7
8
|
/** Кнопка дополнительного действия панели */
|
|
8
9
|
button?: Omit<ButtonProps<ElementType>, 'label' | 'size' | 'view' | 'data-test-id'>;
|
|
9
10
|
size?: 's' | 'm';
|
|
10
|
-
}
|
|
11
|
+
} & Pick<DroplistProps, 'itemRender' | 'groupItemRender'>;
|
|
11
12
|
/** Кнопка настроек панели уведомлений (с выпадающим списком действий, если переданы). */
|
|
12
|
-
export declare function NotificationPanelSettings({ actions, button, size }: NotificationPanelSettingsProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare function NotificationPanelSettings({ actions, button, size, itemRender, groupItemRender, }: NotificationPanelSettingsProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,7 +7,7 @@ const system_1 = require("@cloud-ru/ds-icons/interface/system");
|
|
|
7
7
|
const constants_1 = require("../../../../constants");
|
|
8
8
|
const NotificationPanelSettingsDroplist_1 = require("./NotificationPanelSettingsDroplist");
|
|
9
9
|
/** Кнопка настроек панели уведомлений (с выпадающим списком действий, если переданы). */
|
|
10
|
-
function NotificationPanelSettings({ actions, button, size = 'm' }) {
|
|
10
|
+
function NotificationPanelSettings({ actions, button, size = 'm', itemRender, groupItemRender, }) {
|
|
11
11
|
const buttonProps = {
|
|
12
12
|
...button,
|
|
13
13
|
view: 'function',
|
|
@@ -20,5 +20,5 @@ function NotificationPanelSettings({ actions, button, size = 'm' }) {
|
|
|
20
20
|
if (!actions?.length) {
|
|
21
21
|
return (0, jsx_runtime_1.jsx)(button_1.Button, { ...buttonProps });
|
|
22
22
|
}
|
|
23
|
-
return (0, jsx_runtime_1.jsx)(NotificationPanelSettingsDroplist_1.NotificationPanelSettingsDroplist, { actions: actions, button: buttonProps });
|
|
23
|
+
return ((0, jsx_runtime_1.jsx)(NotificationPanelSettingsDroplist_1.NotificationPanelSettingsDroplist, { actions: actions, button: buttonProps, itemRender: itemRender, groupItemRender: groupItemRender }));
|
|
24
24
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ButtonProps } from '@cloud-ru/ds-button';
|
|
2
|
+
import { DroplistProps } from '@cloud-ru/ds-list';
|
|
2
3
|
import { ElementType } from 'react';
|
|
3
4
|
import { Action } from '../../../../types';
|
|
4
5
|
type NotificationPanelSettingsDroplistProps = {
|
|
5
6
|
actions: Action[];
|
|
6
7
|
button: ButtonProps<ElementType>;
|
|
7
|
-
}
|
|
8
|
-
export declare function NotificationPanelSettingsDroplist({ actions, button }: NotificationPanelSettingsDroplistProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
} & Pick<DroplistProps, 'itemRender' | 'groupItemRender'>;
|
|
9
|
+
export declare function NotificationPanelSettingsDroplist({ actions, button, itemRender, groupItemRender, }: NotificationPanelSettingsDroplistProps): import("react/jsx-runtime").JSX.Element;
|
|
9
10
|
export {};
|
|
@@ -11,7 +11,7 @@ const tag_1 = require("@cloud-ru/ds-tag");
|
|
|
11
11
|
const react_1 = require("react");
|
|
12
12
|
const constants_1 = require("../../../../constants");
|
|
13
13
|
const styles_module_scss_1 = __importDefault(require('../../styles.module.css'));
|
|
14
|
-
function NotificationPanelSettingsDroplist({ actions, button }) {
|
|
14
|
+
function NotificationPanelSettingsDroplist({ actions, button, itemRender, groupItemRender, }) {
|
|
15
15
|
const [isDroplistOpen, setDroplistOpen] = (0, react_1.useState)(false);
|
|
16
16
|
return ((0, jsx_runtime_1.jsx)(list_1.Droplist, { trigger: 'click', open: isDroplistOpen, onOpenChange: setDroplistOpen, scroll: true, placement: 'bottom-end', size: 'm', "data-test-id": constants_1.TEST_IDS.panel.settings.droplist, triggerClassName: styles_module_scss_1.default.inlineFlex, items: actions.map(({ icon, content, tagLabel, disabled, onClick }, index) => ({
|
|
17
17
|
onClick: e => {
|
|
@@ -23,5 +23,5 @@ function NotificationPanelSettingsDroplist({ actions, button }) {
|
|
|
23
23
|
beforeContent: icon,
|
|
24
24
|
afterContent: tagLabel ? (0, jsx_runtime_1.jsx)(tag_1.Tag, { label: tagLabel }) : undefined,
|
|
25
25
|
'data-test-id': `${constants_1.TEST_IDS.panel.settings.droplistAction}-${index}`,
|
|
26
|
-
})), children: (0, jsx_runtime_1.jsx)(button_1.Button, { ...button }) }));
|
|
26
|
+
})), itemRender: itemRender, groupItemRender: groupItemRender, children: (0, jsx_runtime_1.jsx)(button_1.Button, { ...button }) }));
|
|
27
27
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DroplistProps } from '@cloud-ru/ds-list';
|
|
1
2
|
import { Dispatch, ReactElement, SetStateAction } from 'react';
|
|
2
3
|
import { Action } from '../../types';
|
|
3
4
|
export type ActionsButtonTestIds = {
|
|
@@ -15,5 +16,5 @@ export type ActionsButtonProps = {
|
|
|
15
16
|
triggerAriaLabel: string;
|
|
16
17
|
testIds: ActionsButtonTestIds;
|
|
17
18
|
className?: string;
|
|
18
|
-
}
|
|
19
|
-
export declare function ActionsButton({ actions, open, setDroplistOpen, icon, triggerAriaLabel, testIds, className, }: ActionsButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
} & Pick<DroplistProps, 'itemRender' | 'groupItemRender'>;
|
|
20
|
+
export declare function ActionsButton({ actions, open, setDroplistOpen, icon, triggerAriaLabel, testIds, className, itemRender, groupItemRender, }: ActionsButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -11,7 +11,7 @@ const tag_1 = require("@cloud-ru/ds-tag");
|
|
|
11
11
|
const classnames_1 = __importDefault(require("classnames"));
|
|
12
12
|
const utils_1 = require("../../utils");
|
|
13
13
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
14
|
-
function ActionsButton({ actions, open, setDroplistOpen, icon, triggerAriaLabel, testIds, className, }) {
|
|
14
|
+
function ActionsButton({ actions, open, setDroplistOpen, icon, triggerAriaLabel, testIds, className, itemRender, groupItemRender, }) {
|
|
15
15
|
return (
|
|
16
16
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
17
17
|
(0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(styles_module_scss_1.default.inlineFlex, className), "data-test-id": testIds.wrapper, onClick: utils_1.stopPropagationClick, children: (0, jsx_runtime_1.jsx)(list_1.Droplist, { size: 'm', trigger: 'clickAndFocusVisible', open: open, onOpenChange: setDroplistOpen, placement: 'bottom-end', scroll: true, "data-test-id": testIds.droplist, items: actions.map(({ onClick, disabled, content, tagLabel, icon: itemIcon }, index) => ({
|
|
@@ -24,5 +24,5 @@ function ActionsButton({ actions, open, setDroplistOpen, icon, triggerAriaLabel,
|
|
|
24
24
|
beforeContent: itemIcon,
|
|
25
25
|
afterContent: tagLabel ? (0, jsx_runtime_1.jsx)(tag_1.Tag, { label: tagLabel }) : undefined,
|
|
26
26
|
'data-test-id': `${testIds.droplistAction}-${index}`,
|
|
27
|
-
})), triggerClassName: styles_module_scss_1.default.inlineFlex, children: (0, jsx_runtime_1.jsx)(button_1.Button, { view: 'function', appearance: 'neutral', size: 'm', icon: icon, "aria-label": triggerAriaLabel, "data-test-id": testIds.droplistTrigger }) }) }));
|
|
27
|
+
})), triggerClassName: styles_module_scss_1.default.inlineFlex, itemRender: itemRender, groupItemRender: groupItemRender, children: (0, jsx_runtime_1.jsx)(button_1.Button, { view: 'function', appearance: 'neutral', size: 'm', icon: icon, "aria-label": triggerAriaLabel, "data-test-id": testIds.droplistTrigger }) }) }));
|
|
28
28
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ButtonProps } from '@cloud-ru/ds-button';
|
|
2
2
|
import { PickLinkProps } from '@cloud-ru/ds-link';
|
|
3
|
+
import { DroplistProps } from '@cloud-ru/ds-list';
|
|
3
4
|
import { WithSupportProps } from '@cloud-ru/ds-utils';
|
|
4
5
|
import { MouseEventHandler, ReactNode } from 'react';
|
|
5
6
|
import { Action, Appearance } from '../../types.js';
|
|
@@ -37,7 +38,7 @@ export type NotificationCardProps = WithSupportProps<{
|
|
|
37
38
|
actions?: Action[];
|
|
38
39
|
/** CSS-класс */
|
|
39
40
|
className?: string;
|
|
40
|
-
}
|
|
41
|
+
} & Pick<DroplistProps, 'itemRender' | 'groupItemRender'>>;
|
|
41
42
|
/** Карточка уведомления */
|
|
42
|
-
export declare function NotificationCard({ id, appearance, label, unread, title, description, link, date, onClick, primaryButton, secondaryButton, actions, onVisible, className, ...rest }: NotificationCardProps): import("react/jsx-runtime").JSX.Element;
|
|
43
|
+
export declare function NotificationCard({ id, appearance, label, unread, title, description, link, date, onClick, primaryButton, secondaryButton, actions, onVisible, className, itemRender, groupItemRender, ...rest }: NotificationCardProps): import("react/jsx-runtime").JSX.Element;
|
|
43
44
|
export {};
|
|
@@ -15,7 +15,7 @@ import { getAppearanceLabel, getIcon } from './helpers.js';
|
|
|
15
15
|
import styles from './styles.module.css';
|
|
16
16
|
const VISIBILITY_THRESHOLD = 0.8;
|
|
17
17
|
/** Карточка уведомления */
|
|
18
|
-
export function NotificationCard({ id, appearance = APPEARANCE.Default, label, unread, title, description, link, date, onClick, primaryButton, secondaryButton, actions, onVisible, className, ...rest }) {
|
|
18
|
+
export function NotificationCard({ id, appearance = APPEARANCE.Default, label, unread, title, description, link, date, onClick, primaryButton, secondaryButton, actions, onVisible, className, itemRender, groupItemRender, ...rest }) {
|
|
19
19
|
const icon = useMemo(() => getIcon(appearance), [appearance]);
|
|
20
20
|
const [isDroplistOpen, setDroplistOpen] = useState(false);
|
|
21
21
|
const cardRef = useRef(null);
|
|
@@ -68,7 +68,7 @@ export function NotificationCard({ id, appearance = APPEARANCE.Default, label, u
|
|
|
68
68
|
cardRef.current?.click();
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
|
-
return (_jsxs("div", { role: 'button', tabIndex: 0, ref: cardRef, onKeyDown: handleKeyDown, onClick: onClick, ...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: [_jsx("span", { className: styles.stateLayer, "data-state": 'emptyNeutralOnBackground', "aria-hidden": true }), unread && _jsx("span", { className: styles.visuallyHidden, children: "\u041D\u0435\u043F\u0440\u043E\u0447\u0438\u0442\u0430\u043D\u043D\u043E\u0435 \u0443\u0432\u0435\u0434\u043E\u043C\u043B\u0435\u043D\u0438\u0435" }), actions?.length ? (_jsx(ActionsButton, { className: styles.notificationCardFunction, actions: actions, open: isDroplistOpen, setDroplistOpen: setDroplistOpen, icon: _jsx(KebabSVG, {}), triggerAriaLabel: '\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u044F \u0441 \u0443\u0432\u0435\u0434\u043E\u043C\u043B\u0435\u043D\u0438\u0435\u043C', testIds: TEST_IDS.card.actions })) : null, label && (_jsx(Typography, { variant: 'body', size: 's', as: 'div', className: styles.notificationCardLabel, children: _jsx(TruncateString, { maxLines: 1, text: label, "data-test-id": TEST_IDS.card.label }) })), _jsxs("div", { className: styles.notificationCardTitle, children: [_jsx("div", { className: styles.notificationCardTitleIcon, role: 'img', "aria-label": getAppearanceLabel(appearance), children: icon }), _jsx(Typography, { variant: 'label', size: 'l', as: 'div', className: styles.notificationCardTitleText, children: _jsx(TruncateString, { maxLines: 2, text: title, "data-test-id": TEST_IDS.card.title }) })] }), description != null && description !== '' && (_jsx(Typography, { variant: 'body', size: 's', as: 'div', className: styles.notificationCardContent, "data-test-id": TEST_IDS.card.description, children: description })), (primaryButton || secondaryButton) && (
|
|
71
|
+
return (_jsxs("div", { role: 'button', tabIndex: 0, ref: cardRef, onKeyDown: handleKeyDown, onClick: onClick, ...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: [_jsx("span", { className: styles.stateLayer, "data-state": 'emptyNeutralOnBackground', "aria-hidden": true }), unread && _jsx("span", { className: styles.visuallyHidden, children: "\u041D\u0435\u043F\u0440\u043E\u0447\u0438\u0442\u0430\u043D\u043D\u043E\u0435 \u0443\u0432\u0435\u0434\u043E\u043C\u043B\u0435\u043D\u0438\u0435" }), actions?.length ? (_jsx(ActionsButton, { className: styles.notificationCardFunction, actions: actions, open: isDroplistOpen, setDroplistOpen: setDroplistOpen, icon: _jsx(KebabSVG, {}), triggerAriaLabel: '\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u044F \u0441 \u0443\u0432\u0435\u0434\u043E\u043C\u043B\u0435\u043D\u0438\u0435\u043C', testIds: TEST_IDS.card.actions, itemRender: itemRender, groupItemRender: groupItemRender })) : null, label && (_jsx(Typography, { variant: 'body', size: 's', as: 'div', className: styles.notificationCardLabel, children: _jsx(TruncateString, { maxLines: 1, text: label, "data-test-id": TEST_IDS.card.label }) })), _jsxs("div", { className: styles.notificationCardTitle, children: [_jsx("div", { className: styles.notificationCardTitleIcon, role: 'img', "aria-label": getAppearanceLabel(appearance), children: icon }), _jsx(Typography, { variant: 'label', size: 'l', as: 'div', className: styles.notificationCardTitleText, children: _jsx(TruncateString, { maxLines: 2, text: title, "data-test-id": TEST_IDS.card.title }) })] }), description != null && description !== '' && (_jsx(Typography, { variant: 'body', size: 's', as: 'div', className: styles.notificationCardContent, "data-test-id": TEST_IDS.card.description, children: description })), (primaryButton || secondaryButton) && (
|
|
72
72
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
73
73
|
_jsxs("div", { className: styles.notificationCardButtons, onClick: stopPropagationClick, children: [secondaryButton && (_jsx(Button, { ...secondaryButton, view: 'simple', appearance: 'neutral', size: 'm', "data-test-id": TEST_IDS.card.secondaryButton })), primaryButton && (_jsx(Button, { ...primaryButton, view: 'tonal', appearance: 'neutral', size: 'm', "data-test-id": TEST_IDS.card.primaryButton }))] })), showFooter && (_jsxs(Typography, { variant: 'body', size: 's', as: 'div', className: styles.notificationCardFooter, children: [link && _jsx(Link, { ...link, onClick: handleLinkClick, appearance: 'primary', "data-test-id": TEST_IDS.card.link }), date && (_jsx(Typography, { variant: 'body', size: 's', as: 'span', className: styles.notificationCardDate, "data-test-id": TEST_IDS.card.date, children: date }))] })), unread && (_jsx(StatusIndicator, { className: styles.statusIndicator, size: '3xs', appearance: 'green', "data-test-id": TEST_IDS.card.statusIndicator }))] }));
|
|
74
74
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DroplistProps } from '@cloud-ru/ds-list';
|
|
1
2
|
import { WithSupportProps } from '@cloud-ru/ds-utils';
|
|
2
3
|
import { ReactNode } from 'react';
|
|
3
4
|
import { Action } from '../../../../types.js';
|
|
@@ -14,5 +15,5 @@ export type NotificationCardStackProps = WithSupportProps<{
|
|
|
14
15
|
actions?: Action[];
|
|
15
16
|
/** Состояние непрочитанных карточек */
|
|
16
17
|
unread?: boolean;
|
|
17
|
-
}
|
|
18
|
-
export declare function NotificationCardStack({ children, defaultOpen, onOpenChanged, title, actions, unread, ...rest }: NotificationCardStackProps): import("react/jsx-runtime").JSX.Element | null;
|
|
18
|
+
} & Pick<DroplistProps, 'itemRender' | 'groupItemRender'>>;
|
|
19
|
+
export declare function NotificationCardStack({ children, defaultOpen, onOpenChanged, title, actions, unread, itemRender, groupItemRender, ...rest }: NotificationCardStackProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -12,7 +12,7 @@ import { useAnimatedOpening } from './hooks.js';
|
|
|
12
12
|
import styles from './styles.module.css';
|
|
13
13
|
import { cloneCard } from './utils.js';
|
|
14
14
|
const ANIMATION_DURATION = 0.3;
|
|
15
|
-
export function NotificationCardStack({ children, defaultOpen, onOpenChanged, title, actions, unread, ...rest }) {
|
|
15
|
+
export function NotificationCardStack({ children, defaultOpen, onOpenChanged, title, actions, unread, itemRender, groupItemRender, ...rest }) {
|
|
16
16
|
const [actionsOpen, setActionsOpen] = useState(false);
|
|
17
17
|
const { open, toggleOpen, isVisible } = useAnimatedOpening({
|
|
18
18
|
defaultOpen,
|
|
@@ -33,5 +33,5 @@ export function NotificationCardStack({ children, defaultOpen, onOpenChanged, ti
|
|
|
33
33
|
onClick: toggleOpen,
|
|
34
34
|
unread: unread || componentProps.unread,
|
|
35
35
|
}));
|
|
36
|
-
return (_jsxs("div", { className: styles.container, style: { '--snack-notification-stack-animation-duration': `${ANIMATION_DURATION}s` }, "data-test-id": TEST_IDS.panel.cardStack.wrapper, ...extractSupportProps(rest), children: [_jsxs("div", { className: styles.header, "data-test-id": TEST_IDS.panel.cardStack.headline, children: [_jsx(Typography, { variant: 'label', size: 'l', as: 'div', className: styles.title, onClick: toggleOpen, "aria-expanded": open, children: _jsx(TruncateString, { "data-test-id": TEST_IDS.panel.cardStack.title, text: title }) }), _jsxs("div", { className: styles.right, children: [actions && actions.length > 0 && (_jsx(ActionsButton, { actions: actions, open: actionsOpen, setDroplistOpen: setActionsOpen, icon: _jsx(KebabSVG, {}), triggerAriaLabel: '\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u044F \u0441\u043E \u0441\u0442\u043E\u043F\u043A\u043E\u0439', testIds: TEST_IDS.panel.cardStack.actions })), _jsx(Button, { view: 'function', appearance: 'neutral', size: 'm', onClick: toggleOpen, "aria-label": open ? 'Свернуть стопку' : 'Развернуть стопку', "aria-expanded": open, "data-test-id": TEST_IDS.panel.cardStack.openButton, icon: open ? _jsx(ChevronUpSVG, {}) : _jsx(ChevronDownSVG, {}) })] })] }), _jsxs("div", { className: styles.cards, children: [_jsxs("div", { className: styles.first, children: [_jsx(StackTail, { open: open, count: stack.length }), firstCardElement] }), _jsx("div", { className: styles.stack, "data-open": open || undefined, "data-tail-size": stack.length, children: _jsx("div", { className: styles.animationContainer, children: isVisible ? stack : [] }) })] })] }));
|
|
36
|
+
return (_jsxs("div", { className: styles.container, style: { '--snack-notification-stack-animation-duration': `${ANIMATION_DURATION}s` }, "data-test-id": TEST_IDS.panel.cardStack.wrapper, ...extractSupportProps(rest), children: [_jsxs("div", { className: styles.header, "data-test-id": TEST_IDS.panel.cardStack.headline, children: [_jsx(Typography, { variant: 'label', size: 'l', as: 'div', className: styles.title, onClick: toggleOpen, "aria-expanded": open, children: _jsx(TruncateString, { "data-test-id": TEST_IDS.panel.cardStack.title, text: title }) }), _jsxs("div", { className: styles.right, children: [actions && actions.length > 0 && (_jsx(ActionsButton, { actions: actions, open: actionsOpen, setDroplistOpen: setActionsOpen, icon: _jsx(KebabSVG, {}), triggerAriaLabel: '\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u044F \u0441\u043E \u0441\u0442\u043E\u043F\u043A\u043E\u0439', testIds: TEST_IDS.panel.cardStack.actions, itemRender: itemRender, groupItemRender: groupItemRender })), _jsx(Button, { view: 'function', appearance: 'neutral', size: 'm', onClick: toggleOpen, "aria-label": open ? 'Свернуть стопку' : 'Развернуть стопку', "aria-expanded": open, "data-test-id": TEST_IDS.panel.cardStack.openButton, icon: open ? _jsx(ChevronUpSVG, {}) : _jsx(ChevronDownSVG, {}) })] })] }), _jsxs("div", { className: styles.cards, children: [_jsxs("div", { className: styles.first, children: [_jsx(StackTail, { open: open, count: stack.length }), firstCardElement] }), _jsx("div", { className: styles.stack, "data-open": open || undefined, "data-tail-size": stack.length, children: _jsx("div", { className: styles.animationContainer, children: isVisible ? stack : [] }) })] })] }));
|
|
37
37
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ButtonProps } from '@cloud-ru/ds-button';
|
|
2
|
+
import { DroplistProps } from '@cloud-ru/ds-list';
|
|
2
3
|
import { ElementType } from 'react';
|
|
3
4
|
import { Action } from '../../../../types.js';
|
|
4
5
|
export type NotificationPanelSettingsProps = {
|
|
@@ -7,6 +8,6 @@ export type NotificationPanelSettingsProps = {
|
|
|
7
8
|
/** Кнопка дополнительного действия панели */
|
|
8
9
|
button?: Omit<ButtonProps<ElementType>, 'label' | 'size' | 'view' | 'data-test-id'>;
|
|
9
10
|
size?: 's' | 'm';
|
|
10
|
-
}
|
|
11
|
+
} & Pick<DroplistProps, 'itemRender' | 'groupItemRender'>;
|
|
11
12
|
/** Кнопка настроек панели уведомлений (с выпадающим списком действий, если переданы). */
|
|
12
|
-
export declare function NotificationPanelSettings({ actions, button, size }: NotificationPanelSettingsProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare function NotificationPanelSettings({ actions, button, size, itemRender, groupItemRender, }: NotificationPanelSettingsProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,7 +4,7 @@ import { SettingsSVG } from '@cloud-ru/ds-icons/interface/system';
|
|
|
4
4
|
import { TEST_IDS } from '../../../../constants.js';
|
|
5
5
|
import { NotificationPanelSettingsDroplist } from './NotificationPanelSettingsDroplist.js';
|
|
6
6
|
/** Кнопка настроек панели уведомлений (с выпадающим списком действий, если переданы). */
|
|
7
|
-
export function NotificationPanelSettings({ actions, button, size = 'm' }) {
|
|
7
|
+
export function NotificationPanelSettings({ actions, button, size = 'm', itemRender, groupItemRender, }) {
|
|
8
8
|
const buttonProps = {
|
|
9
9
|
...button,
|
|
10
10
|
view: 'function',
|
|
@@ -17,5 +17,5 @@ export function NotificationPanelSettings({ actions, button, size = 'm' }) {
|
|
|
17
17
|
if (!actions?.length) {
|
|
18
18
|
return _jsx(Button, { ...buttonProps });
|
|
19
19
|
}
|
|
20
|
-
return _jsx(NotificationPanelSettingsDroplist, { actions: actions, button: buttonProps });
|
|
20
|
+
return (_jsx(NotificationPanelSettingsDroplist, { actions: actions, button: buttonProps, itemRender: itemRender, groupItemRender: groupItemRender }));
|
|
21
21
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ButtonProps } from '@cloud-ru/ds-button';
|
|
2
|
+
import { DroplistProps } from '@cloud-ru/ds-list';
|
|
2
3
|
import { ElementType } from 'react';
|
|
3
4
|
import { Action } from '../../../../types.js';
|
|
4
5
|
type NotificationPanelSettingsDroplistProps = {
|
|
5
6
|
actions: Action[];
|
|
6
7
|
button: ButtonProps<ElementType>;
|
|
7
|
-
}
|
|
8
|
-
export declare function NotificationPanelSettingsDroplist({ actions, button }: NotificationPanelSettingsDroplistProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
} & Pick<DroplistProps, 'itemRender' | 'groupItemRender'>;
|
|
9
|
+
export declare function NotificationPanelSettingsDroplist({ actions, button, itemRender, groupItemRender, }: NotificationPanelSettingsDroplistProps): import("react/jsx-runtime").JSX.Element;
|
|
9
10
|
export {};
|
|
@@ -5,7 +5,7 @@ import { Tag } from '@cloud-ru/ds-tag';
|
|
|
5
5
|
import { useState } from 'react';
|
|
6
6
|
import { TEST_IDS } from '../../../../constants.js';
|
|
7
7
|
import styles from '../../styles.module.css';
|
|
8
|
-
export function NotificationPanelSettingsDroplist({ actions, button }) {
|
|
8
|
+
export function NotificationPanelSettingsDroplist({ actions, button, itemRender, groupItemRender, }) {
|
|
9
9
|
const [isDroplistOpen, setDroplistOpen] = useState(false);
|
|
10
10
|
return (_jsx(Droplist, { trigger: 'click', open: isDroplistOpen, onOpenChange: setDroplistOpen, scroll: true, placement: 'bottom-end', size: 'm', "data-test-id": TEST_IDS.panel.settings.droplist, triggerClassName: styles.inlineFlex, items: actions.map(({ icon, content, tagLabel, disabled, onClick }, index) => ({
|
|
11
11
|
onClick: e => {
|
|
@@ -17,5 +17,5 @@ export function NotificationPanelSettingsDroplist({ actions, button }) {
|
|
|
17
17
|
beforeContent: icon,
|
|
18
18
|
afterContent: tagLabel ? _jsx(Tag, { label: tagLabel }) : undefined,
|
|
19
19
|
'data-test-id': `${TEST_IDS.panel.settings.droplistAction}-${index}`,
|
|
20
|
-
})), children: _jsx(Button, { ...button }) }));
|
|
20
|
+
})), itemRender: itemRender, groupItemRender: groupItemRender, children: _jsx(Button, { ...button }) }));
|
|
21
21
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DroplistProps } from '@cloud-ru/ds-list';
|
|
1
2
|
import { Dispatch, ReactElement, SetStateAction } from 'react';
|
|
2
3
|
import { Action } from '../../types.js';
|
|
3
4
|
export type ActionsButtonTestIds = {
|
|
@@ -15,5 +16,5 @@ export type ActionsButtonProps = {
|
|
|
15
16
|
triggerAriaLabel: string;
|
|
16
17
|
testIds: ActionsButtonTestIds;
|
|
17
18
|
className?: string;
|
|
18
|
-
}
|
|
19
|
-
export declare function ActionsButton({ actions, open, setDroplistOpen, icon, triggerAriaLabel, testIds, className, }: ActionsButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
} & Pick<DroplistProps, 'itemRender' | 'groupItemRender'>;
|
|
20
|
+
export declare function ActionsButton({ actions, open, setDroplistOpen, icon, triggerAriaLabel, testIds, className, itemRender, groupItemRender, }: ActionsButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,7 +5,7 @@ import { Tag } from '@cloud-ru/ds-tag';
|
|
|
5
5
|
import cn from 'classnames';
|
|
6
6
|
import { stopPropagationClick } from '../../utils.js';
|
|
7
7
|
import styles from './styles.module.css';
|
|
8
|
-
export function ActionsButton({ actions, open, setDroplistOpen, icon, triggerAriaLabel, testIds, className, }) {
|
|
8
|
+
export function ActionsButton({ actions, open, setDroplistOpen, icon, triggerAriaLabel, testIds, className, itemRender, groupItemRender, }) {
|
|
9
9
|
return (
|
|
10
10
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
11
11
|
_jsx("div", { className: cn(styles.inlineFlex, className), "data-test-id": testIds.wrapper, onClick: stopPropagationClick, children: _jsx(Droplist, { size: 'm', trigger: 'clickAndFocusVisible', open: open, onOpenChange: setDroplistOpen, placement: 'bottom-end', scroll: true, "data-test-id": testIds.droplist, items: actions.map(({ onClick, disabled, content, tagLabel, icon: itemIcon }, index) => ({
|
|
@@ -18,5 +18,5 @@ export function ActionsButton({ actions, open, setDroplistOpen, icon, triggerAri
|
|
|
18
18
|
beforeContent: itemIcon,
|
|
19
19
|
afterContent: tagLabel ? _jsx(Tag, { label: tagLabel }) : undefined,
|
|
20
20
|
'data-test-id': `${testIds.droplistAction}-${index}`,
|
|
21
|
-
})), triggerClassName: styles.inlineFlex, children: _jsx(Button, { view: 'function', appearance: 'neutral', size: 'm', icon: icon, "aria-label": triggerAriaLabel, "data-test-id": testIds.droplistTrigger }) }) }));
|
|
21
|
+
})), triggerClassName: styles.inlineFlex, itemRender: itemRender, groupItemRender: groupItemRender, children: _jsx(Button, { view: 'function', appearance: 'neutral', size: 'm', icon: icon, "aria-label": triggerAriaLabel, "data-test-id": testIds.droplistTrigger }) }) }));
|
|
22
22
|
}
|