@astryxdesign/core 0.7.15 → 0.7.16-canary.g54dd64e
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/AppShell/AppShell.d.ts.map +1 -1
- package/dist/AppShell/AppShell.js +8 -2
- package/dist/BottomSheet/BottomSheet.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheet.js +11 -6
- package/dist/DateInput/DateInput.d.ts +3 -3
- package/dist/DateInput/DateInput.d.ts.map +1 -1
- package/dist/DateInput/DateInput.js +13 -2
- package/dist/DateInput/NativeDateField.d.ts +1 -1
- package/dist/DateInput/NativeDateField.d.ts.map +1 -1
- package/dist/DateInput/NativeDateField.js +48 -31
- package/dist/DateInput/useTypedDate.d.ts +66 -6
- package/dist/DateInput/useTypedDate.d.ts.map +1 -1
- package/dist/DateInput/useTypedDate.js +151 -21
- package/dist/DateTimeInput/DateTimeInput.d.ts +3 -3
- package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.js +26 -3
- package/dist/DateTimeInput/NativeDateSegment.d.ts +8 -1
- package/dist/DateTimeInput/NativeDateSegment.d.ts.map +1 -1
- package/dist/DateTimeInput/NativeDateSegment.js +20 -14
- package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenu.js +10 -3
- package/dist/Field/InputClearButton.d.ts.map +1 -1
- package/dist/Field/InputClearButton.js +4 -2
- package/dist/InfoTip/InfoTip.d.ts +1 -1
- package/dist/InfoTip/InfoTip.d.ts.map +1 -1
- package/dist/InfoTip/InfoTip.js +4 -1
- package/dist/Layer/layerAnimations.stylex.d.ts.map +1 -1
- package/dist/Layer/layerAnimations.stylex.js +17 -13
- package/dist/Layer/layerEntranceSide.d.ts +24 -10
- package/dist/Layer/layerEntranceSide.d.ts.map +1 -1
- package/dist/Layer/layerEntranceSide.js +28 -13
- package/dist/Layer/useLayer.d.ts.map +1 -1
- package/dist/Layer/useLayer.js +14 -11
- package/dist/Lightbox/Lightbox.d.ts.map +1 -1
- package/dist/Lightbox/Lightbox.js +625 -180
- package/dist/List/ListItem.d.ts +3 -2
- package/dist/List/ListItem.d.ts.map +1 -1
- package/dist/List/ListReorderHandle.d.ts +7 -0
- package/dist/List/ListReorderHandle.d.ts.map +1 -1
- package/dist/List/ListReorderHandle.js +42 -58
- package/dist/List/listReorderContext.d.ts.map +1 -1
- package/dist/List/listReorderContext.js +4 -4
- package/dist/List/listReorderEngine.d.ts +50 -2
- package/dist/List/listReorderEngine.d.ts.map +1 -1
- package/dist/List/listReorderEngine.js +205 -10
- package/dist/MoreMenu/MoreMenu.d.ts +1 -1
- package/dist/MoreMenu/MoreMenu.d.ts.map +1 -1
- package/dist/MoreMenu/MoreMenu.js +4 -1
- package/dist/PowerSearch/PowerSearch.d.ts +1 -1
- package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearch.js +8 -4
- package/dist/PowerSearch/PowerSearchEditPopover.d.ts +4 -1
- package/dist/PowerSearch/PowerSearchEditPopover.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchEditPopover.js +4 -1
- package/dist/PowerSearch/PowerSearchFilterEditor.d.ts +1 -1
- package/dist/PowerSearch/PowerSearchFilterEditor.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchFilterEditor.js +7 -3
- package/dist/PowerSearch/PowerSearchToken.d.ts +1 -1
- package/dist/PowerSearch/PowerSearchToken.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchToken.js +4 -1
- package/dist/Selector/useSelectorPresentation.d.ts.map +1 -1
- package/dist/Selector/useSelectorPresentation.js +13 -12
- package/dist/Slider/Slider.d.ts.map +1 -1
- package/dist/Slider/Slider.js +6 -8
- package/dist/Table/BaseTable.d.ts +1 -1
- package/dist/Table/BaseTable.d.ts.map +1 -1
- package/dist/Table/BaseTable.js +265 -197
- package/dist/Table/Table.d.ts +5 -1
- package/dist/Table/Table.d.ts.map +1 -1
- package/dist/Table/index.d.ts +5 -3
- package/dist/Table/index.d.ts.map +1 -1
- package/dist/Table/index.js +2 -1
- package/dist/Table/plugins/infiniteScroll/TableInfiniteScrollWide.a11y.chromium.spec.d.ts.map +1 -0
- package/dist/Table/plugins/infiniteScroll/index.d.ts +9 -0
- package/dist/Table/plugins/infiniteScroll/index.d.ts.map +1 -0
- package/dist/Table/plugins/infiniteScroll/index.js +9 -0
- package/dist/Table/plugins/infiniteScroll/useTableInfiniteScroll.d.ts +29 -0
- package/dist/Table/plugins/infiniteScroll/useTableInfiniteScroll.d.ts.map +1 -0
- package/dist/Table/plugins/infiniteScroll/useTableInfiniteScroll.js +394 -0
- package/dist/Table/plugins/sortable/useTableSortableState.d.ts.map +1 -1
- package/dist/Table/plugins/sortable/useTableSortableState.js +4 -4
- package/dist/Table/plugins/stickyColumns/useTableStickyColumns.d.ts.map +1 -1
- package/dist/Table/plugins/stickyColumns/useTableStickyColumns.js +21 -1
- package/dist/Table/plugins/virtualization/TableColumnWindow.d.ts +4 -0
- package/dist/Table/plugins/virtualization/TableColumnWindow.d.ts.map +1 -0
- package/dist/Table/plugins/virtualization/TableColumnWindow.js +109 -0
- package/dist/Table/plugins/virtualization/index.d.ts +3 -1
- package/dist/Table/plugins/virtualization/index.d.ts.map +1 -1
- package/dist/Table/plugins/virtualization/index.js +3 -2
- package/dist/Table/plugins/virtualization/useTableColumnWindow.d.ts +33 -0
- package/dist/Table/plugins/virtualization/useTableColumnWindow.d.ts.map +1 -0
- package/dist/Table/plugins/virtualization/useTableColumnWindow.js +143 -0
- package/dist/Table/plugins/virtualization/useTableColumnsVirtualization.d.ts +23 -0
- package/dist/Table/plugins/virtualization/useTableColumnsVirtualization.d.ts.map +1 -0
- package/dist/Table/plugins/virtualization/useTableColumnsVirtualization.js +37 -0
- package/dist/Table/tableColumnWindowing.d.ts +85 -0
- package/dist/Table/tableColumnWindowing.d.ts.map +1 -0
- package/dist/Table/tableColumnWindowing.js +47 -0
- package/dist/Table/tablePinnedColumnRuns.d.ts +23 -0
- package/dist/Table/tablePinnedColumnRuns.d.ts.map +1 -0
- package/dist/Table/tablePinnedColumnRuns.js +41 -0
- package/dist/Table/tableRuntime.d.ts +14 -2
- package/dist/Table/tableRuntime.d.ts.map +1 -1
- package/dist/Table/tableRuntime.js +32 -11
- package/dist/Table/types.d.ts +28 -2
- package/dist/Table/types.d.ts.map +1 -1
- package/dist/Table/useBaseTablePlugins.js +2 -2
- package/dist/Text/useTruncation.d.ts +6 -1
- package/dist/Text/useTruncation.d.ts.map +1 -1
- package/dist/Text/useTruncation.js +53 -35
- package/dist/TextArea/TextArea.d.ts +10 -1
- package/dist/TextArea/TextArea.d.ts.map +1 -1
- package/dist/TextArea/TextArea.js +2 -0
- package/dist/Toast/Toast.d.ts +1 -1
- package/dist/Toast/Toast.d.ts.map +1 -1
- package/dist/Toast/Toast.js +4 -2
- package/dist/astryx.css +22 -11
- package/dist/dragToSnapPoints/createDragToSnapPoints.d.ts +156 -0
- package/dist/dragToSnapPoints/createDragToSnapPoints.d.ts.map +1 -1
- package/dist/dragToSnapPoints/createDragToSnapPoints.js +313 -97
- package/dist/gestures/createPanGesture.d.ts +41 -0
- package/dist/gestures/createPanGesture.d.ts.map +1 -1
- package/dist/gestures/createPanGesture.js +66 -22
- package/dist/hooks/useMenuPress.d.ts.map +1 -1
- package/dist/hooks/useMenuPress.js +36 -2
- package/dist/i18n/generated-english/DateInput/NativeDateField.generated.d.ts.map +1 -1
- package/dist/i18n/generated-english/DateInput/NativeDateField.generated.js +0 -1
- package/dist/i18n/generated-english/DateTimeInput/NativeDateSegment.generated.d.ts.map +1 -1
- package/dist/i18n/generated-english/DateTimeInput/NativeDateSegment.generated.js +0 -1
- package/dist/i18n/generated-english/Lightbox/Lightbox.generated.d.ts.map +1 -1
- package/dist/i18n/generated-english/Lightbox/Lightbox.generated.js +2 -0
- package/dist/i18n/generated-english/Table/plugins/infiniteScroll/useTableInfiniteScroll.generated.d.ts +8 -0
- package/dist/i18n/generated-english/Table/plugins/infiniteScroll/useTableInfiniteScroll.generated.d.ts.map +1 -0
- package/dist/i18n/generated-english/Table/plugins/infiniteScroll/useTableInfiniteScroll.generated.js +12 -0
- package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/en.generated.js +32 -0
- package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/pseudo.generated.js +32 -0
- package/dist/internal/touch.d.ts +1 -1
- package/dist/internal/touch.d.ts.map +1 -1
- package/dist/internal/touch.js +1 -1
- package/dist/motion/animator.d.ts +28 -1
- package/dist/motion/animator.d.ts.map +1 -1
- package/dist/motion/animator.js +99 -19
- package/dist/theme/generateThemeRules.d.ts.map +1 -1
- package/dist/theme/generateThemeRules.js +14 -3
- package/dist/theme/tokenReferences.d.ts +7 -15
- package/dist/theme/tokenReferences.d.ts.map +1 -1
- package/dist/theme/tokenReferences.js +49 -7
- package/dist/utils/clickGuard.d.ts +8 -1
- package/dist/utils/clickGuard.d.ts.map +1 -1
- package/dist/utils/clickGuard.js +24 -4
- package/dist/utils/sharedResizeObserver.d.ts +18 -2
- package/dist/utils/sharedResizeObserver.d.ts.map +1 -1
- package/dist/utils/sharedResizeObserver.js +43 -2
- package/dist/utils/themeProps.d.ts +8 -0
- package/dist/utils/themeProps.d.ts.map +1 -1
- package/dist/utils/themeProps.js +17 -0
- package/dist/utils/timeParser.d.ts +3 -1
- package/dist/utils/timeParser.d.ts.map +1 -1
- package/dist/utils/timeParser.js +7 -3
- package/dist/virtualization/listWindow.d.ts +18 -2
- package/dist/virtualization/listWindow.d.ts.map +1 -1
- package/dist/virtualization/listWindow.js +55 -2
- package/dist/virtualization/useInlineListWindow.d.ts +40 -0
- package/dist/virtualization/useInlineListWindow.d.ts.map +1 -0
- package/dist/virtualization/useInlineListWindow.js +58 -0
- package/locales/en.json +129 -1
- package/locales/pseudo.json +96 -0
- package/package.json +5 -5
- package/src/AppShell/AppShell.tsx +12 -3
- package/src/BottomSheet/BottomSheet.tsx +12 -8
- package/src/ButtonGroup/ButtonGroup.doc.mjs +5 -0
- package/src/CheckboxInput/CheckboxInput.doc.mjs +3 -0
- package/src/DateInput/DateInput.doc.mjs +3 -3
- package/src/DateInput/DateInput.tsx +27 -5
- package/src/DateInput/NativeDateField.tsx +58 -36
- package/src/DateInput/useTypedDate.ts +226 -55
- package/src/DateTimeInput/DateTimeInput.doc.mjs +3 -3
- package/src/DateTimeInput/DateTimeInput.tsx +38 -5
- package/src/DateTimeInput/NativeDateSegment.tsx +35 -13
- package/src/DropdownMenu/DropdownMenu.tsx +10 -3
- package/src/Field/InputClearButton.tsx +3 -1
- package/src/InfoTip/InfoTip.doc.mjs +2 -2
- package/src/InfoTip/InfoTip.tsx +3 -0
- package/src/Layer/layerAnimations.stylex.ts +13 -9
- package/src/Layer/layerEntranceSide.ts +48 -11
- package/src/Layer/useLayer.tsx +14 -12
- package/src/Lightbox/Lightbox.doc.mjs +2 -1
- package/src/Lightbox/Lightbox.tsx +864 -257
- package/src/List/ListItem.tsx +3 -2
- package/src/List/ListReorderHandle.tsx +59 -77
- package/src/List/listReorderContext.ts +3 -4
- package/src/List/listReorderEngine.tsx +246 -11
- package/src/MoreMenu/MoreMenu.doc.mjs +2 -2
- package/src/MoreMenu/MoreMenu.tsx +3 -0
- package/src/NumberInput/NumberInput.doc.mjs +3 -0
- package/src/PowerSearch/PowerSearch.doc.mjs +2 -2
- package/src/PowerSearch/PowerSearch.tsx +7 -3
- package/src/PowerSearch/PowerSearchEditPopover.tsx +12 -2
- package/src/PowerSearch/PowerSearchFilterEditor.tsx +3 -0
- package/src/PowerSearch/PowerSearchToken.tsx +3 -0
- package/src/ProgressBar/ProgressBar.doc.mjs +3 -0
- package/src/SegmentedControl/SegmentedControl.doc.mjs +5 -0
- package/src/Selector/useSelectorPresentation.ts +16 -12
- package/src/Slider/Slider.tsx +6 -8
- package/src/StatusDot/StatusDot.doc.mjs +3 -0
- package/src/Switch/Switch.doc.mjs +3 -0
- package/src/TabList/TabList.doc.mjs +4 -0
- package/src/Table/BaseTable.tsx +406 -287
- package/src/Table/Table.doc.mjs +2 -2
- package/src/Table/Table.tsx +5 -1
- package/src/Table/index.ts +8 -1
- package/src/Table/plugins/infiniteScroll/index.ts +10 -0
- package/src/Table/plugins/infiniteScroll/useTableInfiniteScroll.tsx +523 -0
- package/src/Table/plugins/sortable/useTableSortableState.tsx +4 -4
- package/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx +31 -1
- package/src/Table/plugins/virtualization/TableColumnWindow.tsx +150 -0
- package/src/Table/plugins/virtualization/index.ts +3 -1
- package/src/Table/plugins/virtualization/useTableColumnWindow.ts +168 -0
- package/src/Table/plugins/virtualization/useTableColumnsVirtualization.ts +53 -0
- package/src/Table/tableColumnWindowing.ts +131 -0
- package/src/Table/tablePinnedColumnRuns.ts +55 -0
- package/src/Table/tableRuntime.ts +44 -11
- package/src/Table/types.ts +25 -2
- package/src/Table/useBaseTablePlugins.ts +2 -2
- package/src/Table/useTableColumnsVirtualization.doc.mjs +29 -0
- package/src/Table/useTableInfiniteScroll.doc.mjs +58 -0
- package/src/Text/Heading.doc.mjs +3 -0
- package/src/Text/useTruncation.doc.mjs +10 -0
- package/src/Text/useTruncation.ts +53 -35
- package/src/TextArea/TextArea.doc.mjs +15 -0
- package/src/TextArea/TextArea.tsx +11 -0
- package/src/TextInput/TextInput.doc.mjs +3 -0
- package/src/Toast/Toast.doc.mjs +2 -2
- package/src/Toast/Toast.tsx +3 -1
- package/src/TopNav/TopNav.doc.mjs +4 -0
- package/src/dragToSnapPoints/createDragToSnapPoints.ts +437 -119
- package/src/gestures/createPanGesture.ts +112 -39
- package/src/hooks/useMenuPress.ts +39 -0
- package/src/i18n/generated-english/DateInput/NativeDateField.generated.ts +0 -1
- package/src/i18n/generated-english/DateTimeInput/NativeDateSegment.generated.ts +0 -1
- package/src/i18n/generated-english/Lightbox/Lightbox.generated.ts +2 -0
- package/src/i18n/generated-english/Table/plugins/infiniteScroll/useTableInfiniteScroll.generated.ts +13 -0
- package/src/i18n/generated-locales/en.generated.ts +34 -0
- package/src/i18n/generated-locales/pseudo.generated.ts +34 -0
- package/src/internal/touch.ts +5 -1
- package/src/motion/animator.ts +181 -23
- package/src/theme/generateThemeRules.ts +14 -3
- package/src/theme/tokenReferences.ts +48 -7
- package/src/utils/clickGuard.ts +30 -3
- package/src/utils/sharedResizeObserver.ts +46 -2
- package/src/utils/themeProps.ts +17 -0
- package/src/utils/timeParser.ts +7 -9
- package/src/virtualization/listWindow.ts +76 -2
- package/src/virtualization/useInlineListWindow.ts +119 -0
package/dist/Table/index.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
/** Semantic row outcome resolved through the active theme. */
|
|
15
15
|
|
|
16
16
|
export { Table } from "./Table.js";
|
|
17
|
-
export { useTableRowsVirtualization } from "./plugins/virtualization/index.js";
|
|
17
|
+
export { useTableColumnsVirtualization, useTableRowsVirtualization } from "./plugins/virtualization/index.js";
|
|
18
18
|
export { TableRow } from "./TableRow.js";
|
|
19
19
|
export { TableCell } from "./TableCell.js";
|
|
20
20
|
export { TableHeaderCell } from "./TableHeaderCell.js";
|
|
@@ -34,6 +34,7 @@ export { useTableColumnResize } from "./plugins/columnResize/index.js";
|
|
|
34
34
|
export { useTableStickyColumns } from "./plugins/stickyColumns/index.js";
|
|
35
35
|
export { useTableGroupedRows } from "./plugins/groupedRows/index.js";
|
|
36
36
|
export { useTableRowIndex } from "./plugins/rowIndex/index.js";
|
|
37
|
+
export { useTableInfiniteScroll } from "./plugins/infiniteScroll/index.js";
|
|
37
38
|
export { useTableRowStatus } from "./plugins/rowStatus/index.js";
|
|
38
39
|
export { useTableRowExpansion } from "./plugins/rowExpansion/index.js";
|
|
39
40
|
export { useTableTreeData, useTableTreeState } from "./plugins/tree/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableInfiniteScrollWide.a11y.chromium.spec.d.ts","sourceRoot":"","sources":["../../../../src/Table/plugins/infiniteScroll/TableInfiniteScrollWide.a11y.chromium.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file index.ts
|
|
3
|
+
* @input Infinite-scroll hook implementation
|
|
4
|
+
* @output useTableInfiniteScroll and its three-field configuration type
|
|
5
|
+
* @position Infinite-scroll module entry point
|
|
6
|
+
*/
|
|
7
|
+
export { useTableInfiniteScroll } from './useTableInfiniteScroll.js';
|
|
8
|
+
export type { UseTableInfiniteScrollConfig } from './useTableInfiniteScroll.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Table/plugins/infiniteScroll/index.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,OAAO,EAAC,sBAAsB,EAAC,MAAM,0BAA0B,CAAC;AAChE,YAAY,EAAC,4BAA4B,EAAC,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file index.ts
|
|
5
|
+
* @input Infinite-scroll hook implementation
|
|
6
|
+
* @output useTableInfiniteScroll and its three-field configuration type
|
|
7
|
+
* @position Infinite-scroll module entry point
|
|
8
|
+
*/
|
|
9
|
+
export { useTableInfiniteScroll } from "./useTableInfiniteScroll.js";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { TablePlugin } from '../../types.js';
|
|
2
|
+
export interface UseTableInfiniteScrollConfig {
|
|
3
|
+
/** Whether another batch can be loaded. */
|
|
4
|
+
hasMore: boolean;
|
|
5
|
+
/** Caller-controlled loading; the request latch also contributes busy state. */
|
|
6
|
+
isLoading: boolean;
|
|
7
|
+
/** Complete the batch work before fulfilling. Rows and errors stay caller-owned. */
|
|
8
|
+
onLoadMore: () => Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Load successive batches without owning rows, pagination or a request client.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```
|
|
15
|
+
* const plugin = useTableInfiniteScroll<Item>({
|
|
16
|
+
* hasMore,
|
|
17
|
+
* isLoading,
|
|
18
|
+
* onLoadMore: async () => {
|
|
19
|
+
* const batch = await fetchNextBatch();
|
|
20
|
+
* setRows(rows => [...rows, ...batch.rows]);
|
|
21
|
+
* setHasMore(batch.hasMore);
|
|
22
|
+
* },
|
|
23
|
+
* });
|
|
24
|
+
* <Table data={rows} idKey="id" plugins={{infiniteScroll: plugin}} />
|
|
25
|
+
* ```
|
|
26
|
+
* Reset by remounting the component owning both this hook and its Table.
|
|
27
|
+
*/
|
|
28
|
+
export declare function useTableInfiniteScroll<T extends Record<string, unknown>>(config: UseTableInfiniteScrollConfig): TablePlugin<T>;
|
|
29
|
+
//# sourceMappingURL=useTableInfiniteScroll.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTableInfiniteScroll.d.ts","sourceRoot":"","sources":["../../../../src/Table/plugins/infiniteScroll/useTableInfiniteScroll.tsx"],"names":[],"mappings":"AA0CA,OAAO,KAAK,EAAC,WAAW,EAAqB,MAAM,aAAa,CAAC;AAEjE,MAAM,WAAW,4BAA4B;IAC3C,2CAA2C;IAC3C,OAAO,EAAE,OAAO,CAAC;IACjB,gFAAgF;IAChF,SAAS,EAAE,OAAO,CAAC;IACnB,oFAAoF;IACpF,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACjC;AA2ZD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACtE,MAAM,EAAE,4BAA4B,GACnC,WAAW,CAAC,CAAC,CAAC,CAwChB"}
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @file useTableInfiniteScroll.tsx
|
|
7
|
+
* @input Controlled loading, parent render context, Button and IntersectionObserver
|
|
8
|
+
* @output Stable generic TablePlugin, immutable loading state and inline-sticky load command
|
|
9
|
+
* @position Infinite-scroll module; caller owns rows, transport and errors
|
|
10
|
+
*
|
|
11
|
+
* SYNC: useTableInfiniteScroll.test.tsx, index.ts, ../../useTableInfiniteScroll.doc.mjs
|
|
12
|
+
*/
|
|
13
|
+
import { use, useCallback, useEffect, useLayoutEffect, useReducer, useRef, useState, useSyncExternalStore } from 'react';
|
|
14
|
+
import * as stylex from '@stylexjs/stylex';
|
|
15
|
+
import { Button } from "../../../Button/Button.js";
|
|
16
|
+
import { registerEnglishFallback, useComponentTranslator } from "../../../i18n/useComponentTranslator.js";
|
|
17
|
+
import english from "../../../i18n/generated-english/Table/plugins/infiniteScroll/useTableInfiniteScroll.generated.js";
|
|
18
|
+
registerEnglishFallback(english);
|
|
19
|
+
import "../../../theme/tokens.stylex.js";
|
|
20
|
+
import { spacingVars } from "../../../theme/tokens.stylex.js";
|
|
21
|
+
import { moveFocusLeftBehind, noteFocusWithin } from "../../../utils/focusReturn.js";
|
|
22
|
+
import { useFocusLeavingChange } from "../../../utils/useFocusLeavingChange.js";
|
|
23
|
+
import { LayoutChangeSnapshot } from "../../../motion/LayoutChangeSnapshot.js";
|
|
24
|
+
import { createDevWarnings } from "../../../utils/devWarning.js";
|
|
25
|
+
import { TableRuntimeContext } from "../../tableRuntime.js";
|
|
26
|
+
import { useInteractionModalityTracking } from "../../../utils/interactionModality.js";
|
|
27
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
28
|
+
function isAdmitted(context) {
|
|
29
|
+
return context?.mode === 'data' && context.rowModel === 'flat';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Hook-owned request/store lifetime, independent of the replaceable Table child. */
|
|
33
|
+
function createRuntime(initial, wake) {
|
|
34
|
+
let snapshot = Object.freeze({
|
|
35
|
+
isLoading: initial.hasMore && initial.isLoading,
|
|
36
|
+
hasMore: initial.hasMore
|
|
37
|
+
});
|
|
38
|
+
const serverSnapshot = snapshot;
|
|
39
|
+
let surface = Object.freeze({
|
|
40
|
+
hasMore: initial.hasMore,
|
|
41
|
+
isLoading: snapshot.isLoading,
|
|
42
|
+
version: 0
|
|
43
|
+
});
|
|
44
|
+
const listeners = new Set();
|
|
45
|
+
// Each diagnosis warns once per hook instance.
|
|
46
|
+
const warnOnce = createDevWarnings();
|
|
47
|
+
const subscribe = listener => {
|
|
48
|
+
listeners.add(listener);
|
|
49
|
+
return () => {
|
|
50
|
+
listeners.delete(listener);
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
const runtime = {
|
|
54
|
+
config: initial,
|
|
55
|
+
context: undefined,
|
|
56
|
+
stopObservation: undefined,
|
|
57
|
+
request: null,
|
|
58
|
+
isActive: true,
|
|
59
|
+
isTableAdmitted: false,
|
|
60
|
+
isAutoPaused: false,
|
|
61
|
+
generation: 0,
|
|
62
|
+
commitCount: 0,
|
|
63
|
+
version: 0,
|
|
64
|
+
renderState: {
|
|
65
|
+
subscribe,
|
|
66
|
+
getSnapshot: () => snapshot,
|
|
67
|
+
getServerSnapshot: () => serverSnapshot
|
|
68
|
+
},
|
|
69
|
+
subscribe,
|
|
70
|
+
getSurface: () => surface,
|
|
71
|
+
diagnose(message) {
|
|
72
|
+
warnOnce('useTableInfiniteScroll', message);
|
|
73
|
+
},
|
|
74
|
+
activate() {
|
|
75
|
+
runtime.isActive = true;
|
|
76
|
+
},
|
|
77
|
+
deactivate() {
|
|
78
|
+
runtime.isActive = false;
|
|
79
|
+
runtime.generation++;
|
|
80
|
+
runtime.request = null;
|
|
81
|
+
runtime.version++;
|
|
82
|
+
},
|
|
83
|
+
attach(context, stopObservation, isTableAdmitted) {
|
|
84
|
+
runtime.context = context;
|
|
85
|
+
runtime.stopObservation = stopObservation;
|
|
86
|
+
runtime.isTableAdmitted = isTableAdmitted;
|
|
87
|
+
},
|
|
88
|
+
detach(context, stopObservation) {
|
|
89
|
+
if (runtime.context === context) {
|
|
90
|
+
runtime.context = undefined;
|
|
91
|
+
}
|
|
92
|
+
if (runtime.stopObservation === stopObservation) {
|
|
93
|
+
runtime.stopObservation = undefined;
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
commit(config) {
|
|
97
|
+
runtime.config = config;
|
|
98
|
+
runtime.commitCount++;
|
|
99
|
+
const request = runtime.request;
|
|
100
|
+
// Settlement schedules a hook commit. A pre-call false value is never completion.
|
|
101
|
+
if (request?.settledAt != null && runtime.commitCount > request.settledAt && !config.isLoading) {
|
|
102
|
+
runtime.request = null;
|
|
103
|
+
if (request.isSuccessful) {
|
|
104
|
+
runtime.isAutoPaused = false;
|
|
105
|
+
}
|
|
106
|
+
runtime.version++;
|
|
107
|
+
}
|
|
108
|
+
const isLoading = config.hasMore && (config.isLoading || runtime.request !== null);
|
|
109
|
+
if (snapshot.isLoading !== isLoading || snapshot.hasMore !== config.hasMore) {
|
|
110
|
+
snapshot = Object.freeze({
|
|
111
|
+
isLoading,
|
|
112
|
+
hasMore: config.hasMore
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
if (surface.hasMore !== config.hasMore || surface.isLoading !== isLoading || surface.version !== runtime.version) {
|
|
116
|
+
surface = Object.freeze({
|
|
117
|
+
hasMore: config.hasMore,
|
|
118
|
+
isLoading,
|
|
119
|
+
version: runtime.version
|
|
120
|
+
});
|
|
121
|
+
// The hook's commit effect is the only broadcast writer. Render never notifies.
|
|
122
|
+
for (const listener of listeners) {
|
|
123
|
+
listener();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
invoke(isAutomatic) {
|
|
128
|
+
const {
|
|
129
|
+
config
|
|
130
|
+
} = runtime;
|
|
131
|
+
if (!runtime.isActive || !runtime.isTableAdmitted || !isAdmitted(runtime.context) || !config.hasMore || config.isLoading || runtime.request || isAutomatic && runtime.isAutoPaused) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const request = {
|
|
135
|
+
generation: runtime.generation,
|
|
136
|
+
settledAt: null,
|
|
137
|
+
isSuccessful: false
|
|
138
|
+
};
|
|
139
|
+
runtime.request = request;
|
|
140
|
+
runtime.version++;
|
|
141
|
+
// Stop observing when the latch is taken. A request that resolves at
|
|
142
|
+
// once may never render a busy state. Keep the last visibility until the
|
|
143
|
+
// next observer reports.
|
|
144
|
+
runtime.stopObservation?.();
|
|
145
|
+
wake();
|
|
146
|
+
const settle = isSuccessful => {
|
|
147
|
+
if (!runtime.isActive || runtime.generation !== request.generation || runtime.request !== request) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
request.isSuccessful = isSuccessful;
|
|
151
|
+
request.settledAt = runtime.commitCount;
|
|
152
|
+
if (!isSuccessful) {
|
|
153
|
+
runtime.isAutoPaused = true;
|
|
154
|
+
}
|
|
155
|
+
runtime.version++;
|
|
156
|
+
wake();
|
|
157
|
+
};
|
|
158
|
+
try {
|
|
159
|
+
const result = config.onLoadMore();
|
|
160
|
+
if (result == null || typeof result.then !== 'function') {
|
|
161
|
+
runtime.request = null;
|
|
162
|
+
runtime.isAutoPaused = true;
|
|
163
|
+
runtime.version++;
|
|
164
|
+
runtime.diagnose('onLoadMore must return a Promise<void>; automatic loading is paused.');
|
|
165
|
+
wake();
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
Promise.resolve(result).then(() => settle(true), () => settle(false));
|
|
169
|
+
} catch {
|
|
170
|
+
settle(false);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
return runtime;
|
|
175
|
+
}
|
|
176
|
+
const styles = {
|
|
177
|
+
viewport: {
|
|
178
|
+
k1xSpc: "xrvj5dj",
|
|
179
|
+
$$css: true
|
|
180
|
+
},
|
|
181
|
+
command: {
|
|
182
|
+
kVAEAm: "x7wzq59",
|
|
183
|
+
kLqNvP: "x1o0tod",
|
|
184
|
+
kt4wiu: "xtijo5x",
|
|
185
|
+
$$css: true
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
/** A single surface owns its observer, rearm task and focus-handoff resource. */
|
|
190
|
+
function InfiniteScrollSurface({
|
|
191
|
+
runtime,
|
|
192
|
+
context
|
|
193
|
+
}) {
|
|
194
|
+
const view = useSyncExternalStore(runtime.subscribe, runtime.getSurface, runtime.getSurface);
|
|
195
|
+
const t = useComponentTranslator();
|
|
196
|
+
const tableRuntime = use(TableRuntimeContext);
|
|
197
|
+
// Table bounds its block viewport only while it windows its rows.
|
|
198
|
+
const hasBlockViewport = tableRuntime?.viewportHeight != null;
|
|
199
|
+
// Table denies loading under a caller's scroll wrapper. A surface rendered
|
|
200
|
+
// outside any Table has no runtime to deny it.
|
|
201
|
+
const isTableAdmitted = tableRuntime?.isLoadingAdmitted !== false;
|
|
202
|
+
useInteractionModalityTracking();
|
|
203
|
+
const surfaceRef = useRef(null);
|
|
204
|
+
const sentinelRef = useRef(null);
|
|
205
|
+
const resourcesRef = useRef({
|
|
206
|
+
observer: null,
|
|
207
|
+
root: null,
|
|
208
|
+
node: null,
|
|
209
|
+
isVisible: false,
|
|
210
|
+
task: null,
|
|
211
|
+
context: undefined,
|
|
212
|
+
viewport: null
|
|
213
|
+
});
|
|
214
|
+
const disconnect = useCallback(() => {
|
|
215
|
+
const state = resourcesRef.current;
|
|
216
|
+
state.observer?.disconnect();
|
|
217
|
+
state.observer = null;
|
|
218
|
+
if (state.task !== null) {
|
|
219
|
+
clearTimeout(state.task);
|
|
220
|
+
}
|
|
221
|
+
state.task = null;
|
|
222
|
+
}, []);
|
|
223
|
+
// When the last batch removes a focused Load more command, focus moves to
|
|
224
|
+
// the Table scroll region, without scrolling. Focus that a caller already
|
|
225
|
+
// moved elsewhere stays there.
|
|
226
|
+
const noteExhaustion = useFocusLeavingChange(view.hasMore, hadMore => hadMore ? noteFocusWithin(surfaceRef.current) : null, focus => moveFocusLeftBehind(focus, context.viewport.current ?? resourcesRef.current.viewport, null, {
|
|
227
|
+
preventScroll: true
|
|
228
|
+
}));
|
|
229
|
+
const setSentinel = useCallback(node => {
|
|
230
|
+
if (sentinelRef.current !== node) {
|
|
231
|
+
disconnect();
|
|
232
|
+
resourcesRef.current.isVisible = false;
|
|
233
|
+
}
|
|
234
|
+
sentinelRef.current = node;
|
|
235
|
+
}, [disconnect]);
|
|
236
|
+
useEffect(() => {
|
|
237
|
+
// Sync the sentinel's IntersectionObserver with the committed loading
|
|
238
|
+
// state. Parent refs are attached by now.
|
|
239
|
+
runtime.attach(context, disconnect, isTableAdmitted);
|
|
240
|
+
if (isAdmitted(context) && !isTableAdmitted) {
|
|
241
|
+
runtime.diagnose("Loading requires the Table's own scroll wrapper; a caller scrollWrapper gets no loading surface.");
|
|
242
|
+
}
|
|
243
|
+
const state = resourcesRef.current;
|
|
244
|
+
state.context = context;
|
|
245
|
+
state.viewport = context.viewport.current;
|
|
246
|
+
const root = hasBlockViewport ? context.viewport.current : null;
|
|
247
|
+
const node = sentinelRef.current;
|
|
248
|
+
if (state.root !== root || state.node !== node) {
|
|
249
|
+
disconnect();
|
|
250
|
+
state.isVisible = false;
|
|
251
|
+
state.root = root;
|
|
252
|
+
state.node = node;
|
|
253
|
+
}
|
|
254
|
+
const canObserve = isTableAdmitted && isAdmitted(context) && view.hasMore && !view.isLoading && !runtime.isAutoPaused;
|
|
255
|
+
if (!canObserve || !node) {
|
|
256
|
+
disconnect();
|
|
257
|
+
if (!view.hasMore) {
|
|
258
|
+
state.isVisible = false;
|
|
259
|
+
}
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
if (typeof IntersectionObserver === 'undefined') {
|
|
263
|
+
disconnect();
|
|
264
|
+
runtime.diagnose('IntersectionObserver is unavailable; use the manual Load more command.');
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
if (state.observer) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
const isRearming = state.isVisible;
|
|
271
|
+
const observer = new IntersectionObserver(entries => {
|
|
272
|
+
if (state.observer !== observer || state.node !== node || !runtime.isActive) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
for (const entry of entries) {
|
|
276
|
+
if (entry.target !== node) {
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
state.isVisible = entry.isIntersecting;
|
|
280
|
+
if (!state.isVisible) {
|
|
281
|
+
if (state.task !== null) {
|
|
282
|
+
clearTimeout(state.task);
|
|
283
|
+
}
|
|
284
|
+
state.task = null;
|
|
285
|
+
} else if (isRearming) {
|
|
286
|
+
// Reacquisition's native entry refreshes visibility after appended rows.
|
|
287
|
+
// Never load from stale pre-append geometry or a recursive microtask.
|
|
288
|
+
if (state.task === null) {
|
|
289
|
+
state.task = setTimeout(() => {
|
|
290
|
+
state.task = null;
|
|
291
|
+
if (state.observer === observer && state.node === node && state.isVisible) {
|
|
292
|
+
runtime.invoke(true);
|
|
293
|
+
}
|
|
294
|
+
}, 0);
|
|
295
|
+
}
|
|
296
|
+
} else {
|
|
297
|
+
runtime.invoke(true);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}, {
|
|
301
|
+
root,
|
|
302
|
+
rootMargin: '0px',
|
|
303
|
+
threshold: 0
|
|
304
|
+
});
|
|
305
|
+
state.observer = observer;
|
|
306
|
+
observer.observe(node);
|
|
307
|
+
});
|
|
308
|
+
// Disconnect the observer and detach the surface on unmount.
|
|
309
|
+
useLayoutEffect(() => () => {
|
|
310
|
+
disconnect();
|
|
311
|
+
runtime.detach(resourcesRef.current.context, disconnect);
|
|
312
|
+
}, [disconnect, runtime]);
|
|
313
|
+
const snapshot = /*#__PURE__*/_jsx(LayoutChangeSnapshot, {
|
|
314
|
+
value: view.hasMore,
|
|
315
|
+
onBeforeChange: noteExhaustion
|
|
316
|
+
});
|
|
317
|
+
if (!view.hasMore || !isTableAdmitted || !isAdmitted(context)) {
|
|
318
|
+
return snapshot;
|
|
319
|
+
}
|
|
320
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
321
|
+
children: [snapshot, /*#__PURE__*/_jsxs("div", {
|
|
322
|
+
ref: surfaceRef,
|
|
323
|
+
...{
|
|
324
|
+
className: "x78zum5 xdt5ytf x6s0dn4 xce4md1 x1txdalj"
|
|
325
|
+
},
|
|
326
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
327
|
+
ref: setSentinel,
|
|
328
|
+
...{
|
|
329
|
+
className: "xjm9jq1 xh8yej3 x2lah0s"
|
|
330
|
+
},
|
|
331
|
+
"aria-hidden": "true"
|
|
332
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
333
|
+
xstyle: styles.command,
|
|
334
|
+
label: t('@astryx.table.loadMore'),
|
|
335
|
+
isLoading: view.isLoading,
|
|
336
|
+
onClick: () => runtime.invoke(false)
|
|
337
|
+
})]
|
|
338
|
+
})]
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Load successive batches without owning rows, pagination or a request client.
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* ```
|
|
347
|
+
* const plugin = useTableInfiniteScroll<Item>({
|
|
348
|
+
* hasMore,
|
|
349
|
+
* isLoading,
|
|
350
|
+
* onLoadMore: async () => {
|
|
351
|
+
* const batch = await fetchNextBatch();
|
|
352
|
+
* setRows(rows => [...rows, ...batch.rows]);
|
|
353
|
+
* setHasMore(batch.hasMore);
|
|
354
|
+
* },
|
|
355
|
+
* });
|
|
356
|
+
* <Table data={rows} idKey="id" plugins={{infiniteScroll: plugin}} />
|
|
357
|
+
* ```
|
|
358
|
+
* Reset by remounting the component owning both this hook and its Table.
|
|
359
|
+
*/
|
|
360
|
+
export function useTableInfiniteScroll(config) {
|
|
361
|
+
const [, wake] = useReducer(version => version + 1, 0);
|
|
362
|
+
const [runtime] = useState(() => createRuntime(config, wake));
|
|
363
|
+
const [plugin] = useState(() => ({
|
|
364
|
+
rowModel: 'flat',
|
|
365
|
+
// Table hides its default empty row while this source loads.
|
|
366
|
+
renderState: runtime.renderState,
|
|
367
|
+
transformScrollWrapper(props, context) {
|
|
368
|
+
if (!isAdmitted(context)) {
|
|
369
|
+
runtime.diagnose(context == null ? 'Loading requires an explicit Table render context; no loading surface is added.' : context.mode !== 'data' ? 'Loading requires a data-driven Table; children mode remains unchanged.' : "Loading requires admitted flat product rows; body modifiers must declare rowModel: 'flat'.");
|
|
370
|
+
return props;
|
|
371
|
+
}
|
|
372
|
+
return {
|
|
373
|
+
...props,
|
|
374
|
+
xstyle: [...props.xstyle, styles.viewport],
|
|
375
|
+
afterTable: /*#__PURE__*/_jsxs(_Fragment, {
|
|
376
|
+
children: [props.afterTable, /*#__PURE__*/_jsx(InfiniteScrollSurface, {
|
|
377
|
+
runtime: runtime,
|
|
378
|
+
context: context
|
|
379
|
+
})]
|
|
380
|
+
})
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
}));
|
|
384
|
+
useLayoutEffect(() => {
|
|
385
|
+
// Synchronize the request runtime's mount lifetime and stale-settlement generation.
|
|
386
|
+
runtime.activate();
|
|
387
|
+
return () => runtime.deactivate();
|
|
388
|
+
}, [runtime]);
|
|
389
|
+
useLayoutEffect(() => {
|
|
390
|
+
// Publish current controlled state only after commit, including settle-only commits.
|
|
391
|
+
runtime.commit(config);
|
|
392
|
+
});
|
|
393
|
+
return plugin;
|
|
394
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTableSortableState.d.ts","sourceRoot":"","sources":["../../../../src/Table/plugins/sortable/useTableSortableState.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAC,cAAc,EAAE,sBAAsB,EAAC,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"useTableSortableState.d.ts","sourceRoot":"","sources":["../../../../src/Table/plugins/sortable/useTableSortableState.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAC,cAAc,EAAE,sBAAsB,EAAC,MAAM,oBAAoB,CAAC;AAQ/E;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC;AAqB5D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,2BAA2B,CAC1C,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,QAAQ,SAAS,MAAM,GAAG,MAAM;IAEhC;;;OAGG;IACH,IAAI,EAAE,CAAC,EAAE,CAAC;IAEV;;;;OAIG;IACH,WAAW,CAAC,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC;IAEvC;;;OAGG;IACH,IAAI,CAAC,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC;IAEhC;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;IAExD;;;;;;;;;;;;;;;;;;OAkBG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEhE;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAMD,MAAM,WAAW,2BAA2B,CAC1C,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,QAAQ,SAAS,MAAM,GAAG,MAAM;IAEhC,8FAA8F;IAC9F,UAAU,EAAE,CAAC,EAAE,CAAC;IAEhB,0BAA0B;IAC1B,IAAI,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC;IAE/B,gDAAgD;IAChD,UAAU,EAAE,sBAAsB,CAAC,QAAQ,CAAC,CAAC;IAE7C;;;OAGG;IACH,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;CAC/B;AAmFD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,qBAAqB,CACnC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,QAAQ,SAAS,MAAM,GAAG,MAAM,EAEhC,MAAM,EAAE,2BAA2B,CAAC,CAAC,EAAE,QAAQ,CAAC,GAC/C,2BAA2B,CAAC,CAAC,EAAE,QAAQ,CAAC,CA6D1C"}
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { useState, useMemo, useCallback, useRef } from 'react';
|
|
20
20
|
import { useCollator } from "../../../i18n/useCollator.js";
|
|
21
|
+
import { useCommittedRef } from "../../../hooks/useCommittedRef.js";
|
|
21
22
|
|
|
22
23
|
// =============================================================================
|
|
23
24
|
// Comparator Types
|
|
@@ -175,10 +176,9 @@ export function useTableSortableState(config) {
|
|
|
175
176
|
comparatorsRef.current = comparators;
|
|
176
177
|
|
|
177
178
|
// The config holds one stable handler, so an inline callback does not
|
|
178
|
-
// recreate it. The handler reads the
|
|
179
|
-
const onSortChangeRef =
|
|
180
|
-
onSortChangeRef.current
|
|
181
|
-
const handleSortChange = useCallback(nextSort => onSortChangeRef.current(nextSort), []);
|
|
179
|
+
// recreate it. The handler reads the committed callback when the user sorts.
|
|
180
|
+
const onSortChangeRef = useCommittedRef(onSortChange);
|
|
181
|
+
const handleSortChange = useCallback(nextSort => onSortChangeRef.current(nextSort), [onSortChangeRef]);
|
|
182
182
|
|
|
183
183
|
// Sorted data — memoized on sort state + data identity
|
|
184
184
|
const sortedData = useMemo(() => sortData(data, sort, comparators, collator),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTableStickyColumns.d.ts","sourceRoot":"","sources":["../../../../src/Table/plugins/stickyColumns/useTableStickyColumns.tsx"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAEV,WAAW,EAIZ,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"useTableStickyColumns.d.ts","sourceRoot":"","sources":["../../../../src/Table/plugins/stickyColumns/useTableStickyColumns.tsx"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAEV,WAAW,EAIZ,MAAM,aAAa,CAAC;AAkBrB;;;;;;;;;GASG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAobD,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrE,MAAM,EAAE,2BAA2B,GAClC,WAAW,CAAC,CAAC,CAAC,CA0RhB"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @file useTableStickyColumns.tsx
|
|
7
7
|
* @input React, StyleX, theme tokens, Table types
|
|
8
|
-
* @output Exports useTableStickyColumns hook and UseTableStickyColumnsConfig type
|
|
8
|
+
* @output Exports useTableStickyColumns hook and UseTableStickyColumnsConfig type; declares its pinned runs to Table
|
|
9
9
|
* @position Sticky-columns plugin; consumed by Table via plugins prop
|
|
10
10
|
*
|
|
11
11
|
* SYNC: When modified, update these files to stay in sync:
|
|
@@ -19,6 +19,7 @@ import "../../../theme/tokens.stylex.js";
|
|
|
19
19
|
import { colorVars, durationVars, easeVars } from "../../../theme/tokens.stylex.js";
|
|
20
20
|
import { resolveColumnFloorWidths } from "../../columnUtils.js";
|
|
21
21
|
import { getLogicalPositionExtraVar, getLogicalPositionRenderer } from "../../tableColumnAdmission.js";
|
|
22
|
+
import { registerPinnedColumnRuns } from "../../tablePinnedColumnRuns.js";
|
|
22
23
|
import { collapsedBottom } from "../../rowDivider.js";
|
|
23
24
|
import { GLIDING_ATTRIBUTE, PINNED_ATTRIBUTE } from "../../glidingDivider.js";
|
|
24
25
|
import { useTheme, useThemeName } from "../../../theme/useTheme.js";
|
|
@@ -123,6 +124,24 @@ function computeEndOffsets(columns, endKeys) {
|
|
|
123
124
|
}
|
|
124
125
|
return offsets;
|
|
125
126
|
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* The pinned runs as column counts. A column in both runs pins to the start,
|
|
130
|
+
* as resolveStickySide does.
|
|
131
|
+
*/
|
|
132
|
+
function countPinnedRuns(columns, startKeys, endKeys) {
|
|
133
|
+
let startCount = 0;
|
|
134
|
+
columns.forEach((column, index) => {
|
|
135
|
+
if (startKeys.includes(column.key)) {
|
|
136
|
+
startCount = index + 1;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
const firstEnd = columns.findIndex(column => endKeys.includes(column.key));
|
|
140
|
+
return {
|
|
141
|
+
startCount,
|
|
142
|
+
endCount: firstEnd === -1 ? 0 : columns.length - Math.max(firstEnd, startCount)
|
|
143
|
+
};
|
|
144
|
+
}
|
|
126
145
|
/**
|
|
127
146
|
* Resolve how a single column should be pinned given the start/end configs and
|
|
128
147
|
* the full column list. A key (mis)configured on both edges resolves to start.
|
|
@@ -635,5 +654,6 @@ export function useTableStickyColumns(config) {
|
|
|
635
654
|
// `attachScrollShadow` is stable (empty deps), so the plugin object can be
|
|
636
655
|
// computed once and reused across renders.
|
|
637
656
|
[attachScrollShadow]);
|
|
657
|
+
registerPinnedColumnRuns(plugin, columns => countPinnedRuns(columns, stateRef.current.start, stateRef.current.end));
|
|
638
658
|
return registerCountIndependentPlugin(plugin);
|
|
639
659
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { TableColumnsWindowing } from '../../tableColumnWindowing.js';
|
|
2
|
+
/** The column windowing a columns capability carries; one object for every capability. */
|
|
3
|
+
export declare const TABLE_COLUMNS_WINDOWING: TableColumnsWindowing;
|
|
4
|
+
//# sourceMappingURL=TableColumnWindow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableColumnWindow.d.ts","sourceRoot":"","sources":["../../../../src/Table/plugins/virtualization/TableColumnWindow.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAKV,qBAAqB,EACtB,MAAM,4BAA4B,CAAC;AAuHpC,0FAA0F;AAC1F,eAAO,MAAM,uBAAuB,EAAE,qBAEpC,CAAC"}
|