@progress/kendo-angular-layout
Version:
Kendo UI for Angular Layout Package - a collection of components to create professional application layoyts
102 lines (101 loc) • 2.81 kB
JavaScript
/**-----------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the project root for more information
*-------------------------------------------------------------------------------------------*/
/**
* @hidden
*/
export const VERTICAL_SUFFIX = {
top: 'start',
middle: 'center',
bottom: 'end',
stretch: 'stretch'
};
/**
* @hidden
*/
export const JUSTIFY_PREFIX = `k-justify-content`;
/**
* @hidden
*/
export const GRID_JUSTIFY_PREFIX = `k-justify-items`;
/**
* @hidden
*/
export const ALIGN_PREFIX = `k-align-items`;
/**
* @hidden
*/
export const normalizeGap = (gap) => {
if (typeof gap === 'number' || typeof gap === 'string') {
return { cols: gap, rows: gap };
}
else {
const parsedGap = {};
parsedGap.rows = gap.rows ? gap.rows : 0;
parsedGap.cols = gap.cols ? gap.cols : 0;
return parsedGap;
}
};
/**
* @hidden
*/
export const generateGapStyle = (gap) => {
if (gap.rows === gap.cols) {
return typeof gap.rows === 'number' ? `${gap.rows}px` : gap.rows;
}
else {
const rowStyle = `${typeof gap.rows === 'number' ? gap.rows + 'px' : gap.rows}`;
const colStyle = `${typeof gap.cols === 'number' ? gap.cols + 'px' : gap.cols}`;
return `${rowStyle} ${colStyle}`;
}
};
/**
* @hidden
*/
export const generateGridStyle = (items, itemType) => {
const styling = [];
items.forEach((item) => {
if (typeof item === 'number') {
styling.push(`${item}px`);
}
else if (typeof item === 'string') {
styling.push(item);
}
else {
if (itemType === 'rows') {
const rowHeight = item.height;
if (rowHeight) {
styling.push(typeof rowHeight === 'number' ? `${rowHeight}px` : rowHeight);
}
else {
styling.push('0px');
}
}
else {
const colWidth = item.width;
if (colWidth) {
styling.push(typeof colWidth === 'number' ? `${colWidth}px` : colWidth);
}
else {
styling.push('0px');
}
}
}
});
return styling;
};
/**
* @hidden
*/
export const validateGridLayoutRowsCols = (arr) => {
for (const el of arr) {
const isNum = typeof el === 'number';
const isStr = typeof el === 'string';
const isObject = typeof el === 'object' && el !== null;
if (!isNum && !isStr && !isObject) {
return false;
}
}
return true;
};