UNPKG

@prosperitainova/dumbo-react-native

Version:
48 lines (45 loc) 1.32 kB
"use strict"; import React from 'react'; import { StyleSheet, ScrollView } from 'react-native'; import { getColor } from '../../styles/colors'; import { styleReferenceBreaker } from '../../helpers'; import { MenuItem } from '../MenuItem'; /** Props for Menu component */ import { jsx as _jsx } from "react/jsx-runtime"; /** * Menu component for rendering a menu (list of clickable options) * * {@link https://github.com/carbon-design-system/carbon-react-native/blob/main/example/src/Views/Menu.tsx | Example code} */ export class Menu extends React.Component { get styles() { const { maxMenuHeight } = this.props; return StyleSheet.create({ wrapper: { maxHeight: maxMenuHeight || 280, backgroundColor: getColor('layer01') } }); } render() { const { items, componentProps, style } = this.props; const finalItems = items || []; return /*#__PURE__*/_jsx(ScrollView, { bounces: false, style: styleReferenceBreaker(this.styles.wrapper, style), accessibilityRole: "menu", ...(componentProps || {}), children: finalItems.map((item, index) => /*#__PURE__*/_jsx(MenuItem, { ...item, lastItem: index === finalItems.length - 1 }, index)) }); } } //# sourceMappingURL=index.js.map