@activecollab/components
Version:
ActiveCollab Components
70 lines (67 loc) • 2.75 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
const _excluded = ["children", "open", "onClose", "className", "enableBackgroundClick", "disableCloseOnEsc", "animate", "onClickOutside"];
import React, { forwardRef } from "react";
import classnames from "classnames";
// import { DialogContext } from "./DialogContext";
import { DialogActions } from "./DialogActions";
import { DialogContent } from "./DialogContent";
import { DialogContentDivider } from "./DialogContentDivider";
import { DialogTitle } from "./DialogTitle";
import { StyledDialog } from "./Styles";
import { Modal } from "../Modal";
import { Fade } from "../Transitions";
import { SlideFromTop } from "../Transitions/SlideFromTop";
export const _Dialog = /*#__PURE__*/forwardRef((_ref, ref) => {
let children = _ref.children,
_ref$open = _ref.open,
open = _ref$open === void 0 ? false : _ref$open,
onClose = _ref.onClose,
className = _ref.className,
_ref$enableBackground = _ref.enableBackgroundClick,
enableBackgroundClick = _ref$enableBackground === void 0 ? false : _ref$enableBackground,
_ref$disableCloseOnEs = _ref.disableCloseOnEsc,
disableCloseOnEsc = _ref$disableCloseOnEs === void 0 ? false : _ref$disableCloseOnEs,
_ref$animate = _ref.animate,
animate = _ref$animate === void 0 ? "slide" : _ref$animate,
onClickOutside = _ref.onClickOutside,
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
const animateDialog = () => {
switch (animate) {
case "fade":
return /*#__PURE__*/React.createElement(Fade, {
in: open
}, /*#__PURE__*/React.createElement(StyledDialog, {
className: classnames("c-dialog", className)
}, children));
default:
return /*#__PURE__*/React.createElement(SlideFromTop, {
in: open
}, /*#__PURE__*/React.createElement(StyledDialog, {
className: classnames("c-dialog", className)
}, children));
}
};
return (
/*#__PURE__*/
// <DialogContext.Provider value={{}}>
React.createElement(Modal, _extends({
ref: ref,
open: open,
onClose: onClose,
disableBackgroundClick: !enableBackgroundClick,
disableCloseOnEsc: disableCloseOnEsc,
onClickOutside: onClickOutside
}, rest), animateDialog())
// </DialogContext.Provider>
);
});
_Dialog.displayName = "Dialog";
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/34757
export const Dialog = Object.assign({}, _Dialog, {
Title: DialogTitle,
Content: DialogContent,
ContentDivider: DialogContentDivider,
Actions: DialogActions
});
//# sourceMappingURL=Dialog.js.map