UNPKG

one

Version:

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

119 lines (117 loc) 5.72 kB
"use strict"; 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 StackHeaderComponent_exports = {}; __export(StackHeaderComponent_exports, { StackHeaderComponent: () => StackHeaderComponent, appendStackHeaderPropsToOptions: () => appendStackHeaderPropsToOptions }); module.exports = __toCommonJS(StackHeaderComponent_exports); var import_react = require("react"); var import_react_native = require("react-native"); var import_StackHeaderBackButton = require("./StackHeaderBackButton.native.js"); var import_StackHeaderLeft = require("./StackHeaderLeft.native.js"); var import_StackHeaderRight = require("./StackHeaderRight.native.js"); var import_StackHeaderSearchBar = require("./StackHeaderSearchBar.native.js"); var import_StackHeaderTitle = require("./StackHeaderTitle.native.js"); var import_children = require("../../utils/children.native.js"); function StackHeaderComponent(_props) { return null; } function appendStackHeaderPropsToOptions(options, props) { var flattenedStyle = import_react_native.StyleSheet.flatten(props.style); var flattenedLargeStyle = import_react_native.StyleSheet.flatten(props.largeStyle); if (props.hidden) { return { ...options, headerShown: false }; } if (props.asChild) { return { ...options, header: function () { return props.children; } }; } var isTransparent = (flattenedStyle === null || flattenedStyle === void 0 ? void 0 : flattenedStyle.backgroundColor) === "transparent"; var hasCustomShadow = (flattenedStyle === null || flattenedStyle === void 0 ? void 0 : flattenedStyle.shadowColor) !== void 0; var hasBackgroundColor = (flattenedStyle === null || flattenedStyle === void 0 ? void 0 : flattenedStyle.backgroundColor) !== void 0; var hasLargeBackgroundColor = (flattenedLargeStyle === null || flattenedLargeStyle === void 0 ? void 0 : flattenedLargeStyle.backgroundColor) !== void 0; var updatedOptions = { ...options, headerShown: !props.hidden, headerBlurEffect: props.blurEffect, // Set headerTransparent when backgroundColor is 'transparent' // This works on both iOS and Android for normal headers // Note: When using SearchBar on iOS, if you don't have a ScrollView with // contentInsetAdjustmentBehavior="automatic", set headerTransparent: false in options ...(isTransparent && { headerTransparent: true }), // Only set header styles when explicitly configured to avoid interfering with native defaults ...(hasBackgroundColor && { headerStyle: { backgroundColor: flattenedStyle.backgroundColor } }), ...(hasLargeBackgroundColor && { headerLargeStyle: { backgroundColor: flattenedLargeStyle.backgroundColor } }), // Only set shadow visibility when explicitly configured ...(hasCustomShadow && { headerShadowVisible: (flattenedStyle === null || flattenedStyle === void 0 ? void 0 : flattenedStyle.shadowColor) !== "transparent" }), ...((flattenedLargeStyle === null || flattenedLargeStyle === void 0 ? void 0 : flattenedLargeStyle.shadowColor) !== void 0 && { headerLargeTitleShadowVisible: (flattenedLargeStyle === null || flattenedLargeStyle === void 0 ? void 0 : flattenedLargeStyle.shadowColor) !== "transparent" }) }; function appendChildOptions(child, options2) { var result = options2; if ((0, import_children.isChildOfType)(child, import_StackHeaderTitle.StackHeaderTitle)) { result = (0, import_StackHeaderTitle.appendStackHeaderTitlePropsToOptions)(result, child.props); } else if ((0, import_children.isChildOfType)(child, import_StackHeaderLeft.StackHeaderLeft)) { result = (0, import_StackHeaderLeft.appendStackHeaderLeftPropsToOptions)(result, child.props); } else if ((0, import_children.isChildOfType)(child, import_StackHeaderRight.StackHeaderRight)) { result = (0, import_StackHeaderRight.appendStackHeaderRightPropsToOptions)(result, child.props); } else if ((0, import_children.isChildOfType)(child, import_StackHeaderBackButton.StackHeaderBackButton)) { result = (0, import_StackHeaderBackButton.appendStackHeaderBackButtonPropsToOptions)(result, child.props); } else if ((0, import_children.isChildOfType)(child, import_StackHeaderSearchBar.StackHeaderSearchBar)) { result = (0, import_StackHeaderSearchBar.appendStackHeaderSearchBarPropsToOptions)(result, child.props); } else { var _child_type_name; console.warn(`Warning: Unknown child element passed to Stack.Header: ${(_child_type_name = child.type.name) !== null && _child_type_name !== void 0 ? _child_type_name : child.type}`); } return result; } import_react.Children.forEach(props.children, function (child) { if (/* @__PURE__ */(0, import_react.isValidElement)(child)) { updatedOptions = appendChildOptions(child, updatedOptions); } }); return updatedOptions; } //# sourceMappingURL=StackHeaderComponent.native.js.map