slick-components 17.0.81 → 17.0.83

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.
@@ -23,7 +23,7 @@ class SlickInitParams {
23
23
  }
24
24
  }
25
25
  class SlickInitService {
26
- static { this.version = "17.0.81"; }
26
+ static { this.version = "17.0.83"; }
27
27
  constructor() { }
28
28
  static init(initParams) {
29
29
  console.info(`Slick Components Version ${SlickInitService.version}`);
@@ -2857,19 +2857,30 @@ class SlickDragDropDirective {
2857
2857
  this.itemDropped = new EventEmitter();
2858
2858
  this.dragEntered = new EventEmitter();
2859
2859
  this.dragLeft = new EventEmitter();
2860
+ this.dragCounter = 0;
2860
2861
  }
2861
2862
  onDragOver(event) {
2862
2863
  event.preventDefault();
2863
2864
  }
2864
2865
  onDragEnter(event) {
2865
2866
  event.preventDefault();
2866
- this.dragEntered.emit();
2867
+ this.dragCounter++;
2868
+ if (this.dragCounter === 1) {
2869
+ this.renderer.setStyle(this.el.nativeElement, 'background-color', 'rgba(var(--bs-primary-rgb), 0.05)');
2870
+ this.dragEntered.emit();
2871
+ }
2867
2872
  }
2868
2873
  onDragLeave(event) {
2869
- this.dragLeft.emit();
2874
+ this.dragCounter--;
2875
+ if (this.dragCounter === 0) {
2876
+ this.renderer.removeStyle(this.el.nativeElement, 'background-color');
2877
+ this.dragLeft.emit();
2878
+ }
2870
2879
  }
2871
2880
  onDrop(event) {
2872
2881
  event.preventDefault();
2882
+ this.dragCounter = 0;
2883
+ this.renderer.removeStyle(this.el.nativeElement, 'background-color');
2873
2884
  if (!event.dataTransfer)
2874
2885
  return;
2875
2886
  const slickData = event.dataTransfer.getData('application/x-slick-draggable');
@@ -3257,13 +3268,14 @@ class SlickDropDownComponent {
3257
3268
  return;
3258
3269
  this.isVisible = true;
3259
3270
  this.changeDetector.detectChanges();
3260
- SlickUtilsService.attachElement(this.dropdownList.nativeElement, this.attachTo);
3271
+ const dropdownEl = this.dropdownList.nativeElement;
3272
+ SlickUtilsService.attachElement(dropdownEl, 'body');
3273
+ dropdownEl.style.position = 'absolute';
3274
+ dropdownEl.style.display = 'block';
3275
+ dropdownEl.style.visibility = 'hidden';
3276
+ await new Promise(r => requestAnimationFrame(r)); // ensure layout
3261
3277
  this.reposition();
3262
- await SlickSleepService.sleep();
3263
- this.dropdownList.nativeElement.style.display = "inline-block";
3264
- const selectedItems = this.dropdownList.nativeElement.getElementsByClassName("active");
3265
- if (selectedItems && selectedItems.length > 0)
3266
- selectedItems[0].scrollIntoView({ block: 'nearest' });
3278
+ dropdownEl.style.visibility = 'visible';
3267
3279
  this.expanded = true;
3268
3280
  // This is necessary, otherwise `this` in the reposition function will be window
3269
3281
  // and not the component.
@@ -3283,21 +3295,25 @@ class SlickDropDownComponent {
3283
3295
  this.isVisible = false;
3284
3296
  }
3285
3297
  reposition() {
3286
- const dropDownRect = this.containerDiv.nativeElement.getBoundingClientRect();
3287
- const parentRect = (this.attachTo === 'body') ? null : document.body.querySelector(this.attachTo).getBoundingClientRect();
3288
- const containerLeft = (this.attachTo === 'body') ? dropDownRect.left : (dropDownRect.left - parentRect.left);
3289
- const containerTop = (this.attachTo === 'body') ? dropDownRect.top : (dropDownRect.top - parentRect.top);
3290
- const containerHeight = this.containerDiv.nativeElement.offsetHeight;
3291
- const containerWidth = dropDownRect.width;
3292
- this.width = containerWidth;
3293
- if (this.listWidth === '100%')
3294
- this.listGroupWidth = this.width;
3295
- else if (this.listWidth === 'auto')
3296
- this.listGroupWidth = "auto";
3297
- else
3298
- this.listGroupWidth = this.listWidth;
3299
- this.top = (containerTop + containerHeight);
3300
- this.left = containerLeft;
3298
+ const dropdownEl = this.dropdownList.nativeElement;
3299
+ const containerEl = this.containerDiv.nativeElement;
3300
+ const rect = containerEl.getBoundingClientRect();
3301
+ const dropdownHeight = dropdownEl.offsetHeight;
3302
+ const scrollY = window.pageYOffset;
3303
+ const scrollX = window.pageXOffset;
3304
+ const spaceBelow = window.innerHeight - rect.bottom;
3305
+ let top;
3306
+ // If enough space below show below
3307
+ if (spaceBelow >= dropdownHeight) {
3308
+ top = rect.bottom + scrollY;
3309
+ }
3310
+ // Otherwise show above
3311
+ else {
3312
+ top = rect.top + scrollY - dropdownHeight;
3313
+ }
3314
+ dropdownEl.style.top = top + 'px';
3315
+ dropdownEl.style.left = (rect.left + scrollX) + 'px';
3316
+ dropdownEl.style.width = rect.width + 'px';
3301
3317
  }
3302
3318
  async documentClick(e) {
3303
3319
  // Not entirely sure why, but iPhones call onFocus when clicking out of the dropdown