UNPKG

@nexara/nativeflow

Version:

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

64 lines (63 loc) 1.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _react = require("react"); var _reactNative = require("react-native"); var _index = require("../../helpers/index.js"); var _index2 = require("../../hooks/index.js"); var _index3 = require("../StyledComponents/index.js"); var _jsxRuntime = require("react/jsx-runtime"); const Grid = ({ container = false, item = false, spacing = 0, spacingH = 0, spacingV = 0, size = 12, xs = 12, sm = 0, md = 0, lg = 0, xl = 0, containerStyle, children, ...rest }) => { container = !item; xs = Math.min(xs, 12); sm = Math.min(sm, 12); md = Math.min(md, 12); lg = Math.min(lg, 12); xl = Math.min(xl, 12); const { width: windowWidth } = (0, _index2.useConditionalWindowDimension)(item); const calculatedGridValue = item ? (0, _react.useMemo)(() => (0, _index.getGridValue)({ xs, sm, md, lg, xl }, windowWidth), [windowWidth, xs, sm, md, lg, xl]) : 12; const STYLES = _reactNative.StyleSheet.create({ MAIN_CONT: { width: item ? `${calculatedGridValue / size * 100}%` : "100%", flexDirection: 'row', flexWrap: container ? 'wrap' : 'nowrap', paddingHorizontal: spacingH, paddingVertical: spacingV, gap: spacing } }); return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, { children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index3.StyledView, { style: [STYLES.MAIN_CONT, containerStyle], ...rest, children: children }) }); }; var _default = exports.default = Grid; //# sourceMappingURL=Grid.js.map