UNPKG

@nova-ui/bits

Version:

SolarWinds Nova Framework

123 lines 6.21 kB
"use strict"; // © 2022 SolarWinds Worldwide, LLC. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. Object.defineProperty(exports, "__esModule", { value: true }); exports.RepeatAtom = void 0; const tslib_1 = require("tslib"); const protractor_1 = require("protractor"); const atom_1 = require("../../atom"); const checkbox_atom_1 = require("../checkbox/checkbox.atom"); class RepeatAtom extends atom_1.Atom { constructor() { super(...arguments); this.itemCount = () => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.getItems().count(); }); this.getItem = (idx) => this.getItems().get(idx); this.isNormal = () => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.hasClass("nui-repeat__normal"); }); this.isCompact = () => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.hasClass("nui-repeat__compact"); }); this.selectCheckbox = (idx) => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.getCheckbox(idx).toggle(); }); this.selectCheckboxes = (...indexes) => tslib_1.__awaiter(this, void 0, void 0, function* () { for (const index of indexes) { yield this.selectCheckbox(index); } }); this.getCheckbox = (idx) => { const checkboxElement = this.getItem(idx).element(protractor_1.by.className("nui-checkbox")); return new checkbox_atom_1.CheckboxAtom(checkboxElement); }; this.selectRow = (idx) => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.getItem(idx).element(protractor_1.by.css(".nui-repeat-item__content")).click(); }); this.selectRows = (...indexes) => tslib_1.__awaiter(this, void 0, void 0, function* () { for (const index of indexes) { yield this.selectRow(index); } }); this.selectRadioRow = (idx) => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.getItem(idx).element(protractor_1.by.css(".nui-repeat-item")).click(); }); this.selectRadio = (idx) => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.getItem(idx).element(protractor_1.by.css(".nui-radio")).click(); }); this.isStriped = () => tslib_1.__awaiter(this, void 0, void 0, function* () { const items = this.getItems(); const lineOneColor = yield items .first() .getCssValue("background-color"); const lineTwoColor = yield items.get(1).getCssValue("background-color"); return lineOneColor !== lineTwoColor; }); this.isItemSelected = (idx) => tslib_1.__awaiter(this, void 0, void 0, function* () { const classValue = yield this.getItem(idx) .element(protractor_1.by.css("li.nui-repeat-item")) .getAttribute("class"); return (classValue === null || classValue === void 0 ? void 0 : classValue.indexOf("nui-repeat-item--selected")) >= 0; }); } getItems() { return super.getElement().all(protractor_1.by.css(".repeat-group-item")); } get vScrollViewport() { return super .getElement() .element(protractor_1.by.className("cdk-virtual-scroll-viewport")); } get vScrollViewportContent() { return super .getElement() .element(protractor_1.by.className("cdk-virtual-scroll-content-wrapper")); } isEmptyTextPresented() { const _super = Object.create(null, { getElement: { get: () => super.getElement } }); return tslib_1.__awaiter(this, void 0, void 0, function* () { return _super.getElement.call(this) .element(protractor_1.by.css(".nui-repeat__empty .nui-repeat__empty--main-message")) .isPresent(); }); } getEmptyText() { const _super = Object.create(null, { getElement: { get: () => super.getElement } }); return tslib_1.__awaiter(this, void 0, void 0, function* () { return _super.getElement.call(this) .element(protractor_1.by.css(".nui-repeat__empty .nui-repeat__empty--main-message")) .getText(); }); } getHeaderText() { const _super = Object.create(null, { getElement: { get: () => super.getElement } }); return tslib_1.__awaiter(this, void 0, void 0, function* () { return _super.getElement.call(this) .element(protractor_1.by.css(".nui-repeat-header")) .getText(); }); } getVScrollViewportHeight() { return tslib_1.__awaiter(this, void 0, void 0, function* () { return this.vScrollViewport.getCssValue("height"); }); } getVScrollViewportContentHeight() { return tslib_1.__awaiter(this, void 0, void 0, function* () { return this.vScrollViewportContent.getCssValue("height"); }); } } exports.RepeatAtom = RepeatAtom; RepeatAtom.CSS_CLASS = "nui-repeat"; //# sourceMappingURL=repeat.atom.js.map