@geomak/ui 7.17.0 → 7.17.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/dist/index.cjs CHANGED
@@ -5092,12 +5092,52 @@ function useTargetBbox(ref) {
5092
5092
  }
5093
5093
  var TOOLTIP_WIDTH = 280;
5094
5094
  var TOOLTIP_GAP = 12;
5095
- function tooltipStyleFor(bbox, placement) {
5096
- const pl = placement ?? "right";
5097
- if (pl === "right") return { left: bbox.right + TOOLTIP_GAP, top: bbox.top + bbox.height / 2, transform: "translateY(-50%)", width: TOOLTIP_WIDTH };
5098
- if (pl === "left") return { left: bbox.left - TOOLTIP_WIDTH - TOOLTIP_GAP, top: bbox.top + bbox.height / 2, transform: "translateY(-50%)", width: TOOLTIP_WIDTH };
5099
- if (pl === "bottom") return { left: bbox.left + bbox.width / 2, top: bbox.bottom + TOOLTIP_GAP, transform: "translateX(-50%)", width: TOOLTIP_WIDTH };
5100
- return { left: bbox.left + bbox.width / 2, top: bbox.top - TOOLTIP_GAP, transform: "translate(-50%, -100%)", width: TOOLTIP_WIDTH };
5095
+ function tooltipStyleFor(bbox, placement, tooltipHeight) {
5096
+ const GAP2 = TOOLTIP_GAP;
5097
+ const W = TOOLTIP_WIDTH;
5098
+ const H = tooltipHeight;
5099
+ const vw = window.innerWidth;
5100
+ const vh = window.innerHeight;
5101
+ let side = placement ?? "right";
5102
+ if (side === "right" && bbox.right + GAP2 + W > vw) side = "left";
5103
+ if (side === "left" && bbox.left - W - GAP2 < 0) side = "right";
5104
+ if (side === "bottom" && bbox.bottom + GAP2 + H > vh) side = "top";
5105
+ if (side === "top" && bbox.top - GAP2 - H < 0) side = "bottom";
5106
+ let left;
5107
+ let top;
5108
+ let transform;
5109
+ if (side === "right") {
5110
+ left = bbox.right + GAP2;
5111
+ top = bbox.top + bbox.height / 2;
5112
+ transform = "translateY(-50%)";
5113
+ } else if (side === "left") {
5114
+ left = bbox.left - W - GAP2;
5115
+ top = bbox.top + bbox.height / 2;
5116
+ transform = "translateY(-50%)";
5117
+ } else if (side === "bottom") {
5118
+ left = bbox.left + bbox.width / 2;
5119
+ top = bbox.bottom + GAP2;
5120
+ transform = "translateX(-50%)";
5121
+ } else {
5122
+ left = bbox.left + bbox.width / 2;
5123
+ top = bbox.top - GAP2;
5124
+ transform = "translate(-50%, -100%)";
5125
+ }
5126
+ if (side === "top" || side === "bottom") {
5127
+ left = Math.max(GAP2 + W / 2, Math.min(left, vw - W / 2 - GAP2));
5128
+ } else {
5129
+ left = Math.max(GAP2, Math.min(left, vw - W - GAP2));
5130
+ }
5131
+ if (H > 0) {
5132
+ if (side === "right" || side === "left") {
5133
+ top = Math.max(GAP2 + H / 2, Math.min(top, vh - GAP2 - H / 2));
5134
+ } else if (side === "bottom") {
5135
+ top = Math.max(GAP2, Math.min(top, vh - GAP2 - H));
5136
+ } else {
5137
+ top = Math.max(GAP2 + H, Math.min(top, vh - GAP2));
5138
+ }
5139
+ }
5140
+ return { left, top, transform, width: W };
5101
5141
  }
5102
5142
  function useFocusTrap(containerRef, active) {
5103
5143
  React36.useEffect(() => {
@@ -5145,6 +5185,11 @@ function Wizard({
5145
5185
  const reduced = framerMotion.useReducedMotion();
5146
5186
  const [open, setOpen] = React36.useState(() => steps.length > 0 && !readDismissed(storageKey));
5147
5187
  const [activeIndex, setActiveIndex] = React36.useState(0);
5188
+ const [tooltipHeight, setTooltipHeight] = React36.useState(0);
5189
+ React36.useLayoutEffect(() => {
5190
+ const h = tooltipRef.current?.offsetHeight ?? 0;
5191
+ if (h > 0) setTooltipHeight((prev) => prev === h ? prev : h);
5192
+ }, [activeIndex, open]);
5148
5193
  const step = steps[activeIndex];
5149
5194
  const bbox = useTargetBbox(step?.stepRef);
5150
5195
  useFocusTrap(tooltipRef, open);
@@ -5197,7 +5242,7 @@ function Wizard({
5197
5242
  right: 0,
5198
5243
  height: bbox.height + SPOT_PAD * 2
5199
5244
  } : { display: "none" };
5200
- const tooltipStyle = bbox ? tooltipStyleFor(bbox, step?.placement) : { display: "none" };
5245
+ const tooltipStyle = bbox ? tooltipStyleFor(bbox, step?.placement, tooltipHeight) : { display: "none" };
5201
5246
  const isLast = activeIndex === steps.length - 1;
5202
5247
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5203
5248
  children,