| 1 |
//@ts-ignore |
| 2 |
import { isUndefined, trim, isEmpty } from "lodash"; |
| 3 |
import { TablebergBlockAttrs } from "./types"; |
| 4 |
|
| 5 |
export function getStyleClass(attributes: TablebergBlockAttrs) { |
| 6 |
const { tableWidth, tableAlignment, enableInnerBorder } = attributes; |
| 7 |
const isValueEmpty = (value: any) => { |
| 8 |
return ( |
| 9 |
isUndefined(value) || |
| 10 |
value === false || |
| 11 |
trim(value) === "" || |
| 12 |
trim(value) === "undefined undefined undefined" || |
| 13 |
isEmpty(value) |
| 14 |
); |
| 15 |
}; |
| 16 |
|
| 17 |
return { |
| 18 |
"has-table-width": !isValueEmpty(tableWidth), |
| 19 |
"has-inner-border": enableInnerBorder, |
| 20 |
[`justify-table-${tableAlignment}`]: !isValueEmpty(tableAlignment), |
| 21 |
}; |
| 22 |
} |
| 23 |
|