This commit is contained in:
2026-02-18 03:13:44 +02:00
parent 1bffdd1d6a
commit 3092a96a68
2 changed files with 12 additions and 44 deletions
+1 -1
View File
@@ -552,7 +552,7 @@
/** /**
* Get Widget Data Value * Get Widget Data Value
*/ */
nval() { key() {
return this[ Ut.WidgetUID ]?.getValue(); return this[ Ut.WidgetUID ]?.getValue();
}, },
+11 -43
View File
@@ -7,9 +7,6 @@ import { Cancelable } from '../cancelable'
export class Autocomplete { export class Autocomplete {
/**
* Autocomplete, Constructor
*/
constructor(target, data, opts) { constructor(target, data, opts) {
this.target = target; this.target = target;
@@ -43,15 +40,12 @@ export class Autocomplete {
} }
new Cancelable(this.target); new Cancelable(this.target);
this.renderContainer(); this.renderContainer();
this.setEvents(); this.setEvents();
} }
/**
* Autocomplete, Render Container
*/
renderContainer() { renderContainer() {
this.ui = { this.ui = {
@@ -61,9 +55,6 @@ export class Autocomplete {
this.ui.wrapper.style.maxHeight = (this.opts.maxOptions * this.opts.optionHeight) + 'px'; this.ui.wrapper.style.maxHeight = (this.opts.maxOptions * this.opts.optionHeight) + 'px';
} }
/**
* Autocomplete, Set Events
*/
setEvents() { setEvents() {
// Input Event Handler // Input Event Handler
@@ -79,15 +70,12 @@ export class Autocomplete {
this.ui.wrapper.dxOn('click', '.ac-option', (e, t) => this.clickOptionHandler(e, t)); this.ui.wrapper.dxOn('click', '.ac-option', (e, t) => this.clickOptionHandler(e, t));
// Click outside // Click outside
document.body.dxOn('click.autocomplete', e => e.target != this.target && this.clear()); document.body.dxOn('click.autocomplete', e => e.target != this.target && this.release());
} }
/**
* Autocomplete, processData
*/
processData(val) { processData(val) {
this.clear(); this.release();
let found = true; let found = true;
let matchId = ''; let matchId = '';
@@ -143,9 +131,6 @@ export class Autocomplete {
} }
} }
/**
* Autocomplete, Input Handler
*/
inputHandler(_, t) { inputHandler(_, t) {
//e.stopPropagation(); //e.stopPropagation();
@@ -172,9 +157,6 @@ export class Autocomplete {
} }
} }
/**
* Autocomplete, Keydown Event Handler
*/
keydownHandler(e, t) { keydownHandler(e, t) {
if (!this.count) { if (!this.count) {
@@ -220,21 +202,15 @@ export class Autocomplete {
} }
} }
/**
* Autocomplete, Click Option Handler
*/
clickOptionHandler(e, t) { clickOptionHandler(e, t) {
e.stopPropagation(); e.stopPropagation();
this.restoreValue(t.dataset.id); this.restoreValue(t.dataset.id);
} }
/**
* Autocomplete, Update Val
*/
restoreValue(id) { restoreValue(id) {
if (id == this.value) { if (id == this.value) {
this.clear(); this.release();
return; return;
} }
@@ -245,16 +221,13 @@ export class Autocomplete {
Ut.trigger(this.opts.onChange, this); Ut.trigger(this.opts.onChange, this);
this.target.dxTrigger('changed'); this.target.dxTrigger('changed');
this.clear(); this.release();
} }
getValue() { getValue() {
return this.value; return this.value;
} }
/**
* Autocomplete, Set Active Option
*/
setActiveOption() { setActiveOption() {
this.selected = this.ui.wrapper.children[this.index]; this.selected = this.ui.wrapper.children[this.index];
@@ -278,20 +251,18 @@ export class Autocomplete {
} }
} }
/**
* Autocomplete Update Options
*/
updateOptions(data) { updateOptions(data) {
this.clear(); this.clear();
this.data = data; this.data = data;
} }
/**
* Autocomplete Clear Options
*/
clear() { clear() {
this.value = '';
this.release();
}
release() {
this.selected = null; this.selected = null;
this.count = 0; this.count = 0;
this.index = -1; this.index = -1;
@@ -302,9 +273,6 @@ export class Autocomplete {
this.ui.wrapper.dxHtml(''); this.ui.wrapper.dxHtml('');
} }
/**
* Autocomplete, Destroy
*/
destroy() { destroy() {
this.ui.wrapper.remove(); this.ui.wrapper.remove();