@apliteni/apliteni-ui 0.187.0 → 0.188.0

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.
@@ -1291,7 +1291,8 @@ Right, Home and End move between columns and announce each one. Enter picks a co
1291
1291
  `selectable` is set. A plot that scrolls adds one more Tab stop for the scroll box. On a touch
1292
1292
  screen, the first tap on a mark opens its readout and does not call `onSelect`. After Escape, a
1293
1293
  new tap on the same mark opens its readout again. Every value is
1294
- reachable at full strength by pointer or keyboard.
1294
+ reachable at full strength by pointer or keyboard. A readout in a scrolling region stays fully
1295
+ visible over the region and opens above its mark when that space is available.
1295
1296
 
1296
1297
  ### Table values
1297
1298
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apliteni/apliteni-ui",
3
- "version": "0.187.0",
3
+ "version": "0.188.0",
4
4
  "workspaces": [
5
5
  "react"
6
6
  ],
@@ -6094,6 +6094,20 @@ function Shares({ look, format, swatch }) {
6094
6094
 
6095
6095
  // src/Chart.tsx
6096
6096
  import { Fragment as Fragment21, jsx as jsx47, jsxs as jsxs43 } from "react/jsx-runtime";
6097
+ function placeChartTip(mark, tip) {
6098
+ const rect = mark.getBoundingClientRect();
6099
+ const view = tip.ownerDocument.documentElement;
6100
+ const gap = parseFloat(getComputedStyle(tip).getPropertyValue("--ui-tip-gap")) || 8;
6101
+ const above = rect.top;
6102
+ const below = view.clientHeight - rect.bottom;
6103
+ const isBelow = above < tip.offsetHeight + gap && below > above;
6104
+ tip.classList.toggle("is-below", isBelow);
6105
+ const ideal = rect.left + rect.width / 2 - tip.offsetWidth / 2;
6106
+ const left = Math.max(0, Math.min(ideal, view.clientWidth - tip.offsetWidth));
6107
+ tip.style.setProperty("--ui-tip-x", `${rect.left + rect.width / 2}px`);
6108
+ tip.style.setProperty("--ui-tip-y", `${isBelow ? rect.bottom : rect.top}px`);
6109
+ tip.style.setProperty("--ui-tip-shift", `${left - ideal}px`);
6110
+ }
6097
6111
  var HEIGHT = { months: 216, bridge: 216, spark: 32, line: 216, area: 216, stacked: 216, donut: 216 };
6098
6112
  var PAD = 2;
6099
6113
  var ZERO_INSET = 1.5;
@@ -6447,6 +6461,7 @@ function Chart(props) {
6447
6461
  const [said, setSaid] = useState21("");
6448
6462
  const [ownPick, setOwnPick] = useState21(null);
6449
6463
  const pick = selected === void 0 ? ownPick : selected;
6464
+ const topLayer = typeof HTMLElement !== "undefined" && typeof HTMLElement.prototype.showPopover === "function";
6450
6465
  const steps = props.variant === "bridge" ? props.steps : void 0;
6451
6466
  const bridgeTones = props.variant === "bridge" ? props.tones : void 0;
6452
6467
  const periods = props.variant === "bridge" || props.variant === "donut" ? void 0 : props.periods;
@@ -6614,10 +6629,20 @@ function Chart(props) {
6614
6629
  if (opensAtEnd && el) el.scrollLeft = el.scrollWidth - el.clientWidth;
6615
6630
  }, [opensAtEnd, plotWidth, boxWidth, count]);
6616
6631
  useLayoutEffect5(() => {
6617
- if (!openId || !frameEl.current || !tipEl.current || !svgEl.current) return;
6632
+ const tip = tipEl.current;
6633
+ if (!tip) return;
6634
+ const layered = topLayer;
6635
+ if (!openId) {
6636
+ if (layered && tip.matches(":popover-open")) tip.hidePopover();
6637
+ return;
6638
+ }
6639
+ if (!frameEl.current || !svgEl.current) return;
6618
6640
  const anchor2 = [...svgEl.current.querySelectorAll("[data-anchor]")].find((el) => el.getAttribute("data-anchor") === openId);
6619
- if (anchor2) placeTip(frameEl.current, anchor2, tipEl.current);
6620
- }, [openId, plotWidth, plotHeight]);
6641
+ if (!anchor2) return;
6642
+ if (layered && !tip.matches(":popover-open")) tip.showPopover();
6643
+ if (layered) placeChartTip(anchor2, tip);
6644
+ else placeTip(frameEl.current, anchor2, tip);
6645
+ }, [openId, plotWidth, plotHeight, topLayer]);
6621
6646
  useEffect21(() => {
6622
6647
  if (!openId) return;
6623
6648
  const doc = frameEl.current?.ownerDocument;
@@ -6630,9 +6655,11 @@ function Chart(props) {
6630
6655
  hide();
6631
6656
  };
6632
6657
  doc.addEventListener("keydown", escape);
6658
+ doc.addEventListener("scroll", hide, true);
6633
6659
  view2.addEventListener("resize", hide);
6634
6660
  return () => {
6635
6661
  doc.removeEventListener("keydown", escape);
6662
+ doc.removeEventListener("scroll", hide, true);
6636
6663
  view2.removeEventListener("resize", hide);
6637
6664
  };
6638
6665
  }, [openId]);
@@ -7050,7 +7077,7 @@ function Chart(props) {
7050
7077
  ] })
7051
7078
  }
7052
7079
  ),
7053
- /* @__PURE__ */ jsx47("span", { ref: tipEl, className: cx9("ui-tip", openId && "is-open"), role: open ? "tooltip" : void 0, children: open && /* @__PURE__ */ jsxs43(Fragment21, { children: [
7080
+ /* @__PURE__ */ jsx47("span", { ref: tipEl, ...topLayer && { popover: "manual" }, className: cx9("ui-tip", openId && "is-open"), role: open ? "tooltip" : void 0, children: open && /* @__PURE__ */ jsxs43(Fragment21, { children: [
7054
7081
  /* @__PURE__ */ jsx47("span", { className: "ui-tip__label", children: spark || look ? columns[open.column]?.label : `${open.name}, ${columns[open.column]?.label}` }),
7055
7082
  open.rows ? /* @__PURE__ */ jsxs43(Fragment21, { children: [
7056
7083
  open.rows.map((row) => /* @__PURE__ */ jsxs43("span", { className: "ui-tip__value ui-chart__row", children: [