@nectary/components 5.51.0 → 5.51.1

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/bundle.js CHANGED
@@ -3687,7 +3687,7 @@ const enableOverscroll = () => {
3687
3687
  document.documentElement.style.removeProperty("overscroll-behavior");
3688
3688
  }
3689
3689
  };
3690
- const templateHTML$Z = '<style>:host{display:contents;position:relative}dialog{position:fixed;left:0;top:0;transform:translate(var(--sinch-pop-offset-x),var(--sinch-pop-offset-y));margin:0;outline:0;padding:0;border:none;box-sizing:border-box;max-width:unset;max-height:unset;z-index:var(--sinch-comp-pop-z-index,1);background:0 0;overflow:visible}dialog:not([open]){display:none}:host(:not([open])) slot[name=content]{display:none}dialog::backdrop{background-color:transparent}#backdrop{display:none;position:fixed;inset:0;margin:0;border:none;padding:0;background:0 0;pointer-events:auto;z-index:0}dialog[data-modal-backdrop] #backdrop{display:block}#content{position:relative;z-index:var(--sinch-comp-pop-z-index,1)}#target-open{display:flex;flex-direction:column;position:absolute;left:0;top:0;z-index:var(--sinch-comp-pop-z-index,1)}#focus{display:none;position:absolute;width:0;height:0}</style><slot id="target" name="target" aria-haspopup="dialog" aria-expanded="false"></slot><div id="focus"></div><dialog id="dialog"><div id="backdrop"></div><div id="target-open"><slot name="target-open"></slot></div><div id="content"><slot name="content"></slot></div></dialog>';
3690
+ const templateHTML$Z = '<style>:host{display:contents;position:relative}dialog{position:fixed;left:0;top:0;margin:0;outline:0;padding:0;border:none;box-sizing:border-box;max-width:unset;max-height:unset;z-index:var(--sinch-comp-pop-z-index,1);background:0 0;overflow:visible}dialog:not([open]){display:none}:host(:not([open])) slot[name=content]{display:none}dialog::backdrop{background-color:transparent}#backdrop{display:none;position:fixed;inset:0;margin:0;border:none;padding:0;background:0 0;pointer-events:auto;z-index:0}dialog[data-modal-backdrop] #backdrop{display:block}#content{position:relative;z-index:var(--sinch-comp-pop-z-index,1);transform:translate(var(--sinch-pop-offset-x),var(--sinch-pop-offset-y))}#target-open{display:flex;flex-direction:column;position:absolute;left:0;top:0;z-index:var(--sinch-comp-pop-z-index,1)}#focus{display:none;position:absolute;width:0;height:0}</style><slot id="target" name="target" aria-haspopup="dialog" aria-expanded="false"></slot><div id="focus"></div><dialog id="dialog"><div id="backdrop"></div><div id="target-open"><slot name="target-open"></slot></div><div id="content"><slot name="content"></slot></div></dialog>';
3691
3691
  const template$Z = document.createElement("template");
3692
3692
  template$Z.innerHTML = templateHTML$Z;
3693
3693
  class Pop extends NectaryElement {
@@ -5150,6 +5150,24 @@ class Tooltip extends NectaryElement {
5150
5150
  });
5151
5151
  }
5152
5152
  };
5153
+ // Pulls an overlap shift back toward zero until the bubble stays inside the viewport.
5154
+ // Never flips the shift or makes it larger than the overlap correction requested.
5155
+ #keepOverlapOffsetInView(offset, start, end, limit) {
5156
+ if (offset === 0) {
5157
+ return 0;
5158
+ }
5159
+ let next = offset;
5160
+ if (start + next < 0) {
5161
+ next = -start;
5162
+ }
5163
+ if (end + next > limit) {
5164
+ next = limit - end;
5165
+ }
5166
+ if (offset > 0) {
5167
+ return Math.min(offset, Math.max(0, next));
5168
+ }
5169
+ return Math.max(offset, Math.min(0, next));
5170
+ }
5153
5171
  #resolveOverlap(placementContext) {
5154
5172
  const orientation = this.orientation;
5155
5173
  const targetRect = toLocalRect(this.#$pop.footprintRect, placementContext);
@@ -5180,6 +5198,10 @@ class Tooltip extends NectaryElement {
5180
5198
  offsetX = targetRight - leftEdge;
5181
5199
  }
5182
5200
  }
5201
+ if (placementContext.transformedAncestor == null && !getBooleanAttribute(this, "allow-scroll")) {
5202
+ offsetX = this.#keepOverlapOffsetInView(offsetX, leftEdge, rightEdge, placementContext.boundsWidth);
5203
+ offsetY = this.#keepOverlapOffsetInView(offsetY, topEdge, bottomEdge, placementContext.boundsHeight);
5204
+ }
5183
5205
  this.#applyContentOffset(offsetX, offsetY);
5184
5206
  return offsetX !== 0 || offsetY !== 0;
5185
5207
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nectary/components",
3
- "version": "5.51.0",
3
+ "version": "5.51.1",
4
4
  "files": [
5
5
  "**/*/*.css",
6
6
  "**/*/*.json",
package/pop/index.js CHANGED
@@ -8,7 +8,7 @@ import { getReactEventHandler } from "../utils/get-react-event-handler.js";
8
8
  import { isTargetEqual } from "../utils/event-target.js";
9
9
  import { getPlacementContext, toLocalRect } from "../utils/placement.js";
10
10
  import { orientationValues, disableOverscroll, enableOverscroll, getAnchorPosition, clampPosition } from "./utils.js";
11
- const templateHTML = '<style>:host{display:contents;position:relative}dialog{position:fixed;left:0;top:0;transform:translate(var(--sinch-pop-offset-x),var(--sinch-pop-offset-y));margin:0;outline:0;padding:0;border:none;box-sizing:border-box;max-width:unset;max-height:unset;z-index:var(--sinch-comp-pop-z-index,1);background:0 0;overflow:visible}dialog:not([open]){display:none}:host(:not([open])) slot[name=content]{display:none}dialog::backdrop{background-color:transparent}#backdrop{display:none;position:fixed;inset:0;margin:0;border:none;padding:0;background:0 0;pointer-events:auto;z-index:0}dialog[data-modal-backdrop] #backdrop{display:block}#content{position:relative;z-index:var(--sinch-comp-pop-z-index,1)}#target-open{display:flex;flex-direction:column;position:absolute;left:0;top:0;z-index:var(--sinch-comp-pop-z-index,1)}#focus{display:none;position:absolute;width:0;height:0}</style><slot id="target" name="target" aria-haspopup="dialog" aria-expanded="false"></slot><div id="focus"></div><dialog id="dialog"><div id="backdrop"></div><div id="target-open"><slot name="target-open"></slot></div><div id="content"><slot name="content"></slot></div></dialog>';
11
+ const templateHTML = '<style>:host{display:contents;position:relative}dialog{position:fixed;left:0;top:0;margin:0;outline:0;padding:0;border:none;box-sizing:border-box;max-width:unset;max-height:unset;z-index:var(--sinch-comp-pop-z-index,1);background:0 0;overflow:visible}dialog:not([open]){display:none}:host(:not([open])) slot[name=content]{display:none}dialog::backdrop{background-color:transparent}#backdrop{display:none;position:fixed;inset:0;margin:0;border:none;padding:0;background:0 0;pointer-events:auto;z-index:0}dialog[data-modal-backdrop] #backdrop{display:block}#content{position:relative;z-index:var(--sinch-comp-pop-z-index,1);transform:translate(var(--sinch-pop-offset-x),var(--sinch-pop-offset-y))}#target-open{display:flex;flex-direction:column;position:absolute;left:0;top:0;z-index:var(--sinch-comp-pop-z-index,1)}#focus{display:none;position:absolute;width:0;height:0}</style><slot id="target" name="target" aria-haspopup="dialog" aria-expanded="false"></slot><div id="focus"></div><dialog id="dialog"><div id="backdrop"></div><div id="target-open"><slot name="target-open"></slot></div><div id="content"><slot name="content"></slot></div></dialog>';
12
12
  const template = document.createElement("template");
13
13
  template.innerHTML = templateHTML;
14
14
  class Pop extends NectaryElement {
package/tooltip/index.js CHANGED
@@ -696,6 +696,24 @@ class Tooltip extends NectaryElement {
696
696
  });
697
697
  }
698
698
  };
699
+ // Pulls an overlap shift back toward zero until the bubble stays inside the viewport.
700
+ // Never flips the shift or makes it larger than the overlap correction requested.
701
+ #keepOverlapOffsetInView(offset, start, end, limit) {
702
+ if (offset === 0) {
703
+ return 0;
704
+ }
705
+ let next = offset;
706
+ if (start + next < 0) {
707
+ next = -start;
708
+ }
709
+ if (end + next > limit) {
710
+ next = limit - end;
711
+ }
712
+ if (offset > 0) {
713
+ return Math.min(offset, Math.max(0, next));
714
+ }
715
+ return Math.max(offset, Math.min(0, next));
716
+ }
699
717
  #resolveOverlap(placementContext) {
700
718
  const orientation = this.orientation;
701
719
  const targetRect = toLocalRect(this.#$pop.footprintRect, placementContext);
@@ -726,6 +744,10 @@ class Tooltip extends NectaryElement {
726
744
  offsetX = targetRight - leftEdge;
727
745
  }
728
746
  }
747
+ if (placementContext.transformedAncestor == null && !getBooleanAttribute(this, "allow-scroll")) {
748
+ offsetX = this.#keepOverlapOffsetInView(offsetX, leftEdge, rightEdge, placementContext.boundsWidth);
749
+ offsetY = this.#keepOverlapOffsetInView(offsetY, topEdge, bottomEdge, placementContext.boundsHeight);
750
+ }
729
751
  this.#applyContentOffset(offsetX, offsetY);
730
752
  return offsetX !== 0 || offsetY !== 0;
731
753
  }