UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

78 lines (77 loc) 2.98 kB
/** * DevExtreme (esm/__internal/ui/file_manager/ui.file_manager.dialog.name_editor.js) * Version: 25.2.7 * Build date: Tue May 05 2026 * * Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import $ from "../../../core/renderer"; import { extend } from "../../../core/utils/extend"; import TextBox from "../../../ui/text_box"; import FileManagerDialogBase from "../../ui/file_manager/ui.file_manager.dialog"; const FILE_MANAGER_DIALOG_NAME_EDITOR = "dx-filemanager-dialog-name-editor"; const FILE_MANAGER_DIALOG_NAME_EDITOR_POPUP = "dx-filemanager-dialog-name-editor-popup"; class FileManagerNameEditorDialog extends FileManagerDialogBase { show(name) { name = name || ""; if (this._nameTextBox) { this._nameTextBox.option("value", name) } else { this._initialNameValue = name } super.show() } _onPopupShown() { if (!this._nameTextBox) { return } const $textBoxInput = this._nameTextBox._input(); if ($textBoxInput.length) { $textBoxInput[0].select() } this._nameTextBox.focus() } _getDialogOptions() { return extend(super._getDialogOptions(), { title: this.option("title"), buttonText: this.option("buttonText"), contentCssClass: FILE_MANAGER_DIALOG_NAME_EDITOR, popupCssClass: FILE_MANAGER_DIALOG_NAME_EDITOR_POPUP }) } _createContentTemplate(element) { var _this$_$contentElemen, _this$_nameTextBox; super._createContentTemplate(element); this._nameTextBox = this._createComponent($("<div>"), TextBox, { value: this._initialNameValue, onEnterKey: () => this._hasCompositionJustEnded && this._applyDialogChanges(), onKeyDown: e => this._checkCompositionEnded(e) }); null === (_this$_$contentElemen = this._$contentElement) || void 0 === _this$_$contentElemen || _this$_$contentElemen.append($(null === (_this$_nameTextBox = this._nameTextBox) || void 0 === _this$_nameTextBox ? void 0 : _this$_nameTextBox.$element())) } _checkCompositionEnded(_ref) { let { event: event } = _ref; this._hasCompositionJustEnded = 229 !== event.which } _getDialogResult() { var _this$_nameTextBox2; const { value: value } = (null === (_this$_nameTextBox2 = this._nameTextBox) || void 0 === _this$_nameTextBox2 ? void 0 : _this$_nameTextBox2.option()) ?? {}; return value ? { name: value } : null } _getDefaultOptions() { return extend(super._getDefaultOptions(), { title: "", buttonText: "" }) } } export default FileManagerNameEditorDialog;