@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.81 kB
JavaScript
import { jsx } from "react/jsx-runtime";
import { NotificationsProvider } from "@mantine/notifications";
import * as React from "react";
import { RequestDialogProvider } from "../components/requestDialog/RequestDialogProvider.js";
import { getNPMPackageVersion } from "../getNPMPackageVersion.js";
import { sendViewMessage } from "../message/sendViewMessage.js";
import { ComponentStateProvider } from "../state/context/ComponentStateProvider.js";
import { QueryClientProvider } from "../state/context/QueryClientProvider.js";
import { ThemeProvider } from "../components/theme/ThemeProvider.js";
import { RunnerScaleSignalProvider } from "../state/context/RunnerScaleSignalProvider.js";
const disableQueryConfigRetries = (q) => {
const queryClientConfig = q ?? {};
if (!queryClientConfig.defaultOptions) {
queryClientConfig.defaultOptions = {};
}
if (!queryClientConfig.defaultOptions.queries) {
queryClientConfig.defaultOptions.queries = {};
}
queryClientConfig.defaultOptions.queries.retry = false;
return queryClientConfig;
};
const ViewProvider = ({
children,
queryClientConfig
}) => {
React.useEffect(() => {
const version = getNPMPackageVersion();
if (version) {
sendViewMessage({
type: "view_init",
version
});
}
}, []);
return /* @__PURE__ */ jsx(ComponentStateProvider, { children: /* @__PURE__ */ jsx(QueryClientProvider, { queryClientConfig: disableQueryConfigRetries(queryClientConfig), children: /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(NotificationsProvider, { position: "bottom-right", children: /* @__PURE__ */ jsx(RequestDialogProvider, { children: /* @__PURE__ */ jsx(RunnerScaleSignalProvider, { children }) }) }) }) }) });
};
export {
ViewProvider
};
//# sourceMappingURL=index.js.map