UNPKG

repoweaver

Version:

A GitHub App that skillfully weaves multiple templates together to create and update repositories with intelligent merge strategies

1 lines 9.15 kB
{"ast":null,"code":"import Dimensions from \"react-native-web/dist/exports/Dimensions\";\nimport StyleSheet from \"react-native-web/dist/exports/StyleSheet\";\nconst overflowLeft = center => {\n return center < 0;\n};\nconst overflowRight = (center, tooltipWidth) => {\n const {\n width: layoutWidth\n } = Dimensions.get('window');\n return center + tooltipWidth > layoutWidth;\n};\nconst overflowBottom = (childrenY, childrenHeight, tooltipHeight) => {\n const {\n height: layoutHeight\n } = Dimensions.get('window');\n return childrenY + childrenHeight + tooltipHeight > layoutHeight;\n};\nconst getTooltipXPosition = ({\n pageX: childrenX,\n width: childrenWidth\n}, {\n width: tooltipWidth\n}) => {\n const center = childrenWidth > 0 ? childrenX + (childrenWidth - tooltipWidth) / 2 : childrenX;\n if (overflowLeft(center)) return childrenX;\n if (overflowRight(center, tooltipWidth)) return childrenX + childrenWidth - tooltipWidth;\n return center;\n};\nconst getTooltipYPosition = ({\n pageY: childrenY,\n height: childrenHeight\n}, {\n height: tooltipHeight\n}) => {\n if (overflowBottom(childrenY, childrenHeight, tooltipHeight)) return childrenY - tooltipHeight;\n return childrenY + childrenHeight;\n};\nconst getChildrenMeasures = (style, measures) => {\n const {\n position,\n top,\n bottom,\n left,\n right\n } = StyleSheet.flatten(style);\n if (position === 'absolute') {\n let pageX = 0;\n let pageY = measures.pageY;\n let height = 0;\n let width = 0;\n if (typeof left === 'number') {\n pageX = left;\n width = 0;\n }\n if (typeof right === 'number') {\n pageX = measures.width - right;\n width = 0;\n }\n if (typeof top === 'number') {\n pageY = pageY + top;\n }\n if (typeof bottom === 'number') {\n pageY = pageY - bottom;\n }\n return {\n pageX,\n pageY,\n width,\n height\n };\n }\n return measures;\n};\nexport const getTooltipPosition = ({\n children,\n tooltip,\n measured\n}, component) => {\n if (!measured) return {};\n let measures = children;\n if (component.props.style) {\n measures = getChildrenMeasures(component.props.style, children);\n }\n return {\n left: getTooltipXPosition(measures, tooltip),\n top: getTooltipYPosition(measures, tooltip)\n };\n};","map":{"version":3,"names":["overflowLeft","center","overflowRight","tooltipWidth","width","layoutWidth","Dimensions","get","overflowBottom","childrenY","childrenHeight","tooltipHeight","height","layoutHeight","getTooltipXPosition","pageX","childrenX","childrenWidth","getTooltipYPosition","pageY","getChildrenMeasures","style","measures","position","top","bottom","left","right","StyleSheet","flatten","getTooltipPosition","children","tooltip","measured","component","props"],"sources":["/Users/pmouli/Documents/GitHub.nosync/boots-strapper/mobile/node_modules/react-native-paper/src/components/Tooltip/utils.ts"],"sourcesContent":["import {\n Dimensions,\n LayoutRectangle,\n StyleProp,\n ViewStyle,\n StyleSheet,\n} from 'react-native';\n\ntype ChildrenMeasurement = {\n width: number;\n height: number;\n pageX: number;\n pageY: number;\n};\n\ntype TooltipLayout = LayoutRectangle;\n\nexport type Measurement = {\n children: ChildrenMeasurement;\n tooltip: TooltipLayout;\n measured: boolean;\n};\n\nexport type TooltipChildProps = {\n style: StyleProp<ViewStyle>;\n disabled?: boolean;\n onPress?: () => void;\n onHoverIn?: () => void;\n onHoverOut?: () => void;\n};\n\n/**\n * Return true when the tooltip center x-coordinate relative to the wrapped element is negative.\n * The tooltip will be placed at the starting x-coordinate from the wrapped element.\n */\nconst overflowLeft = (center: number): boolean => {\n return center < 0;\n};\n\n/**\n * Return true when the tooltip center x-coordinate + tooltip width is greater than the layout width\n * The tooltip width will grow from right to left relative to the wrapped element.\n */\nconst overflowRight = (center: number, tooltipWidth: number): boolean => {\n const { width: layoutWidth } = Dimensions.get('window');\n\n return center + tooltipWidth > layoutWidth;\n};\n\n/**\n * Return true when the children y-coordinate + its height + tooltip height is greater than the layout height.\n * The tooltip will be placed at the top of the wrapped element.\n */\nconst overflowBottom = (\n childrenY: number,\n childrenHeight: number,\n tooltipHeight: number\n): boolean => {\n const { height: layoutHeight } = Dimensions.get('window');\n\n return childrenY + childrenHeight + tooltipHeight > layoutHeight;\n};\n\nconst getTooltipXPosition = (\n { pageX: childrenX, width: childrenWidth }: ChildrenMeasurement,\n { width: tooltipWidth }: TooltipLayout\n): number => {\n // when the children use position absolute the childrenWidth is measured as 0,\n // so it's best to anchor the tooltip at the start of the children\n const center =\n childrenWidth > 0\n ? childrenX + (childrenWidth - tooltipWidth) / 2\n : childrenX;\n\n if (overflowLeft(center)) return childrenX;\n\n if (overflowRight(center, tooltipWidth))\n return childrenX + childrenWidth - tooltipWidth;\n\n return center;\n};\n\nconst getTooltipYPosition = (\n { pageY: childrenY, height: childrenHeight }: ChildrenMeasurement,\n { height: tooltipHeight }: TooltipLayout\n): number => {\n if (overflowBottom(childrenY, childrenHeight, tooltipHeight))\n return childrenY - tooltipHeight;\n\n return childrenY + childrenHeight;\n};\n\nconst getChildrenMeasures = (\n style: StyleProp<ViewStyle>,\n measures: ChildrenMeasurement\n): ChildrenMeasurement => {\n const { position, top, bottom, left, right } = StyleSheet.flatten(style);\n\n if (position === 'absolute') {\n let pageX = 0;\n let pageY = measures.pageY;\n let height = 0;\n let width = 0;\n if (typeof left === 'number') {\n pageX = left;\n width = 0;\n }\n if (typeof right === 'number') {\n pageX = measures.width - right;\n width = 0;\n }\n if (typeof top === 'number') {\n pageY = pageY + top;\n }\n if (typeof bottom === 'number') {\n pageY = pageY - bottom;\n }\n\n return { pageX, pageY, width, height };\n }\n\n return measures;\n};\n\nexport const getTooltipPosition = (\n { children, tooltip, measured }: Measurement,\n component: React.ReactElement<{\n style: StyleProp<ViewStyle>;\n }>\n): {} | { left: number; top: number } => {\n if (!measured) return {};\n let measures = children;\n if (component.props.style) {\n measures = getChildrenMeasures(component.props.style, children);\n }\n\n return {\n left: getTooltipXPosition(measures, tooltip),\n top: getTooltipYPosition(measures, tooltip),\n };\n};\n"],"mappings":";;AAmCA,MAAMA,YAAY,GAAIC,MAAc,IAAc;EAChD,OAAOA,MAAM,GAAG,CAAC;AACnB,CAAC;AAMD,MAAMC,aAAa,GAAGA,CAACD,MAAc,EAAEE,YAAoB,KAAc;EAC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