UNPKG

@itwin/frontend-devtools

Version:

Debug menu and supporting UI widgets

42 lines 1.63 kB
"use strict"; /*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ Object.defineProperty(exports, "__esModule", { value: true }); exports.createComboBox = createComboBox; function _appendComboBoxEntry(select, entry) { const option = document.createElement("option"); option.innerText = entry.name; if (undefined !== entry.value) option.value = entry.value.toString(); select.appendChild(option); } /** @alpha */ function createComboBox(props) { const div = document.createElement("div"); let label; if (undefined !== props.name) { label = document.createElement("label"); label.htmlFor = props.id; label.innerText = props.name; div.appendChild(label); } const select = document.createElement("select"); select.id = props.id; for (const entry of props.entries) { _appendComboBoxEntry(select, entry); } if (undefined !== props.value) select.value = props.value.toString(); const handler = props.handler; if (undefined !== handler) select.onchange = () => handler(select); if (undefined !== props.tooltip) div.title = props.tooltip; div.appendChild(select); if (undefined !== props.parent) props.parent.appendChild(div); return { div, label, select }; } //# sourceMappingURL=ComboBox.js.map