handsontable 0.0.0-next-14118b6-20240131 → 0.0.0-next-817afa4-20240202

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of handsontable might be problematic. Click here for more details.

@@ -50,6 +50,7 @@ exports.removeClass = removeClass;
50
50
  exports.removeContentEditableFromElementAndDeselect = removeContentEditableFromElementAndDeselect;
51
51
  exports.removeEvent = removeEvent;
52
52
  exports.removeTextNodes = removeTextNodes;
53
+ exports.renderMockCell = renderMockCell;
53
54
  exports.resetCssTransform = resetCssTransform;
54
55
  exports.runWithSelectedContendEditableElement = runWithSelectedContendEditableElement;
55
56
  exports.selectElementIfAllowed = selectElementIfAllowed;
@@ -1135,4 +1136,19 @@ function runWithSelectedContendEditableElement(element, callback) {
1135
1136
  makeElementContentEditableAndSelectItsContent(element, invisibleSelection);
1136
1137
  callback();
1137
1138
  removeContentEditableFromElementAndDeselect(element, invisibleSelection);
1139
+ }
1140
+
1141
+ /**
1142
+ * Return a `td` element rendered outside of the table with the provided renderer function.
1143
+ *
1144
+ * @param {Document} rootDocument Root document element.
1145
+ * @param {Function} renderFunction The renderer function.
1146
+ * @param {Array} renderArgs The renderer arguments.
1147
+ * @returns {HTMLElement} The rendered `td` element.
1148
+ */
1149
+ function renderMockCell(rootDocument, renderFunction, renderArgs) {
1150
+ const cell = rootDocument.createElement('td');
1151
+ renderArgs.splice(1, 0, cell);
1152
+ renderFunction.call(renderArgs.instance, ...renderArgs);
1153
+ return cell;
1138
1154
  }
@@ -1077,4 +1077,19 @@ export function runWithSelectedContendEditableElement(element, callback) {
1077
1077
  makeElementContentEditableAndSelectItsContent(element, invisibleSelection);
1078
1078
  callback();
1079
1079
  removeContentEditableFromElementAndDeselect(element, invisibleSelection);
1080
+ }
1081
+
1082
+ /**
1083
+ * Return a `td` element rendered outside of the table with the provided renderer function.
1084
+ *
1085
+ * @param {Document} rootDocument Root document element.
1086
+ * @param {Function} renderFunction The renderer function.
1087
+ * @param {Array} renderArgs The renderer arguments.
1088
+ * @returns {HTMLElement} The rendered `td` element.
1089
+ */
1090
+ export function renderMockCell(rootDocument, renderFunction, renderArgs) {
1091
+ const cell = rootDocument.createElement('td');
1092
+ renderArgs.splice(1, 0, cell);
1093
+ renderFunction.call(renderArgs.instance, ...renderArgs);
1094
+ return cell;
1080
1095
  }
package/helpers/mixed.js CHANGED
@@ -134,7 +134,7 @@ const domMessages = {
134
134
  function _injectProductInfo(key, element) {
135
135
  const hasValidType = !isEmpty(key);
136
136
  const isNonCommercial = typeof key === 'string' && key.toLowerCase() === 'non-commercial-and-evaluation';
137
- const hotVersion = "0.0.0-next-14118b6-20240131";
137
+ const hotVersion = "0.0.0-next-817afa4-20240202";
138
138
  let keyValidityDate;
139
139
  let consoleMessageState = 'invalid';
140
140
  let domMessageState = 'invalid';
package/helpers/mixed.mjs CHANGED
@@ -124,7 +124,7 @@ const domMessages = {
124
124
  export function _injectProductInfo(key, element) {
125
125
  const hasValidType = !isEmpty(key);
126
126
  const isNonCommercial = typeof key === 'string' && key.toLowerCase() === 'non-commercial-and-evaluation';
127
- const hotVersion = "0.0.0-next-14118b6-20240131";
127
+ const hotVersion = "0.0.0-next-817afa4-20240202";
128
128
  let keyValidityDate;
129
129
  let consoleMessageState = 'invalid';
130
130
  let domMessageState = 'invalid';
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "url": "https://github.com/handsontable/handsontable/issues"
11
11
  },
12
12
  "author": "Handsoncode <hello@handsontable.com>",
13
- "version": "0.0.0-next-14118b6-20240131",
13
+ "version": "0.0.0-next-817afa4-20240202",
14
14
  "main": "index",
15
15
  "module": "index.mjs",
16
16
  "jsnext:main": "index.mjs",
package/pluginHooks.js CHANGED
@@ -414,7 +414,7 @@ const REGISTERED_HOOKS = [/* eslint-disable jsdoc/require-description-complete-s
414
414
  */
415
415
  'afterUpdateData',
416
416
  /**
417
- * Fired after a scroll event, which is identified as a momentum scroll.
417
+ * Fired after a scroll event, which is identified as a momentum scroll (e.g. On an iPad).
418
418
  *
419
419
  * @event Hooks#afterMomentumScroll
420
420
  */
package/pluginHooks.mjs CHANGED
@@ -410,7 +410,7 @@ const REGISTERED_HOOKS = [/* eslint-disable jsdoc/require-description-complete-s
410
410
  */
411
411
  'afterUpdateData',
412
412
  /**
413
- * Fired after a scroll event, which is identified as a momentum scroll.
413
+ * Fired after a scroll event, which is identified as a momentum scroll (e.g. On an iPad).
414
414
  *
415
415
  * @event Hooks#afterMomentumScroll
416
416
  */
@@ -108,17 +108,23 @@ class ValueComponent extends _base.BaseComponent {
108
108
  * `editedConditionStack`, `dependentConditionStacks`, `visibleDataFactory` and `conditionArgsChange`.
109
109
  */
110
110
  updateState(stateInfo) {
111
+ const multipleSelectComponent = this.getMultipleSelectElement();
111
112
  const updateColumnState = (physicalColumn, conditions, conditionArgsChange, filteredRowsFactory, conditionsStack) => {
112
113
  const [firstByValueCondition] = (0, _array.arrayFilter)(conditions, condition => condition.name === _constants2.CONDITION_BY_VALUE);
113
114
  const state = {};
114
115
  const defaultBlankCellValue = this.hot.getTranslatedPhrase(C.FILTERS_VALUES_BLANK_CELLS);
115
116
  if (firstByValueCondition) {
116
- const rowValues = (0, _utils.unifyColumnValues)((0, _array.arrayMap)(filteredRowsFactory(physicalColumn, conditionsStack), row => row.value));
117
+ const filteredRows = filteredRowsFactory(physicalColumn, conditionsStack);
118
+ const rowValues = (0, _array.arrayMap)(filteredRows, row => row.value);
119
+ const rowIndexes = (0, _array.arrayMap)(filteredRows, row => row.meta.visualRow);
120
+ const unifiedRowValues = (0, _utils.unifyColumnValues)(rowValues);
121
+ const displayValues = (multipleSelectComponent.getDisplayValuesAtCol(this.hot.toVisualColumn(physicalColumn)) || []).filter((value, index) => rowIndexes.includes(index));
122
+ const displayValuesSyncedWithUnifiedValues = (0, _utils.syncDisplayValuesToUnifiedValues)(displayValues, rowValues, unifiedRowValues);
117
123
  if (conditionArgsChange) {
118
124
  firstByValueCondition.args[0] = conditionArgsChange;
119
125
  }
120
126
  const selectedValues = [];
121
- const itemsSnapshot = (0, _utils.intersectValues)(rowValues, firstByValueCondition.args[0], defaultBlankCellValue, item => {
127
+ const itemsSnapshot = (0, _utils.intersectValues)(unifiedRowValues, firstByValueCondition.args[0], defaultBlankCellValue, displayValuesSyncedWithUnifiedValues, item => {
122
128
  if (item.checked) {
123
129
  selectedValues.push(item.value);
124
130
  }
@@ -181,13 +187,17 @@ class ValueComponent extends _base.BaseComponent {
181
187
  * Reset elements to their initial state.
182
188
  */
183
189
  reset() {
190
+ const multiSelectComponent = this.getMultipleSelectElement();
191
+ const selectedColumn = this.hot.getPlugin('filters').getSelectedColumn();
184
192
  const defaultBlankCellValue = this.hot.getTranslatedPhrase(C.FILTERS_VALUES_BLANK_CELLS);
185
- const values = (0, _utils.unifyColumnValues)(this._getColumnVisibleValues());
186
- const items = (0, _utils.intersectValues)(values, values, defaultBlankCellValue);
193
+ const values = this._getColumnVisibleValues();
194
+ const unifiedValues = (0, _utils.unifyColumnValues)(values);
195
+ const displayValues = multiSelectComponent.getDisplayValuesAtCol(selectedColumn === null || selectedColumn === void 0 ? void 0 : selectedColumn.visualIndex) || [];
196
+ const displayValuesSyncedWithUnifiedValues = (0, _utils.syncDisplayValuesToUnifiedValues)(displayValues, values, unifiedValues);
197
+ const items = (0, _utils.intersectValues)(unifiedValues, unifiedValues, defaultBlankCellValue, displayValuesSyncedWithUnifiedValues || []);
187
198
  this.getMultipleSelectElement().setItems(items);
188
199
  super.reset();
189
- this.getMultipleSelectElement().setValue(values);
190
- const selectedColumn = this.hot.getPlugin('filters').getSelectedColumn();
200
+ this.getMultipleSelectElement().setValue(unifiedValues);
191
201
  if (selectedColumn !== null) {
192
202
  this.getMultipleSelectElement().setLocale(this.hot.getCellMeta(0, selectedColumn.visualIndex).locale);
193
203
  }
@@ -11,7 +11,7 @@ import { stopImmediatePropagation } from "../../../helpers/dom/event.mjs";
11
11
  import { arrayEach, arrayFilter, arrayMap } from "../../../helpers/array.mjs";
12
12
  import { isKey } from "../../../helpers/unicode.mjs";
13
13
  import * as C from "../../../i18n/constants.mjs";
14
- import { unifyColumnValues, intersectValues, toEmptyString } from "../utils.mjs";
14
+ import { unifyColumnValues, intersectValues, toEmptyString, syncDisplayValuesToUnifiedValues } from "../utils.mjs";
15
15
  import { BaseComponent } from "./_base.mjs";
16
16
  import { MultipleSelectUI } from "../ui/multipleSelect.mjs";
17
17
  import { CONDITION_BY_VALUE, CONDITION_NONE } from "../constants.mjs";
@@ -103,17 +103,23 @@ export class ValueComponent extends BaseComponent {
103
103
  * `editedConditionStack`, `dependentConditionStacks`, `visibleDataFactory` and `conditionArgsChange`.
104
104
  */
105
105
  updateState(stateInfo) {
106
+ const multipleSelectComponent = this.getMultipleSelectElement();
106
107
  const updateColumnState = (physicalColumn, conditions, conditionArgsChange, filteredRowsFactory, conditionsStack) => {
107
108
  const [firstByValueCondition] = arrayFilter(conditions, condition => condition.name === CONDITION_BY_VALUE);
108
109
  const state = {};
109
110
  const defaultBlankCellValue = this.hot.getTranslatedPhrase(C.FILTERS_VALUES_BLANK_CELLS);
110
111
  if (firstByValueCondition) {
111
- const rowValues = unifyColumnValues(arrayMap(filteredRowsFactory(physicalColumn, conditionsStack), row => row.value));
112
+ const filteredRows = filteredRowsFactory(physicalColumn, conditionsStack);
113
+ const rowValues = arrayMap(filteredRows, row => row.value);
114
+ const rowIndexes = arrayMap(filteredRows, row => row.meta.visualRow);
115
+ const unifiedRowValues = unifyColumnValues(rowValues);
116
+ const displayValues = (multipleSelectComponent.getDisplayValuesAtCol(this.hot.toVisualColumn(physicalColumn)) || []).filter((value, index) => rowIndexes.includes(index));
117
+ const displayValuesSyncedWithUnifiedValues = syncDisplayValuesToUnifiedValues(displayValues, rowValues, unifiedRowValues);
112
118
  if (conditionArgsChange) {
113
119
  firstByValueCondition.args[0] = conditionArgsChange;
114
120
  }
115
121
  const selectedValues = [];
116
- const itemsSnapshot = intersectValues(rowValues, firstByValueCondition.args[0], defaultBlankCellValue, item => {
122
+ const itemsSnapshot = intersectValues(unifiedRowValues, firstByValueCondition.args[0], defaultBlankCellValue, displayValuesSyncedWithUnifiedValues, item => {
117
123
  if (item.checked) {
118
124
  selectedValues.push(item.value);
119
125
  }
@@ -176,13 +182,17 @@ export class ValueComponent extends BaseComponent {
176
182
  * Reset elements to their initial state.
177
183
  */
178
184
  reset() {
185
+ const multiSelectComponent = this.getMultipleSelectElement();
186
+ const selectedColumn = this.hot.getPlugin('filters').getSelectedColumn();
179
187
  const defaultBlankCellValue = this.hot.getTranslatedPhrase(C.FILTERS_VALUES_BLANK_CELLS);
180
- const values = unifyColumnValues(this._getColumnVisibleValues());
181
- const items = intersectValues(values, values, defaultBlankCellValue);
188
+ const values = this._getColumnVisibleValues();
189
+ const unifiedValues = unifyColumnValues(values);
190
+ const displayValues = multiSelectComponent.getDisplayValuesAtCol(selectedColumn === null || selectedColumn === void 0 ? void 0 : selectedColumn.visualIndex) || [];
191
+ const displayValuesSyncedWithUnifiedValues = syncDisplayValuesToUnifiedValues(displayValues, values, unifiedValues);
192
+ const items = intersectValues(unifiedValues, unifiedValues, defaultBlankCellValue, displayValuesSyncedWithUnifiedValues || []);
182
193
  this.getMultipleSelectElement().setItems(items);
183
194
  super.reset();
184
- this.getMultipleSelectElement().setValue(values);
185
- const selectedColumn = this.hot.getPlugin('filters').getSelectedColumn();
195
+ this.getMultipleSelectElement().setValue(unifiedValues);
186
196
  if (selectedColumn !== null) {
187
197
  this.getMultipleSelectElement().setLocale(this.hot.getCellMeta(0, selectedColumn.visualIndex).locale);
188
198
  }
@@ -380,6 +380,44 @@ class MultipleSelectUI extends _base.BaseUI {
380
380
  _classPrivateFieldSet(this, _items, null);
381
381
  super.destroy();
382
382
  }
383
+
384
+ /**
385
+ * Returns the display values for all the cells at the given `column` visual index.
386
+ * If no display values are defined, the `source data` values will be returned instead.
387
+ *
388
+ * If the provided column index is not a valid integer, the method will return `null`.
389
+ *
390
+ * @param {number} column From visual column index.
391
+ * @returns {Array[]|null} Array containing the display values of all the cells in the column.
392
+ */
393
+ getDisplayValuesAtCol(column) {
394
+ if (!Number.isInteger(column)) {
395
+ return null;
396
+ }
397
+ const sourceRowCount = this.hot.countSourceRows();
398
+ const columnData = [];
399
+ let returnValue;
400
+ for (let row = 0; row < sourceRowCount; row += 1) {
401
+ const cellMeta = this.hot.getCellMeta(row, column);
402
+ const {
403
+ prop,
404
+ displayValue
405
+ } = cellMeta;
406
+ const cellSourceData = this.hot.getSourceDataAtCell(row, column);
407
+ if (displayValue) {
408
+ returnValue = displayValue;
409
+ } else {
410
+ var _cellMeta$displayValu;
411
+ // Render the cell in a mock element to try to get the display value (possibly applied in the renderer).
412
+ (0, _element.renderMockCell)(this.hot.rootDocument, this.hot.getCellRenderer(row, column), [this.hot, row, column, prop, cellSourceData, cellMeta]);
413
+
414
+ // Retry getting the display value.
415
+ returnValue = (_cellMeta$displayValu = cellMeta.displayValue) !== null && _cellMeta$displayValu !== void 0 ? _cellMeta$displayValu : cellSourceData;
416
+ }
417
+ columnData.push(returnValue);
418
+ }
419
+ return columnData;
420
+ }
383
421
  }
384
422
  exports.MultipleSelectUI = MultipleSelectUI;
385
423
  function _onInput2(event) {
@@ -9,7 +9,7 @@ function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) {
9
9
  function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
10
10
  function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
11
11
  function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
12
- import { addClass, getScrollbarWidth } from "../../../helpers/dom/element.mjs";
12
+ import { addClass, getScrollbarWidth, renderMockCell } from "../../../helpers/dom/element.mjs";
13
13
  import { clone, extend } from "../../../helpers/object.mjs";
14
14
  import { arrayFilter, arrayMap, arrayEach } from "../../../helpers/array.mjs";
15
15
  import { isKey } from "../../../helpers/unicode.mjs";
@@ -375,6 +375,44 @@ export class MultipleSelectUI extends BaseUI {
375
375
  _classPrivateFieldSet(this, _items, null);
376
376
  super.destroy();
377
377
  }
378
+
379
+ /**
380
+ * Returns the display values for all the cells at the given `column` visual index.
381
+ * If no display values are defined, the `source data` values will be returned instead.
382
+ *
383
+ * If the provided column index is not a valid integer, the method will return `null`.
384
+ *
385
+ * @param {number} column From visual column index.
386
+ * @returns {Array[]|null} Array containing the display values of all the cells in the column.
387
+ */
388
+ getDisplayValuesAtCol(column) {
389
+ if (!Number.isInteger(column)) {
390
+ return null;
391
+ }
392
+ const sourceRowCount = this.hot.countSourceRows();
393
+ const columnData = [];
394
+ let returnValue;
395
+ for (let row = 0; row < sourceRowCount; row += 1) {
396
+ const cellMeta = this.hot.getCellMeta(row, column);
397
+ const {
398
+ prop,
399
+ displayValue
400
+ } = cellMeta;
401
+ const cellSourceData = this.hot.getSourceDataAtCell(row, column);
402
+ if (displayValue) {
403
+ returnValue = displayValue;
404
+ } else {
405
+ var _cellMeta$displayValu;
406
+ // Render the cell in a mock element to try to get the display value (possibly applied in the renderer).
407
+ renderMockCell(this.hot.rootDocument, this.hot.getCellRenderer(row, column), [this.hot, row, column, prop, cellSourceData, cellMeta]);
408
+
409
+ // Retry getting the display value.
410
+ returnValue = (_cellMeta$displayValu = cellMeta.displayValue) !== null && _cellMeta$displayValu !== void 0 ? _cellMeta$displayValu : cellSourceData;
411
+ }
412
+ columnData.push(returnValue);
413
+ }
414
+ return columnData;
415
+ }
378
416
  }
379
417
  function _onInput2(event) {
380
418
  const value = event.target.value.toLocaleLowerCase(this.getLocale());
@@ -4,6 +4,7 @@ exports.__esModule = true;
4
4
  exports.createArrayAssertion = createArrayAssertion;
5
5
  exports.intersectValues = intersectValues;
6
6
  exports.sortComparison = sortComparison;
7
+ exports.syncDisplayValuesToUnifiedValues = syncDisplayValuesToUnifiedValues;
7
8
  exports.toEmptyString = toEmptyString;
8
9
  exports.toVisualValue = toVisualValue;
9
10
  exports.unifyColumnValues = unifyColumnValues;
@@ -31,12 +32,15 @@ function sortComparison(a, b) {
31
32
  *
32
33
  * @param {*} value The value to convert.
33
34
  * @param {string} defaultEmptyValue Default value for empty cells.
35
+ * @param {string} [displayValue] The display value.
34
36
  * @returns {*}
35
37
  */
36
- function toVisualValue(value, defaultEmptyValue) {
38
+ function toVisualValue(value, defaultEmptyValue, displayValue) {
37
39
  let visualValue = value;
38
40
  if (visualValue === '') {
39
41
  visualValue = `(${defaultEmptyValue})`;
42
+ } else if (displayValue) {
43
+ visualValue = displayValue;
40
44
  }
41
45
  return visualValue;
42
46
  }
@@ -77,7 +81,7 @@ function toEmptyString(value) {
77
81
  }
78
82
 
79
83
  /**
80
- * Unify column values (replace `null` and `undefined` values into empty string, unique values and sort them).
84
+ * Unify column values (remove duplicated values and sort them).
81
85
  *
82
86
  * @param {Array} values An array of values.
83
87
  * @returns {Array}
@@ -101,23 +105,43 @@ function unifyColumnValues(values) {
101
105
  return unifiedValues;
102
106
  }
103
107
 
108
+ /**
109
+ * Synchronize display values with the provided unified values.
110
+ *
111
+ * @param {Array} displayValues An array of display values.
112
+ * @param {Array} values An array of source values.
113
+ * @param {Array} unifiedValues An array of unified values.
114
+ *
115
+ * @returns {Array} An array of synchronized display values.
116
+ */
117
+ function syncDisplayValuesToUnifiedValues(displayValues, values, unifiedValues) {
118
+ const syncedDisplayValues = [];
119
+ (0, _array.arrayEach)(unifiedValues, unifiedValue => {
120
+ const index = values.indexOf(unifiedValue);
121
+ const displayValue = displayValues[index];
122
+ syncedDisplayValues.push(displayValue);
123
+ });
124
+ return syncedDisplayValues;
125
+ }
126
+
104
127
  /**
105
128
  * Intersect 'base' values with 'selected' values and return an array of object.
106
129
  *
107
130
  * @param {Array} base An array of base values.
108
131
  * @param {Array} selected An array of selected values.
109
132
  * @param {string} defaultEmptyValue Default value for empty cells.
133
+ * @param {string[]} [displayValues] An array of display values.
110
134
  * @param {Function} [callback] A callback function which is invoked for every item in an array.
111
135
  * @returns {Array}
112
136
  */
113
- function intersectValues(base, selected, defaultEmptyValue, callback) {
137
+ function intersectValues(base, selected, defaultEmptyValue, displayValues, callback) {
114
138
  const result = [];
115
139
  const same = base === selected;
116
140
  let selectedItemsAssertion;
117
141
  if (!same) {
118
142
  selectedItemsAssertion = createArrayAssertion(selected);
119
143
  }
120
- (0, _array.arrayEach)(base, value => {
144
+ (0, _array.arrayEach)(base, (value, index) => {
121
145
  let checked = false;
122
146
  if (same || selectedItemsAssertion(value)) {
123
147
  checked = true;
@@ -125,7 +149,7 @@ function intersectValues(base, selected, defaultEmptyValue, callback) {
125
149
  const item = {
126
150
  checked,
127
151
  value,
128
- visualValue: toVisualValue(value, defaultEmptyValue)
152
+ visualValue: toVisualValue(value, defaultEmptyValue, displayValues[index])
129
153
  };
130
154
  if (callback) {
131
155
  callback(item);
@@ -22,12 +22,15 @@ export function sortComparison(a, b) {
22
22
  *
23
23
  * @param {*} value The value to convert.
24
24
  * @param {string} defaultEmptyValue Default value for empty cells.
25
+ * @param {string} [displayValue] The display value.
25
26
  * @returns {*}
26
27
  */
27
- export function toVisualValue(value, defaultEmptyValue) {
28
+ export function toVisualValue(value, defaultEmptyValue, displayValue) {
28
29
  let visualValue = value;
29
30
  if (visualValue === '') {
30
31
  visualValue = `(${defaultEmptyValue})`;
32
+ } else if (displayValue) {
33
+ visualValue = displayValue;
31
34
  }
32
35
  return visualValue;
33
36
  }
@@ -68,7 +71,7 @@ export function toEmptyString(value) {
68
71
  }
69
72
 
70
73
  /**
71
- * Unify column values (replace `null` and `undefined` values into empty string, unique values and sort them).
74
+ * Unify column values (remove duplicated values and sort them).
72
75
  *
73
76
  * @param {Array} values An array of values.
74
77
  * @returns {Array}
@@ -92,23 +95,43 @@ export function unifyColumnValues(values) {
92
95
  return unifiedValues;
93
96
  }
94
97
 
98
+ /**
99
+ * Synchronize display values with the provided unified values.
100
+ *
101
+ * @param {Array} displayValues An array of display values.
102
+ * @param {Array} values An array of source values.
103
+ * @param {Array} unifiedValues An array of unified values.
104
+ *
105
+ * @returns {Array} An array of synchronized display values.
106
+ */
107
+ export function syncDisplayValuesToUnifiedValues(displayValues, values, unifiedValues) {
108
+ const syncedDisplayValues = [];
109
+ arrayEach(unifiedValues, unifiedValue => {
110
+ const index = values.indexOf(unifiedValue);
111
+ const displayValue = displayValues[index];
112
+ syncedDisplayValues.push(displayValue);
113
+ });
114
+ return syncedDisplayValues;
115
+ }
116
+
95
117
  /**
96
118
  * Intersect 'base' values with 'selected' values and return an array of object.
97
119
  *
98
120
  * @param {Array} base An array of base values.
99
121
  * @param {Array} selected An array of selected values.
100
122
  * @param {string} defaultEmptyValue Default value for empty cells.
123
+ * @param {string[]} [displayValues] An array of display values.
101
124
  * @param {Function} [callback] A callback function which is invoked for every item in an array.
102
125
  * @returns {Array}
103
126
  */
104
- export function intersectValues(base, selected, defaultEmptyValue, callback) {
127
+ export function intersectValues(base, selected, defaultEmptyValue, displayValues, callback) {
105
128
  const result = [];
106
129
  const same = base === selected;
107
130
  let selectedItemsAssertion;
108
131
  if (!same) {
109
132
  selectedItemsAssertion = createArrayAssertion(selected);
110
133
  }
111
- arrayEach(base, value => {
134
+ arrayEach(base, (value, index) => {
112
135
  let checked = false;
113
136
  if (same || selectedItemsAssertion(value)) {
114
137
  checked = true;
@@ -116,7 +139,7 @@ export function intersectValues(base, selected, defaultEmptyValue, callback) {
116
139
  const item = {
117
140
  checked,
118
141
  value,
119
- visualValue: toVisualValue(value, defaultEmptyValue)
142
+ visualValue: toVisualValue(value, defaultEmptyValue, displayValues[index])
120
143
  };
121
144
  if (callback) {
122
145
  callback(item);
@@ -47,6 +47,7 @@ function numericRenderer(hotInstance, TD, row, col, prop, value, cellProperties)
47
47
  cellProperties.className = classArr.join(' ');
48
48
  TD.dir = 'ltr';
49
49
  }
50
+ cellProperties.displayValue = newValue;
50
51
  (0, _textRenderer.textRenderer)(hotInstance, TD, row, col, prop, newValue, cellProperties);
51
52
  }
52
53
  numericRenderer.RENDERER_TYPE = RENDERER_TYPE;
@@ -42,6 +42,7 @@ export function numericRenderer(hotInstance, TD, row, col, prop, value, cellProp
42
42
  cellProperties.className = classArr.join(' ');
43
43
  TD.dir = 'ltr';
44
44
  }
45
+ cellProperties.displayValue = newValue;
45
46
  textRenderer(hotInstance, TD, row, col, prop, newValue, cellProperties);
46
47
  }
47
48
  numericRenderer.RENDERER_TYPE = RENDERER_TYPE;