UNPKG

@brizy/media-gallery

Version:
132 lines (131 loc) 6.04 kB
function _define_property(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _object_spread(target) { for(var i = 1; i < arguments.length; i++){ var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === "function") { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function(key) { _define_property(target, key, source[key]); }); } return target; } function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function(sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } function _object_spread_props(target, source) { source = source != null ? source : {}; if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function(key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } import React from "react"; import { CheckOutlined } from "@brizy/ui-icons/lib/icons/CheckOutlined"; import { Delete } from "@brizy/ui-icons/lib/icons/Delete"; import { Promote } from "@brizy/ui-icons/lib/icons/Promote"; import { ButtonGroup } from "@brizy/ui/lib/Button/ButtonGroup"; import { Button } from "@brizy/ui/lib/Button"; import { Inline } from "@brizy/ui/lib/Inline"; import { Icon } from "@brizy/ui/lib/Icon"; import { Footer as CFooter } from "@brizy/ui/lib/Footer"; import { useTranslation } from "../../locale/useTranslation"; var props = { color: "inherit", size: "12px" }; var btnProps = { type: "dashed", size: "small" }; export var Footer = function(param) { var onCancel = param.onCancel, loading = param.loading, disabled = param.disabled, onClick = param.onClick, previewLink = param.previewLink, onDelete = param.onDelete, onPrevClick = param.onPrevClick, onNextClick = param.onNextClick, isMultipleSelected = param.isMultipleSelected, isFirstPage = param.isFirstPage, isLastPage = param.isLastPage, isWithInsertFiles = param.isWithInsertFiles, isWithImportToLibrary = param.isWithImportToLibrary; var t = useTranslation().t; var isPreviewDisabled = disabled !== undefined && !disabled.preview; var isDeleteDisabled = disabled !== undefined && !disabled.delete; var isCancelDisabled = disabled !== undefined && !disabled.cancel; var isInsertFilesDisabled = disabled !== undefined && !disabled.insertFiles; var isPreviewLoading = loading !== undefined && loading.preview; var isDeleteLoading = loading !== undefined && loading.delete; var isCancelLoading = loading !== undefined && loading.cancel; var isInsertFilesLoading = loading !== undefined && loading.insertFiles; var disabledPreviewColor = isPreviewDisabled ? "gray-light" : undefined; var disabledDeleteColor = isDeleteDisabled ? "gray-light" : undefined; var showPagination = !isFirstPage || !isLastPage; var SecondLeftBtnText = isWithInsertFiles ? isMultipleSelected ? t("Insert Files") : t("Insert File") : isWithImportToLibrary ? t("Import to Library") : null; return /*#__PURE__*/ React.createElement(CFooter, { fullWidth: true, left: /*#__PURE__*/ React.createElement(ButtonGroup, null, /*#__PURE__*/ React.createElement(Button, { disabled: isCancelDisabled, loading: isCancelLoading, onClick: onCancel }, t("Cancel")), (isWithInsertFiles || isWithImportToLibrary) && /*#__PURE__*/ React.createElement(Button, { type: "primary", disabled: isInsertFilesDisabled, loading: isInsertFilesLoading, onClick: onClick }, SecondLeftBtnText, /*#__PURE__*/ React.createElement(Icon, { source: CheckOutlined, color: "inherit" }))), right: /*#__PURE__*/ React.createElement(ButtonGroup, null, /*#__PURE__*/ React.createElement(Inline, { alignY: "center", spacing: 13 }, showPagination && /*#__PURE__*/ React.createElement(Button, { color: "white", onClick: onPrevClick, disabled: isFirstPage, hoverColor: "blue" }, t("Previous")), showPagination && /*#__PURE__*/ React.createElement(Button, { color: "white", onClick: onNextClick, disabled: isLastPage, hoverColor: "blue" }, t("Next")), /*#__PURE__*/ React.createElement(Button, _object_spread_props(_object_spread({}, btnProps), { color: disabledPreviewColor, href: previewLink, target: "_blank", disabled: isPreviewDisabled, loading: isPreviewLoading }), /*#__PURE__*/ React.createElement(Icon, _object_spread_props(_object_spread({}, props), { source: Promote })), t("PREVIEW")), onDelete && /*#__PURE__*/ React.createElement(Button, _object_spread_props(_object_spread({}, btnProps), { color: disabledDeleteColor, loading: isDeleteLoading, disabled: isDeleteDisabled, onClick: onDelete }), /*#__PURE__*/ React.createElement(Icon, _object_spread_props(_object_spread({}, props), { source: Delete })), t("DELETE")))) }); };