UNPKG

@rcsb/rcsb-saguaro-app

Version:
55 lines 3.18 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { SelectButton } from "./SelectButton"; import { SelectButtonTitle } from "./SelectButtonTitle"; import { MountableComponent } from "./MountableComponent"; export class SelectButtonManager { constructor(elementId) { var _a, _b, _c; this.elementId = elementId; const selectDiv = this.createDiv(SelectButtonManager.MAIN_BUTTON_SUFFIX); const additionalDiv = this.createDiv(SelectButtonManager.ADDITIONAL_BUTTON_SUFFIX); const titleDiv = this.createDiv(SelectButtonManager.SELECT_TITLE_DIV); (_a = document.getElementById(this.elementId)) === null || _a === void 0 ? void 0 : _a.append(selectDiv); (_b = document.getElementById(this.elementId)) === null || _b === void 0 ? void 0 : _b.append(additionalDiv); (_c = document.getElementById(this.elementId)) === null || _c === void 0 ? void 0 : _c.append(titleDiv); this.selectComponent = { mainButton: new MountableComponent(selectDiv), additionalButton: new MountableComponent(additionalDiv), selectTitleButton: new MountableComponent(titleDiv) }; } createButton(options, config) { this.button(this.selectComponent.mainButton, options, config); } addButton(options, config) { this.button(this.selectComponent.additionalButton, options, config); } unmountButton() { this.selectComponent.mainButton.unmount(); this.selectComponent.additionalButton.unmount(); this.selectComponent.selectTitleButton.unmount(); } unmountAdditionalButton() { this.selectComponent.additionalButton.unmount(); this.selectComponent.selectTitleButton.unmount(); } button(button, options, config) { var _a; button.render(_jsx(SelectButton, { elementId: this.elementId, options: options, optionProps: config === null || config === void 0 ? void 0 : config.optionProps, addTitle: (_a = config === null || config === void 0 ? void 0 : config.addTitle) !== null && _a !== void 0 ? _a : false, defaultValue: config === null || config === void 0 ? void 0 : config.defaultValue, width: config === null || config === void 0 ? void 0 : config.width, dropdownTitle: config === null || config === void 0 ? void 0 : config.dropdownTitle, isAdditionalButton: config === null || config === void 0 ? void 0 : config.isAdditionalButton, renderTitle: this.renderTitle.bind(this) })); } renderTitle(title) { this.selectComponent.selectTitleButton.render(_jsx(SelectButtonTitle, { title: title })); } createDiv(suffix) { var _a; const div = (_a = document.getElementById(this.elementId + suffix)) !== null && _a !== void 0 ? _a : document.createElement("div"); const id = this.elementId + suffix; div.setAttribute("id", id); div.style.display = "inline-block"; return div; } } SelectButtonManager.MAIN_BUTTON_SUFFIX = "_buttonDiv"; SelectButtonManager.ADDITIONAL_BUTTON_SUFFIX = "_additionalButtonDiv"; SelectButtonManager.SELECT_TITLE_DIV = "_selectButtonTitleDiv"; //# sourceMappingURL=SelectButtonManager.js.map