@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.
@@ -3019,6 +3019,7 @@
3019
3019
  greater_than_equal: { key: 'greater_than_equal', type: 'comparison', dataTypes: ['number', 'date'], label: 'Greater than or equal' },
3020
3020
  between: { key: 'between', type: 'range', dataTypes: ['number', 'date'], label: 'Between' },
3021
3021
  in: { key: 'in', type: 'list', dataTypes: ['string', 'number'], label: 'In' },
3022
+ n_in: { key: 'n_in', type: 'list', dataTypes: ['string', 'number', 'date', 'boolean'], label: 'Not In' },
3022
3023
  empty: { key: 'empty', type: 'nil', dataTypes: ['string', 'number', 'date', 'boolean'], label: 'Empty' },
3023
3024
  n_empty: { key: 'n_empty', type: 'nil', dataTypes: ['string', 'number', 'date', 'boolean'], label: 'Not empty' },
3024
3025
  };
@@ -3351,6 +3352,14 @@
3351
3352
  };
3352
3353
  this.specificity = [getDateSpecificity(rawStart), getDateSpecificity(rawEnd)];
3353
3354
  }
3355
+ else if (kql.startsWith('!(') && kql.endsWith(')')) {
3356
+ this.operator = 'n_in';
3357
+ this.text = kql.substring(2, kql.length - 1).trim();
3358
+ this.value = this.text.split(',')
3359
+ .map(v => v.trim())
3360
+ .map(v => this._parse(v));
3361
+ this.specificity = [getDateSpecificity(this.text)];
3362
+ }
3354
3363
  else if (kql.startsWith('(') && kql.endsWith(')')) {
3355
3364
  this.operator = 'in';
3356
3365
  this.text = kql.substring(1, kql.length - 1).trim();
@@ -3397,7 +3406,7 @@
3397
3406
  this.value = null;
3398
3407
  this.text = '';
3399
3408
  }
3400
- else if (this.operator === 'in') {
3409
+ else if (this.operator === 'in' || this.operator === 'n_in') {
3401
3410
  this.value = [];
3402
3411
  this.text = '';
3403
3412
  }
@@ -3415,7 +3424,7 @@
3415
3424
  this.value = null;
3416
3425
  this.text = '';
3417
3426
  }
3418
- else if (this.operator === 'in') {
3427
+ else if (this.operator === 'in' || this.operator === 'n_in') {
3419
3428
  this.value = [];
3420
3429
  this.text = '';
3421
3430
  }
@@ -3482,14 +3491,14 @@
3482
3491
  if (this.operator === 'between') {
3483
3492
  return !this.value?.start && !this.value?.end;
3484
3493
  }
3485
- if (this.operator === 'in') {
3494
+ if (this.operator === 'in' || this.operator === 'n_in') {
3486
3495
  return !this.value?.length;
3487
3496
  }
3488
3497
  return this.value === undefined || this.value === null || this.value === '';
3489
3498
  }
3490
- /** Returns true if the value array contains the given value. Only applies to 'in' operator. */
3499
+ /** Returns true if the value array contains the given value. Only applies to 'in' and 'n_in' operators. */
3491
3500
  has(val) {
3492
- if (this.operator !== 'in' || !Array.isArray(this.value)) {
3501
+ if ((this.operator !== 'in' && this.operator !== 'n_in') || !Array.isArray(this.value)) {
3493
3502
  return false;
3494
3503
  }
3495
3504
  // Bucket values from Solr arrive as strings ("true"/"false") but
@@ -3504,9 +3513,9 @@
3504
3513
  }
3505
3514
  return this.value.indexOf(val) >= 0;
3506
3515
  }
3507
- /** Adds or removes a value from the 'in' list and rebuilds text/kql. */
3516
+ /** Adds or removes a value from the 'in' or 'n_in' list and rebuilds text/kql. */
3508
3517
  toggle(val) {
3509
- if (this.operator !== 'in') {
3518
+ if (this.operator !== 'in' && this.operator !== 'n_in') {
3510
3519
  this.setOperator('in');
3511
3520
  }
3512
3521
  // Bucket values from Solr arrive as strings ("true"/"false") —
@@ -3545,8 +3554,8 @@
3545
3554
  if (this.operator === 'n_empty') {
3546
3555
  return true;
3547
3556
  }
3548
- // For 'in' operator, valid as long as there's at least one value (including null for empty buckets)
3549
- if (this.operator === 'in') {
3557
+ // For 'in'/'n_in' operator, valid as long as there's at least one value (including null for empty buckets)
3558
+ if (this.operator === 'in' || this.operator === 'n_in') {
3550
3559
  return Array.isArray(this.value) && this.value.length > 0;
3551
3560
  }
3552
3561
  if (this.type === 'date') {
@@ -3690,6 +3699,18 @@
3690
3699
  data.value = termify(this.value, true);
3691
3700
  }
3692
3701
  break;
3702
+ case 'n_in':
3703
+ if (Array.isArray(this.value) && this.value.length > 0) {
3704
+ data.operation = 'EXPRESSION';
3705
+ data.not = true;
3706
+ data.value = `(${this.value.map((v) => termify(v, true)).join(' OR ')})`;
3707
+ }
3708
+ else {
3709
+ data.operation = 'EXPRESSION';
3710
+ data.not = true;
3711
+ data.value = termify(this.value, true);
3712
+ }
3713
+ break;
3693
3714
  default:
3694
3715
  data.operation = 'EXPRESSION';
3695
3716
  data.value = termify(this.value, true);
@@ -3784,6 +3805,11 @@
3784
3805
  params.operation = 'IN';
3785
3806
  params.values = this.value ?? [];
3786
3807
  break;
3808
+ case 'n_in':
3809
+ params.operation = 'IN';
3810
+ params.not = true;
3811
+ params.values = this.value ?? [];
3812
+ break;
3787
3813
  default:
3788
3814
  throw Error(`${this.operator} operator not supported by db params.`);
3789
3815
  }
@@ -3800,7 +3826,7 @@
3800
3826
  if (this.operator === 'between') {
3801
3827
  this.text = `${this._format(this.value?.start)} - ${this._format(this.value?.end)}`;
3802
3828
  }
3803
- else if (this.operator === 'in') {
3829
+ else if (this.operator === 'in' || this.operator === 'n_in') {
3804
3830
  this.text = this.value.map((v) => this._format(v)).join(',');
3805
3831
  }
3806
3832
  else {
@@ -4014,6 +4040,9 @@
4014
4040
  case 'in':
4015
4041
  this.kql = `(${this.value.map((v) => this._format(v)).join(',')})`;
4016
4042
  break;
4043
+ case 'n_in':
4044
+ this.kql = `!(${this.value.map((v) => this._format(v)).join(',')})`;
4045
+ break;
4017
4046
  default:
4018
4047
  throw Error(`Unknown operator ${this.operator}`);
4019
4048
  }
@@ -4265,7 +4294,7 @@
4265
4294
  continue;
4266
4295
  }
4267
4296
  const filterData = col.filter.toSolrData();
4268
- if (col.facetable && col.filter.operator === 'in') {
4297
+ if (col.facetable && (col.filter.operator === 'in' || col.filter.operator === 'n_in')) {
4269
4298
  filterData.tagged = true;
4270
4299
  }
4271
4300
  request.filterFields.push(filterData);
@@ -4417,7 +4446,7 @@
4417
4446
  }
4418
4447
  }
4419
4448
  // Bucket sync: ensure selected values appear even with 0 results
4420
- if (col.filter && col.filter.operator === 'in' && Array.isArray(col.filter.value)) {
4449
+ if (col.filter && (col.filter.operator === 'in' || col.filter.operator === 'n_in') && Array.isArray(col.filter.value)) {
4421
4450
  for (const selectedVal of col.filter.value) {
4422
4451
  if (!buckets.some(b => b.val === selectedVal)) {
4423
4452
  buckets.push({
@@ -5091,7 +5120,7 @@
5091
5120
  />
5092
5121
  `;
5093
5122
  }
5094
- else if (column.filter.operator === 'in') {
5123
+ else if (column.filter.operator === 'in' || column.filter.operator === 'n_in') {
5095
5124
  valueInput = b `
5096
5125
  <textarea
5097
5126
  class="filter-panel__textarea"