@progressio_resources/gravity-design-system 4.1.6 → 4.1.7

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.
@@ -6169,11 +6169,17 @@ class GravityAvatarStackComponent {
6169
6169
  this.stepThreshold = 30;
6170
6170
  this.touchStartIndex = 0;
6171
6171
  this.isTouchActive = false;
6172
+ this.emitDebounceTimer = null;
6173
+ }
6174
+ ngOnDestroy() {
6175
+ if (this.emitDebounceTimer) {
6176
+ clearTimeout(this.emitDebounceTimer);
6177
+ }
6172
6178
  }
6173
6179
  onItemClick(index) {
6174
6180
  if (this.isDragging)
6175
6181
  return;
6176
- this.selectItem(index);
6182
+ this.selectItem(index, true);
6177
6183
  }
6178
6184
  get isCarousel() {
6179
6185
  return this.size === 'xl';
@@ -6221,7 +6227,7 @@ class GravityAvatarStackComponent {
6221
6227
  getItemLabel(item) {
6222
6228
  return this.config?.label && item?.[this.config.label] ? item[this.config.label] : '';
6223
6229
  }
6224
- selectItem(index) {
6230
+ selectItem(index, immediateEmit = false) {
6225
6231
  if (!this.items?.length || this.selectionMode === 'none')
6226
6232
  return;
6227
6233
  if (this.selectionMode === 'multiple' && !this.isCarousel) {
@@ -6234,7 +6240,22 @@ class GravityAvatarStackComponent {
6234
6240
  this.selectedIndex = index;
6235
6241
  this.selectedIndexes = [index];
6236
6242
  }
6237
- this.clickOnIcon.emit(this.selectedItems);
6243
+ this.emitSelectedItems(immediateEmit);
6244
+ }
6245
+ emitSelectedItems(immediateEmit = false) {
6246
+ if (this.emitDebounceTimer) {
6247
+ clearTimeout(this.emitDebounceTimer);
6248
+ this.emitDebounceTimer = null;
6249
+ }
6250
+ if (immediateEmit || !this.isCarousel) {
6251
+ this.clickOnIcon.emit(this.selectedItems);
6252
+ }
6253
+ else {
6254
+ this.emitDebounceTimer = setTimeout(() => {
6255
+ this.clickOnIcon.emit(this.selectedItems);
6256
+ this.emitDebounceTimer = null;
6257
+ }, 1000);
6258
+ }
6238
6259
  }
6239
6260
  selectNext() {
6240
6261
  if (this.items?.length)