@syncfusion/ej2-multicolumn-combobox 28.1.33 → 28.1.39

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.
@@ -1,4 +1,4 @@
1
- import { Property, ChildProperty, Event, getUniqueID, isNullOrUndefined, addClass, removeClass, formatUnit, attributes, prepend, Browser, append, L10n, select, compile, EventHandler, KeyboardEvents, closest, Animation, detach, Complex, Collection, NotifyPropertyChanges, Component } from '@syncfusion/ej2-base';
1
+ import { Property, ChildProperty, Event, getUniqueID, isNullOrUndefined, addClass, removeClass, formatUnit, getValue, attributes, prepend, Browser, append, L10n, select, compile, EventHandler, KeyboardEvents, closest, Animation, detach, Complex, Collection, NotifyPropertyChanges, Component } from '@syncfusion/ej2-base';
2
2
  import { Input } from '@syncfusion/ej2-inputs';
3
3
  import { DataManager, Query } from '@syncfusion/ej2-data';
4
4
  import { Popup } from '@syncfusion/ej2-popups';
@@ -413,8 +413,23 @@ var MultiColumnComboBox = /** @__PURE__ @class */ (function (_super) {
413
413
  };
414
414
  /* eslint-disable @typescript-eslint/no-explicit-any */
415
415
  MultiColumnComboBox.prototype.isRowMatching = function (data, selectedValue, selectedText) {
416
- var values = Object.values(data).map(String);
417
- return values.includes(selectedValue) && values.includes(selectedText);
416
+ var flattenData = function (data) {
417
+ var result = [];
418
+ if (data && typeof data === 'object') {
419
+ if (Array.isArray(data)) {
420
+ data.forEach(function (item) { return result.push.apply(result, flattenData(item)); });
421
+ }
422
+ else {
423
+ Object.keys(data).forEach(function (key) { return result.push.apply(result, flattenData(data["" + key])); });
424
+ }
425
+ }
426
+ else if (data != null) {
427
+ result.push(String(data));
428
+ }
429
+ return result;
430
+ };
431
+ var flattenedValues = flattenData(data);
432
+ return (flattenedValues.indexOf(selectedValue) !== -1 && flattenedValues.indexOf(selectedText) !== -1);
418
433
  };
419
434
  MultiColumnComboBox.prototype.updateRowSelection = function (args) {
420
435
  var _this = this;
@@ -652,6 +667,10 @@ var MultiColumnComboBox = /** @__PURE__ @class */ (function (_super) {
652
667
  this.inputEle.setAttribute('aria-disabled', value);
653
668
  this.inputWrapper.setAttribute('aria-disabled', value);
654
669
  };
670
+ MultiColumnComboBox.prototype.updateFieldValue = function (fieldValue, dataObj) {
671
+ var fieldVal = getValue(fieldValue, dataObj).toString();
672
+ return fieldVal;
673
+ };
655
674
  MultiColumnComboBox.prototype.initValue = function (isRerender, isValue, isInitial) {
656
675
  var _this = this;
657
676
  var prevItemData = this.gridObj.getSelectedRecords()[0];
@@ -677,8 +696,9 @@ var MultiColumnComboBox = /** @__PURE__ @class */ (function (_super) {
677
696
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
678
697
  var dataLists = e.result;
679
698
  var filteredData = dataLists.filter(function (item) {
680
- return item[isRerender ? (isValue ? _this.fields.value : _this.fields.text) :
681
- !isNullOrUndefined(_this.value) ? _this.fields.value : _this.fields.text].toString() === value_1;
699
+ var fieldVal = _this.updateFieldValue(isRerender ? (isValue ? _this.fields.value : _this.fields.text) :
700
+ !isNullOrUndefined(_this.value) ? _this.fields.value : _this.fields.text, item);
701
+ return fieldVal === value_1;
682
702
  });
683
703
  if (filteredData.length > 0) {
684
704
  item = filteredData[0];
@@ -690,8 +710,9 @@ var MultiColumnComboBox = /** @__PURE__ @class */ (function (_super) {
690
710
  }
691
711
  else if (!isNullOrUndefined(this.dataSource) && this.dataSource instanceof Array) {
692
712
  item = this.dataSource.filter(function (data) {
693
- return data[isRerender ? (isValue ? _this.fields.value : _this.fields.text) :
694
- !isNullOrUndefined(_this.value) ? _this.fields.value : _this.fields.text].toString() === value_1;
713
+ var fieldVal = _this.updateFieldValue(isRerender ? (isValue ? _this.fields.value : _this.fields.text) :
714
+ !isNullOrUndefined(_this.value) ? _this.fields.value : _this.fields.text, data);
715
+ return fieldVal === value_1;
695
716
  })[0];
696
717
  updateValues(this.dataSource);
697
718
  }
@@ -738,8 +759,9 @@ var MultiColumnComboBox = /** @__PURE__ @class */ (function (_super) {
738
759
  }
739
760
  };
740
761
  MultiColumnComboBox.prototype.updateChangeEvent = function (item, prevItemData, prevItemEle, currentValue, currentText, currentIndex, isRerender, isInitial) {
762
+ var fieldValue = item ? this.updateFieldValue(this.fields.value, item) : null;
741
763
  var ChangeEventArgs = {
742
- value: item ? item[this.fields.value].toString() : null,
764
+ value: item ? fieldValue : null,
743
765
  itemData: { text: currentText, value: currentValue },
744
766
  item: this.getDataByValue(this.value),
745
767
  previousItemData: prevItemData,
@@ -752,10 +774,12 @@ var MultiColumnComboBox = /** @__PURE__ @class */ (function (_super) {
752
774
  };
753
775
  MultiColumnComboBox.prototype.updateCurrentValues = function (item, dataList) {
754
776
  if (!isNullOrUndefined(item)) {
755
- Input.setValue(item[this.fields.text].toString(), this.inputEle, this.floatLabelType, this.showClearButton);
777
+ var fieldText = this.updateFieldValue(this.fields.text, item);
778
+ var fieldValue = this.updateFieldValue(this.fields.value, item);
779
+ Input.setValue(fieldText, this.inputEle, this.floatLabelType, this.showClearButton);
756
780
  return {
757
- currentValue: item[this.fields.value].toString(),
758
- currentText: item[this.fields.text].toString(),
781
+ currentValue: fieldValue,
782
+ currentText: fieldText,
759
783
  currentIndex: dataList.indexOf(item)
760
784
  };
761
785
  }
@@ -933,16 +957,16 @@ var MultiColumnComboBox = /** @__PURE__ @class */ (function (_super) {
933
957
  cancel: false
934
958
  };
935
959
  var selectedRecords = this.gridObj.getSelectedRecords()[0];
936
- var fieldText = selectedRecords ? selectedRecords[this.fields.text].toString() : '';
937
- var fieldValue = selectedRecords ? selectedRecords[this.fields.value].toString() : '';
960
+ var dataText = selectedRecords ? this.updateFieldValue(this.fields.text, selectedRecords) : '';
961
+ var dataValue = selectedRecords ? this.updateFieldValue(this.fields.value, selectedRecords) : '';
938
962
  var ChangeEventArgs = {
939
963
  isInteracted: e ? true : false,
940
964
  item: selectedRecords,
941
965
  itemElement: row,
942
- itemData: { text: fieldText, value: fieldValue },
966
+ itemData: { text: selectedRecords ? dataText : '', value: selectedRecords ? dataValue : '' },
943
967
  event: e,
944
968
  cancel: false,
945
- value: fieldValue,
969
+ value: selectedRecords ? dataValue : '',
946
970
  previousItemData: { text: this.text, value: this.value },
947
971
  previousItemElement: this.previousItemElement
948
972
  };
@@ -952,9 +976,9 @@ var MultiColumnComboBox = /** @__PURE__ @class */ (function (_super) {
952
976
  var event_1 = e;
953
977
  var isUpdateVal = event_1.key === 'Enter' || event_1.key === 'Tab' || event_1.shiftKey && event_1.key === 'Tab' || event_1.altKey && event_1.key === 'ArrowUp';
954
978
  if (!isKeyNav || (isKeyNav && isUpdateVal)) {
955
- _this.updateValues(selectedRecord[_this.fields.value], selectedRecord[_this.fields.text], _this.gridObj.selectedRowIndex, ChangeEventArgs);
979
+ _this.updateValues(selectedRecords ? dataValue : '', selectedRecords ? dataText : '', _this.gridObj.selectedRowIndex, ChangeEventArgs);
956
980
  }
957
- Input.setValue(selectedRecord[_this.fields.text], _this.inputEle, _this.floatLabelType, _this.showClearButton);
981
+ Input.setValue(selectedRecords ? dataText : '', _this.inputEle, _this.floatLabelType, _this.showClearButton);
958
982
  if (!isKeyNav || (isKeyNav && isUpdateVal)) {
959
983
  _this.hidePopup(e);
960
984
  }
@@ -1037,10 +1061,12 @@ var MultiColumnComboBox = /** @__PURE__ @class */ (function (_super) {
1037
1061
  MultiColumnComboBox.prototype.filterDatas = function (dataSource, inputValue) {
1038
1062
  var _this = this;
1039
1063
  var data = dataSource.filter(function (item) {
1040
- return item[_this.fields.text].toString().toLowerCase().startsWith(inputValue.toLowerCase());
1064
+ var fieldText = _this.updateFieldValue(_this.fields.text, item);
1065
+ return fieldText.toLowerCase().startsWith(inputValue.toLowerCase());
1041
1066
  });
1042
1067
  var exactData = dataSource.filter(function (item) {
1043
- return item[_this.fields.text].toString() === inputValue;
1068
+ var fieldText = _this.updateFieldValue(_this.fields.text, item);
1069
+ return fieldText === inputValue;
1044
1070
  });
1045
1071
  return { data: data, exactData: exactData };
1046
1072
  };
@@ -1100,7 +1126,8 @@ var MultiColumnComboBox = /** @__PURE__ @class */ (function (_super) {
1100
1126
  });
1101
1127
  };
1102
1128
  MultiColumnComboBox.prototype.filterData = function (item, filterType, inputValue, fields) {
1103
- var itemValue = item[fields ? fields.text : this.fields.text].toString().toLowerCase();
1129
+ var dataValue = this.updateFieldValue(fields ? fields.text : this.fields.text, item);
1130
+ var itemValue = dataValue.toLowerCase();
1104
1131
  switch (filterType) {
1105
1132
  case 'startswith':
1106
1133
  return itemValue.startsWith(inputValue);
@@ -1222,13 +1249,13 @@ var MultiColumnComboBox = /** @__PURE__ @class */ (function (_super) {
1222
1249
  if (!isNullOrUndefined(this.text)) {
1223
1250
  this.updateInputValue(this.text);
1224
1251
  }
1225
- this.updateValuesOnInput(e);
1252
+ var isClearVal = this.inputEle.value === '' ? true : false;
1253
+ this.updateValuesOnInput(e, null, isClearVal);
1226
1254
  }
1227
1255
  }
1228
1256
  };
1229
1257
  MultiColumnComboBox.prototype.updateValuesOnInput = function (mouseEvent, keyEvent, isClearValues, isKeyDown) {
1230
1258
  var _this = this;
1231
- if (isClearValues === void 0) { isClearValues = false; }
1232
1259
  if (isKeyDown === void 0) { isKeyDown = false; }
1233
1260
  var e = mouseEvent ? mouseEvent : keyEvent;
1234
1261
  var val = isKeyDown ? this.matchedContent : this.exactMatchedContent;
@@ -1237,19 +1264,21 @@ var MultiColumnComboBox = /** @__PURE__ @class */ (function (_super) {
1237
1264
  }
1238
1265
  this.hidePopup(e);
1239
1266
  if (this.matchedRowEle && !isClearValues && val) {
1240
- var prevOnChange = this.isProtectedOnChange;
1241
- this.isProtectedOnChange = true;
1242
1267
  setTimeout(function () {
1243
- _this.inputEle.value = _this.matchedContent[_this.fields.text].toString();
1244
- _this.value = _this.matchedContent[_this.fields.value].toString();
1268
+ var prevOnChange = _this.isProtectedOnChange;
1269
+ _this.isProtectedOnChange = true;
1270
+ var fieldText = _this.updateFieldValue(_this.fields.text, _this.matchedContent);
1271
+ var fieldValue = _this.updateFieldValue(_this.fields.value, _this.matchedContent);
1272
+ _this.inputEle.value = fieldText;
1273
+ _this.value = fieldValue;
1245
1274
  var selectIndex = _this.findIndex(_this.gridObj.currentViewData, _this.matchedContent);
1246
1275
  _this.index = selectIndex;
1247
- _this.text = _this.matchedContent[_this.fields.text].toString();
1276
+ _this.text = fieldText;
1248
1277
  _this.gridObj.selectRow(selectIndex);
1249
1278
  _this.selectedGridRow(_this.gridObj.getRowByIndex(selectIndex), e);
1250
1279
  _this.previousItemElement = _this.gridObj.getSelectedRows()[0];
1280
+ _this.isProtectedOnChange = prevOnChange;
1251
1281
  }, 100);
1252
- this.isProtectedOnChange = prevOnChange;
1253
1282
  }
1254
1283
  else {
1255
1284
  if (this.isDataFiltered) {
@@ -1600,7 +1629,8 @@ var MultiColumnComboBox = /** @__PURE__ @class */ (function (_super) {
1600
1629
  var _this = this;
1601
1630
  if (!isNullOrUndefined(this.dataSource) && this.dataSource instanceof Array) {
1602
1631
  return this.dataSource.filter(function (item) {
1603
- return item[_this.fields.value].toString() === value;
1632
+ var fieldValue = _this.updateFieldValue(_this.fields.value, item);
1633
+ return fieldValue === value;
1604
1634
  })[0];
1605
1635
  }
1606
1636
  else if (!isNullOrUndefined(this.dataSource) && this.dataSource instanceof DataManager) {
@@ -1608,7 +1638,8 @@ var MultiColumnComboBox = /** @__PURE__ @class */ (function (_super) {
1608
1638
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1609
1639
  var dataLists = e.result;
1610
1640
  return dataLists.filter(function (item) {
1611
- return item[_this.fields.value].toString() === value;
1641
+ var fieldValue = _this.updateFieldValue(_this.fields.value, item);
1642
+ return fieldValue === value;
1612
1643
  })[0];
1613
1644
  });
1614
1645
  }