@elderbyte/ngx-starter 13.8.0 → 13.8.1

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.
@@ -4406,6 +4406,57 @@ class DelegateContinuableDataSource extends DelegateDataSource {
4406
4406
  }
4407
4407
  }
4408
4408
 
4409
+ class FilterUtil {
4410
+ static filterData(data, filters) {
4411
+ FilterUtil.logger.debug('Filtering data with ' + data.length + ' items.', filters);
4412
+ if (filters && filters.length > 0) {
4413
+ for (const filter of filters) {
4414
+ data = data.filter(e => FilterUtil.matches(e, filter));
4415
+ }
4416
+ }
4417
+ return data;
4418
+ }
4419
+ static matches(entity, filter) {
4420
+ if (filter.value === null || filter.value === undefined) {
4421
+ return true;
4422
+ }
4423
+ let value;
4424
+ if (entity === null || entity === undefined) {
4425
+ value = null;
4426
+ }
4427
+ else if (typeof entity === 'object') {
4428
+ value = entity[filter.key];
4429
+ }
4430
+ else {
4431
+ value = String(entity); // Support filtering primitive values
4432
+ }
4433
+ if (Array.isArray(filter.value)) {
4434
+ for (const val of filter.value) {
4435
+ if (FilterUtil.matchesValue(value, val)) {
4436
+ return true;
4437
+ }
4438
+ }
4439
+ return false;
4440
+ }
4441
+ else {
4442
+ return FilterUtil.matchesValue(value, filter.value);
4443
+ }
4444
+ }
4445
+ static matchesValue(haystack, needle) {
4446
+ if (haystack === needle) {
4447
+ return true;
4448
+ }
4449
+ if (haystack === null || haystack === undefined) {
4450
+ return false;
4451
+ }
4452
+ const str = String(haystack);
4453
+ const match = str.toLowerCase().startsWith(needle.toLowerCase());
4454
+ // FilterUtil.logger.debug('Haystack: ' + str + ' starts with needle: ' + needle + ' --> ' + match);
4455
+ return match;
4456
+ }
4457
+ }
4458
+ FilterUtil.logger = LoggerFactory.getLogger(FilterUtil.constructor.name);
4459
+
4409
4460
  /**
4410
4461
  * Provides the ability to build a IDataContext<T>.
4411
4462
  */
@@ -4531,12 +4582,12 @@ class DataContextBuilder {
4531
4582
  * *
4532
4583
  **************************************************************************/
4533
4584
  buildLocal(items, idProperty) {
4534
- return this.build(LocalListDataSource.from(items, idProperty));
4585
+ return this.build(LocalListDataSource.from(items, idProperty, this._localSort, FilterUtil.filterData));
4535
4586
  }
4536
4587
  buildLocalActivePaged(data, idProperty) {
4537
4588
  this._skipLocalSort = true;
4538
4589
  this.activePaged();
4539
- return this.build(LocalPagedDataSource.from(data, idProperty, this._localSort));
4590
+ return this.build(LocalPagedDataSource.from(data, idProperty, this._localSort, FilterUtil.filterData));
4540
4591
  }
4541
4592
  /***************************************************************************
4542
4593
  * *
@@ -6096,48 +6147,6 @@ class PropertyPathUtil {
6096
6147
  }
6097
6148
  }
6098
6149
 
6099
- class FilterUtil {
6100
- static filterData(data, filters) {
6101
- FilterUtil.logger.debug('Filtering data with ' + data.length + ' items.', filters);
6102
- if (filters && filters.length > 0) {
6103
- for (const filter of filters) {
6104
- data = data.filter(e => FilterUtil.matches(e, filter));
6105
- }
6106
- }
6107
- return data;
6108
- }
6109
- static matches(entity, filter) {
6110
- if (filter.value === null || filter.value === undefined) {
6111
- return true;
6112
- }
6113
- const value = entity[filter.key];
6114
- if (Array.isArray(filter.value)) {
6115
- for (const val of filter.value) {
6116
- if (FilterUtil.matchesValue(value, val)) {
6117
- return true;
6118
- }
6119
- }
6120
- return false;
6121
- }
6122
- else {
6123
- return FilterUtil.matchesValue(value, filter.value);
6124
- }
6125
- }
6126
- static matchesValue(haystack, needle) {
6127
- if (haystack === needle) {
6128
- return true;
6129
- }
6130
- if (haystack === null || haystack === undefined) {
6131
- return false;
6132
- }
6133
- const str = String(haystack);
6134
- const match = str.toLowerCase().startsWith(needle.toLowerCase());
6135
- // FilterUtil.logger.debug('Haystack: ' + str + ' starts with needle: ' + needle + ' --> ' + match);
6136
- return match;
6137
- }
6138
- }
6139
- FilterUtil.logger = LoggerFactory.getLogger(FilterUtil.constructor.name);
6140
-
6141
6150
  class NextNumberUtil {
6142
6151
  /***************************************************************************
6143
6152
  * *
@@ -20348,6 +20357,7 @@ class ElderSelectBase extends FormFieldBaseComponent {
20348
20357
  this.autoCleanUp();
20349
20358
  if (data instanceof Array) {
20350
20359
  this.suggestionsDc = DataContextBuilder.start()
20360
+ .localSort()
20351
20361
  .buildLocal(data); // Memory leak
20352
20362
  this.suggestionsDc.start();
20353
20363
  }