@dloizides/ui-layout 1.62.0 → 1.64.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 +24 -2
- package/dist/index.d.ts +24 -2
- package/dist/index.js +166 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +163 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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 ?
|
|
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
|
+
function resolveSticky(value) {
|
|
3541
|
+
if (value === void 0 || value === false) return { sticky: false, spy: false, activationRatio: SPY_ACTIVATION_RATIO, clickLockMs: SPY_CLICK_LOCK_MS };
|
|
3542
|
+
const config = value === true ? {} : value;
|
|
3543
|
+
return {
|
|
3544
|
+
sticky: true,
|
|
3545
|
+
spy: config.scrollSpy ?? true,
|
|
3546
|
+
activationRatio: config.activationRatio ?? SPY_ACTIVATION_RATIO,
|
|
3547
|
+
clickLockMs: config.clickLockMs ?? SPY_CLICK_LOCK_MS
|
|
3548
|
+
};
|
|
3549
|
+
}
|
|
3550
|
+
function pickActiveIndex(tops, line) {
|
|
3551
|
+
return tops.reduce((picked, top, index) => top <= line ? index : picked, 0);
|
|
3552
|
+
}
|
|
3553
|
+
function pickSpyIndex(tops, viewport, activationRatio) {
|
|
3554
|
+
if (viewport.atEnd) return Math.max(tops.length - 1, 0);
|
|
3555
|
+
return pickActiveIndex(tops, viewport.top + viewport.height * activationRatio);
|
|
3556
|
+
}
|
|
3557
|
+
|
|
3499
3558
|
// src/SectionIndexLayout/sectionKeys.ts
|
|
3500
3559
|
var SECTION_INDEX_BREAKPOINT = 1024;
|
|
3501
3560
|
function resolveActiveKey(sections, wanted) {
|
|
@@ -3511,6 +3570,100 @@ function scrollToSection(anchorId) {
|
|
|
3511
3570
|
const target = document.getElementById(anchorId);
|
|
3512
3571
|
target?.scrollIntoView?.({ behavior: "smooth", block: "start" });
|
|
3513
3572
|
}
|
|
3573
|
+
|
|
3574
|
+
// src/SectionIndexLayout/scrollViewport.ts
|
|
3575
|
+
var SCROLLABLE_OVERFLOW = /^(auto|scroll|overlay)$/;
|
|
3576
|
+
var END_TOLERANCE_PX = 2;
|
|
3577
|
+
function scrollParent(element) {
|
|
3578
|
+
for (let node = element.parentElement; node !== null; node = node.parentElement) {
|
|
3579
|
+
if (SCROLLABLE_OVERFLOW.test(getComputedStyle(node).overflowY) && node.scrollHeight > node.clientHeight) return node;
|
|
3580
|
+
}
|
|
3581
|
+
return null;
|
|
3582
|
+
}
|
|
3583
|
+
function isAtEnd(scrolled, visible, total) {
|
|
3584
|
+
return scrolled > 0 && scrolled + visible >= total - END_TOLERANCE_PX;
|
|
3585
|
+
}
|
|
3586
|
+
function scrollViewport(anchor) {
|
|
3587
|
+
const parent = scrollParent(anchor);
|
|
3588
|
+
if (parent === null) {
|
|
3589
|
+
const root = document.scrollingElement ?? document.documentElement;
|
|
3590
|
+
return { top: 0, height: window.innerHeight, atEnd: isAtEnd(window.scrollY, window.innerHeight, root.scrollHeight) };
|
|
3591
|
+
}
|
|
3592
|
+
return { top: parent.getBoundingClientRect().top, height: parent.clientHeight, atEnd: isAtEnd(parent.scrollTop, parent.clientHeight, parent.scrollHeight) };
|
|
3593
|
+
}
|
|
3594
|
+
|
|
3595
|
+
// src/SectionIndexLayout/useScrollSpy.ts
|
|
3596
|
+
var UNPRIMED = -2;
|
|
3597
|
+
var STALE = -1;
|
|
3598
|
+
var ID_SEPARATOR = "\n";
|
|
3599
|
+
var LISTEN_OPTIONS = { capture: true, passive: true };
|
|
3600
|
+
function canObserve() {
|
|
3601
|
+
return typeof document !== "undefined" && typeof window !== "undefined";
|
|
3602
|
+
}
|
|
3603
|
+
function findAnchors(ids) {
|
|
3604
|
+
return ids.flatMap((id, index) => {
|
|
3605
|
+
const element = document.getElementById(id);
|
|
3606
|
+
return element === null ? [] : [{ index, element }];
|
|
3607
|
+
});
|
|
3608
|
+
}
|
|
3609
|
+
function useScrollSpy({ anchorIds, enabled, activationRatio, onActive }) {
|
|
3610
|
+
const onActiveRef = React16.useRef(onActive);
|
|
3611
|
+
onActiveRef.current = onActive;
|
|
3612
|
+
const pausedUntil = React16.useRef(0);
|
|
3613
|
+
const last = React16.useRef(UNPRIMED);
|
|
3614
|
+
const idsKey = anchorIds.join(ID_SEPARATOR);
|
|
3615
|
+
React16.useEffect(() => {
|
|
3616
|
+
if (!enabled || !canObserve()) return void 0;
|
|
3617
|
+
const anchors = findAnchors(idsKey.split(ID_SEPARATOR));
|
|
3618
|
+
const first = anchors[0];
|
|
3619
|
+
if (first === void 0 || anchors.length < 2) return void 0;
|
|
3620
|
+
last.current = UNPRIMED;
|
|
3621
|
+
const evaluate = () => {
|
|
3622
|
+
if (Date.now() < pausedUntil.current) return;
|
|
3623
|
+
const tops = anchors.map((anchor) => anchor.element.getBoundingClientRect().top);
|
|
3624
|
+
const picked = pickSpyIndex(tops, scrollViewport(first.element), activationRatio);
|
|
3625
|
+
const index = anchors[picked]?.index ?? 0;
|
|
3626
|
+
const primed = last.current !== UNPRIMED;
|
|
3627
|
+
if (index === last.current) return;
|
|
3628
|
+
last.current = index;
|
|
3629
|
+
if (primed || index > 0) onActiveRef.current(index);
|
|
3630
|
+
};
|
|
3631
|
+
document.addEventListener("scroll", evaluate, LISTEN_OPTIONS);
|
|
3632
|
+
window.addEventListener("resize", evaluate, LISTEN_OPTIONS);
|
|
3633
|
+
evaluate();
|
|
3634
|
+
return () => {
|
|
3635
|
+
document.removeEventListener("scroll", evaluate, LISTEN_OPTIONS);
|
|
3636
|
+
window.removeEventListener("resize", evaluate, LISTEN_OPTIONS);
|
|
3637
|
+
};
|
|
3638
|
+
}, [enabled, activationRatio, idsKey]);
|
|
3639
|
+
const pause = React16.useCallback((ms) => {
|
|
3640
|
+
pausedUntil.current = Date.now() + ms;
|
|
3641
|
+
last.current = STALE;
|
|
3642
|
+
}, []);
|
|
3643
|
+
return React16.useMemo(() => ({ pause }), [pause]);
|
|
3644
|
+
}
|
|
3645
|
+
|
|
3646
|
+
// src/SectionIndexLayout/useSectionSelection.ts
|
|
3647
|
+
function useSectionSelection({ sections, testID, preferredKey, spyEnabled, sticky }) {
|
|
3648
|
+
const [current, setCurrent] = React16.useState(void 0);
|
|
3649
|
+
const spy = useScrollSpy({
|
|
3650
|
+
anchorIds: sections.map((entry) => sectionAnchorId(testID, entry.key)),
|
|
3651
|
+
enabled: spyEnabled && sticky.spy,
|
|
3652
|
+
activationRatio: sticky.activationRatio,
|
|
3653
|
+
onActive: (index) => setCurrent(sections[index]?.key)
|
|
3654
|
+
});
|
|
3655
|
+
const { pause } = spy;
|
|
3656
|
+
const { clickLockMs } = sticky;
|
|
3657
|
+
const select = React16.useCallback(
|
|
3658
|
+
(key) => {
|
|
3659
|
+
setCurrent(key);
|
|
3660
|
+
pause(clickLockMs);
|
|
3661
|
+
scrollToSection(sectionAnchorId(testID, key));
|
|
3662
|
+
},
|
|
3663
|
+
[pause, clickLockMs, testID]
|
|
3664
|
+
);
|
|
3665
|
+
return { activeKey: resolveActiveKey(sections, current ?? preferredKey), pick: setCurrent, select };
|
|
3666
|
+
}
|
|
3514
3667
|
var COMFORTABLE_GAP = 12;
|
|
3515
3668
|
var DENSE_GAP = 8;
|
|
3516
3669
|
var DENSE_WIDE_GAP = 16;
|
|
@@ -3541,8 +3694,9 @@ var SectionIndexLayout = ({
|
|
|
3541
3694
|
const fold = toFold(breakpoint);
|
|
3542
3695
|
const wide = useIsWideViewport(fold.wide);
|
|
3543
3696
|
const stacked = useIsWideViewport(fold.stackFrom);
|
|
3544
|
-
const
|
|
3545
|
-
const
|
|
3697
|
+
const sticky = resolveSticky(stickyIndex);
|
|
3698
|
+
const preferredKey = wide ? initialKey : collapsedKey ?? initialKey;
|
|
3699
|
+
const { activeKey, pick, select } = useSectionSelection({ sections, testID, preferredKey, spyEnabled: wide && sections.length > 1, sticky });
|
|
3546
3700
|
const dense = density === "dense" /* Dense */;
|
|
3547
3701
|
const gap = { gap: dense ? DENSE_GAP : COMFORTABLE_GAP };
|
|
3548
3702
|
if (sections.length < 2) return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { testID, children: sections[0]?.content });
|
|
@@ -3561,19 +3715,15 @@ var SectionIndexLayout = ({
|
|
|
3561
3715
|
overflow: chipOverflow,
|
|
3562
3716
|
sections,
|
|
3563
3717
|
testID,
|
|
3564
|
-
onSelect:
|
|
3718
|
+
onSelect: pick
|
|
3565
3719
|
}
|
|
3566
3720
|
),
|
|
3567
3721
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { nativeID: sectionAnchorId(testID, activeKey), testID: sectionAnchorId(testID, activeKey), children: active?.content })
|
|
3568
3722
|
] });
|
|
3569
3723
|
}
|
|
3570
|
-
const
|
|
3571
|
-
setPicked(key);
|
|
3572
|
-
scrollToSection(sectionAnchorId(testID, key));
|
|
3573
|
-
};
|
|
3574
|
-
const sticky = stickyIndex && reactNative.Platform.OS === "web" ? WEB_STICKY : null;
|
|
3724
|
+
const stickyStyle = sticky.sticky && reactNative.Platform.OS === "web" ? WEB_STICKY : null;
|
|
3575
3725
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles31.wide, dense && { gap: DENSE_WIDE_GAP }], testID, children: [
|
|
3576
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style:
|
|
3726
|
+
/* @__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
3727
|
/* @__PURE__ */ jsxRuntime.jsx(SectionColumn, { sections, style: reactNative.StyleSheet.flatten([styles31.column, gap]), testID })
|
|
3578
3728
|
] });
|
|
3579
3729
|
};
|
|
@@ -4241,6 +4391,8 @@ exports.RecordHeader = RecordHeader;
|
|
|
4241
4391
|
exports.RowSelectedStyle = RowSelectedStyle;
|
|
4242
4392
|
exports.SECTION_INDEX_BREAKPOINT = SECTION_INDEX_BREAKPOINT;
|
|
4243
4393
|
exports.SECTION_INDEX_WIDTH = SECTION_INDEX_WIDTH;
|
|
4394
|
+
exports.SPY_ACTIVATION_RATIO = SPY_ACTIVATION_RATIO;
|
|
4395
|
+
exports.SPY_CLICK_LOCK_MS = SPY_CLICK_LOCK_MS;
|
|
4244
4396
|
exports.ScreenColumn = ScreenColumn;
|
|
4245
4397
|
exports.Section = Section;
|
|
4246
4398
|
exports.SectionChips = SectionChips;
|
|
@@ -4283,6 +4435,7 @@ exports.isRecordHeaderCompact = isRecordHeaderCompact;
|
|
|
4283
4435
|
exports.isSplitSideBySide = isSplitSideBySide;
|
|
4284
4436
|
exports.isWideWebViewport = isWideWebViewport;
|
|
4285
4437
|
exports.pageScale = pageScale;
|
|
4438
|
+
exports.pickActiveIndex = pickActiveIndex;
|
|
4286
4439
|
exports.resolveActiveKey = resolveActiveKey;
|
|
4287
4440
|
exports.resolveListDetailPanes = resolveListDetailPanes;
|
|
4288
4441
|
exports.resolveRowLook = resolveRowLook;
|
|
@@ -4298,6 +4451,7 @@ exports.useCopyToClipboard = useCopyToClipboard;
|
|
|
4298
4451
|
exports.useFocusTrap = useFocusTrap;
|
|
4299
4452
|
exports.useIsWideViewport = useIsWideViewport;
|
|
4300
4453
|
exports.useListRowTone = useListRowTone;
|
|
4454
|
+
exports.useScrollSpy = useScrollSpy;
|
|
4301
4455
|
exports.useVisibleViewport = useVisibleViewport;
|
|
4302
4456
|
//# sourceMappingURL=index.js.map
|
|
4303
4457
|
//# sourceMappingURL=index.js.map
|