UNPKG

one

Version:

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

126 lines (124 loc) 5.2 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod)); var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var Stack_exports = {}; __export(Stack_exports, { Stack: () => Stack, default: () => Stack_default }); module.exports = __toCommonJS(Stack_exports); var import_jsx_runtime = require("react/jsx-runtime"); var import_native_stack = require("@react-navigation/native-stack"); var import_react = __toESM(require("react"), 1); var import_stack_utils = require("./stack-utils/index.native.js"); var import_withLayoutContext = require("./withLayoutContext.native.js"); var import_children = require("../utils/children.native.js"); var import_Protected = require("../views/Protected.native.js"); var import_Screen = require("../views/Screen.native.js"); var NativeStackNavigator = (0, import_native_stack.createNativeStackNavigator)().Navigator; var RNStack = (0, import_withLayoutContext.withLayoutContext)(NativeStackNavigator); function mapChildren(children) { return import_react.Children.toArray(children).map(function (child, index) { if ((0, import_children.isChildOfType)(child, import_stack_utils.StackScreen)) { var _child_props_name; var options = (0, import_stack_utils.appendScreenStackPropsToOptions)({}, child.props); var { children: _, ...rest } = child.props; return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_Screen.Screen, { ...rest, options }, (_child_props_name = child.props.name) !== null && _child_props_name !== void 0 ? _child_props_name : index); } if ((0, import_children.isChildOfType)(child, import_Protected.Protected)) { return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_Protected.Protected, { guard: child.props.guard, children: mapChildren(child.props.children) }, `protected-${index}`); } if ((0, import_children.isChildOfType)(child, import_stack_utils.StackHeaderComponent)) { return null; } return child; }).filter(Boolean); } var StackWithComposition = /* @__PURE__ */import_react.default.forwardRef(function (props, ref) { var { children, screenOptions, ...rest } = props; var screenOptionsWithHeader = (0, import_react.useMemo)(function () { var stackHeader = import_react.Children.toArray(children).find(function (child) { return (0, import_children.isChildOfType)(child, import_stack_utils.StackHeaderComponent); }); if (stackHeader && (0, import_children.isChildOfType)(stackHeader, import_stack_utils.StackHeaderComponent)) { var headerProps = { children: stackHeader }; if (screenOptions) { if (typeof screenOptions === "function") { return function () { for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } var opts = screenOptions(...args); return (0, import_stack_utils.appendScreenStackPropsToOptions)(opts, headerProps); }; } return (0, import_stack_utils.appendScreenStackPropsToOptions)(screenOptions, headerProps); } return (0, import_stack_utils.appendScreenStackPropsToOptions)({}, headerProps); } return screenOptions; }, [children, screenOptions]); var processedChildren = (0, import_react.useMemo)(function () { return mapChildren(children); }, [children]); return /* @__PURE__ */(0, import_jsx_runtime.jsx)(RNStack, { ...rest, ref, screenOptions: screenOptionsWithHeader, children: processedChildren }); }); var Stack = Object.assign(StackWithComposition, { Screen: import_stack_utils.StackScreen, Header: import_stack_utils.StackHeader, Protected: import_Protected.Protected, SearchBar: import_stack_utils.StackHeaderSearchBar }); var Stack_default = Stack; //# sourceMappingURL=Stack.native.js.map