@momentum-design/components 0.92.1 → 0.92.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.
@@ -88,10 +88,41 @@ declare class Popover extends Popover_base {
88
88
  */
89
89
  offset: number;
90
90
  /**
91
- *Virtual padding around the boundary to check for overflow.
92
- * @default 16
91
+ * This describes the clipping element(s) or area that overflow will be checked relative to.
92
+ * The default is 'clippingAncestors', which are the overflow ancestors which will cause the
93
+ * element to be clipped.
94
+ *
95
+ * Possible values:
96
+ * - 'clippingAncestors'
97
+ * - any css selector
98
+ *
99
+ * @default 'clippingAncestors'
100
+ *
101
+ * @see [Floating UI - boundary](https://floating-ui.com/docs/detectOverflow#boundary)
102
+ */
103
+ boundary: 'clippingAncestors' | string;
104
+ /**
105
+ * This describes the root boundary that the element will be checked for overflow relative to.
106
+ * The default is 'viewport', which is the area of the page the user can see on the screen.
107
+ *
108
+ * The other string option is 'document', which is the entire page outside the viewport.
109
+ *
110
+ * @default 'viewport'
111
+ *
112
+ * @see [Floating UI - rootBoundary](https://floating-ui.com/docs/detectOverflow#rootboundary)
113
+ */
114
+ boundaryRoot: 'viewport' | 'document';
115
+ /**
116
+ * Virtual padding around the boundary to check for overflow.
117
+ * So the popover will not be placed on top of the edge of the boundary.
118
+ *
119
+ * Default works well for most cases, but you can set this to customise it when necessary.
120
+ *
121
+ * @default undefined
122
+ *
123
+ * @see [Floating UI - padding](https://floating-ui.com/docs/detectOverflow#padding)
93
124
  */
94
- boundaryPadding: number;
125
+ boundaryPadding: undefined | number;
95
126
  /**
96
127
  * Determines whether the focus trap is enabled.
97
128
  * If true, focus will be restricted to the content within this component.
@@ -107,10 +107,30 @@ class Popover extends PreventScrollMixin(FocusTrapMixin(Component)) {
107
107
  */
108
108
  this.offset = DEFAULTS.OFFSET;
109
109
  /**
110
- *Virtual padding around the boundary to check for overflow.
111
- * @default 16
110
+ * This describes the clipping element(s) or area that overflow will be checked relative to.
111
+ * The default is 'clippingAncestors', which are the overflow ancestors which will cause the
112
+ * element to be clipped.
113
+ *
114
+ * Possible values:
115
+ * - 'clippingAncestors'
116
+ * - any css selector
117
+ *
118
+ * @default 'clippingAncestors'
119
+ *
120
+ * @see [Floating UI - boundary](https://floating-ui.com/docs/detectOverflow#boundary)
121
+ */
122
+ this.boundary = DEFAULTS.BOUNDARY;
123
+ /**
124
+ * This describes the root boundary that the element will be checked for overflow relative to.
125
+ * The default is 'viewport', which is the area of the page the user can see on the screen.
126
+ *
127
+ * The other string option is 'document', which is the entire page outside the viewport.
128
+ *
129
+ * @default 'viewport'
130
+ *
131
+ * @see [Floating UI - rootBoundary](https://floating-ui.com/docs/detectOverflow#rootboundary)
112
132
  */
113
- this.boundaryPadding = DEFAULTS.BOUNDARY_PADDING;
133
+ this.boundaryRoot = DEFAULTS.BOUNDARY_ROOT;
114
134
  /**
115
135
  * Determines whether the focus trap is enabled.
116
136
  * If true, focus will be restricted to the content within this component.
@@ -622,7 +642,15 @@ class Popover extends PreventScrollMixin(FocusTrapMixin(Component)) {
622
642
  positionPopover() {
623
643
  if (!this.triggerElement)
624
644
  return;
625
- const middleware = [shift({ padding: this.boundaryPadding })];
645
+ const middleware = [
646
+ shift({
647
+ boundary: !this.boundary || this.boundary === 'clippingAncestors'
648
+ ? 'clippingAncestors'
649
+ : Array.from(document.querySelectorAll(this.boundary)),
650
+ rootBoundary: this.boundaryRoot,
651
+ padding: this.boundaryPadding,
652
+ }),
653
+ ];
626
654
  let popoverOffset = this.offset;
627
655
  if (this.flip) {
628
656
  middleware.push(flip());
@@ -730,9 +758,17 @@ __decorate([
730
758
  property({ type: Number, reflect: true }),
731
759
  __metadata("design:type", Number)
732
760
  ], Popover.prototype, "offset", void 0);
761
+ __decorate([
762
+ property({ type: String, reflect: true, attribute: 'boundary' }),
763
+ __metadata("design:type", String)
764
+ ], Popover.prototype, "boundary", void 0);
765
+ __decorate([
766
+ property({ type: String, reflect: true, attribute: 'boundary-root' }),
767
+ __metadata("design:type", String)
768
+ ], Popover.prototype, "boundaryRoot", void 0);
733
769
  __decorate([
734
770
  property({ type: Number, reflect: true, attribute: 'boundary-padding' }),
735
- __metadata("design:type", Number)
771
+ __metadata("design:type", Object)
736
772
  ], Popover.prototype, "boundaryPadding", void 0);
737
773
  __decorate([
738
774
  property({ type: Boolean, reflect: true, attribute: 'focus-trap' }),
@@ -28,7 +28,9 @@ declare const DEFAULTS: {
28
28
  readonly TRIGGER: "click";
29
29
  readonly COLOR: "tonal";
30
30
  readonly OFFSET: 4;
31
- readonly BOUNDARY_PADDING: 16;
31
+ readonly BOUNDARY: "clippingAncestors";
32
+ readonly BOUNDARY_ROOT: "viewport";
33
+ readonly BOUNDARY_PADDING: 0;
32
34
  readonly VISIBLE: false;
33
35
  readonly ARROW: false;
34
36
  readonly CLOSE_BUTTON: false;
@@ -29,7 +29,9 @@ const DEFAULTS = {
29
29
  TRIGGER: TRIGGER.CLICK,
30
30
  COLOR: COLOR.TONAL,
31
31
  OFFSET: 4,
32
- BOUNDARY_PADDING: 16,
32
+ BOUNDARY: 'clippingAncestors',
33
+ BOUNDARY_ROOT: 'viewport',
34
+ BOUNDARY_PADDING: 0,
33
35
  VISIBLE: false,
34
36
  ARROW: false,
35
37
  CLOSE_BUTTON: false,