UNPKG

@audira/carbon-react-native

Version:

Build React Native apps with component and shared patterns using Carbon

76 lines (75 loc) 2.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ButtonGroup = void 0; var _react = require("react"); var _reactNative = require("react-native"); var _carbonReactNativeElements = require("@audira/carbon-react-native-elements"); var _index = require("../../_internal/contexts/index.js"); var _index2 = require("../../_internal/style-sheets/index.js"); var _jsxRuntime = require("react/jsx-runtime"); const ButtonGroup = exports.ButtonGroup = /*#__PURE__*/(0, _react.forwardRef)(function ButtonGroup({ button1, button2, button3, oneAlone, size = 'large_productive', fluid, vertical, style, dir, ...props }, ref) { const globalConfigContext = (0, _react.useContext)(_index.GlobalConfigContext), styleFlexDir = mapStyleFlexDir[`${!!vertical}`], styleFluid = mapStyleFluid[`${!!fluid}`], rtlStyle = globalConfigContext.rtl && !vertical ? _index2.CommonStyleSheet.rtl : undefined; return /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.ButtonGroupContext.Provider, { value: { size, fluid, vertical }, children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, { ref: ref, ...props, dir: dir ?? globalConfigContext.rtl ? 'rtl' : undefined, style: [styleFlexDir, styleFluid, oneAlone ? _index2.FlexStyleSheet.justify_between : undefined, rtlStyle, style], children: !oneAlone || vertical ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, { children: [button1, button2, button3] }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, { children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, { style: [styleSheet.firstButtonContainer], children: button1 }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, { style: [styleFlexDir, styleFluid, styleSheet.lastTwoButttonContainer, _index2.FlexStyleSheet.justify_end, rtlStyle], children: [button2, button3] })] }) }) }); }); const styleSheet = _reactNative.StyleSheet.create({ fixedGroup: { gap: _carbonReactNativeElements.Spacing.spacing_05 }, fluidGroup: { gap: 1 }, firstButtonContainer: { width: '25%' }, lastTwoButttonContainer: { width: '50%' } }), mapStyleFlexDir = { false: _index2.FlexStyleSheet.flex_row, true: _index2.FlexStyleSheet.flex_col_reverse }, mapStyleFluid = { false: styleSheet.fixedGroup, true: styleSheet.fluidGroup }; //# sourceMappingURL=ButtonGroup.js.map