@mui/x-tree-view
Version:
The community edition of the MUI X Tree View components.
73 lines (72 loc) • 2.44 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.itemsSelectors = void 0;
var _utils = require("./utils");
const EMPTY_CHILDREN = [];
const itemsSelectors = exports.itemsSelectors = {
/**
* Gets the DOM structure of the Tree View.
*/
domStructure: state => state.domStructure,
/**
* Checks whether the disabled items are focusable.
*/
disabledItemFocusable: state => state.disabledItemsFocusable,
/**
* Gets the meta-information of all items.
*/
itemMetaLookup: state => state.itemMetaLookup,
/**
* Gets the ordered children ids of all items.
*/
itemOrderedChildrenIdsLookup: state => state.itemOrderedChildrenIdsLookup,
/**
* Gets the meta-information of an item.
*/
itemMeta: (state, itemId) => state.itemMetaLookup[itemId ?? _utils.TREE_VIEW_ROOT_PARENT_ID] ?? null,
/**
* Gets the ordered children ids of an item.
*/
itemOrderedChildrenIds: (state, itemId) => state.itemOrderedChildrenIdsLookup[itemId ?? _utils.TREE_VIEW_ROOT_PARENT_ID] ?? EMPTY_CHILDREN,
/**
* Gets the model of an item.
*/
itemModel: (state, itemId) => state.itemModelLookup[itemId],
/**
* Checks whether an item is disabled.
*/
isItemDisabled: (state, itemId) => (0, _utils.isItemDisabled)(state.itemMetaLookup, itemId),
/**
* Gets the index of an item in its parent's children.
*/
itemIndex: (state, itemId) => {
const itemMeta = state.itemMetaLookup[itemId];
if (itemMeta == null) {
return -1;
}
const parentIndexes = state.itemChildrenIndexesLookup[itemMeta.parentId ?? _utils.TREE_VIEW_ROOT_PARENT_ID];
return parentIndexes[itemMeta.id];
},
/**
* Gets the id of an item's parent.
*/
itemParentId: (state, itemId) => state.itemMetaLookup[itemId]?.parentId ?? null,
/**
* Gets the depth of an item (items at the root level have a depth of 0).
*/
itemDepth: (state, itemId) => state.itemMetaLookup[itemId]?.depth ?? 0,
/**
* Checks whether an item can be focused.
*/
canItemBeFocused: (state, itemId) => state.disabledItemsFocusable || state.itemModelLookup[itemId] != null && !(0, _utils.isItemDisabled)(state.itemMetaLookup, itemId),
/**
* Gets the identation between an item and its children.
*/
itemChildrenIndentation: state => state.itemChildrenIndentation,
/**
* Gets the height of an individual item.
*/
itemHeight: state => state.itemHeight
};