UNPKG

repoweaver

Version:

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

1 lines 6.28 kB
{"ast":null,"code":"import * as React from 'react';\nimport StyleSheet from \"react-native-web/dist/exports/StyleSheet\";\nimport View from \"react-native-web/dist/exports/View\";\nimport ToggleButton from \"./ToggleButton\";\nimport ToggleButtonGroup from \"./ToggleButtonGroup\";\nconst ToggleButtonRow = ({\n value,\n onValueChange,\n children,\n style\n}) => {\n const count = React.Children.count(children);\n return React.createElement(ToggleButtonGroup, {\n value: value,\n onValueChange: onValueChange\n }, React.createElement(View, {\n style: [styles.row, style]\n }, React.Children.map(children, (child, i) => {\n if (child && child.type === ToggleButton) {\n return React.cloneElement(child, {\n style: [styles.button, i === 0 ? styles.first : i === count - 1 ? styles.last : styles.middle, child.props.style]\n });\n }\n return child;\n })));\n};\nToggleButtonRow.displayName = 'ToggleButton.Row';\nconst styles = StyleSheet.create({\n row: {\n flexDirection: 'row'\n },\n button: {\n borderWidth: StyleSheet.hairlineWidth\n },\n first: {\n borderTopRightRadius: 0,\n borderBottomRightRadius: 0\n },\n middle: {\n borderRadius: 0,\n borderLeftWidth: 0\n },\n last: {\n borderLeftWidth: 0,\n borderTopLeftRadius: 0,\n borderBottomLeftRadius: 0\n }\n});\nexport default ToggleButtonRow;\nexport { ToggleButtonRow };","map":{"version":3,"names":["React","StyleSheet","View","ToggleButton","ToggleButtonGroup","ToggleButtonRow","value","onValueChange","children","style","count","Children","createElement","styles","row","map","child","i","type","cloneElement","button","first","last","middle","props","displayName","create","flexDirection","borderWidth","hairlineWidth","borderTopRightRadius","borderBottomRightRadius","borderRadius","borderLeftWidth","borderTopLeftRadius","borderBottomLeftRadius"],"sources":["/Users/pmouli/Documents/GitHub.nosync/boots-strapper/mobile/node_modules/react-native-paper/src/components/ToggleButton/ToggleButtonRow.tsx"],"sourcesContent":["import * as React from 'react';\nimport { StyleSheet, View, StyleProp, ViewStyle } from 'react-native';\n\nimport ToggleButton from './ToggleButton';\nimport ToggleButtonGroup from './ToggleButtonGroup';\n\nexport type Props = {\n /**\n * Function to execute on selection change.\n */\n onValueChange: (value: string) => void;\n /**\n * Value of the currently selected toggle button.\n */\n value: string;\n /**\n * React elements containing toggle buttons.\n */\n children: React.ReactNode;\n style?: StyleProp<ViewStyle>;\n};\n\n/**\n * Toggle button row renders a group of toggle buttons in a row.\n *\n * ## Usage\n * ```js\n * import * as React from 'react';\n * import { ToggleButton } from 'react-native-paper';\n *\n * const MyComponent = () => {\n * const [value, setValue] = React.useState('left');\n *\n * return (\n * <ToggleButton.Row onValueChange={value => setValue(value)} value={value}>\n * <ToggleButton icon=\"format-align-left\" value=\"left\" />\n * <ToggleButton icon=\"format-align-right\" value=\"right\" />\n * </ToggleButton.Row>\n * );\n * };\n *\n * export default MyComponent;\n *\n *```\n */\nconst ToggleButtonRow = ({ value, onValueChange, children, style }: Props) => {\n const count = React.Children.count(children);\n\n return (\n <ToggleButtonGroup value={value} onValueChange={onValueChange}>\n <View style={[styles.row, style]}>\n {React.Children.map(children, (child, i) => {\n // @ts-expect-error: TypeScript complains about child.type but it doesn't matter\n if (child && child.type === ToggleButton) {\n // @ts-expect-error: We're sure that child is a React Element\n return React.cloneElement(child, {\n style: [\n styles.button,\n i === 0\n ? styles.first\n : i === count - 1\n ? styles.last\n : styles.middle,\n // @ts-expect-error: We're sure that child is a React Element\n child.props.style,\n ],\n });\n }\n\n return child;\n })}\n </View>\n </ToggleButtonGroup>\n );\n};\n\nToggleButtonRow.displayName = 'ToggleButton.Row';\n\nconst styles = StyleSheet.create({\n row: {\n flexDirection: 'row',\n },\n button: {\n borderWidth: StyleSheet.hairlineWidth,\n },\n\n first: {\n borderTopRightRadius: 0,\n borderBottomRightRadius: 0,\n },\n\n middle: {\n borderRadius: 0,\n borderLeftWidth: 0,\n },\n\n last: {\n borderLeftWidth: 0,\n borderTopLeftRadius: 0,\n borderBottomLeftRadius: 0,\n },\n});\n\nexport default ToggleButtonRow;\n\n// @component-docs ignore-next-line\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