@nova-ui/bits
Version:
SolarWinds Nova Framework
63 lines • 2.93 kB
JavaScript
// © 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.
import moment from "moment/moment";
import { Atom } from "../../atom";
import { Helpers } from "../../setup";
import { IconAtom } from "../icon/icon.atom";
import { MenuPopupAtom } from "../menu-popup/menu-popup.atom";
import { OverlayAtom } from "../overlay/overlay.atom";
import { TextboxAtom } from "../textbox/textbox.atom";
export class TimepickerAtom extends Atom {
constructor() {
super(...arguments);
this.toggle = async () => this.getLocator().locator(".nui-timepicker__container").click();
this.selectTime = async (time) => {
await this.textbox.clearText();
await this.textbox.acceptText(`${time}\n`);
await Helpers.page.waitForTimeout(1000); // Wait for buttons to update their state
};
this.getHighlightedMenuValue = async () => {
await this.toggle();
return this.menuPopup.selectedItem;
};
}
static { this.CSS_CLASS = "nui-timepicker"; }
static { this.defaultFormat = "LT"; }
static { this.isCorrectTimeFormat = (timeString, format) => moment(timeString, format, true).isValid(); }
static { this.createTimeString = (hour, minute, format = TimepickerAtom.defaultFormat) => {
const date = new Date();
date.setHours(hour);
date.setMinutes(minute);
return moment(date).format(format);
}; }
get textbox() {
return Atom.findIn(TextboxAtom, this.getLocator());
}
get menuPopup() {
return Atom.findIn(MenuPopupAtom, this.getLocator());
}
get icon() {
return Atom.findIn(IconAtom, this.getLocator());
}
get overlay() {
return Atom.findIn(OverlayAtom, Helpers.page.locator(".nui-timepicker__menu"));
}
}
//# sourceMappingURL=timepicker.atom.js.map