@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,244 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect, useMemo, createElement } from "react";
|
|
3
|
+
import { createPortal } from "react-dom";
|
|
4
|
+
import { randomId } from "@quen-ui/helpers";
|
|
5
|
+
import notificationsStore from "./NotificationsStore.es.js";
|
|
6
|
+
import { NotificationsWrapper } from "./styles.es.js";
|
|
7
|
+
import Notification from "./Notification.es.js";
|
|
8
|
+
const CONTAINER_NOTIFICATIONS = "quen-ui-notifications";
|
|
9
|
+
const NotificationInstance = () => {
|
|
10
|
+
const [notifications2, setNotifications] = useState([]);
|
|
11
|
+
const [element, setElement] = useState();
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
let _element = document.getElementById(CONTAINER_NOTIFICATIONS);
|
|
14
|
+
if (!_element) {
|
|
15
|
+
_element = document.createElement("div");
|
|
16
|
+
_element.setAttribute("id", CONTAINER_NOTIFICATIONS);
|
|
17
|
+
document.body.appendChild(_element);
|
|
18
|
+
}
|
|
19
|
+
setElement(_element);
|
|
20
|
+
}, []);
|
|
21
|
+
const topNotifications = useMemo(
|
|
22
|
+
() => notifications2.filter((notification) => notification.position === "top"),
|
|
23
|
+
[notifications2]
|
|
24
|
+
);
|
|
25
|
+
const topLeftNotifications = useMemo(
|
|
26
|
+
() => notifications2.filter(
|
|
27
|
+
(notification) => notification.position === "top-left"
|
|
28
|
+
),
|
|
29
|
+
[notifications2]
|
|
30
|
+
);
|
|
31
|
+
const topRightNotifications = useMemo(
|
|
32
|
+
() => notifications2.filter(
|
|
33
|
+
(notification) => notification.position === "top-right"
|
|
34
|
+
),
|
|
35
|
+
[notifications2]
|
|
36
|
+
);
|
|
37
|
+
const bottomNotifications = useMemo(
|
|
38
|
+
() => notifications2.filter(
|
|
39
|
+
(notification) => notification.position === "bottom"
|
|
40
|
+
),
|
|
41
|
+
[notifications2]
|
|
42
|
+
);
|
|
43
|
+
const bottomLeftNotifications = useMemo(
|
|
44
|
+
() => notifications2.filter(
|
|
45
|
+
(notification) => notification.position === "bottom-left"
|
|
46
|
+
),
|
|
47
|
+
[notifications2]
|
|
48
|
+
);
|
|
49
|
+
const bottomRightNotifications = useMemo(
|
|
50
|
+
() => notifications2.filter(
|
|
51
|
+
(notification) => notification.position === "bottom-right"
|
|
52
|
+
),
|
|
53
|
+
[notifications2]
|
|
54
|
+
);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (process.env.NODE_ENV !== "production" && element && element.children.length > 1) {
|
|
57
|
+
window.console.error(
|
|
58
|
+
"Warning: You are using two instances NotificationsInstance. Use only one instance per application."
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
}, []);
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
notificationsStore.subscribe(updateNotifications);
|
|
64
|
+
return () => {
|
|
65
|
+
notificationsStore.unsubscribe(updateNotifications);
|
|
66
|
+
element == null ? void 0 : element.remove();
|
|
67
|
+
};
|
|
68
|
+
}, []);
|
|
69
|
+
const updateNotifications = () => {
|
|
70
|
+
setNotifications([...notificationsStore.data]);
|
|
71
|
+
};
|
|
72
|
+
if (element) {
|
|
73
|
+
return createPortal(
|
|
74
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
75
|
+
topNotifications.length ? /* @__PURE__ */ jsx(
|
|
76
|
+
NotificationsWrapper,
|
|
77
|
+
{
|
|
78
|
+
zIndex: topNotifications[topNotifications.length - 1].zIndex,
|
|
79
|
+
position: "top",
|
|
80
|
+
children: /* @__PURE__ */ jsx("div", { children: topNotifications.map((notification) => /* @__PURE__ */ createElement(
|
|
81
|
+
Notification,
|
|
82
|
+
{
|
|
83
|
+
...notification,
|
|
84
|
+
key: notification.id,
|
|
85
|
+
onClose: () => {
|
|
86
|
+
var _a;
|
|
87
|
+
hideNotification(notification.id);
|
|
88
|
+
(_a = notification.onClose) == null ? void 0 : _a.call(notification, notification);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
)) })
|
|
92
|
+
}
|
|
93
|
+
) : null,
|
|
94
|
+
topLeftNotifications.length ? /* @__PURE__ */ jsx(
|
|
95
|
+
NotificationsWrapper,
|
|
96
|
+
{
|
|
97
|
+
zIndex: topLeftNotifications[topLeftNotifications.length - 1].zIndex,
|
|
98
|
+
position: "top-left",
|
|
99
|
+
children: topLeftNotifications.map((notification) => /* @__PURE__ */ createElement(
|
|
100
|
+
Notification,
|
|
101
|
+
{
|
|
102
|
+
...notification,
|
|
103
|
+
key: notification.id,
|
|
104
|
+
onClose: () => {
|
|
105
|
+
var _a;
|
|
106
|
+
hideNotification(notification.id);
|
|
107
|
+
(_a = notification.onClose) == null ? void 0 : _a.call(notification, notification);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
))
|
|
111
|
+
}
|
|
112
|
+
) : null,
|
|
113
|
+
topRightNotifications.length ? /* @__PURE__ */ jsx(
|
|
114
|
+
NotificationsWrapper,
|
|
115
|
+
{
|
|
116
|
+
position: "top-right",
|
|
117
|
+
zIndex: topRightNotifications[topRightNotifications.length - 1].zIndex,
|
|
118
|
+
children: topRightNotifications.map((notification) => /* @__PURE__ */ createElement(
|
|
119
|
+
Notification,
|
|
120
|
+
{
|
|
121
|
+
...notification,
|
|
122
|
+
key: notification.id,
|
|
123
|
+
onClose: () => {
|
|
124
|
+
var _a;
|
|
125
|
+
hideNotification(notification.id);
|
|
126
|
+
(_a = notification.onClose) == null ? void 0 : _a.call(notification, notification);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
))
|
|
130
|
+
}
|
|
131
|
+
) : null,
|
|
132
|
+
bottomNotifications.length ? /* @__PURE__ */ jsx(
|
|
133
|
+
NotificationsWrapper,
|
|
134
|
+
{
|
|
135
|
+
position: "bottom",
|
|
136
|
+
zIndex: bottomNotifications[bottomNotifications.length - 1].zIndex,
|
|
137
|
+
children: bottomNotifications.map((notification) => /* @__PURE__ */ createElement(
|
|
138
|
+
Notification,
|
|
139
|
+
{
|
|
140
|
+
...notification,
|
|
141
|
+
key: notification.id,
|
|
142
|
+
onClose: () => {
|
|
143
|
+
var _a;
|
|
144
|
+
hideNotification(notification.id);
|
|
145
|
+
(_a = notification.onClose) == null ? void 0 : _a.call(notification, notification);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
))
|
|
149
|
+
}
|
|
150
|
+
) : null,
|
|
151
|
+
bottomLeftNotifications.length ? /* @__PURE__ */ jsx(
|
|
152
|
+
NotificationsWrapper,
|
|
153
|
+
{
|
|
154
|
+
position: "bottom-left",
|
|
155
|
+
zIndex: bottomLeftNotifications[bottomLeftNotifications.length - 1].zIndex,
|
|
156
|
+
children: bottomLeftNotifications.map((notification) => /* @__PURE__ */ createElement(
|
|
157
|
+
Notification,
|
|
158
|
+
{
|
|
159
|
+
...notification,
|
|
160
|
+
key: notification.id,
|
|
161
|
+
onClose: () => {
|
|
162
|
+
var _a;
|
|
163
|
+
hideNotification(notification.id);
|
|
164
|
+
(_a = notification.onClose) == null ? void 0 : _a.call(notification, notification);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
))
|
|
168
|
+
}
|
|
169
|
+
) : null,
|
|
170
|
+
bottomRightNotifications.length ? /* @__PURE__ */ jsx(
|
|
171
|
+
NotificationsWrapper,
|
|
172
|
+
{
|
|
173
|
+
position: "bottom-right",
|
|
174
|
+
zIndex: bottomRightNotifications[bottomRightNotifications.length - 1].zIndex,
|
|
175
|
+
children: bottomRightNotifications.map((notification) => /* @__PURE__ */ createElement(
|
|
176
|
+
Notification,
|
|
177
|
+
{
|
|
178
|
+
...notification,
|
|
179
|
+
key: notification.id,
|
|
180
|
+
onClose: () => {
|
|
181
|
+
var _a;
|
|
182
|
+
hideNotification(notification.id);
|
|
183
|
+
(_a = notification.onClose) == null ? void 0 : _a.call(notification, notification);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
))
|
|
187
|
+
}
|
|
188
|
+
) : null
|
|
189
|
+
] }),
|
|
190
|
+
element
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
return null;
|
|
194
|
+
};
|
|
195
|
+
const showNotification = (notification) => {
|
|
196
|
+
const id = notification.id || randomId();
|
|
197
|
+
let newNotifications = [];
|
|
198
|
+
if (notification.id && notificationsStore.data.some((n) => n.id === notification.id)) {
|
|
199
|
+
newNotifications = notificationsStore.data;
|
|
200
|
+
} else {
|
|
201
|
+
newNotifications = [...notificationsStore.data, { ...notification, id, position: notification.position || "top" }];
|
|
202
|
+
}
|
|
203
|
+
notificationsStore.updateNotifications(newNotifications);
|
|
204
|
+
return id;
|
|
205
|
+
};
|
|
206
|
+
const hideNotification = (id) => {
|
|
207
|
+
const newNotifications = notificationsStore.data.filter((notification) => {
|
|
208
|
+
var _a;
|
|
209
|
+
if (notification.id === id) {
|
|
210
|
+
(_a = notification.onClose) == null ? void 0 : _a.call(notification, notification);
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
return true;
|
|
214
|
+
});
|
|
215
|
+
notificationsStore.updateNotifications(newNotifications);
|
|
216
|
+
return id;
|
|
217
|
+
};
|
|
218
|
+
const updateNotification = (notification) => {
|
|
219
|
+
const newNotifications = notificationsStore.data.map((n) => {
|
|
220
|
+
if (n.id === notification.id) {
|
|
221
|
+
return { ...n, ...notification };
|
|
222
|
+
}
|
|
223
|
+
return n;
|
|
224
|
+
});
|
|
225
|
+
notificationsStore.updateNotifications(newNotifications);
|
|
226
|
+
return notification.id;
|
|
227
|
+
};
|
|
228
|
+
const cleanNotifications = () => {
|
|
229
|
+
notificationsStore.updateNotifications([]);
|
|
230
|
+
};
|
|
231
|
+
const notifications = {
|
|
232
|
+
show: showNotification,
|
|
233
|
+
hide: hideNotification,
|
|
234
|
+
update: updateNotification,
|
|
235
|
+
clean: cleanNotifications
|
|
236
|
+
};
|
|
237
|
+
export {
|
|
238
|
+
NotificationInstance,
|
|
239
|
+
cleanNotifications,
|
|
240
|
+
hideNotification,
|
|
241
|
+
notifications,
|
|
242
|
+
showNotification,
|
|
243
|
+
updateNotification
|
|
244
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
class NotificationsStore {
|
|
6
|
+
constructor() {
|
|
7
|
+
__publicField(this, "subscribes", []);
|
|
8
|
+
__publicField(this, "notifications", []);
|
|
9
|
+
}
|
|
10
|
+
subscribe(callback) {
|
|
11
|
+
this.subscribes.push(callback);
|
|
12
|
+
}
|
|
13
|
+
unsubscribe(callback) {
|
|
14
|
+
this.subscribes = this.subscribes.filter(
|
|
15
|
+
(subscriber) => subscriber === callback ? void 0 : subscriber
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
notify() {
|
|
19
|
+
this.subscribes.forEach((subscriber) => subscriber());
|
|
20
|
+
}
|
|
21
|
+
updateNotifications(notifications) {
|
|
22
|
+
this.notifications = notifications;
|
|
23
|
+
this.notify();
|
|
24
|
+
}
|
|
25
|
+
get data() {
|
|
26
|
+
return this.notifications;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const notificationsStore = new NotificationsStore();
|
|
30
|
+
module.exports = notificationsStore;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { INotificationParams } from './types';
|
|
2
|
+
type TNotificationSubscribe = () => void;
|
|
3
|
+
declare class NotificationsStore {
|
|
4
|
+
private subscribes;
|
|
5
|
+
private notifications;
|
|
6
|
+
subscribe(callback: TNotificationSubscribe): void;
|
|
7
|
+
unsubscribe(callback: TNotificationSubscribe): void;
|
|
8
|
+
private notify;
|
|
9
|
+
updateNotifications(notifications: INotificationParams[]): void;
|
|
10
|
+
get data(): INotificationParams[];
|
|
11
|
+
}
|
|
12
|
+
declare const _default: NotificationsStore;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
class NotificationsStore {
|
|
5
|
+
constructor() {
|
|
6
|
+
__publicField(this, "subscribes", []);
|
|
7
|
+
__publicField(this, "notifications", []);
|
|
8
|
+
}
|
|
9
|
+
subscribe(callback) {
|
|
10
|
+
this.subscribes.push(callback);
|
|
11
|
+
}
|
|
12
|
+
unsubscribe(callback) {
|
|
13
|
+
this.subscribes = this.subscribes.filter(
|
|
14
|
+
(subscriber) => subscriber === callback ? void 0 : subscriber
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
notify() {
|
|
18
|
+
this.subscribes.forEach((subscriber) => subscriber());
|
|
19
|
+
}
|
|
20
|
+
updateNotifications(notifications) {
|
|
21
|
+
this.notifications = notifications;
|
|
22
|
+
this.notify();
|
|
23
|
+
}
|
|
24
|
+
get data() {
|
|
25
|
+
return this.notifications;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const notificationsStore = new NotificationsStore();
|
|
29
|
+
export {
|
|
30
|
+
notificationsStore as default
|
|
31
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const styled = require("styled-components");
|
|
4
|
+
const getBackgroundStatus = (theme, status) => {
|
|
5
|
+
switch (status) {
|
|
6
|
+
case "info":
|
|
7
|
+
return theme.colors.violet["9"];
|
|
8
|
+
case "warning":
|
|
9
|
+
return theme.colors.orange["9"];
|
|
10
|
+
case "error":
|
|
11
|
+
return theme.colors.red["9"];
|
|
12
|
+
case "success":
|
|
13
|
+
return theme.colors.green["9"];
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const getPosition = (theme, position) => {
|
|
17
|
+
switch (position) {
|
|
18
|
+
case "top":
|
|
19
|
+
return styled.css`
|
|
20
|
+
top: ${theme.space.m};
|
|
21
|
+
left: 50%;
|
|
22
|
+
transform: translateX(-50%);
|
|
23
|
+
`;
|
|
24
|
+
case "top-left":
|
|
25
|
+
return styled.css`
|
|
26
|
+
top: ${theme.space.m};
|
|
27
|
+
left: ${theme.space.m};
|
|
28
|
+
`;
|
|
29
|
+
case "top-right":
|
|
30
|
+
return styled.css`
|
|
31
|
+
top: ${theme.space.m};
|
|
32
|
+
right: ${theme.space.m};
|
|
33
|
+
`;
|
|
34
|
+
case "bottom":
|
|
35
|
+
return styled.css`
|
|
36
|
+
bottom: ${theme.space.m};
|
|
37
|
+
left: 50%;
|
|
38
|
+
transform: translateX(-50%);
|
|
39
|
+
`;
|
|
40
|
+
case "bottom-left":
|
|
41
|
+
return styled.css`
|
|
42
|
+
bottom: ${theme.space.m};
|
|
43
|
+
left: ${theme.space.m};
|
|
44
|
+
`;
|
|
45
|
+
case "bottom-right":
|
|
46
|
+
return styled.css`
|
|
47
|
+
bottom: ${theme.space.m};
|
|
48
|
+
right: ${theme.space.m};
|
|
49
|
+
`;
|
|
50
|
+
}
|
|
51
|
+
return styled.css``;
|
|
52
|
+
};
|
|
53
|
+
const NotificationsWrapper = styled.div.withConfig({
|
|
54
|
+
shouldForwardProp: (props) => !["position", "zIndex"].includes(props)
|
|
55
|
+
})`
|
|
56
|
+
width: calc(100% - ${({ theme }) => theme.space.m} * 2);
|
|
57
|
+
position: fixed;
|
|
58
|
+
z-index: ${({ zIndex = 2e3 }) => zIndex};
|
|
59
|
+
${({ position, theme }) => getPosition(theme, position)};
|
|
60
|
+
max-width: 384px;
|
|
61
|
+
`;
|
|
62
|
+
const NotificationStyled = styled.div.withConfig({
|
|
63
|
+
shouldForwardProp: (props) => !["status"].includes(props)
|
|
64
|
+
})`
|
|
65
|
+
width: 384px;
|
|
66
|
+
position: relative;
|
|
67
|
+
border-radius: ${({ theme }) => theme.control.radius};
|
|
68
|
+
padding: ${({ theme }) => theme.space.m};
|
|
69
|
+
background: ${({ theme }) => theme.colors.grayViolet["2"]};
|
|
70
|
+
margin-bottom: ${({ theme }) => theme.space.m};
|
|
71
|
+
|
|
72
|
+
.quen-ui__notification-icon {
|
|
73
|
+
color: ${({ theme, status = "info" }) => getBackgroundStatus(theme, status)};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
${({ status, theme }) => status && styled.css`
|
|
77
|
+
&:before {
|
|
78
|
+
content: "";
|
|
79
|
+
display: block;
|
|
80
|
+
position: absolute;
|
|
81
|
+
width: ${theme.space.xs};
|
|
82
|
+
top: 0;
|
|
83
|
+
bottom: 0;
|
|
84
|
+
inset-inline-start: 0;
|
|
85
|
+
background-color: ${getBackgroundStatus(theme, status)};
|
|
86
|
+
}
|
|
87
|
+
`}
|
|
88
|
+
`;
|
|
89
|
+
exports.NotificationStyled = NotificationStyled;
|
|
90
|
+
exports.NotificationsWrapper = NotificationsWrapper;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { INotificationParams } from './types';
|
|
2
|
+
export declare const NotificationsWrapper: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
3
|
+
zIndex?: number;
|
|
4
|
+
position: INotificationParams["position"];
|
|
5
|
+
}>> & string;
|
|
6
|
+
export declare const NotificationStyled: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
7
|
+
status: INotificationParams["status"];
|
|
8
|
+
}>> & string;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
const getBackgroundStatus = (theme, status) => {
|
|
3
|
+
switch (status) {
|
|
4
|
+
case "info":
|
|
5
|
+
return theme.colors.violet["9"];
|
|
6
|
+
case "warning":
|
|
7
|
+
return theme.colors.orange["9"];
|
|
8
|
+
case "error":
|
|
9
|
+
return theme.colors.red["9"];
|
|
10
|
+
case "success":
|
|
11
|
+
return theme.colors.green["9"];
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const getPosition = (theme, position) => {
|
|
15
|
+
switch (position) {
|
|
16
|
+
case "top":
|
|
17
|
+
return css`
|
|
18
|
+
top: ${theme.space.m};
|
|
19
|
+
left: 50%;
|
|
20
|
+
transform: translateX(-50%);
|
|
21
|
+
`;
|
|
22
|
+
case "top-left":
|
|
23
|
+
return css`
|
|
24
|
+
top: ${theme.space.m};
|
|
25
|
+
left: ${theme.space.m};
|
|
26
|
+
`;
|
|
27
|
+
case "top-right":
|
|
28
|
+
return css`
|
|
29
|
+
top: ${theme.space.m};
|
|
30
|
+
right: ${theme.space.m};
|
|
31
|
+
`;
|
|
32
|
+
case "bottom":
|
|
33
|
+
return css`
|
|
34
|
+
bottom: ${theme.space.m};
|
|
35
|
+
left: 50%;
|
|
36
|
+
transform: translateX(-50%);
|
|
37
|
+
`;
|
|
38
|
+
case "bottom-left":
|
|
39
|
+
return css`
|
|
40
|
+
bottom: ${theme.space.m};
|
|
41
|
+
left: ${theme.space.m};
|
|
42
|
+
`;
|
|
43
|
+
case "bottom-right":
|
|
44
|
+
return css`
|
|
45
|
+
bottom: ${theme.space.m};
|
|
46
|
+
right: ${theme.space.m};
|
|
47
|
+
`;
|
|
48
|
+
}
|
|
49
|
+
return css``;
|
|
50
|
+
};
|
|
51
|
+
const NotificationsWrapper = styled.div.withConfig({
|
|
52
|
+
shouldForwardProp: (props) => !["position", "zIndex"].includes(props)
|
|
53
|
+
})`
|
|
54
|
+
width: calc(100% - ${({ theme }) => theme.space.m} * 2);
|
|
55
|
+
position: fixed;
|
|
56
|
+
z-index: ${({ zIndex = 2e3 }) => zIndex};
|
|
57
|
+
${({ position, theme }) => getPosition(theme, position)};
|
|
58
|
+
max-width: 384px;
|
|
59
|
+
`;
|
|
60
|
+
const NotificationStyled = styled.div.withConfig({
|
|
61
|
+
shouldForwardProp: (props) => !["status"].includes(props)
|
|
62
|
+
})`
|
|
63
|
+
width: 384px;
|
|
64
|
+
position: relative;
|
|
65
|
+
border-radius: ${({ theme }) => theme.control.radius};
|
|
66
|
+
padding: ${({ theme }) => theme.space.m};
|
|
67
|
+
background: ${({ theme }) => theme.colors.grayViolet["2"]};
|
|
68
|
+
margin-bottom: ${({ theme }) => theme.space.m};
|
|
69
|
+
|
|
70
|
+
.quen-ui__notification-icon {
|
|
71
|
+
color: ${({ theme, status = "info" }) => getBackgroundStatus(theme, status)};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
${({ status, theme }) => status && css`
|
|
75
|
+
&:before {
|
|
76
|
+
content: "";
|
|
77
|
+
display: block;
|
|
78
|
+
position: absolute;
|
|
79
|
+
width: ${theme.space.xs};
|
|
80
|
+
top: 0;
|
|
81
|
+
bottom: 0;
|
|
82
|
+
inset-inline-start: 0;
|
|
83
|
+
background-color: ${getBackgroundStatus(theme, status)};
|
|
84
|
+
}
|
|
85
|
+
`}
|
|
86
|
+
`;
|
|
87
|
+
export {
|
|
88
|
+
NotificationStyled,
|
|
89
|
+
NotificationsWrapper
|
|
90
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export declare const NOTIFICATION_STATUSES: readonly ["success", "warning", "error", "info"];
|
|
3
|
+
export type TNotificationStatus = (typeof NOTIFICATION_STATUSES)[number];
|
|
4
|
+
export interface INotificationsContext {
|
|
5
|
+
/** Displays new notification */
|
|
6
|
+
show: (notification: INotificationParams) => string;
|
|
7
|
+
/** Removes specific notification */
|
|
8
|
+
hide: (id: string) => string;
|
|
9
|
+
/** Updates existing notification */
|
|
10
|
+
update: (notification: Partial<INotificationParams>) => string;
|
|
11
|
+
/** Clears all notifications */
|
|
12
|
+
clean: () => void;
|
|
13
|
+
}
|
|
14
|
+
export type TNotificationPosition = "top-left" | "top-right" | "top" | "bottom-left" | "bottom-right" | "bottom";
|
|
15
|
+
export interface INotificationParams {
|
|
16
|
+
/** Unique notification identifier */
|
|
17
|
+
id?: string;
|
|
18
|
+
/** Display position */
|
|
19
|
+
position?: TNotificationPosition;
|
|
20
|
+
/** Bold header text (supports JSX) */
|
|
21
|
+
title?: React.ReactNode;
|
|
22
|
+
/** Primary content (supports JSX) */
|
|
23
|
+
message?: React.ReactNode;
|
|
24
|
+
/** Shows loading spinner (overrides icon) */
|
|
25
|
+
loading?: boolean;
|
|
26
|
+
/** Close delay (ms) or false to disable */
|
|
27
|
+
autoClose?: boolean | number;
|
|
28
|
+
/** Callback when notification closes */
|
|
29
|
+
onClose?: (params: INotificationParams) => void;
|
|
30
|
+
/** Visual status type */
|
|
31
|
+
status?: TNotificationStatus;
|
|
32
|
+
/** Shows/hides close button */
|
|
33
|
+
closeButton?: boolean;
|
|
34
|
+
/** Stacking context */
|
|
35
|
+
zIndex?: number;
|
|
36
|
+
/** Custom container class */
|
|
37
|
+
className?: string;
|
|
38
|
+
/** Custom icon or false to hide */
|
|
39
|
+
icon?: true | React.ReactNode;
|
|
40
|
+
[key: string]: any;
|
|
41
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const styles = require("./styles.cjs.js");
|
|
4
|
+
const Text = require("../typography/Text/Text.cjs.js");
|
|
5
|
+
const Flex = require("../Flex/Flex.cjs.js");
|
|
6
|
+
const Progress = ({
|
|
7
|
+
value,
|
|
8
|
+
size = "m",
|
|
9
|
+
label,
|
|
10
|
+
showInfo,
|
|
11
|
+
color = "violet",
|
|
12
|
+
className,
|
|
13
|
+
style,
|
|
14
|
+
...props
|
|
15
|
+
}) => {
|
|
16
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
17
|
+
styles.ProgressWrapper,
|
|
18
|
+
{
|
|
19
|
+
className,
|
|
20
|
+
style,
|
|
21
|
+
role: "progressbar",
|
|
22
|
+
"aria-valuenow": value,
|
|
23
|
+
"aria-valuemin": 0,
|
|
24
|
+
"aria-valuemax": 100,
|
|
25
|
+
...props,
|
|
26
|
+
children: [
|
|
27
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Flex, { gap: 8, align: "center", children: [
|
|
28
|
+
/* @__PURE__ */ jsxRuntime.jsx(styles.ProgressStyled, { size, color, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
29
|
+
styles.ProgressBarStyled,
|
|
30
|
+
{
|
|
31
|
+
role: "progressbar",
|
|
32
|
+
color,
|
|
33
|
+
style: { width: `${value}%` }
|
|
34
|
+
}
|
|
35
|
+
) }),
|
|
36
|
+
showInfo && /* @__PURE__ */ jsxRuntime.jsx(Text, { size, children: `${value}%` })
|
|
37
|
+
] }),
|
|
38
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(styles.ProgressLabelStyled, { size, color, children: label })
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
module.exports = Progress;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ProgressWrapper, ProgressStyled, ProgressBarStyled, ProgressLabelStyled } from "./styles.es.js";
|
|
3
|
+
import Text from "../typography/Text/Text.es.js";
|
|
4
|
+
import Flex from "../Flex/Flex.es.js";
|
|
5
|
+
const Progress = ({
|
|
6
|
+
value,
|
|
7
|
+
size = "m",
|
|
8
|
+
label,
|
|
9
|
+
showInfo,
|
|
10
|
+
color = "violet",
|
|
11
|
+
className,
|
|
12
|
+
style,
|
|
13
|
+
...props
|
|
14
|
+
}) => {
|
|
15
|
+
return /* @__PURE__ */ jsxs(
|
|
16
|
+
ProgressWrapper,
|
|
17
|
+
{
|
|
18
|
+
className,
|
|
19
|
+
style,
|
|
20
|
+
role: "progressbar",
|
|
21
|
+
"aria-valuenow": value,
|
|
22
|
+
"aria-valuemin": 0,
|
|
23
|
+
"aria-valuemax": 100,
|
|
24
|
+
...props,
|
|
25
|
+
children: [
|
|
26
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 8, align: "center", children: [
|
|
27
|
+
/* @__PURE__ */ jsx(ProgressStyled, { size, color, children: /* @__PURE__ */ jsx(
|
|
28
|
+
ProgressBarStyled,
|
|
29
|
+
{
|
|
30
|
+
role: "progressbar",
|
|
31
|
+
color,
|
|
32
|
+
style: { width: `${value}%` }
|
|
33
|
+
}
|
|
34
|
+
) }),
|
|
35
|
+
showInfo && /* @__PURE__ */ jsx(Text, { size, children: `${value}%` })
|
|
36
|
+
] }),
|
|
37
|
+
label && /* @__PURE__ */ jsx(ProgressLabelStyled, { size, color, children: label })
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
export {
|
|
43
|
+
Progress as default
|
|
44
|
+
};
|