UNPKG

@nexara/nativeflow

Version:

Beautiful, responsive, and customizable UI components for React Native – built for performance and seamless experiences.

83 lines (82 loc) 2.27 kB
"use strict"; import React from 'react'; import { StyleSheet, TouchableOpacity } from 'react-native'; import { StyledText, StyledView } from "../StyledComponents/index.js"; import { horizontalScale, verticalScale } from "../../helpers/ResponsiveCalculations.js"; import { useTheme } from "../../hooks/index.js"; import { getChipColors } from "./utils.js"; import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; const Chip = ({ label = 'Chip', labelColor, fs, fScale = 'sm', ff, bg, br = 7, gap = 7, paddingV = 6, paddingH = 15, stroke = 0.8, strokeColor, rippleColor, disabled = false, renderLeftIcon, renderRightIcon, containerStyle, textStyle, active = false, ...rest }) => { const theme = useTheme(); const { buttonTextColor, buttonBorderColor, backgroundColor } = getChipColors({ theme, bg, labelColor, strokeColor, disabled, active }); const STYLES = StyleSheet.create({ CONTAINER: { flexDirection: 'row', alignItems: 'center', borderWidth: stroke, borderColor: buttonBorderColor, backgroundColor: backgroundColor, borderRadius: verticalScale(br), paddingVertical: verticalScale(paddingV), paddingLeft: horizontalScale((renderLeftIcon && paddingH / 2) ?? paddingH), paddingRight: horizontalScale((renderRightIcon && paddingH / 2) ?? paddingH), gap: horizontalScale(gap) }, TEXT: { color: buttonTextColor } }); return /*#__PURE__*/_jsx(_Fragment, { children: /*#__PURE__*/_jsx(StyledView, { alignSelf: "flex-start", children: /*#__PURE__*/_jsx(TouchableOpacity, { disabled: disabled, ...rest, children: /*#__PURE__*/_jsxs(StyledView, { style: [STYLES.CONTAINER, containerStyle], children: [/*#__PURE__*/React.isValidElement(renderLeftIcon) && renderLeftIcon, /*#__PURE__*/_jsx(StyledText, { fScale: fScale, ff: ff, fs: fs, style: [STYLES.TEXT, textStyle], children: label }), /*#__PURE__*/React.isValidElement(renderRightIcon) && renderRightIcon] }) }) }) }); }; export default Chip; //# sourceMappingURL=Chip.js.map