modules_DataGrid_utils_index.js
import { getModules } from '../../../utils/module-utils';
export const DATE_KEY = 'date_created';
export const SEARCH_KEY = 'search';
/**
* @function getColumnStyle
* @description Get the column style.
*
* @since 4.3.0
*
* @param {object} styleProps The style properties.
* @param {boolean} equalGrid Whether the grid is equal or not.
*
* @return {object} The column style.
*/
export const getColumnStyle = (
styleProps = {},
equalGrid = false
) => {
const defaultStyle = { flex: '1 0px' };
if ( ! styleProps || equalGrid ) {
return defaultStyle;
}
// Filter style props to only allowed properties.
const allowedProperties = [ 'flex', 'flexGrow', 'flexShrink', 'flexBasis' ];
const filteredStyleProps = Object.keys( styleProps )
.filter( ( key ) => allowedProperties.includes( key ) )
.reduce( ( obj, key ) => {
obj[ key ] = styleProps[ key ];
return obj;
}, {} );
return Object.assign( defaultStyle, filteredStyleProps );
};
export { getModules };