UNPKG

@etsoo/materialui

Version:

TypeScript Material-UI Implementation

33 lines (32 loc) 1.1 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { BridgeUtils } from "@etsoo/appscript"; import CloseIcon from "@mui/icons-material/Close"; import React from "react"; import { useAppContext } from "./app/ReactApp"; import IconButton from "@mui/material/IconButton"; import Box from "@mui/material/Box"; /** * Bridge close button * @param props Props * @returns Component */ export function BridgeCloseButton(props) { // Global app const app = useAppContext(); // Destruct const { boxProps, onClick, title = app?.get("close") ?? "Close", validate, ...rest } = props; // Host const host = BridgeUtils.host; if (host == null || !host.closable() || (validate && validate(host) === false)) { return _jsx(React.Fragment, {}); } // Click handler const onClickLocal = (event) => { if (onClick) onClick(event); host.exit(); }; return (_jsx(Box, { ...boxProps, children: _jsx(IconButton, { "aria-label": "close", onClick: onClickLocal, title: title, ...rest, children: _jsx(CloseIcon, {}) }) })); }