GT2/Ejectable/node_modules/react-native-safe-area-context/lib/commonjs/NativeSafeAreaProvider.js.map

1 line
7.8 KiB
Plaintext

{"version":3,"sources":["NativeSafeAreaProvider.tsx"],"names":["CSSTransitions","WebkitTransition","Transition","MozTransition","MSTransition","OTransition","NativeSafeAreaView","children","style","onInsetsChange","React","useEffect","document","element","createContextElement","body","appendChild","onEnd","paddingTop","paddingBottom","paddingLeft","paddingRight","window","getComputedStyle","insets","top","parseInt","bottom","left","right","frame","x","y","width","documentElement","offsetWidth","height","offsetHeight","nativeEvent","addEventListener","getSupportedTransitionEvent","removeChild","removeEventListener","_supportedTransitionEvent","createElement","key","undefined","_supportedEnv","getSupportedEnv","CSS","supports","getInset","side","position","zIndex","overflow","visibility","transitionDuration","transitionProperty","transitionDelay"],"mappings":";;;;;;;AAAA;;AACA;;;;;;AAGA;;;;;;;AAQA,MAAMA,cAAsC,GAAG;AAC7CC,EAAAA,gBAAgB,EAAE,qBAD2B;AAE7CC,EAAAA,UAAU,EAAE,eAFiC;AAG7CC,EAAAA,aAAa,EAAE,eAH8B;AAI7CC,EAAAA,YAAY,EAAE,iBAJ+B;AAK7CC,EAAAA,WAAW,EAAE;AALgC,CAA/C;;AAQe,SAASC,kBAAT,CAA4B;AACzCC,EAAAA,QADyC;AAEzCC,EAAAA,KAFyC;AAGzCC,EAAAA;AAHyC,CAA5B,EAIiB;AAC9BC,EAAAA,KAAK,CAACC,SAAN,CAAgB,MAAM;AACpB;AACA,QAAI,OAAOC,QAAP,KAAoB,WAAxB,EAAqC;AACnC;AACD;;AAED,UAAMC,OAAO,GAAGC,oBAAoB,EAApC;AACAF,IAAAA,QAAQ,CAACG,IAAT,CAAcC,WAAd,CAA0BH,OAA1B;;AACA,UAAMI,KAAK,GAAG,MAAM;AAClB,YAAM;AACJC,QAAAA,UADI;AAEJC,QAAAA,aAFI;AAGJC,QAAAA,WAHI;AAIJC,QAAAA;AAJI,UAKFC,MAAM,CAACC,gBAAP,CAAwBV,OAAxB,CALJ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A5B,EAAAA,KAAK,CAAC8C,MAAN,GAAe,IAAf;AACA9C,EAAAA,KAAK,CAAC+C,QAAN,GAAiB,QAAjB;AACA/C,EAAAA,KAAK,CAACgD,UAAN,GAAmB,QAAnB,CAV2C,CAW3C;;AACAhD,EAAAA,KAAK,CAACiD,kBAAN,GAA2B,OAA3B;AACAjD,EAAAA,KAAK,CAACkD,kBAAN,GAA2B,SAA3B;AACAlD,EAAAA,KAAK,CAACmD,eAAN,GAAwB,IAAxB;AACAnD,EAAAA,KAAK,CAACU,UAAN,GAAmBiC,QAAQ,CAAC,KAAD,CAA3B;AACA3C,EAAAA,KAAK,CAACW,aAAN,GAAsBgC,QAAQ,CAAC,QAAD,CAA9B;AACA3C,EAAAA,KAAK,CAACY,WAAN,GAAoB+B,QAAQ,CAAC,MAAD,CAA5B;AACA3C,EAAAA,KAAK,CAACa,YAAN,GAAqB8B,QAAQ,CAAC,OAAD,CAA7B;AACA,SAAOtC,OAAP;AACD","sourcesContent":["import * as React from 'react';\nimport { View } from 'react-native';\nimport { NativeSafeAreaProviderProps } from './SafeArea.types';\n\n/**\n * TODO:\n * Currently insets and frame are based on the window and are not\n * relative to the provider view. This is inconsistent with iOS and Android.\n * However in most cases if the provider view covers the screen this is not\n * an issue.\n */\n\nconst CSSTransitions: Record<string, string> = {\n WebkitTransition: 'webkitTransitionEnd',\n Transition: 'transitionEnd',\n MozTransition: 'transitionend',\n MSTransition: 'msTransitionEnd',\n OTransition: 'oTransitionEnd',\n};\n\nexport default function NativeSafeAreaView({\n children,\n style,\n onInsetsChange,\n}: NativeSafeAreaProviderProps) {\n React.useEffect(() => {\n // Skip for SSR.\n if (typeof document === 'undefined') {\n return;\n }\n\n const element = createContextElement();\n document.body.appendChild(element);\n const onEnd = () => {\n const {\n paddingTop,\n paddingBottom,\n paddingLeft,\n paddingRight,\n } = window.getComputedStyle(element);\n\n const insets = {\n top: paddingTop ? parseInt(paddingTop, 10) : 0,\n bottom: paddingBottom ? parseInt(paddingBottom, 10) : 0,\n left: paddingLeft ? parseInt(paddingLeft, 10) : 0,\n right: paddingRight ? parseInt(paddingRight, 10) : 0,\n };\n const frame = {\n x: 0,\n y: 0,\n width: document.documentElement.offsetWidth,\n height: document.documentElement.offsetHeight,\n };\n // @ts-ignore: missing properties\n onInsetsChange({ nativeEvent: { insets, frame } });\n };\n element.addEventListener(getSupportedTransitionEvent(), onEnd);\n onEnd();\n return () => {\n document.body.removeChild(element);\n element.removeEventListener(getSupportedTransitionEvent(), onEnd);\n };\n }, [onInsetsChange]);\n\n return <View style={style}>{children}</View>;\n}\n\nlet _supportedTransitionEvent: string | null = null;\nfunction getSupportedTransitionEvent(): string {\n if (_supportedTransitionEvent !== null) {\n return _supportedTransitionEvent;\n }\n const element = document.createElement('invalidtype');\n\n _supportedTransitionEvent = CSSTransitions.Transition;\n for (const key in CSSTransitions) {\n if (element.style[key as keyof CSSStyleDeclaration] !== undefined) {\n _supportedTransitionEvent = CSSTransitions[key];\n break;\n }\n }\n return _supportedTransitionEvent;\n}\n\ntype CssEnv = 'constant' | 'env';\n\nlet _supportedEnv: CssEnv | null = null;\nfunction getSupportedEnv(): CssEnv {\n if (_supportedEnv !== null) {\n return _supportedEnv;\n }\n const { CSS } = window;\n if (\n CSS &&\n CSS.supports &&\n CSS.supports('top: constant(safe-area-inset-top)')\n ) {\n _supportedEnv = 'constant';\n } else {\n _supportedEnv = 'env';\n }\n return _supportedEnv;\n}\n\nfunction getInset(side: string): string {\n return `${getSupportedEnv()}(safe-area-inset-${side})`;\n}\n\nfunction createContextElement(): HTMLElement {\n const element = document.createElement('div');\n const { style } = element;\n style.position = 'fixed';\n style.left = '0';\n style.top = '0';\n style.width = '0';\n style.height = '0';\n style.zIndex = '-1';\n style.overflow = 'hidden';\n style.visibility = 'hidden';\n // Bacon: Anything faster than this and the callback will be invoked too early with the wrong insets\n style.transitionDuration = '0.05s';\n style.transitionProperty = 'padding';\n style.transitionDelay = '0s';\n style.paddingTop = getInset('top');\n style.paddingBottom = getInset('bottom');\n style.paddingLeft = getInset('left');\n style.paddingRight = getInset('right');\n return element;\n}\n"]}