UNPKG

one

Version:

One is a new React Framework that makes Vite serve both native and web.

34 lines (32 loc) 1.21 kB
"use client"; import { Children, isValidElement, useMemo } from "react"; import { StackHeaderComponent, appendStackHeaderPropsToOptions } from "./StackHeaderComponent.mjs"; import { Screen } from "../../views/Screen.mjs"; import { jsx } from "react/jsx-runtime"; function StackScreen({ children, options, ...rest }) { const updatedOptions = useMemo(() => appendScreenStackPropsToOptions(options ?? {}, { children }), [options, children]); return /* @__PURE__ */jsx(Screen, { ...rest, options: updatedOptions }); } function appendScreenStackPropsToOptions(options, props) { let updatedOptions = { ...options, ...props.options }; function appendChildOptions(child, options2) { return child.type === StackHeaderComponent ? appendStackHeaderPropsToOptions(options2, child.props) : (console.warn(`Warning: Unknown child element passed to Stack.Screen: ${child.type.name ?? child.type}`), options2); } return Children.forEach(props.children, child => { isValidElement(child) && (updatedOptions = appendChildOptions(child, updatedOptions)); }), updatedOptions; } export { StackScreen, appendScreenStackPropsToOptions }; //# sourceMappingURL=StackScreen.mjs.map