UNPKG

@light-sheet/react

Version:

FortuneSheet is a drop-in javascript spreadsheet library that provides rich features like Excel and Google Sheets

21 lines 790 B
import React, { useContext, useCallback } from "react"; import Dialog from "../components/Dialog"; import { ModalContext } from "../context/modal"; export function useDialog() { var _useContext = useContext(ModalContext), showModal = _useContext.showModal, hideModal = _useContext.hideModal; var showDialog = useCallback(function (content, type) { var onOk = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : hideModal; var onCancel = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : hideModal; showModal( /*#__PURE__*/React.createElement(Dialog, { type: type, onOk: onOk, onCancel: onCancel }, content)); }, [hideModal, showModal]); return { showDialog: showDialog, hideDialog: hideModal }; }