@dloizides/ui-layout 1.62.0 → 1.63.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/dist/index.d.mts CHANGED
@@ -1240,6 +1240,16 @@ declare enum SectionDensity {
1240
1240
  Dense = "dense"
1241
1241
  }
1242
1242
 
1243
+ interface StickyIndexConfig {
1244
+ scrollSpy?: boolean;
1245
+ activationRatio?: number;
1246
+ clickLockMs?: number;
1247
+ }
1248
+ declare const SPY_ACTIVATION_RATIO = 0.3;
1249
+ declare const SPY_CLICK_LOCK_MS = 900;
1250
+ /** Index of the last section whose top is at or above the activation line, else the first. */
1251
+ declare function pickActiveIndex(tops: ReadonlyArray<number>, line: number): number;
1252
+
1243
1253
  interface SectionIndexEntry {
1244
1254
  key: string;
1245
1255
  title: string;
@@ -1259,7 +1269,7 @@ interface SectionIndexLayoutProps {
1259
1269
  collapsedKey?: string;
1260
1270
  breakpoint?: number | SectionFold;
1261
1271
  density?: SectionDensity;
1262
- stickyIndex?: boolean;
1272
+ stickyIndex?: boolean | StickyIndexConfig;
1263
1273
  chipOverflow?: ChipOverflow;
1264
1274
  indexWidth?: number;
1265
1275
  activeColor?: string;
@@ -1299,6 +1309,18 @@ declare const SectionChips: ({ sections, activeKey, groupLabel, itemHint, overfl
1299
1309
  declare const SECTION_INDEX_BREAKPOINT = 1024;
1300
1310
  declare function resolveActiveKey(sections: ReadonlyArray<SectionIndexEntry>, wanted: string | undefined): string;
1301
1311
 
1312
+ interface ScrollSpyOptions {
1313
+ anchorIds: ReadonlyArray<string>;
1314
+ enabled: boolean;
1315
+ activationRatio: number;
1316
+ onActive: (index: number) => void;
1317
+ }
1318
+ interface ScrollSpyControl {
1319
+ pause: (ms: number) => void;
1320
+ }
1321
+ /** Reports the section crossing the activation line on web; a no-op on native, where presses drive the index. */
1322
+ declare function useScrollSpy({ anchorIds, enabled, activationRatio, onActive }: ScrollSpyOptions): ScrollSpyControl;
1323
+
1302
1324
  /** How the DayCard age badge is filled: a solid tone fill or a light tint with tone-coloured ink. */
1303
1325
  declare const enum DayBadgeFill {
1304
1326
  Solid = "solid",
@@ -1586,4 +1608,4 @@ interface ListDetailVisibility {
1586
1608
  /** Wide shows both panes; narrow shows one, the detail only when asked for and present. */
1587
1609
  declare function resolveListDetailPanes(wide: boolean, narrowPane: ListDetailPane, hasDetail: boolean): ListDetailVisibility;
1588
1610
 
1589
- export { A4_PAGE, API_COMMIT_SEPARATOR, Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, AppText, type AppTextProps, BUILD_INFO_PREFIX, BadgeSize, BadgeTone, BottomSheet, type BottomSheetProps, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, BuildInfoFooter, type BuildInfoFooterProps, COPY_FEEDBACK_MS, ChipOverflow, ConfirmDialog, ConfirmDialogFocus, type ConfirmDialogProps, CopyControl, CopyRowEmphasis, CopyStatus, type CopyToClipboard, type CopyValueLabels, CopyValueRow, type CopyValueRowProps, CopyableId, type CopyableIdProps, CountBadge, type CountBadgeProps, DEFAULT_BILLING_ROUTE, DayBadgeFill, DayCard, DayCardLayout, type DayCardProps, type DropdownOption, type DropdownTriggerState, DropdownVariant, ELLIPSIS, FigureStrip, type FigureStripProps, FormDialog, type FormDialogProps, HEADER_STACK_BREAKPOINT, Heading, type HeadingLevel, type HeadingProps, IdChip, type IdChipProps, LAYOUT_COLLAPSE_BREAKPOINT, LAYOUT_I18N, LAYOUT_TEST_IDS, ListDetailLayout, type ListDetailLayoutProps, ListDetailPane, type ListDetailVisibility, ListRow, type ListRowProps, type ListRowTone, MIN_TARGET_PX, MODAL_FOOTER_STACK_BELOW, Modal, ModalDropdown, type ModalDropdownProps, type ModalProps, ModalShell, type ModalShellProps, type ModalSize, PageFrame, type PageFrameProps, PageHead, type PageHeadProps, type PageSize, RecordActionButton, type RecordActionButtonProps, RecordHeader, type RecordHeaderProps, type RowLook, type RowPalette, RowSelectedStyle, type RowSelection, type RowSelectionKeys, type RowState, SECTION_INDEX_BREAKPOINT, SECTION_INDEX_WIDTH, type ScaledFrame, ScreenColumn, type ScreenColumnProps, Section, SectionChips, type SectionChipsProps, SectionDensity, type SectionFold, SectionIndex, type SectionIndexEntry, SectionIndexLayout, type SectionIndexLayoutProps, type SectionIndexProps, type SectionPadding, type SectionProps, SectionVariant, SegmentedControl, type SegmentedControlProps, type SegmentedOption, SegmentedVariant, SelectedMarker, SideSheet, type SideSheetProps, SplitLayout, SplitPanes, type SplitPanesProps, StatusBadge, type StatusBadgeProps, StickyActionBar, type StickyActionBarProps, StickyPreview, type StickyPreviewProps, TYPE_SCALE_BREAKPOINT, type TabDescriptor, Tabs, TabsCollapsedTrigger, type TabsProps, TabsVariant, TextKind, Timeline, type TimelineEntry, type TimelineProps, ToggleSection, type ToggleSectionProps, type ToneColors, type TotalsItem, TotalsStrip, type TotalsStripProps, TotalsTone, TransferSlip, type TransferSlipProps, TruncatedText, type TruncatedTextProps, type UnderlineTab, UnderlineTabs, type UnderlineTabsProps, UpgradePrompt, type UpgradePromptProps, type VersionResponse, type VisibleViewport, WidgetCard, type WidgetCardProps, copyActionLabel, copyText, figureCell, formatBuildInfo, formatCount, formatUrlForDisplay, isKeyboardOpen, isModalFooterStacked, isRecordHeaderCompact, isSplitSideBySide, isWideWebViewport, pageScale, resolveActiveKey, resolveListDetailPanes, resolveRowLook, resolveTintColors, resolveToneColors, rowSelection, scaledFrame, shortenCommit, trimTrailingSlash, truncateMiddle, useApiCommit, useCopyToClipboard, useFocusTrap, useIsWideViewport, useListRowTone, useVisibleViewport };
1611
+ export { A4_PAGE, API_COMMIT_SEPARATOR, Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, AppText, type AppTextProps, BUILD_INFO_PREFIX, BadgeSize, BadgeTone, BottomSheet, type BottomSheetProps, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, BuildInfoFooter, type BuildInfoFooterProps, COPY_FEEDBACK_MS, ChipOverflow, ConfirmDialog, ConfirmDialogFocus, type ConfirmDialogProps, CopyControl, CopyRowEmphasis, CopyStatus, type CopyToClipboard, type CopyValueLabels, CopyValueRow, type CopyValueRowProps, CopyableId, type CopyableIdProps, CountBadge, type CountBadgeProps, DEFAULT_BILLING_ROUTE, DayBadgeFill, DayCard, DayCardLayout, type DayCardProps, type DropdownOption, type DropdownTriggerState, DropdownVariant, ELLIPSIS, FigureStrip, type FigureStripProps, FormDialog, type FormDialogProps, HEADER_STACK_BREAKPOINT, Heading, type HeadingLevel, type HeadingProps, IdChip, type IdChipProps, LAYOUT_COLLAPSE_BREAKPOINT, LAYOUT_I18N, LAYOUT_TEST_IDS, ListDetailLayout, type ListDetailLayoutProps, ListDetailPane, type ListDetailVisibility, ListRow, type ListRowProps, type ListRowTone, MIN_TARGET_PX, MODAL_FOOTER_STACK_BELOW, Modal, ModalDropdown, type ModalDropdownProps, type ModalProps, ModalShell, type ModalShellProps, type ModalSize, PageFrame, type PageFrameProps, PageHead, type PageHeadProps, type PageSize, RecordActionButton, type RecordActionButtonProps, RecordHeader, type RecordHeaderProps, type RowLook, type RowPalette, RowSelectedStyle, type RowSelection, type RowSelectionKeys, type RowState, SECTION_INDEX_BREAKPOINT, SECTION_INDEX_WIDTH, SPY_ACTIVATION_RATIO, SPY_CLICK_LOCK_MS, type ScaledFrame, ScreenColumn, type ScreenColumnProps, type ScrollSpyControl, type ScrollSpyOptions, Section, SectionChips, type SectionChipsProps, SectionDensity, type SectionFold, SectionIndex, type SectionIndexEntry, SectionIndexLayout, type SectionIndexLayoutProps, type SectionIndexProps, type SectionPadding, type SectionProps, SectionVariant, SegmentedControl, type SegmentedControlProps, type SegmentedOption, SegmentedVariant, SelectedMarker, SideSheet, type SideSheetProps, SplitLayout, SplitPanes, type SplitPanesProps, StatusBadge, type StatusBadgeProps, StickyActionBar, type StickyActionBarProps, type StickyIndexConfig, StickyPreview, type StickyPreviewProps, TYPE_SCALE_BREAKPOINT, type TabDescriptor, Tabs, TabsCollapsedTrigger, type TabsProps, TabsVariant, TextKind, Timeline, type TimelineEntry, type TimelineProps, ToggleSection, type ToggleSectionProps, type ToneColors, type TotalsItem, TotalsStrip, type TotalsStripProps, TotalsTone, TransferSlip, type TransferSlipProps, TruncatedText, type TruncatedTextProps, type UnderlineTab, UnderlineTabs, type UnderlineTabsProps, UpgradePrompt, type UpgradePromptProps, type VersionResponse, type VisibleViewport, WidgetCard, type WidgetCardProps, copyActionLabel, copyText, figureCell, formatBuildInfo, formatCount, formatUrlForDisplay, isKeyboardOpen, isModalFooterStacked, isRecordHeaderCompact, isSplitSideBySide, isWideWebViewport, pageScale, pickActiveIndex, resolveActiveKey, resolveListDetailPanes, resolveRowLook, resolveTintColors, resolveToneColors, rowSelection, scaledFrame, shortenCommit, trimTrailingSlash, truncateMiddle, useApiCommit, useCopyToClipboard, useFocusTrap, useIsWideViewport, useListRowTone, useScrollSpy, useVisibleViewport };
package/dist/index.d.ts CHANGED
@@ -1240,6 +1240,16 @@ declare enum SectionDensity {
1240
1240
  Dense = "dense"
1241
1241
  }
1242
1242
 
1243
+ interface StickyIndexConfig {
1244
+ scrollSpy?: boolean;
1245
+ activationRatio?: number;
1246
+ clickLockMs?: number;
1247
+ }
1248
+ declare const SPY_ACTIVATION_RATIO = 0.3;
1249
+ declare const SPY_CLICK_LOCK_MS = 900;
1250
+ /** Index of the last section whose top is at or above the activation line, else the first. */
1251
+ declare function pickActiveIndex(tops: ReadonlyArray<number>, line: number): number;
1252
+
1243
1253
  interface SectionIndexEntry {
1244
1254
  key: string;
1245
1255
  title: string;
@@ -1259,7 +1269,7 @@ interface SectionIndexLayoutProps {
1259
1269
  collapsedKey?: string;
1260
1270
  breakpoint?: number | SectionFold;
1261
1271
  density?: SectionDensity;
1262
- stickyIndex?: boolean;
1272
+ stickyIndex?: boolean | StickyIndexConfig;
1263
1273
  chipOverflow?: ChipOverflow;
1264
1274
  indexWidth?: number;
1265
1275
  activeColor?: string;
@@ -1299,6 +1309,18 @@ declare const SectionChips: ({ sections, activeKey, groupLabel, itemHint, overfl
1299
1309
  declare const SECTION_INDEX_BREAKPOINT = 1024;
1300
1310
  declare function resolveActiveKey(sections: ReadonlyArray<SectionIndexEntry>, wanted: string | undefined): string;
1301
1311
 
1312
+ interface ScrollSpyOptions {
1313
+ anchorIds: ReadonlyArray<string>;
1314
+ enabled: boolean;
1315
+ activationRatio: number;
1316
+ onActive: (index: number) => void;
1317
+ }
1318
+ interface ScrollSpyControl {
1319
+ pause: (ms: number) => void;
1320
+ }
1321
+ /** Reports the section crossing the activation line on web; a no-op on native, where presses drive the index. */
1322
+ declare function useScrollSpy({ anchorIds, enabled, activationRatio, onActive }: ScrollSpyOptions): ScrollSpyControl;
1323
+
1302
1324
  /** How the DayCard age badge is filled: a solid tone fill or a light tint with tone-coloured ink. */
1303
1325
  declare const enum DayBadgeFill {
1304
1326
  Solid = "solid",
@@ -1586,4 +1608,4 @@ interface ListDetailVisibility {
1586
1608
  /** Wide shows both panes; narrow shows one, the detail only when asked for and present. */
1587
1609
  declare function resolveListDetailPanes(wide: boolean, narrowPane: ListDetailPane, hasDetail: boolean): ListDetailVisibility;
1588
1610
 
1589
- export { A4_PAGE, API_COMMIT_SEPARATOR, Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, AppText, type AppTextProps, BUILD_INFO_PREFIX, BadgeSize, BadgeTone, BottomSheet, type BottomSheetProps, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, BuildInfoFooter, type BuildInfoFooterProps, COPY_FEEDBACK_MS, ChipOverflow, ConfirmDialog, ConfirmDialogFocus, type ConfirmDialogProps, CopyControl, CopyRowEmphasis, CopyStatus, type CopyToClipboard, type CopyValueLabels, CopyValueRow, type CopyValueRowProps, CopyableId, type CopyableIdProps, CountBadge, type CountBadgeProps, DEFAULT_BILLING_ROUTE, DayBadgeFill, DayCard, DayCardLayout, type DayCardProps, type DropdownOption, type DropdownTriggerState, DropdownVariant, ELLIPSIS, FigureStrip, type FigureStripProps, FormDialog, type FormDialogProps, HEADER_STACK_BREAKPOINT, Heading, type HeadingLevel, type HeadingProps, IdChip, type IdChipProps, LAYOUT_COLLAPSE_BREAKPOINT, LAYOUT_I18N, LAYOUT_TEST_IDS, ListDetailLayout, type ListDetailLayoutProps, ListDetailPane, type ListDetailVisibility, ListRow, type ListRowProps, type ListRowTone, MIN_TARGET_PX, MODAL_FOOTER_STACK_BELOW, Modal, ModalDropdown, type ModalDropdownProps, type ModalProps, ModalShell, type ModalShellProps, type ModalSize, PageFrame, type PageFrameProps, PageHead, type PageHeadProps, type PageSize, RecordActionButton, type RecordActionButtonProps, RecordHeader, type RecordHeaderProps, type RowLook, type RowPalette, RowSelectedStyle, type RowSelection, type RowSelectionKeys, type RowState, SECTION_INDEX_BREAKPOINT, SECTION_INDEX_WIDTH, type ScaledFrame, ScreenColumn, type ScreenColumnProps, Section, SectionChips, type SectionChipsProps, SectionDensity, type SectionFold, SectionIndex, type SectionIndexEntry, SectionIndexLayout, type SectionIndexLayoutProps, type SectionIndexProps, type SectionPadding, type SectionProps, SectionVariant, SegmentedControl, type SegmentedControlProps, type SegmentedOption, SegmentedVariant, SelectedMarker, SideSheet, type SideSheetProps, SplitLayout, SplitPanes, type SplitPanesProps, StatusBadge, type StatusBadgeProps, StickyActionBar, type StickyActionBarProps, StickyPreview, type StickyPreviewProps, TYPE_SCALE_BREAKPOINT, type TabDescriptor, Tabs, TabsCollapsedTrigger, type TabsProps, TabsVariant, TextKind, Timeline, type TimelineEntry, type TimelineProps, ToggleSection, type ToggleSectionProps, type ToneColors, type TotalsItem, TotalsStrip, type TotalsStripProps, TotalsTone, TransferSlip, type TransferSlipProps, TruncatedText, type TruncatedTextProps, type UnderlineTab, UnderlineTabs, type UnderlineTabsProps, UpgradePrompt, type UpgradePromptProps, type VersionResponse, type VisibleViewport, WidgetCard, type WidgetCardProps, copyActionLabel, copyText, figureCell, formatBuildInfo, formatCount, formatUrlForDisplay, isKeyboardOpen, isModalFooterStacked, isRecordHeaderCompact, isSplitSideBySide, isWideWebViewport, pageScale, resolveActiveKey, resolveListDetailPanes, resolveRowLook, resolveTintColors, resolveToneColors, rowSelection, scaledFrame, shortenCommit, trimTrailingSlash, truncateMiddle, useApiCommit, useCopyToClipboard, useFocusTrap, useIsWideViewport, useListRowTone, useVisibleViewport };
1611
+ export { A4_PAGE, API_COMMIT_SEPARATOR, Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, AppText, type AppTextProps, BUILD_INFO_PREFIX, BadgeSize, BadgeTone, BottomSheet, type BottomSheetProps, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, BuildInfoFooter, type BuildInfoFooterProps, COPY_FEEDBACK_MS, ChipOverflow, ConfirmDialog, ConfirmDialogFocus, type ConfirmDialogProps, CopyControl, CopyRowEmphasis, CopyStatus, type CopyToClipboard, type CopyValueLabels, CopyValueRow, type CopyValueRowProps, CopyableId, type CopyableIdProps, CountBadge, type CountBadgeProps, DEFAULT_BILLING_ROUTE, DayBadgeFill, DayCard, DayCardLayout, type DayCardProps, type DropdownOption, type DropdownTriggerState, DropdownVariant, ELLIPSIS, FigureStrip, type FigureStripProps, FormDialog, type FormDialogProps, HEADER_STACK_BREAKPOINT, Heading, type HeadingLevel, type HeadingProps, IdChip, type IdChipProps, LAYOUT_COLLAPSE_BREAKPOINT, LAYOUT_I18N, LAYOUT_TEST_IDS, ListDetailLayout, type ListDetailLayoutProps, ListDetailPane, type ListDetailVisibility, ListRow, type ListRowProps, type ListRowTone, MIN_TARGET_PX, MODAL_FOOTER_STACK_BELOW, Modal, ModalDropdown, type ModalDropdownProps, type ModalProps, ModalShell, type ModalShellProps, type ModalSize, PageFrame, type PageFrameProps, PageHead, type PageHeadProps, type PageSize, RecordActionButton, type RecordActionButtonProps, RecordHeader, type RecordHeaderProps, type RowLook, type RowPalette, RowSelectedStyle, type RowSelection, type RowSelectionKeys, type RowState, SECTION_INDEX_BREAKPOINT, SECTION_INDEX_WIDTH, SPY_ACTIVATION_RATIO, SPY_CLICK_LOCK_MS, type ScaledFrame, ScreenColumn, type ScreenColumnProps, type ScrollSpyControl, type ScrollSpyOptions, Section, SectionChips, type SectionChipsProps, SectionDensity, type SectionFold, SectionIndex, type SectionIndexEntry, SectionIndexLayout, type SectionIndexLayoutProps, type SectionIndexProps, type SectionPadding, type SectionProps, SectionVariant, SegmentedControl, type SegmentedControlProps, type SegmentedOption, SegmentedVariant, SelectedMarker, SideSheet, type SideSheetProps, SplitLayout, SplitPanes, type SplitPanesProps, StatusBadge, type StatusBadgeProps, StickyActionBar, type StickyActionBarProps, type StickyIndexConfig, StickyPreview, type StickyPreviewProps, TYPE_SCALE_BREAKPOINT, type TabDescriptor, Tabs, TabsCollapsedTrigger, type TabsProps, TabsVariant, TextKind, Timeline, type TimelineEntry, type TimelineProps, ToggleSection, type ToggleSectionProps, type ToneColors, type TotalsItem, TotalsStrip, type TotalsStripProps, TotalsTone, TransferSlip, type TransferSlipProps, TruncatedText, type TruncatedTextProps, type UnderlineTab, UnderlineTabs, type UnderlineTabsProps, UpgradePrompt, type UpgradePromptProps, type VersionResponse, type VisibleViewport, WidgetCard, type WidgetCardProps, copyActionLabel, copyText, figureCell, formatBuildInfo, formatCount, formatUrlForDisplay, isKeyboardOpen, isModalFooterStacked, isRecordHeaderCompact, isSplitSideBySide, isWideWebViewport, pageScale, pickActiveIndex, resolveActiveKey, resolveListDetailPanes, resolveRowLook, resolveTintColors, resolveToneColors, rowSelection, scaledFrame, shortenCommit, trimTrailingSlash, truncateMiddle, useApiCommit, useCopyToClipboard, useFocusTrap, useIsWideViewport, useListRowTone, useScrollSpy, useVisibleViewport };
package/dist/index.js CHANGED
@@ -3450,6 +3450,39 @@ var SectionDensity = /* @__PURE__ */ ((SectionDensity2) => {
3450
3450
  SectionDensity2["Dense"] = "dense";
3451
3451
  return SectionDensity2;
3452
3452
  })(SectionDensity || {});
3453
+ var INDICATOR_MS = 180;
3454
+ var slide = (value, toValue) => reactNative.Animated.timing(value, { toValue, duration: INDICATOR_MS, easing: reactNative.Easing.out(reactNative.Easing.cubic), useNativeDriver: false });
3455
+ function useSlidingIndicator(activeIndex) {
3456
+ const reduced = rnWebHooks.useReducedMotion();
3457
+ const [rows, setRows] = React16.useState([]);
3458
+ const top = React16.useRef(new reactNative.Animated.Value(0)).current;
3459
+ const height = React16.useRef(new reactNative.Animated.Value(0)).current;
3460
+ const placed = React16.useRef(false);
3461
+ const targetY = rows[activeIndex]?.y;
3462
+ const targetHeight = rows[activeIndex]?.height;
3463
+ React16.useEffect(() => {
3464
+ if (targetY === void 0 || targetHeight === void 0) return;
3465
+ if (reduced || !placed.current) {
3466
+ top.setValue(targetY);
3467
+ height.setValue(targetHeight);
3468
+ placed.current = true;
3469
+ return;
3470
+ }
3471
+ reactNative.Animated.parallel([slide(top, targetY), slide(height, targetHeight)]).start();
3472
+ }, [targetY, targetHeight, reduced, top, height]);
3473
+ const onRowLayout = React16.useCallback(
3474
+ (index) => (event) => {
3475
+ const { y, height: rowHeight } = event.nativeEvent.layout;
3476
+ setRows((prev) => {
3477
+ const next = [...prev];
3478
+ next[index] = { y, height: rowHeight };
3479
+ return next;
3480
+ });
3481
+ },
3482
+ []
3483
+ );
3484
+ return { measured: targetY !== void 0, top, height, onRowLayout };
3485
+ }
3453
3486
  var SECTION_INDEX_WIDTH = 200;
3454
3487
  var ACTIVE_BAR = 3;
3455
3488
  var TRANSPARENT3 = "transparent";
@@ -3465,7 +3498,8 @@ var styles30 = reactNative.StyleSheet.create({
3465
3498
  denseHeading: { fontSize: 11, fontWeight: "600", letterSpacing: 0.66, lineHeight: 16, paddingBottom: 6 },
3466
3499
  denseItem: { minHeight: DENSE_TARGET_PX, paddingVertical: 6, paddingLeft: 7, paddingRight: 10, borderRadius: 7 },
3467
3500
  denseLabel: { fontSize: 13, lineHeight: DENSE_LINE },
3468
- denseLabelActive: { fontWeight: "600" }
3501
+ denseLabelActive: { fontWeight: "600" },
3502
+ indicator: { position: "absolute", left: 0, width: ACTIVE_BAR, borderRadius: ACTIVE_BAR }
3469
3503
  });
3470
3504
  function ariaCurrent(active) {
3471
3505
  return active ? { "aria-current": "location" } : {};
@@ -3474,9 +3508,12 @@ var SectionIndex = ({ sections, activeKey, heading, itemHint, onSelect, testID,
3474
3508
  const { theme } = uiFeedback.useUi();
3475
3509
  const { colors } = theme;
3476
3510
  const bar = activeColor ?? colors.text;
3511
+ const indicator = useSlidingIndicator(sections.findIndex((entry) => entry.key === activeKey));
3512
+ const staticBar = indicator.measured ? TRANSPARENT3 : bar;
3477
3513
  return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { role: "navigation", accessibilityLabel: heading, style: [styles30.root, dense && styles30.denseRoot, { width }], testID: `${testID}-index`, children: [
3514
+ indicator.measured ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { pointerEvents: "none", style: [styles30.indicator, { backgroundColor: bar, top: indicator.top, height: indicator.height }], testID: `${testID}-index-indicator` }) : null,
3478
3515
  /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles30.heading, dense && styles30.denseHeading, { color: colors.textSecondary }], children: heading }),
3479
- sections.map((entry) => {
3516
+ sections.map((entry, index) => {
3480
3517
  const active = entry.key === activeKey;
3481
3518
  return /* @__PURE__ */ jsxRuntime.jsx(
3482
3519
  reactNative.Pressable,
@@ -3485,8 +3522,9 @@ var SectionIndex = ({ sections, activeKey, heading, itemHint, onSelect, testID,
3485
3522
  accessibilityRole: "link",
3486
3523
  accessibilityLabel: entry.title,
3487
3524
  accessibilityHint: itemHint,
3488
- style: [styles30.item, dense && styles30.denseItem, { borderLeftColor: active ? bar : TRANSPARENT3, backgroundColor: active ? colors.surface : TRANSPARENT3 }],
3525
+ style: [styles30.item, dense && styles30.denseItem, { borderLeftColor: active ? staticBar : TRANSPARENT3, backgroundColor: active ? colors.surface : TRANSPARENT3 }],
3489
3526
  testID: `${testID}-index-${entry.key}`,
3527
+ onLayout: indicator.onRowLayout(index),
3490
3528
  onPress: () => onSelect(entry.key),
3491
3529
  children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles30.label, active && styles30.labelActive, dense && styles30.denseLabel, dense && active && styles30.denseLabelActive, { color: active ? colors.text : colors.textSecondary }], children: entry.title })
3492
3530
  },
@@ -3496,6 +3534,27 @@ var SectionIndex = ({ sections, activeKey, heading, itemHint, onSelect, testID,
3496
3534
  ] });
3497
3535
  };
3498
3536
 
3537
+ // src/SectionIndexLayout/scrollSpy.ts
3538
+ var SPY_ACTIVATION_RATIO = 0.3;
3539
+ var SPY_CLICK_LOCK_MS = 900;
3540
+ var PERCENT2 = 100;
3541
+ function resolveSticky(value) {
3542
+ if (value === void 0 || value === false) return { sticky: false, spy: false, activationRatio: SPY_ACTIVATION_RATIO, clickLockMs: SPY_CLICK_LOCK_MS };
3543
+ const config = value === true ? {} : value;
3544
+ return {
3545
+ sticky: true,
3546
+ spy: config.scrollSpy ?? true,
3547
+ activationRatio: config.activationRatio ?? SPY_ACTIVATION_RATIO,
3548
+ clickLockMs: config.clickLockMs ?? SPY_CLICK_LOCK_MS
3549
+ };
3550
+ }
3551
+ function pickActiveIndex(tops, line) {
3552
+ return tops.reduce((picked, top, index) => top <= line ? index : picked, 0);
3553
+ }
3554
+ function spyRootMargin(activationRatio) {
3555
+ return `0px 0px -${Math.round((1 - activationRatio) * PERCENT2)}% 0px`;
3556
+ }
3557
+
3499
3558
  // src/SectionIndexLayout/sectionKeys.ts
3500
3559
  var SECTION_INDEX_BREAKPOINT = 1024;
3501
3560
  function resolveActiveKey(sections, wanted) {
@@ -3511,6 +3570,70 @@ function scrollToSection(anchorId) {
3511
3570
  const target = document.getElementById(anchorId);
3512
3571
  target?.scrollIntoView?.({ behavior: "smooth", block: "start" });
3513
3572
  }
3573
+ var UNPRIMED = -2;
3574
+ var STALE = -1;
3575
+ var ID_SEPARATOR = "\n";
3576
+ function canObserve() {
3577
+ return typeof document !== "undefined" && typeof window !== "undefined" && typeof IntersectionObserver !== "undefined";
3578
+ }
3579
+ function findAnchors(ids) {
3580
+ return ids.flatMap((id, index) => {
3581
+ const element = document.getElementById(id);
3582
+ return element === null ? [] : [{ index, element }];
3583
+ });
3584
+ }
3585
+ function useScrollSpy({ anchorIds, enabled, activationRatio, onActive }) {
3586
+ const onActiveRef = React16.useRef(onActive);
3587
+ onActiveRef.current = onActive;
3588
+ const pausedUntil = React16.useRef(0);
3589
+ const last = React16.useRef(UNPRIMED);
3590
+ const idsKey = anchorIds.join(ID_SEPARATOR);
3591
+ React16.useEffect(() => {
3592
+ if (!enabled || !canObserve()) return void 0;
3593
+ const anchors = findAnchors(idsKey.split(ID_SEPARATOR));
3594
+ if (anchors.length < 2) return void 0;
3595
+ last.current = UNPRIMED;
3596
+ const evaluate = () => {
3597
+ if (Date.now() < pausedUntil.current) return;
3598
+ const picked = pickActiveIndex(anchors.map((anchor) => anchor.element.getBoundingClientRect().top), window.innerHeight * activationRatio);
3599
+ const index = anchors[picked]?.index ?? 0;
3600
+ const primed = last.current !== UNPRIMED;
3601
+ if (index === last.current) return;
3602
+ last.current = index;
3603
+ if (primed || index > 0) onActiveRef.current(index);
3604
+ };
3605
+ const observer = new IntersectionObserver(evaluate, { rootMargin: spyRootMargin(activationRatio), threshold: 0 });
3606
+ anchors.forEach((anchor) => observer.observe(anchor.element));
3607
+ return () => observer.disconnect();
3608
+ }, [enabled, activationRatio, idsKey]);
3609
+ const pause = React16.useCallback((ms) => {
3610
+ pausedUntil.current = Date.now() + ms;
3611
+ last.current = STALE;
3612
+ }, []);
3613
+ return React16.useMemo(() => ({ pause }), [pause]);
3614
+ }
3615
+
3616
+ // src/SectionIndexLayout/useSectionSelection.ts
3617
+ function useSectionSelection({ sections, testID, preferredKey, spyEnabled, sticky }) {
3618
+ const [current, setCurrent] = React16.useState(void 0);
3619
+ const spy = useScrollSpy({
3620
+ anchorIds: sections.map((entry) => sectionAnchorId(testID, entry.key)),
3621
+ enabled: spyEnabled && sticky.spy,
3622
+ activationRatio: sticky.activationRatio,
3623
+ onActive: (index) => setCurrent(sections[index]?.key)
3624
+ });
3625
+ const { pause } = spy;
3626
+ const { clickLockMs } = sticky;
3627
+ const select = React16.useCallback(
3628
+ (key) => {
3629
+ setCurrent(key);
3630
+ pause(clickLockMs);
3631
+ scrollToSection(sectionAnchorId(testID, key));
3632
+ },
3633
+ [pause, clickLockMs, testID]
3634
+ );
3635
+ return { activeKey: resolveActiveKey(sections, current ?? preferredKey), pick: setCurrent, select };
3636
+ }
3514
3637
  var COMFORTABLE_GAP = 12;
3515
3638
  var DENSE_GAP = 8;
3516
3639
  var DENSE_WIDE_GAP = 16;
@@ -3541,8 +3664,9 @@ var SectionIndexLayout = ({
3541
3664
  const fold = toFold(breakpoint);
3542
3665
  const wide = useIsWideViewport(fold.wide);
3543
3666
  const stacked = useIsWideViewport(fold.stackFrom);
3544
- const [picked, setPicked] = React16.useState(void 0);
3545
- const activeKey = resolveActiveKey(sections, picked ?? (wide ? initialKey : collapsedKey ?? initialKey));
3667
+ const sticky = resolveSticky(stickyIndex);
3668
+ const preferredKey = wide ? initialKey : collapsedKey ?? initialKey;
3669
+ const { activeKey, pick, select } = useSectionSelection({ sections, testID, preferredKey, spyEnabled: wide && sections.length > 1, sticky });
3546
3670
  const dense = density === "dense" /* Dense */;
3547
3671
  const gap = { gap: dense ? DENSE_GAP : COMFORTABLE_GAP };
3548
3672
  if (sections.length < 2) return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { testID, children: sections[0]?.content });
@@ -3561,19 +3685,15 @@ var SectionIndexLayout = ({
3561
3685
  overflow: chipOverflow,
3562
3686
  sections,
3563
3687
  testID,
3564
- onSelect: setPicked
3688
+ onSelect: pick
3565
3689
  }
3566
3690
  ),
3567
3691
  /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { nativeID: sectionAnchorId(testID, activeKey), testID: sectionAnchorId(testID, activeKey), children: active?.content })
3568
3692
  ] });
3569
3693
  }
3570
- const select = (key) => {
3571
- setPicked(key);
3572
- scrollToSection(sectionAnchorId(testID, key));
3573
- };
3574
- const sticky = stickyIndex && reactNative.Platform.OS === "web" ? WEB_STICKY : null;
3694
+ const stickyStyle = sticky.sticky && reactNative.Platform.OS === "web" ? WEB_STICKY : null;
3575
3695
  return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles31.wide, dense && { gap: DENSE_WIDE_GAP }], testID, children: [
3576
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: sticky, children: /* @__PURE__ */ jsxRuntime.jsx(SectionIndex, { activeColor, activeKey, dense, heading: indexHeading, itemHint, sections, testID, width: indexWidth, onSelect: select }) }),
3696
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: stickyStyle, children: /* @__PURE__ */ jsxRuntime.jsx(SectionIndex, { activeColor, activeKey, dense, heading: indexHeading, itemHint, sections, testID, width: indexWidth, onSelect: select }) }),
3577
3697
  /* @__PURE__ */ jsxRuntime.jsx(SectionColumn, { sections, style: reactNative.StyleSheet.flatten([styles31.column, gap]), testID })
3578
3698
  ] });
3579
3699
  };
@@ -4241,6 +4361,8 @@ exports.RecordHeader = RecordHeader;
4241
4361
  exports.RowSelectedStyle = RowSelectedStyle;
4242
4362
  exports.SECTION_INDEX_BREAKPOINT = SECTION_INDEX_BREAKPOINT;
4243
4363
  exports.SECTION_INDEX_WIDTH = SECTION_INDEX_WIDTH;
4364
+ exports.SPY_ACTIVATION_RATIO = SPY_ACTIVATION_RATIO;
4365
+ exports.SPY_CLICK_LOCK_MS = SPY_CLICK_LOCK_MS;
4244
4366
  exports.ScreenColumn = ScreenColumn;
4245
4367
  exports.Section = Section;
4246
4368
  exports.SectionChips = SectionChips;
@@ -4283,6 +4405,7 @@ exports.isRecordHeaderCompact = isRecordHeaderCompact;
4283
4405
  exports.isSplitSideBySide = isSplitSideBySide;
4284
4406
  exports.isWideWebViewport = isWideWebViewport;
4285
4407
  exports.pageScale = pageScale;
4408
+ exports.pickActiveIndex = pickActiveIndex;
4286
4409
  exports.resolveActiveKey = resolveActiveKey;
4287
4410
  exports.resolveListDetailPanes = resolveListDetailPanes;
4288
4411
  exports.resolveRowLook = resolveRowLook;
@@ -4298,6 +4421,7 @@ exports.useCopyToClipboard = useCopyToClipboard;
4298
4421
  exports.useFocusTrap = useFocusTrap;
4299
4422
  exports.useIsWideViewport = useIsWideViewport;
4300
4423
  exports.useListRowTone = useListRowTone;
4424
+ exports.useScrollSpy = useScrollSpy;
4301
4425
  exports.useVisibleViewport = useVisibleViewport;
4302
4426
  //# sourceMappingURL=index.js.map
4303
4427
  //# sourceMappingURL=index.js.map