@superad/ui 0.1.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/LICENSE +21 -0
- package/README.md +42 -0
- package/es/Button/Button.d.mts +7 -0
- package/es/Button/Button.mjs +29 -0
- package/es/Button/Button.mjs.map +1 -0
- package/es/Button/index.d.mts +3 -0
- package/es/Button/index.d.ts +1 -0
- package/es/Button/index.js +1 -0
- package/es/Button/index.mjs +2 -0
- package/es/Button/style.mjs +33 -0
- package/es/Button/style.mjs.map +1 -0
- package/es/Button/type.d.mts +21 -0
- package/es/ConfigProvider/index.d.mts +9 -0
- package/es/ConfigProvider/index.d.ts +1 -0
- package/es/ConfigProvider/index.js +1 -0
- package/es/ConfigProvider/index.mjs +82 -0
- package/es/ConfigProvider/index.mjs.map +1 -0
- package/es/ConfigProvider/type.d.mts +24 -0
- package/es/DraggablePanel/DraggablePanel.d.mts +6 -0
- package/es/DraggablePanel/DraggablePanel.mjs +104 -0
- package/es/DraggablePanel/DraggablePanel.mjs.map +1 -0
- package/es/DraggablePanel/index.d.mts +3 -0
- package/es/DraggablePanel/index.d.ts +1 -0
- package/es/DraggablePanel/index.js +1 -0
- package/es/DraggablePanel/index.mjs +3 -0
- package/es/DraggablePanel/style.mjs +86 -0
- package/es/DraggablePanel/style.mjs.map +1 -0
- package/es/DraggablePanel/type.d.mts +27 -0
- package/es/Flex/Center.d.mts +7 -0
- package/es/Flex/Center.mjs +14 -0
- package/es/Flex/Center.mjs.map +1 -0
- package/es/Flex/FlexBasic.d.mts +6 -0
- package/es/Flex/FlexBasic.mjs +46 -0
- package/es/Flex/FlexBasic.mjs.map +1 -0
- package/es/Flex/Flexbox.d.mts +2 -0
- package/es/Flex/index.d.mts +5 -0
- package/es/Flex/index.d.ts +1 -0
- package/es/Flex/index.js +1 -0
- package/es/Flex/index.mjs +3 -0
- package/es/Flex/type.d.mts +35 -0
- package/es/Flex/utils.mjs +24 -0
- package/es/Flex/utils.mjs.map +1 -0
- package/es/FontLoader/index.d.mts +9 -0
- package/es/FontLoader/index.d.ts +1 -0
- package/es/FontLoader/index.js +1 -0
- package/es/FontLoader/index.mjs +23 -0
- package/es/FontLoader/index.mjs.map +1 -0
- package/es/GlobalFocusRing/index.d.mts +6 -0
- package/es/GlobalFocusRing/index.d.ts +1 -0
- package/es/GlobalFocusRing/index.js +1 -0
- package/es/GlobalFocusRing/index.mjs +204 -0
- package/es/GlobalFocusRing/index.mjs.map +1 -0
- package/es/GlobalFocusRing/style.mjs +35 -0
- package/es/GlobalFocusRing/style.mjs.map +1 -0
- package/es/Provider.d.mts +5 -0
- package/es/Table/canvas/canvasPalette.mjs +11 -0
- package/es/Table/canvas/canvasPalette.mjs.map +1 -0
- package/es/Table/canvas/chipPainters.mjs +408 -0
- package/es/Table/canvas/chipPainters.mjs.map +1 -0
- package/es/Table/canvas/controlPainters.mjs +193 -0
- package/es/Table/canvas/controlPainters.mjs.map +1 -0
- package/es/Table/canvas/groupTitle.mjs +181 -0
- package/es/Table/canvas/groupTitle.mjs.map +1 -0
- package/es/Table/canvas/paintUtils.mjs +70 -0
- package/es/Table/canvas/paintUtils.mjs.map +1 -0
- package/es/Table/canvas/rowSeries.mjs +130 -0
- package/es/Table/canvas/rowSeries.mjs.map +1 -0
- package/es/Table/canvas/textPainters.mjs +97 -0
- package/es/Table/canvas/textPainters.mjs.map +1 -0
- package/es/Table/canvas/theme.d.mts +14 -0
- package/es/Table/canvas/theme.mjs +276 -0
- package/es/Table/canvas/theme.mjs.map +1 -0
- package/es/Table/core/cellValue.d.mts +1 -0
- package/es/Table/core/cellValue.mjs +240 -0
- package/es/Table/core/cellValue.mjs.map +1 -0
- package/es/Table/core/rowSelection.mjs +138 -0
- package/es/Table/core/rowSelection.mjs.map +1 -0
- package/es/Table/core/size.mjs +60 -0
- package/es/Table/core/size.mjs.map +1 -0
- package/es/Table/core/tableI18n.d.mts +11 -0
- package/es/Table/core/tableI18n.mjs +123 -0
- package/es/Table/core/tableI18n.mjs.map +1 -0
- package/es/Table/core/tagTone.mjs +245 -0
- package/es/Table/core/tagTone.mjs.map +1 -0
- package/es/Table/core/zIndex.mjs +7 -0
- package/es/Table/core/zIndex.mjs.map +1 -0
- package/es/Table/index.d.mts +6 -0
- package/es/Table/index.d.ts +1 -0
- package/es/Table/index.js +1 -0
- package/es/Table/index.mjs +6 -0
- package/es/Table/react/Table.d.mts +9 -0
- package/es/Table/react/Table.mjs +407 -0
- package/es/Table/react/Table.mjs.map +1 -0
- package/es/Table/react/TableColumnSettings.mjs +65 -0
- package/es/Table/react/TableColumnSettings.mjs.map +1 -0
- package/es/Table/react/a11y.mjs +72 -0
- package/es/Table/react/a11y.mjs.map +1 -0
- package/es/Table/react/editors/base.mjs +427 -0
- package/es/Table/react/editors/base.mjs.map +1 -0
- package/es/Table/react/editors/inline.mjs +225 -0
- package/es/Table/react/editors/inline.mjs.map +1 -0
- package/es/Table/react/editors/picker.mjs +368 -0
- package/es/Table/react/editors/picker.mjs.map +1 -0
- package/es/Table/react/overlayChips.mjs +50 -0
- package/es/Table/react/overlayChips.mjs.map +1 -0
- package/es/Table/react/sameRenderInputs.mjs +50 -0
- package/es/Table/react/sameRenderInputs.mjs.map +1 -0
- package/es/Table/react/style.mjs +650 -0
- package/es/Table/react/style.mjs.map +1 -0
- package/es/Table/react/useTableCellEvents.mjs +32 -0
- package/es/Table/react/useTableCellEvents.mjs.map +1 -0
- package/es/Table/react/useTableColumnSettings.mjs +107 -0
- package/es/Table/react/useTableColumnSettings.mjs.map +1 -0
- package/es/Table/react/useTableEditorSync.mjs +41 -0
- package/es/Table/react/useTableEditorSync.mjs.map +1 -0
- package/es/Table/react/useTableHoverHint.mjs +62 -0
- package/es/Table/react/useTableHoverHint.mjs.map +1 -0
- package/es/Table/react/useTableKeyboard.mjs +41 -0
- package/es/Table/react/useTableKeyboard.mjs.map +1 -0
- package/es/Table/react/useTableRenderState.mjs +194 -0
- package/es/Table/react/useTableRenderState.mjs.map +1 -0
- package/es/Table/react/useTableScroll.mjs +33 -0
- package/es/Table/react/useTableScroll.mjs.map +1 -0
- package/es/Table/react/useTableSelectionInfo.mjs +48 -0
- package/es/Table/react/useTableSelectionInfo.mjs.map +1 -0
- package/es/Table/react/useTableVTableEvents.mjs +132 -0
- package/es/Table/react/useTableVTableEvents.mjs.map +1 -0
- package/es/Table/type.d.mts +279 -0
- package/es/Table/type.mjs +34 -0
- package/es/Table/type.mjs.map +1 -0
- package/es/Table/vtable/columns.d.mts +17 -0
- package/es/Table/vtable/columns.mjs +381 -0
- package/es/Table/vtable/columns.mjs.map +1 -0
- package/es/Table/vtable/frozenShadow.mjs +27 -0
- package/es/Table/vtable/frozenShadow.mjs.map +1 -0
- package/es/Table/vtable/interaction.mjs +175 -0
- package/es/Table/vtable/interaction.mjs.map +1 -0
- package/es/Table/vtable/option.d.mts +39 -0
- package/es/Table/vtable/option.mjs +232 -0
- package/es/Table/vtable/option.mjs.map +1 -0
- package/es/Table/vtable/seriesSelection.mjs +374 -0
- package/es/Table/vtable/seriesSelection.mjs.map +1 -0
- package/es/Table/vtable/vtableAdapter.mjs +96 -0
- package/es/Table/vtable/vtableAdapter.mjs.map +1 -0
- package/es/ThemeProvider/AppElementContext.d.mts +5 -0
- package/es/ThemeProvider/AppElementContext.mjs +10 -0
- package/es/ThemeProvider/AppElementContext.mjs.map +1 -0
- package/es/ThemeProvider/ConfigProvider.mjs +29 -0
- package/es/ThemeProvider/ConfigProvider.mjs.map +1 -0
- package/es/ThemeProvider/GlobalStyle/antdOverride.mjs +73 -0
- package/es/ThemeProvider/GlobalStyle/antdOverride.mjs.map +1 -0
- package/es/ThemeProvider/GlobalStyle/essential.mjs +50 -0
- package/es/ThemeProvider/GlobalStyle/essential.mjs.map +1 -0
- package/es/ThemeProvider/GlobalStyle/global.mjs +90 -0
- package/es/ThemeProvider/GlobalStyle/global.mjs.map +1 -0
- package/es/ThemeProvider/GlobalStyle/index.mjs +14 -0
- package/es/ThemeProvider/GlobalStyle/index.mjs.map +1 -0
- package/es/ThemeProvider/Meta.d.mts +7 -0
- package/es/ThemeProvider/Meta.mjs +48 -0
- package/es/ThemeProvider/Meta.mjs.map +1 -0
- package/es/ThemeProvider/ThemeProvider.d.mts +6 -0
- package/es/ThemeProvider/ThemeProvider.mjs +89 -0
- package/es/ThemeProvider/ThemeProvider.mjs.map +1 -0
- package/es/ThemeProvider/constants.d.mts +5 -0
- package/es/ThemeProvider/constants.mjs +6 -0
- package/es/ThemeProvider/constants.mjs.map +1 -0
- package/es/ThemeProvider/index.d.mts +6 -0
- package/es/ThemeProvider/index.d.ts +1 -0
- package/es/ThemeProvider/index.js +1 -0
- package/es/ThemeProvider/index.mjs +5 -0
- package/es/ThemeProvider/type.d.mts +48 -0
- package/es/_virtual/_rolldown/runtime.mjs +13 -0
- package/es/color/colors/blue.d.mts +6 -0
- package/es/color/colors/blue.mjs +67 -0
- package/es/color/colors/blue.mjs.map +1 -0
- package/es/color/colors/cyan.d.mts +6 -0
- package/es/color/colors/cyan.mjs +67 -0
- package/es/color/colors/cyan.mjs.map +1 -0
- package/es/color/colors/geekblue.d.mts +6 -0
- package/es/color/colors/geekblue.mjs +67 -0
- package/es/color/colors/geekblue.mjs.map +1 -0
- package/es/color/colors/gold.d.mts +6 -0
- package/es/color/colors/gold.mjs +67 -0
- package/es/color/colors/gold.mjs.map +1 -0
- package/es/color/colors/gray.d.mts +6 -0
- package/es/color/colors/gray.mjs +67 -0
- package/es/color/colors/gray.mjs.map +1 -0
- package/es/color/colors/green.d.mts +6 -0
- package/es/color/colors/green.mjs +67 -0
- package/es/color/colors/green.mjs.map +1 -0
- package/es/color/colors/index.d.mts +22 -0
- package/es/color/colors/index.mjs +35 -0
- package/es/color/colors/index.mjs.map +1 -0
- package/es/color/colors/lime.d.mts +6 -0
- package/es/color/colors/lime.mjs +67 -0
- package/es/color/colors/lime.mjs.map +1 -0
- package/es/color/colors/magenta.d.mts +6 -0
- package/es/color/colors/magenta.mjs +67 -0
- package/es/color/colors/magenta.mjs.map +1 -0
- package/es/color/colors/orange.d.mts +6 -0
- package/es/color/colors/orange.mjs +67 -0
- package/es/color/colors/orange.mjs.map +1 -0
- package/es/color/colors/primary.d.mts +6 -0
- package/es/color/colors/primary.mjs +67 -0
- package/es/color/colors/primary.mjs.map +1 -0
- package/es/color/colors/purple.d.mts +6 -0
- package/es/color/colors/purple.mjs +67 -0
- package/es/color/colors/purple.mjs.map +1 -0
- package/es/color/colors/red.d.mts +6 -0
- package/es/color/colors/red.mjs +67 -0
- package/es/color/colors/red.mjs.map +1 -0
- package/es/color/colors/volcano.d.mts +6 -0
- package/es/color/colors/volcano.mjs +67 -0
- package/es/color/colors/volcano.mjs.map +1 -0
- package/es/color/colors/yellow.d.mts +6 -0
- package/es/color/colors/yellow.mjs +67 -0
- package/es/color/colors/yellow.mjs.map +1 -0
- package/es/color/index.d.mts +23 -0
- package/es/color/index.d.ts +1 -0
- package/es/color/index.js +1 -0
- package/es/color/index.mjs +22 -0
- package/es/color/neutrals/index.d.mts +13 -0
- package/es/color/neutrals/index.mjs +17 -0
- package/es/color/neutrals/index.mjs.map +1 -0
- package/es/color/neutrals/mauve.d.mts +6 -0
- package/es/color/neutrals/mauve.mjs +67 -0
- package/es/color/neutrals/mauve.mjs.map +1 -0
- package/es/color/neutrals/olive.d.mts +6 -0
- package/es/color/neutrals/olive.mjs +67 -0
- package/es/color/neutrals/olive.mjs.map +1 -0
- package/es/color/neutrals/sage.d.mts +6 -0
- package/es/color/neutrals/sage.mjs +67 -0
- package/es/color/neutrals/sage.mjs.map +1 -0
- package/es/color/neutrals/sand.d.mts +6 -0
- package/es/color/neutrals/sand.mjs +67 -0
- package/es/color/neutrals/sand.mjs.map +1 -0
- package/es/color/neutrals/slate.d.mts +6 -0
- package/es/color/neutrals/slate.mjs +67 -0
- package/es/color/neutrals/slate.mjs.map +1 -0
- package/es/color/types.d.mts +16 -0
- package/es/eslint/index.d.mts +26 -0
- package/es/eslint/index.d.ts +1 -0
- package/es/eslint/index.js +1 -0
- package/es/eslint/index.mjs +11 -0
- package/es/eslint/index.mjs.map +1 -0
- package/es/hooks/useIsClient.d.mts +8 -0
- package/es/hooks/useIsClient.mjs +13 -0
- package/es/hooks/useIsClient.mjs.map +1 -0
- package/es/i18n/context.d.mts +7 -0
- package/es/i18n/context.mjs +16 -0
- package/es/i18n/context.mjs.map +1 -0
- package/es/i18n/index.d.mts +6 -0
- package/es/i18n/index.d.ts +1 -0
- package/es/i18n/index.js +1 -0
- package/es/i18n/index.mjs +5 -0
- package/es/i18n/resources/en/common.d.mts +35 -0
- package/es/i18n/resources/en/common.mjs +36 -0
- package/es/i18n/resources/en/common.mjs.map +1 -0
- package/es/i18n/resources/en/index.d.mts +7 -0
- package/es/i18n/resources/en/index.mjs +8 -0
- package/es/i18n/resources/en/index.mjs.map +1 -0
- package/es/i18n/resources/zhCn/common.d.mts +35 -0
- package/es/i18n/resources/zhCn/common.mjs +36 -0
- package/es/i18n/resources/zhCn/common.mjs.map +1 -0
- package/es/i18n/resources/zhCn/index.d.mts +7 -0
- package/es/i18n/resources/zhCn/index.mjs +8 -0
- package/es/i18n/resources/zhCn/index.mjs.map +1 -0
- package/es/i18n/types.d.mts +22 -0
- package/es/i18n/useTranslation.d.mts +12 -0
- package/es/i18n/useTranslation.mjs +22 -0
- package/es/i18n/useTranslation.mjs.map +1 -0
- package/es/index.d.mts +43 -0
- package/es/index.mjs +26 -0
- package/es/storybook/StoryBook/StoryBook.d.mts +7 -0
- package/es/storybook/StoryBook/StoryBook.mjs +52 -0
- package/es/storybook/StoryBook/StoryBook.mjs.map +1 -0
- package/es/storybook/StoryBook/index.d.mts +3 -0
- package/es/storybook/StoryBook/style.mjs +97 -0
- package/es/storybook/StoryBook/style.mjs.map +1 -0
- package/es/storybook/StoryBook/type.d.mts +13 -0
- package/es/storybook/index.d.mts +4 -0
- package/es/storybook/index.d.ts +1 -0
- package/es/storybook/index.js +1 -0
- package/es/storybook/index.mjs +2 -0
- package/es/styles/classNames.d.mts +11 -0
- package/es/styles/classNames.mjs +12 -0
- package/es/styles/classNames.mjs.map +1 -0
- package/es/styles/customTheme.d.mts +36 -0
- package/es/styles/customTheme.mjs +71 -0
- package/es/styles/customTheme.mjs.map +1 -0
- package/es/styles/index.d.mts +6 -0
- package/es/styles/index.d.ts +1 -0
- package/es/styles/index.js +1 -0
- package/es/styles/index.mjs +6 -0
- package/es/styles/theme/algorithms/darkAlgorithm.mjs +18 -0
- package/es/styles/theme/algorithms/darkAlgorithm.mjs.map +1 -0
- package/es/styles/theme/algorithms/lightAlgorithm.mjs +18 -0
- package/es/styles/theme/algorithms/lightAlgorithm.mjs.map +1 -0
- package/es/styles/theme/algorithms/resolveScales.mjs +25 -0
- package/es/styles/theme/algorithms/resolveScales.mjs.map +1 -0
- package/es/styles/theme/antdTheme.mjs +31 -0
- package/es/styles/theme/antdTheme.mjs.map +1 -0
- package/es/styles/theme/customStylish.d.mts +7 -0
- package/es/styles/theme/customStylish.mjs +158 -0
- package/es/styles/theme/customStylish.mjs.map +1 -0
- package/es/styles/theme/customStylishStatic.d.mts +6 -0
- package/es/styles/theme/customStylishStatic.mjs +156 -0
- package/es/styles/theme/customStylishStatic.mjs.map +1 -0
- package/es/styles/theme/customToken.d.mts +7 -0
- package/es/styles/theme/customToken.mjs +127 -0
- package/es/styles/theme/customToken.mjs.map +1 -0
- package/es/styles/theme/generateColorPalette.d.mts +16 -0
- package/es/styles/theme/generateColorPalette.mjs +170 -0
- package/es/styles/theme/generateColorPalette.mjs.map +1 -0
- package/es/styles/theme/token/base.mjs +64 -0
- package/es/styles/theme/token/base.mjs.map +1 -0
- package/es/styles/theme/token/dark.mjs +37 -0
- package/es/styles/theme/token/dark.mjs.map +1 -0
- package/es/styles/theme/token/light.mjs +37 -0
- package/es/styles/theme/token/light.mjs.map +1 -0
- package/es/types/customStylish.d.mts +28 -0
- package/es/types/customToken.d.mts +34 -0
- package/es/types/customToken.mjs +32 -0
- package/es/types/customToken.mjs.map +1 -0
- package/es/types/index.d.mts +15 -0
- package/es/types/index.d.ts +1 -0
- package/es/types/index.js +1 -0
- package/es/types/index.mjs +2 -0
- package/es/utils/composeEventHandlers.d.mts +5 -0
- package/es/utils/composeEventHandlers.mjs +10 -0
- package/es/utils/composeEventHandlers.mjs.map +1 -0
- package/es/utils/copyToClipboard.d.mts +5 -0
- package/es/utils/copyToClipboard.mjs +28 -0
- package/es/utils/copyToClipboard.mjs.map +1 -0
- package/es/utils/dom.d.mts +15 -0
- package/es/utils/dom.mjs +16 -0
- package/es/utils/dom.mjs.map +1 -0
- package/es/utils/genCdnUrl.d.mts +12 -0
- package/es/utils/genCdnUrl.mjs +17 -0
- package/es/utils/genCdnUrl.mjs.map +1 -0
- package/es/utils/safeReadableColor.mjs +6 -0
- package/es/utils/safeReadableColor.mjs.map +1 -0
- package/package.json +96 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { getStateManager, isTableReleased } from "../vtable/vtableAdapter.mjs";
|
|
3
|
+
import { isFullRowRange } from "../core/rowSelection.mjs";
|
|
4
|
+
import { getCascadeSelectedCount, getCascadeSelectedRowIndexes, isCascadeSelectionTable } from "../vtable/seriesSelection.mjs";
|
|
5
|
+
import { useMemo } from "react";
|
|
6
|
+
//#region src/Table/react/useTableSelectionInfo.ts
|
|
7
|
+
/**
|
|
8
|
+
* Body rows covered by full-row ranges. 去重:逐区间累加会把重叠部分重复计入,于是同一个
|
|
9
|
+
* 表格状态会因为「调用方有没有传 `selectionActions`」而显示不同的「已选 N 行」。
|
|
10
|
+
*/
|
|
11
|
+
const collectFullRowIndexes = (table) => {
|
|
12
|
+
const startRow = table.columnHeaderLevelCount ?? 1;
|
|
13
|
+
const endRow = (table.rowCount ?? 1) - 1;
|
|
14
|
+
const endCol = (table.colCount ?? 1) - 1;
|
|
15
|
+
const ranges = getStateManager(table)?.select?.ranges ?? [];
|
|
16
|
+
const rows = /* @__PURE__ */ new Set();
|
|
17
|
+
ranges.forEach((range) => {
|
|
18
|
+
if (isFullRowRange(range, endCol) === false) return;
|
|
19
|
+
const from = Math.max(startRow, Math.min(range.start.row, range.end.row));
|
|
20
|
+
const to = Math.min(endRow, Math.max(range.start.row, range.end.row));
|
|
21
|
+
for (let row = from; row <= to; row += 1) rows.add(row);
|
|
22
|
+
});
|
|
23
|
+
return [...rows].sort((left, right) => left - right);
|
|
24
|
+
};
|
|
25
|
+
const useTableSelectionInfo = ({ selectionActions, selectionVersion, tableRef }) => useMemo(() => {
|
|
26
|
+
const table = tableRef.current;
|
|
27
|
+
if (table == null || isTableReleased(table)) return {
|
|
28
|
+
count: 0,
|
|
29
|
+
rows: []
|
|
30
|
+
};
|
|
31
|
+
if (isCascadeSelectionTable(table)) return {
|
|
32
|
+
count: getCascadeSelectedCount(table),
|
|
33
|
+
rows: selectionActions == null ? [] : getCascadeSelectedRowIndexes(table)
|
|
34
|
+
};
|
|
35
|
+
const rows = collectFullRowIndexes(table);
|
|
36
|
+
return {
|
|
37
|
+
count: rows.length,
|
|
38
|
+
rows: selectionActions == null ? [] : rows
|
|
39
|
+
};
|
|
40
|
+
}, [
|
|
41
|
+
selectionActions,
|
|
42
|
+
selectionVersion,
|
|
43
|
+
tableRef
|
|
44
|
+
]);
|
|
45
|
+
//#endregion
|
|
46
|
+
export { useTableSelectionInfo };
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=useTableSelectionInfo.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTableSelectionInfo.mjs","names":[],"sources":["../../../src/Table/react/useTableSelectionInfo.ts"],"sourcesContent":["'use client';\n\nimport type { ListTable as ListTableInstance } from '@visactor/vtable';\nimport { type RefObject, useMemo } from 'react';\n\nimport type { TableCellRange } from '../core/rowSelection';\nimport { isFullRowRange } from '../core/rowSelection';\nimport {\n getCascadeSelectedCount,\n getCascadeSelectedRowIndexes,\n isCascadeSelectionTable,\n} from '../vtable/seriesSelection';\nimport { getStateManager, isTableReleased } from '../vtable/vtableAdapter';\n\nexport interface TableSelectionInfo {\n count: number;\n rows: number[];\n}\n\n/**\n * Body rows covered by full-row ranges. 去重:逐区间累加会把重叠部分重复计入,于是同一个\n * 表格状态会因为「调用方有没有传 `selectionActions`」而显示不同的「已选 N 行」。\n */\nconst collectFullRowIndexes = (table: ListTableInstance): number[] => {\n const startRow = table.columnHeaderLevelCount ?? 1;\n const endRow = (table.rowCount ?? 1) - 1;\n const endCol = (table.colCount ?? 1) - 1;\n const ranges: TableCellRange[] = getStateManager(table)?.select?.ranges ?? [];\n const rows = new Set<number>();\n\n ranges.forEach((range) => {\n if (isFullRowRange(range, endCol) === false) return;\n\n const from = Math.max(startRow, Math.min(range.start.row, range.end.row));\n const to = Math.min(endRow, Math.max(range.start.row, range.end.row));\n for (let row = from; row <= to; row += 1) rows.add(row);\n });\n\n return [...rows].sort((left, right) => left - right);\n};\n\nexport const useTableSelectionInfo = ({\n selectionActions,\n selectionVersion,\n tableRef,\n}: {\n selectionActions?: unknown;\n selectionVersion: number;\n tableRef: RefObject<ListTableInstance | null>;\n}): TableSelectionInfo =>\n useMemo(() => {\n void selectionVersion;\n\n const table = tableRef.current;\n // `release()` 会把 `scenegraph` 与 `internalProps` 一起置 null,而 `tableRef` 仍指着那个\n // 实例 —— 之后读 `columnHeaderLevelCount` / `rowCount` / `colCount` 这些 getter 会抛\n // TypeError,而且是**渲染期**抛、库内没有错误边界,整个应用白屏。容器塌成 0×0 让表卸载、\n // 之后再重渲染就会走到这里。\n if (table == null || isTableReleased(table)) return { count: 0, rows: [] };\n\n if (isCascadeSelectionTable(table)) {\n // 级联模式下选中态的真身是 checkedState,行数口径与 ranges 不同源 —— 见 ARCHITECTURE §5。\n return {\n count: getCascadeSelectedCount(table),\n rows: selectionActions == null ? [] : getCascadeSelectedRowIndexes(table),\n };\n }\n\n const rows = collectFullRowIndexes(table);\n return { count: rows.length, rows: selectionActions == null ? [] : rows };\n }, [selectionActions, selectionVersion, tableRef]);\n"],"mappings":";;;;;;;;;;AAuBA,MAAM,yBAAyB,UAAuC;CACpE,MAAM,WAAW,MAAM,0BAA0B;CACjD,MAAM,UAAU,MAAM,YAAY,KAAK;CACvC,MAAM,UAAU,MAAM,YAAY,KAAK;CACvC,MAAM,SAA2B,gBAAgB,KAAK,CAAC,EAAE,QAAQ,UAAU,CAAC;CAC5E,MAAM,uBAAO,IAAI,IAAY;CAE7B,OAAO,SAAS,UAAU;EACxB,IAAI,eAAe,OAAO,MAAM,MAAM,OAAO;EAE7C,MAAM,OAAO,KAAK,IAAI,UAAU,KAAK,IAAI,MAAM,MAAM,KAAK,MAAM,IAAI,GAAG,CAAC;EACxE,MAAM,KAAK,KAAK,IAAI,QAAQ,KAAK,IAAI,MAAM,MAAM,KAAK,MAAM,IAAI,GAAG,CAAC;EACpE,KAAK,IAAI,MAAM,MAAM,OAAO,IAAI,OAAO,GAAG,KAAK,IAAI,GAAG;CACxD,CAAC;CAED,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,MAAM,MAAM,UAAU,OAAO,KAAK;AACrD;AAEA,MAAa,yBAAyB,EACpC,kBACA,kBACA,eAMA,cAAc;CAGZ,MAAM,QAAQ,SAAS;CAKvB,IAAI,SAAS,QAAQ,gBAAgB,KAAK,GAAG,OAAO;EAAE,OAAO;EAAG,MAAM,CAAC;CAAE;CAEzE,IAAI,wBAAwB,KAAK,GAE/B,OAAO;EACL,OAAO,wBAAwB,KAAK;EACpC,MAAM,oBAAoB,OAAO,CAAC,IAAI,6BAA6B,KAAK;CAC1E;CAGF,MAAM,OAAO,sBAAsB,KAAK;CACxC,OAAO;EAAE,OAAO,KAAK;EAAQ,MAAM,oBAAoB,OAAO,CAAC,IAAI;CAAK;AAC1E,GAAG;CAAC;CAAkB;CAAkB;AAAQ,CAAC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { resolveTableCanvasPalette } from "../canvas/theme.mjs";
|
|
3
|
+
import { getAllRowsHeight } from "../vtable/vtableAdapter.mjs";
|
|
4
|
+
import { patchFrozenShadowControls } from "../vtable/frozenShadow.mjs";
|
|
5
|
+
import { alignStickyGroupTitles } from "../canvas/groupTitle.mjs";
|
|
6
|
+
import { syncCascadeSelectionRanges } from "../vtable/seriesSelection.mjs";
|
|
7
|
+
import { refreshRowSeriesHover, refreshVisibleRowSeriesCells } from "../canvas/rowSeries.mjs";
|
|
8
|
+
import { TABLE_EVENT_TYPE } from "@visactor/vtable";
|
|
9
|
+
//#region src/Table/react/useTableVTableEvents.ts
|
|
10
|
+
const useTableVTableEvents = ({ lastRowSeriesHoverRef, onReady, rootRef, scheduleEditorSync, setA11yVersion, setMeasuredContentHeight, setResizeGuide, setSelectionVersion, stickyGroupBackground, syncFrozenColumnShadow, tableCleanupRef, tableRef, token }) => {
|
|
11
|
+
const handleReady = (instance, isInitial) => {
|
|
12
|
+
const table = instance;
|
|
13
|
+
const updateDomContainer = () => table.scenegraph.updateDomContainer();
|
|
14
|
+
const onResize = (args) => {
|
|
15
|
+
updateDomContainer();
|
|
16
|
+
alignStickyGroupTitles(table, stickyGroupBackground);
|
|
17
|
+
const host = rootRef.current;
|
|
18
|
+
const el = table.getElement();
|
|
19
|
+
if (host == null || el == null) return;
|
|
20
|
+
const rect = table.getCellRelativeRect(args?.col ?? 0, 0);
|
|
21
|
+
const hr = host.getBoundingClientRect();
|
|
22
|
+
const tr = el.getBoundingClientRect();
|
|
23
|
+
const guideLeft = rect.left + rect.width + tr.left - hr.left;
|
|
24
|
+
setResizeGuide(Math.max(0, Math.min(guideLeft, host.clientWidth - 1)));
|
|
25
|
+
};
|
|
26
|
+
const onResizeEnd = () => {
|
|
27
|
+
updateDomContainer();
|
|
28
|
+
alignStickyGroupTitles(table, stickyGroupBackground);
|
|
29
|
+
setResizeGuide(null);
|
|
30
|
+
};
|
|
31
|
+
const onSelectionChange = () => {
|
|
32
|
+
lastRowSeriesHoverRef.current = null;
|
|
33
|
+
setSelectionVersion((version) => version + 1);
|
|
34
|
+
setA11yVersion((version) => version + 1);
|
|
35
|
+
refreshVisibleRowSeriesCells(table);
|
|
36
|
+
};
|
|
37
|
+
const onEditTrigger = () => scheduleEditorSync();
|
|
38
|
+
/**
|
|
39
|
+
* 折叠 / 展开之后**容器高度必须重新问引擎**。外层容器的高度是 React 按 `records` 算的
|
|
40
|
+
* (`computeTableHeight`),而折叠只改引擎内部状态:`records` 这个 prop 的身份和内容都没变,
|
|
41
|
+
* 那个 memo 不会重算 —— 折起来时容器留一大片空白,展开时反过来把内容裁掉。
|
|
42
|
+
*
|
|
43
|
+
* 引擎发这个事件时行高**已经是新的**(实测:handler 里同步读 `getAllRowsHeight()` 就是
|
|
44
|
+
* 折叠后的值),所以同步读,不用等下一帧。
|
|
45
|
+
*
|
|
46
|
+
* 这里不能改成「按数据重算」:树节点的 `hierarchyState` 引擎会写回记录,但分组标题行
|
|
47
|
+
* (`groupBy` 生成的那些)的折叠状态只存在引擎的分组结构里,`records` 上没有。
|
|
48
|
+
*/
|
|
49
|
+
const onHierarchyChange = () => {
|
|
50
|
+
syncCascadeSelectionRanges(table);
|
|
51
|
+
alignStickyGroupTitles(table, stickyGroupBackground);
|
|
52
|
+
refreshVisibleRowSeriesCells(table);
|
|
53
|
+
setA11yVersion((version) => version + 1);
|
|
54
|
+
const measured = getAllRowsHeight(table);
|
|
55
|
+
if (measured != null) setMeasuredContentHeight(measured + 8);
|
|
56
|
+
};
|
|
57
|
+
const onLeaveTable = () => {
|
|
58
|
+
const previous = lastRowSeriesHoverRef.current;
|
|
59
|
+
lastRowSeriesHoverRef.current = null;
|
|
60
|
+
if (previous == null || previous < 0) return;
|
|
61
|
+
refreshRowSeriesHover(table, previous, -1);
|
|
62
|
+
};
|
|
63
|
+
const onScrollSticky = () => {
|
|
64
|
+
alignStickyGroupTitles(table, stickyGroupBackground);
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* `updateOption` 的第一件事是 `editorManager.cancelEdit()`,而它**只调 `exit()` + `onEnd()`、
|
|
68
|
+
* 不写值**(提交走 `completeEdit()`)—— 正在输入的内容会被静默丢弃。
|
|
69
|
+
*
|
|
70
|
+
* 而 `updateOption` 在我们的用法下**几乎必然被调用**:react-vtable 用 vutils 的 `isEqual`
|
|
71
|
+
* 比较前后 option,它的实现对任何**非纯对象**直接返回 false,而我们的列上挂着
|
|
72
|
+
* `editor: new TextEditor()` 这类类实例 —— 内容完全相同的两个实例也判不等。所以只要使用方
|
|
73
|
+
* 把 `columns` / `records` 内联传入(父组件每次渲染都换数组身份),每次渲染都会走一遍
|
|
74
|
+
* `updateOption`。实测:父组件每 1.5s 重渲染一次时,刚打开的编辑器会在 2s 内被关掉;
|
|
75
|
+
* 换成静态父组件则一直开着。
|
|
76
|
+
*
|
|
77
|
+
* VTable 在 `cancelEdit()` **之前**发这个事件,所以在这里补一次提交,把「静默丢弃」变成
|
|
78
|
+
* 「正常结束」。
|
|
79
|
+
*/
|
|
80
|
+
const onBeforeUpdateOption = () => {
|
|
81
|
+
table.completeEditCell?.();
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* a11y 隐藏层每个 cell 现读 `table.getCellValue`,但只在 `a11yVersion` 自增时才重读。
|
|
85
|
+
* 编辑提交走的是 `changeCellValue`,既不滚动也不改变选中 —— 不订阅它,读屏读到的会一直是
|
|
86
|
+
* 改前的旧值(canvas 上已经是新值),要等下一次滚动或点选才自愈。
|
|
87
|
+
*/
|
|
88
|
+
const onCellValueChange = () => {
|
|
89
|
+
setA11yVersion((version) => version + 1);
|
|
90
|
+
};
|
|
91
|
+
tableCleanupRef.current?.();
|
|
92
|
+
table.on("resize_column", onResize);
|
|
93
|
+
table.on("resize_column_end", onResizeEnd);
|
|
94
|
+
table.on("scroll", onScrollSticky);
|
|
95
|
+
table.on(TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION, onBeforeUpdateOption);
|
|
96
|
+
table.on(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, onCellValueChange);
|
|
97
|
+
table.on(TABLE_EVENT_TYPE.CHANGE_CELL_VALUES, onCellValueChange);
|
|
98
|
+
table.on(TABLE_EVENT_TYPE.CLICK_CELL, onEditTrigger);
|
|
99
|
+
table.on(TABLE_EVENT_TYPE.DBLCLICK_CELL, onEditTrigger);
|
|
100
|
+
table.on(TABLE_EVENT_TYPE.SELECTED_CHANGED, onSelectionChange);
|
|
101
|
+
table.on(TABLE_EVENT_TYPE.SELECTED_CLEAR, onSelectionChange);
|
|
102
|
+
table.on(TABLE_EVENT_TYPE.TREE_HIERARCHY_STATE_CHANGE, onHierarchyChange);
|
|
103
|
+
table.on(TABLE_EVENT_TYPE.MOUSELEAVE_TABLE, onLeaveTable);
|
|
104
|
+
tableCleanupRef.current = () => {
|
|
105
|
+
table.off("resize_column", onResize);
|
|
106
|
+
table.off("resize_column_end", onResizeEnd);
|
|
107
|
+
table.off("scroll", onScrollSticky);
|
|
108
|
+
table.off(TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION, onBeforeUpdateOption);
|
|
109
|
+
table.off(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, onCellValueChange);
|
|
110
|
+
table.off(TABLE_EVENT_TYPE.CHANGE_CELL_VALUES, onCellValueChange);
|
|
111
|
+
table.off(TABLE_EVENT_TYPE.CLICK_CELL, onEditTrigger);
|
|
112
|
+
table.off(TABLE_EVENT_TYPE.DBLCLICK_CELL, onEditTrigger);
|
|
113
|
+
table.off(TABLE_EVENT_TYPE.SELECTED_CHANGED, onSelectionChange);
|
|
114
|
+
table.off(TABLE_EVENT_TYPE.SELECTED_CLEAR, onSelectionChange);
|
|
115
|
+
table.off(TABLE_EVENT_TYPE.TREE_HIERARCHY_STATE_CHANGE, onHierarchyChange);
|
|
116
|
+
table.off(TABLE_EVENT_TYPE.MOUSELEAVE_TABLE, onLeaveTable);
|
|
117
|
+
};
|
|
118
|
+
tableRef.current = table;
|
|
119
|
+
setSelectionVersion((version) => version + 1);
|
|
120
|
+
table.__superadPalette = resolveTableCanvasPalette(token);
|
|
121
|
+
patchFrozenShadowControls(table);
|
|
122
|
+
syncFrozenColumnShadow();
|
|
123
|
+
alignStickyGroupTitles(table, stickyGroupBackground);
|
|
124
|
+
setA11yVersion((version) => version + 1);
|
|
125
|
+
onReady?.(table, isInitial);
|
|
126
|
+
};
|
|
127
|
+
return { onReady: handleReady };
|
|
128
|
+
};
|
|
129
|
+
//#endregion
|
|
130
|
+
export { useTableVTableEvents };
|
|
131
|
+
|
|
132
|
+
//# sourceMappingURL=useTableVTableEvents.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTableVTableEvents.mjs","names":[],"sources":["../../../src/Table/react/useTableVTableEvents.ts"],"sourcesContent":["'use client';\n\nimport { type ListTable as ListTableInstance, TABLE_EVENT_TYPE } from '@visactor/vtable';\nimport type { Dispatch, RefObject, SetStateAction } from 'react';\n\nimport { alignStickyGroupTitles } from '../canvas/groupTitle';\nimport { refreshRowSeriesHover, refreshVisibleRowSeriesCells } from '../canvas/rowSeries';\nimport { resolveTableCanvasPalette, type TableToken } from '../canvas/theme';\nimport { TABLE_HEIGHT_GUTTER } from '../core/size';\nimport type { TableProps } from '../type';\nimport { patchFrozenShadowControls } from '../vtable/frozenShadow';\nimport { syncCascadeSelectionRanges } from '../vtable/seriesSelection';\nimport { getAllRowsHeight } from '../vtable/vtableAdapter';\n\ntype MutableRef<T> = { current: T };\n\nexport const useTableVTableEvents = ({\n lastRowSeriesHoverRef,\n onReady,\n rootRef,\n scheduleEditorSync,\n setA11yVersion,\n setMeasuredContentHeight,\n setResizeGuide,\n setSelectionVersion,\n stickyGroupBackground,\n syncFrozenColumnShadow,\n tableCleanupRef,\n tableRef,\n token,\n}: {\n lastRowSeriesHoverRef: MutableRef<number | null>;\n onReady?: TableProps['onReady'];\n rootRef: RefObject<HTMLDivElement | null>;\n scheduleEditorSync: () => void;\n setA11yVersion: Dispatch<SetStateAction<number>>;\n setMeasuredContentHeight: Dispatch<SetStateAction<number | null>>;\n setResizeGuide: Dispatch<SetStateAction<number | null>>;\n setSelectionVersion: Dispatch<SetStateAction<number>>;\n stickyGroupBackground: string;\n syncFrozenColumnShadow: () => void;\n tableCleanupRef: MutableRef<(() => void) | undefined>;\n tableRef: MutableRef<ListTableInstance | null>;\n token: TableToken;\n}) => {\n const handleReady = (instance: unknown, isInitial: boolean) => {\n const table = instance as ListTableInstance;\n const updateDomContainer = () => table.scenegraph.updateDomContainer();\n const onResize = (args: any) => {\n updateDomContainer();\n alignStickyGroupTitles(table, stickyGroupBackground);\n const host = rootRef.current;\n const el = table.getElement();\n if (host == null || el == null) return;\n const rect = table.getCellRelativeRect(args?.col ?? 0, 0);\n const hr = host.getBoundingClientRect();\n const tr = el.getBoundingClientRect();\n const guideLeft = rect.left + rect.width + tr.left - hr.left;\n setResizeGuide(Math.max(0, Math.min(guideLeft, host.clientWidth - 1)));\n };\n const onResizeEnd = () => {\n updateDomContainer();\n alignStickyGroupTitles(table, stickyGroupBackground);\n setResizeGuide(null);\n };\n\n const onSelectionChange = () => {\n lastRowSeriesHoverRef.current = null;\n setSelectionVersion((version) => version + 1);\n setA11yVersion((version) => version + 1);\n refreshVisibleRowSeriesCells(table);\n };\n const onEditTrigger = () => scheduleEditorSync();\n /**\n * 折叠 / 展开之后**容器高度必须重新问引擎**。外层容器的高度是 React 按 `records` 算的\n * (`computeTableHeight`),而折叠只改引擎内部状态:`records` 这个 prop 的身份和内容都没变,\n * 那个 memo 不会重算 —— 折起来时容器留一大片空白,展开时反过来把内容裁掉。\n *\n * 引擎发这个事件时行高**已经是新的**(实测:handler 里同步读 `getAllRowsHeight()` 就是\n * 折叠后的值),所以同步读,不用等下一帧。\n *\n * 这里不能改成「按数据重算」:树节点的 `hierarchyState` 引擎会写回记录,但分组标题行\n * (`groupBy` 生成的那些)的折叠状态只存在引擎的分组结构里,`records` 上没有。\n */\n const onHierarchyChange = () => {\n syncCascadeSelectionRanges(table);\n alignStickyGroupTitles(table, stickyGroupBackground);\n refreshVisibleRowSeriesCells(table);\n setA11yVersion((version) => version + 1);\n const measured = getAllRowsHeight(table);\n if (measured != null) setMeasuredContentHeight(measured + TABLE_HEIGHT_GUTTER);\n };\n const onLeaveTable = () => {\n const previous = lastRowSeriesHoverRef.current;\n lastRowSeriesHoverRef.current = null;\n if (previous == null || previous < 0) return;\n refreshRowSeriesHover(table, previous, -1);\n };\n const onScrollSticky = () => {\n alignStickyGroupTitles(table, stickyGroupBackground);\n };\n /**\n * `updateOption` 的第一件事是 `editorManager.cancelEdit()`,而它**只调 `exit()` + `onEnd()`、\n * 不写值**(提交走 `completeEdit()`)—— 正在输入的内容会被静默丢弃。\n *\n * 而 `updateOption` 在我们的用法下**几乎必然被调用**:react-vtable 用 vutils 的 `isEqual`\n * 比较前后 option,它的实现对任何**非纯对象**直接返回 false,而我们的列上挂着\n * `editor: new TextEditor()` 这类类实例 —— 内容完全相同的两个实例也判不等。所以只要使用方\n * 把 `columns` / `records` 内联传入(父组件每次渲染都换数组身份),每次渲染都会走一遍\n * `updateOption`。实测:父组件每 1.5s 重渲染一次时,刚打开的编辑器会在 2s 内被关掉;\n * 换成静态父组件则一直开着。\n *\n * VTable 在 `cancelEdit()` **之前**发这个事件,所以在这里补一次提交,把「静默丢弃」变成\n * 「正常结束」。\n */\n const onBeforeUpdateOption = () => {\n (table as ListTableInstance & { completeEditCell?: () => void }).completeEditCell?.();\n };\n /**\n * a11y 隐藏层每个 cell 现读 `table.getCellValue`,但只在 `a11yVersion` 自增时才重读。\n * 编辑提交走的是 `changeCellValue`,既不滚动也不改变选中 —— 不订阅它,读屏读到的会一直是\n * 改前的旧值(canvas 上已经是新值),要等下一次滚动或点选才自愈。\n */\n const onCellValueChange = () => {\n setA11yVersion((version) => version + 1);\n };\n\n tableCleanupRef.current?.();\n table.on('resize_column', onResize);\n table.on('resize_column_end', onResizeEnd);\n table.on('scroll', onScrollSticky);\n table.on(TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION, onBeforeUpdateOption);\n table.on(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, onCellValueChange);\n table.on(TABLE_EVENT_TYPE.CHANGE_CELL_VALUES, onCellValueChange);\n table.on(TABLE_EVENT_TYPE.CLICK_CELL, onEditTrigger);\n table.on(TABLE_EVENT_TYPE.DBLCLICK_CELL, onEditTrigger);\n table.on(TABLE_EVENT_TYPE.SELECTED_CHANGED, onSelectionChange);\n table.on(TABLE_EVENT_TYPE.SELECTED_CLEAR, onSelectionChange);\n table.on(TABLE_EVENT_TYPE.TREE_HIERARCHY_STATE_CHANGE, onHierarchyChange);\n table.on(TABLE_EVENT_TYPE.MOUSELEAVE_TABLE, onLeaveTable);\n tableCleanupRef.current = () => {\n table.off('resize_column', onResize);\n table.off('resize_column_end', onResizeEnd);\n table.off('scroll', onScrollSticky);\n table.off(TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION, onBeforeUpdateOption);\n table.off(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, onCellValueChange);\n table.off(TABLE_EVENT_TYPE.CHANGE_CELL_VALUES, onCellValueChange);\n table.off(TABLE_EVENT_TYPE.CLICK_CELL, onEditTrigger);\n table.off(TABLE_EVENT_TYPE.DBLCLICK_CELL, onEditTrigger);\n table.off(TABLE_EVENT_TYPE.SELECTED_CHANGED, onSelectionChange);\n table.off(TABLE_EVENT_TYPE.SELECTED_CLEAR, onSelectionChange);\n table.off(TABLE_EVENT_TYPE.TREE_HIERARCHY_STATE_CHANGE, onHierarchyChange);\n table.off(TABLE_EVENT_TYPE.MOUSELEAVE_TABLE, onLeaveTable);\n };\n tableRef.current = table;\n setSelectionVersion((version) => version + 1);\n (\n table as ListTableInstance & {\n __superadPalette?: ReturnType<typeof resolveTableCanvasPalette>;\n }\n ).__superadPalette = resolveTableCanvasPalette(token);\n patchFrozenShadowControls(table);\n syncFrozenColumnShadow();\n alignStickyGroupTitles(table, stickyGroupBackground);\n setA11yVersion((version) => version + 1);\n onReady?.(table, isInitial);\n };\n\n return { onReady: handleReady };\n};\n"],"mappings":";;;;;;;;;AAgBA,MAAa,wBAAwB,EACnC,uBACA,SACA,SACA,oBACA,gBACA,0BACA,gBACA,qBACA,uBACA,wBACA,iBACA,UACA,YAeI;CACJ,MAAM,eAAe,UAAmB,cAAuB;EAC7D,MAAM,QAAQ;EACd,MAAM,2BAA2B,MAAM,WAAW,mBAAmB;EACrE,MAAM,YAAY,SAAc;GAC9B,mBAAmB;GACnB,uBAAuB,OAAO,qBAAqB;GACnD,MAAM,OAAO,QAAQ;GACrB,MAAM,KAAK,MAAM,WAAW;GAC5B,IAAI,QAAQ,QAAQ,MAAM,MAAM;GAChC,MAAM,OAAO,MAAM,oBAAoB,MAAM,OAAO,GAAG,CAAC;GACxD,MAAM,KAAK,KAAK,sBAAsB;GACtC,MAAM,KAAK,GAAG,sBAAsB;GACpC,MAAM,YAAY,KAAK,OAAO,KAAK,QAAQ,GAAG,OAAO,GAAG;GACxD,eAAe,KAAK,IAAI,GAAG,KAAK,IAAI,WAAW,KAAK,cAAc,CAAC,CAAC,CAAC;EACvE;EACA,MAAM,oBAAoB;GACxB,mBAAmB;GACnB,uBAAuB,OAAO,qBAAqB;GACnD,eAAe,IAAI;EACrB;EAEA,MAAM,0BAA0B;GAC9B,sBAAsB,UAAU;GAChC,qBAAqB,YAAY,UAAU,CAAC;GAC5C,gBAAgB,YAAY,UAAU,CAAC;GACvC,6BAA6B,KAAK;EACpC;EACA,MAAM,sBAAsB,mBAAmB;;;;;;;;;;;;EAY/C,MAAM,0BAA0B;GAC9B,2BAA2B,KAAK;GAChC,uBAAuB,OAAO,qBAAqB;GACnD,6BAA6B,KAAK;GAClC,gBAAgB,YAAY,UAAU,CAAC;GACvC,MAAM,WAAW,iBAAiB,KAAK;GACvC,IAAI,YAAY,MAAM,yBAAyB,WAAA,CAA8B;EAC/E;EACA,MAAM,qBAAqB;GACzB,MAAM,WAAW,sBAAsB;GACvC,sBAAsB,UAAU;GAChC,IAAI,YAAY,QAAQ,WAAW,GAAG;GACtC,sBAAsB,OAAO,UAAU,EAAE;EAC3C;EACA,MAAM,uBAAuB;GAC3B,uBAAuB,OAAO,qBAAqB;EACrD;;;;;;;;;;;;;;;EAeA,MAAM,6BAA6B;GACjC,MAAiE,mBAAmB;EACtF;;;;;;EAMA,MAAM,0BAA0B;GAC9B,gBAAgB,YAAY,UAAU,CAAC;EACzC;EAEA,gBAAgB,UAAU;EAC1B,MAAM,GAAG,iBAAiB,QAAQ;EAClC,MAAM,GAAG,qBAAqB,WAAW;EACzC,MAAM,GAAG,UAAU,cAAc;EACjC,MAAM,GAAG,iBAAiB,sBAAsB,oBAAoB;EACpE,MAAM,GAAG,iBAAiB,mBAAmB,iBAAiB;EAC9D,MAAM,GAAG,iBAAiB,oBAAoB,iBAAiB;EAC/D,MAAM,GAAG,iBAAiB,YAAY,aAAa;EACnD,MAAM,GAAG,iBAAiB,eAAe,aAAa;EACtD,MAAM,GAAG,iBAAiB,kBAAkB,iBAAiB;EAC7D,MAAM,GAAG,iBAAiB,gBAAgB,iBAAiB;EAC3D,MAAM,GAAG,iBAAiB,6BAA6B,iBAAiB;EACxE,MAAM,GAAG,iBAAiB,kBAAkB,YAAY;EACxD,gBAAgB,gBAAgB;GAC9B,MAAM,IAAI,iBAAiB,QAAQ;GACnC,MAAM,IAAI,qBAAqB,WAAW;GAC1C,MAAM,IAAI,UAAU,cAAc;GAClC,MAAM,IAAI,iBAAiB,sBAAsB,oBAAoB;GACrE,MAAM,IAAI,iBAAiB,mBAAmB,iBAAiB;GAC/D,MAAM,IAAI,iBAAiB,oBAAoB,iBAAiB;GAChE,MAAM,IAAI,iBAAiB,YAAY,aAAa;GACpD,MAAM,IAAI,iBAAiB,eAAe,aAAa;GACvD,MAAM,IAAI,iBAAiB,kBAAkB,iBAAiB;GAC9D,MAAM,IAAI,iBAAiB,gBAAgB,iBAAiB;GAC5D,MAAM,IAAI,iBAAiB,6BAA6B,iBAAiB;GACzE,MAAM,IAAI,iBAAiB,kBAAkB,YAAY;EAC3D;EACA,SAAS,UAAU;EACnB,qBAAqB,YAAY,UAAU,CAAC;EAC5C,MAIE,mBAAmB,0BAA0B,KAAK;EACpD,0BAA0B,KAAK;EAC/B,uBAAuB;EACvB,uBAAuB,OAAO,qBAAqB;EACnD,gBAAgB,YAAY,UAAU,CAAC;EACvC,UAAU,OAAO,SAAS;CAC5B;CAEA,OAAO,EAAE,SAAS,YAAY;AAChC"}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode, Ref } from "react";
|
|
2
|
+
import { ColumnDefine, ColumnDefine as ColumnDefine$1, ColumnsDefine as ColumnsDefine$1, ListTable, ListTableConstructorOptions, ListTableConstructorOptions as ListTableConstructorOptions$1 } from "@visactor/vtable";
|
|
3
|
+
//#region src/Table/type.d.ts
|
|
4
|
+
type TableSize = 'large' | 'middle' | 'small';
|
|
5
|
+
type TableHover = 'cell' | 'column' | 'cross' | 'none' | 'row';
|
|
6
|
+
type TableCellType = 'address' | 'array' | 'boolean' | 'checkbox' | 'currency' | 'date' | 'dateRange' | 'datetime' | 'email' | 'image' | 'json' | 'link' | 'number' | 'phone' | 'progress' | 'rating' | 'select' | 'tag' | 'text' | 'user';
|
|
7
|
+
declare const TABLE_CELL_MIN_WIDTH: Record<TableCellType, number>;
|
|
8
|
+
declare const DEFAULT_TABLE_COLUMN_MIN_WIDTH = 80;
|
|
9
|
+
declare const TABLE_ROW_HEIGHT: Record<TableSize, number>;
|
|
10
|
+
declare const TABLE_HEADER_HEIGHT = 36;
|
|
11
|
+
interface TableSelectOption {
|
|
12
|
+
/**
|
|
13
|
+
* SuperAd tag color name (`blue`, `green`, `purple`…) or a hex that snaps to that palette.
|
|
14
|
+
*/
|
|
15
|
+
color?: string;
|
|
16
|
+
label: string;
|
|
17
|
+
value: string;
|
|
18
|
+
}
|
|
19
|
+
interface TableUser {
|
|
20
|
+
avatar?: string;
|
|
21
|
+
/**
|
|
22
|
+
* 第二行说明(部门 / 公司 / 邮箱…)。只出现在**人员选择面板**里,单元格仍只画姓名。
|
|
23
|
+
*/
|
|
24
|
+
description?: string;
|
|
25
|
+
name: string;
|
|
26
|
+
}
|
|
27
|
+
interface TableAddress {
|
|
28
|
+
city?: string;
|
|
29
|
+
country?: string;
|
|
30
|
+
postcode?: string;
|
|
31
|
+
state?: string;
|
|
32
|
+
street?: string;
|
|
33
|
+
street2?: string;
|
|
34
|
+
}
|
|
35
|
+
interface TableRecord {
|
|
36
|
+
[key: string]: unknown;
|
|
37
|
+
children?: TableRecord[];
|
|
38
|
+
hierarchyState?: 'collapse' | 'expand';
|
|
39
|
+
}
|
|
40
|
+
/** SuperAd column. Use `type` for bitable-style cells; raw VTable columns are also accepted. */
|
|
41
|
+
interface TableColumn {
|
|
42
|
+
/**
|
|
43
|
+
* Currency symbol for `currency` cells.
|
|
44
|
+
* @default ¥
|
|
45
|
+
*/
|
|
46
|
+
currency?: string;
|
|
47
|
+
/**
|
|
48
|
+
* 状态 / 标签标题后跟的时长来源:记录里存日期范围的字段名(值本身是 `[起, 止]` 数组),
|
|
49
|
+
* 或 `{ from, to }` 两个字段。时长按「N天 / N个月」现算,不写死在选项里。
|
|
50
|
+
*/
|
|
51
|
+
duration?: string | {
|
|
52
|
+
from: string;
|
|
53
|
+
to: string;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Enable editor for this column.
|
|
57
|
+
* @default inherits Table.editable
|
|
58
|
+
*/
|
|
59
|
+
editable?: boolean;
|
|
60
|
+
field: string;
|
|
61
|
+
/**
|
|
62
|
+
* Custom cell text, passed straight through to VTable. When set it wins over the
|
|
63
|
+
* formatter this component would generate for `type`; the column still keeps its
|
|
64
|
+
* editor, so `fieldFormat` and `editable` can be used together.
|
|
65
|
+
*/
|
|
66
|
+
fieldFormat?: ColumnDefine['fieldFormat'];
|
|
67
|
+
/**
|
|
68
|
+
* Datetime display format, also used by `dateRange`.
|
|
69
|
+
* @default YYYY-MM-DD
|
|
70
|
+
*/
|
|
71
|
+
format?: string;
|
|
72
|
+
/** Minimum column width. Defaults to a type-specific value. */
|
|
73
|
+
minWidth?: number | string;
|
|
74
|
+
/**
|
|
75
|
+
* Allow multiple values for tag / select / user / email / phone.
|
|
76
|
+
* @default false for select, true for tag / user / email / phone / array
|
|
77
|
+
*/
|
|
78
|
+
multiple?: boolean;
|
|
79
|
+
options?: TableSelectOption[];
|
|
80
|
+
/**
|
|
81
|
+
* Enable header sort.
|
|
82
|
+
* @default false
|
|
83
|
+
*/
|
|
84
|
+
sort?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Optional VTable cell style. Useful for row-level highlighting in tree / grouped tables.
|
|
87
|
+
*/
|
|
88
|
+
style?: ColumnDefine['style'];
|
|
89
|
+
title?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Mark this column as the tree expand column.
|
|
92
|
+
* @default first column when Table.tree is true
|
|
93
|
+
*/
|
|
94
|
+
tree?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Cell type.
|
|
97
|
+
*
|
|
98
|
+
* `image` is preview-only (`clickToPreview`). It never mounts an editor, even
|
|
99
|
+
* when `Table.editable` is true.
|
|
100
|
+
* @default text
|
|
101
|
+
*/
|
|
102
|
+
type?: TableCellType;
|
|
103
|
+
/**
|
|
104
|
+
* Suffix for `number` / `progress` cells, such as `%`.
|
|
105
|
+
* `progress` defaults to `%`.
|
|
106
|
+
*/
|
|
107
|
+
unit?: string;
|
|
108
|
+
/** People directory for `user` picker. */
|
|
109
|
+
users?: TableUser[];
|
|
110
|
+
width?: number | string;
|
|
111
|
+
}
|
|
112
|
+
type TableColumnInput = ColumnDefine | TableColumn;
|
|
113
|
+
/** SuperAd table, wrapping VisActor VTable ListTable. */
|
|
114
|
+
interface TableProps {
|
|
115
|
+
/**
|
|
116
|
+
* Stretch columns to fill the container.
|
|
117
|
+
* @default true
|
|
118
|
+
*/
|
|
119
|
+
autoFillWidth?: boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Shrink numeric height to content height.
|
|
122
|
+
* @default true
|
|
123
|
+
*/
|
|
124
|
+
autoHeight?: boolean;
|
|
125
|
+
className?: string;
|
|
126
|
+
/** SuperAd or VTable column definitions. */
|
|
127
|
+
columns?: TableColumnInput[];
|
|
128
|
+
/**
|
|
129
|
+
* Enable editors on supported cell types. Click a cell to edit; select / tag cells open an option picker.
|
|
130
|
+
* @default false
|
|
131
|
+
*/
|
|
132
|
+
editable?: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Empty state copy.
|
|
135
|
+
* @default No data
|
|
136
|
+
*/
|
|
137
|
+
emptyText?: string;
|
|
138
|
+
/**
|
|
139
|
+
* Freeze the first N data columns. The row index / drag column stays fixed on
|
|
140
|
+
* the left, so with it present the frozen columns start at the second column.
|
|
141
|
+
*
|
|
142
|
+
* VTable caps the frozen block at 80% of the table width. Rather than dropping
|
|
143
|
+
* the whole freeze once the block would be wider, the block is trimmed to the
|
|
144
|
+
* columns that fit — a narrow container freezes fewer columns instead of none.
|
|
145
|
+
* Pass `option={{ unfreezeAllOnExceedsMaxWidth: true }}` to drop it entirely
|
|
146
|
+
* instead. Reaching the column count (N plus the row index column) zeroes it too.
|
|
147
|
+
* @default 0
|
|
148
|
+
*/
|
|
149
|
+
frozenColCount?: number;
|
|
150
|
+
/**
|
|
151
|
+
* Group rows by field name.
|
|
152
|
+
*/
|
|
153
|
+
groupBy?: string | string[];
|
|
154
|
+
/**
|
|
155
|
+
* Per-group title tag colors, keyed by group value. When provided, group
|
|
156
|
+
* titles render as colored tags while keeping the standard collapse icon.
|
|
157
|
+
*/
|
|
158
|
+
groupTitleColors?: Record<string, string | undefined>;
|
|
159
|
+
/** Merged on top of the default group title style. */
|
|
160
|
+
groupTitleStyle?: NonNullable<ListTableConstructorOptions['theme']>['groupTitleStyle'];
|
|
161
|
+
/**
|
|
162
|
+
* Header row height in pixels. Strings like `32px` are accepted.
|
|
163
|
+
*/
|
|
164
|
+
headerRowHeight?: number | string;
|
|
165
|
+
/**
|
|
166
|
+
* Table height. When autoHeight is true and records exist, a numeric value shrinks to content height.
|
|
167
|
+
* @default auto
|
|
168
|
+
*/
|
|
169
|
+
height?: number | string;
|
|
170
|
+
/**
|
|
171
|
+
* Hover highlight mode.
|
|
172
|
+
* @default row
|
|
173
|
+
*/
|
|
174
|
+
hover?: TableHover;
|
|
175
|
+
/**
|
|
176
|
+
* Called after a column is moved with the column settings menu.
|
|
177
|
+
*/
|
|
178
|
+
onColumnOrderChange?: (fields: string[]) => void;
|
|
179
|
+
/**
|
|
180
|
+
* Called after a column is shown or hidden with the column settings menu.
|
|
181
|
+
*/
|
|
182
|
+
onColumnVisibilityChange?: (field: string, visible: boolean) => void;
|
|
183
|
+
onReady?: (instance: ListTable, isInitial: boolean) => void;
|
|
184
|
+
/**
|
|
185
|
+
* Extra VTable options. First-class props win on conflict.
|
|
186
|
+
*
|
|
187
|
+
* Column resizing is off by default — pass `{ columnResizeMode: 'all' }`
|
|
188
|
+
* (or `'header'` / `'body'`) to enable it. The column drag guide only appears
|
|
189
|
+
* while it is on.
|
|
190
|
+
*
|
|
191
|
+
* `rowSeriesNumber` is merged onto the built-in row index column rather than
|
|
192
|
+
* replacing it, so a custom `field` / `cellType` / `title` applies and the
|
|
193
|
+
* checkbox state follows the `field` you give. One exception: while the row
|
|
194
|
+
* selection column is on, its checkbox is drawn by this component on canvas, so
|
|
195
|
+
* `cellType` / `headerType` are dropped — passing `checkbox` would make VTable
|
|
196
|
+
* draw a second one in the same cell.
|
|
197
|
+
*/
|
|
198
|
+
option?: ListTableConstructorOptions;
|
|
199
|
+
/** Row data. Nested rows use `children` when `tree` is on. */
|
|
200
|
+
records?: TableRecord[];
|
|
201
|
+
ref?: Ref<ListTable>;
|
|
202
|
+
/**
|
|
203
|
+
* Reorder rows via VTable's native `rowSeriesNumber.dragOrder` handle.
|
|
204
|
+
* Opt-in per table (`@default false`); other tables are unchanged unless they pass it.
|
|
205
|
+
* Tree / grouped tables can turn it on, but VTable reorders visible rows and does not
|
|
206
|
+
* keep parent–child or group-title semantics — dragging a parent will not move children
|
|
207
|
+
* as a unit, and group title rows are not data records.
|
|
208
|
+
* @default false
|
|
209
|
+
*/
|
|
210
|
+
rowDrag?: boolean;
|
|
211
|
+
/**
|
|
212
|
+
* Body row height in pixels. Strings like `32px` are accepted.
|
|
213
|
+
*/
|
|
214
|
+
rowHeight?: number | string;
|
|
215
|
+
/**
|
|
216
|
+
* Render extra actions in the selection status bar.
|
|
217
|
+
*
|
|
218
|
+
* `selectedRowIndexes` lists **visible** rows only. The "已选 N 行" count next to it
|
|
219
|
+
* counts every checked record instead, so it can exceed `selectedRowIndexes.length`
|
|
220
|
+
* when a group node is collapsed — collapsed rows are still selected, they just are
|
|
221
|
+
* not on screen. Do not derive one from the other.
|
|
222
|
+
*/
|
|
223
|
+
selectionActions?: (selectedRowIndexes: number[], clearSelection: () => void) => ReactNode;
|
|
224
|
+
/**
|
|
225
|
+
* Show the column settings menu button in the header.
|
|
226
|
+
* @default true
|
|
227
|
+
*/
|
|
228
|
+
showColumnSettings?: boolean;
|
|
229
|
+
/**
|
|
230
|
+
* @default true
|
|
231
|
+
*/
|
|
232
|
+
showHeader?: boolean;
|
|
233
|
+
/**
|
|
234
|
+
* Show a leading row index column.
|
|
235
|
+
* @default false
|
|
236
|
+
*/
|
|
237
|
+
showRowIndex?: boolean;
|
|
238
|
+
/**
|
|
239
|
+
* Show the row selection checkbox column.
|
|
240
|
+
* @default true
|
|
241
|
+
*/
|
|
242
|
+
showRowSelection?: boolean;
|
|
243
|
+
/**
|
|
244
|
+
* Show vertical borders between columns, including the leading row index column.
|
|
245
|
+
* @default false
|
|
246
|
+
*/
|
|
247
|
+
showVerticalBorder?: boolean;
|
|
248
|
+
/**
|
|
249
|
+
* Row density.
|
|
250
|
+
* @default middle
|
|
251
|
+
*/
|
|
252
|
+
size?: TableSize;
|
|
253
|
+
style?: CSSProperties;
|
|
254
|
+
/** Merged on top of the SuperAd VTable theme. */
|
|
255
|
+
theme?: ListTableConstructorOptions['theme'];
|
|
256
|
+
/**
|
|
257
|
+
* Enable tree rows. Records nest via `children`.
|
|
258
|
+
* @default false
|
|
259
|
+
*/
|
|
260
|
+
tree?: boolean;
|
|
261
|
+
/**
|
|
262
|
+
* Expanded tree depth. Use `Infinity` to expand all.
|
|
263
|
+
* @default 1
|
|
264
|
+
*/
|
|
265
|
+
treeExpandLevel?: number;
|
|
266
|
+
/**
|
|
267
|
+
* Indent per tree level.
|
|
268
|
+
* @default 16
|
|
269
|
+
*/
|
|
270
|
+
treeIndent?: number;
|
|
271
|
+
/**
|
|
272
|
+
* @default 100%
|
|
273
|
+
*/
|
|
274
|
+
width?: number | string;
|
|
275
|
+
}
|
|
276
|
+
type TableTheme = NonNullable<ListTableConstructorOptions['theme']>;
|
|
277
|
+
//#endregion
|
|
278
|
+
export { type ColumnDefine$1 as ColumnDefine, type ColumnsDefine$1 as ColumnsDefine, DEFAULT_TABLE_COLUMN_MIN_WIDTH, type ListTableConstructorOptions$1 as ListTableConstructorOptions, TABLE_CELL_MIN_WIDTH, TABLE_HEADER_HEIGHT, TABLE_ROW_HEIGHT, TableAddress, TableCellType, TableColumn, TableColumnInput, TableHover, TableProps, TableRecord, TableSelectOption, TableSize, TableTheme, TableUser };
|
|
279
|
+
//# sourceMappingURL=type.d.mts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region src/Table/type.ts
|
|
2
|
+
const TABLE_CELL_MIN_WIDTH = {
|
|
3
|
+
address: 160,
|
|
4
|
+
array: 104,
|
|
5
|
+
boolean: 64,
|
|
6
|
+
checkbox: 56,
|
|
7
|
+
currency: 96,
|
|
8
|
+
date: 112,
|
|
9
|
+
dateRange: 216,
|
|
10
|
+
datetime: 144,
|
|
11
|
+
email: 144,
|
|
12
|
+
image: 80,
|
|
13
|
+
json: 120,
|
|
14
|
+
link: 144,
|
|
15
|
+
number: 80,
|
|
16
|
+
phone: 128,
|
|
17
|
+
progress: 112,
|
|
18
|
+
rating: 96,
|
|
19
|
+
select: 96,
|
|
20
|
+
tag: 104,
|
|
21
|
+
text: 80,
|
|
22
|
+
user: 112
|
|
23
|
+
};
|
|
24
|
+
const DEFAULT_TABLE_COLUMN_MIN_WIDTH = 80;
|
|
25
|
+
const TABLE_ROW_HEIGHT = {
|
|
26
|
+
large: 44,
|
|
27
|
+
middle: 36,
|
|
28
|
+
small: 32
|
|
29
|
+
};
|
|
30
|
+
const TABLE_HEADER_HEIGHT = 36;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { DEFAULT_TABLE_COLUMN_MIN_WIDTH, TABLE_CELL_MIN_WIDTH, TABLE_HEADER_HEIGHT, TABLE_ROW_HEIGHT };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=type.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.mjs","names":[],"sources":["../../src/Table/type.ts"],"sourcesContent":["import type { ColumnDefine, ListTable, ListTableConstructorOptions } from '@visactor/vtable';\nimport type { CSSProperties, ReactNode, Ref } from 'react';\n\nexport type TableSize = 'large' | 'middle' | 'small';\n\nexport type TableHover = 'cell' | 'column' | 'cross' | 'none' | 'row';\n\nexport type TableCellType =\n | 'address'\n | 'array'\n | 'boolean'\n | 'checkbox'\n | 'currency'\n | 'date'\n | 'dateRange'\n | 'datetime'\n | 'email'\n | 'image'\n | 'json'\n | 'link'\n | 'number'\n | 'phone'\n | 'progress'\n | 'rating'\n | 'select'\n | 'tag'\n | 'text'\n | 'user';\n\nexport const TABLE_CELL_MIN_WIDTH: Record<TableCellType, number> = {\n address: 160,\n array: 104,\n boolean: 64,\n checkbox: 56,\n currency: 96,\n date: 112,\n dateRange: 216,\n datetime: 144,\n email: 144,\n image: 80,\n json: 120,\n link: 144,\n number: 80,\n phone: 128,\n progress: 112,\n rating: 96,\n select: 96,\n tag: 104,\n text: 80,\n user: 112,\n};\n\nexport const DEFAULT_TABLE_COLUMN_MIN_WIDTH = 80;\n\nexport const TABLE_ROW_HEIGHT: Record<TableSize, number> = {\n large: 44,\n middle: 36,\n small: 32,\n};\nexport const TABLE_HEADER_HEIGHT = 36;\n\nexport interface TableSelectOption {\n /**\n * SuperAd tag color name (`blue`, `green`, `purple`…) or a hex that snaps to that palette.\n */\n color?: string;\n label: string;\n value: string;\n}\n\nexport interface TableUser {\n avatar?: string;\n /**\n * 第二行说明(部门 / 公司 / 邮箱…)。只出现在**人员选择面板**里,单元格仍只画姓名。\n */\n description?: string;\n name: string;\n}\n\nexport interface TableAddress {\n city?: string;\n country?: string;\n postcode?: string;\n state?: string;\n street?: string;\n street2?: string;\n}\n\nexport interface TableRecord {\n [key: string]: unknown;\n children?: TableRecord[];\n hierarchyState?: 'collapse' | 'expand';\n}\n\n/** SuperAd column. Use `type` for bitable-style cells; raw VTable columns are also accepted. */\nexport interface TableColumn {\n /**\n * Currency symbol for `currency` cells.\n * @default ¥\n */\n currency?: string;\n /**\n * 状态 / 标签标题后跟的时长来源:记录里存日期范围的字段名(值本身是 `[起, 止]` 数组),\n * 或 `{ from, to }` 两个字段。时长按「N天 / N个月」现算,不写死在选项里。\n */\n duration?: string | { from: string; to: string };\n /**\n * Enable editor for this column.\n * @default inherits Table.editable\n */\n editable?: boolean;\n field: string;\n /**\n * Custom cell text, passed straight through to VTable. When set it wins over the\n * formatter this component would generate for `type`; the column still keeps its\n * editor, so `fieldFormat` and `editable` can be used together.\n */\n fieldFormat?: ColumnDefine['fieldFormat'];\n /**\n * Datetime display format, also used by `dateRange`.\n * @default YYYY-MM-DD\n */\n format?: string;\n /** Minimum column width. Defaults to a type-specific value. */\n minWidth?: number | string;\n /**\n * Allow multiple values for tag / select / user / email / phone.\n * @default false for select, true for tag / user / email / phone / array\n */\n multiple?: boolean;\n options?: TableSelectOption[];\n /**\n * Enable header sort.\n * @default false\n */\n sort?: boolean;\n /**\n * Optional VTable cell style. Useful for row-level highlighting in tree / grouped tables.\n */\n style?: ColumnDefine['style'];\n title?: string;\n /**\n * Mark this column as the tree expand column.\n * @default first column when Table.tree is true\n */\n tree?: boolean;\n /**\n * Cell type.\n *\n * `image` is preview-only (`clickToPreview`). It never mounts an editor, even\n * when `Table.editable` is true.\n * @default text\n */\n type?: TableCellType;\n /**\n * Suffix for `number` / `progress` cells, such as `%`.\n * `progress` defaults to `%`.\n */\n unit?: string;\n /** People directory for `user` picker. */\n users?: TableUser[];\n width?: number | string;\n}\n\nexport type TableColumnInput = ColumnDefine | TableColumn;\n\n/** SuperAd table, wrapping VisActor VTable ListTable. */\nexport interface TableProps {\n /**\n * Stretch columns to fill the container.\n * @default true\n */\n autoFillWidth?: boolean;\n /**\n * Shrink numeric height to content height.\n * @default true\n */\n autoHeight?: boolean;\n className?: string;\n /** SuperAd or VTable column definitions. */\n columns?: TableColumnInput[];\n /**\n * Enable editors on supported cell types. Click a cell to edit; select / tag cells open an option picker.\n * @default false\n */\n editable?: boolean;\n /**\n * Empty state copy.\n * @default No data\n */\n emptyText?: string;\n /**\n * Freeze the first N data columns. The row index / drag column stays fixed on\n * the left, so with it present the frozen columns start at the second column.\n *\n * VTable caps the frozen block at 80% of the table width. Rather than dropping\n * the whole freeze once the block would be wider, the block is trimmed to the\n * columns that fit — a narrow container freezes fewer columns instead of none.\n * Pass `option={{ unfreezeAllOnExceedsMaxWidth: true }}` to drop it entirely\n * instead. Reaching the column count (N plus the row index column) zeroes it too.\n * @default 0\n */\n frozenColCount?: number;\n /**\n * Group rows by field name.\n */\n groupBy?: string | string[];\n /**\n * Per-group title tag colors, keyed by group value. When provided, group\n * titles render as colored tags while keeping the standard collapse icon.\n */\n groupTitleColors?: Record<string, string | undefined>;\n /** Merged on top of the default group title style. */\n groupTitleStyle?: NonNullable<ListTableConstructorOptions['theme']>['groupTitleStyle'];\n /**\n * Header row height in pixels. Strings like `32px` are accepted.\n */\n headerRowHeight?: number | string;\n /**\n * Table height. When autoHeight is true and records exist, a numeric value shrinks to content height.\n * @default auto\n */\n height?: number | string;\n /**\n * Hover highlight mode.\n * @default row\n */\n hover?: TableHover;\n /**\n * Called after a column is moved with the column settings menu.\n */\n onColumnOrderChange?: (fields: string[]) => void;\n /**\n * Called after a column is shown or hidden with the column settings menu.\n */\n onColumnVisibilityChange?: (field: string, visible: boolean) => void;\n onReady?: (instance: ListTable, isInitial: boolean) => void;\n /**\n * Extra VTable options. First-class props win on conflict.\n *\n * Column resizing is off by default — pass `{ columnResizeMode: 'all' }`\n * (or `'header'` / `'body'`) to enable it. The column drag guide only appears\n * while it is on.\n *\n * `rowSeriesNumber` is merged onto the built-in row index column rather than\n * replacing it, so a custom `field` / `cellType` / `title` applies and the\n * checkbox state follows the `field` you give. One exception: while the row\n * selection column is on, its checkbox is drawn by this component on canvas, so\n * `cellType` / `headerType` are dropped — passing `checkbox` would make VTable\n * draw a second one in the same cell.\n */\n option?: ListTableConstructorOptions;\n /** Row data. Nested rows use `children` when `tree` is on. */\n records?: TableRecord[];\n ref?: Ref<ListTable>;\n /**\n * Reorder rows via VTable's native `rowSeriesNumber.dragOrder` handle.\n * Opt-in per table (`@default false`); other tables are unchanged unless they pass it.\n * Tree / grouped tables can turn it on, but VTable reorders visible rows and does not\n * keep parent–child or group-title semantics — dragging a parent will not move children\n * as a unit, and group title rows are not data records.\n * @default false\n */\n rowDrag?: boolean;\n /**\n * Body row height in pixels. Strings like `32px` are accepted.\n */\n rowHeight?: number | string;\n /**\n * Render extra actions in the selection status bar.\n *\n * `selectedRowIndexes` lists **visible** rows only. The \"已选 N 行\" count next to it\n * counts every checked record instead, so it can exceed `selectedRowIndexes.length`\n * when a group node is collapsed — collapsed rows are still selected, they just are\n * not on screen. Do not derive one from the other.\n */\n selectionActions?: (selectedRowIndexes: number[], clearSelection: () => void) => ReactNode;\n /**\n * Show the column settings menu button in the header.\n * @default true\n */\n showColumnSettings?: boolean;\n /**\n * @default true\n */\n showHeader?: boolean;\n /**\n * Show a leading row index column.\n * @default false\n */\n showRowIndex?: boolean;\n /**\n * Show the row selection checkbox column.\n * @default true\n */\n showRowSelection?: boolean;\n /**\n * Show vertical borders between columns, including the leading row index column.\n * @default false\n */\n showVerticalBorder?: boolean;\n /**\n * Row density.\n * @default middle\n */\n size?: TableSize;\n style?: CSSProperties;\n /** Merged on top of the SuperAd VTable theme. */\n theme?: ListTableConstructorOptions['theme'];\n /**\n * Enable tree rows. Records nest via `children`.\n * @default false\n */\n tree?: boolean;\n /**\n * Expanded tree depth. Use `Infinity` to expand all.\n * @default 1\n */\n treeExpandLevel?: number;\n /**\n * Indent per tree level.\n * @default 16\n */\n treeIndent?: number;\n /**\n * @default 100%\n */\n width?: number | string;\n}\n\nexport type { ColumnDefine, ColumnsDefine, ListTableConstructorOptions } from '@visactor/vtable';\nexport type TableTheme = NonNullable<ListTableConstructorOptions['theme']>;\n"],"mappings":";AA6BA,MAAa,uBAAsD;CACjE,SAAS;CACT,OAAO;CACP,SAAS;CACT,UAAU;CACV,UAAU;CACV,MAAM;CACN,WAAW;CACX,UAAU;CACV,OAAO;CACP,OAAO;CACP,MAAM;CACN,MAAM;CACN,QAAQ;CACR,OAAO;CACP,UAAU;CACV,QAAQ;CACR,QAAQ;CACR,KAAK;CACL,MAAM;CACN,MAAM;AACR;AAEA,MAAa,iCAAiC;AAE9C,MAAa,mBAA8C;CACzD,OAAO;CACP,QAAQ;CACR,OAAO;AACT;AACA,MAAa,sBAAsB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TableColumnInput } from "../type.mjs";
|
|
2
|
+
import { TableToken } from "../canvas/theme.mjs";
|
|
3
|
+
import "../core/cellValue.mjs";
|
|
4
|
+
import { TableI18n } from "../core/tableI18n.mjs";
|
|
5
|
+
import { ColumnsDefine } from "@visactor/vtable";
|
|
6
|
+
//#region src/Table/vtable/columns.d.ts
|
|
7
|
+
interface CompileColumnsContext {
|
|
8
|
+
editable?: boolean;
|
|
9
|
+
groupedTree?: boolean;
|
|
10
|
+
i18n?: TableI18n;
|
|
11
|
+
token?: TableToken;
|
|
12
|
+
tree?: boolean;
|
|
13
|
+
}
|
|
14
|
+
declare const compileColumns: (columns: TableColumnInput[] | undefined, ctx?: CompileColumnsContext) => ColumnsDefine | undefined;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { CompileColumnsContext, compileColumns };
|
|
17
|
+
//# sourceMappingURL=columns.d.mts.map
|