UNPKG

@mui/x-tree-view

Version:

The community edition of the MUI X Tree View components.

70 lines (69 loc) 2.71 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.itemsSelectors = void 0; var _store = require("@mui/x-internals/store"); var _utils = require("./utils"); const EMPTY_CHILDREN = []; const itemsSelectors = exports.itemsSelectors = { /** * Gets the DOM structure of the Tree View. */ domStructure: (0, _store.createSelector)(state => state.domStructure), /** * Checks whether the disabled items are focusable. */ disabledItemFocusable: (0, _store.createSelector)(state => state.disabledItemsFocusable), /** * Gets the meta-information of all items. */ itemMetaLookup: (0, _store.createSelector)(state => state.itemMetaLookup), /** * Gets the ordered children ids of all items. */ itemOrderedChildrenIdsLookup: (0, _store.createSelector)(state => state.itemOrderedChildrenIdsLookup), /** * Gets the meta-information of an item. */ itemMeta: (0, _store.createSelector)((state, itemId) => state.itemMetaLookup[itemId ?? _utils.TREE_VIEW_ROOT_PARENT_ID] ?? null), /** * Gets the ordered children ids of an item. */ itemOrderedChildrenIds: (0, _store.createSelector)((state, itemId) => state.itemOrderedChildrenIdsLookup[itemId ?? _utils.TREE_VIEW_ROOT_PARENT_ID] ?? EMPTY_CHILDREN), /** * Gets the model of an item. */ itemModel: (0, _store.createSelector)((state, itemId) => state.itemModelLookup[itemId]), /** * Checks whether an item is disabled. */ isItemDisabled: (0, _store.createSelector)((state, itemId) => (0, _utils.isItemDisabled)(state.itemMetaLookup, itemId)), /** * Gets the index of an item in its parent's children. */ itemIndex: (0, _store.createSelector)((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: (0, _store.createSelector)((state, itemId) => state.itemMetaLookup[itemId]?.parentId ?? null), /** * Gets the depth of an item (items at the root level have a depth of 0). */ itemDepth: (0, _store.createSelector)((state, itemId) => state.itemMetaLookup[itemId]?.depth ?? 0), /** * Checks whether an item can be focused. */ canItemBeFocused: (0, _store.createSelector)((state, itemId) => state.disabledItemsFocusable || !(0, _utils.isItemDisabled)(state.itemMetaLookup, itemId)), /** * Gets the identation between an item and its children. */ itemChildrenIndentation: (0, _store.createSelector)(state => state.itemChildrenIndentation) };