UNPKG

@airplane/views

Version:

A React library for building Airplane views. Views components are optimized in style and functionality to produce internal apps that are easy to build and maintain.

41 lines (40 loc) 1.04 kB
import { jsxs, jsx } from "react/jsx-runtime"; import * as React from "react"; import { useState } from "react"; import { RequestRunnableDialog } from "./RequestRunnableDialog.js"; const defaultContext = { setState: () => { } }; const RequestDialogContext = /* @__PURE__ */ React.createContext(defaultContext); const RequestDialogProvider = ({ children }) => { const [state, setState] = useState({ params: {}, opened: false }); const { params, taskSlug, runbookSlug, opened } = state; return /* @__PURE__ */ jsxs(RequestDialogContext.Provider, { value: { setState }, children: [ children, (taskSlug || runbookSlug) && /* @__PURE__ */ jsx(RequestRunnableDialog, { opened, onSubmit: () => setState({ ...state, opened: false }), onClose: () => setState({ ...state, opened: false }), taskSlug, runbookSlug, paramValues: params || {} }) ] }); }; export { RequestDialogContext, RequestDialogProvider }; //# sourceMappingURL=RequestDialogProvider.js.map