select_box.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. /**
  2. * DevExtreme (ui/select_box.js)
  3. * Version: 19.1.16
  4. * Build date: Tue Oct 18 2022
  5. *
  6. * Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED
  7. * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
  8. */
  9. "use strict";
  10. var $ = require("../core/renderer");
  11. var commonUtils = require("../core/utils/common");
  12. var typeUtils = require("../core/utils/type");
  13. var isDefined = typeUtils.isDefined;
  14. var isPromise = typeUtils.isPromise;
  15. var extend = require("../core/utils/extend").extend;
  16. var inArray = require("../core/utils/array").inArray;
  17. var each = require("../core/utils/iterator").each;
  18. var deferredUtils = require("../core/utils/deferred");
  19. var getPublicElement = require("../core/utils/dom").getPublicElement;
  20. var Deferred = deferredUtils.Deferred;
  21. var errors = require("../core/errors");
  22. var domAdapter = require("../core/dom_adapter");
  23. var inkRipple = require("./widget/utils.ink_ripple");
  24. var messageLocalization = require("../localization/message");
  25. var registerComponent = require("../core/component_registrator");
  26. var DropDownList = require("./drop_down_editor/ui.drop_down_list");
  27. var DISABLED_STATE_SELECTOR = ".dx-state-disabled";
  28. var SELECTBOX_CLASS = "dx-selectbox";
  29. var SELECTBOX_POPUP_CLASS = "dx-selectbox-popup";
  30. var SELECTBOX_CONTAINER_CLASS = "dx-selectbox-container";
  31. var SELECTBOX_POPUP_WRAPPER_CLASS = "dx-selectbox-popup-wrapper";
  32. var SelectBox = DropDownList.inherit({
  33. _supportedKeys: function() {
  34. var that = this;
  35. var parent = this.callBase();
  36. var clearSelectBox = function(e) {
  37. var isEditable = this._isEditable();
  38. if (!isEditable) {
  39. if (this.option("showClearButton")) {
  40. e.preventDefault();
  41. this.reset()
  42. }
  43. } else {
  44. if (this._valueSubstituted()) {
  45. this._preventFiltering = true
  46. }
  47. }
  48. this._preventSubstitution = true
  49. };
  50. var searchIfNeeded = function() {
  51. if (that.option("searchEnabled") && that._valueSubstituted()) {
  52. that._searchHandler()
  53. }
  54. };
  55. return extend({}, parent, {
  56. tab: function() {
  57. if (this.option("opened") && "instantly" === this.option("applyValueMode")) {
  58. this._cleanInputSelection()
  59. }
  60. if (this._wasSearch()) {
  61. this._clearFilter()
  62. }
  63. parent.tab && parent.tab.apply(this, arguments)
  64. },
  65. upArrow: function() {
  66. if (parent.upArrow && parent.upArrow.apply(this, arguments)) {
  67. if (!this.option("opened")) {
  68. this._setNextValue(-1)
  69. }
  70. return true
  71. }
  72. },
  73. downArrow: function() {
  74. if (parent.downArrow && parent.downArrow.apply(this, arguments)) {
  75. if (!this.option("opened")) {
  76. this._setNextValue(1)
  77. }
  78. return true
  79. }
  80. },
  81. leftArrow: function() {
  82. searchIfNeeded();
  83. parent.leftArrow && parent.leftArrow.apply(this, arguments)
  84. },
  85. rightArrow: function() {
  86. searchIfNeeded();
  87. parent.rightArrow && parent.rightArrow.apply(this, arguments)
  88. },
  89. home: function() {
  90. searchIfNeeded();
  91. parent.home && parent.home.apply(this, arguments)
  92. },
  93. end: function() {
  94. searchIfNeeded();
  95. parent.end && parent.end.apply(this, arguments)
  96. },
  97. escape: function() {
  98. var result = parent.escape && parent.escape.apply(this, arguments);
  99. this._cancelEditing();
  100. return isDefined(result) ? result : true
  101. },
  102. enter: function(e) {
  103. var isOpened = this.option("opened");
  104. var inputText = this._input().val().trim();
  105. var isCustomText = inputText && this._list && !this._list.option("focusedElement");
  106. if (!inputText && this.option("value") && this.option("allowClearing")) {
  107. this.option({
  108. selectedItem: null,
  109. value: null
  110. });
  111. this.close()
  112. } else {
  113. if (this.option("acceptCustomValue")) {
  114. e.preventDefault();
  115. if (isCustomText) {
  116. this._valueChangeEventHandler(e);
  117. if (isOpened) {
  118. this._toggleOpenState()
  119. }
  120. }
  121. return isOpened
  122. }
  123. if (parent.enter && parent.enter.apply(this, arguments)) {
  124. return isOpened
  125. }
  126. }
  127. },
  128. space: function(e) {
  129. var isOpened = this.option("opened");
  130. var isSearchEnabled = this.option("searchEnabled");
  131. var acceptCustomValue = this.option("acceptCustomValue");
  132. if (!isOpened || isSearchEnabled || acceptCustomValue) {
  133. return
  134. }
  135. e.preventDefault();
  136. this._valueChangeEventHandler(e);
  137. return true
  138. },
  139. backspace: clearSelectBox,
  140. del: clearSelectBox
  141. })
  142. },
  143. _getDefaultOptions: function() {
  144. return extend(this.callBase(), {
  145. placeholder: messageLocalization.format("Select"),
  146. fieldTemplate: null,
  147. valueChangeEvent: "change",
  148. acceptCustomValue: false,
  149. onCustomItemCreating: function(e) {
  150. if (!isDefined(e.customItem)) {
  151. e.customItem = e.text
  152. }
  153. },
  154. showSelectionControls: false,
  155. autocompletionEnabled: true,
  156. allowClearing: true,
  157. tooltipEnabled: false,
  158. openOnFieldClick: true,
  159. showDropDownButton: true,
  160. displayCustomValue: false,
  161. _isAdaptablePopupPosition: false,
  162. useInkRipple: false,
  163. useHiddenSubmitElement: true
  164. })
  165. },
  166. _init: function() {
  167. this.callBase();
  168. this._initCustomItemCreatingAction()
  169. },
  170. _initMarkup: function() {
  171. this.$element().addClass(SELECTBOX_CLASS);
  172. this._renderTooltip();
  173. this.option("useInkRipple") && this._renderInkRipple();
  174. this.callBase();
  175. this._$container.addClass(SELECTBOX_CONTAINER_CLASS)
  176. },
  177. _renderInkRipple: function() {
  178. this._inkRipple = inkRipple.render()
  179. },
  180. _toggleActiveState: function($element, value, e) {
  181. this.callBase.apply(this, arguments);
  182. if (!this._inkRipple || this._isEditable()) {
  183. return
  184. }
  185. var config = {
  186. element: this._inputWrapper(),
  187. event: e
  188. };
  189. if (value) {
  190. this._inkRipple.showWave(config)
  191. } else {
  192. this._inkRipple.hideWave(config)
  193. }
  194. },
  195. _createPopup: function() {
  196. this.callBase();
  197. this._popup.$element().addClass(SELECTBOX_POPUP_CLASS)
  198. },
  199. _popupWrapperClass: function() {
  200. return this.callBase() + " " + SELECTBOX_POPUP_WRAPPER_CLASS
  201. },
  202. _cancelEditing: function() {
  203. if (!this.option("searchEnabled") && this._list) {
  204. this._focusListElement(null);
  205. this._updateField(this.option("selectedItem"))
  206. }
  207. },
  208. _renderOpenedState: function() {
  209. this.callBase();
  210. if (this.option("opened")) {
  211. this._scrollToSelectedItem();
  212. this._focusSelectedElement()
  213. }
  214. },
  215. _focusSelectedElement: function() {
  216. var searchValue = this._searchValue();
  217. if (!searchValue) {
  218. this._focusListElement(null);
  219. return
  220. }
  221. var $listItems = this._list._itemElements();
  222. var index = inArray(this.option("selectedItem"), this.option("items"));
  223. var focusedElement = index >= 0 && !this._isCustomItemSelected() ? $listItems.eq(index) : null;
  224. this._focusListElement(focusedElement)
  225. },
  226. _renderFocusedElement: function() {
  227. if (!this._list) {
  228. return
  229. }
  230. var searchValue = this._searchValue();
  231. if (!searchValue || this.option("acceptCustomValue")) {
  232. this._focusListElement(null);
  233. return
  234. }
  235. var $listItems = this._list._itemElements();
  236. var focusedElement = $listItems.not(DISABLED_STATE_SELECTOR).eq(0);
  237. this._focusListElement(focusedElement)
  238. },
  239. _focusListElement: function(element) {
  240. this._preventInputValueRender = true;
  241. this._list.option("focusedElement", getPublicElement(element));
  242. delete this._preventInputValueRender
  243. },
  244. _scrollToSelectedItem: function() {
  245. this._list && this._list.scrollToItem(this._list.option("selectedItem"))
  246. },
  247. _listContentReadyHandler: function() {
  248. this.callBase();
  249. var isPaginate = this._dataSource && this._dataSource.paginate();
  250. if (isPaginate && this._needPopupRepaint()) {
  251. return
  252. }
  253. this._scrollToSelectedItem()
  254. },
  255. _renderValue: function() {
  256. this._renderInputValue();
  257. this._setSubmitValue();
  258. return (new Deferred).resolve()
  259. },
  260. _renderInputValue: function() {
  261. return this.callBase().always(function() {
  262. this._renderInputValueAsync()
  263. }.bind(this))
  264. },
  265. _renderInputValueAsync: function() {
  266. this._renderTooltip();
  267. this._renderInputValueImpl().always(function() {
  268. this._refreshSelected()
  269. }.bind(this))
  270. },
  271. _renderInputValueImpl: function() {
  272. this._renderField();
  273. return (new Deferred).resolve()
  274. },
  275. _setNextItem: function(step) {
  276. var item = this._calcNextItem(step);
  277. var value = this._valueGetter(item);
  278. this._setValue(value)
  279. },
  280. _setNextValue: function(step) {
  281. var dataSourceIsLoaded = this._dataSource.isLoaded() ? (new Deferred).resolve() : this._dataSource.load();
  282. dataSourceIsLoaded.done(function() {
  283. var selectedIndex = this._getSelectedIndex();
  284. var hasPages = this._dataSource.pageSize();
  285. var isLastPage = this._dataSource.isLastPage();
  286. var isLastItem = selectedIndex === this._items().length - 1;
  287. if (hasPages && !isLastPage && isLastItem && step > 0) {
  288. if (!this._popup) {
  289. this._createPopup()
  290. }
  291. if (!this._dataSource.isLoading()) {
  292. this._list._loadNextPage().done(this._setNextItem.bind(this, step))
  293. }
  294. } else {
  295. this._setNextItem(step)
  296. }
  297. }.bind(this))
  298. },
  299. _setSelectedItem: function(item) {
  300. var isUnknownItem = !this._isCustomValueAllowed() && void 0 === item;
  301. this.callBase(isUnknownItem ? null : item);
  302. if (!isUnknownItem && (!this._isEditable() || this._isCustomItemSelected())) {
  303. this._setListOption("selectedItem", this.option("selectedItem"))
  304. }
  305. },
  306. _isCustomValueAllowed: function() {
  307. return this.option("acceptCustomValue") || this.callBase()
  308. },
  309. _displayValue: function(item) {
  310. item = !isDefined(item) && this._isCustomValueAllowed() ? this.option("value") : item;
  311. return this.callBase(item)
  312. },
  313. _listConfig: function() {
  314. var result = extend(this.callBase(), {
  315. pageLoadMode: "scrollBottom",
  316. onSelectionChanged: this._getSelectionChangeHandler(),
  317. selectedItem: this.option("selectedItem"),
  318. onFocusedItemChanged: this._listFocusedItemChangeHandler.bind(this)
  319. });
  320. if (this.option("showSelectionControls")) {
  321. extend(result, {
  322. showSelectionControls: true,
  323. selectionByClick: true
  324. })
  325. }
  326. return result
  327. },
  328. _listFocusedItemChangeHandler: function(e) {
  329. if (this._preventInputValueRender) {
  330. return
  331. }
  332. var list = e.component;
  333. var focusedElement = $(list.option("focusedElement"));
  334. var focusedItem = list._getItemData(focusedElement);
  335. this._updateField(focusedItem)
  336. },
  337. _updateField: function(item) {
  338. var fieldTemplate = this._getTemplateByOption("fieldTemplate");
  339. if (!(fieldTemplate && this.option("fieldTemplate"))) {
  340. this._renderDisplayText(this._displayGetter(item));
  341. return
  342. }
  343. this._renderField()
  344. },
  345. _getSelectionChangeHandler: function() {
  346. return this.option("showSelectionControls") ? this._selectionChangeHandler.bind(this) : commonUtils.noop
  347. },
  348. _selectionChangeHandler: function(e) {
  349. each(e.addedItems || [], function(_, addedItem) {
  350. this._setValue(this._valueGetter(addedItem))
  351. }.bind(this))
  352. },
  353. _getActualSearchValue: function() {
  354. return this._dataSource.searchValue()
  355. },
  356. _toggleOpenState: function(isVisible) {
  357. if (this.option("disabled")) {
  358. return
  359. }
  360. isVisible = arguments.length ? isVisible : !this.option("opened");
  361. if (!isVisible) {
  362. this._restoreInputText(true)
  363. }
  364. if (this._wasSearch() && isVisible) {
  365. this._wasSearch(false);
  366. var showDataImmediately = this.option("showDataBeforeSearch") || 0 === this.option("minSearchLength");
  367. if (showDataImmediately && this._dataSource) {
  368. if (this._searchTimer) {
  369. return
  370. }
  371. var searchValue = this._getActualSearchValue();
  372. searchValue && this._wasSearch(true);
  373. this._filterDataSource(searchValue || null)
  374. } else {
  375. this._setListOption("items", [])
  376. }
  377. }
  378. if (isVisible) {
  379. this._scrollToSelectedItem()
  380. }
  381. this.callBase(isVisible)
  382. },
  383. _renderTooltip: function() {
  384. if (this.option("tooltipEnabled")) {
  385. this.$element().attr("title", this.option("displayValue"))
  386. }
  387. },
  388. _renderDimensions: function() {
  389. this.callBase();
  390. this._setPopupOption("width")
  391. },
  392. _isValueEqualInputText: function() {
  393. var initialSelectedItem = this.option("selectedItem");
  394. var value = this._displayGetter(initialSelectedItem);
  395. var displayValue = value ? String(value) : "";
  396. var inputText = this._searchValue();
  397. return displayValue === inputText
  398. },
  399. _popupHidingHandler: function() {
  400. if (this._isValueEqualInputText()) {
  401. this._cancelEditing()
  402. }
  403. this.callBase()
  404. },
  405. _restoreInputText: function(saveEditingValue) {
  406. if (this.option("readOnly")) {
  407. return
  408. }
  409. this._loadItemDeferred && this._loadItemDeferred.always(function() {
  410. var initialSelectedItem = this.option("selectedItem");
  411. if (this.option("acceptCustomValue")) {
  412. if (!saveEditingValue) {
  413. this._updateField(initialSelectedItem);
  414. this._clearFilter()
  415. }
  416. return
  417. }
  418. if (this.option("searchEnabled")) {
  419. if (!this._searchValue() && this.option("allowClearing")) {
  420. this._clearTextValue();
  421. return
  422. }
  423. }
  424. if (this._isValueEqualInputText()) {
  425. return
  426. }
  427. this._renderInputValue().always(function(selectedItem) {
  428. var newSelectedItem = commonUtils.ensureDefined(selectedItem, initialSelectedItem);
  429. this._setSelectedItem(newSelectedItem);
  430. this._updateField(newSelectedItem);
  431. this._clearFilter()
  432. }.bind(this))
  433. }.bind(this))
  434. },
  435. _focusOutHandler: function(e) {
  436. if (!this._preventNestedFocusEvent(e)) {
  437. this._clearSearchTimer();
  438. this._restoreInputText();
  439. var shouldCancelSearch = this._wasSearch() && !this.option("acceptCustomValue") && this.option("searchEnabled") && this.option("opened") && !this._isOverlayNestedTarget(e.relatedTarget);
  440. if (shouldCancelSearch) {
  441. this._searchCanceled()
  442. }
  443. }
  444. this.callBase(e)
  445. },
  446. _isOverlayNestedTarget: function(target) {
  447. return !!$(target).closest(".".concat(SELECTBOX_POPUP_WRAPPER_CLASS)).length
  448. },
  449. _clearTextValue: function() {
  450. this.option("value", null)
  451. },
  452. _shouldOpenPopup: function() {
  453. return this._needPassDataSourceToList()
  454. },
  455. _isFocused: function() {
  456. var activeElement = domAdapter.getActiveElement();
  457. return this.callBase() && $(activeElement).closest(this._input()).length > 0
  458. },
  459. _renderValueChangeEvent: function() {
  460. if (this._isEditable()) {
  461. this.callBase()
  462. }
  463. },
  464. _isEditable: function() {
  465. return this.option("acceptCustomValue") || this.option("searchEnabled")
  466. },
  467. _fieldRenderData: function() {
  468. var $listFocused = this._list && this.option("opened") && $(this._list.option("focusedElement"));
  469. if ($listFocused && $listFocused.length) {
  470. return this._list._getItemData($listFocused)
  471. }
  472. return this.option("selectedItem")
  473. },
  474. _readOnlyPropValue: function() {
  475. return !this._isEditable() || this.option("readOnly")
  476. },
  477. _isSelectedValue: function(value) {
  478. return this._isValueEquals(value, this.option("value"))
  479. },
  480. _shouldCloseOnItemClick: function() {
  481. return !(this.option("showSelectionControls") && "single" !== this.option("selectionMode"))
  482. },
  483. _listItemClickHandler: function(e) {
  484. var previousValue = this._getCurrentValue();
  485. this._focusListElement($(e.itemElement));
  486. this._saveValueChangeEvent(e.event);
  487. if (this._shouldClearFilter()) {
  488. this._clearFilter()
  489. }
  490. this._completeSelection(this._valueGetter(e.itemData));
  491. if (this._shouldCloseOnItemClick()) {
  492. this.option("opened", false)
  493. }
  494. if (this.option("searchEnabled") && previousValue === this._valueGetter(e.itemData)) {
  495. this._updateField(e.itemData)
  496. }
  497. },
  498. _shouldClearFilter: function() {
  499. return this._wasSearch()
  500. },
  501. _completeSelection: function(value) {
  502. this._setValue(value)
  503. },
  504. _loadItem: function(value, cache) {
  505. var that = this;
  506. var deferred = new Deferred;
  507. this.callBase(value, cache).done(function(item) {
  508. deferred.resolve(item)
  509. }.bind(this)).fail(function() {
  510. var selectedItem = that.option("selectedItem");
  511. if (that.option("acceptCustomValue") && value === that._valueGetter(selectedItem)) {
  512. deferred.resolve(selectedItem)
  513. } else {
  514. deferred.reject()
  515. }
  516. }.bind(this));
  517. return deferred.promise()
  518. },
  519. _loadInputValue: function(value, callback) {
  520. this._loadItemDeferred = this._loadItem(value).always(callback);
  521. return this._loadItemDeferred
  522. },
  523. _isCustomItemSelected: function() {
  524. var selectedItem = this.option("selectedItem");
  525. var searchValue = this._searchValue();
  526. var selectedItemText = this._displayGetter(selectedItem);
  527. return !selectedItemText || searchValue !== selectedItemText.toString()
  528. },
  529. _valueChangeEventHandler: function(e) {
  530. if (this.option("acceptCustomValue") && this._isCustomItemSelected()) {
  531. this._customItemAddedHandler(e)
  532. }
  533. },
  534. _initCustomItemCreatingAction: function() {
  535. this._customItemCreatingAction = this._createActionByOption("onCustomItemCreating")
  536. },
  537. _createCustomItem: function(text) {
  538. var params = {
  539. text: text
  540. };
  541. var actionResult = this._customItemCreatingAction(params);
  542. var item = commonUtils.ensureDefined(actionResult, params.customItem);
  543. if (isDefined(actionResult)) {
  544. errors.log("W0015", "onCustomItemCreating", "customItem")
  545. }
  546. return item
  547. },
  548. _customItemAddedHandler: function(e) {
  549. var searchValue = this._searchValue();
  550. var item = this._createCustomItem(searchValue);
  551. this._saveValueChangeEvent(e);
  552. if (void 0 === item) {
  553. this._renderValue();
  554. throw errors.Error("E0121")
  555. }
  556. if (isPromise(item)) {
  557. deferredUtils.fromPromise(item).done(this._setCustomItem.bind(this)).fail(this._setCustomItem.bind(this, null))
  558. } else {
  559. this._setCustomItem(item)
  560. }
  561. },
  562. _setCustomItem: function(item) {
  563. if (this._disposed) {
  564. return
  565. }
  566. item = item || null;
  567. this.option("selectedItem", item);
  568. if (this._shouldClearFilter()) {
  569. this._filterDataSource(null)
  570. }
  571. this._setValue(this._valueGetter(item));
  572. this._renderDisplayText(this._displayGetter(item))
  573. },
  574. _clearValueHandler: function(e) {
  575. this.callBase(e);
  576. return false
  577. },
  578. _wasSearch: function(value) {
  579. if (!arguments.length) {
  580. return this._wasSearchValue
  581. }
  582. this._wasSearchValue = value
  583. },
  584. _searchHandler: function(e) {
  585. if (this._preventFiltering) {
  586. delete this._preventFiltering;
  587. return
  588. }
  589. if (this._needPassDataSourceToList()) {
  590. this._wasSearch(true)
  591. }
  592. this.callBase(e)
  593. },
  594. _dataSourceFiltered: function(searchValue) {
  595. this.callBase();
  596. if (null !== searchValue) {
  597. this._renderInputSubstitution();
  598. this._renderFocusedElement()
  599. }
  600. },
  601. _valueSubstituted: function() {
  602. var input = this._input().get(0);
  603. var isAllSelected = 0 === input.selectionStart && input.selectionEnd === this._searchValue().length;
  604. var inputHasSelection = input.selectionStart !== input.selectionEnd;
  605. return this._wasSearch() && inputHasSelection && !isAllSelected
  606. },
  607. _shouldSubstitutionBeRendered: function() {
  608. return this.option("autocompletionEnabled") && !this._preventSubstitution && this.option("searchEnabled") && !this.option("acceptCustomValue") && "startswith" === this.option("searchMode")
  609. },
  610. _renderInputSubstitution: function() {
  611. if (!this._shouldSubstitutionBeRendered()) {
  612. delete this._preventSubstitution;
  613. return
  614. }
  615. var item = this._list && this._getPlainItems(this._list.option("items"))[0];
  616. if (!item) {
  617. return
  618. }
  619. var $input = this._input();
  620. var valueLength = $input.val().length;
  621. if (0 === valueLength) {
  622. return
  623. }
  624. var inputElement = $input.get(0);
  625. var displayValue = this._displayGetter(item).toString();
  626. inputElement.value = displayValue;
  627. this._caret({
  628. start: valueLength,
  629. end: displayValue.length
  630. })
  631. },
  632. _cleanInputSelection: function() {
  633. var inputElement = this._input().get(0);
  634. var endPosition = inputElement.value.length;
  635. inputElement.selectionStart = endPosition;
  636. inputElement.selectionEnd = endPosition
  637. },
  638. _dispose: function() {
  639. this._renderInputValueAsync = commonUtils.noop;
  640. delete this._loadItemDeferred;
  641. this.callBase()
  642. },
  643. _optionChanged: function(args) {
  644. switch (args.name) {
  645. case "_isAdaptablePopupPosition":
  646. case "autocompletionEnabled":
  647. break;
  648. case "onCustomItemCreating":
  649. this._initCustomItemCreatingAction();
  650. break;
  651. case "tooltipEnabled":
  652. this._renderTooltip();
  653. break;
  654. case "displayCustomValue":
  655. case "acceptCustomValue":
  656. case "showSelectionControls":
  657. case "useInkRipple":
  658. this._invalidate();
  659. break;
  660. case "allowClearing":
  661. break;
  662. default:
  663. this.callBase(args)
  664. }
  665. },
  666. _clean: function() {
  667. delete this._inkRipple;
  668. this.callBase()
  669. }
  670. });
  671. registerComponent("dxSelectBox", SelectBox);
  672. module.exports = SelectBox;
  673. module.exports.default = module.exports;