@syncfusion/ej2-dropdowns 18.2.44-4568 → 18.2.44-4570
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +244 -0
- package/CHANGELOG.md +1524 -1524
- package/README.md +118 -118
- package/dist/ej2-dropdowns.umd.min.js +1 -1
- package/dist/ej2-dropdowns.umd.min.js.map +1 -1
- package/dist/es6/ej2-dropdowns.es2015.js +99 -60
- package/dist/es6/ej2-dropdowns.es2015.js.map +1 -1
- package/dist/es6/ej2-dropdowns.es5.js +191 -151
- package/dist/es6/ej2-dropdowns.es5.js.map +1 -1
- package/dist/global/ej2-dropdowns.min.js +1 -1
- package/dist/global/ej2-dropdowns.min.js.map +1 -1
- package/dist/ts/auto-complete/auto-complete.ts +527 -0
- package/dist/ts/combo-box/combo-box.ts +957 -0
- package/dist/ts/common/highlight-search.ts +47 -0
- package/dist/ts/common/incremental-search.ts +81 -0
- package/dist/ts/drop-down-base/drop-down-base.ts +1572 -0
- package/dist/ts/drop-down-list/drop-down-list.ts +2993 -0
- package/dist/ts/drop-down-tree/drop-down-tree.ts +3066 -0
- package/dist/ts/list-box/list-box.ts +2317 -0
- package/dist/ts/multi-select/checkbox-selection.ts +528 -0
- package/dist/ts/multi-select/float-label.ts +155 -0
- package/dist/ts/multi-select/interface.ts +66 -0
- package/dist/ts/multi-select/multi-select.ts +4216 -0
- package/helpers/e2e/index.js +3 -3
- package/license +2 -2
- package/package.json +63 -77
- package/src/auto-complete/auto-complete-model.d.ts +179 -179
- package/src/auto-complete/auto-complete.js +19 -19
- package/src/combo-box/combo-box-model.d.ts +212 -212
- package/src/combo-box/combo-box.js +19 -19
- package/src/drop-down-base/drop-down-base-model.d.ts +191 -191
- package/src/drop-down-base/drop-down-base.js +19 -19
- package/src/drop-down-list/drop-down-list-model.d.ts +222 -222
- package/src/drop-down-list/drop-down-list.js +19 -19
- package/src/drop-down-tree/drop-down-tree-model.d.ts +344 -344
- package/src/drop-down-tree/drop-down-tree.js +19 -19
- package/src/list-box/list-box-model.d.ts +156 -156
- package/src/list-box/list-box.js +19 -19
- package/src/multi-select/checkbox-selection.js +3 -1
- package/src/multi-select/multi-select-model.d.ts +452 -452
- package/src/multi-select/multi-select.d.ts +2 -0
- package/src/multi-select/multi-select.js +58 -19
- package/styles/_all.scss +3 -3
- package/styles/auto-complete/_bootstrap-dark-definition.scss +3 -3
- package/styles/auto-complete/_bootstrap4-definition.scss +11 -11
- package/styles/auto-complete/_fabric-dark-definition.scss +2 -2
- package/styles/auto-complete/_highcontrast-light-definition.scss +2 -2
- package/styles/auto-complete/_material-dark-definition.scss +2 -2
- package/styles/bootstrap-dark.css +13 -16
- package/styles/bootstrap.css +12 -15
- package/styles/bootstrap4.css +6 -10
- package/styles/combo-box/_bootstrap-dark-definition.scss +2 -2
- package/styles/combo-box/_bootstrap4-definition.scss +11 -11
- package/styles/combo-box/_fabric-dark-definition.scss +2 -2
- package/styles/combo-box/_highcontrast-light-definition.scss +3 -3
- package/styles/combo-box/_material-dark-definition.scss +2 -2
- package/styles/drop-down-base/_all.scss +2 -2
- package/styles/drop-down-base/_bootstrap-dark-definition.scss +64 -64
- package/styles/drop-down-base/_bootstrap-definition.scss +64 -64
- package/styles/drop-down-base/_bootstrap4-definition.scss +78 -78
- package/styles/drop-down-base/_definition.scss +23 -23
- package/styles/drop-down-base/_fabric-dark-definition.scss +68 -68
- package/styles/drop-down-base/_fabric-definition.scss +66 -66
- package/styles/drop-down-base/_highcontrast-definition.scss +82 -82
- package/styles/drop-down-base/_highcontrast-light-definition.scss +81 -81
- package/styles/drop-down-base/_layout.scss +108 -108
- package/styles/drop-down-base/_material-dark-definition.scss +67 -67
- package/styles/drop-down-base/_material-definition.scss +65 -65
- package/styles/drop-down-base/_theme.scss +242 -242
- package/styles/drop-down-list/_all.scss +2 -2
- package/styles/drop-down-list/_bootstrap-dark-definition.scss +157 -157
- package/styles/drop-down-list/_bootstrap-definition.scss +156 -156
- package/styles/drop-down-list/_bootstrap4-definition.scss +184 -184
- package/styles/drop-down-list/_fabric-dark-definition.scss +127 -127
- package/styles/drop-down-list/_fabric-definition.scss +122 -122
- package/styles/drop-down-list/_highcontrast-definition.scss +131 -131
- package/styles/drop-down-list/_highcontrast-light-definition.scss +133 -133
- package/styles/drop-down-list/_layout.scss +218 -218
- package/styles/drop-down-list/_material-dark-definition.scss +143 -143
- package/styles/drop-down-list/_material-definition.scss +166 -166
- package/styles/drop-down-list/_theme.scss +10 -10
- package/styles/drop-down-list/icons/_bootstrap-dark.scss +14 -14
- package/styles/drop-down-list/icons/_bootstrap.scss +14 -14
- package/styles/drop-down-list/icons/_bootstrap4.scss +14 -14
- package/styles/drop-down-list/icons/_fabric-dark.scss +14 -14
- package/styles/drop-down-list/icons/_fabric.scss +14 -14
- package/styles/drop-down-list/icons/_highcontrast-light.scss +14 -14
- package/styles/drop-down-list/icons/_highcontrast.scss +14 -14
- package/styles/drop-down-list/icons/_material-dark.scss +14 -14
- package/styles/drop-down-list/icons/_material.scss +14 -14
- package/styles/drop-down-list/material.css +9 -0
- package/styles/drop-down-tree/_all.scss +2 -2
- package/styles/drop-down-tree/_bootstrap-dark-definition.scss +61 -61
- package/styles/drop-down-tree/_bootstrap-definition.scss +61 -61
- package/styles/drop-down-tree/_bootstrap4-definition.scss +62 -62
- package/styles/drop-down-tree/_fabric-dark-definition.scss +62 -62
- package/styles/drop-down-tree/_fabric-definition.scss +62 -62
- package/styles/drop-down-tree/_highcontrast-definition.scss +62 -62
- package/styles/drop-down-tree/_highcontrast-light-definition.scss +62 -62
- package/styles/drop-down-tree/_layout.scss +437 -437
- package/styles/drop-down-tree/_material-dark-definition.scss +60 -60
- package/styles/drop-down-tree/_material-definition.scss +60 -60
- package/styles/drop-down-tree/_theme.scss +68 -68
- package/styles/drop-down-tree/icons/_bootstrap-dark.scss +11 -11
- package/styles/drop-down-tree/icons/_bootstrap.scss +11 -11
- package/styles/drop-down-tree/icons/_bootstrap4.scss +11 -11
- package/styles/drop-down-tree/icons/_fabric-dark.scss +11 -11
- package/styles/drop-down-tree/icons/_fabric.scss +11 -11
- package/styles/drop-down-tree/icons/_highcontrast-light.scss +11 -11
- package/styles/drop-down-tree/icons/_highcontrast.scss +11 -11
- package/styles/drop-down-tree/icons/_material-dark.scss +11 -11
- package/styles/drop-down-tree/icons/_material.scss +11 -11
- package/styles/drop-down-tree/material.css +9 -0
- package/styles/fabric-dark.css +2 -5
- package/styles/fabric.css +1 -4
- package/styles/highcontrast-light.css +2 -5
- package/styles/highcontrast.css +2 -7
- package/styles/list-box/_all.scss +2 -2
- package/styles/list-box/_bootstrap-dark-definition.scss +118 -118
- package/styles/list-box/_bootstrap-definition.scss +112 -112
- package/styles/list-box/_bootstrap4-definition.scss +118 -118
- package/styles/list-box/_fabric-dark-definition.scss +118 -118
- package/styles/list-box/_fabric-definition.scss +112 -112
- package/styles/list-box/_highcontrast-definition.scss +112 -112
- package/styles/list-box/_highcontrast-light-definition.scss +118 -118
- package/styles/list-box/_layout.scss +458 -458
- package/styles/list-box/_material-dark-definition.scss +118 -118
- package/styles/list-box/_material-definition.scss +112 -112
- package/styles/list-box/_theme.scss +273 -273
- package/styles/list-box/icons/_bootstrap-dark.scss +25 -25
- package/styles/list-box/icons/_bootstrap.scss +25 -25
- package/styles/list-box/icons/_bootstrap4.scss +25 -25
- package/styles/list-box/icons/_fabric-dark.scss +25 -25
- package/styles/list-box/icons/_fabric.scss +25 -25
- package/styles/list-box/icons/_highcontrast-light.scss +25 -25
- package/styles/list-box/icons/_highcontrast.scss +25 -25
- package/styles/list-box/icons/_material-dark.scss +25 -25
- package/styles/list-box/icons/_material.scss +25 -25
- package/styles/material-dark.css +8 -11
- package/styles/material.css +34 -10
- package/styles/multi-select/_all.scss +2 -2
- package/styles/multi-select/_bootstrap-dark-definition.scss +171 -171
- package/styles/multi-select/_bootstrap-definition.scss +166 -166
- package/styles/multi-select/_bootstrap4-definition.scss +233 -233
- package/styles/multi-select/_fabric-dark-definition.scss +170 -170
- package/styles/multi-select/_fabric-definition.scss +167 -167
- package/styles/multi-select/_highcontrast-definition.scss +257 -259
- package/styles/multi-select/_highcontrast-light-definition.scss +258 -258
- package/styles/multi-select/_layout.scss +1153 -1153
- package/styles/multi-select/_material-dark-definition.scss +186 -186
- package/styles/multi-select/_material-definition.scss +191 -191
- package/styles/multi-select/_theme.scss +384 -389
- package/styles/multi-select/bootstrap-dark.css +13 -16
- package/styles/multi-select/bootstrap.css +12 -15
- package/styles/multi-select/bootstrap4.css +6 -10
- package/styles/multi-select/fabric-dark.css +2 -5
- package/styles/multi-select/fabric.css +1 -4
- package/styles/multi-select/highcontrast-light.css +2 -5
- package/styles/multi-select/highcontrast.css +2 -7
- package/styles/multi-select/icons/_bootstrap-dark.scss +26 -26
- package/styles/multi-select/icons/_bootstrap.scss +26 -26
- package/styles/multi-select/icons/_bootstrap4.scss +37 -37
- package/styles/multi-select/icons/_fabric-dark.scss +26 -26
- package/styles/multi-select/icons/_fabric.scss +26 -26
- package/styles/multi-select/icons/_highcontrast-light.scss +26 -26
- package/styles/multi-select/icons/_highcontrast.scss +26 -26
- package/styles/multi-select/icons/_material-dark.scss +26 -26
- package/styles/multi-select/icons/_material.scss +324 -324
- package/styles/multi-select/material-dark.css +8 -11
- package/styles/multi-select/material.css +16 -10
|
@@ -0,0 +1,957 @@
|
|
|
1
|
+
/// <reference path='../drop-down-list/drop-down-list-model.d.ts'/>
|
|
2
|
+
import { EventHandler, Property, Event, EmitType, addClass, Browser, KeyboardEventArgs, removeClass, detach } from '@syncfusion/ej2-base';
|
|
3
|
+
import { isNullOrUndefined, NotifyPropertyChanges, getValue, setValue } from '@syncfusion/ej2-base';
|
|
4
|
+
import { DropDownList, dropDownListClasses } from '../drop-down-list/drop-down-list';
|
|
5
|
+
import { FilteringEventArgs } from '../drop-down-base/drop-down-base';
|
|
6
|
+
import { FieldSettingsModel } from '../drop-down-base/drop-down-base-model';
|
|
7
|
+
import { ComboBoxModel } from '../combo-box/combo-box-model';
|
|
8
|
+
import { Search } from '../common/incremental-search';
|
|
9
|
+
import { createSpinner, showSpinner, hideSpinner } from '@syncfusion/ej2-popups';
|
|
10
|
+
/* tslint:disable */
|
|
11
|
+
import { Input, InputObject, FloatLabelType } from '@syncfusion/ej2-inputs';
|
|
12
|
+
import { DataManager, Query } from '@syncfusion/ej2-data';
|
|
13
|
+
/* tslint:enable */
|
|
14
|
+
const SPINNER_CLASS: string = 'e-atc-spinner-icon';
|
|
15
|
+
|
|
16
|
+
dropDownListClasses.root = 'e-combobox';
|
|
17
|
+
let inputObject: InputObject = {
|
|
18
|
+
container: null,
|
|
19
|
+
buttons: []
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The ComboBox component allows the user to type a value or choose an option from the list of predefined options.
|
|
23
|
+
* ```html
|
|
24
|
+
* <select id="list">
|
|
25
|
+
* <option value='1'>Badminton</option>
|
|
26
|
+
* <option value='2'>Basketball</option>
|
|
27
|
+
* <option value='3'>Cricket</option>
|
|
28
|
+
* <option value='4'>Football</option>
|
|
29
|
+
* <option value='5'>Tennis</option>
|
|
30
|
+
* </select>
|
|
31
|
+
* ```
|
|
32
|
+
* ```typescript
|
|
33
|
+
* let games:ComboBox = new ComboBox();
|
|
34
|
+
* games.appendTo("#list");
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
@NotifyPropertyChanges
|
|
38
|
+
export class ComboBox extends DropDownList {
|
|
39
|
+
/**
|
|
40
|
+
* Specifies whether suggest a first matched item in input when searching. No action happens when no matches found.
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
@Property(false)
|
|
44
|
+
public autofill: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Specifies whether the component allows user defined value which does not exist in data source.
|
|
47
|
+
* @default true
|
|
48
|
+
*/
|
|
49
|
+
@Property(true)
|
|
50
|
+
public allowCustom: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Allows additional HTML attributes such as title, name, etc., and
|
|
53
|
+
* accepts n number of attributes in a key-value pair format.
|
|
54
|
+
*
|
|
55
|
+
* {% codeBlock src='combobox/htmlAttributes/index.md' %}{% endcodeBlock %}
|
|
56
|
+
*
|
|
57
|
+
* @default {}
|
|
58
|
+
* @deprecated
|
|
59
|
+
*/
|
|
60
|
+
@Property({})
|
|
61
|
+
public htmlAttributes: { [key: string]: string; };
|
|
62
|
+
/**
|
|
63
|
+
* When allowFiltering is set to true, show the filter bar (search box) of the component.
|
|
64
|
+
* The filter action retrieves matched items through the `filtering` event based on
|
|
65
|
+
* the characters typed in the search TextBox.
|
|
66
|
+
* If no match is found, the value of the `noRecordsTemplate` property will be displayed.
|
|
67
|
+
*
|
|
68
|
+
* {% codeBlock src="combobox/allow-filtering-api/index.ts" %}{% endcodeBlock %}
|
|
69
|
+
*
|
|
70
|
+
* {% codeBlock src="combobox/allow-filtering-api/index.html" %}{% endcodeBlock %}
|
|
71
|
+
* @default false
|
|
72
|
+
* @deprecated
|
|
73
|
+
*/
|
|
74
|
+
@Property(false)
|
|
75
|
+
public allowFiltering: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Accepts the external `Query`
|
|
78
|
+
* that execute along with [`data processing`](../../combo-box/data-binding).
|
|
79
|
+
*
|
|
80
|
+
* {% codeBlock src='combobox/query/index.md' %}{% endcodeBlock %}
|
|
81
|
+
* @default null
|
|
82
|
+
* @deprecated
|
|
83
|
+
*/
|
|
84
|
+
@Property(null)
|
|
85
|
+
public query: Query;
|
|
86
|
+
/**
|
|
87
|
+
* Gets or sets the index of the selected item in the component.
|
|
88
|
+
*
|
|
89
|
+
* {% codeBlock src="combobox/index-api/index.ts" %}{% endcodeBlock %}
|
|
90
|
+
*
|
|
91
|
+
* {% codeBlock src="combobox/index-api/index.html" %}{% endcodeBlock %}
|
|
92
|
+
*
|
|
93
|
+
* @default null
|
|
94
|
+
* @blazorType int
|
|
95
|
+
* @isBlazorNullableType true
|
|
96
|
+
* @blazorDefaultValue
|
|
97
|
+
* @deprecated
|
|
98
|
+
*/
|
|
99
|
+
@Property(null)
|
|
100
|
+
public index: number;
|
|
101
|
+
/**
|
|
102
|
+
* Specifies whether to show or hide the clear button.
|
|
103
|
+
* When the clear button is clicked, `value`, `text`, and `index` properties are reset to null.
|
|
104
|
+
* @default true
|
|
105
|
+
* @blazorOverrideType override
|
|
106
|
+
*/
|
|
107
|
+
@Property(true)
|
|
108
|
+
public showClearButton: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Enable or disable rendering component in right to left direction.
|
|
111
|
+
* @default false
|
|
112
|
+
* @deprecated
|
|
113
|
+
* @blazorOverrideType override
|
|
114
|
+
*/
|
|
115
|
+
@Property(false)
|
|
116
|
+
public enableRtl: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Triggers on set a
|
|
119
|
+
* [`custom value`](../../combo-box/getting-started#custom-values) to this component.
|
|
120
|
+
* @event
|
|
121
|
+
* @blazorProperty 'CustomValueSpecifier'
|
|
122
|
+
*/
|
|
123
|
+
@Event()
|
|
124
|
+
public customValueSpecifier: EmitType<CustomValueSpecifierEventArgs>;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Triggers on typing a character in the component.
|
|
128
|
+
* > For more details about the filtering refer to [`Filtering`](../../combo-box/filtering) documentation.
|
|
129
|
+
* @event
|
|
130
|
+
* @blazorProperty 'Filtering'
|
|
131
|
+
*/
|
|
132
|
+
@Event()
|
|
133
|
+
public filtering: EmitType<FilteringEventArgs>;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Not applicable to this component.
|
|
137
|
+
* @default null
|
|
138
|
+
* @private
|
|
139
|
+
*/
|
|
140
|
+
@Property(null)
|
|
141
|
+
public valueTemplate: string;
|
|
142
|
+
/**
|
|
143
|
+
* Specifies whether to display the floating label above the input element.
|
|
144
|
+
* Possible values are:
|
|
145
|
+
* * Never: The label will never float in the input when the placeholder is available.
|
|
146
|
+
* * Always: The floating label will always float above the input.
|
|
147
|
+
* * Auto: The floating label will float above the input after focusing or entering a value in the input.
|
|
148
|
+
*
|
|
149
|
+
* {% codeBlock src="combobox/float-label-type-api/index.ts" %}{% endcodeBlock %}
|
|
150
|
+
*
|
|
151
|
+
* {% codeBlock src="combobox/float-label-type-api/index.html" %}{% endcodeBlock %}
|
|
152
|
+
*
|
|
153
|
+
* @default Syncfusion.EJ2.Inputs.FloatLabelType.Never
|
|
154
|
+
* @aspType Syncfusion.EJ2.Inputs.FloatLabelType
|
|
155
|
+
* @isEnumeration true
|
|
156
|
+
* @blazorType Syncfusion.Blazor.Inputs.FloatLabelType
|
|
157
|
+
* @deprecated
|
|
158
|
+
*/
|
|
159
|
+
@Property('Never')
|
|
160
|
+
public floatLabelType: FloatLabelType;
|
|
161
|
+
/**
|
|
162
|
+
* Not applicable to this component.
|
|
163
|
+
* @default null
|
|
164
|
+
* @private
|
|
165
|
+
* @deprecated
|
|
166
|
+
*/
|
|
167
|
+
@Property(null)
|
|
168
|
+
public filterBarPlaceholder: string;
|
|
169
|
+
/**
|
|
170
|
+
* Sets CSS classes to the root element of the component that allows customization of appearance.
|
|
171
|
+
* @default null
|
|
172
|
+
* @deprecated
|
|
173
|
+
*/
|
|
174
|
+
@Property(null)
|
|
175
|
+
public cssClass: string;
|
|
176
|
+
/**
|
|
177
|
+
* Accepts the template design and assigns it to the header container of the popup list.
|
|
178
|
+
* > For more details about the available template options refer to [`Template`](../../drop-down-list/templates) documentation.
|
|
179
|
+
* @default null
|
|
180
|
+
* @deprecated
|
|
181
|
+
*/
|
|
182
|
+
@Property(null)
|
|
183
|
+
public headerTemplate: string;
|
|
184
|
+
/**
|
|
185
|
+
* Accepts the template design and assigns it to the footer container of the popup list.
|
|
186
|
+
* > For more details about the available template options refer to [`Template`](../../drop-down-list/templates) documentation.
|
|
187
|
+
* @default null
|
|
188
|
+
* @deprecated
|
|
189
|
+
*/
|
|
190
|
+
@Property(null)
|
|
191
|
+
public footerTemplate: string;
|
|
192
|
+
/**
|
|
193
|
+
* Specifies a short hint that describes the expected value of the DropDownList component.
|
|
194
|
+
* @default null
|
|
195
|
+
* @deprecated
|
|
196
|
+
*/
|
|
197
|
+
@Property(null)
|
|
198
|
+
public placeholder: string;
|
|
199
|
+
/**
|
|
200
|
+
* Specifies the width of the component. By default, the component width sets based on the width of
|
|
201
|
+
* its parent container. You can also set the width in pixel values.
|
|
202
|
+
* @default '100%'
|
|
203
|
+
* @aspType string
|
|
204
|
+
* @blazorType string
|
|
205
|
+
* @deprecated
|
|
206
|
+
*/
|
|
207
|
+
@Property('100%')
|
|
208
|
+
public width: string | number;
|
|
209
|
+
/**
|
|
210
|
+
* Specifies the height of the popup list.
|
|
211
|
+
* > For more details about the popup configuration refer to
|
|
212
|
+
* [`Popup Configuration`](../../drop-down-list/getting-started#configure-the-popup-list) documentation.
|
|
213
|
+
* @default '300px'
|
|
214
|
+
* @aspType string
|
|
215
|
+
* @blazorType string
|
|
216
|
+
* @deprecated
|
|
217
|
+
*/
|
|
218
|
+
@Property('300px')
|
|
219
|
+
public popupHeight: string | number;
|
|
220
|
+
/**
|
|
221
|
+
* Specifies the width of the popup list. By default, the popup width sets based on the width of
|
|
222
|
+
* the component.
|
|
223
|
+
* > For more details about the popup configuration refer to
|
|
224
|
+
* [`Popup Configuration`](../../drop-down-list/getting-started#configure-the-popup-list) documentation.
|
|
225
|
+
* @default '100%'
|
|
226
|
+
* @aspType string
|
|
227
|
+
* @blazorType string
|
|
228
|
+
* @deprecated
|
|
229
|
+
*/
|
|
230
|
+
@Property('100%')
|
|
231
|
+
public popupWidth: string | number;
|
|
232
|
+
/**
|
|
233
|
+
* When set to true, the user interactions on the component are disabled.
|
|
234
|
+
* @default false
|
|
235
|
+
* @deprecated
|
|
236
|
+
*/
|
|
237
|
+
@Property(false)
|
|
238
|
+
public readonly: boolean;
|
|
239
|
+
/**
|
|
240
|
+
* Gets or sets the display text of the selected item in the component.
|
|
241
|
+
* @default null
|
|
242
|
+
* @deprecated
|
|
243
|
+
*/
|
|
244
|
+
@Property(null)
|
|
245
|
+
public text: string;
|
|
246
|
+
/**
|
|
247
|
+
* Gets or sets the value of the selected item in the component.
|
|
248
|
+
* @default null
|
|
249
|
+
* @isGenericType true
|
|
250
|
+
* @deprecated
|
|
251
|
+
*/
|
|
252
|
+
@Property(null)
|
|
253
|
+
public value: number | string | boolean;
|
|
254
|
+
/**
|
|
255
|
+
* *Constructor for creating the component
|
|
256
|
+
*/
|
|
257
|
+
constructor(options?: ComboBoxModel, element?: string | HTMLElement) {
|
|
258
|
+
super(options, element);
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* Initialize the event handler
|
|
262
|
+
* @private
|
|
263
|
+
*/
|
|
264
|
+
protected preRender(): void {
|
|
265
|
+
super.preRender();
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
protected getLocaleName(): string {
|
|
269
|
+
return 'combo-box';
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
protected wireEvent(): void {
|
|
273
|
+
if (this.getModuleName() === 'combobox') {
|
|
274
|
+
EventHandler.add(this.inputWrapper.buttons[0], 'mousedown', this.preventBlur, this);
|
|
275
|
+
EventHandler.add(this.inputWrapper.container, 'blur', this.onBlur, this);
|
|
276
|
+
}
|
|
277
|
+
if (!isNullOrUndefined(this.inputWrapper.buttons[0])) {
|
|
278
|
+
EventHandler.add(this.inputWrapper.buttons[0], 'mousedown', this.dropDownClick, this);
|
|
279
|
+
}
|
|
280
|
+
EventHandler.add(this.inputElement, 'focus', this.targetFocus, this);
|
|
281
|
+
if (!this.readonly) {
|
|
282
|
+
EventHandler.add(this.inputElement, 'input', this.onInput, this);
|
|
283
|
+
EventHandler.add(this.inputElement, 'keyup', this.onFilterUp, this);
|
|
284
|
+
EventHandler.add(this.inputElement, 'keydown', this.onFilterDown, this);
|
|
285
|
+
EventHandler.add(this.inputElement, 'paste', this.pasteHandler, this);
|
|
286
|
+
}
|
|
287
|
+
this.bindCommonEvent();
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
private preventBlur(e: MouseEvent): void {
|
|
291
|
+
if ((!this.allowFiltering && document.activeElement !== this.inputElement &&
|
|
292
|
+
!document.activeElement.classList.contains(dropDownListClasses.input) && Browser.isDevice || !Browser.isDevice)) {
|
|
293
|
+
e.preventDefault();
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
protected onBlur(e: MouseEvent): void {
|
|
298
|
+
let inputValue: string = this.inputElement.value === '' ? null : this.inputElement.value;
|
|
299
|
+
if (!isNullOrUndefined(this.listData) && !isNullOrUndefined(inputValue) && inputValue !== this.text) {
|
|
300
|
+
this.customValue(e);
|
|
301
|
+
}
|
|
302
|
+
super.onBlur(e);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
protected targetElement(): HTMLElement | HTMLInputElement {
|
|
306
|
+
return this.inputElement;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
protected setOldText(text: string): void {
|
|
310
|
+
Input.setValue(this.text, this.inputElement, this.floatLabelType, this.showClearButton);
|
|
311
|
+
this.customValue();
|
|
312
|
+
this.removeSelection();
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
protected setOldValue(value: string | number): void {
|
|
316
|
+
if (this.allowCustom) {
|
|
317
|
+
this.valueMuteChange(this.value);
|
|
318
|
+
} else {
|
|
319
|
+
this.valueMuteChange(null);
|
|
320
|
+
}
|
|
321
|
+
this.removeSelection();
|
|
322
|
+
this.setHiddenValue();
|
|
323
|
+
}
|
|
324
|
+
private valueMuteChange(value: string | number | boolean): void {
|
|
325
|
+
let inputValue: string = isNullOrUndefined(value) ? null : value.toString();
|
|
326
|
+
Input.setValue(inputValue, this.inputElement, this.floatLabelType, this.showClearButton);
|
|
327
|
+
this.setProperties({ value: value, text: value, index: null }, true);
|
|
328
|
+
this.activeIndex = this.index;
|
|
329
|
+
let fields: FieldSettingsModel = this.fields;
|
|
330
|
+
let dataItem: { [key: string]: string | Object } = {};
|
|
331
|
+
dataItem[fields.text] = isNullOrUndefined(value) ? null : value.toString();
|
|
332
|
+
dataItem[fields.value] = isNullOrUndefined(value) ? null : value.toString();
|
|
333
|
+
this.itemData = <{ [key: string]: Object }>dataItem;
|
|
334
|
+
this.item = null;
|
|
335
|
+
if (this.previousValue !== this.value) {
|
|
336
|
+
this.detachChangeEvent(null);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
protected updateValues(): void {
|
|
340
|
+
if (!isNullOrUndefined(this.value)) {
|
|
341
|
+
let li: Element = this.getElementByValue(this.value);
|
|
342
|
+
if (li) {
|
|
343
|
+
this.setSelection(li, null);
|
|
344
|
+
} else if (this.allowCustom) {
|
|
345
|
+
this.valueMuteChange(this.value);
|
|
346
|
+
} else {
|
|
347
|
+
this.valueMuteChange(null);
|
|
348
|
+
}
|
|
349
|
+
} else if (this.text && isNullOrUndefined(this.value)) {
|
|
350
|
+
let li: Element = this.getElementByText(this.text);
|
|
351
|
+
if (li) {
|
|
352
|
+
this.setSelection(li, null);
|
|
353
|
+
} else {
|
|
354
|
+
Input.setValue(this.text, this.inputElement, this.floatLabelType, this.showClearButton);
|
|
355
|
+
this.customValue();
|
|
356
|
+
}
|
|
357
|
+
} else {
|
|
358
|
+
this.setSelection(this.liCollections[this.activeIndex], null);
|
|
359
|
+
}
|
|
360
|
+
this.setHiddenValue();
|
|
361
|
+
Input.setValue(this.text, this.inputElement, this.floatLabelType, this.showClearButton);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
protected updateIconState(): void {
|
|
365
|
+
if (this.showClearButton) {
|
|
366
|
+
if (this.inputElement.value !== '' && !this.readonly) {
|
|
367
|
+
removeClass([this.inputWrapper.clearButton], dropDownListClasses.clearIconHide);
|
|
368
|
+
} else {
|
|
369
|
+
addClass([this.inputWrapper.clearButton], dropDownListClasses.clearIconHide);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
protected getAriaAttributes(): { [key: string]: string } {
|
|
375
|
+
let ariaAttributes: { [key: string]: string } = {
|
|
376
|
+
'aria-owns': this.element.id + '_options',
|
|
377
|
+
'role': 'combobox',
|
|
378
|
+
'aria-autocomplete': 'both',
|
|
379
|
+
'aria-labelledby': this.hiddenElement.id,
|
|
380
|
+
'aria-hasPopup': 'true',
|
|
381
|
+
'aria-expanded': 'false',
|
|
382
|
+
'aria-readonly': this.readonly.toString(),
|
|
383
|
+
'autocomplete': 'off',
|
|
384
|
+
'autocorrect': 'off',
|
|
385
|
+
'autocapitalize': 'off',
|
|
386
|
+
'spellcheck': 'false'
|
|
387
|
+
};
|
|
388
|
+
return ariaAttributes;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
protected searchLists(e: KeyboardEventArgs): void {
|
|
392
|
+
this.isTyped = true;
|
|
393
|
+
if (this.isFiltering()) {
|
|
394
|
+
super.searchLists(e);
|
|
395
|
+
if (this.ulElement && this.filterInput.value.trim() === '') {
|
|
396
|
+
this.setHoverList(this.ulElement.querySelector('.' + dropDownListClasses.li));
|
|
397
|
+
}
|
|
398
|
+
} else {
|
|
399
|
+
if (this.ulElement && this.inputElement.value === '' && this.preventAutoFill) {
|
|
400
|
+
this.setHoverList(this.ulElement.querySelector('.' + dropDownListClasses.li));
|
|
401
|
+
}
|
|
402
|
+
this.incrementalSearch(e as KeyboardEventArgs);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
protected getNgDirective(): string {
|
|
407
|
+
return 'EJS-COMBOBOX';
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
protected setSearchBox(): InputObject {
|
|
411
|
+
this.filterInput = this.inputElement;
|
|
412
|
+
return (this.isFiltering() ? this.inputWrapper : inputObject);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
protected onActionComplete(ulElement: HTMLElement, list: { [key: string]: Object }[], e?: Object, isUpdated?: boolean): void {
|
|
416
|
+
if (!this.isServerBlazor) {
|
|
417
|
+
super.onActionComplete(ulElement, list, e);
|
|
418
|
+
}
|
|
419
|
+
if (this.isSelectCustom) {
|
|
420
|
+
this.removeSelection();
|
|
421
|
+
}
|
|
422
|
+
if (!this.preventAutoFill && this.getModuleName() === 'combobox' && this.isTyped) {
|
|
423
|
+
this.inlineSearch();
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
protected getFocusElement(): Element {
|
|
428
|
+
let dataItem: { [key: string]: string } = this.isSelectCustom ? { text: '' } : this.getItemData();
|
|
429
|
+
let selected: HTMLElement = <HTMLElement>this.list.querySelector('.' + dropDownListClasses.selected);
|
|
430
|
+
let isSelected: boolean = dataItem.text === this.inputElement.value && !isNullOrUndefined(selected);
|
|
431
|
+
if (isSelected) {
|
|
432
|
+
return selected;
|
|
433
|
+
}
|
|
434
|
+
if ((Browser.isDevice && !this.isDropDownClick || !Browser.isDevice) &&
|
|
435
|
+
!isNullOrUndefined(this.liCollections) && this.liCollections.length > 0) {
|
|
436
|
+
let inputValue: string = this.inputElement.value;
|
|
437
|
+
let activeItem: { [key: string]: Element | number } = Search(inputValue, this.liCollections, 'StartsWith', true);
|
|
438
|
+
let activeElement: Element = activeItem.item as Element;
|
|
439
|
+
if (!isNullOrUndefined(activeElement)) {
|
|
440
|
+
let count: number = this.getIndexByValue(activeElement.getAttribute('data-value')) - 1;
|
|
441
|
+
let height: number = parseInt(getComputedStyle(this.liCollections[0], null).getPropertyValue('height'), 10);
|
|
442
|
+
if (!isNaN(height) && this.getModuleName() !== 'autocomplete') {
|
|
443
|
+
this.removeFocus();
|
|
444
|
+
let fixedHead: number = this.fields.groupBy ? this.liCollections[0].offsetHeight : 0;
|
|
445
|
+
this.list.scrollTop = count * height + fixedHead;
|
|
446
|
+
addClass([activeElement], dropDownListClasses.focus);
|
|
447
|
+
}
|
|
448
|
+
} else {
|
|
449
|
+
if (this.isSelectCustom && this.inputElement.value.trim() !== '') {
|
|
450
|
+
this.removeFocus();
|
|
451
|
+
this.list.scrollTop = 0;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
return activeElement;
|
|
455
|
+
} else {
|
|
456
|
+
return null;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
protected setValue(e?: KeyboardEventArgs): boolean {
|
|
461
|
+
if (e && e.type === 'keydown' && e.action === 'enter') {
|
|
462
|
+
this.removeFillSelection();
|
|
463
|
+
}
|
|
464
|
+
if (this.autofill && this.getModuleName() === 'combobox' && e && e.type === 'keydown' && e.action !== 'enter') {
|
|
465
|
+
this.preventAutoFill = false;
|
|
466
|
+
this.inlineSearch(e);
|
|
467
|
+
return false;
|
|
468
|
+
} else {
|
|
469
|
+
return super.setValue(e);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
protected checkCustomValue(): void {
|
|
473
|
+
this.itemData = this.getDataByValue(this.value);
|
|
474
|
+
let dataItem: { [key: string]: string } = this.getItemData();
|
|
475
|
+
if (!(this.allowCustom && isNullOrUndefined(dataItem.value) && isNullOrUndefined(dataItem.text))) {
|
|
476
|
+
this.setProperties({ 'value': dataItem.value, 'text': dataItem.text }, true);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Shows the spinner loader.
|
|
481
|
+
* @returns void.
|
|
482
|
+
* @deprecated
|
|
483
|
+
*/
|
|
484
|
+
public showSpinner(): void {
|
|
485
|
+
if (isNullOrUndefined(this.spinnerElement)) {
|
|
486
|
+
this.spinnerElement = (this.getModuleName() === 'autocomplete') ? (this.inputWrapper.buttons[0] ||
|
|
487
|
+
this.inputWrapper.clearButton ||
|
|
488
|
+
Input.appendSpan('e-input-group-icon ' + SPINNER_CLASS, this.inputWrapper.container, this.createElement)) :
|
|
489
|
+
(this.inputWrapper.buttons[0] || this.inputWrapper.clearButton);
|
|
490
|
+
addClass([this.spinnerElement], dropDownListClasses.disableIcon);
|
|
491
|
+
createSpinner(
|
|
492
|
+
{
|
|
493
|
+
target: this.spinnerElement,
|
|
494
|
+
width: Browser.isDevice ? '16px' : '14px'
|
|
495
|
+
},
|
|
496
|
+
this.createElement);
|
|
497
|
+
showSpinner(this.spinnerElement);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Hides the spinner loader.
|
|
502
|
+
* @returns void.
|
|
503
|
+
* @deprecated
|
|
504
|
+
*/
|
|
505
|
+
public hideSpinner(): void {
|
|
506
|
+
if (!isNullOrUndefined(this.spinnerElement)) {
|
|
507
|
+
hideSpinner(this.spinnerElement);
|
|
508
|
+
removeClass([this.spinnerElement], dropDownListClasses.disableIcon);
|
|
509
|
+
if (this.spinnerElement.classList.contains(SPINNER_CLASS)) {
|
|
510
|
+
detach(this.spinnerElement);
|
|
511
|
+
} else {
|
|
512
|
+
this.spinnerElement.innerHTML = '';
|
|
513
|
+
}
|
|
514
|
+
this.spinnerElement = null;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
protected setAutoFill(activeElement: Element, isHover?: boolean): void {
|
|
519
|
+
if (!isHover) {
|
|
520
|
+
this.setHoverList(activeElement);
|
|
521
|
+
}
|
|
522
|
+
if (this.autofill && !this.preventAutoFill) {
|
|
523
|
+
let currentValue: string = <string>this.getTextByValue(activeElement.getAttribute('data-value')).toString();
|
|
524
|
+
let currentFillValue: string | number | boolean = this.getFormattedValue(activeElement.getAttribute('data-value'));
|
|
525
|
+
if (this.getModuleName() === 'combobox') {
|
|
526
|
+
if (!this.isSelected && this.previousValue !== currentFillValue) {
|
|
527
|
+
this.updateSelectedItem(activeElement, null);
|
|
528
|
+
this.isSelected = true;
|
|
529
|
+
this.previousValue = this.getFormattedValue(activeElement.getAttribute('data-value'));
|
|
530
|
+
} else {
|
|
531
|
+
this.updateSelectedItem(activeElement, null, true);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
if (!this.isAndroidAutoFill(currentValue)) {
|
|
535
|
+
this.setAutoFillSelection(currentValue);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
private isAndroidAutoFill(value: string): boolean {
|
|
541
|
+
if (Browser.isAndroid) {
|
|
542
|
+
let currentPoints: { [key: string]: number } = this.getSelectionPoints();
|
|
543
|
+
let prevEnd: number = this.prevSelectPoints.end;
|
|
544
|
+
let curEnd: number = currentPoints.end;
|
|
545
|
+
let prevStart: number = this.prevSelectPoints.start;
|
|
546
|
+
let curStart: number = currentPoints.start;
|
|
547
|
+
if (prevEnd !== 0 && ((prevEnd === value.length && prevStart === value.length) ||
|
|
548
|
+
(prevStart > curStart && prevEnd > curEnd) || (prevEnd === curEnd && prevStart === curStart))) {
|
|
549
|
+
return true;
|
|
550
|
+
} else {
|
|
551
|
+
return false;
|
|
552
|
+
}
|
|
553
|
+
} else {
|
|
554
|
+
return false;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
protected clearAll(e?: MouseEvent | KeyboardEventArgs, property?: ComboBoxModel): void {
|
|
559
|
+
if (isNullOrUndefined(property) || (!isNullOrUndefined(property) && isNullOrUndefined(property.dataSource))) {
|
|
560
|
+
super.clearAll(e);
|
|
561
|
+
if (this.isServerBlazor && this.isFiltering() && this.isPopupOpen && e) {
|
|
562
|
+
// tslint:disable-next-line
|
|
563
|
+
(this as any).interopAdaptor.invokeMethodAsync('OnServerRenderList', this.beforePopupOpen, true);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
protected isSelectFocusItem(element: Element): boolean {
|
|
569
|
+
return !isNullOrUndefined(element);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
private inlineSearch(e?: KeyboardEventArgs): void {
|
|
573
|
+
let isKeyNavigate: boolean = (e && (e.action === 'down' || e.action === 'up' ||
|
|
574
|
+
e.action === 'home' || e.action === 'end' || e.action === 'pageUp' || e.action === 'pageDown'));
|
|
575
|
+
let activeElement: Element = isKeyNavigate ? this.liCollections[this.activeIndex] : this.getFocusElement();
|
|
576
|
+
if (!isNullOrUndefined(activeElement)) {
|
|
577
|
+
if (!isKeyNavigate) {
|
|
578
|
+
let value: string | number | boolean = this.getFormattedValue(activeElement.getAttribute('data-value'));
|
|
579
|
+
this.activeIndex = this.getIndexByValue(value);
|
|
580
|
+
this.activeIndex = !isNullOrUndefined(this.activeIndex) ? this.activeIndex : null;
|
|
581
|
+
}
|
|
582
|
+
this.preventAutoFill = this.inputElement.value === '' ? false : this.preventAutoFill;
|
|
583
|
+
this.setAutoFill(activeElement, isKeyNavigate);
|
|
584
|
+
} else if (this.inputElement.value === '') {
|
|
585
|
+
this.activeIndex = null;
|
|
586
|
+
this.list.scrollTop = 0;
|
|
587
|
+
let focusItem: Element = this.list.querySelector('.' + dropDownListClasses.li);
|
|
588
|
+
this.setHoverList(focusItem);
|
|
589
|
+
} else {
|
|
590
|
+
this.activeIndex = null;
|
|
591
|
+
this.removeSelection();
|
|
592
|
+
if (this.liCollections && this.liCollections.length < 0) {
|
|
593
|
+
this.removeFocus();
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
protected incrementalSearch(e: KeyboardEventArgs): void {
|
|
599
|
+
this.showPopup();
|
|
600
|
+
if (!isNullOrUndefined(this.listData)) {
|
|
601
|
+
this.inlineSearch(e);
|
|
602
|
+
e.preventDefault();
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
|
|
606
|
+
private setAutoFillSelection(currentValue: string): void {
|
|
607
|
+
let selection: { [key: string]: number } = this.getSelectionPoints();
|
|
608
|
+
let value: string = this.inputElement.value.substr(0, selection.start);
|
|
609
|
+
if (value && (value.toLowerCase() === currentValue.substr(0, selection.start).toLowerCase())) {
|
|
610
|
+
let inputValue: string = value + currentValue.substr(value.length, currentValue.length);
|
|
611
|
+
Input.setValue(inputValue, this.inputElement, this.floatLabelType, this.showClearButton);
|
|
612
|
+
this.inputElement.setSelectionRange(selection.start, this.inputElement.value.length);
|
|
613
|
+
} else {
|
|
614
|
+
Input.setValue(currentValue, this.inputElement, this.floatLabelType, this.showClearButton);
|
|
615
|
+
this.inputElement.setSelectionRange(0, this.inputElement.value.length);
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
protected getValueByText(text: string): string | number | boolean {
|
|
620
|
+
return super.getValueByText(text, true, this.ignoreAccent);
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
protected unWireEvent(): void {
|
|
624
|
+
if (this.getModuleName() === 'combobox') {
|
|
625
|
+
EventHandler.remove(this.inputWrapper.buttons[0], 'mousedown', this.preventBlur);
|
|
626
|
+
EventHandler.remove(this.inputWrapper.container, 'blur', this.onBlur);
|
|
627
|
+
}
|
|
628
|
+
if (!isNullOrUndefined(this.inputWrapper.buttons[0])) {
|
|
629
|
+
EventHandler.remove(this.inputWrapper.buttons[0], 'mousedown', this.dropDownClick);
|
|
630
|
+
}
|
|
631
|
+
EventHandler.remove(this.inputElement, 'focus', this.targetFocus);
|
|
632
|
+
if (!this.readonly) {
|
|
633
|
+
EventHandler.remove(this.inputElement, 'input', this.onInput);
|
|
634
|
+
EventHandler.remove(this.inputElement, 'keyup', this.onFilterUp);
|
|
635
|
+
EventHandler.remove(this.inputElement, 'keydown', this.onFilterDown);
|
|
636
|
+
EventHandler.remove(this.inputElement, 'paste', this.pasteHandler);
|
|
637
|
+
}
|
|
638
|
+
this.unBindCommonEvent();
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
protected setSelection(li: Element, e: MouseEvent | KeyboardEventArgs | TouchEvent): void {
|
|
642
|
+
super.setSelection(li, e);
|
|
643
|
+
if (!isNullOrUndefined(li) && !this.autofill && !this.isDropDownClick) {
|
|
644
|
+
this.removeFocus();
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
protected selectCurrentItem(e: KeyboardEventArgs): void {
|
|
648
|
+
let li: Element;
|
|
649
|
+
if (this.isPopupOpen) {
|
|
650
|
+
if (this.isSelected) {
|
|
651
|
+
li = this.list.querySelector('.' + dropDownListClasses.selected);
|
|
652
|
+
} else {
|
|
653
|
+
li = this.list.querySelector('.' + dropDownListClasses.focus);
|
|
654
|
+
}
|
|
655
|
+
if (li) {
|
|
656
|
+
this.setSelection(li, e);
|
|
657
|
+
this.isTyped = false;
|
|
658
|
+
}
|
|
659
|
+
if (this.isSelected) {
|
|
660
|
+
this.isSelectCustom = false;
|
|
661
|
+
this.onChangeEvent(e);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
if (e.action === 'enter' && this.inputElement.value.trim() === '') {
|
|
665
|
+
this.clearAll(e);
|
|
666
|
+
} else if (this.isTyped && !this.isSelected && isNullOrUndefined(li)) {
|
|
667
|
+
this.customValue(e);
|
|
668
|
+
}
|
|
669
|
+
this.hidePopup();
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
protected setHoverList(li: Element): void {
|
|
673
|
+
this.removeSelection();
|
|
674
|
+
if (this.isValidLI(li) && !li.classList.contains(dropDownListClasses.selected)) {
|
|
675
|
+
this.removeFocus();
|
|
676
|
+
li.classList.add(dropDownListClasses.focus);
|
|
677
|
+
}
|
|
678
|
+
};
|
|
679
|
+
private targetFocus(e: MouseEvent): void {
|
|
680
|
+
if (Browser.isDevice && !this.allowFiltering) {
|
|
681
|
+
this.preventFocus = false;
|
|
682
|
+
}
|
|
683
|
+
this.onFocus(e);
|
|
684
|
+
}
|
|
685
|
+
protected dropDownClick(e: MouseEvent): void {
|
|
686
|
+
e.preventDefault();
|
|
687
|
+
if (Browser.isDevice && !this.allowFiltering) {
|
|
688
|
+
this.preventFocus = true;
|
|
689
|
+
}
|
|
690
|
+
super.dropDownClick(e);
|
|
691
|
+
}
|
|
692
|
+
private customValue(e?: MouseEvent | KeyboardEventArgs): void {
|
|
693
|
+
let value: string | number | boolean = this.getValueByText(this.inputElement.value);
|
|
694
|
+
if (!this.allowCustom && this.inputElement.value !== '') {
|
|
695
|
+
let previousValue: string | number | boolean = this.previousValue;
|
|
696
|
+
let currentValue: string | number | boolean = this.value;
|
|
697
|
+
this.setProperties({ value: value });
|
|
698
|
+
if (isNullOrUndefined(this.value)) {
|
|
699
|
+
Input.setValue('', this.inputElement, this.floatLabelType, this.showClearButton);
|
|
700
|
+
}
|
|
701
|
+
if (this.autofill && previousValue === this.value && currentValue !== this.value) {
|
|
702
|
+
this.onChangeEvent(null);
|
|
703
|
+
}
|
|
704
|
+
} else if (this.inputElement.value.trim() !== '') {
|
|
705
|
+
let previousValue: string | number | boolean = this.value;
|
|
706
|
+
if (isNullOrUndefined(value)) {
|
|
707
|
+
let value: string | Object = this.inputElement.value === '' ? null : this.inputElement.value;
|
|
708
|
+
let eventArgs: { [key: string]: Object | string | number };
|
|
709
|
+
eventArgs = <{ [key: string]: Object | string | number }>{ text: value, item: {} };
|
|
710
|
+
if (!this.initial) {
|
|
711
|
+
this.trigger('customValueSpecifier', eventArgs, (eventArgs: { [key: string]: Object | string | number }) => {
|
|
712
|
+
this.updateCustomValueCallback(value, eventArgs, previousValue, e);
|
|
713
|
+
});
|
|
714
|
+
} else {
|
|
715
|
+
this.updateCustomValueCallback(value, eventArgs, previousValue);
|
|
716
|
+
}
|
|
717
|
+
} else {
|
|
718
|
+
this.isSelectCustom = false;
|
|
719
|
+
this.setProperties({ value: value });
|
|
720
|
+
if (previousValue !== this.value) {
|
|
721
|
+
this.onChangeEvent(e);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
} else if (this.allowCustom) {
|
|
725
|
+
this.isSelectCustom = true;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
private updateCustomValueCallback(
|
|
729
|
+
value: string | Object,
|
|
730
|
+
eventArgs: { [key: string]: Object | string | number },
|
|
731
|
+
previousValue: string | number | boolean,
|
|
732
|
+
e?: MouseEvent| KeyboardEventArgs): void {
|
|
733
|
+
let fields: FieldSettingsModel = this.fields;
|
|
734
|
+
let item: { [key: string]: string | Object } = <{ [key: string]: string | Object }>eventArgs.item;
|
|
735
|
+
let dataItem: { [key: string]: string | Object } = {};
|
|
736
|
+
if (item && getValue(fields.text, item) && getValue(fields.value, item)) {
|
|
737
|
+
dataItem = item;
|
|
738
|
+
} else {
|
|
739
|
+
setValue(fields.text, value, dataItem);
|
|
740
|
+
setValue(fields.value, value, dataItem);
|
|
741
|
+
}
|
|
742
|
+
this.itemData = <{ [key: string]: Object }>dataItem;
|
|
743
|
+
let changeData: { [key: string]: Object } = {
|
|
744
|
+
text: getValue(fields.text, this.itemData),
|
|
745
|
+
value: getValue(fields.value, this.itemData),
|
|
746
|
+
index: null
|
|
747
|
+
};
|
|
748
|
+
this.setProperties(changeData, true);
|
|
749
|
+
this.setSelection(null, null);
|
|
750
|
+
this.isSelectCustom = true;
|
|
751
|
+
if (previousValue !== this.value) {
|
|
752
|
+
this.onChangeEvent(e);
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* Dynamically change the value of properties.
|
|
757
|
+
* @private
|
|
758
|
+
*/
|
|
759
|
+
public onPropertyChanged(newProp: ComboBoxModel, oldProp: ComboBoxModel): void {
|
|
760
|
+
if (this.getModuleName() === 'combobox') {
|
|
761
|
+
this.setUpdateInitial(['fields', 'query', 'dataSource'], newProp as { [key: string]: string; });
|
|
762
|
+
}
|
|
763
|
+
for (let prop of Object.keys(newProp)) {
|
|
764
|
+
switch (prop) {
|
|
765
|
+
case 'readonly':
|
|
766
|
+
Input.setReadonly(this.readonly, this.inputElement as HTMLInputElement);
|
|
767
|
+
if (this.readonly) {
|
|
768
|
+
EventHandler.remove(this.inputElement, 'input', this.onInput);
|
|
769
|
+
EventHandler.remove(this.inputElement, 'keyup', this.onFilterUp);
|
|
770
|
+
EventHandler.remove(this.inputElement, 'keydown', this.onFilterDown);
|
|
771
|
+
} else {
|
|
772
|
+
EventHandler.add(this.inputElement, 'input', this.onInput, this);
|
|
773
|
+
EventHandler.add(this.inputElement, 'keyup', this.onFilterUp, this);
|
|
774
|
+
EventHandler.add(this.inputElement, 'keydown', this.onFilterDown, this);
|
|
775
|
+
}
|
|
776
|
+
break;
|
|
777
|
+
case 'allowFiltering':
|
|
778
|
+
this.setSearchBox();
|
|
779
|
+
if (this.isFiltering() && this.getModuleName() === 'combobox' && isNullOrUndefined(this.list)) {
|
|
780
|
+
super.renderList();
|
|
781
|
+
}
|
|
782
|
+
break;
|
|
783
|
+
case 'allowCustom':
|
|
784
|
+
break;
|
|
785
|
+
default:
|
|
786
|
+
let comboProps: { [key: string]: Object };
|
|
787
|
+
comboProps = this.getPropObject(prop, <{ [key: string]: string; }>newProp, <{ [key: string]: string; }>oldProp);
|
|
788
|
+
super.onPropertyChanged(comboProps.newProperty, comboProps.oldProperty);
|
|
789
|
+
break;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
/**
|
|
794
|
+
* To initialize the control rendering.
|
|
795
|
+
* @private
|
|
796
|
+
*/
|
|
797
|
+
public render(): void {
|
|
798
|
+
super.render();
|
|
799
|
+
this.setSearchBox();
|
|
800
|
+
if (this.isFiltering() && this.getModuleName() === 'combobox' && isNullOrUndefined(this.list)) {
|
|
801
|
+
super.renderList();
|
|
802
|
+
}
|
|
803
|
+
this.renderComplete();
|
|
804
|
+
};
|
|
805
|
+
/**
|
|
806
|
+
* Return the module name of this component.
|
|
807
|
+
* @private
|
|
808
|
+
*/
|
|
809
|
+
public getModuleName(): string {
|
|
810
|
+
return 'combobox';
|
|
811
|
+
}
|
|
812
|
+
/**
|
|
813
|
+
* Adds a new item to the combobox popup list. By default, new item appends to the list as the last item,
|
|
814
|
+
* but you can insert based on the index parameter.
|
|
815
|
+
* @param { Object[] } items - Specifies an array of JSON data or a JSON data.
|
|
816
|
+
* @param { number } itemIndex - Specifies the index to place the newly added item in the popup list.
|
|
817
|
+
* @return {void}.
|
|
818
|
+
* @deprecated
|
|
819
|
+
*/
|
|
820
|
+
public addItem(
|
|
821
|
+
items: { [key: string]: Object }[] | { [key: string]: Object } | string | boolean | number | string[] | boolean[] | number[],
|
|
822
|
+
itemIndex?: number): void {
|
|
823
|
+
super.addItem(items, itemIndex);
|
|
824
|
+
}
|
|
825
|
+
/**
|
|
826
|
+
* To filter the data from given data source by using query
|
|
827
|
+
* @param {Object[] | DataManager } dataSource - Set the data source to filter.
|
|
828
|
+
* @param {Query} query - Specify the query to filter the data.
|
|
829
|
+
* @param {FieldSettingsModel} fields - Specify the fields to map the column in the data table.
|
|
830
|
+
* @return {void}.
|
|
831
|
+
* @deprecated
|
|
832
|
+
*/
|
|
833
|
+
public filter(
|
|
834
|
+
dataSource: { [key: string]: Object }[] | DataManager | string[] | number[] | boolean[],
|
|
835
|
+
query?: Query, fields?: FieldSettingsModel): void {
|
|
836
|
+
super.filter(dataSource, query, fields);
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* Opens the popup that displays the list of items.
|
|
840
|
+
* @returns void.
|
|
841
|
+
* @deprecated
|
|
842
|
+
*/
|
|
843
|
+
public showPopup(): void {
|
|
844
|
+
super.showPopup();
|
|
845
|
+
}
|
|
846
|
+
/**
|
|
847
|
+
* Hides the popup if it is in open state.
|
|
848
|
+
* @returns void.
|
|
849
|
+
* @deprecated
|
|
850
|
+
*/
|
|
851
|
+
public hidePopup(e?: MouseEvent | KeyboardEventArgs): void {
|
|
852
|
+
let inputValue: string | Object = this.inputElement.value === '' ? null : this.inputElement.value;
|
|
853
|
+
if (!isNullOrUndefined(this.listData)) {
|
|
854
|
+
let isEscape: boolean = this.isEscapeKey;
|
|
855
|
+
if (this.isEscapeKey) {
|
|
856
|
+
Input.setValue(this.typedString, this.inputElement, this.floatLabelType, this.showClearButton);
|
|
857
|
+
this.isEscapeKey = false;
|
|
858
|
+
}
|
|
859
|
+
if (this.autofill) {
|
|
860
|
+
this.removeFillSelection();
|
|
861
|
+
}
|
|
862
|
+
let dataItem: { [key: string]: string } = this.isSelectCustom ? { text: '' } : this.getItemData();
|
|
863
|
+
let selected: HTMLElement = <HTMLElement>this.list.querySelector('.' + dropDownListClasses.selected);
|
|
864
|
+
if (dataItem.text === this.inputElement.value && !isNullOrUndefined(selected)) {
|
|
865
|
+
if (this.isSelected) {
|
|
866
|
+
this.onChangeEvent(e);
|
|
867
|
+
this.isSelectCustom = false;
|
|
868
|
+
}
|
|
869
|
+
super.hidePopup(e);
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
if (this.getModuleName() === 'combobox' && this.inputElement.value.trim() !== '') {
|
|
873
|
+
let searchItem: { [key: string]: number | Element } = Search(this.inputElement.value, this.liCollections, 'Equal', true);
|
|
874
|
+
this.selectedLI = searchItem.item as HTMLElement;
|
|
875
|
+
if (isNullOrUndefined(searchItem.index)) {
|
|
876
|
+
searchItem.index = Search(this.inputElement.value, this.liCollections, 'StartsWith', true).index as number;
|
|
877
|
+
}
|
|
878
|
+
this.activeIndex = searchItem.index as number;
|
|
879
|
+
if (!isNullOrUndefined(this.selectedLI)) {
|
|
880
|
+
this.updateSelectedItem(this.selectedLI, null, true);
|
|
881
|
+
} else if (isEscape) {
|
|
882
|
+
this.isSelectCustom = true;
|
|
883
|
+
this.removeSelection();
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
if (!this.isEscapeKey && this.isTyped && !this.isInteracted) {
|
|
887
|
+
this.customValue(e);
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
if (isNullOrUndefined(this.listData) && this.allowCustom && !isNullOrUndefined(inputValue) && inputValue !== this.value) {
|
|
891
|
+
this.customValue();
|
|
892
|
+
}
|
|
893
|
+
super.hidePopup(e);
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* Sets the focus to the component for interaction.
|
|
897
|
+
* @returns void.
|
|
898
|
+
*/
|
|
899
|
+
public focusIn(): void {
|
|
900
|
+
if (!this.enabled) {
|
|
901
|
+
return;
|
|
902
|
+
}
|
|
903
|
+
if (Browser.isDevice && !this.allowFiltering) {
|
|
904
|
+
this.preventFocus = true;
|
|
905
|
+
}
|
|
906
|
+
super.focusIn();
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* Allows you to clear the selected values from the component.
|
|
910
|
+
* @returns void.
|
|
911
|
+
* @deprecated
|
|
912
|
+
*/
|
|
913
|
+
public clear(): void {
|
|
914
|
+
this.value = null;
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* Moves the focus from the component if the component is already focused.
|
|
918
|
+
* @returns void.
|
|
919
|
+
* @deprecated
|
|
920
|
+
*/
|
|
921
|
+
public focusOut(e?: MouseEvent | KeyboardEventArgs): void {
|
|
922
|
+
super.focusOut(e);
|
|
923
|
+
}
|
|
924
|
+
/**
|
|
925
|
+
* Gets all the list items bound on this component.
|
|
926
|
+
* @returns Element[].
|
|
927
|
+
* @deprecated
|
|
928
|
+
*/
|
|
929
|
+
public getItems(): Element[] {
|
|
930
|
+
return super.getItems();
|
|
931
|
+
}
|
|
932
|
+
/**
|
|
933
|
+
* Gets the data Object that matches the given value.
|
|
934
|
+
* @param { string | number } value - Specifies the value of the list item.
|
|
935
|
+
* @returns Object.
|
|
936
|
+
* @blazorType object
|
|
937
|
+
* @deprecated
|
|
938
|
+
*/
|
|
939
|
+
public getDataByValue(value: string | number | boolean)
|
|
940
|
+
: { [key: string]: Object } | string | number | boolean {
|
|
941
|
+
return super.getDataByValue(value);
|
|
942
|
+
}
|
|
943
|
+
protected renderHightSearch(): void {
|
|
944
|
+
// update high light search
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
export interface CustomValueSpecifierEventArgs {
|
|
948
|
+
/**
|
|
949
|
+
* Gets the typed custom text to make a own text format and assign it to `item` argument.
|
|
950
|
+
*/
|
|
951
|
+
text: string;
|
|
952
|
+
/**
|
|
953
|
+
* Sets the text custom format data for set a `value` and `text`.
|
|
954
|
+
* @blazorType object
|
|
955
|
+
*/
|
|
956
|
+
item: { [key: string]: string | Object };
|
|
957
|
+
}
|