UNPKG

one

Version:

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

110 lines (108 loc) 5.12 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: !0 }); }, __copyProps = (to, from, except, desc) => { if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__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: !0 }) : target, mod)), __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", { value: !0 }), 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"), import_native_stack = require("@react-navigation/native-stack"), import_react = __toESM(require("react"), 1), import_stack_utils = require("./stack-utils/index.native.js"), import_withLayoutContext = require("./withLayoutContext.native.js"), import_children = require("../utils/children.native.js"), import_Protected = require("../views/Protected.native.js"), import_Screen = require("../views/Screen.native.js"), NativeStackNavigator = (0, import_native_stack.createNativeStackNavigator)().Navigator, 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, options = (0, import_stack_utils.appendScreenStackPropsToOptions)({}, child.props), { 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); } return (0, import_children.isChildOfType)(child, import_Protected.Protected) ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_Protected.Protected, { guard: child.props.guard, children: mapChildren(child.props.children) }, `protected-${index}`) : (0, import_children.isChildOfType)(child, import_stack_utils.StackHeaderComponent) ? null : child; }).filter(Boolean); } var StackWithComposition = /* @__PURE__ */import_react.default.forwardRef(function (props, ref) { var { children, screenOptions, ...rest } = props, 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 }; return screenOptions ? typeof screenOptions == "function" ? 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); } : (0, import_stack_utils.appendScreenStackPropsToOptions)(screenOptions, headerProps) : (0, import_stack_utils.appendScreenStackPropsToOptions)({}, headerProps); } return screenOptions; }, [children, screenOptions]), processedChildren = (0, import_react.useMemo)(function () { return mapChildren(children); }, [children]); return /* @__PURE__ */(0, import_jsx_runtime.jsx)(RNStack, { ...rest, ref, screenOptions: screenOptionsWithHeader, children: processedChildren }); }), Stack = Object.assign(StackWithComposition, { Screen: import_stack_utils.StackScreen, Header: import_stack_utils.StackHeader, Protected: import_Protected.Protected, SearchBar: import_stack_utils.StackHeaderSearchBar }), Stack_default = Stack; //# sourceMappingURL=Stack.native.js.map