@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
111 lines • 4.82 kB
JavaScript
;
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 button_1 = require("../button");
const styles_selectors_js_1 = require("../../../tabs/styles.selectors.js");
const styles_selectors_js_2 = require("../../../tabs/test-classes/styles.selectors.js");
class TabWrapper extends dom_1.ComponentWrapper {
findDisabledReason() {
return (0, dom_1.createWrapper)().find(`.${styles_selectors_js_1.default['disabled-reason-tooltip']}`);
}
}
class TabsWrapper extends dom_1.ComponentWrapper {
/**
* Finds all tab headers and returns the clickable elements from their labels.
*/
findTabLinks() {
return this.findAllByClassName(styles_selectors_js_1.default['tabs-tab-link']);
}
/**
* Finds the tab at the given position (1-based) and returns the clickable element from its tab label.
*
* @param index 1-based index of the clickable element to return
*/
findTabLinkByIndex(index) {
return this.findComponent(`.${styles_selectors_js_1.default['tabs-tab']}:nth-child(${index}) .${styles_selectors_js_1.default['tabs-tab-link']}`, TabWrapper);
}
/**
* Finds the tab header container at the given position (1-based) and returns the element.
*
* @param index 1-based index of the clickable element to return
*/
findTabHeaderContentByIndex(index) {
return this.find(`.${styles_selectors_js_1.default['tabs-tab']}:nth-child(${index}) .${styles_selectors_js_1.default['tabs-tab-header-container']}`);
}
/**
* Finds the tab with the given ID and returns the clickable element from its tab label.
*
* @param id ID of the clickable element to return
*/
findTabLinkById(id) {
return this.findComponent(`.${styles_selectors_js_1.default['tabs-tab-link']}[data-testid="${id}"]`, TabWrapper);
}
/**
* Finds the currently focused tab, which might not be active if disabled with a reason.
*/
findFocusedTab() {
return this.find(`.${styles_selectors_js_1.default['tabs-tab-focused']}`);
}
/**
* Finds the dismissible button by using the tab index.
*
* @param index 1-based index of the clickable element to return
*/
findDismissibleButtonByTabIndex(index) {
return this.findComponent(`.${styles_selectors_js_1.default['tabs-tab']}:nth-child(${index}) .${styles_selectors_js_2.default['tab-dismiss-button']}`, button_1.default);
}
/**
* Finds the dismissible button by using the tab id
*
* @param id ID of the clickable element to return
*/
findDismissibleButtonByTabId(id) {
return this.findComponent(`.${styles_selectors_js_2.default['tab-dismiss-button']}[data-testid="awsui-tab-dismiss-button-${id}"]`, button_1.default);
}
/**
* Finds the tab action by using the tab id
* @param id ID of the clickable element to return
*/
findActionByTabId(id) {
return this.find(`.${styles_selectors_js_1.default['tabs-tab-link']}[data-testid="${id}"] ~ .${styles_selectors_js_1.default['tabs-tab-action']}`);
}
/**
* Finds the tab action by using the tab index
* @param index 1-based index of the clickable element to return
*/
findActionByTabIndex(index) {
return this.find(`.${styles_selectors_js_1.default['tabs-tab']}:nth-child(${index}) .${styles_selectors_js_1.default['tabs-tab-action']}`);
}
/**
* Finds the currently active tab and returns the clickable element from its tab label.
*/
findActiveTab() {
return this.find(`.${styles_selectors_js_1.default['tabs-tab-active']} .${styles_selectors_js_1.default['tabs-tab-link']}`);
}
/**
* Finds the currently displayed tab content and returns it.
*/
findTabContent() {
return this.find(`.${styles_selectors_js_1.default['tabs-content-active']}`);
}
/**
* Finds the dismissible button for the active tab
*/
findActiveTabDismissibleButton() {
return this.findComponent(`.${styles_selectors_js_1.default['tabs-tab-active']} .${styles_selectors_js_2.default['tab-dismiss-button']}`, button_1.default);
}
/**
* Finds the tab action for the active tab
*/
findActiveTabAction() {
return this.find(`.${styles_selectors_js_1.default['tabs-tab-active']} .${styles_selectors_js_1.default['tabs-tab-action']}`);
}
findActions() {
return this.find(`.${styles_selectors_js_1.default['actions-container']}`);
}
}
TabsWrapper.rootSelector = styles_selectors_js_1.default.root;
exports.default = TabsWrapper;
//# sourceMappingURL=index.js.map