@syncfusion/ej2-dropdowns 20.3.59 → 20.3.60

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.
@@ -6,9 +6,6 @@ import { Input, TextBox } from '@syncfusion/ej2-inputs';
6
6
  import { Button, createCheckBox } from '@syncfusion/ej2-buttons';
7
7
  import { TreeView } from '@syncfusion/ej2-navigations';
8
8
 
9
- /**
10
- * IncrementalSearch module file
11
- */
12
9
  let queryString = '';
13
10
  let prevString = '';
14
11
  let matches$1 = [];
@@ -81,7 +78,7 @@ function incrementalSearch(keyCode, items, selectedIndex, ignoreCase, elementId)
81
78
  * @param {boolean} ignoreCase - Specifies the case sensitive option for search operation.
82
79
  * @returns {Element | number} Returns the search matched items.
83
80
  */
84
- function Search(inputVal, items, searchType, ignoreCase) {
81
+ function Search(inputVal, items, searchType, ignoreCase, dataSource, fields, type) {
85
82
  const listItems = items;
86
83
  ignoreCase = ignoreCase !== undefined && ignoreCase !== null ? ignoreCase : true;
87
84
  const itemData = { item: null, index: null };
@@ -91,7 +88,20 @@ function Search(inputVal, items, searchType, ignoreCase) {
91
88
  queryStr = escapeCharRegExp(queryStr);
92
89
  for (let i = 0, itemsData = listItems; i < itemsData.length; i++) {
93
90
  const item = itemsData[i];
94
- const text = (ignoreCase ? item.textContent.toLocaleLowerCase() : item.textContent).replace(/^\s+|\s+$/g, '');
91
+ let text;
92
+ let filterValue;
93
+ if (items && dataSource) {
94
+ let checkField = item;
95
+ let fieldValue = fields.text.split('.');
96
+ dataSource.filter(function (data) {
97
+ Array.prototype.slice.call(fieldValue).forEach(function (value) {
98
+ if (type === 'object' && checkField.textContent.toString().indexOf(data[value]) !== -1 && checkField.getAttribute('data-value') === data[fields.value] || type === 'string' && checkField.textContent.toString().indexOf(data) !== -1) {
99
+ filterValue = type === 'object' ? data[value] : data;
100
+ }
101
+ });
102
+ });
103
+ }
104
+ text = dataSource && filterValue ? (ignoreCase ? filterValue.toLocaleLowerCase() : filterValue).replace(/^\s+|\s+$/g, '') : (ignoreCase ? item.textContent.toLocaleLowerCase() : item.textContent).replace(/^\s+|\s+$/g, '');
95
105
  if ((searchType === 'Equal' && text === queryStr) || (searchType === 'StartsWith' && text.substr(0, strLength) === queryStr) || (searchType === 'EndsWith' && text.substr(text.length - queryStr.length) === queryStr) || (searchType === 'Contains' && new RegExp(queryStr, "g").test(text))) {
96
106
  itemData.item = item;
97
107
  itemData.index = i;
@@ -1186,7 +1196,7 @@ let DropDownBase = class DropDownBase extends Component {
1186
1196
  * Adds a new item to the popup list. By default, new item appends to the list as the last item,
1187
1197
  * but you can insert based on the index parameter.
1188
1198
  *
1189
- * @param { Object[] } items - Specifies an array of JSON data or a JSON data.
1199
+ * @param { Object[] } items - Specifies an array of JSON data or a JSON data.
1190
1200
  * @param { number } itemIndex - Specifies the index to place the newly added item in the popup list.
1191
1201
  * @returns {void}
1192
1202
  * @deprecated
@@ -2447,10 +2457,10 @@ let DropDownList = class DropDownList extends DropDownBase {
2447
2457
  attributes(this.targetElement(), { 'aria-describedby': this.inputElement.id != '' ? this.inputElement.id : this.element.id });
2448
2458
  this.targetElement().removeAttribute('aria-live');
2449
2459
  }
2450
- if (!isNullOrUndefined(this.ulElement) && !isNullOrUndefined(this.ulElement.getElementsByClassName('e-item-focus')[0])) {
2460
+ if (this.isPopupOpen && !isNullOrUndefined(this.ulElement) && !isNullOrUndefined(this.ulElement.getElementsByClassName('e-item-focus')[0])) {
2451
2461
  attributes(this.targetElement(), { 'aria-activedescendant': this.ulElement.getElementsByClassName('e-item-focus')[0].id });
2452
2462
  }
2453
- else if (!isNullOrUndefined(this.ulElement) && !isNullOrUndefined(this.ulElement.getElementsByClassName('e-active')[0])) {
2463
+ else if (this.isPopupOpen && !isNullOrUndefined(this.ulElement) && !isNullOrUndefined(this.ulElement.getElementsByClassName('e-active')[0])) {
2454
2464
  attributes(this.targetElement(), { 'aria-activedescendant': this.ulElement.getElementsByClassName('e-active')[0].id });
2455
2465
  }
2456
2466
  }
@@ -2769,9 +2779,9 @@ let DropDownList = class DropDownList extends DropDownBase {
2769
2779
  /**
2770
2780
  * To filter the data from given data source by using query
2771
2781
  *
2772
- * @param {Object[] | DataManager } dataSource - Set the data source to filter.
2773
- * @param {Query} query - Specify the query to filter the data.
2774
- * @param {FieldSettingsModel} fields - Specify the fields to map the column in the data table.
2782
+ * @param {Object[] | DataManager } dataSource - Set the data source to filter.
2783
+ * @param {Query} query - Specify the query to filter the data.
2784
+ * @param {FieldSettingsModel} fields - Specify the fields to map the column in the data table.
2775
2785
  * @returns {void}
2776
2786
  * @deprecated
2777
2787
  */
@@ -7573,7 +7583,9 @@ let ComboBox = class ComboBox extends DropDownList {
7573
7583
  if ((Browser.isDevice && !this.isDropDownClick || !Browser.isDevice) &&
7574
7584
  !isNullOrUndefined(this.liCollections) && this.liCollections.length > 0) {
7575
7585
  const inputValue = this.inputElement.value;
7576
- const activeItem = Search(inputValue, this.liCollections, this.filterType, true);
7586
+ const dataSource = this.sortedData;
7587
+ const type = this.typeOfData(dataSource).typeof;
7588
+ const activeItem = Search(inputValue, this.liCollections, this.filterType, true, dataSource, this.fields, type);
7577
7589
  const activeElement = activeItem.item;
7578
7590
  if (!isNullOrUndefined(activeElement)) {
7579
7591
  const count = this.getIndexByValue(activeElement.getAttribute('data-value')) - 1;
@@ -7971,7 +7983,7 @@ let ComboBox = class ComboBox extends DropDownList {
7971
7983
  * Adds a new item to the combobox popup list. By default, new item appends to the list as the last item,
7972
7984
  * but you can insert based on the index parameter.
7973
7985
  *
7974
- * @param { Object[] } items - Specifies an array of JSON data or a JSON data.
7986
+ * @param { Object[] } items - Specifies an array of JSON data or a JSON data.
7975
7987
  * @param { number } itemIndex - Specifies the index to place the newly added item in the popup list.
7976
7988
  * @returns {void}
7977
7989
  * @deprecated
@@ -7982,9 +7994,9 @@ let ComboBox = class ComboBox extends DropDownList {
7982
7994
  /**
7983
7995
  * To filter the data from given data source by using query
7984
7996
  *
7985
- * @param {Object[] | DataManager } dataSource - Set the data source to filter.
7986
- * @param {Query} query - Specify the query to filter the data.
7987
- * @param {FieldSettingsModel} fields - Specify the fields to map the column in the data table.
7997
+ * @param {Object[] | DataManager } dataSource - Set the data source to filter.
7998
+ * @param {Query} query - Specify the query to filter the data.
7999
+ * @param {FieldSettingsModel} fields - Specify the fields to map the column in the data table.
7988
8000
  * @returns {void}
7989
8001
  * @deprecated
7990
8002
  */
@@ -8031,10 +8043,12 @@ let ComboBox = class ComboBox extends DropDownList {
8031
8043
  return;
8032
8044
  }
8033
8045
  if (this.getModuleName() === 'combobox' && this.inputElement.value.trim() !== '') {
8034
- const searchItem = Search(this.inputElement.value, this.liCollections, 'Equal', true);
8046
+ const dataSource = this.sortedData;
8047
+ const type = this.typeOfData(dataSource).typeof;
8048
+ const searchItem = Search(this.inputElement.value, this.liCollections, 'Equal', true, dataSource, this.fields, type);
8035
8049
  this.selectedLI = searchItem.item;
8036
8050
  if (isNullOrUndefined(searchItem.index)) {
8037
- searchItem.index = Search(this.inputElement.value, this.liCollections, 'StartsWith', true).index;
8051
+ searchItem.index = Search(this.inputElement.value, this.liCollections, 'StartsWith', true, dataSource, this.fields, type).index;
8038
8052
  }
8039
8053
  this.activeIndex = searchItem.index;
8040
8054
  if (!isNullOrUndefined(this.selectedLI)) {
@@ -8306,9 +8320,9 @@ let AutoComplete = class AutoComplete extends ComboBox {
8306
8320
  /**
8307
8321
  * To filter the data from given data source by using query
8308
8322
  *
8309
- * @param {Object[] | DataManager } dataSource - Set the data source to filter.
8310
- * @param {Query} query - Specify the query to filter the data.
8311
- * @param {FieldSettingsModel} fields - Specify the fields to map the column in the data table.
8323
+ * @param {Object[] | DataManager } dataSource - Set the data source to filter.
8324
+ * @param {Query} query - Specify the query to filter the data.
8325
+ * @param {FieldSettingsModel} fields - Specify the fields to map the column in the data table.
8312
8326
  * @returns {void}
8313
8327
  * @deprecated
8314
8328
  */
@@ -8348,7 +8362,9 @@ let AutoComplete = class AutoComplete extends ComboBox {
8348
8362
  postBackAction() {
8349
8363
  if (this.autofill && !isNullOrUndefined(this.liCollections[0]) && this.searchList) {
8350
8364
  const items = [this.liCollections[0]];
8351
- const searchItem = Search(this.inputElement.value, items, 'StartsWith', this.ignoreCase);
8365
+ const dataSource = this.listData;
8366
+ const type = this.typeOfData(dataSource).typeof;
8367
+ const searchItem = Search(this.inputElement.value, items, 'StartsWith', this.ignoreCase, dataSource, this.fields, type);
8352
8368
  this.searchList = false;
8353
8369
  if (!isNullOrUndefined(searchItem.item)) {
8354
8370
  super.setAutoFill(this.liCollections[0], true);
@@ -9367,9 +9383,9 @@ let MultiSelect = class MultiSelect extends DropDownBase {
9367
9383
  /**
9368
9384
  * To filter the multiselect data from given data source by using query
9369
9385
  *
9370
- * @param {Object[] | DataManager } dataSource - Set the data source to filter.
9371
- * @param {Query} query - Specify the query to filter the data.
9372
- * @param {FieldSettingsModel} fields - Specify the fields to map the column in the data table.
9386
+ * @param {Object[] | DataManager } dataSource - Set the data source to filter.
9387
+ * @param {Query} query - Specify the query to filter the data.
9388
+ * @param {FieldSettingsModel} fields - Specify the fields to map the column in the data table.
9373
9389
  * @returns {void}
9374
9390
  */
9375
9391
  filter(dataSource, query, fields) {
@@ -12364,7 +12380,7 @@ let MultiSelect = class MultiSelect extends DropDownBase {
12364
12380
  * Adds a new item to the multiselect popup list. By default, new item appends to the list as the last item,
12365
12381
  * but you can insert based on the index parameter.
12366
12382
  *
12367
- * @param { Object[] } items - Specifies an array of JSON data or a JSON data.
12383
+ * @param { Object[] } items - Specifies an array of JSON data or a JSON data.
12368
12384
  * @param { number } itemIndex - Specifies the index to place the newly added item in the popup list.
12369
12385
  * @returns {void}
12370
12386
  */