UNPKG

@public-ui/components

Version:

Contains all web components that belong to KoliBri - The accessible HTML-Standard.

38 lines (37 loc) 1.64 kB
/*! * KoliBri - The accessible HTML-Standard */ import { emptyStringByArrayHandler, objectObjectHandler, parseJson, watchValidator } from "../utils"; const isHeaderRows = (rows) => { return Array.isArray(rows) && rows.every((headerRow) => Array.isArray(headerRow)); }; export const validateTableHeaderCells = (component, value) => { emptyStringByArrayHandler(value, () => { objectObjectHandler(value, () => { try { value = parseJson(value); } catch (e) { void e; } watchValidator(component, '_headerCells', (value) => { if (typeof value !== 'object' || value === null) return false; const horizontal = value.horizontal; const vertical = value.vertical; if ((horizontal !== undefined && !isHeaderRows(horizontal)) || (vertical !== undefined && !isHeaderRows(vertical))) { return false; } const allHeaderCells = []; for (const row of horizontal !== null && horizontal !== void 0 ? horizontal : []) { allHeaderCells.push(...row); } for (const col of vertical !== null && vertical !== void 0 ? vertical : []) { allHeaderCells.push(...col); } return allHeaderCells.every((cell) => cell.width === undefined || typeof cell.width === 'number'); }, new Set(['TableHeaderCellsPropType']), value); }); }); }; //# sourceMappingURL=table-header-cells.js.map