UNPKG

@bitrix24/b24ui-nuxt

Version:

Bitrix24 UI-Kit for developing web applications REST API for NUXT & VUE

42 lines (41 loc) 1.01 kB
import { get } from "./index.js"; function itemHasDescription(item, descriptionKey) { if (typeof item !== "object" || item === null) { return false; } const value = get(item, descriptionKey); return value !== void 0 && value !== null && value !== ""; } function getSize(size, hasDescription) { if (hasDescription) { return { xss: 40, xs: 44, sm: 48, md: 52, lg: 56, xl: 60 }[size]; } return { xss: 20, xs: 24, sm: 28, md: 32, lg: 36, xl: 40 }[size]; } export function getEstimateSize(items, size, descriptionKey, hasDescriptionSlot) { const sizeWithDescription = getSize(size, true); const sizeWithoutDescription = getSize(size, false); if (hasDescriptionSlot) { return () => sizeWithDescription; } if (!descriptionKey) { return () => sizeWithoutDescription; } return (index) => { return itemHasDescription(items[index], descriptionKey) ? sizeWithDescription : sizeWithoutDescription; }; }