UNPKG

@zohodesk/dot

Version:

In this Library, we Provide Some Basic Components to Build Your Application

713 lines (639 loc) 34.5 kB
"use strict"; function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _react = _interopRequireWildcard(require("react")); var _defaultProps = require("./props/defaultProps"); var _propTypes = require("./props/propTypes"); var _Layout = require("@zohodesk/components/es/v1/Layout"); var _icons = require("@zohodesk/icons"); var _Avatar = _interopRequireDefault(require("@zohodesk/components/es/v1/Avatar/Avatar")); var _CustomResponsive = require("@zohodesk/components/es/Responsive/CustomResponsive"); var _IdProvider = require("@zohodesk/components/es/Provider/IdProvider"); var _AttachmentImage = _interopRequireDefault(require("./AttachmentImage")); var _Link = _interopRequireDefault(require("../Link/Link")); var _IconButton = _interopRequireDefault(require("../IconButton/IconButton")); var _FreezeLayer = _interopRequireDefault(require("../FreezeLayer/FreezeLayer")); var _Attachment = require("../../AttachmentViewer/Attachment"); var _utils = require("../../AttachmentViewer/utils"); var _audio_thumbnail = _interopRequireDefault(require("../../../images/audio_thumbnail.png")); var _General = require("../../utils/General"); var _AttachmentViewerModule = _interopRequireDefault(require("../../AttachmentViewer/AttachmentViewer.module.css")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } var AttachmentViewer = /*#__PURE__*/function (_Component) { _inherits(AttachmentViewer, _Component); var _super = _createSuper(AttachmentViewer); function AttachmentViewer(props) { var _this; _classCallCheck(this, AttachmentViewer); _this = _super.call(this, props); _this.state = { isPViewListOpen: !!(_this.props.previewObj && _this.props.previewObj.previewData), selectedIndex: _this.props.previewObj.selectedIndex, isZoomed: false, data: _this.props.previewObj ? _this.props.previewObj.previewData : [], dataList: _this.getUpdateDataList({ index: _this.props.previewObj.selectedIndex, data: _this.props.previewObj ? _this.props.previewObj.previewData : [], dataList: [] }), canOpenInNewTab: false, canZoom: false, isPreviewAttachmentValid: false }; _this.togglePViewList = _this.togglePViewList.bind(_assertThisInitialized(_this)); _this.changeSelectedIndex = _this.changeSelectedIndex.bind(_assertThisInitialized(_this)); _this.closeAttachmentViewer = _this.closeAttachmentViewer.bind(_assertThisInitialized(_this)); _this.responsiveFunc = _this.responsiveFunc.bind(_assertThisInitialized(_this)); _this.zoomIn = _this.zoomIn.bind(_assertThisInitialized(_this)); _this.zoomOut = _this.zoomOut.bind(_assertThisInitialized(_this)); _this.imgPreviewView = _this.imgPreviewView.bind(_assertThisInitialized(_this)); _this.getNextId = (0, _IdProvider.getUniqueId)(_assertThisInitialized(_this)); _this.getUpdateDataList = _this.getUpdateDataList.bind(_assertThisInitialized(_this)); _this.zoomMaintain = _this.zoomMaintain.bind(_assertThisInitialized(_this)); _this.handleMenuValidation = _this.handleMenuValidation.bind(_assertThisInitialized(_this)); return _this; } _createClass(AttachmentViewer, [{ key: "componentDidMount", value: function componentDidMount() { this.handleMenuValidation(); } }, { key: "componentDidUpdate", value: function componentDidUpdate(prevProps, prevState) { var previewObj = this.props.previewObj; var selectedIndex = this.state.selectedIndex; var indexChanged = previewObj.selectedIndex != prevProps.previewObj.selectedIndex; if (previewObj.previewData.length != prevProps.previewObj.previewData.length || indexChanged) { var objChanged = previewObj.previewData.some(function (value, index) { return (0, _General.shallowDiff)(value, prevProps.previewObj[index]); }); if (objChanged || indexChanged) { this.setState({ selectedIndex: previewObj.selectedIndex, data: previewObj ? previewObj.previewData : [], dataList: this.getUpdateDataList({ index: previewObj.selectedIndex, data: previewObj ? previewObj.previewData : [], dataList: [] }), isPViewListOpen: !!(this.props.previewObj && this.props.previewObj.previewData) }); } } if (prevState.selectedIndex != selectedIndex) { this.handleMenuValidation(); } } }, { key: "handleMenuValidation", value: function handleMenuValidation() { var _this2 = this; var _this$state = this.state, data = _this$state.data, selectedIndex = _this$state.selectedIndex; var selectedAttachment = data[selectedIndex] || {}; var selectedAttachmentViewUrl = selectedAttachment.viewUrl; var selectedAttachmentDownloadUrl = selectedAttachment.downloadUrl; var selectedAttachmentName = selectedAttachment.name; (0, _utils.checkFileSourcesValidation)({ fileName: selectedAttachmentName, viewURL: selectedAttachmentViewUrl }).then(function (fileSourceValidation) { var isViewURLValid = fileSourceValidation.isViewURLValid, canZoom = fileSourceValidation.canZoom; _this2.setState({ isPreviewAttachmentValid: isViewURLValid, canZoom: canZoom, canOpenInNewTab: isViewURLValid }); }); } }, { key: "togglePViewList", value: function togglePViewList() { var _this3 = this; this.setState(function (prevState) { return { isPViewListOpen: !prevState.isPViewListOpen }; }, function () { _this3.focusSelectedImg(_this3.state.selectedIndex); }); } }, { key: "zoomOut", value: function zoomOut(ele) { this.setState({ isZoomed: false }); // const img = document.getElementById(`img${ele}`); // if (img) { // img.classList.remove(style.zoomedImg); // img.classList.add(style.normalImg); // } } }, { key: "zoomIn", value: function zoomIn(event, ele) { var moveToPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; this.setState({ isZoomed: true }); var img = document.getElementById("img".concat(ele)); var ratio = 95; var imgContainer, imgUnits, imgSize, imgRatio, imgContainerUnits, imgContainerPosition; if (moveToPosition) { imgContainer = document.getElementById("imgBox".concat(ele)); imgUnits = img.getBoundingClientRect(); imgSize = { height: img.naturalHeight, width: img.naturalWidth }; imgRatio = { height: Math.floor(imgSize.height / imgUnits.height / 100 * ratio), width: Math.floor(imgSize.width / imgUnits.width / 100 * ratio) }; imgContainerUnits = imgContainer.getBoundingClientRect(); imgContainerPosition = imgContainer ? { top: imgContainerUnits.top, left: imgContainerUnits.left } : { top: 0, left: 0 }; } // if (img) { // img.classList.remove(style.normalImg); // img.classList.add(style.zoomedImg); // } if (moveToPosition) { imgContainer.scrollLeft = (event.pageX - imgContainerPosition.left - imgUnits.left) * imgRatio.width; imgContainer.scrollTop = (event.pageY - imgContainerPosition.top - imgUnits.top) * imgRatio.height; } } }, { key: "zoomMaintain", value: function zoomMaintain(selectedIndex) { var isZoomed = this.state.isZoomed; isZoomed ? this.zoomIn({}, selectedIndex) : this.zoomOut(selectedIndex); } }, { key: "getUpdateDataList", value: function getUpdateDataList(_ref) { var index = _ref.index, data = _ref.data, dataList = _ref.dataList; data = data || this.state.data; dataList = dataList || this.state.dataList; var finalDataList = _toConsumableArray(dataList); if (index >= finalDataList.length) { for (var i = dataList.length; i <= index; i++) { finalDataList.push(data.slice(i)[0]); } } else if (index + 1 === finalDataList.length && index + 1 < data.length) { finalDataList.push(data.slice(index + 1)[0]); } return finalDataList; } }, { key: "updateDataList", value: function updateDataList(index) { this.setState({ dataList: this.getUpdateDataList({ index: index }) }); } }, { key: "changeSelectedIndex", value: function changeSelectedIndex(index) { var _this4 = this; var _this$state2 = this.state, data = _this$state2.data, selectedIndex = _this$state2.selectedIndex; var maintainZoom = this.props.maintainZoom; maintainZoom ? this.zoomMaintain(index) : this.zoomOut(selectedIndex); if (index <= data.length - 1) { this.updateDataList(index); } this.setState({ selectedIndex: index }, function () { _this4.focusSelectedImg(index); }); } }, { key: "focusSelectedImg", value: function focusSelectedImg(index) { var ele = this["img_".concat(index)]; if (ele) { var cont = this.imgListCont; cont.scrollLeft = ele.offsetLeft; } } }, { key: "closeAttachmentViewer", value: function closeAttachmentViewer() { this.setState({ isPViewListOpen: false, isZoomed: false }); this.props.hideAttachmentViewer(); } }, { key: "responsiveFunc", value: function responsiveFunc(_ref2) { var mediaQueryOR = _ref2.mediaQueryOR; return { uptoTablet: mediaQueryOR([{ maxWidth: 768 }]) }; } }, { key: "imgPreviewView", value: function imgPreviewView() { var _this5 = this; var _this$state3 = this.state, dataList = _this$state3.dataList, selectedIndex = _this$state3.selectedIndex, isZoomed = _this$state3.isZoomed, canZoom = _this$state3.canZoom, isPreviewAttachmentValid = _this$state3.isPreviewAttachmentValid; var _this$props = this.props, maintainZoom = _this$props.maintainZoom, dataId = _this$props.dataId; var getImgStyle = function getImgStyle(i) { var position; if (selectedIndex < i) { position = (i - selectedIndex) * 100; return { transform: "translateX(".concat(parseInt(position), "%)"), opacity: '0' }; } if (i === selectedIndex) { return { transform: 'translateX(0%)', opacity: '1' }; } position = (selectedIndex - i) * 100 * -1; return { transform: "translateX(".concat(parseInt(position), "%)"), opacity: '0' }; }; return dataList.length && dataList.map(function () { var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var i = arguments.length > 1 ? arguments[1] : undefined; var viewUrl = data.viewUrl, name = data.name, children = data.children, _data$dataId = data.dataId, dataId = _data$dataId === void 0 ? 'attachViewer' : _data$dataId, _data$customClass = data.customClass, customClass = _data$customClass === void 0 ? {} : _data$customClass, _data$customProps = data.customProps, customProps = _data$customProps === void 0 ? {} : _data$customProps; var _customProps$audioPro = customProps.audioProps, audioProps = _customProps$audioPro === void 0 ? {} : _customProps$audioPro, _customProps$imagePro = customProps.imageProps, imageProps = _customProps$imagePro === void 0 ? {} : _customProps$imagePro; var _customClass$customIm = customClass.customImageClass, customImageClass = _customClass$customIm === void 0 ? '' : _customClass$customIm, _customClass$customCh = customClass.customChildrenClass, customChildrenClass = _customClass$customCh === void 0 ? '' : _customClass$customCh; var retainZoom = canZoom && selectedIndex == i && maintainZoom; return /*#__PURE__*/_react["default"].createElement(_Layout.Container, { className: _AttachmentViewerModule["default"].imgBox, id: "imgBox".concat(i), key: i, alignBox: "row", align: "both", style: getImgStyle(i) }, /*#__PURE__*/_react["default"].createElement(_Layout.Box, { className: _AttachmentViewerModule["default"].imgRef, id: "imgPreviewRef".concat(i) }, (0, _Attachment.isAudioFile)(name) ? selectedIndex == i ? /*#__PURE__*/_react["default"].createElement("video", _extends({ autoPlay: true, controls: true, className: _AttachmentViewerModule["default"].zoomIn, "data-id": "".concat(dataId, "_videoPreview"), "data-test-id": "".concat(dataId, "_videoPreview") }, audioProps), /*#__PURE__*/_react["default"].createElement("source", { src: viewUrl, type: "audio/".concat((0, _Attachment.getExtensionFromFileName)(name)) })) : null : /*#__PURE__*/_react["default"].createElement(_AttachmentImage["default"], _extends({ customClass: { customImageClass: "".concat(_AttachmentViewerModule["default"].img, " ").concat(_AttachmentViewerModule["default"].altText, "\n ").concat(canZoom || retainZoom ? isZoomed ? "".concat(_AttachmentViewerModule["default"].zoomedImg, " ").concat(_AttachmentViewerModule["default"].zoomOutCursor) : "".concat(_AttachmentViewerModule["default"].normalImg, " ").concat(_AttachmentViewerModule["default"].zoomInCursor) : '', " ").concat(customImageClass), customChildrenClass: customChildrenClass }, src: viewUrl, onClick: isPreviewAttachmentValid ? isZoomed ? _this5.zoomOut.bind(_this5, i) : function (e) { _this5.zoomIn(e, i, true); } : undefined, alt: name, dataId: dataId, id: "img".concat(i), isCover: false }, imageProps), children))); }); } }, { key: "render", value: function render() { var _this6 = this; var _this$state4 = this.state, isPViewListOpen = _this$state4.isPViewListOpen, selectedIndex = _this$state4.selectedIndex, data = _this$state4.data, isZoomed = _this$state4.isZoomed, canZoom = _this$state4.canZoom, canOpenInNewTab = _this$state4.canOpenInNewTab; var _this$props2 = this.props, responsiveId = _this$props2.responsiveId, needDownload = _this$props2.needDownload, i18nKeys = _this$props2.i18nKeys, isActive = _this$props2.isActive, dataId = _this$props2.dataId; var totalLen = data.length; var selectedAttachment = data[selectedIndex] || {}; var selectedImgUrl = selectedAttachment.viewUrl; var downloadUrl = selectedAttachment.downloadUrl; var authorHref; var authorName; var _ref3 = data[selectedIndex] ? data[selectedIndex] : {}, author = _ref3.author; if (author) { authorHref = author.href; authorName = author.name; } var ariaId = this.getNextId(); return /*#__PURE__*/_react["default"].createElement(_FreezeLayer["default"], { isActive: isActive && totalLen >= 1, palette: "dark", animationName: "expand" }, /*#__PURE__*/_react["default"].createElement(_CustomResponsive.ResponsiveReceiver, { responsiveId: responsiveId, query: this.responsiveFunc }, function (_ref4) { var uptoTablet = _ref4.uptoTablet; return /*#__PURE__*/_react["default"].createElement(_Layout.Container, { scroll: "none", "data-scroll-palette": "dark" }, /*#__PURE__*/_react["default"].createElement(_Layout.Box, null, /*#__PURE__*/_react["default"].createElement(_Layout.Container, { alignBox: "row", className: _AttachmentViewerModule["default"].header, align: "between", tabindex: "0" }, /*#__PURE__*/_react["default"].createElement(_Layout.Box, { shrink: true, className: _AttachmentViewerModule["default"].title, "data-title": selectedAttachment.name, dataId: "attachName", id: ariaId }, selectedAttachment.name), /*#__PURE__*/_react["default"].createElement(_Layout.Box, { flexible: true, className: _AttachmentViewerModule["default"].count, dataId: "attachCountContainer" }, selectedIndex + 1, "/", totalLen), /*#__PURE__*/_react["default"].createElement(_Layout.Box, { className: uptoTablet ? _AttachmentViewerModule["default"].mbleMenuBar : _AttachmentViewerModule["default"].menuBar }, /*#__PURE__*/_react["default"].createElement(_Layout.Container, { isInline: true, alignBox: uptoTablet ? 'column-reverse' : 'row', align: uptoTablet ? 'bottom' : 'center', wrap: "wrap", isCover: false }, canZoom ? isZoomed ? /*#__PURE__*/_react["default"].createElement("div", { className: uptoTablet ? _AttachmentViewerModule["default"].mobileMenu : _AttachmentViewerModule["default"].menu, onClick: _this6.zoomOut.bind(_this6, selectedIndex), "data-id": "zoomOut", "data-test-id": "zoomOut", "data-title": i18nKeys.zoomOutText }, /*#__PURE__*/_react["default"].createElement(_IconButton["default"], { iconName: "ZD-GN-zoomOut", className: _AttachmentViewerModule["default"].menuIcon, iconSize: "16", hoverType: "border", a11y: { ariaLabel: i18nKeys.zoomOutText } })) : /*#__PURE__*/_react["default"].createElement("div", { className: uptoTablet ? _AttachmentViewerModule["default"].mobileMenu : _AttachmentViewerModule["default"].menu, onClick: function onClick(e) { return _this6.zoomIn(e, selectedIndex); }, "data-id": "zoomIn", "data-test-id": "zoomIn", "data-title": i18nKeys.zoomInText }, /*#__PURE__*/_react["default"].createElement(_IconButton["default"], { iconName: "ZD-GN-zoomIn", className: _AttachmentViewerModule["default"].menuIcon, iconSize: "16", hoverType: "border", a11y: { ariaLabel: i18nKeys.zoomInText } })) : null, canOpenInNewTab ? /*#__PURE__*/_react["default"].createElement("div", { className: uptoTablet ? _AttachmentViewerModule["default"].mobileMenu : _AttachmentViewerModule["default"].menu }, /*#__PURE__*/_react["default"].createElement(_Link["default"], { href: selectedImgUrl, target: "_blank", dataId: "newTabAttach", title: i18nKeys.newTabText }, /*#__PURE__*/_react["default"].createElement(_IconButton["default"], { iconName: "ZD-GN-newLink", className: _AttachmentViewerModule["default"].menuIcon, iconSize: "16", hoverType: "border", needButtonTag: false, a11y: { ariaLabel: i18nKeys.newTabText } }))) : null, needDownload ? /*#__PURE__*/_react["default"].createElement("div", { className: uptoTablet ? _AttachmentViewerModule["default"].mobileMenu : _AttachmentViewerModule["default"].menu }, /*#__PURE__*/_react["default"].createElement(_Link["default"], { href: downloadUrl, target: "_parent", hasReload: true, download: true, title: i18nKeys.downloadText, dataId: "".concat(dataId, "_downloadAttach") }, /*#__PURE__*/_react["default"].createElement(_IconButton["default"], { iconName: "ZD-GN-download", className: _AttachmentViewerModule["default"].menuIcon, iconSize: "16", hoverType: "border", needButtonTag: false, a11y: { ariaLabel: i18nKeys.downloadText } }))) : null, /*#__PURE__*/_react["default"].createElement("div", { className: uptoTablet ? _AttachmentViewerModule["default"].mobileMenu : _AttachmentViewerModule["default"].menu, onClick: _this6.closeAttachmentViewer, "data-id": "closeAttach", "data-test-id": "closeAttach", "data-title": i18nKeys.closeText }, /*#__PURE__*/_react["default"].createElement(_IconButton["default"], { iconName: "ZD-cross", iconSize: "15", hoverType: "border", className: _AttachmentViewerModule["default"].menuIcon, a11y: { ariaLabel: i18nKeys.closeText }, title: i18nKeys.closeText })))))), /*#__PURE__*/_react["default"].createElement(_Layout.Box, { flexible: true, role: "toolbar", tabindex: "0" }, /*#__PURE__*/_react["default"].createElement(_Layout.Container, { alignBox: "row" }, /*#__PURE__*/_react["default"].createElement(_Layout.Box, { className: "".concat(_AttachmentViewerModule["default"].arrowBox, " ").concat(uptoTablet ? _AttachmentViewerModule["default"].mbleArrowBox : _AttachmentViewerModule["default"].nrmlArrowBox, " ").concat(selectedIndex === 0 ? _AttachmentViewerModule["default"].hidden : ''), onClick: _this6.changeSelectedIndex.bind(_this6, selectedIndex - 1), "data-title": i18nKeys.previousText, "data-title-position": "left" }, /*#__PURE__*/_react["default"].createElement("button", { className: _AttachmentViewerModule["default"].btn, "aria-label": i18nKeys.previousText }, /*#__PURE__*/_react["default"].createElement(_icons.Icon, { name: "ZD-arrowLeft3", iconClass: _AttachmentViewerModule["default"].arrow, dataId: "leftAttachNav", isBold: true }))), /*#__PURE__*/_react["default"].createElement(_Layout.Box, { className: _AttachmentViewerModule["default"].previewBox, tabindex: "0", "aria-describedby": ariaId, isShrink: false, eleRef: _this6.setImgBoxRef, scroll: "both", flexible: true }, _this6.imgPreviewView()), /*#__PURE__*/_react["default"].createElement(_Layout.Box, { className: "".concat(_AttachmentViewerModule["default"].arrowBox, " ").concat(uptoTablet ? _AttachmentViewerModule["default"].mbleArrowBox : _AttachmentViewerModule["default"].nrmlArrowBox, " ").concat(totalLen === selectedIndex + 1 ? _AttachmentViewerModule["default"].hidden : ''), onClick: _this6.changeSelectedIndex.bind(_this6, selectedIndex + 1), "data-title": i18nKeys.nextText, "data-title-position": "right" }, /*#__PURE__*/_react["default"].createElement("button", { className: _AttachmentViewerModule["default"].btn, "aria-label": i18nKeys.nextText }, /*#__PURE__*/_react["default"].createElement(_icons.Icon, { name: "ZD-arrowRight3", iconClass: _AttachmentViewerModule["default"].arrow, dataId: "rightAttachNav", isBold: true }))))), /*#__PURE__*/_react["default"].createElement(_Layout.Box, { className: "".concat(_AttachmentViewerModule["default"].footer, " ").concat(isPViewListOpen && totalLen !== 1 ? _AttachmentViewerModule["default"].footerHeight : _AttachmentViewerModule["default"].footerHide, " "), dataId: "".concat(dataId, "_attachPreviewFooter") }, /*#__PURE__*/_react["default"].createElement(_Layout.Container, { align: "vertical", alignBox: "row", className: _AttachmentViewerModule["default"].footerHeight }, author && /*#__PURE__*/_react["default"].createElement(_Layout.Box, { className: _AttachmentViewerModule["default"].author, dataId: "".concat(dataId, "_authorName") }, /*#__PURE__*/_react["default"].createElement(_Layout.Container, { alignBox: "row", align: "both" }, /*#__PURE__*/_react["default"].createElement(_Avatar["default"], { name: authorName, size: "xmedium", src: authorHref, palette: "info" }), /*#__PURE__*/_react["default"].createElement(_Layout.Box, { flexible: true, className: _AttachmentViewerModule["default"].authorName, "data-title": authorName }, authorName))), /*#__PURE__*/_react["default"].createElement(_Layout.Box, { flexible: true }, /*#__PURE__*/_react["default"].createElement(_Layout.Container, { align: "vertical", alignBox: "row", scroll: "horizontal", eleRef: function eleRef(el) { return _this6.imgListCont = el; }, className: _AttachmentViewerModule["default"].listContainer }, data.map(function (item, index) { var name = item.name, viewUrl = item.viewUrl, children = item.children, _item$customClass = item.customClass, customClass = _item$customClass === void 0 ? {} : _item$customClass, _item$dataId = item.dataId, dataId = _item$dataId === void 0 ? 'AttachmentImage' : _item$dataId, _item$customProps = item.customProps, customProps = _item$customProps === void 0 ? {} : _item$customProps; var thumbnail = item.thumbnail; var _customClass$customIm2 = customClass.customImageClass, customImageClass = _customClass$customIm2 === void 0 ? '' : _customClass$customIm2, _customClass$customCh2 = customClass.customChildrenClass, customChildrenClass = _customClass$customCh2 === void 0 ? '' : _customClass$customCh2; thumbnail = (0, _Attachment.isAudioFile)(name) ? thumbnail || _audio_thumbnail["default"] : thumbnail; //fallback thumbnail for audio return /*#__PURE__*/_react["default"].createElement(_Layout.Box, { className: "".concat(_AttachmentViewerModule["default"].imgItem, " ").concat(index === selectedIndex ? _AttachmentViewerModule["default"].selected : ''), key: index, onClick: _this6.changeSelectedIndex.bind(_this6, index), eleRef: function eleRef(el) { return _this6["img_".concat(index)] = el; }, dataId: "attachPreviewList", "data-title": name }, /*#__PURE__*/_react["default"].createElement(_AttachmentImage["default"], _extends({ src: thumbnail || viewUrl, size: "small", alt: name, customClass: { customImageClass: "".concat(_AttachmentViewerModule["default"].image, " ").concat(_AttachmentViewerModule["default"].altText, " ").concat(customImageClass), customChildrenClass: "".concat(_AttachmentViewerModule["default"].crsrPointer, " ").concat(customChildrenClass) }, dataId: dataId }, customProps), children)); }))))), totalLen !== 1 && /*#__PURE__*/_react["default"].createElement(_IconButton["default"], { dataId: "attachToggle", onClick: _this6.togglePViewList, iconName: "ZD-GN-hideTab", iconSize: "14", hoverType: "border", iconClass: "".concat(_AttachmentViewerModule["default"].thumpIcon, " ").concat(isPViewListOpen ? _AttachmentViewerModule["default"].thumpIconActive : ''), className: _AttachmentViewerModule["default"].button, a11y: { ariaLabel: i18nKeys.hideText }, title: isPViewListOpen ? i18nKeys.hideText : i18nKeys.showText })); })); } }]); return AttachmentViewer; }(_react.Component); exports["default"] = AttachmentViewer; AttachmentViewer.propTypes = _propTypes.AttachmentViewer_propTypes; AttachmentViewer.defaultProps = _defaultProps.AttachmentViewer_defaultProps; // if (__DOCS__) { // AttachmentViewer.docs = { // componentGroup: "Molecule" // }; // }