bromcom-ui 2.4.11 → 2.4.14

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.
@@ -469,14 +469,19 @@ export class BcmSelect {
469
469
  this.captionTypeCache = this.captionType;
470
470
  }
471
471
  handleChange(newValue, oldValue) {
472
- if (oldValue != newValue) {
472
+ const newVal = newValue ? newValue : null;
473
+ const oldVal = oldValue ? oldValue : null;
474
+ if (oldVal != newVal) {
473
475
  if (this.checkboxes == true) {
474
- this.change.emit(newValue);
476
+ this.change.emit(newVal);
475
477
  }
476
478
  else {
477
- if (!oldValue || (newValue[this.objectMapping['id']] != oldValue[this.objectMapping['id']])) {
479
+ if (!oldVal || (newVal && (newVal[this.objectMapping['id']] != oldVal[this.objectMapping['id']]))) {
478
480
  // await delay(10)
479
- this.change.emit(newValue);
481
+ this.change.emit(newVal);
482
+ }
483
+ if (!newVal) {
484
+ this.change.emit(newVal);
480
485
  }
481
486
  }
482
487
  }
@@ -18688,11 +18688,15 @@
18688
18688
  border-color: var(--bcm-color-prime-blue-5);
18689
18689
  box-shadow: 0px 0px 4px var(--bcm-color-prime-blue-6);
18690
18690
  }
18691
+ .bcm-list__item {
18692
+ padding: 2px 8px;
18693
+ }
18691
18694
  .bcm-list__item:focus {
18692
- border: 2px solid #000000;
18695
+ outline: none;
18693
18696
  }
18694
- .bcm-list__item.focused {
18695
- border: 2px solid #000000;
18697
+ .bcm-list__item:focus .bcm-list__item-content {
18698
+ color: var(--bcm-color-grey-8);
18699
+ background-color: var(--bcm-color-prime-blue-1);
18696
18700
  }
18697
18701
  .bcm-list__item-content {
18698
18702
  display: flex;
@@ -18701,7 +18705,6 @@
18701
18705
  align-items: stretch;
18702
18706
  cursor: pointer;
18703
18707
  padding: 0;
18704
- margin: 0 8px;
18705
18708
  color: var(--bcm-color-grey-8);
18706
18709
  background-color: var(--bcm-color-grey-1);
18707
18710
  }
@@ -209,6 +209,7 @@ export class BcmList {
209
209
  }
210
210
  async handleOpen() {
211
211
  if (this.isOpen) {
212
+ this.calculateLocation();
212
213
  this.onSelectSearch();
213
214
  }
214
215
  else {
@@ -626,36 +627,50 @@ export class BcmList {
626
627
  if (this.keyControl) {
627
628
  const focusedList = Generate.findEventPath(ev, this.el);
628
629
  if (focusedList) {
629
- if (this.type === 'select' && !this.isOpen) {
630
- if (keycode === Bcm.KeyCode.enter || keycode === Bcm.KeyCode.space) {
631
- this.isOpen = true;
630
+ const keyCode = ev.keyCode || ev.which;
631
+ const keyList = [
632
+ [Bcm.KeyCode.up],
633
+ [Bcm.KeyCode.down],
634
+ [Bcm.KeyCode.enter],
635
+ [Bcm.KeyCode.space],
636
+ [Bcm.KeyCode.left],
637
+ [Bcm.KeyCode.right]
638
+ ];
639
+ if (keyList.some(key => key.includes(keyCode))) {
640
+ ev.preventDefault();
641
+ ev.stopPropagation();
642
+ ev.stopImmediatePropagation();
643
+ if (this.type === 'select' && !this.isOpen) {
644
+ if (keycode === Bcm.KeyCode.enter || keycode === Bcm.KeyCode.space) {
645
+ this.isOpen = true;
646
+ }
632
647
  }
633
- }
634
- else {
635
- const list = document.getElementById(`bcm-list-${this._id}`);
636
- if (list) {
637
- const items = list.querySelectorAll('.bcm-list__item');
638
- if (items.length > 0) {
639
- const selectedItem = list.querySelector('.bcm-list__item.focused');
640
- if (selectedItem) {
641
- const selectedIndex = Array.prototype.indexOf.call(items, selectedItem);
642
- if (ev.key === 'ArrowDown') {
643
- if (selectedIndex < items.length - 1) {
644
- items[selectedIndex + 1].focus();
648
+ else {
649
+ const list = document.getElementById(`bcm-list-${this._id}`);
650
+ if (list) {
651
+ const items = list.querySelectorAll('.bcm-list__item');
652
+ if (items.length > 0) {
653
+ const selectedItem = list.querySelector('.bcm-list__item.focused');
654
+ if (selectedItem) {
655
+ const selectedIndex = Array.prototype.indexOf.call(items, selectedItem);
656
+ if (ev.key === 'ArrowDown') {
657
+ if (selectedIndex < items.length - 1) {
658
+ items[selectedIndex + 1].focus();
659
+ }
645
660
  }
646
- }
647
- else if (ev.key === 'ArrowUp') {
648
- if (selectedIndex > 0) {
649
- items[selectedIndex - 1].focus();
661
+ else if (ev.key === 'ArrowUp') {
662
+ if (selectedIndex > 0) {
663
+ items[selectedIndex - 1].focus();
664
+ }
665
+ }
666
+ else if (ev.key === 'Enter') {
667
+ this.selectedItem(selectedItem.id);
650
668
  }
651
669
  }
652
- else if (ev.key === 'Enter') {
653
- this.selectedItem(selectedItem);
670
+ else {
671
+ items[0].focus();
654
672
  }
655
673
  }
656
- else {
657
- items[0].focus();
658
- }
659
674
  }
660
675
  }
661
676
  }
@@ -666,38 +681,20 @@ export class BcmList {
666
681
  if (this.keyControl) {
667
682
  const focusedList = Generate.findEventPath(ev, this.el);
668
683
  if (focusedList) {
669
- const keycode = ev.keyCode || ev.which;
670
- if (keycode === Bcm.KeyCode.escape) {
671
- //unfocused element
672
- const list = document.getElementById(`bcm-list-${this._id}`);
673
- if (list) {
674
- const items = list.querySelectorAll('.bcm-list__item');
675
- if (items.length > 0) {
676
- items[0].focus();
677
- }
678
- }
679
- }
680
- const goToScroll = (item, list) => {
681
- const main = list.querySelector('main');
682
- const itemHeight = item.offsetHeight;
683
- const listHeight = main.offsetHeight;
684
- const itemTop = item.offsetTop;
685
- // console.log(item.offsetTop)
686
- const listTop = main.scrollTop;
687
- const listBottom = listTop + listHeight;
688
- if (itemTop < listTop) {
689
- main.scrollTop = itemTop;
690
- }
691
- else if (itemTop > listBottom) {
692
- main.scrollTop = itemTop - listHeight + itemHeight;
693
- }
694
- // console.log(main.scrollTop)
695
- };
696
684
  const list = document.getElementById(`bcm-list-${this._id}`);
697
685
  if (list) {
698
686
  const items = list.querySelectorAll('.bcm-list__item.focused');
699
687
  if (items.length > 0) {
700
- goToScroll(items[0], list);
688
+ const main = list.querySelector('main');
689
+ const itemHeight = items[0].offsetHeight;
690
+ const listHeight = main.offsetHeight;
691
+ const itemTop = items[0].offsetTop;
692
+ if (itemTop > listHeight) {
693
+ main.scrollTop = itemTop - (listHeight / 2) + (itemHeight / 2);
694
+ }
695
+ if (itemTop < listHeight) {
696
+ main.scrollTop = itemTop - (listHeight / 2) - (itemHeight / 2);
697
+ }
701
698
  }
702
699
  }
703
700
  }
@@ -11014,14 +11014,19 @@ const BcmSelect = class {
11014
11014
  this.captionTypeCache = this.captionType;
11015
11015
  }
11016
11016
  handleChange(newValue, oldValue) {
11017
- if (oldValue != newValue) {
11017
+ const newVal = newValue ? newValue : null;
11018
+ const oldVal = oldValue ? oldValue : null;
11019
+ if (oldVal != newVal) {
11018
11020
  if (this.checkboxes == true) {
11019
- this.change.emit(newValue);
11021
+ this.change.emit(newVal);
11020
11022
  }
11021
11023
  else {
11022
- if (!oldValue || (newValue[this.objectMapping['id']] != oldValue[this.objectMapping['id']])) {
11024
+ if (!oldVal || (newVal && (newVal[this.objectMapping['id']] != oldVal[this.objectMapping['id']]))) {
11023
11025
  // await delay(10)
11024
- this.change.emit(newValue);
11026
+ this.change.emit(newVal);
11027
+ }
11028
+ if (!newVal) {
11029
+ this.change.emit(newVal);
11025
11030
  }
11026
11031
  }
11027
11032
  }