42 lines
1.5 KiB
JavaScript
42 lines
1.5 KiB
JavaScript
define(["require", "exports"], function (require, exports) {
|
|
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.getIsChecked = getIsChecked;
|
|
exports.hasSubmenu = hasSubmenu;
|
|
exports.isItemDisabled = isItemDisabled;
|
|
exports.getMenuItemAriaRole = getMenuItemAriaRole;
|
|
/**
|
|
* Determines the effective checked state of a menu item.
|
|
*
|
|
* @param item {IContextualMenuItem} to get the check state of.
|
|
* @returns {true} if the item is checked.
|
|
* @returns {false} if the item is unchecked.
|
|
* @returns {null} if the item is not checkable.
|
|
*/
|
|
function getIsChecked(item) {
|
|
if (item.canCheck) {
|
|
return !!(item.isChecked || item.checked);
|
|
}
|
|
if (typeof item.isChecked === 'boolean') {
|
|
return item.isChecked;
|
|
}
|
|
if (typeof item.checked === 'boolean') {
|
|
return item.checked;
|
|
}
|
|
// Item is not checkable.
|
|
return null;
|
|
}
|
|
function hasSubmenu(item) {
|
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
return !!(item.subMenuProps || item.items);
|
|
}
|
|
function isItemDisabled(item) {
|
|
return !!(item.isDisabled || item.disabled);
|
|
}
|
|
function getMenuItemAriaRole(item) {
|
|
var isChecked = getIsChecked(item);
|
|
var canCheck = isChecked !== null;
|
|
return canCheck ? 'menuitemcheckbox' : 'menuitem';
|
|
}
|
|
});
|
|
//# sourceMappingURL=contextualMenuUtility.js.map
|