@jsenv/navi 0.25.8 → 0.25.10
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/jsenv_navi.js +31 -22
- package/dist/jsenv_navi.js.map +11 -10
- package/package.json +1 -1
package/dist/jsenv_navi.js
CHANGED
|
@@ -21346,6 +21346,26 @@ const TextAnchor = ({
|
|
|
21346
21346
|
}) => {
|
|
21347
21347
|
import.meta.css = [css$z, "@jsenv/navi/src/text/text_anchor.jsx"];
|
|
21348
21348
|
const anchorRef = useRef();
|
|
21349
|
+
const setTopOffset = (childEl, topOffset) => {
|
|
21350
|
+
// position:relative + top shifts the element visually.
|
|
21351
|
+
// marginTop: -topOffset makes the layout box follow the visual position, so any container
|
|
21352
|
+
// (button, link, box…) computes its own padding/border/height based on the real final position
|
|
21353
|
+
// rather than the original unshifted one. This means a badge inside a button will symmetrically
|
|
21354
|
+
// expand the button height instead of overflowing or being clipped.
|
|
21355
|
+
// marginBottom: topOffset compensates the marginTop so the line height stays unchanged —
|
|
21356
|
+
// the shift is purely a repositioning, not an inflation of the line.
|
|
21357
|
+
if (!topOffset) {
|
|
21358
|
+
childEl.style.position = "";
|
|
21359
|
+
childEl.style.top = "";
|
|
21360
|
+
childEl.style.marginTop = "";
|
|
21361
|
+
childEl.style.marginBottom = "";
|
|
21362
|
+
return;
|
|
21363
|
+
}
|
|
21364
|
+
childEl.style.position = "relative";
|
|
21365
|
+
childEl.style.top = `${topOffset}px`;
|
|
21366
|
+
childEl.style.marginTop = `${-topOffset}px`;
|
|
21367
|
+
childEl.style.marginBottom = `${topOffset}px`;
|
|
21368
|
+
};
|
|
21349
21369
|
useLayoutEffect(() => {
|
|
21350
21370
|
const anchorEl = anchorRef.current;
|
|
21351
21371
|
const childEl = childRef.current;
|
|
@@ -21359,32 +21379,16 @@ const TextAnchor = ({
|
|
|
21359
21379
|
if (parentDisplay !== "inline" && parentDisplay !== "inline-block" && parentDisplay !== "block") {
|
|
21360
21380
|
// we must hide the anchor otherwise it would affect layout without providing any benefit (would trigger flex gap for instance)
|
|
21361
21381
|
anchorEl.setAttribute("hidden", "");
|
|
21362
|
-
|
|
21363
|
-
|
|
21382
|
+
setTopOffset(childEl, 0);
|
|
21383
|
+
return;
|
|
21364
21384
|
}
|
|
21385
|
+
anchorEl.removeAttribute("hidden");
|
|
21365
21386
|
const topOffset = computeTopOffset({
|
|
21366
21387
|
anchorEl,
|
|
21367
21388
|
childEl,
|
|
21368
21389
|
textAnchor
|
|
21369
21390
|
});
|
|
21370
|
-
|
|
21371
|
-
// position:relative + top shifts the element visually.
|
|
21372
|
-
// marginTop: -topOffset makes the layout box follow the visual position, so any container
|
|
21373
|
-
// (button, link, box…) computes its own padding/border/height based on the real final position
|
|
21374
|
-
// rather than the original unshifted one. This means a badge inside a button will symmetrically
|
|
21375
|
-
// expand the button height instead of overflowing or being clipped.
|
|
21376
|
-
// marginBottom: topOffset compensates the marginTop so the line height stays unchanged —
|
|
21377
|
-
// the shift is purely a repositioning, not an inflation of the line.
|
|
21378
|
-
childEl.style.position = "relative";
|
|
21379
|
-
childEl.style.top = `${topOffset}px`;
|
|
21380
|
-
childEl.style.marginTop = `${-topOffset}px`;
|
|
21381
|
-
childEl.style.marginBottom = `${topOffset}px`;
|
|
21382
|
-
} else {
|
|
21383
|
-
childEl.style.position = "";
|
|
21384
|
-
childEl.style.top = "";
|
|
21385
|
-
childEl.style.marginTop = "";
|
|
21386
|
-
childEl.style.marginBottom = "";
|
|
21387
|
-
}
|
|
21391
|
+
setTopOffset(childEl, topOffset);
|
|
21388
21392
|
}, [textAnchor, textKey, textSize, lineLayout?.size, lineLayout?.verticalAlign]);
|
|
21389
21393
|
return jsxs(Fragment, {
|
|
21390
21394
|
children: [children, jsx("span", {
|
|
@@ -21889,6 +21893,8 @@ const useAccentColorAttributes = (
|
|
|
21889
21893
|
return undefined;
|
|
21890
21894
|
}
|
|
21891
21895
|
let elementToCheck = el;
|
|
21896
|
+
elementSelector =
|
|
21897
|
+
elementSelector || el.getAttribute("data-visual-selector");
|
|
21892
21898
|
if (elementSelector) {
|
|
21893
21899
|
elementToCheck = el.querySelector(elementSelector);
|
|
21894
21900
|
if (!elementToCheck) {
|
|
@@ -22803,7 +22809,10 @@ const ButtonUI = props => {
|
|
|
22803
22809
|
innerTarget = target === undefined ? isSameSite ? undefined : "_blank" : target;
|
|
22804
22810
|
innerRel = rel === undefined ? isSameSite ? undefined : "noopener noreferrer" : rel;
|
|
22805
22811
|
}
|
|
22806
|
-
|
|
22812
|
+
const visualSelector = ".navi_button_content";
|
|
22813
|
+
useAccentColorAttributes(ref, null, {
|
|
22814
|
+
elementSelector: visualSelector
|
|
22815
|
+
});
|
|
22807
22816
|
const renderButtonContent = buttonProps => {
|
|
22808
22817
|
return jsxs(Text, {
|
|
22809
22818
|
...buttonProps,
|
|
@@ -22857,7 +22866,7 @@ const ButtonUI = props => {
|
|
|
22857
22866
|
":disabled": innerDisabled,
|
|
22858
22867
|
":-navi-loading": innerLoading
|
|
22859
22868
|
},
|
|
22860
|
-
visualSelector:
|
|
22869
|
+
visualSelector: visualSelector,
|
|
22861
22870
|
hasChildFunction: true,
|
|
22862
22871
|
children: [jsx(LoaderBackground, {
|
|
22863
22872
|
loading: innerLoading,
|