UNPKG

@itwin/frontend-devtools

Version:

Debug menu and supporting UI widgets

56 lines 2.18 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.createTextBox = createTextBox; /** @alpha */ function createTextBox(props) { const div = document.createElement("div"); if (true === props.inline) div.style.display = "inline"; let label; if (undefined !== props.label) { label = document.createElement("label"); label.innerText = props.label; if (undefined !== props.id) label.htmlFor = props.id; div.appendChild(label); } const textbox = document.createElement("input"); textbox.type = "text"; if (undefined !== props.id) textbox.id = props.id; div.appendChild(textbox); if (undefined !== props.parent) props.parent.appendChild(div); const handler = props.handler; if (undefined !== handler) { textbox.onchange = () => handler(textbox); } // Don't want the document's listeners intepreting keypresses as keyboard shortcuts... const stopPropagation = (ev) => ev.stopPropagation(); textbox.onkeydown = textbox.onkeyup = stopPropagation; const keypresshandler = props.keypresshandler; if (undefined !== keypresshandler) { textbox.onkeypress = (ev) => { keypresshandler(textbox, ev); ev.stopPropagation(); }; } else { textbox.onkeypress = stopPropagation; // eslint-disable-line @typescript-eslint/no-deprecated } const focushandler = props.focushandler; if (undefined !== focushandler) { textbox.onfocus = () => focushandler(textbox); } if (undefined !== props.list) { textbox.setAttribute("list", props.list); } if (undefined !== props.tooltip) div.title = props.tooltip; return { label, textbox, div }; } //# sourceMappingURL=TextBox.js.map