UNPKG

@kitten-science/kitten-scientists

Version:

Add-on for the wonderful incremental browser game: https://kittensgame.com/web/

35 lines 1.44 kB
import { MaxButton } from "./buttons/MaxButton.js"; import { Container } from "./Container.js"; import stylesLabelListItem from "./LabelListItem.module.css"; import { SettingListItem } from "./SettingListItem.js"; export class SettingMaxListItem extends SettingListItem { maxButton; /** * Create a UI element for a setting that can have a maximum. * This will result in an element with a labeled checkbox and a "Max" indicator, * which controls the respective `max` property in the setting model. * * @param host The userscript instance. * @param label The label for the setting. * @param setting The setting model. * @param options Options for the list item. */ constructor(parent, setting, label, options) { super(parent, setting, label, options); this.maxButton = new MaxButton(parent, setting, { border: false, onClick: async () => { await options.onSetMax.call(this); }, onRefresh: options?.onRefreshMax ? () => options.onRefreshMax?.call(this) : undefined, }); this.addChildrenHead([ new Container(parent, { classes: [stylesLabelListItem.fillSpace] }), this.maxButton, ]); } toString() { return `[${SettingMaxListItem.name}#${this.componentId}]: '${this.elementLabel.text()}'`; } } //# sourceMappingURL=SettingMaxListItem.js.map