one
Version:
One is a React framework for web, iOS, and Android apps.
1 lines • 6.3 kB
Source Map (JSON)
{"version":3,"file":"insets.js","names":[],"sources":["esm/platform/safe-area/insets.js"],"sourcesContent":["function resolveSafeAreaEdgeModes(edges) {\n const all = [\"top\", \"right\", \"bottom\", \"left\"];\n if (edges == null) {\n return { top: \"additive\", right: \"additive\", bottom: \"additive\", left: \"additive\" };\n }\n if (Array.isArray(edges)) {\n return Object.fromEntries(\n all.map((edge) => [edge, edges.includes(edge) ? \"additive\" : \"off\"])\n );\n }\n return Object.fromEntries(\n all.map((edge) => {\n const mode = edges[edge];\n return [\n edge,\n mode === \"maximum\" || mode === \"additive\" || mode === \"off\" ? mode : \"off\"\n ];\n })\n );\n}\nfunction flattenStyle(style, resolveStyle) {\n if (!style) return {};\n if (resolveStyle) {\n const resolved = resolveStyle(style);\n if (!resolved || typeof resolved !== \"object\" || Array.isArray(resolved)) {\n return flattenStyle(resolved);\n }\n return resolved;\n }\n if (Array.isArray(style)) {\n return Object.assign({}, ...style.map((entry) => flattenStyle(entry)));\n }\n if (typeof style === \"number\") {\n throw new Error(\n \"buildSafeAreaInsetStyle cannot read a registered StyleSheet ID without resolveStyle; pass StyleSheet.flatten\"\n );\n }\n return typeof style === \"object\" ? style : {};\n}\nfunction readBaseInset(style, mode, edge) {\n const capitalized = edge.charAt(0).toUpperCase() + edge.slice(1);\n const exact = style[`${mode}${capitalized}`];\n if (typeof exact === \"number\") return exact;\n const axis = edge === \"top\" || edge === \"bottom\" ? style[`${mode}Vertical`] : style[`${mode}Horizontal`];\n if (typeof axis === \"number\") return axis;\n const base = style[mode];\n return typeof base === \"number\" ? base : 0;\n}\nfunction buildSafeAreaInsetStyle(options) {\n const mode = options.mode === \"margin\" ? \"margin\" : \"padding\";\n const flattened = flattenStyle(options.style, options.resolveStyle);\n const edgeModes = resolveSafeAreaEdgeModes(options.edges);\n const output = {};\n for (const edge of [\"top\", \"right\", \"bottom\", \"left\"]) {\n const base = readBaseInset(flattened, mode, edge);\n const inset = options.insets[edge];\n const edgeMode = edgeModes[edge];\n const value = edgeMode === \"off\" ? base : edgeMode === \"maximum\" ? Math.max(base, inset) : base + inset;\n output[`${mode}${edge.charAt(0).toUpperCase() + edge.slice(1)}`] = value;\n }\n return output;\n}\nfunction keyboardSafeBottom(systemBottom, stableBottom) {\n return Math.min(systemBottom, stableBottom);\n}\nfunction resolveOverlappingInsets(options) {\n const {\n windowInsets,\n windowWidth,\n windowHeight,\n visibleLeft,\n visibleTop,\n viewWidth,\n viewHeight\n } = options;\n return {\n top: Math.max(windowInsets.top - visibleTop, 0),\n right: Math.max(\n Math.min(visibleLeft + viewWidth - windowWidth, 0) + windowInsets.right,\n 0\n ),\n bottom: Math.max(\n Math.min(visibleTop + viewHeight - windowHeight, 0) + windowInsets.bottom,\n 0\n ),\n left: Math.max(windowInsets.left - visibleLeft, 0)\n };\n}\nfunction providerEventToMetrics(payload) {\n for (const [key, value] of Object.entries(payload)) {\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n throw new Error(`OneNativeSafeAreaProvider emitted non-finite ${key}`);\n }\n }\n return {\n insets: {\n top: payload.insetTop,\n right: payload.insetRight,\n bottom: payload.insetBottom,\n left: payload.insetLeft\n },\n frame: {\n x: payload.frameX,\n y: payload.frameY,\n width: payload.frameWidth,\n height: payload.frameHeight\n }\n };\n}\nexport {\n buildSafeAreaInsetStyle,\n keyboardSafeBottom,\n providerEventToMetrics,\n resolveOverlappingInsets,\n resolveSafeAreaEdgeModes\n};\n//# sourceMappingURL=insets.js.map\n"],"mappings":";AAAA,SAAS,yBAAyB,OAAO;CACvC,MAAM,MAAM;EAAC;EAAO;EAAS;EAAU;CAAM;CAC7C,IAAI,SAAS,MAAM;EACjB,OAAO;GAAE,KAAK;GAAY,OAAO;GAAY,QAAQ;GAAY,MAAM;EAAW;CACpF;CACA,IAAI,MAAM,QAAQ,KAAK,GAAG;EACxB,OAAO,OAAO,YACZ,IAAI,KAAK,SAAS,CAAC,MAAM,MAAM,S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