@alfalab/core-components-notification-manager 7.0.4-alfasans → 7.0.5
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/component.d.ts +3 -35
- package/component.js +3 -13
- package/component.js.map +1 -1
- package/components/notification/component.d.ts +5 -4
- package/components/notification/component.js +16 -4
- package/components/notification/component.js.map +1 -1
- package/components/notification/index.css +18 -0
- package/components/notification/index.module.css.js +8 -0
- package/components/notification/index.module.css.js.map +1 -0
- package/cssm/component.d.ts +3 -35
- package/cssm/component.js +3 -13
- package/cssm/component.js.map +1 -1
- package/cssm/components/notification/component.d.ts +5 -4
- package/cssm/components/notification/component.js +17 -4
- package/cssm/components/notification/component.js.map +1 -1
- package/cssm/components/notification/index.module.css +18 -0
- package/cssm/index.module.css +0 -17
- package/esm/component.d.ts +3 -35
- package/esm/component.js +5 -15
- package/esm/component.js.map +1 -1
- package/esm/components/notification/component.d.ts +5 -4
- package/esm/components/notification/component.js +16 -5
- package/esm/components/notification/component.js.map +1 -1
- package/esm/components/notification/index.css +18 -0
- package/esm/components/notification/index.module.css.js +6 -0
- package/esm/components/notification/index.module.css.js.map +1 -0
- package/esm/index.css +6 -23
- package/esm/index.module.css.js +1 -1
- package/esm/index.module.css.js.map +1 -1
- package/index.css +6 -23
- package/index.module.css.js +1 -1
- package/index.module.css.js.map +1 -1
- package/modern/component.d.ts +3 -35
- package/modern/component.js +11 -23
- package/modern/component.js.map +1 -1
- package/modern/components/notification/component.d.ts +5 -4
- package/modern/components/notification/component.js +16 -5
- package/modern/components/notification/component.js.map +1 -1
- package/modern/components/notification/index.css +18 -0
- package/modern/components/notification/index.module.css.js +6 -0
- package/modern/components/notification/index.module.css.js.map +1 -0
- package/modern/index.css +6 -23
- package/modern/index.module.css.js +1 -1
- package/modern/index.module.css.js.map +1 -1
- package/moderncssm/component.d.ts +3 -35
- package/moderncssm/component.js +11 -23
- package/moderncssm/component.js.map +1 -1
- package/moderncssm/components/notification/component.d.ts +5 -4
- package/moderncssm/components/notification/component.js +16 -5
- package/moderncssm/components/notification/component.js.map +1 -1
- package/moderncssm/components/notification/index.module.css +22 -0
- package/moderncssm/index.module.css +0 -19
- package/package.json +6 -6
- package/src/component.tsx +36 -58
- package/src/components/notification/{component.ts → component.tsx} +45 -9
- package/src/components/notification/index.module.css +22 -0
- package/src/index.module.css +0 -19
package/component.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { type HTMLAttributes } from 'react';
|
|
2
2
|
import { type PortalProps } from '@alfalab/core-components-portal';
|
|
3
3
|
import { type NotificationElement } from './components';
|
|
4
|
-
export
|
|
4
|
+
export interface NotificationManagerProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
5
|
/**
|
|
6
6
|
* Массив нотификаций.
|
|
7
7
|
* В нотификации обязательно передавайте id.
|
|
@@ -33,37 +33,5 @@ export type NotificationManagerProps = HTMLAttributes<HTMLDivElement> & {
|
|
|
33
33
|
* Контейнер к которому будут добавляться порталы
|
|
34
34
|
*/
|
|
35
35
|
container?: PortalProps['getPortalContainer'];
|
|
36
|
-
}
|
|
37
|
-
export declare const NotificationManager: React.ForwardRefExoticComponent<React.
|
|
38
|
-
/**
|
|
39
|
-
* Массив нотификаций.
|
|
40
|
-
* В нотификации обязательно передавайте id.
|
|
41
|
-
*/
|
|
42
|
-
notifications: NotificationElement[];
|
|
43
|
-
/**
|
|
44
|
-
* Дополнительный класс (native prop)
|
|
45
|
-
*/
|
|
46
|
-
className?: string;
|
|
47
|
-
/**
|
|
48
|
-
* Идентификатор для систем автоматизированного тестирования
|
|
49
|
-
*/
|
|
50
|
-
dataTestId?: string;
|
|
51
|
-
/**
|
|
52
|
-
* z-index компонента
|
|
53
|
-
*/
|
|
54
|
-
zIndex?: number;
|
|
55
|
-
/**
|
|
56
|
-
* Отступ от верхнего края
|
|
57
|
-
*/
|
|
58
|
-
offset?: number;
|
|
59
|
-
/**
|
|
60
|
-
* Удаление нотификации
|
|
61
|
-
*/
|
|
62
|
-
onRemoveNotification: (id: string) => void;
|
|
63
|
-
/**
|
|
64
|
-
* Нода, компонент или функция возвращающая их
|
|
65
|
-
*
|
|
66
|
-
* Контейнер к которому будут добавляться порталы
|
|
67
|
-
*/
|
|
68
|
-
container?: PortalProps["getPortalContainer"];
|
|
69
|
-
} & React.RefAttributes<HTMLDivElement>>;
|
|
36
|
+
}
|
|
37
|
+
export declare const NotificationManager: React.ForwardRefExoticComponent<NotificationManagerProps & React.RefAttributes<HTMLDivElement>>;
|
package/component.js
CHANGED
|
@@ -17,25 +17,15 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
17
17
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
18
18
|
var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
|
|
19
19
|
|
|
20
|
-
var CSS_TRANSITION_CLASS_NAMES = {
|
|
21
|
-
enter: index_module.enter,
|
|
22
|
-
enterActive: index_module.enterActive,
|
|
23
|
-
};
|
|
24
|
-
var TIMEOUT = {
|
|
25
|
-
exit: 0,
|
|
26
|
-
enter: 400,
|
|
27
|
-
};
|
|
28
20
|
var NotificationManager = React.forwardRef(function (_a, ref) {
|
|
29
21
|
var notifications = _a.notifications, className = _a.className, dataTestId = _a.dataTestId, _b = _a.zIndex, zIndex = _b === void 0 ? coreComponentsStackContext.stackingOrder.TOAST : _b, _c = _a.style, style = _c === void 0 ? {} : _c, offset = _a.offset, onRemoveNotification = _a.onRemoveNotification, container = _a.container, restProps = tslib.__rest(_a, ["notifications", "className", "dataTestId", "zIndex", "style", "offset", "onRemoveNotification", "container"]);
|
|
30
|
-
var nodeRef = React.useRef(null);
|
|
31
22
|
return (React__default.default.createElement(coreComponentsStack.Stack, { value: zIndex }, function (computedZIndex) { return (React__default.default.createElement(coreComponentsPortal.Portal, { getPortalContainer: container },
|
|
32
23
|
React__default.default.createElement("div", tslib.__assign({ className: cn__default.default(index_module.component, className), ref: ref, "data-test-id": dataTestId, style: tslib.__assign({ zIndex: computedZIndex, top: offset }, style) }, restProps),
|
|
33
24
|
React__default.default.createElement(reactTransitionGroup.TransitionGroup, null, notifications.map(function (element, index) {
|
|
34
25
|
var _a;
|
|
35
|
-
return (React__default.default.createElement(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
_a)), onRemoveNotification: onRemoveNotification })));
|
|
26
|
+
return (React__default.default.createElement(component.Notification, { key: element.props.id, element: element, onRemoveNotification: onRemoveNotification, className: cn__default.default(index_module.notification, (_a = {},
|
|
27
|
+
_a[index_module.withoutMargin] = offset && index === 0,
|
|
28
|
+
_a)) }));
|
|
39
29
|
}))))); }));
|
|
40
30
|
});
|
|
41
31
|
NotificationManager.displayName = 'NotificationManager';
|
package/component.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["src/component.tsx"],"sourcesContent":["import React, { forwardRef, type HTMLAttributes
|
|
1
|
+
{"version":3,"file":"component.js","sources":["src/component.tsx"],"sourcesContent":["import React, { forwardRef, type HTMLAttributes } from 'react';\nimport { TransitionGroup } from 'react-transition-group';\nimport cn from 'classnames';\n\nimport { Portal, type PortalProps } from '@alfalab/core-components-portal';\nimport { Stack } from '@alfalab/core-components-stack';\nimport { stackingOrder } from '@alfalab/core-components-stack-context';\n\nimport { Notification, type NotificationElement } from './components';\n\nimport styles from './index.module.css';\n\nexport interface NotificationManagerProps extends HTMLAttributes<HTMLDivElement> {\n /**\n * Массив нотификаций.\n * В нотификации обязательно передавайте id.\n */\n notifications: NotificationElement[];\n\n /**\n * Дополнительный класс (native prop)\n */\n className?: string;\n\n /**\n * Идентификатор для систем автоматизированного тестирования\n */\n dataTestId?: string;\n\n /**\n * z-index компонента\n */\n zIndex?: number;\n\n /**\n * Отступ от верхнего края\n */\n offset?: number;\n\n /**\n * Удаление нотификации\n */\n onRemoveNotification: (id: string) => void;\n\n /**\n * Нода, компонент или функция возвращающая их\n *\n * Контейнер к которому будут добавляться порталы\n */\n container?: PortalProps['getPortalContainer'];\n}\n\nexport const NotificationManager = forwardRef<HTMLDivElement, NotificationManagerProps>(\n (\n {\n notifications,\n className,\n dataTestId,\n zIndex = stackingOrder.TOAST,\n style = {},\n offset,\n onRemoveNotification,\n container,\n ...restProps\n },\n ref,\n ) => (\n <Stack value={zIndex}>\n {(computedZIndex) => (\n <Portal getPortalContainer={container}>\n <div\n className={cn(styles.component, className)}\n ref={ref}\n data-test-id={dataTestId}\n style={{\n zIndex: computedZIndex,\n top: offset,\n ...style,\n }}\n {...restProps}\n >\n <TransitionGroup>\n {notifications.map((element, index) => (\n <Notification\n key={element.props.id}\n element={element}\n onRemoveNotification={onRemoveNotification}\n className={cn(styles.notification, {\n [styles.withoutMargin]: offset && index === 0,\n })}\n />\n ))}\n </TransitionGroup>\n </div>\n </Portal>\n )}\n </Stack>\n ),\n);\n\nNotificationManager.displayName = 'NotificationManager';\n"],"names":["forwardRef","stackingOrder","__rest","React","Stack","Portal","__assign","cn","styles","TransitionGroup","Notification"],"mappings":";;;;;;;;;;;;;;;;;;;IAoDa,mBAAmB,GAAGA,gBAAU,CACzC,UACI,EAUC,EACD,GAAG,EAAA;AAVC,IAAA,IAAA,aAAa,GAAA,EAAA,CAAA,aAAA,EACb,SAAS,GAAA,EAAA,CAAA,SAAA,EACT,UAAU,GAAA,EAAA,CAAA,UAAA,EACV,EAAA,GAAA,EAAA,CAAA,MAA4B,EAA5B,MAAM,GAAA,EAAA,KAAA,MAAA,GAAGC,wCAAa,CAAC,KAAK,GAAA,EAAA,EAC5B,EAAU,GAAA,EAAA,CAAA,KAAA,EAAV,KAAK,GAAG,EAAA,KAAA,MAAA,GAAA,EAAE,GAAA,EAAA,EACV,MAAM,GAAA,EAAA,CAAA,MAAA,EACN,oBAAoB,GAAA,EAAA,CAAA,oBAAA,EACpB,SAAS,GAAA,EAAA,CAAA,SAAA,EACN,SAAS,GAAAC,YAAA,CAAA,EAAA,EAThB,8GAUC,CADe;AAGf,IAAA,QACDC,sBAAC,CAAA,aAAA,CAAAC,yBAAK,IAAC,KAAK,EAAE,MAAM,EACf,EAAA,UAAC,cAAc,EAAA,EAAK,QACjBD,sBAAA,CAAA,aAAA,CAACE,2BAAM,EAAC,EAAA,kBAAkB,EAAE,SAAS,EAAA;AACjC,QAAAF,sBAAA,CAAA,aAAA,CAAA,KAAA,EAAAG,cAAA,CAAA,EACI,SAAS,EAAEC,mBAAE,CAACC,YAAM,CAAC,SAAS,EAAE,SAAS,CAAC,EAC1C,GAAG,EAAE,GAAG,EACM,cAAA,EAAA,UAAU,EACxB,KAAK,EACDF,cAAA,CAAA,EAAA,MAAM,EAAE,cAAc,EACtB,GAAG,EAAE,MAAM,EACR,EAAA,KAAK,KAER,SAAS,CAAA;YAEbH,sBAAC,CAAA,aAAA,CAAAM,oCAAe,QACX,aAAa,CAAC,GAAG,CAAC,UAAC,OAAO,EAAE,KAAK,EAAA;;gBAAK,QACnCN,sBAAC,CAAA,aAAA,CAAAO,sBAAY,EACT,EAAA,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,EACrB,OAAO,EAAE,OAAO,EAChB,oBAAoB,EAAE,oBAAoB,EAC1C,SAAS,EAAEH,mBAAE,CAACC,YAAM,CAAC,YAAY,GAAA,EAAA,GAAA,EAAA;wBAC7B,EAAC,CAAAA,YAAM,CAAC,aAAa,CAAA,GAAG,MAAM,IAAI,KAAK,KAAK,CAAC;AAC/C,wBAAA,EAAA,EAAA,EAAA,CACJ;aACL,CAAC,CACY,CAChB,CACD,EA1BQ,EA2BpB,CACG;AACX,CAAA;AAGL,mBAAmB,CAAC,WAAW,GAAG,qBAAqB;;;;"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { type FC, type ReactElement
|
|
1
|
+
import { type FC, type ReactElement } from 'react';
|
|
2
|
+
import { type CSSTransitionProps } from 'react-transition-group/CSSTransition';
|
|
2
3
|
import { type NotificationProps as CoreNotificationProps } from '@alfalab/core-components-notification';
|
|
3
4
|
export type NotificationElement = ReactElement<CoreNotificationProps & {
|
|
4
5
|
id: string;
|
|
5
6
|
}>;
|
|
6
|
-
type
|
|
7
|
+
type NotificationTransitionProps = Partial<Pick<CSSTransitionProps<HTMLDivElement>, 'in' | 'onExited' | 'appear' | 'enter' | 'exit'>>;
|
|
8
|
+
interface NotificationProps extends NotificationTransitionProps {
|
|
7
9
|
element: NotificationElement;
|
|
8
10
|
className: string;
|
|
9
11
|
onRemoveNotification: (id: string) => void;
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
+
}
|
|
12
13
|
export declare const Notification: FC<NotificationProps>;
|
|
13
14
|
export {};
|
|
@@ -4,14 +4,26 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
6
|
var React = require('react');
|
|
7
|
+
var reactTransitionGroup = require('react-transition-group');
|
|
7
8
|
var cn = require('classnames');
|
|
9
|
+
var index_module = require('./index.module.css.js');
|
|
8
10
|
|
|
9
11
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
10
12
|
|
|
13
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
11
14
|
var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
|
|
12
15
|
|
|
16
|
+
var TIMEOUT = {
|
|
17
|
+
exit: 0,
|
|
18
|
+
enter: 400,
|
|
19
|
+
};
|
|
20
|
+
var CSS_TRANSITION_CLASS_NAMES = {
|
|
21
|
+
enter: index_module.enter,
|
|
22
|
+
enterActive: index_module.enterActive,
|
|
23
|
+
};
|
|
13
24
|
var Notification = function (_a) {
|
|
14
|
-
var
|
|
25
|
+
var inProp = _a.in, onExited = _a.onExited, appear = _a.appear, enter = _a.enter, exit = _a.exit, element = _a.element, className = _a.className, onRemoveNotification = _a.onRemoveNotification;
|
|
26
|
+
var nodeRef = React.useRef(null);
|
|
15
27
|
var _b = element.props, onClose = _b.onClose, onCloseTimeout = _b.onCloseTimeout;
|
|
16
28
|
var handleClose = React.useCallback(function () {
|
|
17
29
|
if (onClose) {
|
|
@@ -25,10 +37,10 @@ var Notification = function (_a) {
|
|
|
25
37
|
}
|
|
26
38
|
onRemoveNotification(element.props.id);
|
|
27
39
|
}, [element.props.id, onCloseTimeout, onRemoveNotification]);
|
|
28
|
-
var notificationProps = React.useMemo(function () { return (tslib.__assign(tslib.__assign({}, element.props), { visible: true, className: cn__default.default(className, element.props.className), usePortal: false, offset: 0, onClose: handleClose, onCloseTimeout: handleCloseTimeout, containerRef:
|
|
40
|
+
var notificationProps = React.useMemo(function () { return (tslib.__assign(tslib.__assign({}, element.props), { visible: true, className: cn__default.default(className, element.props.className), usePortal: false, offset: 0, onClose: handleClose, onCloseTimeout: handleCloseTimeout, containerRef: nodeRef })); },
|
|
29
41
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
30
|
-
[element, handleClose, handleCloseTimeout,
|
|
31
|
-
return React.cloneElement(element, notificationProps);
|
|
42
|
+
[element, handleClose, handleCloseTimeout, className]);
|
|
43
|
+
return (React__default.default.createElement(reactTransitionGroup.CSSTransition, { in: inProp, onExited: onExited, appear: appear, enter: enter, exit: exit, timeout: TIMEOUT, classNames: CSS_TRANSITION_CLASS_NAMES, unmountOnExit: true, nodeRef: nodeRef }, React.cloneElement(element, notificationProps)));
|
|
32
44
|
};
|
|
33
45
|
|
|
34
46
|
exports.Notification = Notification;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../src/components/notification/component.
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../src/components/notification/component.tsx"],"sourcesContent":["import React, {\n cloneElement,\n type FC,\n type ReactElement,\n useCallback,\n useMemo,\n useRef,\n} from 'react';\nimport { CSSTransition } from 'react-transition-group';\nimport { type CSSTransitionProps } from 'react-transition-group/CSSTransition';\nimport cn from 'classnames';\n\nimport { type NotificationProps as CoreNotificationProps } from '@alfalab/core-components-notification';\n\nimport styles from './index.module.css';\n\nexport type NotificationElement = ReactElement<CoreNotificationProps & { id: string }>;\n\nconst TIMEOUT = {\n exit: 0,\n enter: 400,\n};\n\nconst CSS_TRANSITION_CLASS_NAMES = {\n enter: styles.enter,\n enterActive: styles.enterActive,\n};\n\ntype NotificationTransitionProps = Partial<\n Pick<CSSTransitionProps<HTMLDivElement>, 'in' | 'onExited' | 'appear' | 'enter' | 'exit'>\n>;\n\ninterface NotificationProps extends NotificationTransitionProps {\n element: NotificationElement;\n className: string;\n onRemoveNotification: (id: string) => void;\n}\n\nexport const Notification: FC<NotificationProps> = ({\n in: inProp,\n onExited,\n appear,\n enter,\n exit,\n element,\n className,\n onRemoveNotification,\n}) => {\n const nodeRef = useRef<HTMLDivElement>(null);\n const { onClose, onCloseTimeout } = element.props;\n\n const handleClose = useCallback(() => {\n if (onClose) {\n onClose();\n }\n\n onRemoveNotification(element.props.id);\n }, [onClose, onRemoveNotification, element.props.id]);\n\n const handleCloseTimeout = useCallback(() => {\n if (onCloseTimeout) {\n onCloseTimeout();\n }\n\n onRemoveNotification(element.props.id);\n }, [element.props.id, onCloseTimeout, onRemoveNotification]);\n\n const notificationProps = useMemo<CoreNotificationProps>(\n () => ({\n ...element.props,\n visible: true,\n className: cn(className, element.props.className),\n usePortal: false,\n offset: 0,\n onClose: handleClose,\n onCloseTimeout: handleCloseTimeout,\n containerRef: nodeRef,\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [element, handleClose, handleCloseTimeout, className],\n );\n\n return (\n <CSSTransition<HTMLDivElement>\n in={inProp}\n onExited={onExited}\n appear={appear}\n enter={enter}\n exit={exit}\n timeout={TIMEOUT}\n classNames={CSS_TRANSITION_CLASS_NAMES}\n unmountOnExit={true}\n nodeRef={nodeRef}\n >\n {cloneElement(element, notificationProps)}\n </CSSTransition>\n );\n};\n"],"names":["styles","useRef","useCallback","useMemo","__assign","cn","React","CSSTransition","cloneElement"],"mappings":";;;;;;;;;;;;;;;AAkBA,IAAM,OAAO,GAAG;AACZ,IAAA,IAAI,EAAE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CAAA,EAAA,EACC,OAAO,CAAC,KAAK,CAAA,EAAA,EAChB,OAAO,EAAE,IAAI,EACb,SAAS,EAAEC,mBAAE,CAAC,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,EACjD,SAAS,EAAE,KAAK,EAChB,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,WAAW,EACpB,cAAc,EAAE,kBAAkB,EAClC,YAAY,EAAE,OAAO,EACvB,CAAA,EAAA,EAAA;;IAEF,CAAC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,SAAS,CAAC,CACxD;IAED,QACIC,qCAACC,kCAAa,EAAA,EACV,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,0BAA0B,EACtC,aAAa,EAAE,IAAI,EACnB,OAAO,EAAE,OAAO,EAAA,EAEfC,kBAAY,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAC7B;AAExB;;;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.notification-manager__enter_4ws0s {
|
|
2
|
+
visibility: hidden;
|
|
3
|
+
transform: translate(0, -500px);
|
|
4
|
+
}
|
|
5
|
+
.notification-manager__enterActive_4ws0s {
|
|
6
|
+
visibility: visible;
|
|
7
|
+
transform: translate(0);
|
|
8
|
+
transition: transform 0.4s ease-out;
|
|
9
|
+
}
|
|
10
|
+
@media (min-width: 600px) {
|
|
11
|
+
.notification-manager__enter_4ws0s {
|
|
12
|
+
transform: translate(100%, 0);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.notification-manager__enterActive_4ws0s {
|
|
16
|
+
transform: translate(0);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.module.css.js","sources":["../../src/components/notification/index.module.css"],"sourcesContent":["@import '@alfalab/core-components-vars/src/index.css';\n\n.enter {\n visibility: hidden;\n transform: translate(0, -500px);\n}\n\n.enterActive {\n visibility: visible;\n transform: translate(0);\n transition: transform 0.4s ease-out;\n}\n\n@media (--tablet-s) {\n .enter {\n transform: translate(100%, 0);\n }\n\n .enterActive {\n transform: translate(0);\n }\n}\n"],"names":[],"mappings":";;;;AAEgB,aAAe,CAAC,OAAO,CAAC,mCAAmC,CAAC,aAAa,CAAC,yCAAyC,CAAC;;;;"}
|
package/cssm/component.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { type HTMLAttributes } from 'react';
|
|
2
2
|
import { type PortalProps } from '@alfalab/core-components-portal/cssm';
|
|
3
3
|
import { type NotificationElement } from './components';
|
|
4
|
-
export
|
|
4
|
+
export interface NotificationManagerProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
5
|
/**
|
|
6
6
|
* Массив нотификаций.
|
|
7
7
|
* В нотификации обязательно передавайте id.
|
|
@@ -33,37 +33,5 @@ export type NotificationManagerProps = HTMLAttributes<HTMLDivElement> & {
|
|
|
33
33
|
* Контейнер к которому будут добавляться порталы
|
|
34
34
|
*/
|
|
35
35
|
container?: PortalProps['getPortalContainer'];
|
|
36
|
-
}
|
|
37
|
-
export declare const NotificationManager: React.ForwardRefExoticComponent<React.
|
|
38
|
-
/**
|
|
39
|
-
* Массив нотификаций.
|
|
40
|
-
* В нотификации обязательно передавайте id.
|
|
41
|
-
*/
|
|
42
|
-
notifications: NotificationElement[];
|
|
43
|
-
/**
|
|
44
|
-
* Дополнительный класс (native prop)
|
|
45
|
-
*/
|
|
46
|
-
className?: string;
|
|
47
|
-
/**
|
|
48
|
-
* Идентификатор для систем автоматизированного тестирования
|
|
49
|
-
*/
|
|
50
|
-
dataTestId?: string;
|
|
51
|
-
/**
|
|
52
|
-
* z-index компонента
|
|
53
|
-
*/
|
|
54
|
-
zIndex?: number;
|
|
55
|
-
/**
|
|
56
|
-
* Отступ от верхнего края
|
|
57
|
-
*/
|
|
58
|
-
offset?: number;
|
|
59
|
-
/**
|
|
60
|
-
* Удаление нотификации
|
|
61
|
-
*/
|
|
62
|
-
onRemoveNotification: (id: string) => void;
|
|
63
|
-
/**
|
|
64
|
-
* Нода, компонент или функция возвращающая их
|
|
65
|
-
*
|
|
66
|
-
* Контейнер к которому будут добавляться порталы
|
|
67
|
-
*/
|
|
68
|
-
container?: PortalProps["getPortalContainer"];
|
|
69
|
-
} & React.RefAttributes<HTMLDivElement>>;
|
|
36
|
+
}
|
|
37
|
+
export declare const NotificationManager: React.ForwardRefExoticComponent<NotificationManagerProps & React.RefAttributes<HTMLDivElement>>;
|
package/cssm/component.js
CHANGED
|
@@ -18,25 +18,15 @@ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
|
18
18
|
var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
|
|
19
19
|
var styles__default = /*#__PURE__*/_interopDefaultCompat(styles);
|
|
20
20
|
|
|
21
|
-
var CSS_TRANSITION_CLASS_NAMES = {
|
|
22
|
-
enter: styles__default.default.enter,
|
|
23
|
-
enterActive: styles__default.default.enterActive,
|
|
24
|
-
};
|
|
25
|
-
var TIMEOUT = {
|
|
26
|
-
exit: 0,
|
|
27
|
-
enter: 400,
|
|
28
|
-
};
|
|
29
21
|
var NotificationManager = React.forwardRef(function (_a, ref) {
|
|
30
22
|
var notifications = _a.notifications, className = _a.className, dataTestId = _a.dataTestId, _b = _a.zIndex, zIndex = _b === void 0 ? cssm.stackingOrder.TOAST : _b, _c = _a.style, style = _c === void 0 ? {} : _c, offset = _a.offset, onRemoveNotification = _a.onRemoveNotification, container = _a.container, restProps = tslib.__rest(_a, ["notifications", "className", "dataTestId", "zIndex", "style", "offset", "onRemoveNotification", "container"]);
|
|
31
|
-
var nodeRef = React.useRef(null);
|
|
32
23
|
return (React__default.default.createElement(cssm$1.Stack, { value: zIndex }, function (computedZIndex) { return (React__default.default.createElement(cssm$2.Portal, { getPortalContainer: container },
|
|
33
24
|
React__default.default.createElement("div", tslib.__assign({ className: cn__default.default(styles__default.default.component, className), ref: ref, "data-test-id": dataTestId, style: tslib.__assign({ zIndex: computedZIndex, top: offset }, style) }, restProps),
|
|
34
25
|
React__default.default.createElement(reactTransitionGroup.TransitionGroup, null, notifications.map(function (element, index) {
|
|
35
26
|
var _a;
|
|
36
|
-
return (React__default.default.createElement(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
_a)), onRemoveNotification: onRemoveNotification })));
|
|
27
|
+
return (React__default.default.createElement(component.Notification, { key: element.props.id, element: element, onRemoveNotification: onRemoveNotification, className: cn__default.default(styles__default.default.notification, (_a = {},
|
|
28
|
+
_a[styles__default.default.withoutMargin] = offset && index === 0,
|
|
29
|
+
_a)) }));
|
|
40
30
|
}))))); }));
|
|
41
31
|
});
|
|
42
32
|
NotificationManager.displayName = 'NotificationManager';
|
package/cssm/component.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../src/component.tsx"],"sourcesContent":["import React, { forwardRef, type HTMLAttributes
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../src/component.tsx"],"sourcesContent":["import React, { forwardRef, type HTMLAttributes } from 'react';\nimport { TransitionGroup } from 'react-transition-group';\nimport cn from 'classnames';\n\nimport { Portal, type PortalProps } from '@alfalab/core-components-portal';\nimport { Stack } from '@alfalab/core-components-stack';\nimport { stackingOrder } from '@alfalab/core-components-stack-context';\n\nimport { Notification, type NotificationElement } from './components';\n\nimport styles from './index.module.css';\n\nexport interface NotificationManagerProps extends HTMLAttributes<HTMLDivElement> {\n /**\n * Массив нотификаций.\n * В нотификации обязательно передавайте id.\n */\n notifications: NotificationElement[];\n\n /**\n * Дополнительный класс (native prop)\n */\n className?: string;\n\n /**\n * Идентификатор для систем автоматизированного тестирования\n */\n dataTestId?: string;\n\n /**\n * z-index компонента\n */\n zIndex?: number;\n\n /**\n * Отступ от верхнего края\n */\n offset?: number;\n\n /**\n * Удаление нотификации\n */\n onRemoveNotification: (id: string) => void;\n\n /**\n * Нода, компонент или функция возвращающая их\n *\n * Контейнер к которому будут добавляться порталы\n */\n container?: PortalProps['getPortalContainer'];\n}\n\nexport const NotificationManager = forwardRef<HTMLDivElement, NotificationManagerProps>(\n (\n {\n notifications,\n className,\n dataTestId,\n zIndex = stackingOrder.TOAST,\n style = {},\n offset,\n onRemoveNotification,\n container,\n ...restProps\n },\n ref,\n ) => (\n <Stack value={zIndex}>\n {(computedZIndex) => (\n <Portal getPortalContainer={container}>\n <div\n className={cn(styles.component, className)}\n ref={ref}\n data-test-id={dataTestId}\n style={{\n zIndex: computedZIndex,\n top: offset,\n ...style,\n }}\n {...restProps}\n >\n <TransitionGroup>\n {notifications.map((element, index) => (\n <Notification\n key={element.props.id}\n element={element}\n onRemoveNotification={onRemoveNotification}\n className={cn(styles.notification, {\n [styles.withoutMargin]: offset && index === 0,\n })}\n />\n ))}\n </TransitionGroup>\n </div>\n </Portal>\n )}\n </Stack>\n ),\n);\n\nNotificationManager.displayName = 'NotificationManager';\n"],"names":["forwardRef","stackingOrder","__rest","React","Stack","Portal","__assign","cn","styles","TransitionGroup","Notification"],"mappings":";;;;;;;;;;;;;;;;;;;;IAoDa,mBAAmB,GAAGA,gBAAU,CACzC,UACI,EAUC,EACD,GAAG,EAAA;AAVC,IAAA,IAAA,aAAa,GAAA,EAAA,CAAA,aAAA,EACb,SAAS,GAAA,EAAA,CAAA,SAAA,EACT,UAAU,GAAA,EAAA,CAAA,UAAA,EACV,EAAA,GAAA,EAAA,CAAA,MAA4B,EAA5B,MAAM,GAAA,EAAA,KAAA,MAAA,GAAGC,kBAAa,CAAC,KAAK,GAAA,EAAA,EAC5B,EAAU,GAAA,EAAA,CAAA,KAAA,EAAV,KAAK,GAAG,EAAA,KAAA,MAAA,GAAA,EAAE,GAAA,EAAA,EACV,MAAM,GAAA,EAAA,CAAA,MAAA,EACN,oBAAoB,GAAA,EAAA,CAAA,oBAAA,EACpB,SAAS,GAAA,EAAA,CAAA,SAAA,EACN,SAAS,GAAAC,YAAA,CAAA,EAAA,EAThB,8GAUC,CADe;AAGf,IAAA,QACDC,sBAAC,CAAA,aAAA,CAAAC,YAAK,IAAC,KAAK,EAAE,MAAM,EACf,EAAA,UAAC,cAAc,EAAA,EAAK,QACjBD,sBAAA,CAAA,aAAA,CAACE,aAAM,EAAC,EAAA,kBAAkB,EAAE,SAAS,EAAA;AACjC,QAAAF,sBAAA,CAAA,aAAA,CAAA,KAAA,EAAAG,cAAA,CAAA,EACI,SAAS,EAAEC,mBAAE,CAACC,uBAAM,CAAC,SAAS,EAAE,SAAS,CAAC,EAC1C,GAAG,EAAE,GAAG,EACM,cAAA,EAAA,UAAU,EACxB,KAAK,EACDF,cAAA,CAAA,EAAA,MAAM,EAAE,cAAc,EACtB,GAAG,EAAE,MAAM,EACR,EAAA,KAAK,KAER,SAAS,CAAA;YAEbH,sBAAC,CAAA,aAAA,CAAAM,oCAAe,QACX,aAAa,CAAC,GAAG,CAAC,UAAC,OAAO,EAAE,KAAK,EAAA;;gBAAK,QACnCN,sBAAC,CAAA,aAAA,CAAAO,sBAAY,EACT,EAAA,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,EACrB,OAAO,EAAE,OAAO,EAChB,oBAAoB,EAAE,oBAAoB,EAC1C,SAAS,EAAEH,mBAAE,CAACC,uBAAM,CAAC,YAAY,GAAA,EAAA,GAAA,EAAA;wBAC7B,EAAC,CAAAA,uBAAM,CAAC,aAAa,CAAA,GAAG,MAAM,IAAI,KAAK,KAAK,CAAC;AAC/C,wBAAA,EAAA,EAAA,EAAA,CACJ;aACL,CAAC,CACY,CAChB,CACD,EA1BQ,EA2BpB,CACG;AACX,CAAA;AAGL,mBAAmB,CAAC,WAAW,GAAG,qBAAqB;;;;"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { type FC, type ReactElement
|
|
1
|
+
import { type FC, type ReactElement } from 'react';
|
|
2
|
+
import { type CSSTransitionProps } from 'react-transition-group/CSSTransition';
|
|
2
3
|
import { type NotificationProps as CoreNotificationProps } from '@alfalab/core-components-notification/cssm';
|
|
3
4
|
export type NotificationElement = ReactElement<CoreNotificationProps & {
|
|
4
5
|
id: string;
|
|
5
6
|
}>;
|
|
6
|
-
type
|
|
7
|
+
type NotificationTransitionProps = Partial<Pick<CSSTransitionProps<HTMLDivElement>, 'in' | 'onExited' | 'appear' | 'enter' | 'exit'>>;
|
|
8
|
+
interface NotificationProps extends NotificationTransitionProps {
|
|
7
9
|
element: NotificationElement;
|
|
8
10
|
className: string;
|
|
9
11
|
onRemoveNotification: (id: string) => void;
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
+
}
|
|
12
13
|
export declare const Notification: FC<NotificationProps>;
|
|
13
14
|
export {};
|
|
@@ -4,14 +4,27 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
6
|
var React = require('react');
|
|
7
|
+
var reactTransitionGroup = require('react-transition-group');
|
|
7
8
|
var cn = require('classnames');
|
|
9
|
+
var styles = require('./index.module.css');
|
|
8
10
|
|
|
9
11
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
10
12
|
|
|
13
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
11
14
|
var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
|
|
15
|
+
var styles__default = /*#__PURE__*/_interopDefaultCompat(styles);
|
|
12
16
|
|
|
17
|
+
var TIMEOUT = {
|
|
18
|
+
exit: 0,
|
|
19
|
+
enter: 400,
|
|
20
|
+
};
|
|
21
|
+
var CSS_TRANSITION_CLASS_NAMES = {
|
|
22
|
+
enter: styles__default.default.enter,
|
|
23
|
+
enterActive: styles__default.default.enterActive,
|
|
24
|
+
};
|
|
13
25
|
var Notification = function (_a) {
|
|
14
|
-
var
|
|
26
|
+
var inProp = _a.in, onExited = _a.onExited, appear = _a.appear, enter = _a.enter, exit = _a.exit, element = _a.element, className = _a.className, onRemoveNotification = _a.onRemoveNotification;
|
|
27
|
+
var nodeRef = React.useRef(null);
|
|
15
28
|
var _b = element.props, onClose = _b.onClose, onCloseTimeout = _b.onCloseTimeout;
|
|
16
29
|
var handleClose = React.useCallback(function () {
|
|
17
30
|
if (onClose) {
|
|
@@ -25,10 +38,10 @@ var Notification = function (_a) {
|
|
|
25
38
|
}
|
|
26
39
|
onRemoveNotification(element.props.id);
|
|
27
40
|
}, [element.props.id, onCloseTimeout, onRemoveNotification]);
|
|
28
|
-
var notificationProps = React.useMemo(function () { return (tslib.__assign(tslib.__assign({}, element.props), { visible: true, className: cn__default.default(className, element.props.className), usePortal: false, offset: 0, onClose: handleClose, onCloseTimeout: handleCloseTimeout, containerRef:
|
|
41
|
+
var notificationProps = React.useMemo(function () { return (tslib.__assign(tslib.__assign({}, element.props), { visible: true, className: cn__default.default(className, element.props.className), usePortal: false, offset: 0, onClose: handleClose, onCloseTimeout: handleCloseTimeout, containerRef: nodeRef })); },
|
|
29
42
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
30
|
-
[element, handleClose, handleCloseTimeout,
|
|
31
|
-
return React.cloneElement(element, notificationProps);
|
|
43
|
+
[element, handleClose, handleCloseTimeout, className]);
|
|
44
|
+
return (React__default.default.createElement(reactTransitionGroup.CSSTransition, { in: inProp, onExited: onExited, appear: appear, enter: enter, exit: exit, timeout: TIMEOUT, classNames: CSS_TRANSITION_CLASS_NAMES, unmountOnExit: true, nodeRef: nodeRef }, React.cloneElement(element, notificationProps)));
|
|
32
45
|
};
|
|
33
46
|
|
|
34
47
|
exports.Notification = Notification;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../../src/components/notification/component.
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../../src/components/notification/component.tsx"],"sourcesContent":["import React, {\n cloneElement,\n type FC,\n type ReactElement,\n useCallback,\n useMemo,\n useRef,\n} from 'react';\nimport { CSSTransition } from 'react-transition-group';\nimport { type CSSTransitionProps } from 'react-transition-group/CSSTransition';\nimport cn from 'classnames';\n\nimport { type NotificationProps as CoreNotificationProps } from '@alfalab/core-components-notification';\n\nimport styles from './index.module.css';\n\nexport type NotificationElement = ReactElement<CoreNotificationProps & { id: string }>;\n\nconst TIMEOUT = {\n exit: 0,\n enter: 400,\n};\n\nconst CSS_TRANSITION_CLASS_NAMES = {\n enter: styles.enter,\n enterActive: styles.enterActive,\n};\n\ntype NotificationTransitionProps = Partial<\n Pick<CSSTransitionProps<HTMLDivElement>, 'in' | 'onExited' | 'appear' | 'enter' | 'exit'>\n>;\n\ninterface NotificationProps extends NotificationTransitionProps {\n element: NotificationElement;\n className: string;\n onRemoveNotification: (id: string) => void;\n}\n\nexport const Notification: FC<NotificationProps> = ({\n in: inProp,\n onExited,\n appear,\n enter,\n exit,\n element,\n className,\n onRemoveNotification,\n}) => {\n const nodeRef = useRef<HTMLDivElement>(null);\n const { onClose, onCloseTimeout } = element.props;\n\n const handleClose = useCallback(() => {\n if (onClose) {\n onClose();\n }\n\n onRemoveNotification(element.props.id);\n }, [onClose, onRemoveNotification, element.props.id]);\n\n const handleCloseTimeout = useCallback(() => {\n if (onCloseTimeout) {\n onCloseTimeout();\n }\n\n onRemoveNotification(element.props.id);\n }, [element.props.id, onCloseTimeout, onRemoveNotification]);\n\n const notificationProps = useMemo<CoreNotificationProps>(\n () => ({\n ...element.props,\n visible: true,\n className: cn(className, element.props.className),\n usePortal: false,\n offset: 0,\n onClose: handleClose,\n onCloseTimeout: handleCloseTimeout,\n containerRef: nodeRef,\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [element, handleClose, handleCloseTimeout, className],\n );\n\n return (\n <CSSTransition<HTMLDivElement>\n in={inProp}\n onExited={onExited}\n appear={appear}\n enter={enter}\n exit={exit}\n timeout={TIMEOUT}\n classNames={CSS_TRANSITION_CLASS_NAMES}\n unmountOnExit={true}\n nodeRef={nodeRef}\n >\n {cloneElement(element, notificationPro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,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,cAAc,EAAE,oBAAoB,CAAC,CAAC;IAE5D,IAAM,iBAAiB,GAAGC,aAAO,CAC7B,cAAM,QAAAC,cAAA,CAAAA,cAAA,CAAA,EAAA,EACC,OAAO,CAAC,KAAK,CAAA,EAAA,EAChB,OAAO,EAAE,IAAI,EACb,SAAS,EAAEC,mBAAE,CAAC,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,EACjD,SAAS,EAAE,KAAK,EAChB,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,WAAW,EACpB,cAAc,EAAE,kBAAkB,EAClC,YAAY,EAAE,OAAO,EACvB,CAAA,EAAA,EAAA;;IAEF,CAAC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,SAAS,CAAC,CACxD;IAED,QACIC,qCAACC,kCAAa,EAAA,EACV,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,0BAA0B,EACtC,aAAa,EAAE,IAAI,EACnB,OAAO,EAAE,OAAO,EAAA,EAEfC,kBAAY,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAC7B;AAExB;;;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.enter {
|
|
2
|
+
visibility: hidden;
|
|
3
|
+
transform: translate(0, -500px);
|
|
4
|
+
}
|
|
5
|
+
.enterActive {
|
|
6
|
+
visibility: visible;
|
|
7
|
+
transform: translate(0);
|
|
8
|
+
transition: transform 0.4s ease-out;
|
|
9
|
+
}
|
|
10
|
+
@media (min-width: 600px) {
|
|
11
|
+
.enter {
|
|
12
|
+
transform: translate(100%, 0);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.enterActive {
|
|
16
|
+
transform: translate(0);
|
|
17
|
+
}
|
|
18
|
+
}
|
package/cssm/index.module.css
CHANGED
|
@@ -25,15 +25,6 @@
|
|
|
25
25
|
.component .notification.notification {
|
|
26
26
|
position: static;
|
|
27
27
|
}
|
|
28
|
-
.enter {
|
|
29
|
-
visibility: hidden;
|
|
30
|
-
transform: translate(0, -500px);
|
|
31
|
-
}
|
|
32
|
-
.enterActive {
|
|
33
|
-
visibility: visible;
|
|
34
|
-
transform: translate(0);
|
|
35
|
-
transition: transform 0.4s ease-out;
|
|
36
|
-
}
|
|
37
28
|
@media (min-width: 600px) {
|
|
38
29
|
.component {
|
|
39
30
|
right: var(--gap-48);
|
|
@@ -42,12 +33,4 @@
|
|
|
42
33
|
.component .notification {
|
|
43
34
|
width: auto;
|
|
44
35
|
}
|
|
45
|
-
|
|
46
|
-
.enter {
|
|
47
|
-
transform: translate(100%, 0);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.enterActive {
|
|
51
|
-
transform: translate(0);
|
|
52
|
-
}
|
|
53
36
|
}
|
package/esm/component.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { type HTMLAttributes } from 'react';
|
|
2
2
|
import { type PortalProps } from '@alfalab/core-components-portal/esm';
|
|
3
3
|
import { type NotificationElement } from './components';
|
|
4
|
-
export
|
|
4
|
+
export interface NotificationManagerProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
5
|
/**
|
|
6
6
|
* Массив нотификаций.
|
|
7
7
|
* В нотификации обязательно передавайте id.
|
|
@@ -33,37 +33,5 @@ export type NotificationManagerProps = HTMLAttributes<HTMLDivElement> & {
|
|
|
33
33
|
* Контейнер к которому будут добавляться порталы
|
|
34
34
|
*/
|
|
35
35
|
container?: PortalProps['getPortalContainer'];
|
|
36
|
-
}
|
|
37
|
-
export declare const NotificationManager: React.ForwardRefExoticComponent<React.
|
|
38
|
-
/**
|
|
39
|
-
* Массив нотификаций.
|
|
40
|
-
* В нотификации обязательно передавайте id.
|
|
41
|
-
*/
|
|
42
|
-
notifications: NotificationElement[];
|
|
43
|
-
/**
|
|
44
|
-
* Дополнительный класс (native prop)
|
|
45
|
-
*/
|
|
46
|
-
className?: string;
|
|
47
|
-
/**
|
|
48
|
-
* Идентификатор для систем автоматизированного тестирования
|
|
49
|
-
*/
|
|
50
|
-
dataTestId?: string;
|
|
51
|
-
/**
|
|
52
|
-
* z-index компонента
|
|
53
|
-
*/
|
|
54
|
-
zIndex?: number;
|
|
55
|
-
/**
|
|
56
|
-
* Отступ от верхнего края
|
|
57
|
-
*/
|
|
58
|
-
offset?: number;
|
|
59
|
-
/**
|
|
60
|
-
* Удаление нотификации
|
|
61
|
-
*/
|
|
62
|
-
onRemoveNotification: (id: string) => void;
|
|
63
|
-
/**
|
|
64
|
-
* Нода, компонент или функция возвращающая их
|
|
65
|
-
*
|
|
66
|
-
* Контейнер к которому будут добавляться порталы
|
|
67
|
-
*/
|
|
68
|
-
container?: PortalProps["getPortalContainer"];
|
|
69
|
-
} & React.RefAttributes<HTMLDivElement>>;
|
|
36
|
+
}
|
|
37
|
+
export declare const NotificationManager: React.ForwardRefExoticComponent<NotificationManagerProps & React.RefAttributes<HTMLDivElement>>;
|
package/esm/component.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __rest, __assign } from 'tslib';
|
|
2
|
-
import React, { forwardRef
|
|
3
|
-
import { TransitionGroup
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import { TransitionGroup } from 'react-transition-group';
|
|
4
4
|
import cn from 'classnames';
|
|
5
5
|
import { Portal } from '@alfalab/core-components-portal/esm';
|
|
6
6
|
import { Stack } from '@alfalab/core-components-stack/esm';
|
|
@@ -8,25 +8,15 @@ import { stackingOrder } from '@alfalab/core-components-stack-context/esm';
|
|
|
8
8
|
import { Notification } from './components/notification/component.js';
|
|
9
9
|
import styles from './index.module.css.js';
|
|
10
10
|
|
|
11
|
-
var CSS_TRANSITION_CLASS_NAMES = {
|
|
12
|
-
enter: styles.enter,
|
|
13
|
-
enterActive: styles.enterActive,
|
|
14
|
-
};
|
|
15
|
-
var TIMEOUT = {
|
|
16
|
-
exit: 0,
|
|
17
|
-
enter: 400,
|
|
18
|
-
};
|
|
19
11
|
var NotificationManager = forwardRef(function (_a, ref) {
|
|
20
12
|
var notifications = _a.notifications, className = _a.className, dataTestId = _a.dataTestId, _b = _a.zIndex, zIndex = _b === void 0 ? stackingOrder.TOAST : _b, _c = _a.style, style = _c === void 0 ? {} : _c, offset = _a.offset, onRemoveNotification = _a.onRemoveNotification, container = _a.container, restProps = __rest(_a, ["notifications", "className", "dataTestId", "zIndex", "style", "offset", "onRemoveNotification", "container"]);
|
|
21
|
-
var nodeRef = useRef(null);
|
|
22
13
|
return (React.createElement(Stack, { value: zIndex }, function (computedZIndex) { return (React.createElement(Portal, { getPortalContainer: container },
|
|
23
14
|
React.createElement("div", __assign({ className: cn(styles.component, className), ref: ref, "data-test-id": dataTestId, style: __assign({ zIndex: computedZIndex, top: offset }, style) }, restProps),
|
|
24
15
|
React.createElement(TransitionGroup, null, notifications.map(function (element, index) {
|
|
25
16
|
var _a;
|
|
26
|
-
return (React.createElement(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
_a)), onRemoveNotification: onRemoveNotification })));
|
|
17
|
+
return (React.createElement(Notification, { key: element.props.id, element: element, onRemoveNotification: onRemoveNotification, className: cn(styles.notification, (_a = {},
|
|
18
|
+
_a[styles.withoutMargin] = offset && index === 0,
|
|
19
|
+
_a)) }));
|
|
30
20
|
}))))); }));
|
|
31
21
|
});
|
|
32
22
|
NotificationManager.displayName = 'NotificationManager';
|
package/esm/component.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../src/component.tsx"],"sourcesContent":["import React, { forwardRef, type HTMLAttributes
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../src/component.tsx"],"sourcesContent":["import React, { forwardRef, type HTMLAttributes } from 'react';\nimport { TransitionGroup } from 'react-transition-group';\nimport cn from 'classnames';\n\nimport { Portal, type PortalProps } from '@alfalab/core-components-portal';\nimport { Stack } from '@alfalab/core-components-stack';\nimport { stackingOrder } from '@alfalab/core-components-stack-context';\n\nimport { Notification, type NotificationElement } from './components';\n\nimport styles from './index.module.css';\n\nexport interface NotificationManagerProps extends HTMLAttributes<HTMLDivElement> {\n /**\n * Массив нотификаций.\n * В нотификации обязательно передавайте id.\n */\n notifications: NotificationElement[];\n\n /**\n * Дополнительный класс (native prop)\n */\n className?: string;\n\n /**\n * Идентификатор для систем автоматизированного тестирования\n */\n dataTestId?: string;\n\n /**\n * z-index компонента\n */\n zIndex?: number;\n\n /**\n * Отступ от верхнего края\n */\n offset?: number;\n\n /**\n * Удаление нотификации\n */\n onRemoveNotification: (id: string) => void;\n\n /**\n * Нода, компонент или функция возвращающая их\n *\n * Контейнер к которому будут добавляться порталы\n */\n container?: PortalProps['getPortalContainer'];\n}\n\nexport const NotificationManager = forwardRef<HTMLDivElement, NotificationManagerProps>(\n (\n {\n notifications,\n className,\n dataTestId,\n zIndex = stackingOrder.TOAST,\n style = {},\n offset,\n onRemoveNotification,\n container,\n ...restProps\n },\n ref,\n ) => (\n <Stack value={zIndex}>\n {(computedZIndex) => (\n <Portal getPortalContainer={container}>\n <div\n className={cn(styles.component, className)}\n ref={ref}\n data-test-id={dataTestId}\n style={{\n zIndex: computedZIndex,\n top: offset,\n ...style,\n }}\n {...restProps}\n >\n <TransitionGroup>\n {notifications.map((element, index) => (\n <Notification\n key={element.props.id}\n element={element}\n onRemoveNotification={onRemoveNotification}\n className={cn(styles.notification, {\n [styles.withoutMargin]: offset && index === 0,\n })}\n />\n ))}\n </TransitionGroup>\n </div>\n </Portal>\n )}\n </Stack>\n ),\n);\n\nNotificationManager.displayName = 'NotificationManager';\n"],"names":[],"mappings":";;;;;;;;;;IAoDa,mBAAmB,GAAG,UAAU,CACzC,UACI,EAUC,EACD,GAAG,EAAA;AAVC,IAAA,IAAA,aAAa,GAAA,EAAA,CAAA,aAAA,EACb,SAAS,GA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