terra-table
Version:
The Terra Table component provides user a way to display data in an accessible table format.
34 lines (32 loc) • 1.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.validateRowHeaderIndex = exports.validateAction = void 0;
var _constants = require("../utils/constants");
// eslint-disable-next-line consistent-return
var validateRowHeaderIndex = exports.validateRowHeaderIndex = function validateRowHeaderIndex(props) {
if (!Number.isInteger(props.rowHeaderIndex)) {
return new Error(_constants.ERRORS.ROW_HEADER_INDEX_NOT_AN_INTEGER);
}
if (props.rowHeaderIndex < -1) {
return new Error(_constants.ERRORS.ROW_HEADER_INDEX_LESS_THAN_MINUS_ONE);
}
if (props.pinnedColumns.length && props.rowHeaderIndex >= props.pinnedColumns.length) {
return new Error(_constants.ERRORS.ROW_HEADER_INDEX_EXCEEDS_PINNED);
}
};
// eslint-disable-next-line consistent-return
var validateAction = exports.validateAction = function validateAction(props) {
if (props.action) {
if (!props.action.label || props.action.label.length < 1) {
return new Error(_constants.ERRORS.ACTION_LABEL_MISSING);
}
if (!props.action.onClick) {
return new Error(_constants.ERRORS.ACTION_ONCLICK_MISSING);
}
if (props.action.onClick && typeof props.action.onClick !== 'function') {
return new Error(_constants.ERRORS.ACTION_ONCLICK_IS_NOT_A_FUNCTION);
}
}
};