handsontable
Version:
Handsontable is a JavaScript Data Grid available for React, Angular and Vue.
37 lines (35 loc) • 1.7 kB
JavaScript
;
exports.__esModule = true;
exports.default = columnRightItem;
var C = _interopRequireWildcard(require("../../../i18n/constants"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
const KEY = exports.KEY = 'col_right';
/**
* @returns {object}
*/
function columnRightItem() {
return {
key: KEY,
name() {
return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_INSERT_RIGHT);
},
callback() {
const activeSelection = this.getSelectedRangeActive().getTopRightCorner();
const alterAction = this.isRtl() ? 'insert_col_start' : 'insert_col_end';
this.alter(alterAction, activeSelection.col, 1, 'ContextMenu.columnRight');
},
disabled() {
if (!this.isColumnModificationAllowed()) {
return true;
}
const range = this.getSelectedRangeActive();
if (!range || this.selection.isSelectedByRowHeader() || range.isSingleHeader() && range.highlight.col < 0 || this.countSourceCols() >= this.getSettings().maxCols) {
return true;
}
return false;
},
hidden() {
return !this.getSettings().allowInsertColumn;
}
};
}