UNPKG

@mui/x-tree-view

Version:

The community edition of the MUI X Tree View components.

33 lines (29 loc) 1.94 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.selectorIsLazyLoadingEnabled = exports.selectorIsItemLoading = exports.selectorGetTreeItemError = exports.selectorDataSourceState = void 0; var _selectors = require("../../utils/selectors"); const selectorLazyLoading = state => state.lazyLoading; const selectorLazyLoadingOptional = state => state.lazyLoading; const selectorDataSourceState = exports.selectorDataSourceState = (0, _selectors.createSelector)([selectorLazyLoading], lazyLoading => lazyLoading.dataSource); /** * Check if lazy loading is enabled. * @param {TreeViewState<[UseTreeViewLazyLoadingSignature]>} state The state of the tree view. * @returns {boolean} True if lazy loading is enabled, false if it isn't. */ const selectorIsLazyLoadingEnabled = exports.selectorIsLazyLoadingEnabled = (0, _selectors.createSelector)([selectorLazyLoadingOptional], lazyLoading => !!lazyLoading?.enabled); /** * Get the loading state for a tree item. * @param {TreeViewState<[UseTreeViewLazyLoadingSignature]>} state The state of the tree view. * @param {TreeViewItemId} itemId The id of the item to get the loading state of. * @returns {boolean} The loading state for the Tree Item. */ const selectorIsItemLoading = exports.selectorIsItemLoading = (0, _selectors.createSelector)([selectorDataSourceState, (_, itemId) => itemId], (dataSourceState, itemId) => dataSourceState.loading[itemId] || false); /** * Get the error for a tree item. * @param {TreeViewState<[UseTreeViewLazyLoadingSignature]>} state The state of the tree view. * @param {TreeViewItemId} itemId The id of the item to get the error for. * @returns {boolean} The error for the Tree Item. */ const selectorGetTreeItemError = exports.selectorGetTreeItemError = (0, _selectors.createSelector)([selectorDataSourceState, (_, itemId) => itemId], (dataSourceState, itemId) => dataSourceState.errors[itemId] || null);