@c8y/ngx-components 1024.13.0 → 1024.14.0

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.
@@ -228,10 +228,10 @@ class IconCellRendererComponent {
228
228
  if (!Array.isArray(iconConfigs))
229
229
  return null;
230
230
  return (iconConfigs.find(config => {
231
- const { comparison, value } = config;
231
+ const { comparison, value, dataType } = config;
232
232
  if (!comparison || value === undefined || value === null)
233
233
  return false;
234
- return this.evaluateCondition(cellValue, comparison.value, value);
234
+ return this.evaluateCondition(cellValue, comparison.value, value, dataType?.value);
235
235
  }) ?? null);
236
236
  }
237
237
  resolveValue(context) {
@@ -245,16 +245,27 @@ class IconCellRendererComponent {
245
245
  }
246
246
  return item[path];
247
247
  }
248
- evaluateCondition(cellValue, operator, value) {
248
+ /**
249
+ * Whether `cellValue`/`value` may be compared as numbers instead of their native types.
250
+ * Skipped when the condition's declared data type is explicitly `'string'`; a missing
251
+ * data type (e.g. after a legacy config round-trip) still allows numeric comparison.
252
+ */
253
+ canCompareNumerically(cellValue, value, dataType) {
254
+ if (dataType === 'string')
255
+ return false;
256
+ return [cellValue, value].every(v => v != null && String(v).trim() !== '' && typeof v !== 'boolean' && !Number.isNaN(Number(v)));
257
+ }
258
+ evaluateCondition(cellValue, operator, value, dataType) {
259
+ const numeric = this.canCompareNumerically(cellValue, value, dataType);
249
260
  switch (operator) {
250
261
  case 'GREATER_THAN':
251
- return cellValue > value;
262
+ return numeric ? Number(cellValue) > Number(value) : cellValue > value;
252
263
  case 'LESS_THAN':
253
- return cellValue < value;
264
+ return numeric ? Number(cellValue) < Number(value) : cellValue < value;
254
265
  case 'EQUAL':
255
- return cellValue === value;
266
+ return cellValue === value || (numeric && Number(cellValue) === Number(value));
256
267
  case 'NOT_EQUAL':
257
- return cellValue !== value;
268
+ return cellValue !== value && !(numeric && Number(cellValue) === Number(value));
258
269
  case 'CONTAINS':
259
270
  return typeof cellValue === 'string' && cellValue.includes(value);
260
271
  case 'STARTS_WITH':