import type { StackflowReactPlugin } from "@stackflow/react"; import { assignInlineVars } from "@vanilla-extract/dynamic"; import { createContext, useContext } from "react"; import * as css from "./basicUIPlugin.css"; import type { RecursivePartial } from "./utils"; import { compact, compactMap, isBrowser } from "./utils"; type BasicUIPluginOptions = RecursivePartial & { theme: "android" | "cupertino"; rootClassName?: string; appBar?: { backButton?: | { renderIcon?: () => React.ReactNode; ariaLabel?: string; } | { render?: () => React.ReactNode; }; closeButton?: | { renderIcon?: () => React.ReactNode; ariaLabel?: string; onClick?: (e: React.MouseEvent) => void; } | { render?: () => React.ReactNode; }; }; }; const GlobalOptionsContext = createContext({ theme: "android", }); export const GlobalOptionsProvider = GlobalOptionsContext.Provider; export function useGlobalOptions() { return useContext(GlobalOptionsContext); } export const basicUIPlugin: ( options: | BasicUIPluginOptions | ((args: { initialContext?: any }) => BasicUIPluginOptions), ) => StackflowReactPlugin = (options) => () => ({ key: "basic-ui", wrapStack({ stack, initialContext }) { const _options = typeof options === "function" ? options({ initialContext }) : options; return (
{stack.render()}
); }, });