UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

133 lines (132 loc) 3.52 kB
"use client"; import _extends from "@babel/runtime-corejs3/helpers/esm/extends"; import React, { useContext } from 'react'; import Modal from "../modal/Modal.js"; import DialogContent from "./DialogContent.js"; import DialogBody from "./parts/DialogBody.js"; import DialogHeader from "./parts/DialogHeader.js"; import DialogNavigation from "./parts/DialogNavigation.js"; import classnames from 'classnames'; import Context from "../../shared/Context.js"; import DialogAction from "./parts/DialogAction.js"; import { extendPropsWithContext } from "../../shared/component-helper.js"; const defaultProps = { variant: 'information', spacing: true }; function Dialog(localProps) { const context = useContext(Context); const propsWithContext = extendPropsWithContext(localProps, defaultProps, context === null || context === void 0 ? void 0 : context.Dialog); const { id, rootId, contentId, focusSelector, labelledBy, directDomReturn, disabled, variant, title, dialogTitle, closeTitle, spacing, verticalAlignment, noAnimation, noAnimationOnMobile, animationDuration, triggerAttributes, hideCloseButton, fullscreen, onOpen, onClose, onClosePrevent, openModal, closeModal, preventClose, preventOverlayClose, openState, openDelay, trigger, omitTriggerButton = false, overlayClass, contentClass, contentRef, scrollRef, top, bottom, left, right, space, ...props } = propsWithContext; let currentHideCloseButton = hideCloseButton; let currentOmitTriggerButton = omitTriggerButton; let currentFullscreen = fullscreen; let currentPreventOverlayClose = preventOverlayClose; if (variant === 'confirmation') { currentHideCloseButton = hideCloseButton !== undefined ? hideCloseButton : true; currentOmitTriggerButton = triggerAttributes !== undefined ? omitTriggerButton : true; currentPreventOverlayClose = preventOverlayClose !== undefined ? preventOverlayClose : true; } if (fullscreen === undefined && fullscreen !== false) { currentFullscreen = variant === 'information' ? 'auto' : false; } const modalProps = { title, id, focusSelector, labelledBy, disabled, spacing, verticalAlignment, openDelay, contentId, dialogTitle, closeTitle, hideCloseButton: currentHideCloseButton, preventClose, preventOverlayClose: currentPreventOverlayClose, animationDuration, noAnimation, noAnimationOnMobile, fullscreen: currentFullscreen, openState, directDomReturn, rootId, onOpen, onClose, onClosePrevent, openModal, closeModal, omitTriggerButton: currentOmitTriggerButton, trigger, triggerAttributes, overlayClass, top, bottom, left, right, space, contentRef, scrollRef }; const dialogProps = { ...props, noAnimation, noAnimationOnMobile, fullscreen: currentFullscreen, spacing, variant }; return React.createElement(Modal, _extends({}, modalProps, { dialogRole: variant === 'information' ? 'dialog' : 'alertdialog', contentClass: classnames('dnb-dialog__root', contentClass) }), React.createElement(DialogContent, dialogProps)); } Dialog.Body = DialogBody; Dialog.Header = DialogHeader; Dialog.Navigation = DialogNavigation; Dialog.Action = DialogAction; Dialog._supportsSpacingProps = true; export default Dialog; //# sourceMappingURL=Dialog.js.map