@quen-ui/components 0.0.13
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 +43 -0
- package/dist/Alert/Alert.cjs.js +54 -0
- package/dist/Alert/Alert.d.ts +4 -0
- package/dist/Alert/Alert.es.js +55 -0
- package/dist/Alert/index.d.ts +2 -0
- package/dist/Alert/styles.cjs.js +90 -0
- package/dist/Alert/styles.d.ts +10 -0
- package/dist/Alert/styles.es.js +90 -0
- package/dist/Alert/types.d.ts +25 -0
- package/dist/Avatar/Avatar.cjs.js +65 -0
- package/dist/Avatar/Avatar.d.ts +4 -0
- package/dist/Avatar/Avatar.es.js +66 -0
- package/dist/Avatar/AvatarIcon.svg.cjs.js +21 -0
- package/dist/Avatar/AvatarIcon.svg.es.js +5 -0
- package/dist/Avatar/helpers.cjs.js +18 -0
- package/dist/Avatar/helpers.d.ts +1 -0
- package/dist/Avatar/helpers.es.js +18 -0
- package/dist/Avatar/index.d.ts +2 -0
- package/dist/Avatar/styles.cjs.js +31 -0
- package/dist/Avatar/styles.d.ts +9 -0
- package/dist/Avatar/styles.es.js +31 -0
- package/dist/Avatar/types.d.ts +31 -0
- package/dist/Badge/Badge.cjs.js +53 -0
- package/dist/Badge/Badge.d.ts +4 -0
- package/dist/Badge/Badge.es.js +54 -0
- package/dist/Badge/index.d.ts +3 -0
- package/dist/Badge/styles.cjs.js +70 -0
- package/dist/Badge/styles.d.ts +7 -0
- package/dist/Badge/styles.es.js +70 -0
- package/dist/Badge/types.cjs.js +10 -0
- package/dist/Badge/types.d.ts +22 -0
- package/dist/Badge/types.es.js +10 -0
- package/dist/Breadcrumbs/BreadcrumbItem.cjs.js +42 -0
- package/dist/Breadcrumbs/BreadcrumbItem.d.ts +4 -0
- package/dist/Breadcrumbs/BreadcrumbItem.es.js +43 -0
- package/dist/Breadcrumbs/Breadcrumbs.cjs.js +48 -0
- package/dist/Breadcrumbs/Breadcrumbs.d.ts +4 -0
- package/dist/Breadcrumbs/Breadcrumbs.es.js +49 -0
- package/dist/Breadcrumbs/helpers.cjs.js +18 -0
- package/dist/Breadcrumbs/helpers.d.ts +16 -0
- package/dist/Breadcrumbs/helpers.es.js +18 -0
- package/dist/Breadcrumbs/index.d.ts +2 -0
- package/dist/Breadcrumbs/styles.cjs.js +50 -0
- package/dist/Breadcrumbs/styles.d.ts +4 -0
- package/dist/Breadcrumbs/styles.es.js +50 -0
- package/dist/Breadcrumbs/types.d.ts +56 -0
- package/dist/Button/Button.cjs.js +66 -0
- package/dist/Button/Button.d.ts +4 -0
- package/dist/Button/Button.es.js +67 -0
- package/dist/Button/index.d.ts +2 -0
- package/dist/Button/styles.cjs.js +177 -0
- package/dist/Button/styles.d.ts +7 -0
- package/dist/Button/styles.es.js +177 -0
- package/dist/Button/types.d.ts +38 -0
- package/dist/Card/Card.cjs.js +38 -0
- package/dist/Card/Card.d.ts +3 -0
- package/dist/Card/Card.es.js +39 -0
- package/dist/Card/index.d.ts +2 -0
- package/dist/Card/styles.cjs.js +55 -0
- package/dist/Card/styles.d.ts +11 -0
- package/dist/Card/styles.es.js +55 -0
- package/dist/Card/types.d.ts +26 -0
- package/dist/Checkbox/Checkbox.cjs.js +39 -0
- package/dist/Checkbox/Checkbox.d.ts +4 -0
- package/dist/Checkbox/Checkbox.es.js +40 -0
- package/dist/Checkbox/CheckboxGroup.cjs.js +82 -0
- package/dist/Checkbox/CheckboxGroup.d.ts +4 -0
- package/dist/Checkbox/CheckboxGroup.es.js +83 -0
- package/dist/Checkbox/helpers.cjs.js +14 -0
- package/dist/Checkbox/helpers.d.ts +18 -0
- package/dist/Checkbox/helpers.es.js +14 -0
- package/dist/Checkbox/index.cjs.js +7 -0
- package/dist/Checkbox/index.d.ts +8 -0
- package/dist/Checkbox/index.es.js +7 -0
- package/dist/Checkbox/styles.cjs.js +147 -0
- package/dist/Checkbox/styles.d.ts +13 -0
- package/dist/Checkbox/styles.es.js +147 -0
- package/dist/Checkbox/types.d.ts +67 -0
- package/dist/Divider/Divider.cjs.js +27 -0
- package/dist/Divider/Divider.d.ts +4 -0
- package/dist/Divider/Divider.es.js +28 -0
- package/dist/Divider/index.d.ts +2 -0
- package/dist/Divider/styles.cjs.js +121 -0
- package/dist/Divider/styles.d.ts +3 -0
- package/dist/Divider/styles.es.js +121 -0
- package/dist/Divider/types.d.ts +17 -0
- package/dist/Drawer/Drawer.cjs.js +67 -0
- package/dist/Drawer/Drawer.d.ts +4 -0
- package/dist/Drawer/Drawer.es.js +68 -0
- package/dist/Drawer/index.d.ts +2 -0
- package/dist/Drawer/styles.cjs.js +85 -0
- package/dist/Drawer/styles.d.ts +18 -0
- package/dist/Drawer/styles.es.js +85 -0
- package/dist/Drawer/types.d.ts +24 -0
- package/dist/Dropdown/Dropdown.cjs.js +65 -0
- package/dist/Dropdown/Dropdown.d.ts +4 -0
- package/dist/Dropdown/Dropdown.es.js +66 -0
- package/dist/Dropdown/DropdownItem.cjs.js +32 -0
- package/dist/Dropdown/DropdownItem.d.ts +4 -0
- package/dist/Dropdown/DropdownItem.es.js +33 -0
- package/dist/Dropdown/DropdownList.cjs.js +85 -0
- package/dist/Dropdown/DropdownList.d.ts +6 -0
- package/dist/Dropdown/DropdownList.es.js +86 -0
- package/dist/Dropdown/DropdownPortal.cjs.js +41 -0
- package/dist/Dropdown/DropdownPortal.d.ts +4 -0
- package/dist/Dropdown/DropdownPortal.es.js +42 -0
- package/dist/Dropdown/helpers.cjs.js +112 -0
- package/dist/Dropdown/helpers.d.ts +35 -0
- package/dist/Dropdown/helpers.es.js +112 -0
- package/dist/Dropdown/index.d.ts +2 -0
- package/dist/Dropdown/styles.cjs.js +150 -0
- package/dist/Dropdown/styles.d.ts +33 -0
- package/dist/Dropdown/styles.es.js +150 -0
- package/dist/Dropdown/types.d.ts +81 -0
- package/dist/Flex/Flex.cjs.js +10 -0
- package/dist/Flex/Flex.d.ts +4 -0
- package/dist/Flex/Flex.es.js +11 -0
- package/dist/Flex/index.d.ts +2 -0
- package/dist/Flex/styles.cjs.js +32 -0
- package/dist/Flex/styles.d.ts +2 -0
- package/dist/Flex/styles.es.js +32 -0
- package/dist/Flex/types.d.ts +23 -0
- package/dist/Image/Image.cjs.js +79 -0
- package/dist/Image/Image.d.ts +4 -0
- package/dist/Image/Image.es.js +80 -0
- package/dist/Image/index.d.ts +2 -0
- package/dist/Image/styles.cjs.js +87 -0
- package/dist/Image/styles.d.ts +13 -0
- package/dist/Image/styles.es.js +87 -0
- package/dist/Image/types.d.ts +20 -0
- package/dist/InputNumber/InputNumber.cjs.js +145 -0
- package/dist/InputNumber/InputNumber.d.ts +4 -0
- package/dist/InputNumber/InputNumber.es.js +146 -0
- package/dist/InputNumber/index.d.ts +2 -0
- package/dist/InputNumber/styles.cjs.js +136 -0
- package/dist/InputNumber/styles.d.ts +21 -0
- package/dist/InputNumber/styles.es.js +136 -0
- package/dist/InputNumber/types.d.ts +61 -0
- package/dist/Layout/Content.cjs.js +7 -0
- package/dist/Layout/Content.d.ts +4 -0
- package/dist/Layout/Content.es.js +8 -0
- package/dist/Layout/Footer.cjs.js +7 -0
- package/dist/Layout/Footer.d.ts +4 -0
- package/dist/Layout/Footer.es.js +8 -0
- package/dist/Layout/Header.cjs.js +47 -0
- package/dist/Layout/Header.d.ts +4 -0
- package/dist/Layout/Header.es.js +48 -0
- package/dist/Layout/Layout.cjs.js +49 -0
- package/dist/Layout/Layout.d.ts +5 -0
- package/dist/Layout/Layout.es.js +49 -0
- package/dist/Layout/Sidebar.cjs.js +57 -0
- package/dist/Layout/Sidebar.d.ts +4 -0
- package/dist/Layout/Sidebar.es.js +58 -0
- package/dist/Layout/index.cjs.js +13 -0
- package/dist/Layout/index.d.ts +14 -0
- package/dist/Layout/index.es.js +13 -0
- package/dist/Layout/styles.cjs.js +150 -0
- package/dist/Layout/styles.d.ts +32 -0
- package/dist/Layout/styles.es.js +150 -0
- package/dist/Layout/types.d.ts +75 -0
- package/dist/Loader/Loader.cjs.js +34 -0
- package/dist/Loader/Loader.d.ts +4 -0
- package/dist/Loader/Loader.es.js +35 -0
- package/dist/Loader/index.d.ts +2 -0
- package/dist/Loader/loaders/Bars.cjs.js +12 -0
- package/dist/Loader/loaders/Bars.d.ts +6 -0
- package/dist/Loader/loaders/Bars.es.js +13 -0
- package/dist/Loader/loaders/Dots.cjs.js +12 -0
- package/dist/Loader/loaders/Dots.d.ts +6 -0
- package/dist/Loader/loaders/Dots.es.js +13 -0
- package/dist/Loader/loaders/Oval.cjs.js +8 -0
- package/dist/Loader/loaders/Oval.d.ts +6 -0
- package/dist/Loader/loaders/Oval.es.js +9 -0
- package/dist/Loader/styles.cjs.js +95 -0
- package/dist/Loader/styles.d.ts +9 -0
- package/dist/Loader/styles.es.js +95 -0
- package/dist/Loader/types.d.ts +11 -0
- package/dist/Modal/Modal.cjs.js +67 -0
- package/dist/Modal/Modal.d.ts +4 -0
- package/dist/Modal/Modal.es.js +68 -0
- package/dist/Modal/index.d.ts +2 -0
- package/dist/Modal/styles.cjs.js +52 -0
- package/dist/Modal/styles.d.ts +14 -0
- package/dist/Modal/styles.es.js +52 -0
- package/dist/Modal/types.d.ts +31 -0
- package/dist/Notification/Notification.cjs.js +73 -0
- package/dist/Notification/Notification.d.ts +4 -0
- package/dist/Notification/Notification.es.js +74 -0
- package/dist/Notification/NotificationInstance.cjs.js +244 -0
- package/dist/Notification/NotificationInstance.d.ts +8 -0
- package/dist/Notification/NotificationInstance.es.js +244 -0
- package/dist/Notification/NotificationsStore.cjs.js +30 -0
- package/dist/Notification/NotificationsStore.d.ts +13 -0
- package/dist/Notification/NotificationsStore.es.js +31 -0
- package/dist/Notification/index.d.ts +3 -0
- package/dist/Notification/styles.cjs.js +90 -0
- package/dist/Notification/styles.d.ts +8 -0
- package/dist/Notification/styles.es.js +90 -0
- package/dist/Notification/types.cjs.js +9 -0
- package/dist/Notification/types.d.ts +41 -0
- package/dist/Notification/types.es.js +9 -0
- package/dist/Progress/Progress.cjs.js +43 -0
- package/dist/Progress/Progress.d.ts +4 -0
- package/dist/Progress/Progress.es.js +44 -0
- package/dist/Progress/index.d.ts +2 -0
- package/dist/Progress/styles.cjs.js +82 -0
- package/dist/Progress/styles.d.ts +13 -0
- package/dist/Progress/styles.es.js +82 -0
- package/dist/Progress/types.d.ts +20 -0
- package/dist/RadioButton/RadioButton.cjs.js +45 -0
- package/dist/RadioButton/RadioButton.d.ts +4 -0
- package/dist/RadioButton/RadioButton.es.js +46 -0
- package/dist/RadioButton/RadioButtonGroup.cjs.js +68 -0
- package/dist/RadioButton/RadioButtonGroup.d.ts +4 -0
- package/dist/RadioButton/RadioButtonGroup.es.js +69 -0
- package/dist/RadioButton/helpers.cjs.js +14 -0
- package/dist/RadioButton/helpers.d.ts +18 -0
- package/dist/RadioButton/helpers.es.js +14 -0
- package/dist/RadioButton/index.cjs.js +7 -0
- package/dist/RadioButton/index.d.ts +8 -0
- package/dist/RadioButton/index.es.js +7 -0
- package/dist/RadioButton/styles.cjs.js +84 -0
- package/dist/RadioButton/styles.d.ts +12 -0
- package/dist/RadioButton/styles.es.js +84 -0
- package/dist/RadioButton/types.d.ts +65 -0
- package/dist/Select/Select.cjs.js +114 -0
- package/dist/Select/Select.d.ts +4 -0
- package/dist/Select/Select.es.js +115 -0
- package/dist/Select/helpers.cjs.js +16 -0
- package/dist/Select/helpers.d.ts +138 -0
- package/dist/Select/helpers.es.js +16 -0
- package/dist/Select/index.d.ts +2 -0
- package/dist/Select/styles.cjs.js +415 -0
- package/dist/Select/styles.d.ts +9 -0
- package/dist/Select/styles.es.js +415 -0
- package/dist/Select/types.d.ts +116 -0
- package/dist/Select/useSelect.cjs.js +72 -0
- package/dist/Select/useSelect.d.ts +150 -0
- package/dist/Select/useSelect.es.js +72 -0
- package/dist/Switch/Switch.cjs.js +53 -0
- package/dist/Switch/Switch.d.ts +4 -0
- package/dist/Switch/Switch.es.js +54 -0
- package/dist/Switch/index.d.ts +2 -0
- package/dist/Switch/styles.cjs.js +78 -0
- package/dist/Switch/styles.d.ts +7 -0
- package/dist/Switch/styles.es.js +78 -0
- package/dist/Switch/types.d.ts +25 -0
- package/dist/Tabs/Tab.cjs.js +42 -0
- package/dist/Tabs/Tab.d.ts +4 -0
- package/dist/Tabs/Tab.es.js +43 -0
- package/dist/Tabs/TabPanel.cjs.js +14 -0
- package/dist/Tabs/TabPanel.d.ts +4 -0
- package/dist/Tabs/TabPanel.es.js +15 -0
- package/dist/Tabs/Tabs.cjs.js +21 -0
- package/dist/Tabs/Tabs.d.ts +5 -0
- package/dist/Tabs/Tabs.es.js +21 -0
- package/dist/Tabs/TabsList.cjs.js +12 -0
- package/dist/Tabs/TabsList.d.ts +4 -0
- package/dist/Tabs/TabsList.es.js +13 -0
- package/dist/Tabs/index.cjs.js +10 -0
- package/dist/Tabs/index.d.ts +12 -0
- package/dist/Tabs/index.es.js +11 -0
- package/dist/Tabs/styles.cjs.js +74 -0
- package/dist/Tabs/styles.d.ts +9 -0
- package/dist/Tabs/styles.es.js +74 -0
- package/dist/Tabs/types.d.ts +51 -0
- package/dist/Tag/Tag.cjs.js +39 -0
- package/dist/Tag/Tag.d.ts +4 -0
- package/dist/Tag/Tag.es.js +40 -0
- package/dist/Tag/index.d.ts +2 -0
- package/dist/Tag/styles.cjs.js +51 -0
- package/dist/Tag/styles.d.ts +6 -0
- package/dist/Tag/styles.es.js +51 -0
- package/dist/Tag/types.d.ts +18 -0
- package/dist/TextField/TextField.cjs.js +100 -0
- package/dist/TextField/TextField.d.ts +4 -0
- package/dist/TextField/TextField.es.js +101 -0
- package/dist/TextField/index.d.ts +2 -0
- package/dist/TextField/styles.cjs.js +65 -0
- package/dist/TextField/styles.d.ts +9 -0
- package/dist/TextField/styles.es.js +65 -0
- package/dist/TextField/types.d.ts +41 -0
- package/dist/Textarea/Textarea.cjs.js +103 -0
- package/dist/Textarea/Textarea.d.ts +4 -0
- package/dist/Textarea/Textarea.es.js +104 -0
- package/dist/Textarea/index.d.ts +2 -0
- package/dist/Textarea/styles.cjs.js +80 -0
- package/dist/Textarea/styles.d.ts +9 -0
- package/dist/Textarea/styles.es.js +80 -0
- package/dist/Textarea/types.d.ts +47 -0
- package/dist/Tooltip/Tooltip.cjs.js +69 -0
- package/dist/Tooltip/Tooltip.d.ts +4 -0
- package/dist/Tooltip/Tooltip.es.js +70 -0
- package/dist/Tooltip/index.d.ts +2 -0
- package/dist/Tooltip/styles.cjs.js +232 -0
- package/dist/Tooltip/styles.d.ts +13 -0
- package/dist/Tooltip/styles.es.js +232 -0
- package/dist/Tooltip/types.d.ts +22 -0
- package/dist/assets/icon-arrow-bottom.svg.cjs.js +21 -0
- package/dist/assets/icon-arrow-bottom.svg.es.js +5 -0
- package/dist/assets/icon-close.svg.cjs.js +21 -0
- package/dist/assets/icon-close.svg.es.js +5 -0
- package/dist/assets/icon-error.svg.cjs.js +21 -0
- package/dist/assets/icon-error.svg.es.js +5 -0
- package/dist/assets/icon-info.svg.cjs.js +21 -0
- package/dist/assets/icon-info.svg.es.js +5 -0
- package/dist/assets/icon-lines.svg.cjs.js +21 -0
- package/dist/assets/icon-lines.svg.es.js +5 -0
- package/dist/assets/icon-success.svg.cjs.js +21 -0
- package/dist/assets/icon-success.svg.es.js +5 -0
- package/dist/assets/icon-warning.svg.cjs.js +21 -0
- package/dist/assets/icon-warning.svg.es.js +5 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/index.cjs.js +63 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.es.js +63 -0
- package/dist/types/propsWithAttributes.d.ts +2 -0
- package/dist/types/size.d.ts +2 -0
- package/dist/typography/Text/Text.cjs.js +31 -0
- package/dist/typography/Text/Text.d.ts +4 -0
- package/dist/typography/Text/Text.es.js +32 -0
- package/dist/typography/Text/__stories__/Text.stories.d.ts +9 -0
- package/dist/typography/Text/index.d.ts +2 -0
- package/dist/typography/Text/styles.cjs.js +69 -0
- package/dist/typography/Text/styles.d.ts +2 -0
- package/dist/typography/Text/styles.es.js +69 -0
- package/dist/typography/Text/types.d.ts +22 -0
- package/dist/typography/Title/Title.cjs.js +26 -0
- package/dist/typography/Title/Title.d.ts +4 -0
- package/dist/typography/Title/Title.es.js +27 -0
- package/dist/typography/Title/__stories__/Title.stories.d.ts +9 -0
- package/dist/typography/Title/index.d.ts +2 -0
- package/dist/typography/Title/styles.cjs.js +75 -0
- package/dist/typography/Title/styles.d.ts +2 -0
- package/dist/typography/Title/styles.es.js +75 -0
- package/dist/typography/Title/types.d.ts +22 -0
- package/package.json +67 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { IModalProps } from './types';
|
|
3
|
+
declare const Modal: ({ open, title, size, closeButton, onClickClose, onEsc, zIndex, description, children, footer, fullScreen, classNameFooter, className, ...props }: IModalProps) => React.ReactNode;
|
|
4
|
+
export default Modal;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { createPortal } from "react-dom";
|
|
4
|
+
import { useTransitionState } from "react-transition-state";
|
|
5
|
+
import { ModalContainer, ModalStyled, ModalHeaderStyled, ModalFooterStyled } from "./styles.es.js";
|
|
6
|
+
import Title from "../typography/Title/Title.es.js";
|
|
7
|
+
import Text from "../typography/Text/Text.es.js";
|
|
8
|
+
import Button from "../Button/Button.es.js";
|
|
9
|
+
import SvgIconClose from "../assets/icon-close.svg.es.js";
|
|
10
|
+
const Modal = ({
|
|
11
|
+
open,
|
|
12
|
+
title,
|
|
13
|
+
size = "m",
|
|
14
|
+
closeButton,
|
|
15
|
+
onClickClose,
|
|
16
|
+
onEsc,
|
|
17
|
+
zIndex = 1e3,
|
|
18
|
+
description,
|
|
19
|
+
children,
|
|
20
|
+
footer,
|
|
21
|
+
fullScreen,
|
|
22
|
+
classNameFooter,
|
|
23
|
+
className,
|
|
24
|
+
...props
|
|
25
|
+
}) => {
|
|
26
|
+
const [state, toggle] = useTransitionState({
|
|
27
|
+
timeout: 500,
|
|
28
|
+
unmountOnExit: true,
|
|
29
|
+
initialEntered: open
|
|
30
|
+
});
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
toggle(open);
|
|
33
|
+
}, [open]);
|
|
34
|
+
const [container, setContainer] = useState(null);
|
|
35
|
+
const handleEscapeDown = (event) => {
|
|
36
|
+
if (event.key === "Escape") {
|
|
37
|
+
onEsc == null ? void 0 : onEsc();
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
const container2 = document.getElementsByTagName("body").item(0);
|
|
42
|
+
if (container2) {
|
|
43
|
+
container2.addEventListener("keydown", handleEscapeDown);
|
|
44
|
+
}
|
|
45
|
+
setContainer(container2);
|
|
46
|
+
return () => {
|
|
47
|
+
container2 == null ? void 0 : container2.removeEventListener("keydown", handleEscapeDown);
|
|
48
|
+
};
|
|
49
|
+
}, []);
|
|
50
|
+
if (state.isEnter && container) {
|
|
51
|
+
return createPortal(
|
|
52
|
+
/* @__PURE__ */ jsx(ModalContainer, { status: state.status, zIndex, ...props, children: /* @__PURE__ */ jsxs(ModalStyled, { fullScreen, className, size, children: [
|
|
53
|
+
/* @__PURE__ */ jsxs(ModalHeaderStyled, { children: [
|
|
54
|
+
title && /* @__PURE__ */ jsx(Title, { size, children: title }),
|
|
55
|
+
closeButton && /* @__PURE__ */ jsx(Button, { view: "icon", size, onClick: onClickClose, children: /* @__PURE__ */ jsx(SvgIconClose, { width: 16, height: 16 }) })
|
|
56
|
+
] }),
|
|
57
|
+
description && /* @__PURE__ */ jsx(Text, { size, children: description }),
|
|
58
|
+
children,
|
|
59
|
+
footer && /* @__PURE__ */ jsx(ModalFooterStyled, { className: classNameFooter, children: footer })
|
|
60
|
+
] }) }),
|
|
61
|
+
container
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
};
|
|
66
|
+
export {
|
|
67
|
+
Modal as default
|
|
68
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const styled = require("styled-components");
|
|
4
|
+
const polished = require("polished");
|
|
5
|
+
const ModalContainer = styled.div.withConfig({
|
|
6
|
+
shouldForwardProp: (prop) => !["status", "zIndex"].includes(prop)
|
|
7
|
+
})`
|
|
8
|
+
${({ status }) => (status === "preEnter" || status === "exiting") && styled.css`
|
|
9
|
+
opacity: 0;
|
|
10
|
+
transform: scale(0.9);
|
|
11
|
+
`};
|
|
12
|
+
position: absolute;
|
|
13
|
+
opacity: 1;
|
|
14
|
+
width: 100%;
|
|
15
|
+
height: 100%;
|
|
16
|
+
background: ${({ theme }) => polished.rgba(theme.colors.grayViolet[3], 0.7)};
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
justify-content: center;
|
|
20
|
+
top: 0;
|
|
21
|
+
left: 0;
|
|
22
|
+
z-index: ${({ zIndex }) => zIndex};
|
|
23
|
+
`;
|
|
24
|
+
const ModalStyled = styled.div.withConfig({
|
|
25
|
+
shouldForwardProp: (props) => !["fullScreen", "size"].includes(props)
|
|
26
|
+
})`
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
gap: 2rem;
|
|
30
|
+
padding: ${({ theme, size }) => polished.math(`${theme.space[size]} * 2`)};
|
|
31
|
+
background-color: ${({ theme }) => theme.colors.grayViolet[3]};
|
|
32
|
+
border-radius: 0.5rem;
|
|
33
|
+
${({ fullScreen }) => fullScreen && styled.css`
|
|
34
|
+
width: 100%;
|
|
35
|
+
height: 100%;
|
|
36
|
+
`};
|
|
37
|
+
`;
|
|
38
|
+
const ModalHeaderStyled = styled.div`
|
|
39
|
+
display: flex;
|
|
40
|
+
gap: 1rem;
|
|
41
|
+
justify-content: space-between;
|
|
42
|
+
align-items: center;
|
|
43
|
+
`;
|
|
44
|
+
const ModalFooterStyled = styled.div`
|
|
45
|
+
display: flex;
|
|
46
|
+
flex: 0 0 auto;
|
|
47
|
+
gap: 1rem;
|
|
48
|
+
`;
|
|
49
|
+
exports.ModalContainer = ModalContainer;
|
|
50
|
+
exports.ModalFooterStyled = ModalFooterStyled;
|
|
51
|
+
exports.ModalHeaderStyled = ModalHeaderStyled;
|
|
52
|
+
exports.ModalStyled = ModalStyled;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TransitionStatus } from 'react-transition-state';
|
|
2
|
+
import { TQuenSize } from '../types/size';
|
|
3
|
+
interface IModalContainerProps {
|
|
4
|
+
status: TransitionStatus;
|
|
5
|
+
zIndex: number;
|
|
6
|
+
}
|
|
7
|
+
export declare const ModalContainer: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, IModalContainerProps>> & string;
|
|
8
|
+
export declare const ModalStyled: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
9
|
+
fullScreen?: boolean;
|
|
10
|
+
size: TQuenSize;
|
|
11
|
+
}>> & string;
|
|
12
|
+
export declare const ModalHeaderStyled: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
13
|
+
export declare const ModalFooterStyled: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
import { rgba, math } from "polished";
|
|
3
|
+
const ModalContainer = styled.div.withConfig({
|
|
4
|
+
shouldForwardProp: (prop) => !["status", "zIndex"].includes(prop)
|
|
5
|
+
})`
|
|
6
|
+
${({ status }) => (status === "preEnter" || status === "exiting") && css`
|
|
7
|
+
opacity: 0;
|
|
8
|
+
transform: scale(0.9);
|
|
9
|
+
`};
|
|
10
|
+
position: absolute;
|
|
11
|
+
opacity: 1;
|
|
12
|
+
width: 100%;
|
|
13
|
+
height: 100%;
|
|
14
|
+
background: ${({ theme }) => rgba(theme.colors.grayViolet[3], 0.7)};
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
justify-content: center;
|
|
18
|
+
top: 0;
|
|
19
|
+
left: 0;
|
|
20
|
+
z-index: ${({ zIndex }) => zIndex};
|
|
21
|
+
`;
|
|
22
|
+
const ModalStyled = styled.div.withConfig({
|
|
23
|
+
shouldForwardProp: (props) => !["fullScreen", "size"].includes(props)
|
|
24
|
+
})`
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-direction: column;
|
|
27
|
+
gap: 2rem;
|
|
28
|
+
padding: ${({ theme, size }) => math(`${theme.space[size]} * 2`)};
|
|
29
|
+
background-color: ${({ theme }) => theme.colors.grayViolet[3]};
|
|
30
|
+
border-radius: 0.5rem;
|
|
31
|
+
${({ fullScreen }) => fullScreen && css`
|
|
32
|
+
width: 100%;
|
|
33
|
+
height: 100%;
|
|
34
|
+
`};
|
|
35
|
+
`;
|
|
36
|
+
const ModalHeaderStyled = styled.div`
|
|
37
|
+
display: flex;
|
|
38
|
+
gap: 1rem;
|
|
39
|
+
justify-content: space-between;
|
|
40
|
+
align-items: center;
|
|
41
|
+
`;
|
|
42
|
+
const ModalFooterStyled = styled.div`
|
|
43
|
+
display: flex;
|
|
44
|
+
flex: 0 0 auto;
|
|
45
|
+
gap: 1rem;
|
|
46
|
+
`;
|
|
47
|
+
export {
|
|
48
|
+
ModalContainer,
|
|
49
|
+
ModalFooterStyled,
|
|
50
|
+
ModalHeaderStyled,
|
|
51
|
+
ModalStyled
|
|
52
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { TQuenSize } from '../types/size';
|
|
3
|
+
export interface IModalProps {
|
|
4
|
+
/** Controls modal visibility */
|
|
5
|
+
open: boolean;
|
|
6
|
+
/** Controls width of the content area */
|
|
7
|
+
size?: TQuenSize;
|
|
8
|
+
/** Custom CSS class */
|
|
9
|
+
className?: string;
|
|
10
|
+
/** Custom CSS class for footer */
|
|
11
|
+
classNameFooter?: string;
|
|
12
|
+
/** Header title content */
|
|
13
|
+
title?: React.ReactNode;
|
|
14
|
+
/** Show close (×) button in header */
|
|
15
|
+
closeButton?: boolean;
|
|
16
|
+
/** Full-screen modal */
|
|
17
|
+
fullScreen?: boolean;
|
|
18
|
+
/** Click handler for close button */
|
|
19
|
+
onClickClose?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
20
|
+
/** Base z-index for modal/overlay */
|
|
21
|
+
zIndex?: number;
|
|
22
|
+
/** Callback when ESC key is pressed */
|
|
23
|
+
onEsc?: () => void;
|
|
24
|
+
/** Optional description below the title */
|
|
25
|
+
description?: React.ReactNode;
|
|
26
|
+
/** Main body content */
|
|
27
|
+
children?: React.ReactNode;
|
|
28
|
+
/** Footer content (e.g., buttons) */
|
|
29
|
+
footer?: React.ReactNode;
|
|
30
|
+
[key: string]: any;
|
|
31
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const styles = require("./styles.cjs.js");
|
|
5
|
+
const Title = require("../typography/Title/Title.cjs.js");
|
|
6
|
+
const Text = require("../typography/Text/Text.cjs.js");
|
|
7
|
+
const Flex = require("../Flex/Flex.cjs.js");
|
|
8
|
+
const Button = require("../Button/Button.cjs.js");
|
|
9
|
+
const iconClose = require("../assets/icon-close.svg.cjs.js");
|
|
10
|
+
const iconInfo = require("../assets/icon-info.svg.cjs.js");
|
|
11
|
+
const iconWarning = require("../assets/icon-warning.svg.cjs.js");
|
|
12
|
+
const iconError = require("../assets/icon-error.svg.cjs.js");
|
|
13
|
+
const iconSuccess = require("../assets/icon-success.svg.cjs.js");
|
|
14
|
+
const Loader = require("../Loader/Loader.cjs.js");
|
|
15
|
+
const Notification = ({
|
|
16
|
+
message,
|
|
17
|
+
status = "info",
|
|
18
|
+
title,
|
|
19
|
+
closeButton = true,
|
|
20
|
+
onClose,
|
|
21
|
+
className,
|
|
22
|
+
autoClose = true,
|
|
23
|
+
icon,
|
|
24
|
+
loading,
|
|
25
|
+
...props
|
|
26
|
+
}) => {
|
|
27
|
+
const autoCloseTimeout = React.useRef(-1);
|
|
28
|
+
const IconComponent = React.useMemo(() => {
|
|
29
|
+
if (loading) {
|
|
30
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Loader, { view: "oval" });
|
|
31
|
+
}
|
|
32
|
+
if (typeof icon === "boolean" && icon) {
|
|
33
|
+
switch (status) {
|
|
34
|
+
case "error":
|
|
35
|
+
return /* @__PURE__ */ jsxRuntime.jsx(iconError, { className: "quen-ui__notification-icon" });
|
|
36
|
+
case "info":
|
|
37
|
+
return /* @__PURE__ */ jsxRuntime.jsx(iconInfo, { className: "quen-ui__notification-icon" });
|
|
38
|
+
case "warning":
|
|
39
|
+
return /* @__PURE__ */ jsxRuntime.jsx(iconWarning, { className: "quen-ui__notification-icon" });
|
|
40
|
+
case "success":
|
|
41
|
+
return /* @__PURE__ */ jsxRuntime.jsx(iconSuccess, { className: "quen-ui__notification-icon" });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return icon;
|
|
45
|
+
}, [icon, status]);
|
|
46
|
+
const cancelAutoClose = () => window.clearTimeout(autoCloseTimeout.current);
|
|
47
|
+
const handleAutoClose = () => {
|
|
48
|
+
if (typeof autoClose === "number") {
|
|
49
|
+
autoCloseTimeout.current = window.setTimeout(
|
|
50
|
+
() => onClose == null ? void 0 : onClose({}),
|
|
51
|
+
autoClose
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
if (autoClose) {
|
|
55
|
+
autoCloseTimeout.current = window.setTimeout(() => onClose == null ? void 0 : onClose({}), 5e3);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
React.useEffect(() => {
|
|
59
|
+
handleAutoClose();
|
|
60
|
+
return cancelAutoClose;
|
|
61
|
+
}, [autoClose]);
|
|
62
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(styles.NotificationStyled, { className, status, ...props, children: [
|
|
63
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Flex, { gap: "m", direction: "row", justify: "space-between", align: "center", children: [
|
|
64
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Flex, { gap: "m", align: "center", children: [
|
|
65
|
+
IconComponent,
|
|
66
|
+
title ? /* @__PURE__ */ jsxRuntime.jsx(Title, { size: "xs", children: title }) : /* @__PURE__ */ jsxRuntime.jsx(Text, { size: "s", children: message })
|
|
67
|
+
] }),
|
|
68
|
+
closeButton && /* @__PURE__ */ jsxRuntime.jsx(Button, { view: "icon", size: "s", onClick: () => onClose == null ? void 0 : onClose({}), children: /* @__PURE__ */ jsxRuntime.jsx(iconClose, { width: 16 }) })
|
|
69
|
+
] }),
|
|
70
|
+
title && /* @__PURE__ */ jsxRuntime.jsx(Text, { size: "s", type: "secondary", children: message })
|
|
71
|
+
] });
|
|
72
|
+
};
|
|
73
|
+
module.exports = Notification;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { INotificationParams } from './types';
|
|
3
|
+
declare const Notification: ({ message, status, title, closeButton, onClose, className, autoClose, icon, loading, ...props }: INotificationParams) => React.ReactElement;
|
|
4
|
+
export default Notification;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useMemo, useEffect } from "react";
|
|
3
|
+
import { NotificationStyled } from "./styles.es.js";
|
|
4
|
+
import Title from "../typography/Title/Title.es.js";
|
|
5
|
+
import Text from "../typography/Text/Text.es.js";
|
|
6
|
+
import Flex from "../Flex/Flex.es.js";
|
|
7
|
+
import Button from "../Button/Button.es.js";
|
|
8
|
+
import SvgIconClose from "../assets/icon-close.svg.es.js";
|
|
9
|
+
import SvgIconInfo from "../assets/icon-info.svg.es.js";
|
|
10
|
+
import SvgIconWarning from "../assets/icon-warning.svg.es.js";
|
|
11
|
+
import SvgIconError from "../assets/icon-error.svg.es.js";
|
|
12
|
+
import SvgIconSuccess from "../assets/icon-success.svg.es.js";
|
|
13
|
+
import Loader from "../Loader/Loader.es.js";
|
|
14
|
+
const Notification = ({
|
|
15
|
+
message,
|
|
16
|
+
status = "info",
|
|
17
|
+
title,
|
|
18
|
+
closeButton = true,
|
|
19
|
+
onClose,
|
|
20
|
+
className,
|
|
21
|
+
autoClose = true,
|
|
22
|
+
icon,
|
|
23
|
+
loading,
|
|
24
|
+
...props
|
|
25
|
+
}) => {
|
|
26
|
+
const autoCloseTimeout = useRef(-1);
|
|
27
|
+
const IconComponent = useMemo(() => {
|
|
28
|
+
if (loading) {
|
|
29
|
+
return /* @__PURE__ */ jsx(Loader, { view: "oval" });
|
|
30
|
+
}
|
|
31
|
+
if (typeof icon === "boolean" && icon) {
|
|
32
|
+
switch (status) {
|
|
33
|
+
case "error":
|
|
34
|
+
return /* @__PURE__ */ jsx(SvgIconError, { className: "quen-ui__notification-icon" });
|
|
35
|
+
case "info":
|
|
36
|
+
return /* @__PURE__ */ jsx(SvgIconInfo, { className: "quen-ui__notification-icon" });
|
|
37
|
+
case "warning":
|
|
38
|
+
return /* @__PURE__ */ jsx(SvgIconWarning, { className: "quen-ui__notification-icon" });
|
|
39
|
+
case "success":
|
|
40
|
+
return /* @__PURE__ */ jsx(SvgIconSuccess, { className: "quen-ui__notification-icon" });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return icon;
|
|
44
|
+
}, [icon, status]);
|
|
45
|
+
const cancelAutoClose = () => window.clearTimeout(autoCloseTimeout.current);
|
|
46
|
+
const handleAutoClose = () => {
|
|
47
|
+
if (typeof autoClose === "number") {
|
|
48
|
+
autoCloseTimeout.current = window.setTimeout(
|
|
49
|
+
() => onClose == null ? void 0 : onClose({}),
|
|
50
|
+
autoClose
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
if (autoClose) {
|
|
54
|
+
autoCloseTimeout.current = window.setTimeout(() => onClose == null ? void 0 : onClose({}), 5e3);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
handleAutoClose();
|
|
59
|
+
return cancelAutoClose;
|
|
60
|
+
}, [autoClose]);
|
|
61
|
+
return /* @__PURE__ */ jsxs(NotificationStyled, { className, status, ...props, children: [
|
|
62
|
+
/* @__PURE__ */ jsxs(Flex, { gap: "m", direction: "row", justify: "space-between", align: "center", children: [
|
|
63
|
+
/* @__PURE__ */ jsxs(Flex, { gap: "m", align: "center", children: [
|
|
64
|
+
IconComponent,
|
|
65
|
+
title ? /* @__PURE__ */ jsx(Title, { size: "xs", children: title }) : /* @__PURE__ */ jsx(Text, { size: "s", children: message })
|
|
66
|
+
] }),
|
|
67
|
+
closeButton && /* @__PURE__ */ jsx(Button, { view: "icon", size: "s", onClick: () => onClose == null ? void 0 : onClose({}), children: /* @__PURE__ */ jsx(SvgIconClose, { width: 16 }) })
|
|
68
|
+
] }),
|
|
69
|
+
title && /* @__PURE__ */ jsx(Text, { size: "s", type: "secondary", children: message })
|
|
70
|
+
] });
|
|
71
|
+
};
|
|
72
|
+
export {
|
|
73
|
+
Notification as default
|
|
74
|
+
};
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const reactDom = require("react-dom");
|
|
6
|
+
const helpers = require("@quen-ui/helpers");
|
|
7
|
+
const NotificationsStore = require("./NotificationsStore.cjs.js");
|
|
8
|
+
const styles = require("./styles.cjs.js");
|
|
9
|
+
const Notification = require("./Notification.cjs.js");
|
|
10
|
+
const CONTAINER_NOTIFICATIONS = "quen-ui-notifications";
|
|
11
|
+
const NotificationInstance = () => {
|
|
12
|
+
const [notifications2, setNotifications] = React.useState([]);
|
|
13
|
+
const [element, setElement] = React.useState();
|
|
14
|
+
React.useEffect(() => {
|
|
15
|
+
let _element = document.getElementById(CONTAINER_NOTIFICATIONS);
|
|
16
|
+
if (!_element) {
|
|
17
|
+
_element = document.createElement("div");
|
|
18
|
+
_element.setAttribute("id", CONTAINER_NOTIFICATIONS);
|
|
19
|
+
document.body.appendChild(_element);
|
|
20
|
+
}
|
|
21
|
+
setElement(_element);
|
|
22
|
+
}, []);
|
|
23
|
+
const topNotifications = React.useMemo(
|
|
24
|
+
() => notifications2.filter((notification) => notification.position === "top"),
|
|
25
|
+
[notifications2]
|
|
26
|
+
);
|
|
27
|
+
const topLeftNotifications = React.useMemo(
|
|
28
|
+
() => notifications2.filter(
|
|
29
|
+
(notification) => notification.position === "top-left"
|
|
30
|
+
),
|
|
31
|
+
[notifications2]
|
|
32
|
+
);
|
|
33
|
+
const topRightNotifications = React.useMemo(
|
|
34
|
+
() => notifications2.filter(
|
|
35
|
+
(notification) => notification.position === "top-right"
|
|
36
|
+
),
|
|
37
|
+
[notifications2]
|
|
38
|
+
);
|
|
39
|
+
const bottomNotifications = React.useMemo(
|
|
40
|
+
() => notifications2.filter(
|
|
41
|
+
(notification) => notification.position === "bottom"
|
|
42
|
+
),
|
|
43
|
+
[notifications2]
|
|
44
|
+
);
|
|
45
|
+
const bottomLeftNotifications = React.useMemo(
|
|
46
|
+
() => notifications2.filter(
|
|
47
|
+
(notification) => notification.position === "bottom-left"
|
|
48
|
+
),
|
|
49
|
+
[notifications2]
|
|
50
|
+
);
|
|
51
|
+
const bottomRightNotifications = React.useMemo(
|
|
52
|
+
() => notifications2.filter(
|
|
53
|
+
(notification) => notification.position === "bottom-right"
|
|
54
|
+
),
|
|
55
|
+
[notifications2]
|
|
56
|
+
);
|
|
57
|
+
React.useEffect(() => {
|
|
58
|
+
if (process.env.NODE_ENV !== "production" && element && element.children.length > 1) {
|
|
59
|
+
window.console.error(
|
|
60
|
+
"Warning: You are using two instances NotificationsInstance. Use only one instance per application."
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}, []);
|
|
64
|
+
React.useEffect(() => {
|
|
65
|
+
NotificationsStore.subscribe(updateNotifications);
|
|
66
|
+
return () => {
|
|
67
|
+
NotificationsStore.unsubscribe(updateNotifications);
|
|
68
|
+
element == null ? void 0 : element.remove();
|
|
69
|
+
};
|
|
70
|
+
}, []);
|
|
71
|
+
const updateNotifications = () => {
|
|
72
|
+
setNotifications([...NotificationsStore.data]);
|
|
73
|
+
};
|
|
74
|
+
if (element) {
|
|
75
|
+
return reactDom.createPortal(
|
|
76
|
+
/* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
77
|
+
topNotifications.length ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
78
|
+
styles.NotificationsWrapper,
|
|
79
|
+
{
|
|
80
|
+
zIndex: topNotifications[topNotifications.length - 1].zIndex,
|
|
81
|
+
position: "top",
|
|
82
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: topNotifications.map((notification) => /* @__PURE__ */ React.createElement(
|
|
83
|
+
Notification,
|
|
84
|
+
{
|
|
85
|
+
...notification,
|
|
86
|
+
key: notification.id,
|
|
87
|
+
onClose: () => {
|
|
88
|
+
var _a;
|
|
89
|
+
hideNotification(notification.id);
|
|
90
|
+
(_a = notification.onClose) == null ? void 0 : _a.call(notification, notification);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
)) })
|
|
94
|
+
}
|
|
95
|
+
) : null,
|
|
96
|
+
topLeftNotifications.length ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
97
|
+
styles.NotificationsWrapper,
|
|
98
|
+
{
|
|
99
|
+
zIndex: topLeftNotifications[topLeftNotifications.length - 1].zIndex,
|
|
100
|
+
position: "top-left",
|
|
101
|
+
children: topLeftNotifications.map((notification) => /* @__PURE__ */ React.createElement(
|
|
102
|
+
Notification,
|
|
103
|
+
{
|
|
104
|
+
...notification,
|
|
105
|
+
key: notification.id,
|
|
106
|
+
onClose: () => {
|
|
107
|
+
var _a;
|
|
108
|
+
hideNotification(notification.id);
|
|
109
|
+
(_a = notification.onClose) == null ? void 0 : _a.call(notification, notification);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
))
|
|
113
|
+
}
|
|
114
|
+
) : null,
|
|
115
|
+
topRightNotifications.length ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
116
|
+
styles.NotificationsWrapper,
|
|
117
|
+
{
|
|
118
|
+
position: "top-right",
|
|
119
|
+
zIndex: topRightNotifications[topRightNotifications.length - 1].zIndex,
|
|
120
|
+
children: topRightNotifications.map((notification) => /* @__PURE__ */ React.createElement(
|
|
121
|
+
Notification,
|
|
122
|
+
{
|
|
123
|
+
...notification,
|
|
124
|
+
key: notification.id,
|
|
125
|
+
onClose: () => {
|
|
126
|
+
var _a;
|
|
127
|
+
hideNotification(notification.id);
|
|
128
|
+
(_a = notification.onClose) == null ? void 0 : _a.call(notification, notification);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
))
|
|
132
|
+
}
|
|
133
|
+
) : null,
|
|
134
|
+
bottomNotifications.length ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
135
|
+
styles.NotificationsWrapper,
|
|
136
|
+
{
|
|
137
|
+
position: "bottom",
|
|
138
|
+
zIndex: bottomNotifications[bottomNotifications.length - 1].zIndex,
|
|
139
|
+
children: bottomNotifications.map((notification) => /* @__PURE__ */ React.createElement(
|
|
140
|
+
Notification,
|
|
141
|
+
{
|
|
142
|
+
...notification,
|
|
143
|
+
key: notification.id,
|
|
144
|
+
onClose: () => {
|
|
145
|
+
var _a;
|
|
146
|
+
hideNotification(notification.id);
|
|
147
|
+
(_a = notification.onClose) == null ? void 0 : _a.call(notification, notification);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
))
|
|
151
|
+
}
|
|
152
|
+
) : null,
|
|
153
|
+
bottomLeftNotifications.length ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
154
|
+
styles.NotificationsWrapper,
|
|
155
|
+
{
|
|
156
|
+
position: "bottom-left",
|
|
157
|
+
zIndex: bottomLeftNotifications[bottomLeftNotifications.length - 1].zIndex,
|
|
158
|
+
children: bottomLeftNotifications.map((notification) => /* @__PURE__ */ React.createElement(
|
|
159
|
+
Notification,
|
|
160
|
+
{
|
|
161
|
+
...notification,
|
|
162
|
+
key: notification.id,
|
|
163
|
+
onClose: () => {
|
|
164
|
+
var _a;
|
|
165
|
+
hideNotification(notification.id);
|
|
166
|
+
(_a = notification.onClose) == null ? void 0 : _a.call(notification, notification);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
))
|
|
170
|
+
}
|
|
171
|
+
) : null,
|
|
172
|
+
bottomRightNotifications.length ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
173
|
+
styles.NotificationsWrapper,
|
|
174
|
+
{
|
|
175
|
+
position: "bottom-right",
|
|
176
|
+
zIndex: bottomRightNotifications[bottomRightNotifications.length - 1].zIndex,
|
|
177
|
+
children: bottomRightNotifications.map((notification) => /* @__PURE__ */ React.createElement(
|
|
178
|
+
Notification,
|
|
179
|
+
{
|
|
180
|
+
...notification,
|
|
181
|
+
key: notification.id,
|
|
182
|
+
onClose: () => {
|
|
183
|
+
var _a;
|
|
184
|
+
hideNotification(notification.id);
|
|
185
|
+
(_a = notification.onClose) == null ? void 0 : _a.call(notification, notification);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
))
|
|
189
|
+
}
|
|
190
|
+
) : null
|
|
191
|
+
] }),
|
|
192
|
+
element
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
return null;
|
|
196
|
+
};
|
|
197
|
+
const showNotification = (notification) => {
|
|
198
|
+
const id = notification.id || helpers.randomId();
|
|
199
|
+
let newNotifications = [];
|
|
200
|
+
if (notification.id && NotificationsStore.data.some((n) => n.id === notification.id)) {
|
|
201
|
+
newNotifications = NotificationsStore.data;
|
|
202
|
+
} else {
|
|
203
|
+
newNotifications = [...NotificationsStore.data, { ...notification, id, position: notification.position || "top" }];
|
|
204
|
+
}
|
|
205
|
+
NotificationsStore.updateNotifications(newNotifications);
|
|
206
|
+
return id;
|
|
207
|
+
};
|
|
208
|
+
const hideNotification = (id) => {
|
|
209
|
+
const newNotifications = NotificationsStore.data.filter((notification) => {
|
|
210
|
+
var _a;
|
|
211
|
+
if (notification.id === id) {
|
|
212
|
+
(_a = notification.onClose) == null ? void 0 : _a.call(notification, notification);
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
return true;
|
|
216
|
+
});
|
|
217
|
+
NotificationsStore.updateNotifications(newNotifications);
|
|
218
|
+
return id;
|
|
219
|
+
};
|
|
220
|
+
const updateNotification = (notification) => {
|
|
221
|
+
const newNotifications = NotificationsStore.data.map((n) => {
|
|
222
|
+
if (n.id === notification.id) {
|
|
223
|
+
return { ...n, ...notification };
|
|
224
|
+
}
|
|
225
|
+
return n;
|
|
226
|
+
});
|
|
227
|
+
NotificationsStore.updateNotifications(newNotifications);
|
|
228
|
+
return notification.id;
|
|
229
|
+
};
|
|
230
|
+
const cleanNotifications = () => {
|
|
231
|
+
NotificationsStore.updateNotifications([]);
|
|
232
|
+
};
|
|
233
|
+
const notifications = {
|
|
234
|
+
show: showNotification,
|
|
235
|
+
hide: hideNotification,
|
|
236
|
+
update: updateNotification,
|
|
237
|
+
clean: cleanNotifications
|
|
238
|
+
};
|
|
239
|
+
exports.NotificationInstance = NotificationInstance;
|
|
240
|
+
exports.cleanNotifications = cleanNotifications;
|
|
241
|
+
exports.hideNotification = hideNotification;
|
|
242
|
+
exports.notifications = notifications;
|
|
243
|
+
exports.showNotification = showNotification;
|
|
244
|
+
exports.updateNotification = updateNotification;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { INotificationParams, INotificationsContext } from './types';
|
|
3
|
+
export declare const NotificationInstance: () => React.ReactNode;
|
|
4
|
+
export declare const showNotification: (notification: INotificationParams) => string;
|
|
5
|
+
export declare const hideNotification: (id: string) => string;
|
|
6
|
+
export declare const updateNotification: (notification: Partial<INotificationParams>) => string;
|
|
7
|
+
export declare const cleanNotifications: () => void;
|
|
8
|
+
export declare const notifications: INotificationsContext;
|