UNPKG

one

Version:

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

86 lines (85 loc) 3.16 kB
"use client"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; 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 __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var StackScreen_exports = {}; __export(StackScreen_exports, { StackScreen: () => StackScreen, appendScreenStackPropsToOptions: () => appendScreenStackPropsToOptions, validateStackPresentation: () => validateStackPresentation }); module.exports = __toCommonJS(StackScreen_exports); var import_react = require("react"); var import_StackHeaderComponent = require("./StackHeaderComponent.cjs"); var import_Screen = require("../../views/Screen.cjs"); var import_jsx_runtime = require("react/jsx-runtime"); function StackScreen({ children, options, ...rest }) { const updatedOptions = (0, import_react.useMemo)(() => appendScreenStackPropsToOptions(options ?? {}, { children }), [options, children]); return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_Screen.Screen, { ...rest, options: updatedOptions }); } const VALID_PRESENTATIONS = ["card", "modal", "transparentModal", "containedModal", "containedTransparentModal", "fullScreenModal", "formSheet", "pageSheet"]; function validateStackPresentation(options) { if (typeof options === "function") { return (...args) => { const resolved = options(...args); validateStackPresentation(resolved); return resolved; }; } if (process.env.NODE_ENV !== "production") { const presentation = options.presentation; if (presentation && !VALID_PRESENTATIONS.includes(presentation)) { console.warn(`Invalid presentation value "${presentation}" passed to Stack.Screen. Valid values are: ${VALID_PRESENTATIONS.map(v => `"${v}"`).join(", ")}.`); } } return options; } function appendScreenStackPropsToOptions(options, props) { let updatedOptions = { ...options, ...props.options }; validateStackPresentation(updatedOptions); function appendChildOptions(child, options2) { if (child.type === import_StackHeaderComponent.StackHeaderComponent) { return (0, import_StackHeaderComponent.appendStackHeaderPropsToOptions)(options2, child.props); } else { console.warn(`Warning: Unknown child element passed to Stack.Screen: ${child.type.name ?? child.type}`); } return options2; } import_react.Children.forEach(props.children, child => { if ((0, import_react.isValidElement)(child)) { updatedOptions = appendChildOptions(child, updatedOptions); } }); return updatedOptions; }