@dereekb/dbx-web 9.23.11 → 9.23.13

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.
@@ -15,7 +15,7 @@ import * as i3 from '@angular/material/progress-spinner';
15
15
  import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
16
16
  import * as i2$1 from '@angular/material/icon';
17
17
  import { MatIconModule } from '@angular/material/icon';
18
- import { getValueFromGetter, mergeObjects, splitCommaSeparatedStringToSet, objectHasNoKeys, modifier, combineMaps, addModifiers, removeModifiers, applyBestFit, isMaybeNot, isNotNullOrEmptyString, filterMaybeValues, mapIterable, toReadableError, isDefaultReadableError, build, ServerErrorResponse, UnauthorizedServerErrorResponse, maybeModifierMapToFunction, ModelRelationUtility, encodeModelKeyTypePair, useIterableOrValue } from '@dereekb/util';
18
+ import { getValueFromGetter, mergeObjects, splitCommaSeparatedStringToSet, asPromise, objectHasNoKeys, modifier, combineMaps, addModifiers, removeModifiers, applyBestFit, isMaybeNot, isNotNullOrEmptyString, filterMaybeValues, mapIterable, toReadableError, isDefaultReadableError, build, ServerErrorResponse, UnauthorizedServerErrorResponse, maybeModifierMapToFunction, ModelRelationUtility, encodeModelKeyTypePair, useIterableOrValue } from '@dereekb/util';
19
19
  import * as i3$1 from '@angular/material/progress-bar';
20
20
  import { MatProgressBarModule } from '@angular/material/progress-bar';
21
21
  import * as i5 from '@angular/material/core';
@@ -1539,6 +1539,20 @@ class DbxPopoverComponent extends AbstractTransitionWatcherDirective {
1539
1539
  originalClose.call(this.popoverRef, x);
1540
1540
  }
1541
1541
  };
1542
+ // Also intercept the _close function to capture backdropClose, etc.
1543
+ const original_close = this.popoverRef._close;
1544
+ this.popoverRef._close = (closeType, inputValue) => {
1545
+ const closeWithValue = (value) => {
1546
+ original_close.call(this.popoverRef, closeType, value);
1547
+ };
1548
+ if (closeType === 'close' || inputValue != null) {
1549
+ closeWithValue(inputValue);
1550
+ }
1551
+ else {
1552
+ // expected to be a backdrop close. Get the closing value then close.
1553
+ this._useClosingValue(closeType, (x) => closeWithValue(x));
1554
+ }
1555
+ };
1542
1556
  // eslint-disable-next-line
1543
1557
  const overlay = popoverRef._overlay; // overlay is not publically accessible
1544
1558
  const elementRef = this.config.origin;
@@ -1578,12 +1592,8 @@ class DbxPopoverComponent extends AbstractTransitionWatcherDirective {
1578
1592
  }
1579
1593
  // Popover Controls
1580
1594
  close() {
1581
- if (!this._startedClosing && this.getClosingValueFn) {
1582
- this.getClosingValueFn().then((x) => {
1583
- this.return(x);
1584
- }, () => {
1585
- this.return();
1586
- });
1595
+ if (!this._startedClosing && this.getClosingValueFn != null) {
1596
+ this._useClosingValue('close', (x) => this.return(x));
1587
1597
  }
1588
1598
  else {
1589
1599
  this.return();
@@ -1593,6 +1603,18 @@ class DbxPopoverComponent extends AbstractTransitionWatcherDirective {
1593
1603
  this._closing.next();
1594
1604
  this.popoverRef.close(value);
1595
1605
  }
1606
+ _useClosingValue(closeType, useValue) {
1607
+ if (this.getClosingValueFn != null) {
1608
+ asPromise(this.getClosingValueFn(this.data, closeType)).then((x) => {
1609
+ useValue(x);
1610
+ }, () => {
1611
+ useValue();
1612
+ });
1613
+ }
1614
+ else {
1615
+ useValue();
1616
+ }
1617
+ }
1596
1618
  // Keypresses
1597
1619
  handleKeydown() {
1598
1620
  this.close();