@nexara/nativeflow
Version:
Beautiful, responsive, and customizable UI components for React Native – built for performance and seamless experiences.
59 lines (58 loc) • 1.44 kB
JavaScript
import React, { useMemo } from 'react';
import { View, StyleSheet } from "react-native";
import { getGridValue } from "../../helpers/index.js";
import { useConditionalWindowDimension } from "../../hooks/index.js";
import { jsx as _jsx, Fragment as _Fragment } from "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
} = useConditionalWindowDimension(item);
const calculatedGridValue = item ? useMemo(() => getGridValue({
xs,
sm,
md,
lg,
xl
}, windowWidth), [windowWidth, xs, sm, md, lg, xl]) : 12;
const STYLES = StyleSheet.create({
MAIN_CONT: {
width: item ? `${calculatedGridValue / size * 100}%` : "100%",
flexDirection: 'row',
flexWrap: container ? 'wrap' : 'nowrap',
paddingHorizontal: spacingH,
paddingVertical: spacingV,
gap: spacing
}
});
return /*#__PURE__*/_jsx(_Fragment, {
children: /*#__PURE__*/_jsx(View, {
style: [STYLES.MAIN_CONT, containerStyle],
...rest,
children: children
})
});
};
export default Grid;
//# sourceMappingURL=Grid.js.map
;