@nova-ui/bits
Version:
SolarWinds Nova Framework
93 lines • 5.29 kB
JavaScript
"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.ChipsAtom = void 0;
const tslib_1 = require("tslib");
const protractor_1 = require("protractor");
const atom_1 = require("../../atom");
class ChipsAtom extends atom_1.Atom {
constructor() {
super(...arguments);
this.root = this.getElement();
this.groups = this.root.all(protractor_1.by.className(ChipsAtom.groupNameClass));
this.getChipElements = () => this.root.all(protractor_1.by.className(ChipsAtom.itemClass));
this.getChipsCount = () => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.getChipElements().count(); });
this.getChipElement = (index) => this.getChipElements().get(index);
this.getChipName = (element) => tslib_1.__awaiter(this, void 0, void 0, function* () { return element.all(protractor_1.by.className(ChipsAtom.itemNameClass)).first().getText(); });
this.getChipsNames = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
return this.getChipElements().map((el) => tslib_1.__awaiter(this, void 0, void 0, function* () {
if (!el) {
throw new Error("elementFinder is not defined");
}
return yield this.getChipName(el);
}));
});
this.getChipsGroupNames = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
return this.groups.map((el) => tslib_1.__awaiter(this, void 0, void 0, function* () {
if (!el) {
throw new Error("elementFinder is not defined");
}
return yield this.getGroupName(el);
}));
});
this.getGroupsCount = () => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.groups.count(); });
this.getGroupName = (element) => tslib_1.__awaiter(this, void 0, void 0, function* () { return element.getText(); });
this.removeItem = (index) => tslib_1.__awaiter(this, void 0, void 0, function* () {
return this.root
.all(protractor_1.by.className(ChipsAtom.itemRemoveIconClass))
.get(index)
.click();
});
this.getClearAllLinkElement = () => this.root.element(protractor_1.by.className(ChipsAtom.clearAllLinkClass));
this.clearAll = () => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.getClearAllLinkElement().click(); });
this.isVisible = () => tslib_1.__awaiter(this, void 0, void 0, function* () { return (yield this.isPresent()) && (yield this.isDisplayed()); });
this.click = () => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.getElement().click(); });
this.getChipsOverflowElement = () => this.root.element(protractor_1.by.className(ChipsAtom.chipsoverflowedClass));
this.getChipsOverflowCounter = () => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.getChipsOverflowElement().getText(); });
}
isVertical() {
const _super = Object.create(null, {
hasClass: { get: () => super.hasClass }
});
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return _super.hasClass.call(this, ChipsAtom.verticalClass);
});
}
getChipsQuantityFromLabel() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const t = yield this.root
.element(protractor_1.by.className(ChipsAtom.qtyLabelClass))
.getText();
return +t.slice(1, -1);
});
}
}
exports.ChipsAtom = ChipsAtom;
ChipsAtom.CSS_CLASS = "nui-chips";
ChipsAtom.verticalClass = "nui-chips__vertical";
ChipsAtom.qtyLabelClass = "nui-chips__count";
ChipsAtom.itemClass = "nui-chip__value";
ChipsAtom.itemNameClass = "nui-chip__value-name";
ChipsAtom.itemRemoveIconClass = "nui-chip__value-remove";
ChipsAtom.groupNameClass = "nui-chips__group-name";
ChipsAtom.clearAllLinkClass = "nui-chips__clear";
ChipsAtom.chipsoverflowedClass = "nui-chips-overflowed__counter";
//# sourceMappingURL=chips.atom.js.map