@kodaris/krubble-components 1.0.56 → 1.0.57

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.
@@ -3013,6 +3013,7 @@ const KR_OPERATORS = {
3013
3013
  greater_than_equal: { key: 'greater_than_equal', type: 'comparison', dataTypes: ['number', 'date'], label: 'Greater than or equal' },
3014
3014
  between: { key: 'between', type: 'range', dataTypes: ['number', 'date'], label: 'Between' },
3015
3015
  in: { key: 'in', type: 'list', dataTypes: ['string', 'number'], label: 'In' },
3016
+ n_in: { key: 'n_in', type: 'list', dataTypes: ['string', 'number', 'date', 'boolean'], label: 'Not In' },
3016
3017
  empty: { key: 'empty', type: 'nil', dataTypes: ['string', 'number', 'date', 'boolean'], label: 'Empty' },
3017
3018
  n_empty: { key: 'n_empty', type: 'nil', dataTypes: ['string', 'number', 'date', 'boolean'], label: 'Not empty' },
3018
3019
  };
@@ -3345,6 +3346,14 @@ class KRQuery {
3345
3346
  };
3346
3347
  this.specificity = [getDateSpecificity(rawStart), getDateSpecificity(rawEnd)];
3347
3348
  }
3349
+ else if (kql.startsWith('!(') && kql.endsWith(')')) {
3350
+ this.operator = 'n_in';
3351
+ this.text = kql.substring(2, kql.length - 1).trim();
3352
+ this.value = this.text.split(',')
3353
+ .map(v => v.trim())
3354
+ .map(v => this._parse(v));
3355
+ this.specificity = [getDateSpecificity(this.text)];
3356
+ }
3348
3357
  else if (kql.startsWith('(') && kql.endsWith(')')) {
3349
3358
  this.operator = 'in';
3350
3359
  this.text = kql.substring(1, kql.length - 1).trim();
@@ -3391,7 +3400,7 @@ class KRQuery {
3391
3400
  this.value = null;
3392
3401
  this.text = '';
3393
3402
  }
3394
- else if (this.operator === 'in') {
3403
+ else if (this.operator === 'in' || this.operator === 'n_in') {
3395
3404
  this.value = [];
3396
3405
  this.text = '';
3397
3406
  }
@@ -3409,7 +3418,7 @@ class KRQuery {
3409
3418
  this.value = null;
3410
3419
  this.text = '';
3411
3420
  }
3412
- else if (this.operator === 'in') {
3421
+ else if (this.operator === 'in' || this.operator === 'n_in') {
3413
3422
  this.value = [];
3414
3423
  this.text = '';
3415
3424
  }
@@ -3476,14 +3485,14 @@ class KRQuery {
3476
3485
  if (this.operator === 'between') {
3477
3486
  return !this.value?.start && !this.value?.end;
3478
3487
  }
3479
- if (this.operator === 'in') {
3488
+ if (this.operator === 'in' || this.operator === 'n_in') {
3480
3489
  return !this.value?.length;
3481
3490
  }
3482
3491
  return this.value === undefined || this.value === null || this.value === '';
3483
3492
  }
3484
- /** Returns true if the value array contains the given value. Only applies to 'in' operator. */
3493
+ /** Returns true if the value array contains the given value. Only applies to 'in' and 'n_in' operators. */
3485
3494
  has(val) {
3486
- if (this.operator !== 'in' || !Array.isArray(this.value)) {
3495
+ if ((this.operator !== 'in' && this.operator !== 'n_in') || !Array.isArray(this.value)) {
3487
3496
  return false;
3488
3497
  }
3489
3498
  // Bucket values from Solr arrive as strings ("true"/"false") but
@@ -3498,9 +3507,9 @@ class KRQuery {
3498
3507
  }
3499
3508
  return this.value.indexOf(val) >= 0;
3500
3509
  }
3501
- /** Adds or removes a value from the 'in' list and rebuilds text/kql. */
3510
+ /** Adds or removes a value from the 'in' or 'n_in' list and rebuilds text/kql. */
3502
3511
  toggle(val) {
3503
- if (this.operator !== 'in') {
3512
+ if (this.operator !== 'in' && this.operator !== 'n_in') {
3504
3513
  this.setOperator('in');
3505
3514
  }
3506
3515
  // Bucket values from Solr arrive as strings ("true"/"false") —
@@ -3539,8 +3548,8 @@ class KRQuery {
3539
3548
  if (this.operator === 'n_empty') {
3540
3549
  return true;
3541
3550
  }
3542
- // For 'in' operator, valid as long as there's at least one value (including null for empty buckets)
3543
- if (this.operator === 'in') {
3551
+ // For 'in'/'n_in' operator, valid as long as there's at least one value (including null for empty buckets)
3552
+ if (this.operator === 'in' || this.operator === 'n_in') {
3544
3553
  return Array.isArray(this.value) && this.value.length > 0;
3545
3554
  }
3546
3555
  if (this.type === 'date') {
@@ -3684,6 +3693,18 @@ class KRQuery {
3684
3693
  data.value = termify(this.value, true);
3685
3694
  }
3686
3695
  break;
3696
+ case 'n_in':
3697
+ if (Array.isArray(this.value) && this.value.length > 0) {
3698
+ data.operation = 'EXPRESSION';
3699
+ data.not = true;
3700
+ data.value = `(${this.value.map((v) => termify(v, true)).join(' OR ')})`;
3701
+ }
3702
+ else {
3703
+ data.operation = 'EXPRESSION';
3704
+ data.not = true;
3705
+ data.value = termify(this.value, true);
3706
+ }
3707
+ break;
3687
3708
  default:
3688
3709
  data.operation = 'EXPRESSION';
3689
3710
  data.value = termify(this.value, true);
@@ -3778,6 +3799,11 @@ class KRQuery {
3778
3799
  params.operation = 'IN';
3779
3800
  params.values = this.value ?? [];
3780
3801
  break;
3802
+ case 'n_in':
3803
+ params.operation = 'IN';
3804
+ params.not = true;
3805
+ params.values = this.value ?? [];
3806
+ break;
3781
3807
  default:
3782
3808
  throw Error(`${this.operator} operator not supported by db params.`);
3783
3809
  }
@@ -3794,7 +3820,7 @@ class KRQuery {
3794
3820
  if (this.operator === 'between') {
3795
3821
  this.text = `${this._format(this.value?.start)} - ${this._format(this.value?.end)}`;
3796
3822
  }
3797
- else if (this.operator === 'in') {
3823
+ else if (this.operator === 'in' || this.operator === 'n_in') {
3798
3824
  this.text = this.value.map((v) => this._format(v)).join(',');
3799
3825
  }
3800
3826
  else {
@@ -4008,6 +4034,9 @@ class KRQuery {
4008
4034
  case 'in':
4009
4035
  this.kql = `(${this.value.map((v) => this._format(v)).join(',')})`;
4010
4036
  break;
4037
+ case 'n_in':
4038
+ this.kql = `!(${this.value.map((v) => this._format(v)).join(',')})`;
4039
+ break;
4011
4040
  default:
4012
4041
  throw Error(`Unknown operator ${this.operator}`);
4013
4042
  }
@@ -4259,7 +4288,7 @@ let KRTable = class KRTable extends i$2 {
4259
4288
  continue;
4260
4289
  }
4261
4290
  const filterData = col.filter.toSolrData();
4262
- if (col.facetable && col.filter.operator === 'in') {
4291
+ if (col.facetable && (col.filter.operator === 'in' || col.filter.operator === 'n_in')) {
4263
4292
  filterData.tagged = true;
4264
4293
  }
4265
4294
  request.filterFields.push(filterData);
@@ -4411,7 +4440,7 @@ let KRTable = class KRTable extends i$2 {
4411
4440
  }
4412
4441
  }
4413
4442
  // Bucket sync: ensure selected values appear even with 0 results
4414
- if (col.filter && col.filter.operator === 'in' && Array.isArray(col.filter.value)) {
4443
+ if (col.filter && (col.filter.operator === 'in' || col.filter.operator === 'n_in') && Array.isArray(col.filter.value)) {
4415
4444
  for (const selectedVal of col.filter.value) {
4416
4445
  if (!buckets.some(b => b.val === selectedVal)) {
4417
4446
  buckets.push({
@@ -5085,7 +5114,7 @@ let KRTable = class KRTable extends i$2 {
5085
5114
  />
5086
5115
  `;
5087
5116
  }
5088
- else if (column.filter.operator === 'in') {
5117
+ else if (column.filter.operator === 'in' || column.filter.operator === 'n_in') {
5089
5118
  valueInput = b `
5090
5119
  <textarea
5091
5120
  class="filter-panel__textarea"