| 1 |
import { __rest } from "tslib"; |
| 2 |
import { jsx as _jsx } from "react/jsx-runtime"; |
| 3 |
import styles from '@patternfly/react-styles/css/layouts/Grid/grid.mjs'; |
| 4 |
import { css } from '@patternfly/react-styles'; |
| 5 |
import { DeviceSizes } from '../../styles/sizes'; |
| 6 |
import * as gridToken from '@patternfly/react-tokens/dist/esm/l_grid_item_Order'; |
| 7 |
import { setBreakpointCssVars } from '../../helpers/util'; |
| 8 |
export const GridItem = (_a) => { |
| 9 |
var { children = null, className = '', component = 'div', span = null, rowSpan = null, offset = null, order, style } = _a, props = __rest(_a, ["children", "className", "component", "span", "rowSpan", "offset", "order", "style"]); |
| 10 |
const classes = [ |
| 11 |
styles.gridItem, |
| 12 |
span && styles.modifiers[`${span}Col`], |
| 13 |
rowSpan && styles.modifiers[`${rowSpan}Row`], |
| 14 |
offset && styles.modifiers[`offset_${offset}Col`] |
| 15 |
]; |
| 16 |
const Component = component; |
| 17 |
Object.entries(DeviceSizes).forEach(([propKey, classModifier]) => { |
| 18 |
const key = propKey; |
| 19 |
const rowSpanKey = `${key}RowSpan`; |
| 20 |
const offsetKey = `${key}Offset`; |
| 21 |
const spanValue = props[key]; |
| 22 |
const rowSpanValue = props[rowSpanKey]; |
| 23 |
const offsetValue = props[offsetKey]; |
| 24 |
if (spanValue) { |
| 25 |
classes.push(styles.modifiers[`${spanValue}ColOn${classModifier}`]); |
| 26 |
} |
| 27 |
if (rowSpanValue) { |
| 28 |
classes.push(styles.modifiers[`${rowSpanValue}RowOn${classModifier}`]); |
| 29 |
} |
| 30 |
if (offsetValue) { |
| 31 |
classes.push(styles.modifiers[`offset_${offsetValue}ColOn${classModifier}`]); |
| 32 |
} |
| 33 |
delete props[key]; |
| 34 |
delete props[rowSpanKey]; |
| 35 |
delete props[offsetKey]; |
| 36 |
}); |
| 37 |
return (_jsx(Component, Object.assign({ className: css(...classes, className), style: style || order ? Object.assign(Object.assign({}, style), setBreakpointCssVars(order, gridToken.l_grid_item_Order.name)) : undefined }, props, { children: children }))); |
| 38 |
}; |
| 39 |
GridItem.displayName = 'GridItem'; |
| 40 |
//# sourceMappingURL=GridItem.js.map |