@krizaka/ui 3.33.0 → 3.34.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.
@@ -942,14 +942,29 @@ function DayStrip({ label, locale, value: valueProp, defaultValue = null, onValu
942
942
  const reduce = usePrefersReducedMotion();
943
943
  const weekday = getDateTimeFormat3(locale, { weekday: "short" });
944
944
  const monthTitle = getDateTimeFormat3(locale, { month: "long", year: "numeric" }).format(toLocalDate(value ?? first));
945
+ const scrollTrackTo = (el, where, smooth) => {
946
+ const strip = track.current;
947
+ if (!strip) return;
948
+ const box = el.getBoundingClientRect();
949
+ const frame = strip.getBoundingClientRect();
950
+ const offset = box.left - frame.left;
951
+ let left = strip.scrollLeft;
952
+ if (where === "center") left += offset - (strip.clientWidth - box.width) / 2;
953
+ else if (offset < 0) left += offset;
954
+ else if (offset + box.width > strip.clientWidth) left += offset + box.width - strip.clientWidth;
955
+ if (left === strip.scrollLeft) return;
956
+ if (typeof strip.scrollTo === "function") strip.scrollTo({ left, behavior: smooth ? "smooth" : "auto" });
957
+ else strip.scrollLeft = left;
958
+ };
945
959
  const reveal = (iso, focus) => {
946
960
  const el = track.current?.querySelector(`[data-date="${iso}"]`);
947
961
  if (!el) return;
948
962
  if (focus) el.focus({ preventScroll: true });
949
- el.scrollIntoView?.({ block: "nearest", inline: "nearest", behavior: reduce ? "auto" : "smooth" });
963
+ scrollTrackTo(el, "nearest", !reduce);
950
964
  };
951
965
  React6.useEffect(() => {
952
- if (value) track.current?.querySelector(`[data-date="${value}"]`)?.scrollIntoView?.({ block: "nearest", inline: "center" });
966
+ const el = value ? track.current?.querySelector(`[data-date="${value}"]`) : null;
967
+ if (el) scrollTrackTo(el, "center", false);
953
968
  }, []);
954
969
  const onKeyDown = (event) => {
955
970
  const i = enabled.indexOf(tabStop ?? "");