UNPKG

myprojectpackageprav

Version:
113 lines 7.33 kB
import { __assign } from "tslib"; import React, { useState, useRef, useEffect } from "react"; import ActionButtons from '../buttons/actionbutton'; import InputSelect from "../../utils/controls/input-select"; import Notificationtabcontent from "./notification-items"; import "./notifications.css"; import Tabs from "../tabs/tabs"; var popupTop = ''; var xpositionvalue = ''; var offsetLeftValue = ''; var offsetTopValue = ''; var elementHeightValue = ''; var offsetWidthValue = ''; export default function Notifications() { var notification_items = [ { tabtitle: 'All (08)', is_active: "true", content: (React.createElement(React.Fragment, null, React.createElement(Notificationtabcontent, { tabId: "all" }))) }, { tabtitle: 'Actions (02)', is_active: "false", content: (React.createElement(React.Fragment, null, React.createElement(Notificationtabcontent, { tabId: "actions" }))) }, { tabtitle: 'Notifications (06)', is_active: "false", content: (React.createElement(React.Fragment, null, React.createElement(Notificationtabcontent, { tabId: "notifications" }))) } ]; /***** Responsive Popup Code Start*****/ var notification = useRef(null); var popupbtnRef = useRef(null); var _a = useState(''), xpositionvalueupdate = _a[0], setpopupwidthupdate = _a[1]; var _b = useState(''), popupheight = _b[0], setpopupheight = _b[1]; var _c = useState({ notification: false, }), showActionPopups = _c[0], setShowActionPopups = _c[1]; var initialValues = ['notification']; var _d = useState({ notification: false, }), btnActionshowhide = _d[0], setActionbtnshowhide = _d[1]; useEffect(function () { setpopupheight(window.innerHeight - (offsetTopValue + 58)); var popupwidthdata = popupbtnRef.current ? popupbtnRef.current.offsetWidth : 0; // setpopupwidth(popupwidthdata) if (popupwidthdata < xpositionvalue) { xpositionvalue = xpositionvalue - popupwidthdata; setpopupwidthupdate(xpositionvalue); } else if (popupwidthdata > offsetLeftValue && popupwidthdata < (window.innerWidth - (offsetLeftValue + offsetWidthValue))) { xpositionvalue = offsetLeftValue; setpopupwidthupdate(xpositionvalue); } else if (popupwidthdata > offsetLeftValue && popupwidthdata > (window.innerWidth - (offsetLeftValue + offsetWidthValue))) { xpositionvalue = 0; setpopupwidthupdate(xpositionvalue); } }, [showActionPopups]); var showhide = __assign({}, btnActionshowhide); function popupCloseOpenFunctionality(type, value, top, xposition, left, Ref, elementHeight, offsetWidth) { var _a, _b; popupTop = top; xpositionvalue = xposition; offsetLeftValue = left; offsetTopValue = top; elementHeightValue = elementHeight; offsetWidthValue = offsetWidth; initialValues.forEach(function (element) { showhide[element] = false; }); setActionbtnshowhide(showhide); if (type) { setActionbtnshowhide(__assign(__assign({}, showhide), (_a = {}, _a[type] = value, _a))); setShowActionPopups(__assign(__assign({}, showhide), (_b = {}, _b[type] = value, _b))); } } return (React.createElement(React.Fragment, null, React.createElement("div", { className: "notification" }, React.createElement(ActionButtons, { label: "Notifications", name: '', className: (btnActionshowhide === null || btnActionshowhide === void 0 ? void 0 : btnActionshowhide.notification) ? 'btn btn-sm p-0 p-relative popup-arrow' : 'btn btn-sm p-0 p-relative', icon: "icon-bell font-16 darktext bold", isClick: 'notification', type: "button", badgeinfo: "22", badge: "badge bgcolor-primary border-radius3 px-1 font-10 whitetext", ref: notification, popupCloseOpenFunctionality: popupCloseOpenFunctionality, showhide: showActionPopups.notification, props: undefined, inputProps: undefined, onClick: undefined, reference: undefined, btnclassName: undefined, id: undefined, ricon: undefined, "aria-label": undefined }), (btnActionshowhide === null || btnActionshowhide === void 0 ? void 0 : btnActionshowhide.notification) ? React.createElement("div", { className: 'popup', ref: popupbtnRef, style: { top: popupTop + 8, position: "absolute", overflow: "auto", left: xpositionvalueupdate, maxHeight: popupheight } }, React.createElement("div", { className: "d-flex w-100 p-relative align-items-center border-bottom1 pb-1" }, React.createElement("h2", { tabIndex: 0, "aria-label": "Alerts", className: "d-flex font-16" }, React.createElement("span", { className: "icon-bell pe-1" }), " Alerts"), React.createElement("div", { className: "d-flex align-items-center ms-auto" }, React.createElement("div", { className: "d-flex align-items-center ms-1" }, React.createElement(InputSelect, { inputProps: { id: 'FilterBy', name: 'Filter By', placeholder: 'Select', className: 'font-11' }, label: 'Filter By', type: 'select', className: 'font-11 form-xs', formClassName: "ms-auto form-horizontal" })), React.createElement("div", { className: "d-flex align-items-center ms-1 mb-1" }, React.createElement(InputSelect, { inputProps: { id: 'Date', name: 'Date', placeholder: 'Select', className: 'font-11' }, label: 'Date', type: 'select', className: 'font-11 form-xs', formClassName: "form-horizontal" })), React.createElement("div", { className: "font-11 links ms-1" }, "days")), React.createElement("div", { className: 'close' }, React.createElement(ActionButtons, { label: "Cancel", name: "", className: 'btn-bgcolor6 whitetext p-0 btn btn-sm font-0 btn-border-radius3', icon: "icon-close font-8 p-1", type: "button", isClick: 'notification', ref: notification, popupCloseOpenFunctionality: popupCloseOpenFunctionality, showhide: showActionPopups.notification, props: undefined, inputProps: undefined, onClick: undefined, reference: undefined, btnclassName: undefined, id: undefined, badgeinfo: undefined, badge: undefined, ricon: undefined, "aria-label": undefined }))), React.createElement("div", null, React.createElement(Tabs, { items: notification_items, contentstyles: "pe-1", anchorclassName: "darktext", className: "latobold darktext", tablistclassName: "font-13" }))) : ''))); } //# sourceMappingURL=notifications.js.map