UNPKG

@awsui/components-react

Version:

On July 19th, 2022, we launched [Cloudscape Design System](https://cloudscape.design). Cloudscape is an evolution of AWS-UI. It consists of user interface guidelines, front-end components, design resources, and development tools for building intuitive, en

95 lines 3.79 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 const dom_1 = require("@awsui/test-utils-core/dom"); const styles_selectors_js_1 = require("../../../internal/components/expand-toggle-button/styles.selectors.js"); const styles_selectors_js_2 = require("../../../internal/components/structured-item/test-classes/styles.selectors.js"); const styles_selectors_js_3 = require("../../../tree-view/test-classes/styles.selectors.js"); class TreeViewItemWrapper extends dom_1.ComponentWrapper { /** * Finds the content slot of the tree view item. */ findContent() { return this.findByClassName(styles_selectors_js_2.default.content); } /** * Finds the icon slot of the tree view item. */ findIcon() { return this.findByClassName(styles_selectors_js_2.default.icon); } /** * Finds the secondary content slot of the tree view item. */ findSecondaryContent() { return this.findByClassName(styles_selectors_js_2.default.secondary); } /** * Finds the actions slot of the tree view item. */ findActions() { return this.findByClassName(styles_selectors_js_2.default.actions); } /** * Finds the expand toggle of the tree view item. */ findItemToggle() { return this.findByClassName(styles_selectors_js_1.default['expand-toggle']); } /** * Finds all visible child items of the tree view item. * @param options * * expanded (optional, boolean) - Use it to find all visible expanded or collapsed child items. */ findChildItems(options = {}) { const selector = getTreeItemSelector(options); return this.findAll(selector).map(item => new TreeViewItemWrapper(item.getElement())); } /** * Finds a visible child item by its ID. * @param id of the item to find * @param options * * expanded (optional, boolean) - Use it to find the visible expanded or collapsed child item. */ findChildItemById(id, options = {}) { const selector = `${getTreeItemSelector(options)}[data-testid="awsui-treeitem-${id}"]`; const item = this.find(selector); return item ? new TreeViewItemWrapper(item.getElement()) : null; } } class TreeViewWrapper extends dom_1.ComponentWrapper { /** * Finds all visible tree view items. * @param options * * expanded (optional, boolean) - Use it to find all visible expanded or collapsed items. */ findItems(options = {}) { const selector = getTreeItemSelector(options); return this.findAll(selector).map(item => new TreeViewItemWrapper(item.getElement())); } /** * Finds a visible tree view item by its ID. * @param id of the item to find * @param options * * expanded (optiona, boolean) - Use it to find the visible expanded or collapsed item. */ findItemById(id, options = {}) { const selector = `${getTreeItemSelector(options)}[data-testid="awsui-treeitem-${id}"]`; const item = this.find(selector); return item ? new TreeViewItemWrapper(item.getElement()) : null; } } TreeViewWrapper.rootSelector = styles_selectors_js_3.default.root; exports.default = TreeViewWrapper; function getTreeItemSelector({ expanded }) { let selector = `.${styles_selectors_js_3.default.treeitem}`; if (expanded === true) { selector += `.${styles_selectors_js_3.default.expanded}`; } else if (expanded === false) { selector += `.${styles_selectors_js_3.default.expandable}:not(.${styles_selectors_js_3.default.expanded})`; } return selector; } //# sourceMappingURL=index.js.map