UNPKG

1.82 kBJavaScriptView Raw
1function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
3import * as React from 'react';
4import { StyleSheet, View } from 'react-native';
5
6/**
7 * A component to show a list of actions in a Dialog.
8 *
9 * <div class="screenshots">
10 * <figure>
11 * <img class="medium" src="screenshots/dialog-actions.png" />
12 * </figure>
13 * </div>
14 *
15 * ## Usage
16 * ```js
17 * import * as React from 'react';
18 * import { Button, Dialog, Portal } from 'react-native-paper';
19 *
20 * const MyComponent = () => {
21 * const [visible, setVisible] = React.useState(false);
22 *
23 * const hideDialog = () => setVisible(false);
24 *
25 * return (
26 * <Portal>
27 * <Dialog visible={visible} onDismiss={hideDialog}>
28 * <Dialog.Actions>
29 * <Button onPress={() => console.log('Cancel')}>Cancel</Button>
30 * <Button onPress={() => console.log('Ok')}>Ok</Button>
31 * </Dialog.Actions>
32 * </Dialog>
33 * </Portal>
34 * );
35 * };
36 *
37 * export default MyComponent;
38 * ```
39 */
40const DialogActions = props => /*#__PURE__*/React.createElement(View, _extends({}, props, {
41 style: [styles.container, props.style]
42}), React.Children.map(props.children, child => /*#__PURE__*/React.isValidElement(child) ? /*#__PURE__*/React.cloneElement(child, {
43 compact: true
44}) : child));
45
46DialogActions.displayName = 'Dialog.Actions';
47const styles = StyleSheet.create({
48 container: {
49 flexDirection: 'row',
50 alignItems: 'center',
51 justifyContent: 'flex-end',
52 padding: 8
53 }
54});
55export default DialogActions;
56//# sourceMappingURL=DialogActions.js.map
\No newline at end of file