@galaxy-io/dls 1.2.7 → 1.3.1
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/README.md +2 -0
- package/dist/avatar/Avatar.d.ts +2 -1
- package/dist/avatar/Avatar.js +103 -14
- package/dist/buttons/Button.d.ts +6 -1
- package/dist/buttons/Button.js +8 -4
- package/dist/charts/BarChart.d.ts +30 -20
- package/dist/charts/BarChart.js +183 -253
- package/dist/charts/ChartAxis.d.ts +47 -22
- package/dist/charts/ChartAxis.js +81 -60
- package/dist/charts/ChartCategoryTargets.d.ts +27 -0
- package/dist/charts/ChartCategoryTargets.js +75 -0
- package/dist/charts/ChartEmptyState.d.ts +17 -0
- package/dist/charts/ChartEmptyState.js +29 -0
- package/dist/charts/ChartFrame.d.ts +110 -0
- package/dist/charts/ChartFrame.js +143 -0
- package/dist/charts/ChartLegend.d.ts +27 -4
- package/dist/charts/ChartLegend.js +46 -23
- package/dist/charts/ChartPrimitives.d.ts +230 -0
- package/dist/charts/ChartPrimitives.js +305 -0
- package/dist/charts/ChartTooltip.d.ts +25 -4
- package/dist/charts/ChartTooltip.js +55 -49
- package/dist/charts/LineChart.d.ts +42 -20
- package/dist/charts/LineChart.js +175 -241
- package/dist/charts/PieChart.d.ts +48 -32
- package/dist/charts/PieChart.js +180 -170
- package/dist/charts/barChartGeometry.d.ts +120 -0
- package/dist/charts/barChartGeometry.js +210 -0
- package/dist/charts/barChartLegend.d.ts +25 -0
- package/dist/charts/barChartLegend.js +23 -0
- package/dist/charts/chartFormat.d.ts +27 -0
- package/dist/charts/chartFormat.js +71 -0
- package/dist/charts/chartScales.d.ts +120 -0
- package/dist/charts/chartScales.js +165 -0
- package/dist/charts/chartTheme.d.ts +18 -0
- package/dist/charts/chartTheme.js +26 -0
- package/dist/charts/constants.d.ts +241 -18
- package/dist/charts/constants.js +261 -32
- package/dist/charts/lineChartGeometry.d.ts +92 -0
- package/dist/charts/lineChartGeometry.js +134 -0
- package/dist/charts/pieChartGeometry.d.ts +60 -0
- package/dist/charts/pieChartGeometry.js +79 -0
- package/dist/charts/types.d.ts +428 -54
- package/dist/charts/types.js +155 -0
- package/dist/charts/useCartesianChartLayout.d.ts +70 -0
- package/dist/charts/useCartesianChartLayout.js +56 -0
- package/dist/charts/useChartDimensions.d.ts +47 -0
- package/dist/charts/useChartDimensions.js +63 -0
- package/dist/charts/useChartFormatters.d.ts +19 -0
- package/dist/charts/useChartFormatters.js +20 -0
- package/dist/charts/useChartInteraction.d.ts +76 -0
- package/dist/charts/useChartInteraction.js +126 -0
- package/dist/charts/useChartTooltipPosition.d.ts +53 -0
- package/dist/charts/useChartTooltipPosition.js +39 -0
- package/dist/charts/useSeriesColorResolver.d.ts +37 -0
- package/dist/charts/useSeriesColorResolver.js +27 -0
- package/dist/hooks/useElementClientSize.d.ts +20 -0
- package/dist/hooks/useElementClientSize.js +43 -0
- package/dist/inputs/CheckboxInput.d.ts +7 -2
- package/dist/inputs/CheckboxInput.js +30 -14
- package/dist/inputs/Input.d.ts +1 -1
- package/dist/inputs/Input.js +6 -2
- package/dist/inputs/MultiSelectInput.js +1 -1
- package/dist/inputs/RadioInput.js +7 -2
- package/dist/styles.css +69 -74
- package/dist/table/InfiniteSpreadsheet.d.ts +6 -0
- package/dist/table/InfiniteSpreadsheet.js +235 -0
- package/dist/table/InfiniteTable.d.ts +7 -88
- package/dist/table/InfiniteTable.js +366 -577
- package/dist/{spreadsheet → table}/SpreadsheetCell.d.ts +6 -4
- package/dist/table/SpreadsheetCell.js +71 -0
- package/dist/{spreadsheet → table}/SpreadsheetCellEditor.js +27 -21
- package/dist/table/SpreadsheetHeaderCell.d.ts +23 -0
- package/dist/table/SpreadsheetHeaderCell.js +91 -0
- package/dist/table/SpreadsheetMenuItem.d.ts +14 -0
- package/dist/table/SpreadsheetMenuItem.js +33 -0
- package/dist/table/SpreadsheetPrimitives.d.ts +172 -0
- package/dist/table/SpreadsheetPrimitives.js +105 -0
- package/dist/table/SpreadsheetRow.d.ts +33 -0
- package/dist/table/SpreadsheetRow.js +73 -0
- package/dist/{spreadsheet → table}/SpreadsheetRowActionCell.d.ts +5 -7
- package/dist/table/SpreadsheetRowActionCell.js +51 -0
- package/dist/table/TableExpandCell.d.ts +11 -0
- package/dist/table/TableExpandCell.js +24 -0
- package/dist/table/TableExpandedRow.d.ts +16 -0
- package/dist/table/TableExpandedRow.js +77 -0
- package/dist/table/TableHeaderCellContent.d.ts +30 -0
- package/dist/table/TableHeaderCellContent.js +48 -0
- package/dist/table/TablePrimitives.d.ts +307 -0
- package/dist/table/TablePrimitives.js +298 -0
- package/dist/table/TableSelectCell.d.ts +18 -0
- package/dist/table/TableSelectCell.js +26 -0
- package/dist/table/TableStatusRow.d.ts +18 -0
- package/dist/table/TableStatusRow.js +50 -0
- package/dist/table/VirtualizedInfiniteTable.d.ts +11 -27
- package/dist/table/VirtualizedInfiniteTable.js +182 -317
- package/dist/table/types.d.ts +249 -0
- package/dist/table/types.js +51 -0
- package/dist/table/useInfiniteScrollSentinel.d.ts +24 -0
- package/dist/table/useInfiniteScrollSentinel.js +53 -0
- package/dist/{spreadsheet/hooks → table}/useSpreadsheetEditing.d.ts +1 -1
- package/dist/{spreadsheet/hooks → table}/useSpreadsheetEditing.js +1 -1
- package/dist/table/useTableColumnLayout.d.ts +28 -0
- package/dist/table/useTableColumnLayout.js +63 -0
- package/dist/table/useTableColumnResize.d.ts +38 -0
- package/dist/table/useTableColumnResize.js +155 -0
- package/dist/table/useTableKeyboardNavigation.d.ts +25 -0
- package/dist/table/useTableKeyboardNavigation.js +83 -0
- package/dist/table/useTableRowExpansion.d.ts +24 -0
- package/dist/table/useTableRowExpansion.js +62 -0
- package/dist/table/useTableRowSelection.d.ts +27 -0
- package/dist/table/useTableRowSelection.js +94 -0
- package/dist/table/utils.d.ts +50 -0
- package/dist/table/utils.js +78 -0
- package/dist/text/MarkdownText.js +45 -27
- package/dist/theme/variants/dark.js +1 -1
- package/dist/widget/Widget.d.ts +2 -0
- package/dist/widget/Widget.js +14 -7
- package/package.json +1 -5
- package/dist/assets/components/enrichment/PerplexityIcon.d.ts +0 -3
- package/dist/assets/components/enrichment/PerplexityIcon.js +0 -35
- package/dist/assets/components/enrichment/TavilyIcon.d.ts +0 -3
- package/dist/assets/components/enrichment/TavilyIcon.js +0 -15
- package/dist/assets/components/onboarding/TenantSetupDark.d.ts +0 -3
- package/dist/assets/components/onboarding/TenantSetupDark.js +0 -498
- package/dist/assets/components/onboarding/TenantSetupLight.d.ts +0 -3
- package/dist/assets/components/onboarding/TenantSetupLight.js +0 -482
- package/dist/assets/components/onboarding/UserSetupDark.d.ts +0 -3
- package/dist/assets/components/onboarding/UserSetupDark.js +0 -1086
- package/dist/assets/components/onboarding/UserSetupLight.d.ts +0 -3
- package/dist/assets/components/onboarding/UserSetupLight.js +0 -1024
- package/dist/assets/components/onboarding/WorkspaceSetupBuildDark.d.ts +0 -3
- package/dist/assets/components/onboarding/WorkspaceSetupBuildDark.js +0 -466
- package/dist/assets/components/onboarding/WorkspaceSetupBuildLight.d.ts +0 -3
- package/dist/assets/components/onboarding/WorkspaceSetupBuildLight.js +0 -460
- package/dist/assets/components/onboarding/WorkspaceSetupConnectDark.d.ts +0 -3
- package/dist/assets/components/onboarding/WorkspaceSetupConnectDark.js +0 -336
- package/dist/assets/components/onboarding/WorkspaceSetupConnectLight.d.ts +0 -3
- package/dist/assets/components/onboarding/WorkspaceSetupConnectLight.js +0 -336
- package/dist/assets/components/onboarding/WorkspaceSetupIntegrateDark.d.ts +0 -3
- package/dist/assets/components/onboarding/WorkspaceSetupIntegrateDark.js +0 -153
- package/dist/assets/components/onboarding/WorkspaceSetupIntegrateLight.d.ts +0 -3
- package/dist/assets/components/onboarding/WorkspaceSetupIntegrateLight.js +0 -153
- package/dist/assets/components/projects/MappingMethodAutoIntrospectDark.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodAutoIntrospectDark.js +0 -117
- package/dist/assets/components/projects/MappingMethodAutoIntrospectLight.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodAutoIntrospectLight.js +0 -117
- package/dist/assets/components/projects/MappingMethodBlankDark.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodBlankDark.js +0 -150
- package/dist/assets/components/projects/MappingMethodBlankDarkHovered.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodBlankDarkHovered.js +0 -150
- package/dist/assets/components/projects/MappingMethodBlankLight.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodBlankLight.js +0 -150
- package/dist/assets/components/projects/MappingMethodBlankLightHovered.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodBlankLightHovered.js +0 -150
- package/dist/assets/components/projects/MappingMethodJsonDark.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodJsonDark.js +0 -90
- package/dist/assets/components/projects/MappingMethodJsonDarkHovered.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodJsonDarkHovered.js +0 -90
- package/dist/assets/components/projects/MappingMethodJsonLight.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodJsonLight.js +0 -90
- package/dist/assets/components/projects/MappingMethodJsonLightHovered.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodJsonLightHovered.js +0 -90
- package/dist/assets/components/projects/ProjectsEmptyStateDark.d.ts +0 -3
- package/dist/assets/components/projects/ProjectsEmptyStateDark.js +0 -454
- package/dist/assets/components/projects/ProjectsEmptyStateLight.d.ts +0 -3
- package/dist/assets/components/projects/ProjectsEmptyStateLight.js +0 -456
- package/dist/assets/components/root/CreateProjectActionCardDark.d.ts +0 -3
- package/dist/assets/components/root/CreateProjectActionCardDark.js +0 -1796
- package/dist/assets/components/root/CreateProjectActionCardDarkHovered.d.ts +0 -3
- package/dist/assets/components/root/CreateProjectActionCardDarkHovered.js +0 -1796
- package/dist/assets/components/root/CreateProjectActionCardLight.d.ts +0 -3
- package/dist/assets/components/root/CreateProjectActionCardLight.js +0 -1786
- package/dist/assets/components/root/CreateProjectActionCardLightHovered.d.ts +0 -3
- package/dist/assets/components/root/CreateProjectActionCardLightHovered.js +0 -1786
- package/dist/assets/components/root/CreateSourceActionCardDark.d.ts +0 -3
- package/dist/assets/components/root/CreateSourceActionCardDark.js +0 -879
- package/dist/assets/components/root/CreateSourceActionCardDarkHovered.d.ts +0 -3
- package/dist/assets/components/root/CreateSourceActionCardDarkHovered.js +0 -879
- package/dist/assets/components/root/CreateSourceActionCardLight.d.ts +0 -3
- package/dist/assets/components/root/CreateSourceActionCardLight.js +0 -889
- package/dist/assets/components/root/CreateSourceActionCardLightHovered.d.ts +0 -3
- package/dist/assets/components/root/CreateSourceActionCardLightHovered.js +0 -889
- package/dist/assets/components/sources/AttioIcon.d.ts +0 -3
- package/dist/assets/components/sources/AttioIcon.js +0 -11
- package/dist/assets/components/sources/BigquerySourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/BigquerySourceIcon.js +0 -39
- package/dist/assets/components/sources/BrowserbaseSourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/BrowserbaseSourceIcon.js +0 -35
- package/dist/assets/components/sources/ClickhouseLogoSourceIconDark.d.ts +0 -3
- package/dist/assets/components/sources/ClickhouseLogoSourceIconDark.js +0 -13
- package/dist/assets/components/sources/ClickhouseLogoSourceIconLight.d.ts +0 -3
- package/dist/assets/components/sources/ClickhouseLogoSourceIconLight.js +0 -13
- package/dist/assets/components/sources/ConfluenceSourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/ConfluenceSourceIcon.js +0 -30
- package/dist/assets/components/sources/GithubSourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/GithubSourceIcon.js +0 -27
- package/dist/assets/components/sources/GoogleDriveIcon.d.ts +0 -3
- package/dist/assets/components/sources/GoogleDriveIcon.js +0 -45
- package/dist/assets/components/sources/HubspotSourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/HubspotSourceIcon.js +0 -14
- package/dist/assets/components/sources/JiraSourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/JiraSourceIcon.js +0 -54
- package/dist/assets/components/sources/LinearSourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/LinearSourceIcon.js +0 -14
- package/dist/assets/components/sources/MysqlLogoSourceIconDark.d.ts +0 -3
- package/dist/assets/components/sources/MysqlLogoSourceIconDark.js +0 -17
- package/dist/assets/components/sources/NetsuiteSourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/NetsuiteSourceIcon.js +0 -32
- package/dist/assets/components/sources/NotionIcon.d.ts +0 -3
- package/dist/assets/components/sources/NotionIcon.js +0 -20
- package/dist/assets/components/sources/PostgresqlIcon.d.ts +0 -3
- package/dist/assets/components/sources/PostgresqlIcon.js +0 -61
- package/dist/assets/components/sources/S3Icon.d.ts +0 -3
- package/dist/assets/components/sources/S3Icon.js +0 -76
- package/dist/assets/components/sources/SalesforceSourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/SalesforceSourceIcon.js +0 -23
- package/dist/assets/components/sources/SlackIcon.d.ts +0 -3
- package/dist/assets/components/sources/SlackIcon.js +0 -32
- package/dist/assets/components/sources/SnowflakeLogoSourceIconDark.d.ts +0 -3
- package/dist/assets/components/sources/SnowflakeLogoSourceIconDark.js +0 -14
- package/dist/assets/components/sources/SnowflakeLogoSourceIconLight.d.ts +0 -3
- package/dist/assets/components/sources/SnowflakeLogoSourceIconLight.js +0 -14
- package/dist/assets/components/sources/WikipediaSourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/WikipediaSourceIcon.js +0 -1490
- package/dist/avatar/AvatarEmpty.d.ts +0 -7
- package/dist/avatar/AvatarEmpty.js +0 -99
- package/dist/avatar/types.d.ts +0 -5
- package/dist/avatar/types.js +0 -9
- package/dist/charts/utils.d.ts +0 -29
- package/dist/charts/utils.js +0 -62
- package/dist/icons/BackIcon.d.ts +0 -3
- package/dist/icons/BackIcon.js +0 -13
- package/dist/icons/CloseIcon.d.ts +0 -3
- package/dist/icons/CloseIcon.js +0 -13
- package/dist/icons/CreateIcon.d.ts +0 -3
- package/dist/icons/CreateIcon.js +0 -13
- package/dist/icons/ForwardIcon.d.ts +0 -3
- package/dist/icons/ForwardIcon.js +0 -13
- package/dist/icons/HelpIcon.d.ts +0 -3
- package/dist/icons/HelpIcon.js +0 -14
- package/dist/icons/ProjectsIcon.d.ts +0 -3
- package/dist/icons/ProjectsIcon.js +0 -12
- package/dist/icons/SearchIcon.d.ts +0 -3
- package/dist/icons/SearchIcon.js +0 -12
- package/dist/icons/SourcesIcon.d.ts +0 -3
- package/dist/icons/SourcesIcon.js +0 -12
- package/dist/icons/TextIcon.d.ts +0 -4
- package/dist/icons/TextIcon.js +0 -22
- package/dist/icons/WebScrapeIcon.d.ts +0 -4
- package/dist/icons/WebScrapeIcon.js +0 -22
- package/dist/icons/WebhookIcon.d.ts +0 -4
- package/dist/icons/WebhookIcon.js +0 -22
- package/dist/icons/sources/AttioLogomark.d.ts +0 -4
- package/dist/icons/sources/AttioLogomark.js +0 -8
- package/dist/icons/sources/BrowserbaseLogomark.d.ts +0 -4
- package/dist/icons/sources/BrowserbaseLogomark.js +0 -8
- package/dist/icons/sources/ClickhouseLogomark.d.ts +0 -4
- package/dist/icons/sources/ClickhouseLogomark.js +0 -16
- package/dist/icons/sources/ConfluenceLogomark.d.ts +0 -4
- package/dist/icons/sources/ConfluenceLogomark.js +0 -8
- package/dist/icons/sources/GithubLogomark.d.ts +0 -4
- package/dist/icons/sources/GithubLogomark.js +0 -8
- package/dist/icons/sources/GoogleBigqueryLogomark.d.ts +0 -4
- package/dist/icons/sources/GoogleBigqueryLogomark.js +0 -8
- package/dist/icons/sources/GoogleDriveLogomark.d.ts +0 -4
- package/dist/icons/sources/GoogleDriveLogomark.js +0 -8
- package/dist/icons/sources/HubspotLogomark.d.ts +0 -4
- package/dist/icons/sources/HubspotLogomark.js +0 -8
- package/dist/icons/sources/JiraLogomark.d.ts +0 -4
- package/dist/icons/sources/JiraLogomark.js +0 -8
- package/dist/icons/sources/LinearLogomark.d.ts +0 -4
- package/dist/icons/sources/LinearLogomark.js +0 -8
- package/dist/icons/sources/MySQLLogomark.d.ts +0 -4
- package/dist/icons/sources/MySQLLogomark.js +0 -8
- package/dist/icons/sources/NetsuiteLogomark.d.ts +0 -4
- package/dist/icons/sources/NetsuiteLogomark.js +0 -8
- package/dist/icons/sources/NotionLogomark.d.ts +0 -4
- package/dist/icons/sources/NotionLogomark.js +0 -8
- package/dist/icons/sources/PostgresLogomark.d.ts +0 -4
- package/dist/icons/sources/PostgresLogomark.js +0 -8
- package/dist/icons/sources/S3Logomark.d.ts +0 -4
- package/dist/icons/sources/S3Logomark.js +0 -8
- package/dist/icons/sources/SalesforceLogomark.d.ts +0 -4
- package/dist/icons/sources/SalesforceLogomark.js +0 -8
- package/dist/icons/sources/SlackLogoIconmark.d.ts +0 -4
- package/dist/icons/sources/SlackLogoIconmark.js +0 -8
- package/dist/icons/sources/SnowflakeLogomark.d.ts +0 -4
- package/dist/icons/sources/SnowflakeLogomark.js +0 -16
- package/dist/icons/sources/WikipediaLogomark.d.ts +0 -4
- package/dist/icons/sources/WikipediaLogomark.js +0 -8
- package/dist/spreadsheet/InfiniteSpreadsheet.d.ts +0 -3
- package/dist/spreadsheet/InfiniteSpreadsheet.js +0 -265
- package/dist/spreadsheet/SpreadsheetAddColumnButton.d.ts +0 -6
- package/dist/spreadsheet/SpreadsheetAddColumnButton.js +0 -32
- package/dist/spreadsheet/SpreadsheetCell.js +0 -115
- package/dist/spreadsheet/SpreadsheetHeaderCell.d.ts +0 -18
- package/dist/spreadsheet/SpreadsheetHeaderCell.js +0 -141
- package/dist/spreadsheet/SpreadsheetRow.d.ts +0 -21
- package/dist/spreadsheet/SpreadsheetRow.js +0 -68
- package/dist/spreadsheet/SpreadsheetRowActionCell.js +0 -78
- package/dist/spreadsheet/hooks/useColumnResize.d.ts +0 -6
- package/dist/spreadsheet/hooks/useColumnResize.js +0 -46
- package/dist/spreadsheet/types.d.ts +0 -92
- package/dist/spreadsheet/types.js +0 -21
- /package/dist/{spreadsheet → table}/SpreadsheetCellEditor.d.ts +0 -0
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { OnChangeFn as TanstackOnChangeFn, Row as TanstackRow, RowSelectionState as TanstackRowSelectionState, SortingState as TanstackSortingState, Table as TanstackTable } from "@tanstack/react-table";
|
|
3
|
+
import type { TextVariant } from "../text/Text";
|
|
4
|
+
export declare enum TableVariant {
|
|
5
|
+
BASE = "BASE",
|
|
6
|
+
PRIMARY = "PRIMARY",
|
|
7
|
+
SECONDARY = "SECONDARY",
|
|
8
|
+
TERTIARY = "TERTIARY"
|
|
9
|
+
}
|
|
10
|
+
export declare enum TableDensity {
|
|
11
|
+
SMALL = "SMALL",
|
|
12
|
+
MEDIUM = "MEDIUM",
|
|
13
|
+
LARGE = "LARGE"
|
|
14
|
+
}
|
|
15
|
+
export declare enum ColumnPin {
|
|
16
|
+
LEFT = "LEFT",
|
|
17
|
+
RIGHT = "RIGHT"
|
|
18
|
+
}
|
|
19
|
+
export declare enum ColumnAlign {
|
|
20
|
+
LEFT = "LEFT",
|
|
21
|
+
CENTER = "CENTER",
|
|
22
|
+
RIGHT = "RIGHT"
|
|
23
|
+
}
|
|
24
|
+
export declare enum ColumnResizeMode {
|
|
25
|
+
/** Column width follows the pointer while dragging. */
|
|
26
|
+
ON_CHANGE = "ON_CHANGE",
|
|
27
|
+
/** Column width commits once the drag ends. */
|
|
28
|
+
ON_END = "ON_END"
|
|
29
|
+
}
|
|
30
|
+
export interface ColumnDef<TData, TValue = unknown> {
|
|
31
|
+
id: string;
|
|
32
|
+
accessorFn?: (row: TData) => TValue;
|
|
33
|
+
header?: string | ((props: {
|
|
34
|
+
table: TanstackTable<TData>;
|
|
35
|
+
}) => ReactNode);
|
|
36
|
+
cell?: (props: {
|
|
37
|
+
value: TValue;
|
|
38
|
+
row: TanstackRow<TData>;
|
|
39
|
+
}) => ReactNode;
|
|
40
|
+
size?: number;
|
|
41
|
+
minSize?: number;
|
|
42
|
+
maxSize?: number;
|
|
43
|
+
pin?: ColumnPin;
|
|
44
|
+
enableSorting?: boolean;
|
|
45
|
+
sortDescFirst?: boolean;
|
|
46
|
+
enableResizing?: boolean;
|
|
47
|
+
align?: ColumnAlign;
|
|
48
|
+
cellLoading?: () => ReactNode;
|
|
49
|
+
headerAriaLabel?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface EstimateColumnWidthOptions {
|
|
52
|
+
minWidth?: number;
|
|
53
|
+
maxWidth?: number;
|
|
54
|
+
charWidth?: number;
|
|
55
|
+
padding?: number;
|
|
56
|
+
}
|
|
57
|
+
/** Column widths keyed by column id, as produced by resizing. */
|
|
58
|
+
export type ColumnSizingState = Record<string, number>;
|
|
59
|
+
/**
|
|
60
|
+
* Props shared by every table surface — dimensions, paging, loading/error
|
|
61
|
+
* states and resizing behave identically whether or not rows are virtualized.
|
|
62
|
+
*/
|
|
63
|
+
export interface BaseTableProps<TData> {
|
|
64
|
+
columns: ColumnDef<TData, unknown>[];
|
|
65
|
+
getRowId?: (row: TData, index: number) => string;
|
|
66
|
+
height?: number | string;
|
|
67
|
+
width?: number | string;
|
|
68
|
+
fillWidth?: boolean;
|
|
69
|
+
fillHeight?: boolean;
|
|
70
|
+
density?: TableDensity;
|
|
71
|
+
variant?: TableVariant;
|
|
72
|
+
hasNextPage?: boolean;
|
|
73
|
+
isFetchingNextPage?: boolean;
|
|
74
|
+
fetchNextPage?: () => void;
|
|
75
|
+
isLoading?: boolean;
|
|
76
|
+
isError?: boolean;
|
|
77
|
+
error?: Error;
|
|
78
|
+
loadingRowCount?: number;
|
|
79
|
+
contentWhenEmpty?: ReactNode;
|
|
80
|
+
contentWhenError?: ReactNode | ((error?: Error) => ReactNode);
|
|
81
|
+
noHeader?: boolean;
|
|
82
|
+
noLastRowBorder?: boolean;
|
|
83
|
+
noLastRowPadding?: boolean;
|
|
84
|
+
enableColumnResizing?: boolean;
|
|
85
|
+
columnSizing?: ColumnSizingState;
|
|
86
|
+
defaultColumnSizing?: ColumnSizingState;
|
|
87
|
+
onColumnSizingChange?: (columnSizing: ColumnSizingState) => void;
|
|
88
|
+
columnResizeMode?: ColumnResizeMode;
|
|
89
|
+
ariaLabel?: string;
|
|
90
|
+
ariaLabelledBy?: string;
|
|
91
|
+
}
|
|
92
|
+
export interface InfiniteTableProps<TData> extends BaseTableProps<TData> {
|
|
93
|
+
data: TData[];
|
|
94
|
+
enableRowSelection?: boolean | ((row: TanstackRow<TData>) => boolean);
|
|
95
|
+
enableMultiRowSelection?: boolean;
|
|
96
|
+
rowSelection?: TanstackRowSelectionState;
|
|
97
|
+
defaultRowSelection?: TanstackRowSelectionState;
|
|
98
|
+
onRowSelectionChange?: TanstackOnChangeFn<TanstackRowSelectionState>;
|
|
99
|
+
onSelectedRowsChange?: (rows: TanstackRow<TData>[]) => void;
|
|
100
|
+
/** Renders a leading checkbox column that can actually toggle selection. */
|
|
101
|
+
showSelectionColumn?: boolean;
|
|
102
|
+
selectionColumnPin?: ColumnPin;
|
|
103
|
+
enableSelectAll?: boolean;
|
|
104
|
+
/** Shift-click selects the range between the last click and this row. */
|
|
105
|
+
enableSelectionRange?: boolean;
|
|
106
|
+
selectAllAriaLabel?: string;
|
|
107
|
+
getRowSelectAriaLabel?: (row: TanstackRow<TData>) => string;
|
|
108
|
+
enableSorting?: boolean;
|
|
109
|
+
enableMultiSort?: boolean;
|
|
110
|
+
sorting?: TanstackSortingState;
|
|
111
|
+
onSortingChange?: TanstackOnChangeFn<TanstackSortingState>;
|
|
112
|
+
manualSorting?: boolean;
|
|
113
|
+
onRowExpand?: (row: TanstackRow<TData>) => ReactNode;
|
|
114
|
+
expandedRowIds?: string[];
|
|
115
|
+
defaultExpandedRowIds?: string[];
|
|
116
|
+
onExpandedChange?: (expandedRowIds: string[]) => void;
|
|
117
|
+
getRowCanExpand?: (row: TanstackRow<TData>) => boolean;
|
|
118
|
+
/** When false, expanding a row collapses whichever row was open. */
|
|
119
|
+
enableMultiRowExpansion?: boolean;
|
|
120
|
+
showExpandColumn?: boolean;
|
|
121
|
+
expandColumnPin?: ColumnPin;
|
|
122
|
+
onRowClick?: (row: TanstackRow<TData>, event: React.MouseEvent) => void;
|
|
123
|
+
onRowDoubleClick?: (row: TanstackRow<TData>, event: React.MouseEvent) => void;
|
|
124
|
+
/** Fired by click *and* by Enter/Space when a row has keyboard focus. */
|
|
125
|
+
onRowActivate?: (row: TanstackRow<TData>, event: React.MouseEvent | React.KeyboardEvent) => void;
|
|
126
|
+
getRowAriaLabel?: (row: TanstackRow<TData>) => string;
|
|
127
|
+
enableRowFocus?: boolean;
|
|
128
|
+
onTableReady?: (table: TanstackTable<TData>) => void;
|
|
129
|
+
}
|
|
130
|
+
export interface VirtualizedInfiniteTableProps<TData> extends BaseTableProps<TData> {
|
|
131
|
+
totalRowCount: number;
|
|
132
|
+
getRowData: (index: number) => TData | undefined;
|
|
133
|
+
estimateRowHeight?: number;
|
|
134
|
+
overscan?: number;
|
|
135
|
+
onRowClick?: (row: TanstackRow<TData>, event: React.MouseEvent) => void;
|
|
136
|
+
}
|
|
137
|
+
export type { TanstackRow as Row, TanstackTable as Table };
|
|
138
|
+
export declare enum CellEnrichmentStatus {
|
|
139
|
+
IDLE = "IDLE",
|
|
140
|
+
PENDING = "PENDING",
|
|
141
|
+
RUNNING = "RUNNING",
|
|
142
|
+
COMPLETE = "COMPLETE",
|
|
143
|
+
ERROR = "ERROR"
|
|
144
|
+
}
|
|
145
|
+
export declare enum SpreadsheetCellType {
|
|
146
|
+
TEXT = "TEXT",
|
|
147
|
+
NUMBER = "NUMBER",
|
|
148
|
+
BOOLEAN = "BOOLEAN",
|
|
149
|
+
ENUM = "ENUM",
|
|
150
|
+
DATE = "DATE",
|
|
151
|
+
READONLY = "READONLY"
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Row access handed to a column-level enrichment action.
|
|
155
|
+
*
|
|
156
|
+
* A spreadsheet is virtualized over an index, so there is no row array to pass.
|
|
157
|
+
* Actions that genuinely need every row call `getLoadedRows()`; actions that
|
|
158
|
+
* only need a count read `totalRowCount` without paying for a full scan.
|
|
159
|
+
*/
|
|
160
|
+
export interface SpreadsheetRowsContext<TData> {
|
|
161
|
+
totalRowCount: number;
|
|
162
|
+
getRowData: (index: number) => TData | undefined;
|
|
163
|
+
/**
|
|
164
|
+
* Materializes every currently-loaded row, skipping indices that have not
|
|
165
|
+
* been fetched. O(totalRowCount) — call once, never per row.
|
|
166
|
+
*/
|
|
167
|
+
getLoadedRows: () => TData[];
|
|
168
|
+
}
|
|
169
|
+
export interface SpreadsheetColumnAction<TData> {
|
|
170
|
+
id: string;
|
|
171
|
+
label: string;
|
|
172
|
+
icon?: ReactNode;
|
|
173
|
+
onAction: (columnId: string, rows: SpreadsheetRowsContext<TData>) => void;
|
|
174
|
+
}
|
|
175
|
+
export interface SpreadsheetHeaderAction {
|
|
176
|
+
id: string;
|
|
177
|
+
label: string;
|
|
178
|
+
icon?: ReactNode;
|
|
179
|
+
variant?: TextVariant;
|
|
180
|
+
onAction: (columnId: string) => void;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* A spreadsheet column.
|
|
184
|
+
*
|
|
185
|
+
* Extends `ColumnDef` so `id`, `accessorFn`, sizing, `pin`, `align`,
|
|
186
|
+
* `cellLoading`, `enableResizing` and `headerAriaLabel` have one definition
|
|
187
|
+
* across the domain — and so these columns feed `useTableColumnLayout` and
|
|
188
|
+
* `useTableColumnResize` without a cast.
|
|
189
|
+
*
|
|
190
|
+
* `header` is narrowed to a string and sorting is dropped: the spreadsheet
|
|
191
|
+
* header owns its own menu affordance, and there is no table instance to hand
|
|
192
|
+
* a header render function.
|
|
193
|
+
*/
|
|
194
|
+
export interface SpreadsheetColumnDef<TData, TValue = unknown> extends Omit<ColumnDef<TData, TValue>, "cell" | "header" | "enableSorting" | "sortDescFirst"> {
|
|
195
|
+
header?: string;
|
|
196
|
+
/**
|
|
197
|
+
* Custom cell renderer.
|
|
198
|
+
*
|
|
199
|
+
* `row` carries only `original` and `index` — a virtualized spreadsheet has
|
|
200
|
+
* no TanStack row model behind it, so row methods (`id`, `getIsSelected`,
|
|
201
|
+
* `subRows`, `getValue`) are absent at runtime despite being on the type.
|
|
202
|
+
*
|
|
203
|
+
* `isEditing` is optional on purpose: it keeps this signature assignable to
|
|
204
|
+
* `ColumnDef["cell"]`, which is what lets the shared layout and resize hooks
|
|
205
|
+
* consume these columns unchanged.
|
|
206
|
+
*/
|
|
207
|
+
cell?: (props: {
|
|
208
|
+
value: TValue;
|
|
209
|
+
row: TanstackRow<TData>;
|
|
210
|
+
isEditing?: boolean;
|
|
211
|
+
}) => ReactNode;
|
|
212
|
+
cellType: SpreadsheetCellType;
|
|
213
|
+
editable?: boolean;
|
|
214
|
+
enumOptions?: string[];
|
|
215
|
+
onCellChange?: (rowIndex: number, row: TData, value: TValue) => void;
|
|
216
|
+
headerActions?: SpreadsheetHeaderAction[];
|
|
217
|
+
enrichmentActions?: SpreadsheetColumnAction<TData>[];
|
|
218
|
+
getCellEnrichmentStatus?: (row: TData, rowIndex: number) => CellEnrichmentStatus;
|
|
219
|
+
}
|
|
220
|
+
export interface SpreadsheetRowAction<TData> {
|
|
221
|
+
id: string;
|
|
222
|
+
label: string;
|
|
223
|
+
icon?: ReactNode;
|
|
224
|
+
onAction: (rowIndex: number, row: TData) => void;
|
|
225
|
+
}
|
|
226
|
+
export interface EditingCell {
|
|
227
|
+
rowIndex: number;
|
|
228
|
+
columnId: string;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Inherits dimensions, density, variant, paging, loading/error state,
|
|
232
|
+
* controlled column sizing and the ARIA labels from the virtualized table.
|
|
233
|
+
*
|
|
234
|
+
* `onRowClick` is omitted deliberately: a whole-row click target would fight
|
|
235
|
+
* the per-cell click-to-edit affordance.
|
|
236
|
+
*/
|
|
237
|
+
export interface InfiniteSpreadsheetProps<TData> extends Omit<VirtualizedInfiniteTableProps<TData>, "columns" | "onRowClick"> {
|
|
238
|
+
columns: SpreadsheetColumnDef<TData, unknown>[];
|
|
239
|
+
/** Renders the trailing action column with an add-column control. */
|
|
240
|
+
onAddColumn?: () => void;
|
|
241
|
+
addColumnAriaLabel?: string;
|
|
242
|
+
rowActions?: SpreadsheetRowAction<TData>[];
|
|
243
|
+
getRowActionsAriaLabel?: (rowIndex: number) => string;
|
|
244
|
+
/** Controlled when provided; uncontrolled otherwise. */
|
|
245
|
+
editingCell?: EditingCell | null;
|
|
246
|
+
onEditingCellChange?: (cell: EditingCell | null) => void;
|
|
247
|
+
/** Roving-tabindex row focus and arrow-key row navigation. Defaults to true. */
|
|
248
|
+
enableRowFocus?: boolean;
|
|
249
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
//#region src/table/types.ts
|
|
2
|
+
var TableVariant = /* @__PURE__ */ function(TableVariant) {
|
|
3
|
+
TableVariant["BASE"] = "BASE";
|
|
4
|
+
TableVariant["PRIMARY"] = "PRIMARY";
|
|
5
|
+
TableVariant["SECONDARY"] = "SECONDARY";
|
|
6
|
+
TableVariant["TERTIARY"] = "TERTIARY";
|
|
7
|
+
return TableVariant;
|
|
8
|
+
}({});
|
|
9
|
+
var TableDensity = /* @__PURE__ */ function(TableDensity) {
|
|
10
|
+
TableDensity["SMALL"] = "SMALL";
|
|
11
|
+
TableDensity["MEDIUM"] = "MEDIUM";
|
|
12
|
+
TableDensity["LARGE"] = "LARGE";
|
|
13
|
+
return TableDensity;
|
|
14
|
+
}({});
|
|
15
|
+
var ColumnPin = /* @__PURE__ */ function(ColumnPin) {
|
|
16
|
+
ColumnPin["LEFT"] = "LEFT";
|
|
17
|
+
ColumnPin["RIGHT"] = "RIGHT";
|
|
18
|
+
return ColumnPin;
|
|
19
|
+
}({});
|
|
20
|
+
var ColumnAlign = /* @__PURE__ */ function(ColumnAlign) {
|
|
21
|
+
ColumnAlign["LEFT"] = "LEFT";
|
|
22
|
+
ColumnAlign["CENTER"] = "CENTER";
|
|
23
|
+
ColumnAlign["RIGHT"] = "RIGHT";
|
|
24
|
+
return ColumnAlign;
|
|
25
|
+
}({});
|
|
26
|
+
var ColumnResizeMode = /* @__PURE__ */ function(ColumnResizeMode) {
|
|
27
|
+
/** Column width follows the pointer while dragging. */
|
|
28
|
+
ColumnResizeMode["ON_CHANGE"] = "ON_CHANGE";
|
|
29
|
+
/** Column width commits once the drag ends. */
|
|
30
|
+
ColumnResizeMode["ON_END"] = "ON_END";
|
|
31
|
+
return ColumnResizeMode;
|
|
32
|
+
}({});
|
|
33
|
+
var CellEnrichmentStatus = /* @__PURE__ */ function(CellEnrichmentStatus) {
|
|
34
|
+
CellEnrichmentStatus["IDLE"] = "IDLE";
|
|
35
|
+
CellEnrichmentStatus["PENDING"] = "PENDING";
|
|
36
|
+
CellEnrichmentStatus["RUNNING"] = "RUNNING";
|
|
37
|
+
CellEnrichmentStatus["COMPLETE"] = "COMPLETE";
|
|
38
|
+
CellEnrichmentStatus["ERROR"] = "ERROR";
|
|
39
|
+
return CellEnrichmentStatus;
|
|
40
|
+
}({});
|
|
41
|
+
var SpreadsheetCellType = /* @__PURE__ */ function(SpreadsheetCellType) {
|
|
42
|
+
SpreadsheetCellType["TEXT"] = "TEXT";
|
|
43
|
+
SpreadsheetCellType["NUMBER"] = "NUMBER";
|
|
44
|
+
SpreadsheetCellType["BOOLEAN"] = "BOOLEAN";
|
|
45
|
+
SpreadsheetCellType["ENUM"] = "ENUM";
|
|
46
|
+
SpreadsheetCellType["DATE"] = "DATE";
|
|
47
|
+
SpreadsheetCellType["READONLY"] = "READONLY";
|
|
48
|
+
return SpreadsheetCellType;
|
|
49
|
+
}({});
|
|
50
|
+
//#endregion
|
|
51
|
+
export { CellEnrichmentStatus, ColumnAlign, ColumnPin, ColumnResizeMode, SpreadsheetCellType, TableDensity, TableVariant };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
interface UseInfiniteScrollSentinelOptions {
|
|
2
|
+
scrollRef: React.RefObject<HTMLElement | null>;
|
|
3
|
+
hasNextPage?: boolean;
|
|
4
|
+
isFetchingNextPage?: boolean;
|
|
5
|
+
fetchNextPage?: () => void;
|
|
6
|
+
/**
|
|
7
|
+
* Number of rows currently rendered. Changing it re-arms the observer, which
|
|
8
|
+
* is what makes a short first page keep paging until the viewport fills.
|
|
9
|
+
*/
|
|
10
|
+
rowCount: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Drives infinite scroll from an `IntersectionObserver` on a sentinel element
|
|
14
|
+
* placed after the last row.
|
|
15
|
+
*
|
|
16
|
+
* A plain `scroll` listener can dead-end: if the first page is shorter than the
|
|
17
|
+
* viewport, no scroll event ever fires and paging never starts. Re-observing an
|
|
18
|
+
* already-intersecting sentinel re-fires the callback, so this keeps pumping
|
|
19
|
+
* until the content overflows or `hasNextPage` goes false.
|
|
20
|
+
*
|
|
21
|
+
* @returns A ref to attach to the sentinel element.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useInfiniteScrollSentinel({ scrollRef, hasNextPage, isFetchingNextPage, fetchNextPage, rowCount, }: UseInfiniteScrollSentinelOptions): import("react").RefObject<HTMLDivElement>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import "./utils.js";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
//#region src/table/useInfiniteScrollSentinel.ts
|
|
4
|
+
/**
|
|
5
|
+
* Drives infinite scroll from an `IntersectionObserver` on a sentinel element
|
|
6
|
+
* placed after the last row.
|
|
7
|
+
*
|
|
8
|
+
* A plain `scroll` listener can dead-end: if the first page is shorter than the
|
|
9
|
+
* viewport, no scroll event ever fires and paging never starts. Re-observing an
|
|
10
|
+
* already-intersecting sentinel re-fires the callback, so this keeps pumping
|
|
11
|
+
* until the content overflows or `hasNextPage` goes false.
|
|
12
|
+
*
|
|
13
|
+
* @returns A ref to attach to the sentinel element.
|
|
14
|
+
*/
|
|
15
|
+
function useInfiniteScrollSentinel({ scrollRef, hasNextPage, isFetchingNextPage, fetchNextPage, rowCount }) {
|
|
16
|
+
const sentinelRef = useRef(null);
|
|
17
|
+
const fetchNextPageRef = useRef(fetchNextPage);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
fetchNextPageRef.current = fetchNextPage;
|
|
20
|
+
});
|
|
21
|
+
const canFetch = fetchNextPage !== void 0;
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const root = scrollRef.current;
|
|
24
|
+
const sentinel = sentinelRef.current;
|
|
25
|
+
if (!root || !sentinel || !canFetch || !hasNextPage || isFetchingNextPage) return;
|
|
26
|
+
if (typeof IntersectionObserver === "undefined") {
|
|
27
|
+
const onScroll = () => {
|
|
28
|
+
const { scrollHeight, scrollTop, clientHeight } = root;
|
|
29
|
+
if (scrollHeight - scrollTop - clientHeight < 500) fetchNextPageRef.current?.();
|
|
30
|
+
};
|
|
31
|
+
onScroll();
|
|
32
|
+
root.addEventListener("scroll", onScroll, { passive: true });
|
|
33
|
+
return () => root.removeEventListener("scroll", onScroll);
|
|
34
|
+
}
|
|
35
|
+
const observer = new IntersectionObserver((entries) => {
|
|
36
|
+
if (entries.some((entry) => entry.isIntersecting)) fetchNextPageRef.current?.();
|
|
37
|
+
}, {
|
|
38
|
+
root,
|
|
39
|
+
rootMargin: `0px 0px 500px 0px`
|
|
40
|
+
});
|
|
41
|
+
observer.observe(sentinel);
|
|
42
|
+
return () => observer.disconnect();
|
|
43
|
+
}, [
|
|
44
|
+
scrollRef,
|
|
45
|
+
canFetch,
|
|
46
|
+
hasNextPage,
|
|
47
|
+
isFetchingNextPage,
|
|
48
|
+
rowCount
|
|
49
|
+
]);
|
|
50
|
+
return sentinelRef;
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { useInfiniteScrollSentinel };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from "react";
|
|
2
|
-
//#region src/
|
|
2
|
+
//#region src/table/useSpreadsheetEditing.ts
|
|
3
3
|
function useSpreadsheetEditing(options) {
|
|
4
4
|
const { editingCell: controlledCell, onEditingCellChange } = options;
|
|
5
5
|
const isControlled = controlledCell !== void 0;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type ColumnDef, type ColumnSizingState } from "./types";
|
|
2
|
+
export interface TableColumnLayout<TData> {
|
|
3
|
+
/**
|
|
4
|
+
* Resolved width for a column, or `undefined` when the column is flexible
|
|
5
|
+
* and should share the leftover space.
|
|
6
|
+
*/
|
|
7
|
+
getColumnWidth: (column: ColumnDef<TData, unknown>) => number | undefined;
|
|
8
|
+
/** Sticky offset in pixels, keyed by column id, for pinned columns only. */
|
|
9
|
+
pinnedOffsets: Map<string, number>;
|
|
10
|
+
/** Sum of every column's resolved width — the table's minimum content width. */
|
|
11
|
+
rowMinWidth: number;
|
|
12
|
+
}
|
|
13
|
+
interface UseTableColumnLayoutOptions<TData> {
|
|
14
|
+
columns: ColumnDef<TData, unknown>[];
|
|
15
|
+
/** Widths produced by resizing; they win over the column's declared `size`. */
|
|
16
|
+
columnSizing?: ColumnSizingState;
|
|
17
|
+
/** Reserved space at the trailing edge, ahead of any right-pinned columns. */
|
|
18
|
+
rightOffsetBase?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Derives column widths, sticky offsets for pinned columns, and the row's
|
|
22
|
+
* minimum content width from plain column definitions.
|
|
23
|
+
*
|
|
24
|
+
* Deliberately independent of any TanStack table instance so the virtualized
|
|
25
|
+
* table — which has none — shares exactly the same layout maths.
|
|
26
|
+
*/
|
|
27
|
+
export declare function useTableColumnLayout<TData>({ columns, columnSizing, rightOffsetBase, }: UseTableColumnLayoutOptions<TData>): TableColumnLayout<TData>;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ColumnPin } from "./types.js";
|
|
2
|
+
import "./utils.js";
|
|
3
|
+
import { useEffect, useMemo } from "react";
|
|
4
|
+
//#region src/table/useTableColumnLayout.ts
|
|
5
|
+
function resolveColumnWidth(column, columnSizing) {
|
|
6
|
+
const override = columnSizing?.[column.id];
|
|
7
|
+
if (override !== void 0) return override;
|
|
8
|
+
if (column.size !== void 0) return column.size;
|
|
9
|
+
if (column.pin) return column.minSize ?? 150;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Derives column widths, sticky offsets for pinned columns, and the row's
|
|
13
|
+
* minimum content width from plain column definitions.
|
|
14
|
+
*
|
|
15
|
+
* Deliberately independent of any TanStack table instance so the virtualized
|
|
16
|
+
* table — which has none — shares exactly the same layout maths.
|
|
17
|
+
*/
|
|
18
|
+
function useTableColumnLayout({ columns, columnSizing, rightOffsetBase = 0 }) {
|
|
19
|
+
const layout = useMemo(() => {
|
|
20
|
+
const widths = /* @__PURE__ */ new Map();
|
|
21
|
+
let rowMinWidth = 0;
|
|
22
|
+
columns.forEach((column) => {
|
|
23
|
+
const width = resolveColumnWidth(column, columnSizing);
|
|
24
|
+
widths.set(column.id, width);
|
|
25
|
+
rowMinWidth += width ?? column.minSize ?? 0;
|
|
26
|
+
});
|
|
27
|
+
const pinnedOffsets = /* @__PURE__ */ new Map();
|
|
28
|
+
let leftOffset = 0;
|
|
29
|
+
columns.forEach((column) => {
|
|
30
|
+
if (column.pin !== ColumnPin.LEFT) return;
|
|
31
|
+
pinnedOffsets.set(column.id, leftOffset);
|
|
32
|
+
leftOffset += widths.get(column.id) ?? 150;
|
|
33
|
+
});
|
|
34
|
+
let rightOffset = rightOffsetBase;
|
|
35
|
+
[...columns].reverse().forEach((column) => {
|
|
36
|
+
if (column.pin !== ColumnPin.RIGHT) return;
|
|
37
|
+
pinnedOffsets.set(column.id, rightOffset);
|
|
38
|
+
rightOffset += widths.get(column.id) ?? 150;
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
widths,
|
|
42
|
+
pinnedOffsets,
|
|
43
|
+
rowMinWidth
|
|
44
|
+
};
|
|
45
|
+
}, [
|
|
46
|
+
columns,
|
|
47
|
+
columnSizing,
|
|
48
|
+
rightOffsetBase
|
|
49
|
+
]);
|
|
50
|
+
const unsizedPinnedColumnIds = useMemo(() => columns.filter((column) => column.pin && column.size === void 0 && column.minSize === void 0).map((column) => column.id), [columns]);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (unsizedPinnedColumnIds.length === 0) return;
|
|
53
|
+
console.warn(`[InfiniteTable] Pinned columns need an explicit \`size\` so their sticky offset is correct. Falling back to 150px for: ${unsizedPinnedColumnIds.join(", ")}.`);
|
|
54
|
+
}, [unsizedPinnedColumnIds]);
|
|
55
|
+
const { widths, pinnedOffsets, rowMinWidth } = layout;
|
|
56
|
+
return {
|
|
57
|
+
getColumnWidth: useMemo(() => (column) => widths.get(column.id), [widths]),
|
|
58
|
+
pinnedOffsets,
|
|
59
|
+
rowMinWidth
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { useTableColumnLayout };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ColumnResizeMode, type ColumnDef, type ColumnSizingState } from "./types";
|
|
2
|
+
interface UseTableColumnResizeOptions<TData> {
|
|
3
|
+
columns: ColumnDef<TData, unknown>[];
|
|
4
|
+
enabled?: boolean;
|
|
5
|
+
columnSizing?: ColumnSizingState;
|
|
6
|
+
defaultColumnSizing?: ColumnSizingState;
|
|
7
|
+
onColumnSizingChange?: (columnSizing: ColumnSizingState) => void;
|
|
8
|
+
mode?: ColumnResizeMode;
|
|
9
|
+
}
|
|
10
|
+
export interface TableColumnResize<TData> {
|
|
11
|
+
columnSizing: ColumnSizingState;
|
|
12
|
+
/** TanStack-shaped setter, so `state.columnSizing` stays in sync. */
|
|
13
|
+
onColumnSizingChange: (updater: ColumnSizingState | ((old: ColumnSizingState) => ColumnSizingState)) => void;
|
|
14
|
+
resizingColumnId: string | null;
|
|
15
|
+
canResizeColumn: (column: ColumnDef<TData, unknown>) => boolean;
|
|
16
|
+
/**
|
|
17
|
+
* `measuredWidth` is the column's rendered width. Pass it for flexible
|
|
18
|
+
* columns — they have no declared `size`, so without it the drag would jump
|
|
19
|
+
* to the fallback width on the first pointer move.
|
|
20
|
+
*/
|
|
21
|
+
startResize: (columnId: string, clientX: number, measuredWidth?: number) => void;
|
|
22
|
+
resizeByKeyboard: (columnId: string, event: React.KeyboardEvent) => void;
|
|
23
|
+
/** `current` is undefined for a flexible column that has not been resized. */
|
|
24
|
+
getColumnResizeBounds: (columnId: string) => {
|
|
25
|
+
min: number;
|
|
26
|
+
max: number;
|
|
27
|
+
current: number | undefined;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Drag- and keyboard-driven column resizing, controlled or uncontrolled.
|
|
32
|
+
*
|
|
33
|
+
* Pointer listeners live on `window` so the drag survives the pointer leaving
|
|
34
|
+
* the header, and the teardown is held in a ref so unmounting mid-drag cannot
|
|
35
|
+
* leave listeners or the `col-resize` body cursor behind.
|
|
36
|
+
*/
|
|
37
|
+
export declare function useTableColumnResize<TData>({ columns, enabled, columnSizing, defaultColumnSizing, onColumnSizingChange, mode, }: UseTableColumnResizeOptions<TData>): TableColumnResize<TData>;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { ColumnResizeMode } from "./types.js";
|
|
2
|
+
import "./utils.js";
|
|
3
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
//#region src/table/useTableColumnResize.ts
|
|
5
|
+
/** Keyboard resize step, and the step while shift is held. */
|
|
6
|
+
var KEYBOARD_RESIZE_STEP_PX = 8;
|
|
7
|
+
var KEYBOARD_RESIZE_STEP_LARGE_PX = 32;
|
|
8
|
+
function clampWidth(column, width) {
|
|
9
|
+
const min = column?.minSize ?? 60;
|
|
10
|
+
const max = column?.maxSize ?? 800;
|
|
11
|
+
return Math.min(max, Math.max(min, width));
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Drag- and keyboard-driven column resizing, controlled or uncontrolled.
|
|
15
|
+
*
|
|
16
|
+
* Pointer listeners live on `window` so the drag survives the pointer leaving
|
|
17
|
+
* the header, and the teardown is held in a ref so unmounting mid-drag cannot
|
|
18
|
+
* leave listeners or the `col-resize` body cursor behind.
|
|
19
|
+
*/
|
|
20
|
+
function useTableColumnResize({ columns, enabled = false, columnSizing, defaultColumnSizing, onColumnSizingChange, mode = ColumnResizeMode.ON_CHANGE }) {
|
|
21
|
+
const [internalSizing, setInternalSizing] = useState(defaultColumnSizing ?? {});
|
|
22
|
+
const [resizingColumnId, setResizingColumnId] = useState(null);
|
|
23
|
+
const isControlled = columnSizing !== void 0;
|
|
24
|
+
const resolvedSizing = isControlled ? columnSizing : internalSizing;
|
|
25
|
+
const sizingRef = useRef(resolvedSizing);
|
|
26
|
+
const columnsRef = useRef(columns);
|
|
27
|
+
const onChangeRef = useRef(onColumnSizingChange);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
sizingRef.current = resolvedSizing;
|
|
30
|
+
columnsRef.current = columns;
|
|
31
|
+
onChangeRef.current = onColumnSizingChange;
|
|
32
|
+
});
|
|
33
|
+
const dragRef = useRef(null);
|
|
34
|
+
const teardownRef = useRef(null);
|
|
35
|
+
useEffect(() => () => teardownRef.current?.(), []);
|
|
36
|
+
const commitWidth = useCallback((columnId, width) => {
|
|
37
|
+
const next = {
|
|
38
|
+
...sizingRef.current,
|
|
39
|
+
[columnId]: width
|
|
40
|
+
};
|
|
41
|
+
sizingRef.current = next;
|
|
42
|
+
if (!isControlled) setInternalSizing(next);
|
|
43
|
+
onChangeRef.current?.(next);
|
|
44
|
+
}, [isControlled]);
|
|
45
|
+
const handleColumnSizingChange = useCallback((updater) => {
|
|
46
|
+
const next = typeof updater === "function" ? updater(sizingRef.current) : updater;
|
|
47
|
+
sizingRef.current = next;
|
|
48
|
+
if (!isControlled) setInternalSizing(next);
|
|
49
|
+
onChangeRef.current?.(next);
|
|
50
|
+
}, [isControlled]);
|
|
51
|
+
const findColumn = useCallback((columnId) => columnsRef.current.find((column) => column.id === columnId), []);
|
|
52
|
+
const getColumnWidth = useCallback((columnId) => {
|
|
53
|
+
const column = findColumn(columnId);
|
|
54
|
+
return sizingRef.current[columnId] ?? column?.size ?? 150;
|
|
55
|
+
}, [findColumn]);
|
|
56
|
+
const canResizeColumn = useCallback((column) => enabled && column.enableResizing !== false, [enabled]);
|
|
57
|
+
const startResize = useCallback((columnId, clientX, measuredWidth) => {
|
|
58
|
+
const column = findColumn(columnId);
|
|
59
|
+
if (!enabled || !column || column.enableResizing === false) return;
|
|
60
|
+
teardownRef.current?.();
|
|
61
|
+
const startWidth = measuredWidth ?? getColumnWidth(columnId);
|
|
62
|
+
dragRef.current = {
|
|
63
|
+
columnId,
|
|
64
|
+
startX: clientX,
|
|
65
|
+
startWidth,
|
|
66
|
+
latestWidth: startWidth
|
|
67
|
+
};
|
|
68
|
+
setResizingColumnId(columnId);
|
|
69
|
+
const onPointerMove = (event) => {
|
|
70
|
+
const drag = dragRef.current;
|
|
71
|
+
if (!drag) return;
|
|
72
|
+
const width = clampWidth(findColumn(drag.columnId), drag.startWidth + (event.clientX - drag.startX));
|
|
73
|
+
drag.latestWidth = width;
|
|
74
|
+
if (mode === ColumnResizeMode.ON_CHANGE) commitWidth(drag.columnId, width);
|
|
75
|
+
};
|
|
76
|
+
const teardown = () => {
|
|
77
|
+
window.removeEventListener("pointermove", onPointerMove);
|
|
78
|
+
window.removeEventListener("pointerup", onPointerUp);
|
|
79
|
+
window.removeEventListener("pointercancel", onPointerUp);
|
|
80
|
+
document.body.style.cursor = "";
|
|
81
|
+
document.body.style.userSelect = "";
|
|
82
|
+
dragRef.current = null;
|
|
83
|
+
teardownRef.current = null;
|
|
84
|
+
setResizingColumnId(null);
|
|
85
|
+
};
|
|
86
|
+
function onPointerUp() {
|
|
87
|
+
const drag = dragRef.current;
|
|
88
|
+
if (drag && mode === ColumnResizeMode.ON_END) commitWidth(drag.columnId, drag.latestWidth);
|
|
89
|
+
teardown();
|
|
90
|
+
}
|
|
91
|
+
teardownRef.current = teardown;
|
|
92
|
+
window.addEventListener("pointermove", onPointerMove);
|
|
93
|
+
window.addEventListener("pointerup", onPointerUp);
|
|
94
|
+
window.addEventListener("pointercancel", onPointerUp);
|
|
95
|
+
document.body.style.cursor = "col-resize";
|
|
96
|
+
document.body.style.userSelect = "none";
|
|
97
|
+
}, [
|
|
98
|
+
enabled,
|
|
99
|
+
mode,
|
|
100
|
+
commitWidth,
|
|
101
|
+
findColumn,
|
|
102
|
+
getColumnWidth
|
|
103
|
+
]);
|
|
104
|
+
const resizeByKeyboard = useCallback((columnId, event) => {
|
|
105
|
+
const column = findColumn(columnId);
|
|
106
|
+
if (!enabled || !column || column.enableResizing === false) return;
|
|
107
|
+
const step = event.shiftKey ? KEYBOARD_RESIZE_STEP_LARGE_PX : KEYBOARD_RESIZE_STEP_PX;
|
|
108
|
+
if (event.key === "ArrowLeft") {
|
|
109
|
+
event.preventDefault();
|
|
110
|
+
commitWidth(columnId, clampWidth(column, getColumnWidth(columnId) - step));
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (event.key === "ArrowRight") {
|
|
114
|
+
event.preventDefault();
|
|
115
|
+
commitWidth(columnId, clampWidth(column, getColumnWidth(columnId) + step));
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (event.key === "Home") {
|
|
119
|
+
event.preventDefault();
|
|
120
|
+
commitWidth(columnId, clampWidth(column, column.size ?? 150));
|
|
121
|
+
}
|
|
122
|
+
}, [
|
|
123
|
+
enabled,
|
|
124
|
+
commitWidth,
|
|
125
|
+
findColumn,
|
|
126
|
+
getColumnWidth
|
|
127
|
+
]);
|
|
128
|
+
const getColumnResizeBounds = useCallback((columnId) => {
|
|
129
|
+
const column = findColumn(columnId);
|
|
130
|
+
return {
|
|
131
|
+
min: column?.minSize ?? 60,
|
|
132
|
+
max: column?.maxSize ?? 800,
|
|
133
|
+
current: sizingRef.current[columnId] ?? column?.size
|
|
134
|
+
};
|
|
135
|
+
}, [findColumn]);
|
|
136
|
+
return useMemo(() => ({
|
|
137
|
+
columnSizing: resolvedSizing,
|
|
138
|
+
onColumnSizingChange: handleColumnSizingChange,
|
|
139
|
+
resizingColumnId,
|
|
140
|
+
canResizeColumn,
|
|
141
|
+
startResize,
|
|
142
|
+
resizeByKeyboard,
|
|
143
|
+
getColumnResizeBounds
|
|
144
|
+
}), [
|
|
145
|
+
resolvedSizing,
|
|
146
|
+
handleColumnSizingChange,
|
|
147
|
+
resizingColumnId,
|
|
148
|
+
canResizeColumn,
|
|
149
|
+
startResize,
|
|
150
|
+
resizeByKeyboard,
|
|
151
|
+
getColumnResizeBounds
|
|
152
|
+
]);
|
|
153
|
+
}
|
|
154
|
+
//#endregion
|
|
155
|
+
export { useTableColumnResize };
|