@carbon/ibm-products
Version:
Carbon for IBM Products
38 lines (36 loc) • 1.48 kB
JavaScript
/**
* Copyright IBM Corp. 2020, 2026
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
let react = require("react");
react = require_runtime.__toESM(react);
let prop_types = require("prop-types");
prop_types = require_runtime.__toESM(prop_types);
//#region src/components/WebTerminal/hooks/index.tsx
const WebTerminalContext = (0, react.createContext)({});
const WebTerminalProvider = ({ children }) => {
const [open, setOpen] = (0, react.useState)(false);
const openWebTerminal = (0, react.useCallback)(() => setOpen(true), []);
const closeWebTerminal = (0, react.useCallback)(() => setOpen(false), []);
const toggleWebTerminal = (0, react.useCallback)(() => setOpen(!open), [open]);
return /* @__PURE__ */ react.default.createElement(WebTerminalContext.Provider, { value: {
open,
openWebTerminal,
closeWebTerminal,
toggleWebTerminal
} }, children);
};
WebTerminalProvider.propTypes = {
/**
* Provide your own terminal component as children to show up in the web terminal
*/
children: prop_types.default.oneOfType([prop_types.default.arrayOf(prop_types.default.node), prop_types.default.node]).isRequired };
const useWebTerminal = () => {
return (0, react.useContext)(WebTerminalContext);
};
//#endregion
exports.WebTerminalProvider = WebTerminalProvider;
exports.useWebTerminal = useWebTerminal;