@galaxy-io/dls 1.2.6 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +216 -250
- package/dist/charts/ChartAxis.d.ts +47 -22
- package/dist/charts/ChartAxis.js +81 -60
- package/dist/charts/ChartEmptyState.d.ts +17 -0
- package/dist/charts/ChartEmptyState.js +29 -0
- package/dist/charts/ChartFrame.d.ts +82 -0
- package/dist/charts/ChartFrame.js +86 -0
- package/dist/charts/ChartLegend.d.ts +27 -4
- package/dist/charts/ChartLegend.js +46 -23
- package/dist/charts/ChartPrimitives.d.ts +195 -0
- package/dist/charts/ChartPrimitives.js +268 -0
- package/dist/charts/ChartTooltip.d.ts +27 -6
- package/dist/charts/ChartTooltip.js +56 -50
- package/dist/charts/LineChart.d.ts +42 -20
- package/dist/charts/LineChart.js +186 -237
- package/dist/charts/PieChart.d.ts +48 -32
- package/dist/charts/PieChart.js +159 -171
- package/dist/charts/barChartGeometry.d.ts +87 -0
- package/dist/charts/barChartGeometry.js +218 -0
- package/dist/charts/chartFormat.d.ts +19 -0
- package/dist/charts/chartFormat.js +59 -0
- package/dist/charts/chartScales.d.ts +84 -0
- package/dist/charts/chartScales.js +111 -0
- package/dist/charts/chartTheme.d.ts +18 -0
- package/dist/charts/chartTheme.js +26 -0
- package/dist/charts/constants.d.ts +225 -18
- package/dist/charts/constants.js +240 -32
- package/dist/charts/lineChartGeometry.d.ts +54 -0
- package/dist/charts/lineChartGeometry.js +143 -0
- package/dist/charts/pieChartGeometry.d.ts +48 -0
- package/dist/charts/pieChartGeometry.js +89 -0
- package/dist/charts/types.d.ts +522 -54
- package/dist/charts/types.js +136 -0
- package/dist/charts/useChartDimensions.d.ts +40 -0
- package/dist/charts/useChartDimensions.js +53 -0
- package/dist/charts/useChartFormatters.d.ts +19 -0
- package/dist/charts/useChartFormatters.js +20 -0
- package/dist/charts/useChartInteraction.d.ts +71 -0
- package/dist/charts/useChartInteraction.js +130 -0
- package/dist/charts/useChartTooltipPosition.d.ts +53 -0
- package/dist/charts/useChartTooltipPosition.js +39 -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 +5 -2
- package/dist/inputs/Input.js +20 -17
- package/dist/inputs/MultiSelectInput.js +1 -1
- package/dist/inputs/RadioInput.js +7 -2
- package/dist/styles.css +68 -75
- 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,25 @@
|
|
|
1
|
+
/** Body rows carry this attribute so focus can be moved without a ref per row. */
|
|
2
|
+
export declare const ROW_INDEX_ATTRIBUTE = "data-row-index";
|
|
3
|
+
interface UseTableKeyboardNavigationOptions {
|
|
4
|
+
/** The element containing the body rows. */
|
|
5
|
+
bodyRef: React.RefObject<HTMLElement | null>;
|
|
6
|
+
rowCount: number;
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
onActivate?: (rowIndex: number, event: React.KeyboardEvent) => void;
|
|
9
|
+
onToggleSelect?: (rowIndex: number, event: React.KeyboardEvent) => void;
|
|
10
|
+
/** Lets a virtualized host bring an off-screen row into the DOM first. */
|
|
11
|
+
scrollToIndex?: (rowIndex: number) => void;
|
|
12
|
+
}
|
|
13
|
+
export interface TableKeyboardNavigation {
|
|
14
|
+
focusedRowIndex: number;
|
|
15
|
+
/** Roving tabindex: exactly one body row is in the tab order. */
|
|
16
|
+
getRowTabIndex: (rowIndex: number) => number | undefined;
|
|
17
|
+
onRowKeyDown: (rowIndex: number, event: React.KeyboardEvent) => void;
|
|
18
|
+
onRowFocus: (rowIndex: number) => void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Roving-tabindex keyboard navigation over table rows: one Tab stop for the
|
|
22
|
+
* whole body, arrows to move between rows, Enter to activate, Space to select.
|
|
23
|
+
*/
|
|
24
|
+
export declare function useTableKeyboardNavigation({ bodyRef, rowCount, enabled, onActivate, onToggleSelect, scrollToIndex, }: UseTableKeyboardNavigationOptions): TableKeyboardNavigation;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
//#region src/table/useTableKeyboardNavigation.ts
|
|
3
|
+
/** Body rows carry this attribute so focus can be moved without a ref per row. */
|
|
4
|
+
var ROW_INDEX_ATTRIBUTE = "data-row-index";
|
|
5
|
+
/**
|
|
6
|
+
* Roving-tabindex keyboard navigation over table rows: one Tab stop for the
|
|
7
|
+
* whole body, arrows to move between rows, Enter to activate, Space to select.
|
|
8
|
+
*/
|
|
9
|
+
function useTableKeyboardNavigation({ bodyRef, rowCount, enabled = false, onActivate, onToggleSelect, scrollToIndex }) {
|
|
10
|
+
const [focusedRowIndex, setFocusedRowIndex] = useState(0);
|
|
11
|
+
const shouldMoveFocusRef = useRef(false);
|
|
12
|
+
const onActivateRef = useRef(onActivate);
|
|
13
|
+
const onToggleSelectRef = useRef(onToggleSelect);
|
|
14
|
+
const scrollToIndexRef = useRef(scrollToIndex);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
onActivateRef.current = onActivate;
|
|
17
|
+
onToggleSelectRef.current = onToggleSelect;
|
|
18
|
+
scrollToIndexRef.current = scrollToIndex;
|
|
19
|
+
});
|
|
20
|
+
const clampedFocusedRowIndex = rowCount === 0 ? 0 : Math.min(focusedRowIndex, Math.max(0, rowCount - 1));
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (!shouldMoveFocusRef.current) return;
|
|
23
|
+
shouldMoveFocusRef.current = false;
|
|
24
|
+
const body = bodyRef.current;
|
|
25
|
+
if (!body) return;
|
|
26
|
+
body.querySelector(`[${ROW_INDEX_ATTRIBUTE}="${clampedFocusedRowIndex}"]`)?.focus();
|
|
27
|
+
}, [bodyRef, clampedFocusedRowIndex]);
|
|
28
|
+
const moveFocusTo = useCallback((rowIndex) => {
|
|
29
|
+
shouldMoveFocusRef.current = true;
|
|
30
|
+
scrollToIndexRef.current?.(rowIndex);
|
|
31
|
+
setFocusedRowIndex(rowIndex);
|
|
32
|
+
}, []);
|
|
33
|
+
const onRowKeyDown = useCallback((rowIndex, event) => {
|
|
34
|
+
if (!enabled || rowCount === 0) return;
|
|
35
|
+
if (event.target !== event.currentTarget) return;
|
|
36
|
+
switch (event.key) {
|
|
37
|
+
case "ArrowDown":
|
|
38
|
+
event.preventDefault();
|
|
39
|
+
moveFocusTo(Math.min(rowCount - 1, rowIndex + 1));
|
|
40
|
+
return;
|
|
41
|
+
case "ArrowUp":
|
|
42
|
+
event.preventDefault();
|
|
43
|
+
moveFocusTo(Math.max(0, rowIndex - 1));
|
|
44
|
+
return;
|
|
45
|
+
case "Home":
|
|
46
|
+
event.preventDefault();
|
|
47
|
+
moveFocusTo(0);
|
|
48
|
+
return;
|
|
49
|
+
case "End":
|
|
50
|
+
event.preventDefault();
|
|
51
|
+
moveFocusTo(rowCount - 1);
|
|
52
|
+
return;
|
|
53
|
+
case "Enter":
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
onActivateRef.current?.(rowIndex, event);
|
|
56
|
+
return;
|
|
57
|
+
case " ":
|
|
58
|
+
case "Spacebar":
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
onToggleSelectRef.current?.(rowIndex, event);
|
|
61
|
+
return;
|
|
62
|
+
default:
|
|
63
|
+
}
|
|
64
|
+
}, [
|
|
65
|
+
enabled,
|
|
66
|
+
rowCount,
|
|
67
|
+
moveFocusTo
|
|
68
|
+
]);
|
|
69
|
+
const onRowFocus = useCallback((rowIndex) => {
|
|
70
|
+
setFocusedRowIndex(rowIndex);
|
|
71
|
+
}, []);
|
|
72
|
+
return {
|
|
73
|
+
focusedRowIndex: clampedFocusedRowIndex,
|
|
74
|
+
getRowTabIndex: useCallback((rowIndex) => {
|
|
75
|
+
if (!enabled) return void 0;
|
|
76
|
+
return rowIndex === clampedFocusedRowIndex ? 0 : -1;
|
|
77
|
+
}, [enabled, clampedFocusedRowIndex]),
|
|
78
|
+
onRowKeyDown,
|
|
79
|
+
onRowFocus
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
export { ROW_INDEX_ATTRIBUTE, useTableKeyboardNavigation };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ExpandedState as TanstackExpandedState, OnChangeFn as TanstackOnChangeFn } from "@tanstack/react-table";
|
|
2
|
+
interface UseTableRowExpansionOptions {
|
|
3
|
+
expandedRowIds?: string[];
|
|
4
|
+
defaultExpandedRowIds?: string[];
|
|
5
|
+
onExpandedChange?: (expandedRowIds: string[]) => void;
|
|
6
|
+
enableMultiRowExpansion?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface TableRowExpansion {
|
|
9
|
+
/** Always defined, so it can be fed to TanStack's `state.expanded`. */
|
|
10
|
+
expanded: TanstackExpandedState;
|
|
11
|
+
expandedRowIds: string[];
|
|
12
|
+
onExpandedChange: TanstackOnChangeFn<TanstackExpandedState>;
|
|
13
|
+
/** Drops ids for rows that no longer exist, e.g. after a refetch. */
|
|
14
|
+
pruneMissingRowIds: (rowIds: string[]) => void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Owns row-expansion state, controlled or uncontrolled, and translates between
|
|
18
|
+
* the `string[]` public shape and TanStack's `ExpandedState` record.
|
|
19
|
+
*
|
|
20
|
+
* Expansion lives in table state rather than in the column definitions, so
|
|
21
|
+
* toggling a row no longer rebuilds every column def.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useTableRowExpansion({ expandedRowIds, defaultExpandedRowIds, onExpandedChange, enableMultiRowExpansion, }: UseTableRowExpansionOptions): TableRowExpansion;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
//#region src/table/useTableRowExpansion.ts
|
|
3
|
+
function toExpandedState(expandedRowIds) {
|
|
4
|
+
return Object.fromEntries(expandedRowIds.map((rowId) => [rowId, true]));
|
|
5
|
+
}
|
|
6
|
+
function toExpandedRowIds(expanded) {
|
|
7
|
+
if (expanded === true) return [];
|
|
8
|
+
return Object.entries(expanded).filter(([, isExpanded]) => isExpanded).map(([rowId]) => rowId);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Owns row-expansion state, controlled or uncontrolled, and translates between
|
|
12
|
+
* the `string[]` public shape and TanStack's `ExpandedState` record.
|
|
13
|
+
*
|
|
14
|
+
* Expansion lives in table state rather than in the column definitions, so
|
|
15
|
+
* toggling a row no longer rebuilds every column def.
|
|
16
|
+
*/
|
|
17
|
+
function useTableRowExpansion({ expandedRowIds, defaultExpandedRowIds, onExpandedChange, enableMultiRowExpansion = true }) {
|
|
18
|
+
const [internalRowIds, setInternalRowIds] = useState(defaultExpandedRowIds ?? []);
|
|
19
|
+
const isControlled = expandedRowIds !== void 0;
|
|
20
|
+
const resolvedRowIds = isControlled ? expandedRowIds : internalRowIds;
|
|
21
|
+
const rowIdsRef = useRef(resolvedRowIds);
|
|
22
|
+
const onChangeRef = useRef(onExpandedChange);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
rowIdsRef.current = resolvedRowIds;
|
|
25
|
+
onChangeRef.current = onExpandedChange;
|
|
26
|
+
});
|
|
27
|
+
const applyRowIds = useCallback((nextRowIds) => {
|
|
28
|
+
rowIdsRef.current = nextRowIds;
|
|
29
|
+
if (!isControlled) setInternalRowIds(nextRowIds);
|
|
30
|
+
onChangeRef.current?.(nextRowIds);
|
|
31
|
+
}, [isControlled]);
|
|
32
|
+
const handleExpandedChange = useCallback((updater) => {
|
|
33
|
+
const current = toExpandedState(rowIdsRef.current);
|
|
34
|
+
const nextRowIds = toExpandedRowIds(typeof updater === "function" ? updater(current) : updater);
|
|
35
|
+
if (!enableMultiRowExpansion && nextRowIds.length > 1) {
|
|
36
|
+
const opened = nextRowIds.filter((rowId) => !rowIdsRef.current.includes(rowId));
|
|
37
|
+
applyRowIds(opened.length > 0 ? [opened[opened.length - 1]] : []);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
applyRowIds(nextRowIds);
|
|
41
|
+
}, [applyRowIds, enableMultiRowExpansion]);
|
|
42
|
+
const pruneMissingRowIds = useCallback((rowIds) => {
|
|
43
|
+
const present = new Set(rowIds);
|
|
44
|
+
const nextRowIds = rowIdsRef.current.filter((rowId) => present.has(rowId));
|
|
45
|
+
if (nextRowIds.length === rowIdsRef.current.length) return;
|
|
46
|
+
applyRowIds(nextRowIds);
|
|
47
|
+
}, [applyRowIds]);
|
|
48
|
+
const expanded = useMemo(() => toExpandedState(resolvedRowIds), [resolvedRowIds]);
|
|
49
|
+
return useMemo(() => ({
|
|
50
|
+
expanded,
|
|
51
|
+
expandedRowIds: resolvedRowIds,
|
|
52
|
+
onExpandedChange: handleExpandedChange,
|
|
53
|
+
pruneMissingRowIds
|
|
54
|
+
}), [
|
|
55
|
+
expanded,
|
|
56
|
+
resolvedRowIds,
|
|
57
|
+
handleExpandedChange,
|
|
58
|
+
pruneMissingRowIds
|
|
59
|
+
]);
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { useTableRowExpansion };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { OnChangeFn as TanstackOnChangeFn, Row as TanstackRow, RowSelectionState as TanstackRowSelectionState } from "@tanstack/react-table";
|
|
2
|
+
interface UseTableRowSelectionOptions<TData> {
|
|
3
|
+
rowSelection?: TanstackRowSelectionState;
|
|
4
|
+
defaultRowSelection?: TanstackRowSelectionState;
|
|
5
|
+
onRowSelectionChange?: TanstackOnChangeFn<TanstackRowSelectionState>;
|
|
6
|
+
enableMultiRowSelection?: boolean;
|
|
7
|
+
enableSelectionRange?: boolean;
|
|
8
|
+
onSelectedRowsChange?: (rows: TanstackRow<TData>[]) => void;
|
|
9
|
+
}
|
|
10
|
+
export interface TableRowSelection<TData> {
|
|
11
|
+
/** Always defined, so it can be fed to TanStack's `state.rowSelection`. */
|
|
12
|
+
rowSelection: TanstackRowSelectionState;
|
|
13
|
+
onRowSelectionChange: TanstackOnChangeFn<TanstackRowSelectionState>;
|
|
14
|
+
toggleRow: (row: TanstackRow<TData>, rows: TanstackRow<TData>[], isShiftKey: boolean) => void;
|
|
15
|
+
toggleAll: (rows: TanstackRow<TData>[], isSelected: boolean) => void;
|
|
16
|
+
notifySelectedRows: (rows: TanstackRow<TData>[]) => void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Owns row-selection state so it works whether the consumer controls it or not.
|
|
20
|
+
*
|
|
21
|
+
* TanStack replaces its default updater as soon as `onRowSelectionChange` is
|
|
22
|
+
* supplied, so passing that callback without also passing `state.rowSelection`
|
|
23
|
+
* silently freezes selection. Holding the state here means there is one code
|
|
24
|
+
* path and selection always sticks.
|
|
25
|
+
*/
|
|
26
|
+
export declare function useTableRowSelection<TData>({ rowSelection, defaultRowSelection, onRowSelectionChange, enableMultiRowSelection, enableSelectionRange, onSelectedRowsChange, }: UseTableRowSelectionOptions<TData>): TableRowSelection<TData>;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
//#region src/table/useTableRowSelection.ts
|
|
3
|
+
/**
|
|
4
|
+
* Owns row-selection state so it works whether the consumer controls it or not.
|
|
5
|
+
*
|
|
6
|
+
* TanStack replaces its default updater as soon as `onRowSelectionChange` is
|
|
7
|
+
* supplied, so passing that callback without also passing `state.rowSelection`
|
|
8
|
+
* silently freezes selection. Holding the state here means there is one code
|
|
9
|
+
* path and selection always sticks.
|
|
10
|
+
*/
|
|
11
|
+
function useTableRowSelection({ rowSelection, defaultRowSelection, onRowSelectionChange, enableMultiRowSelection = true, enableSelectionRange = true, onSelectedRowsChange }) {
|
|
12
|
+
const [internalSelection, setInternalSelection] = useState(defaultRowSelection ?? {});
|
|
13
|
+
const isControlled = rowSelection !== void 0;
|
|
14
|
+
const resolvedSelection = isControlled ? rowSelection : internalSelection;
|
|
15
|
+
const selectionRef = useRef(resolvedSelection);
|
|
16
|
+
const onChangeRef = useRef(onRowSelectionChange);
|
|
17
|
+
const onSelectedRowsChangeRef = useRef(onSelectedRowsChange);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
selectionRef.current = resolvedSelection;
|
|
20
|
+
onChangeRef.current = onRowSelectionChange;
|
|
21
|
+
onSelectedRowsChangeRef.current = onSelectedRowsChange;
|
|
22
|
+
});
|
|
23
|
+
/** Anchor for shift-click ranges — the row of the last plain click. */
|
|
24
|
+
const anchorRowIdRef = useRef(null);
|
|
25
|
+
const applySelection = useCallback((next) => {
|
|
26
|
+
selectionRef.current = next;
|
|
27
|
+
if (!isControlled) setInternalSelection(next);
|
|
28
|
+
onChangeRef.current?.(next);
|
|
29
|
+
}, [isControlled]);
|
|
30
|
+
const handleRowSelectionChange = useCallback((updater) => {
|
|
31
|
+
applySelection(typeof updater === "function" ? updater(selectionRef.current) : updater);
|
|
32
|
+
}, [applySelection]);
|
|
33
|
+
const toggleRow = useCallback((row, rows, isShiftKey) => {
|
|
34
|
+
if (!row.getCanSelect()) return;
|
|
35
|
+
const isSelected = !selectionRef.current[row.id];
|
|
36
|
+
if (!enableMultiRowSelection) {
|
|
37
|
+
applySelection(isSelected ? { [row.id]: true } : {});
|
|
38
|
+
anchorRowIdRef.current = row.id;
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const anchorRowId = anchorRowIdRef.current;
|
|
42
|
+
if (!(isShiftKey && enableSelectionRange && anchorRowId !== null)) {
|
|
43
|
+
const next = { ...selectionRef.current };
|
|
44
|
+
if (isSelected) next[row.id] = true;
|
|
45
|
+
else delete next[row.id];
|
|
46
|
+
applySelection(next);
|
|
47
|
+
anchorRowIdRef.current = row.id;
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const anchorIndex = rows.findIndex((candidate) => candidate.id === anchorRowId);
|
|
51
|
+
const targetIndex = rows.findIndex((candidate) => candidate.id === row.id);
|
|
52
|
+
if (anchorIndex === -1 || targetIndex === -1) return;
|
|
53
|
+
const [from, to] = anchorIndex <= targetIndex ? [anchorIndex, targetIndex] : [targetIndex, anchorIndex];
|
|
54
|
+
const next = { ...selectionRef.current };
|
|
55
|
+
rows.slice(from, to + 1).forEach((candidate) => {
|
|
56
|
+
if (candidate.getCanSelect()) next[candidate.id] = true;
|
|
57
|
+
});
|
|
58
|
+
applySelection(next);
|
|
59
|
+
}, [
|
|
60
|
+
applySelection,
|
|
61
|
+
enableMultiRowSelection,
|
|
62
|
+
enableSelectionRange
|
|
63
|
+
]);
|
|
64
|
+
const toggleAll = useCallback((rows, isSelected) => {
|
|
65
|
+
if (!isSelected) {
|
|
66
|
+
applySelection({});
|
|
67
|
+
anchorRowIdRef.current = null;
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const next = { ...selectionRef.current };
|
|
71
|
+
rows.forEach((row) => {
|
|
72
|
+
if (row.getCanSelect()) next[row.id] = true;
|
|
73
|
+
});
|
|
74
|
+
applySelection(next);
|
|
75
|
+
}, [applySelection]);
|
|
76
|
+
const notifySelectedRows = useCallback((rows) => {
|
|
77
|
+
onSelectedRowsChangeRef.current?.(rows);
|
|
78
|
+
}, []);
|
|
79
|
+
return useMemo(() => ({
|
|
80
|
+
rowSelection: resolvedSelection,
|
|
81
|
+
onRowSelectionChange: handleRowSelectionChange,
|
|
82
|
+
toggleRow,
|
|
83
|
+
toggleAll,
|
|
84
|
+
notifySelectedRows
|
|
85
|
+
}), [
|
|
86
|
+
resolvedSelection,
|
|
87
|
+
handleRowSelectionChange,
|
|
88
|
+
toggleRow,
|
|
89
|
+
toggleAll,
|
|
90
|
+
notifySelectedRows
|
|
91
|
+
]);
|
|
92
|
+
}
|
|
93
|
+
//#endregion
|
|
94
|
+
export { useTableRowSelection };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Theme } from "../theme/types";
|
|
2
|
+
import { EstimateColumnWidthOptions, Row, TableDensity, TableVariant } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Density and variant tokens for every table surface.
|
|
5
|
+
*
|
|
6
|
+
* This module is evaluated by Linaria at build time (its constants are
|
|
7
|
+
* interpolated statically into styled templates), so it must stay free of
|
|
8
|
+
* component imports — pulling in React, framer-motion or Phosphor here would
|
|
9
|
+
* drag them into build-time evaluation.
|
|
10
|
+
*/
|
|
11
|
+
/** Synthetic column injected in front of the consumer's columns. */
|
|
12
|
+
export declare const SELECT_COLUMN_ID = "__select__";
|
|
13
|
+
export declare const SELECT_COLUMN_WIDTH = 44;
|
|
14
|
+
export declare const EXPAND_COLUMN_ID = "__expand__";
|
|
15
|
+
export declare const EXPAND_COLUMN_WIDTH = 44;
|
|
16
|
+
/** Width assumed for a pinned column that declares no explicit `size`. */
|
|
17
|
+
export declare const DEFAULT_COLUMN_WIDTH = 150;
|
|
18
|
+
/** Bounds applied when a resized column declares no `minSize`/`maxSize`. */
|
|
19
|
+
export declare const DEFAULT_MIN_COLUMN_WIDTH = 60;
|
|
20
|
+
export declare const DEFAULT_MAX_COLUMN_WIDTH = 800;
|
|
21
|
+
/** How far past the last row the infinite-scroll sentinel reaches. */
|
|
22
|
+
export declare const INFINITE_SCROLL_ROOT_MARGIN_PX = 500;
|
|
23
|
+
/** Spreadsheet: trailing sticky column holding row actions and add-column. */
|
|
24
|
+
export declare const ROW_ACTION_COLUMN_WIDTH = 48;
|
|
25
|
+
/** Spreadsheet: diameter of the per-cell enrichment status dot. */
|
|
26
|
+
export declare const CELL_STATUS_DOT_SIZE = 6;
|
|
27
|
+
/**
|
|
28
|
+
* Builds a stand-in row for surfaces with no TanStack table instance — the
|
|
29
|
+
* virtualized table and the spreadsheet both render straight from an index.
|
|
30
|
+
*
|
|
31
|
+
* Only `original` and `index` exist at runtime. Every other member of
|
|
32
|
+
* TanStack's `Row` — `id`, `getIsSelected()`, `subRows`, `getValue()` — is
|
|
33
|
+
* typed as present but absent, so calling one throws. Cell renderers on those
|
|
34
|
+
* surfaces should read `original` and `index` and nothing else.
|
|
35
|
+
*/
|
|
36
|
+
export declare function createVirtualRow<TData>(original: TData, index: number): Row<TData>;
|
|
37
|
+
/** Vertical padding is constant across densities; only the horizontal changes. */
|
|
38
|
+
export declare const CELL_PADDING_Y = "8px";
|
|
39
|
+
export declare function getDensityRowHeightPx(density?: TableDensity): number;
|
|
40
|
+
export declare function getDensityRowHeight(density?: TableDensity): string;
|
|
41
|
+
export declare function getDensityCellPaddingX(density?: TableDensity): string;
|
|
42
|
+
export declare function getDensityCellPadding(density?: TableDensity): string;
|
|
43
|
+
export declare function getVariantBackgroundColor(theme: Theme, variant?: TableVariant): string;
|
|
44
|
+
export declare function getVariantHoverBackgroundColor(theme: Theme, variant?: TableVariant): string;
|
|
45
|
+
export declare function getVariantSelectedBackgroundColor(theme: Theme, variant?: TableVariant): string;
|
|
46
|
+
/**
|
|
47
|
+
* Estimate column width based on header name and sample data values.
|
|
48
|
+
* Useful for auto-sizing table columns based on content.
|
|
49
|
+
*/
|
|
50
|
+
export declare const estimateColumnWidth: (columnName: string, sampleValues: string[], options?: EstimateColumnWidthOptions) => number;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { TableDensity, TableVariant } from "./types.js";
|
|
2
|
+
import { match } from "ts-pattern";
|
|
3
|
+
//#region src/table/utils.ts
|
|
4
|
+
/**
|
|
5
|
+
* Density and variant tokens for every table surface.
|
|
6
|
+
*
|
|
7
|
+
* This module is evaluated by Linaria at build time (its constants are
|
|
8
|
+
* interpolated statically into styled templates), so it must stay free of
|
|
9
|
+
* component imports — pulling in React, framer-motion or Phosphor here would
|
|
10
|
+
* drag them into build-time evaluation.
|
|
11
|
+
*/
|
|
12
|
+
/** Synthetic column injected in front of the consumer's columns. */
|
|
13
|
+
var SELECT_COLUMN_ID = "__select__";
|
|
14
|
+
var SELECT_COLUMN_WIDTH = 44;
|
|
15
|
+
var EXPAND_COLUMN_ID = "__expand__";
|
|
16
|
+
var EXPAND_COLUMN_WIDTH = 44;
|
|
17
|
+
/** Width assumed for a pinned column that declares no explicit `size`. */
|
|
18
|
+
var DEFAULT_COLUMN_WIDTH = 150;
|
|
19
|
+
/** Bounds applied when a resized column declares no `minSize`/`maxSize`. */
|
|
20
|
+
var DEFAULT_MIN_COLUMN_WIDTH = 60;
|
|
21
|
+
var DEFAULT_MAX_COLUMN_WIDTH = 800;
|
|
22
|
+
/** How far past the last row the infinite-scroll sentinel reaches. */
|
|
23
|
+
var INFINITE_SCROLL_ROOT_MARGIN_PX = 500;
|
|
24
|
+
/** Spreadsheet: trailing sticky column holding row actions and add-column. */
|
|
25
|
+
var ROW_ACTION_COLUMN_WIDTH = 48;
|
|
26
|
+
/** Spreadsheet: diameter of the per-cell enrichment status dot. */
|
|
27
|
+
var CELL_STATUS_DOT_SIZE = 6;
|
|
28
|
+
/**
|
|
29
|
+
* Builds a stand-in row for surfaces with no TanStack table instance — the
|
|
30
|
+
* virtualized table and the spreadsheet both render straight from an index.
|
|
31
|
+
*
|
|
32
|
+
* Only `original` and `index` exist at runtime. Every other member of
|
|
33
|
+
* TanStack's `Row` — `id`, `getIsSelected()`, `subRows`, `getValue()` — is
|
|
34
|
+
* typed as present but absent, so calling one throws. Cell renderers on those
|
|
35
|
+
* surfaces should read `original` and `index` and nothing else.
|
|
36
|
+
*/
|
|
37
|
+
function createVirtualRow(original, index) {
|
|
38
|
+
return {
|
|
39
|
+
original,
|
|
40
|
+
index
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** Vertical padding is constant across densities; only the horizontal changes. */
|
|
44
|
+
var CELL_PADDING_Y = "8px";
|
|
45
|
+
function getDensityRowHeightPx(density) {
|
|
46
|
+
return match(density).with(TableDensity.SMALL, () => 32).with(TableDensity.MEDIUM, () => 48).with(TableDensity.LARGE, () => 56).with(void 0, () => 48).exhaustive();
|
|
47
|
+
}
|
|
48
|
+
function getDensityRowHeight(density) {
|
|
49
|
+
return `${getDensityRowHeightPx(density)}px`;
|
|
50
|
+
}
|
|
51
|
+
function getDensityCellPaddingX(density) {
|
|
52
|
+
return match(density).with(TableDensity.SMALL, () => "12px").with(TableDensity.MEDIUM, () => "16px").with(TableDensity.LARGE, () => "20px").with(void 0, () => "16px").exhaustive();
|
|
53
|
+
}
|
|
54
|
+
function getDensityCellPadding(density) {
|
|
55
|
+
return `8px ${getDensityCellPaddingX(density)}`;
|
|
56
|
+
}
|
|
57
|
+
function getVariantBackgroundColor(theme, variant) {
|
|
58
|
+
return match(variant).with(TableVariant.BASE, () => theme.color.background.base).with(TableVariant.PRIMARY, () => theme.color.background.primary).with(TableVariant.SECONDARY, () => theme.color.background.secondary).with(TableVariant.TERTIARY, () => theme.color.background.tertiary).with(void 0, () => theme.color.background.primary).exhaustive();
|
|
59
|
+
}
|
|
60
|
+
function getVariantHoverBackgroundColor(theme, variant) {
|
|
61
|
+
return match(variant).with(TableVariant.BASE, () => theme.color.background.tertiary).with(TableVariant.PRIMARY, () => theme.color.background.tertiary).with(TableVariant.SECONDARY, () => theme.color.background.tertiary).with(TableVariant.TERTIARY, () => theme.color.background.secondary).with(void 0, () => theme.color.background.tertiary).exhaustive();
|
|
62
|
+
}
|
|
63
|
+
function getVariantSelectedBackgroundColor(theme, variant) {
|
|
64
|
+
return match(variant).with(TableVariant.BASE, () => theme.color.background.secondary).with(TableVariant.PRIMARY, () => theme.color.background.secondary).with(TableVariant.SECONDARY, () => theme.color.background.primary).with(TableVariant.TERTIARY, () => theme.color.background.primary).with(void 0, () => theme.color.background.secondary).exhaustive();
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Estimate column width based on header name and sample data values.
|
|
68
|
+
* Useful for auto-sizing table columns based on content.
|
|
69
|
+
*/
|
|
70
|
+
var estimateColumnWidth = (columnName, sampleValues, options = {}) => {
|
|
71
|
+
const { minWidth = 80, maxWidth = 400, charWidth = 8, padding = 32 } = options;
|
|
72
|
+
const headerLength = columnName.length;
|
|
73
|
+
const maxValueLength = sampleValues.reduce((max, val) => Math.max(max, String(val).length), 0);
|
|
74
|
+
const estimatedWidth = Math.max(headerLength, maxValueLength) * charWidth + padding;
|
|
75
|
+
return Math.max(minWidth, Math.min(maxWidth, estimatedWidth));
|
|
76
|
+
};
|
|
77
|
+
//#endregion
|
|
78
|
+
export { CELL_PADDING_Y, CELL_STATUS_DOT_SIZE, DEFAULT_COLUMN_WIDTH, DEFAULT_MAX_COLUMN_WIDTH, DEFAULT_MIN_COLUMN_WIDTH, EXPAND_COLUMN_ID, EXPAND_COLUMN_WIDTH, INFINITE_SCROLL_ROOT_MARGIN_PX, ROW_ACTION_COLUMN_WIDTH, SELECT_COLUMN_ID, SELECT_COLUMN_WIDTH, createVirtualRow, estimateColumnWidth, getDensityCellPadding, getDensityCellPaddingX, getDensityRowHeight, getDensityRowHeightPx, getVariantBackgroundColor, getVariantHoverBackgroundColor, getVariantSelectedBackgroundColor };
|
|
@@ -22,7 +22,7 @@ var StyledParagraph = withTheme(/*#__PURE__*/ styled("p")({
|
|
|
22
22
|
"sgj79p2-3": [_exp4()]
|
|
23
23
|
}
|
|
24
24
|
}));
|
|
25
|
-
var _exp5 = () => ({ theme }) => theme.color.background.
|
|
25
|
+
var _exp5 = () => ({ theme }) => theme.color.background.tertiary;
|
|
26
26
|
var _exp6 = () => ({ theme }) => theme.color.border.tertiary;
|
|
27
27
|
var _exp7 = () => ({ theme }) => theme.font.mono.family;
|
|
28
28
|
var _exp8 = () => ({ theme }) => theme.font.mono.size.body_md;
|
|
@@ -41,7 +41,7 @@ var StyledPre = withTheme(/*#__PURE__*/ styled("pre")({
|
|
|
41
41
|
"s17hp2a6-5": [_exp0()]
|
|
42
42
|
}
|
|
43
43
|
}));
|
|
44
|
-
var _exp1 = () => ({ theme }) => theme.color.background.
|
|
44
|
+
var _exp1 = () => ({ theme }) => theme.color.background.tertiary;
|
|
45
45
|
var _exp10 = () => ({ theme }) => theme.color.border.tertiary;
|
|
46
46
|
var _exp11 = () => ({ theme }) => theme.font.mono.family;
|
|
47
47
|
var _exp12 = () => ({ theme }) => theme.font.mono.size.body_sm;
|
|
@@ -60,7 +60,7 @@ var StyledInlineCode = withTheme(/*#__PURE__*/ styled("code")({
|
|
|
60
60
|
"s1l8k0vu-5": [_exp14()]
|
|
61
61
|
}
|
|
62
62
|
}));
|
|
63
|
-
var _exp15 = () => ({ theme }) => theme.color.border.
|
|
63
|
+
var _exp15 = () => ({ theme }) => theme.color.border.tertiary;
|
|
64
64
|
var _exp16 = () => ({ theme }) => theme.font.sans.family;
|
|
65
65
|
var _exp17 = () => ({ theme }) => theme.font.sans.size.body_md;
|
|
66
66
|
var _exp18 = () => ({ theme }) => theme.font.sans.height.body_lg;
|
|
@@ -131,56 +131,67 @@ var StyledEm = withTheme(/*#__PURE__*/ styled("em")({
|
|
|
131
131
|
propsAsIs: false,
|
|
132
132
|
vars: { "s1s7p3od-0": [_exp33()] }
|
|
133
133
|
}));
|
|
134
|
-
var
|
|
134
|
+
var _exp35 = () => ({ theme }) => theme.color.text.tertiary;
|
|
135
|
+
var _exp36 = () => ({ theme }) => theme.color.text.primary;
|
|
136
|
+
var StyledAnchor = withTheme(/*#__PURE__*/ styled("a")({
|
|
137
|
+
name: "StyledAnchor",
|
|
138
|
+
class: "s1ll404u",
|
|
139
|
+
propsAsIs: false,
|
|
140
|
+
vars: {
|
|
141
|
+
"s1ll404u-0": [_exp36()],
|
|
142
|
+
"s1ll404u-1": [_exp35()]
|
|
143
|
+
}
|
|
144
|
+
}));
|
|
145
|
+
var _exp37 = () => ({ theme }) => theme.color.border.tertiary;
|
|
135
146
|
var StyledTableWrapper = withTheme(/*#__PURE__*/ styled("div")({
|
|
136
147
|
name: "StyledTableWrapper",
|
|
137
|
-
class: "
|
|
148
|
+
class: "scwvhie",
|
|
138
149
|
propsAsIs: false,
|
|
139
|
-
vars: { "
|
|
150
|
+
vars: { "scwvhie-0": [_exp37()] }
|
|
140
151
|
}));
|
|
141
|
-
var
|
|
142
|
-
var
|
|
143
|
-
var
|
|
144
|
-
var
|
|
152
|
+
var _exp38 = () => ({ theme }) => theme.font.sans.family;
|
|
153
|
+
var _exp39 = () => ({ theme }) => theme.font.sans.size.body_md;
|
|
154
|
+
var _exp40 = () => ({ theme }) => theme.font.sans.height.heading_sm;
|
|
155
|
+
var _exp41 = () => ({ theme }) => theme.color.text.primary;
|
|
145
156
|
var StyledTable = withTheme(/*#__PURE__*/ styled("table")({
|
|
146
157
|
name: "StyledTable",
|
|
147
|
-
class: "
|
|
158
|
+
class: "svk1lh",
|
|
148
159
|
propsAsIs: false,
|
|
149
160
|
vars: {
|
|
150
|
-
"
|
|
151
|
-
"
|
|
152
|
-
"
|
|
153
|
-
"
|
|
161
|
+
"svk1lh-0": [_exp38()],
|
|
162
|
+
"svk1lh-1": [_exp39()],
|
|
163
|
+
"svk1lh-2": [_exp40()],
|
|
164
|
+
"svk1lh-3": [_exp41()]
|
|
154
165
|
}
|
|
155
166
|
}));
|
|
156
|
-
var
|
|
167
|
+
var _exp42 = () => ({ theme }) => theme.color.border.secondary;
|
|
157
168
|
var StyledThead = withTheme(/*#__PURE__*/ styled("thead")({
|
|
158
169
|
name: "StyledThead",
|
|
159
|
-
class: "
|
|
170
|
+
class: "ss1iwpz",
|
|
160
171
|
propsAsIs: false,
|
|
161
|
-
vars: { "
|
|
172
|
+
vars: { "ss1iwpz-0": [_exp42()] }
|
|
162
173
|
}));
|
|
163
|
-
var
|
|
164
|
-
var
|
|
174
|
+
var _exp43 = () => ({ theme }) => theme.font.sans.weight.medium;
|
|
175
|
+
var _exp44 = () => ({ theme }) => theme.color.text.secondary;
|
|
165
176
|
var StyledTh = withTheme(/*#__PURE__*/ styled("th")({
|
|
166
177
|
name: "StyledTh",
|
|
167
|
-
class: "
|
|
178
|
+
class: "shi85us",
|
|
168
179
|
propsAsIs: false,
|
|
169
180
|
vars: {
|
|
170
|
-
"
|
|
171
|
-
"
|
|
181
|
+
"shi85us-0": [_exp43()],
|
|
182
|
+
"shi85us-1": [_exp44()]
|
|
172
183
|
}
|
|
173
184
|
}));
|
|
174
|
-
var
|
|
185
|
+
var _exp45 = () => ({ theme }) => theme.color.border.tertiary;
|
|
175
186
|
var StyledTd = withTheme(/*#__PURE__*/ styled("td")({
|
|
176
187
|
name: "StyledTd",
|
|
177
|
-
class: "
|
|
188
|
+
class: "s10h6trl",
|
|
178
189
|
propsAsIs: false,
|
|
179
|
-
vars: { "
|
|
190
|
+
vars: { "s10h6trl-0": [_exp45()] }
|
|
180
191
|
}));
|
|
181
192
|
var StyledHeadingWrapper = /*#__PURE__*/ styled("div")({
|
|
182
193
|
name: "StyledHeadingWrapper",
|
|
183
|
-
class: "
|
|
194
|
+
class: "s1sfwhg3",
|
|
184
195
|
propsAsIs: false
|
|
185
196
|
});
|
|
186
197
|
var markdownComponents = {
|
|
@@ -254,6 +265,13 @@ var markdownComponents = {
|
|
|
254
265
|
...props,
|
|
255
266
|
children
|
|
256
267
|
}),
|
|
268
|
+
a: ({ children, href, ...props }) => /* @__PURE__ */ jsx(StyledAnchor, {
|
|
269
|
+
...props,
|
|
270
|
+
href,
|
|
271
|
+
target: "_blank",
|
|
272
|
+
rel: "noreferrer",
|
|
273
|
+
children
|
|
274
|
+
}),
|
|
257
275
|
strong: ({ children, ...props }) => /* @__PURE__ */ jsx(StyledStrong, {
|
|
258
276
|
...props,
|
|
259
277
|
children
|
package/dist/widget/Widget.d.ts
CHANGED
package/dist/widget/Widget.js
CHANGED
|
@@ -10,17 +10,19 @@ var WidgetVariant = /* @__PURE__ */ function(WidgetVariant) {
|
|
|
10
10
|
WidgetVariant["PRIMARY"] = "PRIMARY";
|
|
11
11
|
WidgetVariant["SECONDARY"] = "SECONDARY";
|
|
12
12
|
WidgetVariant["TERTIARY"] = "TERTIARY";
|
|
13
|
+
WidgetVariant["SUCCESS"] = "SUCCESS";
|
|
14
|
+
WidgetVariant["WARNING"] = "WARNING";
|
|
13
15
|
WidgetVariant["ERROR"] = "ERROR";
|
|
14
16
|
WidgetVariant["DISABLED"] = "DISABLED";
|
|
15
17
|
return WidgetVariant;
|
|
16
18
|
}({});
|
|
17
19
|
var _exp = () => ({ theme, $variant }) => {
|
|
18
|
-
return match($variant).with("BASE", () => theme.color.background.base).with("PRIMARY", () => theme.color.background.primary).with("SECONDARY", () => theme.color.background.secondary).with("TERTIARY", () => theme.color.background.tertiary).with("ERROR", () => theme.color.background.
|
|
20
|
+
return match($variant).with("BASE", () => theme.color.background.base).with("PRIMARY", () => theme.color.background.primary).with("SECONDARY", () => theme.color.background.secondary).with("TERTIARY", () => theme.color.background.tertiary).with("SUCCESS", () => theme.color.background.success).with("WARNING", () => theme.color.background.warning).with("ERROR", () => theme.color.background.error).with("DISABLED", () => theme.color.background.primary).exhaustive();
|
|
19
21
|
};
|
|
20
22
|
var _exp2 = () => ({ theme, $noBorder, $isSelected, $variant }) => {
|
|
21
23
|
if ($noBorder) return "transparent";
|
|
22
24
|
if ($isSelected) return theme.color.border.selected;
|
|
23
|
-
return match($variant).with("BASE", () => theme.color.border.primary).with("PRIMARY", () => theme.color.border.primary).with("SECONDARY", () => theme.color.border.primary).with("TERTIARY", () => theme.color.border.primary).with("ERROR", () => theme.color.border.error).with("DISABLED", () => theme.color.border.
|
|
25
|
+
return match($variant).with("BASE", () => theme.color.border.primary).with("PRIMARY", () => theme.color.border.primary).with("SECONDARY", () => theme.color.border.primary).with("TERTIARY", () => theme.color.border.primary).with("SUCCESS", () => theme.color.border.success).with("WARNING", () => theme.color.border.warning).with("ERROR", () => theme.color.border.error).with("DISABLED", () => theme.color.border.primary).exhaustive();
|
|
24
26
|
};
|
|
25
27
|
var _exp3 = () => ({ $padding, $noPadding }) => $padding ?? ($noPadding ? "0" : "12px");
|
|
26
28
|
var _exp4 = () => ({ theme }) => theme.color.opacity.bw16;
|
|
@@ -43,14 +45,18 @@ var _exp1 = () => ({ $maxHeight }) => {
|
|
|
43
45
|
if ($maxHeight === void 0) return "auto";
|
|
44
46
|
return getCssSizeValue($maxHeight);
|
|
45
47
|
};
|
|
46
|
-
var _exp10 = () => ({ $
|
|
48
|
+
var _exp10 = () => ({ $variant }) => {
|
|
49
|
+
if ($variant === "DISABLED") return .5;
|
|
50
|
+
return 1;
|
|
51
|
+
};
|
|
52
|
+
var _exp11 = () => ({ $isClickable, $variant }) => {
|
|
47
53
|
if ($variant === "ERROR") return "not-allowed";
|
|
48
54
|
if ($isClickable) return "pointer";
|
|
49
55
|
return "inherit";
|
|
50
56
|
};
|
|
51
|
-
var
|
|
52
|
-
if (!$isClickable) return match($variant).with("ERROR", () => theme.color.border.error).with("DISABLED", () => theme.color.border.disabled).otherwise(() => theme.color.border.primary);
|
|
53
|
-
return match($variant).with("ERROR", () => theme.color.border.error).with("DISABLED", () => theme.color.border.disabled).otherwise(() => {
|
|
57
|
+
var _exp12 = () => ({ theme, $noHover, $isSelected, $isClickable, $variant }) => {
|
|
58
|
+
if (!$isClickable) return match($variant).with("SUCCESS", () => theme.color.border.success).with("WARNING", () => theme.color.border.warning).with("ERROR", () => theme.color.border.error).with("DISABLED", () => theme.color.border.disabled).otherwise(() => theme.color.border.primary);
|
|
59
|
+
return match($variant).with("SUCCESS", () => theme.color.border.success).with("WARNING", () => theme.color.border.warning).with("ERROR", () => theme.color.border.error).with("DISABLED", () => theme.color.border.disabled).otherwise(() => {
|
|
54
60
|
if ($isSelected) return theme.color.border.selected;
|
|
55
61
|
if ($noHover) return theme.color.border.primary;
|
|
56
62
|
return theme.color.border.secondary;
|
|
@@ -73,7 +79,8 @@ var StyledWidget = withTheme(/*#__PURE__*/ styled("div")({
|
|
|
73
79
|
"sx1o0cd-9": [_exp0()],
|
|
74
80
|
"sx1o0cd-10": [_exp1()],
|
|
75
81
|
"sx1o0cd-11": [_exp10()],
|
|
76
|
-
"sx1o0cd-12": [_exp11()]
|
|
82
|
+
"sx1o0cd-12": [_exp11()],
|
|
83
|
+
"sx1o0cd-13": [_exp12()]
|
|
77
84
|
}
|
|
78
85
|
}));
|
|
79
86
|
var Widget = ({ children, minHeight, maxHeight, minWidth, maxWidth, fillWidth, fillHeight, padding, noPadding, noHover, noBorder, isSelected, variant = "PRIMARY", onClick }) => {
|