@light-sheet/react
Version:
FortuneSheet is a drop-in javascript spreadsheet library that provides rich features like Excel and Google Sheets
30 lines • 1.05 kB
JavaScript
import { useContext } from "react";
import { useDialog } from "./useDialog";
import { RightPanelContext } from "../context/rightPanel";
import WorkbookContext from "../context";
export function useUIapi() {
var _useDialog = useDialog(),
showDialog = _useDialog.showDialog;
var _useContext = useContext(RightPanelContext),
setRightPanelValue = _useContext.setValue;
var _useContext2 = useContext(WorkbookContext),
setContext = _useContext2.setContext;
return {
showModal: function showModal(content, type) {
showDialog(content, type);
},
showRightPanel: function showRightPanel(value) {
setRightPanelValue(value);
setContext(function (draftCtx) {
draftCtx.rightPanelVisible = true;
draftCtx.rightPanelWidth = (value === null || value === void 0 ? void 0 : value.width) || 0;
});
},
hideRightPanel: function hideRightPanel() {
setContext(function (draftCtx) {
draftCtx.rightPanelVisible = false;
draftCtx.rightPanelWidth = 0;
});
}
};
}