@dloizides/ui-layout 1.64.0 → 1.66.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.
- package/CHANGELOG.md +4 -0
- package/dist/index.d.mts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1008,6 +1008,7 @@ var styles11 = StyleSheet.create({
|
|
|
1008
1008
|
track: {
|
|
1009
1009
|
flexDirection: "row",
|
|
1010
1010
|
alignSelf: "flex-start",
|
|
1011
|
+
maxWidth: "100%",
|
|
1011
1012
|
alignItems: "center",
|
|
1012
1013
|
gap: TRACK_PADDING + 1,
|
|
1013
1014
|
padding: TRACK_PADDING,
|
|
@@ -1015,6 +1016,7 @@ var styles11 = StyleSheet.create({
|
|
|
1015
1016
|
borderWidth: BORDER_WIDTH
|
|
1016
1017
|
},
|
|
1017
1018
|
segment: {
|
|
1019
|
+
flexShrink: 1,
|
|
1018
1020
|
minHeight: MIN_TARGET_PX,
|
|
1019
1021
|
justifyContent: "center",
|
|
1020
1022
|
paddingHorizontal: SEGMENT_PAD_H,
|
|
@@ -3545,6 +3547,7 @@ function pickActiveIndex(tops, line) {
|
|
|
3545
3547
|
return tops.reduce((picked, top, index) => top <= line ? index : picked, 0);
|
|
3546
3548
|
}
|
|
3547
3549
|
function pickSpyIndex(tops, viewport, activationRatio) {
|
|
3550
|
+
if (viewport.atStart) return 0;
|
|
3548
3551
|
if (viewport.atEnd) return Math.max(tops.length - 1, 0);
|
|
3549
3552
|
return pickActiveIndex(tops, viewport.top + viewport.height * activationRatio);
|
|
3550
3553
|
}
|
|
@@ -3574,6 +3577,9 @@ function scrollParent(element) {
|
|
|
3574
3577
|
}
|
|
3575
3578
|
return null;
|
|
3576
3579
|
}
|
|
3580
|
+
function isAtStart(scrolled) {
|
|
3581
|
+
return scrolled <= 0;
|
|
3582
|
+
}
|
|
3577
3583
|
function isAtEnd(scrolled, visible, total) {
|
|
3578
3584
|
return scrolled > 0 && scrolled + visible >= total - END_TOLERANCE_PX;
|
|
3579
3585
|
}
|
|
@@ -3581,9 +3587,9 @@ function scrollViewport(anchor) {
|
|
|
3581
3587
|
const parent = scrollParent(anchor);
|
|
3582
3588
|
if (parent === null) {
|
|
3583
3589
|
const root = document.scrollingElement ?? document.documentElement;
|
|
3584
|
-
return { top: 0, height: window.innerHeight, atEnd: isAtEnd(window.scrollY, window.innerHeight, root.scrollHeight) };
|
|
3590
|
+
return { top: 0, height: window.innerHeight, atStart: isAtStart(window.scrollY), atEnd: isAtEnd(window.scrollY, window.innerHeight, root.scrollHeight) };
|
|
3585
3591
|
}
|
|
3586
|
-
return { top: parent.getBoundingClientRect().top, height: parent.clientHeight, atEnd: isAtEnd(parent.scrollTop, parent.clientHeight, parent.scrollHeight) };
|
|
3592
|
+
return { top: parent.getBoundingClientRect().top, height: parent.clientHeight, atStart: isAtStart(parent.scrollTop), atEnd: isAtEnd(parent.scrollTop, parent.clientHeight, parent.scrollHeight) };
|
|
3587
3593
|
}
|
|
3588
3594
|
|
|
3589
3595
|
// src/SectionIndexLayout/useScrollSpy.ts
|
|
@@ -3617,10 +3623,9 @@ function useScrollSpy({ anchorIds, enabled, activationRatio, onActive }) {
|
|
|
3617
3623
|
const tops = anchors.map((anchor) => anchor.element.getBoundingClientRect().top);
|
|
3618
3624
|
const picked = pickSpyIndex(tops, scrollViewport(first.element), activationRatio);
|
|
3619
3625
|
const index = anchors[picked]?.index ?? 0;
|
|
3620
|
-
const primed = last.current !== UNPRIMED;
|
|
3621
3626
|
if (index === last.current) return;
|
|
3622
3627
|
last.current = index;
|
|
3623
|
-
|
|
3628
|
+
onActiveRef.current(index);
|
|
3624
3629
|
};
|
|
3625
3630
|
document.addEventListener("scroll", evaluate, LISTEN_OPTIONS);
|
|
3626
3631
|
window.addEventListener("resize", evaluate, LISTEN_OPTIONS);
|
|
@@ -3689,7 +3694,7 @@ var SectionIndexLayout = ({
|
|
|
3689
3694
|
const wide = useIsWideViewport(fold.wide);
|
|
3690
3695
|
const stacked = useIsWideViewport(fold.stackFrom);
|
|
3691
3696
|
const sticky = resolveSticky(stickyIndex);
|
|
3692
|
-
const preferredKey = wide ? initialKey : collapsedKey
|
|
3697
|
+
const preferredKey = wide ? initialKey : collapsedKey;
|
|
3693
3698
|
const { activeKey, pick, select } = useSectionSelection({ sections, testID, preferredKey, spyEnabled: wide && sections.length > 1, sticky });
|
|
3694
3699
|
const dense = density === "dense" /* Dense */;
|
|
3695
3700
|
const gap = { gap: dense ? DENSE_GAP : COMFORTABLE_GAP };
|
|
@@ -3756,6 +3761,7 @@ var DayCard = ({
|
|
|
3756
3761
|
accessibilityHint,
|
|
3757
3762
|
badgeTone = "warning" /* Warning */,
|
|
3758
3763
|
badgeFill = "solid" /* Solid */,
|
|
3764
|
+
badgeColors,
|
|
3759
3765
|
badgeIcon,
|
|
3760
3766
|
layout = "grouped" /* Grouped */,
|
|
3761
3767
|
testID,
|
|
@@ -3763,7 +3769,7 @@ var DayCard = ({
|
|
|
3763
3769
|
}) => {
|
|
3764
3770
|
const { theme } = useUi();
|
|
3765
3771
|
const { colors } = theme;
|
|
3766
|
-
const tint = badgeFill === "tint" /* Tint */ ? resolveTintColors(theme, badgeTone) : void 0;
|
|
3772
|
+
const tint = badgeColors ?? (badgeFill === "tint" /* Tint */ ? resolveTintColors(theme, badgeTone) : void 0);
|
|
3767
3773
|
const surface = { backgroundColor: colors.surface, borderColor: colors.border };
|
|
3768
3774
|
const iconInk = tint?.color ?? colors.textSecondary;
|
|
3769
3775
|
const icon = badgeIcon === void 0 ? void 0 : /* @__PURE__ */ jsx(SvgIcon, { color: iconInk, name: badgeIcon, size: BADGE_ICON_SIZE });
|