one
Version:
One is a React framework for web, iOS, and Android apps.
93 lines (92 loc) • 4.46 kB
JavaScript
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_children = require("../../headless/children.cjs");
var import_StackHeaderBackButton = require("./StackHeaderBackButton.cjs");
var import_StackHeaderLeft = require("./StackHeaderLeft.cjs");
var import_StackHeaderRight = require("./StackHeaderRight.cjs");
var import_StackHeaderSearchBar = require("./StackHeaderSearchBar.cjs");
var import_StackHeaderTitle = require("./StackHeaderTitle.cjs");
var import_children2 = require("../../utils/children.cjs");
var import_style = require("../../utils/style.cjs");
function StackHeaderComponent(_props) {
return null;
}
Object.assign(StackHeaderComponent, { [import_children.NAVIGATOR_CONFIG]: true });
function appendStackHeaderPropsToOptions(options, props) {
const flattenedStyle = (0, import_style.flattenStyle)(props.style);
const flattenedLargeStyle = (0, import_style.flattenStyle)(props.largeStyle);
if (props.hidden) {
return {
...options,
headerShown: false
};
}
if (props.asChild) {
return {
...options,
header: () => props.children
};
}
const isTransparent = flattenedStyle?.backgroundColor === "transparent";
const hasCustomShadow = flattenedStyle?.shadowColor !== void 0;
const hasBackgroundColor = flattenedStyle?.backgroundColor !== void 0;
const hasLargeBackgroundColor = flattenedLargeStyle?.backgroundColor !== void 0;
let updatedOptions = {
...options,
headerShown: !props.hidden,
headerBlurEffect: props.blurEffect,
...isTransparent && { headerTransparent: true },
...hasBackgroundColor && { headerStyle: { backgroundColor: flattenedStyle.backgroundColor } },
...hasLargeBackgroundColor && { headerLargeStyle: { backgroundColor: flattenedLargeStyle.backgroundColor } },
...hasCustomShadow && { headerShadowVisible: flattenedStyle?.shadowColor !== "transparent" },
...flattenedLargeStyle?.shadowColor !== void 0 && { headerLargeTitleShadowVisible: flattenedLargeStyle?.shadowColor !== "transparent" }
};
function appendChildOptions(child, options2) {
let result = options2;
if ((0, import_children2.isChildOfType)(child, import_StackHeaderTitle.StackHeaderTitle)) {
result = (0, import_StackHeaderTitle.appendStackHeaderTitlePropsToOptions)(result, child.props);
} else if ((0, import_children2.isChildOfType)(child, import_StackHeaderLeft.StackHeaderLeft)) {
result = (0, import_StackHeaderLeft.appendStackHeaderLeftPropsToOptions)(result, child.props);
} else if ((0, import_children2.isChildOfType)(child, import_StackHeaderRight.StackHeaderRight)) {
result = (0, import_StackHeaderRight.appendStackHeaderRightPropsToOptions)(result, child.props);
} else if ((0, import_children2.isChildOfType)(child, import_StackHeaderBackButton.StackHeaderBackButton)) {
result = (0, import_StackHeaderBackButton.appendStackHeaderBackButtonPropsToOptions)(result, child.props);
} else if ((0, import_children2.isChildOfType)(child, import_StackHeaderSearchBar.StackHeaderSearchBar)) {
result = (0, import_StackHeaderSearchBar.appendStackHeaderSearchBarPropsToOptions)(result, child.props);
} else {
console.warn(`Warning: Unknown child element passed to Stack.Header: ${child.type.name ?? child.type}`);
}
return result;
}
import_react.Children.forEach(props.children, (child) => {
if ((0, import_react.isValidElement)(child)) {
updatedOptions = appendChildOptions(child, updatedOptions);
}
});
return updatedOptions;
}