@momentum-design/components 0.83.1 → 0.83.2
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.
- package/dist/browser/index.js +6 -6
- package/dist/browser/index.js.map +3 -3
- package/dist/components/popover/popover.component.d.ts +13 -0
- package/dist/components/popover/popover.component.js +29 -6
- package/dist/components/popover/popover.constants.d.ts +1 -0
- package/dist/components/popover/popover.constants.js +1 -0
- package/dist/custom-elements.json +1342 -1210
- package/dist/react/index.d.ts +5 -5
- package/dist/react/index.js +5 -5
- package/dist/utils/mixins/FocusTrapMixin.js +11 -8
- package/package.json +1 -1
@@ -123,6 +123,17 @@ declare class Popover extends Popover_base {
|
|
123
123
|
* @default false
|
124
124
|
*/
|
125
125
|
hideOnEscape: boolean;
|
126
|
+
/**
|
127
|
+
* Propagates the event, when the escape key is pressed (only when pressed inside the popover)
|
128
|
+
* If true, the escape key press close the popover and will propagate the keydown event.
|
129
|
+
* If false, the escape key press will close the popover but will not propagate the keydown event.
|
130
|
+
* (set to false to prevent the event from bubbling up to the document).
|
131
|
+
*
|
132
|
+
* This only works when `hideOnEscape` is true.
|
133
|
+
*
|
134
|
+
* @default false
|
135
|
+
*/
|
136
|
+
propagateEventOnEscape: boolean;
|
126
137
|
/**
|
127
138
|
* Hide popover on blur.
|
128
139
|
* @default false
|
@@ -231,6 +242,8 @@ declare class Popover extends Popover_base {
|
|
231
242
|
/**
|
232
243
|
* Handles the escape keydown event to close the popover.
|
233
244
|
*
|
245
|
+
* This method is attached to the document.
|
246
|
+
*
|
234
247
|
* @param event - The keyboard event.
|
235
248
|
*/
|
236
249
|
private onEscapeKeydown;
|
@@ -141,6 +141,17 @@ class Popover extends FocusTrapMixin(Component) {
|
|
141
141
|
* @default false
|
142
142
|
*/
|
143
143
|
this.hideOnEscape = DEFAULTS.HIDE_ON_ESCAPE;
|
144
|
+
/**
|
145
|
+
* Propagates the event, when the escape key is pressed (only when pressed inside the popover)
|
146
|
+
* If true, the escape key press close the popover and will propagate the keydown event.
|
147
|
+
* If false, the escape key press will close the popover but will not propagate the keydown event.
|
148
|
+
* (set to false to prevent the event from bubbling up to the document).
|
149
|
+
*
|
150
|
+
* This only works when `hideOnEscape` is true.
|
151
|
+
*
|
152
|
+
* @default false
|
153
|
+
*/
|
154
|
+
this.propagateEventOnEscape = DEFAULTS.PROPAGATE_EVENT_ON_ESCAPE;
|
144
155
|
/**
|
145
156
|
* Hide popover on blur.
|
146
157
|
* @default false
|
@@ -240,12 +251,18 @@ class Popover extends FocusTrapMixin(Component) {
|
|
240
251
|
/**
|
241
252
|
* Handles the escape keydown event to close the popover.
|
242
253
|
*
|
254
|
+
* This method is attached to the document.
|
255
|
+
*
|
243
256
|
* @param event - The keyboard event.
|
244
257
|
*/
|
245
258
|
this.onEscapeKeydown = (event) => {
|
246
259
|
if (!this.visible || event.code !== 'Escape') {
|
247
260
|
return;
|
248
261
|
}
|
262
|
+
if (!this.propagateEventOnEscape) {
|
263
|
+
// If propagateEventOnEscape is false, we don't want to allow the event to bubble up
|
264
|
+
event.stopPropagation();
|
265
|
+
}
|
249
266
|
event.preventDefault();
|
250
267
|
this.hidePopover();
|
251
268
|
};
|
@@ -446,7 +463,7 @@ class Popover extends FocusTrapMixin(Component) {
|
|
446
463
|
* @param newValue - The new value of the visible property.
|
447
464
|
*/
|
448
465
|
async isOpenUpdated(oldValue, newValue) {
|
449
|
-
var _a, _b, _c;
|
466
|
+
var _a, _b, _c, _d, _e;
|
450
467
|
if (oldValue === newValue || !this.triggerElement) {
|
451
468
|
return;
|
452
469
|
}
|
@@ -471,7 +488,8 @@ class Popover extends FocusTrapMixin(Component) {
|
|
471
488
|
document.addEventListener('click', this.onOutsidePopoverClick);
|
472
489
|
}
|
473
490
|
if (this.hideOnEscape) {
|
474
|
-
|
491
|
+
this.addEventListener('keydown', this.onEscapeKeydown);
|
492
|
+
(_a = this.triggerElement) === null || _a === void 0 ? void 0 : _a.addEventListener('keydown', this.onEscapeKeydown);
|
475
493
|
}
|
476
494
|
PopoverEventManager.onShowPopover(this);
|
477
495
|
}
|
@@ -480,7 +498,7 @@ class Popover extends FocusTrapMixin(Component) {
|
|
480
498
|
popoverStack.pop();
|
481
499
|
}
|
482
500
|
if (this.backdropElement) {
|
483
|
-
(
|
501
|
+
(_b = this.backdropElement) === null || _b === void 0 ? void 0 : _b.remove();
|
484
502
|
this.backdropElement = null;
|
485
503
|
}
|
486
504
|
if (this.hideOnBlur) {
|
@@ -493,9 +511,10 @@ class Popover extends FocusTrapMixin(Component) {
|
|
493
511
|
document.removeEventListener('click', this.onOutsidePopoverClick);
|
494
512
|
}
|
495
513
|
if (this.hideOnEscape) {
|
496
|
-
|
514
|
+
this.removeEventListener('keydown', this.onEscapeKeydown);
|
515
|
+
(_c = this.triggerElement) === null || _c === void 0 ? void 0 : _c.removeEventListener('keydown', this.onEscapeKeydown);
|
497
516
|
}
|
498
|
-
(
|
517
|
+
(_d = this.deactivateFocusTrap) === null || _d === void 0 ? void 0 : _d.call(this);
|
499
518
|
if (!this.disableAriaExpanded) {
|
500
519
|
this.triggerElement.removeAttribute('aria-expanded');
|
501
520
|
}
|
@@ -504,7 +523,7 @@ class Popover extends FocusTrapMixin(Component) {
|
|
504
523
|
this.triggerElement.removeAttribute('aria-haspopup');
|
505
524
|
}
|
506
525
|
if (this.focusBackToTrigger) {
|
507
|
-
(
|
526
|
+
(_e = this.triggerElement) === null || _e === void 0 ? void 0 : _e.focus();
|
508
527
|
}
|
509
528
|
PopoverEventManager.onHidePopover(this);
|
510
529
|
}
|
@@ -651,6 +670,10 @@ __decorate([
|
|
651
670
|
property({ type: Boolean, reflect: true, attribute: 'hide-on-escape' }),
|
652
671
|
__metadata("design:type", Boolean)
|
653
672
|
], Popover.prototype, "hideOnEscape", void 0);
|
673
|
+
__decorate([
|
674
|
+
property({ type: Boolean, reflect: true, attribute: 'propagate-event-on-escape' }),
|
675
|
+
__metadata("design:type", Boolean)
|
676
|
+
], Popover.prototype, "propagateEventOnEscape", void 0);
|
654
677
|
__decorate([
|
655
678
|
property({ type: Boolean, reflect: true, attribute: 'hide-on-blur' }),
|
656
679
|
__metadata("design:type", Boolean)
|