UNPKG

myprojectpackageprav

Version:
78 lines 5.23 kB
import { __assign } from "tslib"; import React, { useState, useRef, useEffect } from "react"; import ActionButtons from '../../../components/buttons/actionbutton'; import FileUpload from "../../../components/upload/upload-file"; import InputTextarea from "../../../utils/controls/input-textarea"; import Buttons from "../../../components/buttons/buttons"; var popupTop = ''; var xpositionvalue = ''; var offsetLeftValue = ''; var offsetTopValue = ''; var offsetWidthValue = ''; export default function Adddiscussion() { /***** Responsive Popup Code Start*****/ var adddiscussion = 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({ adddiscussion: false, }), showActionPopups = _c[0], setShowActionPopups = _c[1]; var initialValues = ['adddiscussion']; var _d = useState({ adddiscussion: false, }), btnActionshowhide = _d[0], setActionbtnshowhide = _d[1]; useEffect(function () { setpopupheight(window.innerHeight - (offsetTopValue + 30)); 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; 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(ActionButtons, { label: "Add Discussion", name: 'Add Discussion', className: (btnActionshowhide === null || btnActionshowhide === void 0 ? void 0 : btnActionshowhide.adddiscussion) ? 'btn-border btn btn-xs font-0 font-lg-14 color-primary btn-border-radius3 p-relative popup-arrow ms-auto' : 'btn-border btn btn-xs font-0 font-xl-14 color-primary btn-border-radius3 p-relative ms-auto', icon: "icon-add color-primary font-12 me-xl-1 bold", isClick: 'adddiscussion', type: "button", btnclassName: "ms-auto", ref: adddiscussion, popupCloseOpenFunctionality: popupCloseOpenFunctionality, showhide: showActionPopups.adddiscussion }), (btnActionshowhide === null || btnActionshowhide === void 0 ? void 0 : btnActionshowhide.adddiscussion) ? React.createElement("div", { className: 'popup popup-sm', ref: popupbtnRef, style: { top: popupTop + 8, position: "absolute", overflow: "auto", left: xpositionvalueupdate, maxHeight: popupheight } }, React.createElement("h3", null, "Add Files"), React.createElement("div", { className: "pt-2 text-wrap" }, React.createElement(FileUpload, { label: "Add file (s)", hint: "Hint: Only Files with the following extensions are allowed: .png, .gif, .jpeg, .xlsx, .doc, .pdf, .ppt, .txt, .msg" })), React.createElement("div", { className: "pt-2" }, React.createElement(InputTextarea, { inputProps: { id: 'message', name: 'Message', className: 'font-12', placeholder: 'Message', }, label: 'Message', isMandatory: true, formClassName: "ms-auto form-vertical" })), React.createElement("div", { className: 'pt-2 d-flex gap-2' }, React.createElement(Buttons, { label: "Ok", "aria-label": "Ok", icon: "icon-checked font-12 me-1", className: 'btn btn-sm btn-primary whitetext font-0 font-md-14 btn-border-radius3 ms-auto ' }), React.createElement(ActionButtons, { label: "Cancel", name: "Cancel", className: 'btn-bgcolor5 whitetext btn btn-sm font-0 font-md-14 btn-border-radius3', icon: "icon-close font-10 me-1", type: "button", isClick: 'adddiscussion', ref: adddiscussion, popupCloseOpenFunctionality: popupCloseOpenFunctionality, showhide: showActionPopups.adddiscussion }))) : '')); } //# sourceMappingURL=add-discussion.js.map