@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 { ChildProperty, Property, Event, Component, getUniqueID, isNullOrUndefined, addClass, removeClass, formatUnit, attributes, prepend, Browser, append, L10n, select, compile, EventHandler, KeyboardEvents, closest, Animation, detach, Complex, Collection, NotifyPropertyChanges } from '@syncfusion/ej2-base';
1
+ import { ChildProperty, Property, Event, Component, getUniqueID, isNullOrUndefined, addClass, removeClass, formatUnit, getValue, attributes, prepend, Browser, append, L10n, select, compile, EventHandler, KeyboardEvents, closest, Animation, detach, Complex, Collection, NotifyPropertyChanges } 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';
@@ -352,8 +352,23 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
352
352
  }
353
353
  /* eslint-disable @typescript-eslint/no-explicit-any */
354
354
  isRowMatching(data, selectedValue, selectedText) {
355
- const values = Object.values(data).map(String);
356
- return values.includes(selectedValue) && values.includes(selectedText);
355
+ const flattenData = (data) => {
356
+ const result = [];
357
+ if (data && typeof data === 'object') {
358
+ if (Array.isArray(data)) {
359
+ data.forEach((item) => result.push(...flattenData(item)));
360
+ }
361
+ else {
362
+ Object.keys(data).forEach((key) => result.push(...flattenData(data[`${key}`])));
363
+ }
364
+ }
365
+ else if (data != null) {
366
+ result.push(String(data));
367
+ }
368
+ return result;
369
+ };
370
+ const flattenedValues = flattenData(data);
371
+ return (flattenedValues.indexOf(selectedValue) !== -1 && flattenedValues.indexOf(selectedText) !== -1);
357
372
  }
358
373
  updateRowSelection(args) {
359
374
  if (args) {
@@ -585,6 +600,10 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
585
600
  this.inputEle.setAttribute('aria-disabled', value);
586
601
  this.inputWrapper.setAttribute('aria-disabled', value);
587
602
  }
603
+ updateFieldValue(fieldValue, dataObj) {
604
+ const fieldVal = getValue(fieldValue, dataObj).toString();
605
+ return fieldVal;
606
+ }
588
607
  initValue(isRerender, isValue, isInitial) {
589
608
  const prevItemData = this.gridObj.getSelectedRecords()[0];
590
609
  const prevItemEle = this.gridObj.getSelectedRows()[0];
@@ -609,8 +628,9 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
609
628
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
610
629
  const dataLists = e.result;
611
630
  const filteredData = dataLists.filter((item) => {
612
- return item[isRerender ? (isValue ? this.fields.value : this.fields.text) :
613
- !isNullOrUndefined(this.value) ? this.fields.value : this.fields.text].toString() === value;
631
+ const fieldVal = this.updateFieldValue(isRerender ? (isValue ? this.fields.value : this.fields.text) :
632
+ !isNullOrUndefined(this.value) ? this.fields.value : this.fields.text, item);
633
+ return fieldVal === value;
614
634
  });
615
635
  if (filteredData.length > 0) {
616
636
  item = filteredData[0];
@@ -622,8 +642,9 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
622
642
  }
623
643
  else if (!isNullOrUndefined(this.dataSource) && this.dataSource instanceof Array) {
624
644
  item = this.dataSource.filter((data) => {
625
- return data[isRerender ? (isValue ? this.fields.value : this.fields.text) :
626
- !isNullOrUndefined(this.value) ? this.fields.value : this.fields.text].toString() === value;
645
+ const fieldVal = this.updateFieldValue(isRerender ? (isValue ? this.fields.value : this.fields.text) :
646
+ !isNullOrUndefined(this.value) ? this.fields.value : this.fields.text, data);
647
+ return fieldVal === value;
627
648
  })[0];
628
649
  updateValues(this.dataSource);
629
650
  }
@@ -670,8 +691,9 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
670
691
  }
671
692
  }
672
693
  updateChangeEvent(item, prevItemData, prevItemEle, currentValue, currentText, currentIndex, isRerender, isInitial) {
694
+ const fieldValue = item ? this.updateFieldValue(this.fields.value, item) : null;
673
695
  const ChangeEventArgs = {
674
- value: item ? item[this.fields.value].toString() : null,
696
+ value: item ? fieldValue : null,
675
697
  itemData: { text: currentText, value: currentValue },
676
698
  item: this.getDataByValue(this.value),
677
699
  previousItemData: prevItemData,
@@ -684,10 +706,12 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
684
706
  }
685
707
  updateCurrentValues(item, dataList) {
686
708
  if (!isNullOrUndefined(item)) {
687
- Input.setValue(item[this.fields.text].toString(), this.inputEle, this.floatLabelType, this.showClearButton);
709
+ const fieldText = this.updateFieldValue(this.fields.text, item);
710
+ const fieldValue = this.updateFieldValue(this.fields.value, item);
711
+ Input.setValue(fieldText, this.inputEle, this.floatLabelType, this.showClearButton);
688
712
  return {
689
- currentValue: item[this.fields.value].toString(),
690
- currentText: item[this.fields.text].toString(),
713
+ currentValue: fieldValue,
714
+ currentText: fieldText,
691
715
  currentIndex: dataList.indexOf(item)
692
716
  };
693
717
  }
@@ -863,16 +887,16 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
863
887
  cancel: false
864
888
  };
865
889
  const selectedRecords = this.gridObj.getSelectedRecords()[0];
866
- const fieldText = selectedRecords ? selectedRecords[this.fields.text].toString() : '';
867
- const fieldValue = selectedRecords ? selectedRecords[this.fields.value].toString() : '';
890
+ const dataText = selectedRecords ? this.updateFieldValue(this.fields.text, selectedRecords) : '';
891
+ const dataValue = selectedRecords ? this.updateFieldValue(this.fields.value, selectedRecords) : '';
868
892
  const ChangeEventArgs = {
869
893
  isInteracted: e ? true : false,
870
894
  item: selectedRecords,
871
895
  itemElement: row,
872
- itemData: { text: fieldText, value: fieldValue },
896
+ itemData: { text: selectedRecords ? dataText : '', value: selectedRecords ? dataValue : '' },
873
897
  event: e,
874
898
  cancel: false,
875
- value: fieldValue,
899
+ value: selectedRecords ? dataValue : '',
876
900
  previousItemData: { text: this.text, value: this.value },
877
901
  previousItemElement: this.previousItemElement
878
902
  };
@@ -882,9 +906,9 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
882
906
  const event = e;
883
907
  const isUpdateVal = event.key === 'Enter' || event.key === 'Tab' || event.shiftKey && event.key === 'Tab' || event.altKey && event.key === 'ArrowUp';
884
908
  if (!isKeyNav || (isKeyNav && isUpdateVal)) {
885
- this.updateValues(selectedRecord[this.fields.value], selectedRecord[this.fields.text], this.gridObj.selectedRowIndex, ChangeEventArgs);
909
+ this.updateValues(selectedRecords ? dataValue : '', selectedRecords ? dataText : '', this.gridObj.selectedRowIndex, ChangeEventArgs);
886
910
  }
887
- Input.setValue(selectedRecord[this.fields.text], this.inputEle, this.floatLabelType, this.showClearButton);
911
+ Input.setValue(selectedRecords ? dataText : '', this.inputEle, this.floatLabelType, this.showClearButton);
888
912
  if (!isKeyNav || (isKeyNav && isUpdateVal)) {
889
913
  this.hidePopup(e);
890
914
  }
@@ -956,10 +980,12 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
956
980
  }
957
981
  filterDatas(dataSource, inputValue) {
958
982
  const data = dataSource.filter((item) => {
959
- return item[this.fields.text].toString().toLowerCase().startsWith(inputValue.toLowerCase());
983
+ const fieldText = this.updateFieldValue(this.fields.text, item);
984
+ return fieldText.toLowerCase().startsWith(inputValue.toLowerCase());
960
985
  });
961
986
  const exactData = dataSource.filter((item) => {
962
- return item[this.fields.text].toString() === inputValue;
987
+ const fieldText = this.updateFieldValue(this.fields.text, item);
988
+ return fieldText === inputValue;
963
989
  });
964
990
  return { data, exactData };
965
991
  }
@@ -1015,7 +1041,8 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
1015
1041
  });
1016
1042
  }
1017
1043
  filterData(item, filterType, inputValue, fields) {
1018
- const itemValue = item[fields ? fields.text : this.fields.text].toString().toLowerCase();
1044
+ const dataValue = this.updateFieldValue(fields ? fields.text : this.fields.text, item);
1045
+ const itemValue = dataValue.toLowerCase();
1019
1046
  switch (filterType) {
1020
1047
  case 'startswith':
1021
1048
  return itemValue.startsWith(inputValue);
@@ -1137,11 +1164,12 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
1137
1164
  if (!isNullOrUndefined(this.text)) {
1138
1165
  this.updateInputValue(this.text);
1139
1166
  }
1140
- this.updateValuesOnInput(e);
1167
+ const isClearVal = this.inputEle.value === '' ? true : false;
1168
+ this.updateValuesOnInput(e, null, isClearVal);
1141
1169
  }
1142
1170
  }
1143
1171
  }
1144
- updateValuesOnInput(mouseEvent, keyEvent, isClearValues = false, isKeyDown = false) {
1172
+ updateValuesOnInput(mouseEvent, keyEvent, isClearValues, isKeyDown = false) {
1145
1173
  const e = mouseEvent ? mouseEvent : keyEvent;
1146
1174
  const val = isKeyDown ? this.matchedContent : this.exactMatchedContent;
1147
1175
  if (!val) {
@@ -1149,19 +1177,21 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
1149
1177
  }
1150
1178
  this.hidePopup(e);
1151
1179
  if (this.matchedRowEle && !isClearValues && val) {
1152
- const prevOnChange = this.isProtectedOnChange;
1153
- this.isProtectedOnChange = true;
1154
1180
  setTimeout(() => {
1155
- this.inputEle.value = this.matchedContent[this.fields.text].toString();
1156
- this.value = this.matchedContent[this.fields.value].toString();
1181
+ const prevOnChange = this.isProtectedOnChange;
1182
+ this.isProtectedOnChange = true;
1183
+ const fieldText = this.updateFieldValue(this.fields.text, this.matchedContent);
1184
+ const fieldValue = this.updateFieldValue(this.fields.value, this.matchedContent);
1185
+ this.inputEle.value = fieldText;
1186
+ this.value = fieldValue;
1157
1187
  const selectIndex = this.findIndex(this.gridObj.currentViewData, this.matchedContent);
1158
1188
  this.index = selectIndex;
1159
- this.text = this.matchedContent[this.fields.text].toString();
1189
+ this.text = fieldText;
1160
1190
  this.gridObj.selectRow(selectIndex);
1161
1191
  this.selectedGridRow(this.gridObj.getRowByIndex(selectIndex), e);
1162
1192
  this.previousItemElement = this.gridObj.getSelectedRows()[0];
1193
+ this.isProtectedOnChange = prevOnChange;
1163
1194
  }, 100);
1164
- this.isProtectedOnChange = prevOnChange;
1165
1195
  }
1166
1196
  else {
1167
1197
  if (this.isDataFiltered) {
@@ -1506,7 +1536,8 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
1506
1536
  getDataByValue(value) {
1507
1537
  if (!isNullOrUndefined(this.dataSource) && this.dataSource instanceof Array) {
1508
1538
  return this.dataSource.filter((item) => {
1509
- return item[this.fields.value].toString() === value;
1539
+ const fieldValue = this.updateFieldValue(this.fields.value, item);
1540
+ return fieldValue === value;
1510
1541
  })[0];
1511
1542
  }
1512
1543
  else if (!isNullOrUndefined(this.dataSource) && this.dataSource instanceof DataManager) {
@@ -1514,7 +1545,8 @@ let MultiColumnComboBox = class MultiColumnComboBox extends Component {
1514
1545
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1515
1546
  const dataLists = e.result;
1516
1547
  return dataLists.filter((item) => {
1517
- return item[this.fields.value].toString() === value;
1548
+ const fieldValue = this.updateFieldValue(this.fields.value, item);
1549
+ return fieldValue === value;
1518
1550
  })[0];
1519
1551
  });
1520
1552
  }