@sumaris-net/ngx-components 1.0.1 → 1.0.2

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.
@@ -518,8 +518,11 @@
518
518
  return { data: [value] };
519
519
  value = (typeof value === 'string' && value !== '*') && value.toUpperCase() || undefined;
520
520
  var keys = opts && (opts.searchAttribute && [opts.searchAttribute] || opts.searchAttributes) || ['label'];
521
+ if (!items) {
522
+ return { data: [], total: 0 };
523
+ }
521
524
  // Filter items
522
- if (isNotNilOrBlank(value) && items) {
525
+ if (isNotNilOrBlank(value)) {
523
526
  // If wildcard, search using regexp
524
527
  if (value.indexOf('*') !== -1) {
525
528
  value = value.replace('*', '.*');
@@ -531,15 +534,14 @@
531
534
  }
532
535
  }
533
536
  // Exclude ids
534
- if (items && isNotEmptyArray(opts === null || opts === void 0 ? void 0 : opts.excludedIds)) {
537
+ if (isNotEmptyArray(opts === null || opts === void 0 ? void 0 : opts.excludedIds)) {
535
538
  items = items.filter(function (v) { return !opts.excludedIds.includes(+v['id']); });
536
539
  }
537
540
  // Sort
538
- if (items)
539
- items.sort(propertiesPathComparator(keys));
541
+ items.sort(propertiesPathComparator(keys));
540
542
  // Truncate if need
541
- var total = items && items.length || 0;
542
- if (items && opts) {
543
+ var total = items.length || 0;
544
+ if (opts) {
543
545
  if (opts.offset > 0) {
544
546
  items = items.slice(opts.offset);
545
547
  }