lynote-ui 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accordion/index.js +2 -2
- package/dist/accordion/index.mjs +1 -1
- package/dist/alert/index.js +2 -2
- package/dist/alert/index.mjs +1 -1
- package/dist/alert-dialog/index.js +2 -2
- package/dist/alert-dialog/index.mjs +1 -1
- package/dist/aspect-ratio/index.js +2 -2
- package/dist/aspect-ratio/index.mjs +1 -1
- package/dist/avatar/index.js +2 -2
- package/dist/avatar/index.mjs +1 -1
- package/dist/badge/index.js +2 -2
- package/dist/badge/index.mjs +1 -1
- package/dist/breadcrumb/index.js +2 -2
- package/dist/breadcrumb/index.mjs +1 -1
- package/dist/button/index.js +2 -2
- package/dist/button/index.mjs +1 -1
- package/dist/button-group/index.js +2 -2
- package/dist/button-group/index.mjs +1 -1
- package/dist/calendar/index.js +2 -2
- package/dist/calendar/index.mjs +1 -1
- package/dist/card/index.js +2 -2
- package/dist/card/index.mjs +1 -1
- package/dist/carousel/index.js +2 -2
- package/dist/carousel/index.mjs +1 -1
- package/dist/chart/index.js +2 -2
- package/dist/chart/index.mjs +1 -1
- package/dist/checkbox/index.js +2 -2
- package/dist/checkbox/index.mjs +1 -1
- package/dist/{chunk-CoQrYLCe.js → chunk-8l464Juk.js} +0 -22
- package/dist/collapsible/index.js +1 -1
- package/dist/combobox/index.js +2 -2
- package/dist/combobox/index.mjs +1 -1
- package/dist/command/index.js +2 -2
- package/dist/command/index.mjs +1 -1
- package/dist/context-menu/index.d.ts +1 -1
- package/dist/context-menu/index.js +10 -7
- package/dist/context-menu/index.js.map +1 -1
- package/dist/context-menu/index.mjs +9 -6
- package/dist/context-menu/index.mjs.map +1 -1
- package/dist/date-picker/index.js +1 -1
- package/dist/dialog/index.js +2 -2
- package/dist/dialog/index.mjs +1 -1
- package/dist/direction/index.js +1 -1
- package/dist/drawer/index.js +2 -2
- package/dist/drawer/index.mjs +1 -1
- package/dist/dropdown-menu/index.js +2 -2
- package/dist/dropdown-menu/index.mjs +1 -1
- package/dist/empty/index.js +2 -2
- package/dist/empty/index.mjs +1 -1
- package/dist/field/index.js +4 -4
- package/dist/field/index.js.map +1 -1
- package/dist/field/index.mjs +3 -3
- package/dist/field/index.mjs.map +1 -1
- package/dist/hover-card/index.js +2 -2
- package/dist/hover-card/index.mjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +35 -26
- package/dist/index.mjs +5 -9
- package/dist/input/index.js +2 -2
- package/dist/input/index.mjs +1 -1
- package/dist/input-group/index.js +2 -2
- package/dist/input-group/index.mjs +1 -1
- package/dist/input-otp/index.js +2 -2
- package/dist/input-otp/index.mjs +1 -1
- package/dist/item/index.js +2 -2
- package/dist/item/index.mjs +1 -1
- package/dist/kbd/index.js +2 -2
- package/dist/kbd/index.mjs +1 -1
- package/dist/label/index.js +2 -2
- package/dist/label/index.mjs +1 -1
- package/dist/menubar/index.js +2 -2
- package/dist/menubar/index.mjs +1 -1
- package/dist/native-select/index.js +2 -2
- package/dist/native-select/index.mjs +1 -1
- package/dist/navigation-menu/index.js +2 -2
- package/dist/navigation-menu/index.mjs +1 -1
- package/dist/pagination/index.js +2 -2
- package/dist/pagination/index.mjs +1 -1
- package/dist/popover/index.js +2 -2
- package/dist/popover/index.mjs +1 -1
- package/dist/progress/index.js +2 -2
- package/dist/progress/index.mjs +1 -1
- package/dist/radio-group/index.js +2 -2
- package/dist/radio-group/index.mjs +1 -1
- package/dist/resizable/index.js +2 -2
- package/dist/resizable/index.mjs +1 -1
- package/dist/scroll-area/index.js +2 -2
- package/dist/scroll-area/index.mjs +1 -1
- package/dist/select/SelectMultipleValue.d.ts +8 -0
- package/dist/select/context.d.ts +4 -0
- package/dist/select/index.d.ts +4 -2
- package/dist/select/index.js +11 -110
- package/dist/select/index.mjs +1 -98
- package/dist/select/type.d.ts +33 -0
- package/dist/select/utils.d.ts +8 -0
- package/dist/select---wbqUEL.js +402 -0
- package/dist/select---wbqUEL.js.map +1 -0
- package/dist/select-DJcPlxTU.mjs +341 -0
- package/dist/select-DJcPlxTU.mjs.map +1 -0
- package/dist/separator/index.js +2 -2
- package/dist/separator/index.mjs +1 -1
- package/dist/sheet/index.js +2 -2
- package/dist/sheet/index.mjs +1 -1
- package/dist/sidebar/index.js +1 -2
- package/dist/sidebar/index.mjs +1 -2
- package/dist/{sidebar-Ddt6hBj_.mjs → sidebar-BO_ns2qp.mjs} +2 -2
- package/dist/{sidebar-Ddt6hBj_.mjs.map → sidebar-BO_ns2qp.mjs.map} +1 -1
- package/dist/{sidebar-E9uledix.js → sidebar-KSjzFqo5.js} +3 -3
- package/dist/{sidebar-E9uledix.js.map → sidebar-KSjzFqo5.js.map} +1 -1
- package/dist/skeleton/index.js +2 -2
- package/dist/skeleton/index.mjs +1 -1
- package/dist/slider/index.js +2 -2
- package/dist/slider/index.mjs +1 -1
- package/dist/sonner/index.js +2 -2
- package/dist/{sonner-BbeMMXzI.js → sonner-6WfFozil.js} +2 -2
- package/dist/{sonner-BbeMMXzI.js.map → sonner-6WfFozil.js.map} +1 -1
- package/dist/spinner/index.js +2 -2
- package/dist/spinner/index.mjs +1 -1
- package/dist/style.css +768 -27
- package/dist/switch/index.js +2 -2
- package/dist/switch/index.mjs +1 -1
- package/dist/table/components/base-table.d.ts +10 -0
- package/dist/table/components/data-table-column-header.d.ts +12 -0
- package/dist/table/components/data-table-pagination.d.ts +12 -0
- package/dist/table/components/data-table-toolbar.d.ts +23 -0
- package/dist/table/components/data-table-view-options.d.ts +18 -0
- package/dist/table/components/data-table-virtual-body.d.ts +19 -0
- package/dist/table/components/data-table.d.ts +15 -0
- package/dist/table/components/row-drag-handle.d.ts +16 -0
- package/dist/table/components/row-expand-toggle.d.ts +21 -0
- package/dist/table/hooks/use-data-table.d.ts +44 -0
- package/dist/table/index.d.ts +13 -10
- package/dist/table/index.js +24 -78
- package/dist/table/index.mjs +2 -69
- package/dist/table/type.d.ts +198 -0
- package/dist/table/utils.d.ts +31 -0
- package/dist/table-BA2BijtZ.mjs +1077 -0
- package/dist/table-BA2BijtZ.mjs.map +1 -0
- package/dist/table-FocfdaF7.js +1216 -0
- package/dist/table-FocfdaF7.js.map +1 -0
- package/dist/tabs/index.js +2 -2
- package/dist/tabs/index.mjs +1 -1
- package/dist/textarea/index.js +2 -2
- package/dist/textarea/index.mjs +1 -1
- package/dist/toggle/index.js +2 -2
- package/dist/toggle/index.mjs +1 -1
- package/dist/toggle-group/index.js +2 -2
- package/dist/toggle-group/index.mjs +1 -1
- package/dist/tooltip/index.js +2 -2
- package/dist/tooltip/index.mjs +1 -1
- package/dist/typography/index.d.ts +14 -0
- package/dist/typography/index.js +120 -0
- package/dist/typography/index.js.map +1 -0
- package/dist/typography/index.mjs +105 -0
- package/dist/typography/index.mjs.map +1 -0
- package/dist/{utils-TtTqRIUX.mjs → utils-Bg4z4cXr.mjs} +1 -1
- package/dist/{utils-TtTqRIUX.mjs.map → utils-Bg4z4cXr.mjs.map} +1 -1
- package/dist/{utils-BGuEr0aP.js → utils-DrngEK1K.js} +2 -2
- package/dist/{utils-BGuEr0aP.js.map → utils-DrngEK1K.js.map} +1 -1
- package/package.json +16 -7
- package/dist/form/components/Form.d.ts +0 -4
- package/dist/form/components/FormControl.d.ts +0 -3
- package/dist/form/components/FormDescription.d.ts +0 -3
- package/dist/form/components/FormField.d.ts +0 -3
- package/dist/form/components/FormItem.d.ts +0 -7
- package/dist/form/components/FormLabel.d.ts +0 -3
- package/dist/form/components/FormMessage.d.ts +0 -4
- package/dist/form/components/variants.d.ts +0 -6
- package/dist/form/context/index.d.ts +0 -4
- package/dist/form/hooks/useFormField.d.ts +0 -14
- package/dist/form/index.d.ts +0 -11
- package/dist/form/index.js +0 -19
- package/dist/form/index.mjs +0 -3
- package/dist/form/type.d.ts +0 -48
- package/dist/form-DLd4sOko.mjs +0 -183
- package/dist/form-DLd4sOko.mjs.map +0 -1
- package/dist/form-h_cJBAwg.js +0 -205
- package/dist/form-h_cJBAwg.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/select/index.js.map +0 -1
- package/dist/select/index.mjs.map +0 -1
- package/dist/table/index.js.map +0 -1
- package/dist/table/index.mjs.map +0 -1
package/dist/switch/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
require("../chunk-
|
|
4
|
-
const require_utils = require("../utils-
|
|
3
|
+
require("../chunk-8l464Juk.js");
|
|
4
|
+
const require_utils = require("../utils-DrngEK1K.js");
|
|
5
5
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
6
|
let _base_ui_react_switch = require("@base-ui/react/switch");
|
|
7
7
|
//#region src/switch/index.tsx
|
package/dist/switch/index.mjs
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
declare function Table({ className, ...props }: React.ComponentProps<"table">): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
declare function TableHeader({ className, ...props }: React.ComponentProps<"thead">): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare function TableBody({ className, ...props }: React.ComponentProps<"tbody">): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare function TableFooter({ className, ...props }: React.ComponentProps<"tfoot">): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare function TableRow({ className, ...props }: React.ComponentProps<"tr">): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
declare function TableHead({ className, ...props }: React.ComponentProps<"th">): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
declare function TableCell({ className, ...props }: React.ComponentProps<"td">): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare function TableCaption({ className, ...props }: React.ComponentProps<"caption">): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Header } from '@tanstack/react-table';
|
|
2
|
+
import { ScrollShadowState } from '../type';
|
|
3
|
+
type DataTableColumnHeaderProps<TData> = {
|
|
4
|
+
header: Header<TData, unknown>;
|
|
5
|
+
resizable?: boolean;
|
|
6
|
+
scrollShadow: ScrollShadowState;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* 表头单元格,封装排序、列宽拖拽、固定列阴影
|
|
10
|
+
*/
|
|
11
|
+
export declare function DataTableColumnHeader<TData>({ header, resizable, scrollShadow, }: DataTableColumnHeaderProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Table as TanstackTable } from '@tanstack/react-table';
|
|
2
|
+
type DataTablePaginationProps<TData> = {
|
|
3
|
+
table: TanstackTable<TData>;
|
|
4
|
+
pageSizeOptions?: number[];
|
|
5
|
+
/** 是否显示已选择行数,默认 true */
|
|
6
|
+
showSelectionCount?: boolean;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* 表格分页栏:总行数 / 每页数量 / 页码跳转
|
|
10
|
+
*/
|
|
11
|
+
export declare function DataTablePagination<TData>({ table, pageSizeOptions, showSelectionCount, }: DataTablePaginationProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Table as TanstackTable } from '@tanstack/react-table';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
type DataTableToolbarProps<TData> = {
|
|
4
|
+
table: TanstackTable<TData>;
|
|
5
|
+
/** 绑定搜索输入框的列 id;留空则使用全局过滤 */
|
|
6
|
+
searchColumnId?: string;
|
|
7
|
+
/** 输入框 placeholder */
|
|
8
|
+
searchPlaceholder?: string;
|
|
9
|
+
/** 是否展示视图配置(列显隐),默认 true */
|
|
10
|
+
showViewOptions?: boolean;
|
|
11
|
+
/** 是否启用列拖拽 */
|
|
12
|
+
enableColumnOrdering?: boolean;
|
|
13
|
+
/** 是否启用列固定 */
|
|
14
|
+
enableColumnPinning?: boolean;
|
|
15
|
+
/** 工具栏右侧追加内容 */
|
|
16
|
+
extra?: ReactNode;
|
|
17
|
+
className?: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* 表格工具栏:搜索 + 视图配置 + 自定义扩展
|
|
21
|
+
*/
|
|
22
|
+
export declare function DataTableToolbar<TData>({ table, searchColumnId, searchPlaceholder, showViewOptions, enableColumnOrdering, enableColumnPinning, extra, className, }: DataTableToolbarProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Table as TanstackTable } from '@tanstack/react-table';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
type DataTableViewOptionsProps<TData> = {
|
|
4
|
+
table: TanstackTable<TData>;
|
|
5
|
+
/** 是否允许列拖拽排序,默认 false */
|
|
6
|
+
enableOrdering?: boolean;
|
|
7
|
+
/** 是否允许列固定操作,默认 false */
|
|
8
|
+
enablePinning?: boolean;
|
|
9
|
+
/** 触发按钮自定义,默认 "视图" */
|
|
10
|
+
trigger?: ReactElement;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* 列显隐 / 排序 / 固定 设置面板
|
|
14
|
+
*
|
|
15
|
+
* 通过 DropdownMenu 弹出列表,内置 DnD-Kit 排序与固定按钮
|
|
16
|
+
*/
|
|
17
|
+
export declare function DataTableViewOptions<TData>({ table, enableOrdering, enablePinning, trigger, }: DataTableViewOptionsProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Table as TanstackTable } from '@tanstack/react-table';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { DataTableVirtualOptions } from '../type';
|
|
4
|
+
type DataTableVirtualBodyProps<TData> = {
|
|
5
|
+
table: TanstackTable<TData>;
|
|
6
|
+
loading?: boolean;
|
|
7
|
+
empty?: ReactNode;
|
|
8
|
+
options?: DataTableVirtualOptions;
|
|
9
|
+
/** 是否显示纵向边框 */
|
|
10
|
+
bordered?: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* 行虚拟滚动表格:使用 grid 布局 + `useVirtualizer` 仅渲染可视区域
|
|
15
|
+
*
|
|
16
|
+
* 因表格采用 grid 布局,固定列 / 多级表头暂不支持
|
|
17
|
+
*/
|
|
18
|
+
export declare function DataTableVirtualBody<TData>({ table, loading, empty, options, bordered, className, }: DataTableVirtualBodyProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Table as TanstackTable } from '@tanstack/react-table';
|
|
2
|
+
import { ReactElement, RefAttributes } from 'react';
|
|
3
|
+
import { DataTablePropsType } from '../type';
|
|
4
|
+
/**
|
|
5
|
+
* DataTable 暴露给 ref 的命令式 handle —— 就是底层 TanStack table 实例
|
|
6
|
+
*
|
|
7
|
+
* 通过 `ref` 即可拿到完整的 TanStack `table` API:`setPageIndex`、`getSelectedRowModel`、
|
|
8
|
+
* `resetSorting`、`getState` 等。配合受控状态使用更顺手
|
|
9
|
+
*/
|
|
10
|
+
export type DataTableHandle<TData> = TanstackTable<TData>;
|
|
11
|
+
/**
|
|
12
|
+
* forwardRef 包装,泛型用 cast 保留 —— 否则会被 forwardRef 的签名擦除成 unknown
|
|
13
|
+
*/
|
|
14
|
+
declare const DataTable: <TData, TValue = unknown>(props: DataTablePropsType<TData, TValue> & RefAttributes<DataTableHandle<TData>>) => ReactElement | null;
|
|
15
|
+
export { DataTable };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DraggableAttributes, DraggableSyntheticListeners } from '@dnd-kit/core';
|
|
2
|
+
import { ComponentProps, Ref, Context } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* SortableRow 通过此 context 向其内部 cell 暴露 dnd-kit 的激活器/监听器
|
|
5
|
+
*
|
|
6
|
+
* 用 context 而非 prop 钻透,因为 cell 是用户自定义渲染函数,触不到 SortableRow 的局部变量
|
|
7
|
+
*/
|
|
8
|
+
export type RowDragHandleContextValue = {
|
|
9
|
+
attributes: DraggableAttributes;
|
|
10
|
+
listeners: DraggableSyntheticListeners | undefined;
|
|
11
|
+
setActivatorNodeRef: Ref<HTMLElement>;
|
|
12
|
+
isDragging: boolean;
|
|
13
|
+
} | null;
|
|
14
|
+
export declare const RowDragHandleContext: Context<RowDragHandleContextValue>;
|
|
15
|
+
/** 在 cell 内任意位置放此组件即可成为行拖拽手柄 */
|
|
16
|
+
export declare function RowDragHandle({ className, ...props }: Omit<ComponentProps<"button">, "ref" | "onMouseDown" | "onKeyDown" | "onTouchStart">): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Row } from '@tanstack/react-table';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
|
+
type RowExpandTogglePropsType<TData> = Omit<ComponentProps<"button">, "onClick" | "children"> & {
|
|
4
|
+
/** 当前行实例 */
|
|
5
|
+
row: Row<TData>;
|
|
6
|
+
/**
|
|
7
|
+
* 嵌套树场景下,每层缩进的像素数;设为 0 关闭自动缩进
|
|
8
|
+
*
|
|
9
|
+
* 默认 16,即每深一层缩进 16px
|
|
10
|
+
*/
|
|
11
|
+
indent?: number;
|
|
12
|
+
/** 当行无可展开子项时是否仍占位渲染(保持对齐),默认 true */
|
|
13
|
+
placeholder?: boolean;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* 行展开切换按钮:基于 `row.getToggleExpandedHandler` + `row.depth` 自动缩进
|
|
17
|
+
*
|
|
18
|
+
* 配合 `features.expanding` 与 `tableOptions.getSubRows`(嵌套树),或 `expandedRowRender`(展开面板)使用
|
|
19
|
+
*/
|
|
20
|
+
export declare function RowExpandToggle<TData>({ row, indent, placeholder, className, ...props }: RowExpandTogglePropsType<TData>): import("react/jsx-runtime").JSX.Element | null;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { TableOptions, Table } from '@tanstack/react-table';
|
|
2
|
+
import { DataTableColumn, DataTableFeatures, DataTableState, DataTableStateHandlers, ScrollShadowState } from '../type';
|
|
3
|
+
type UseDataTableOptions<TData, TValue> = {
|
|
4
|
+
data: TData[];
|
|
5
|
+
columns: DataTableColumn<TData, TValue>[];
|
|
6
|
+
features?: DataTableFeatures;
|
|
7
|
+
state?: DataTableState;
|
|
8
|
+
initialState?: DataTableState;
|
|
9
|
+
onStateChange?: DataTableStateHandlers;
|
|
10
|
+
/**
|
|
11
|
+
* 透传至底层 useReactTable 的额外配置,会与内部配置浅合并
|
|
12
|
+
*
|
|
13
|
+
* 常用于服务端模式:`manualPagination` / `pageCount` / `rowCount` /
|
|
14
|
+
* `manualSorting` / `manualFiltering`,以及 `meta` 等
|
|
15
|
+
*/
|
|
16
|
+
tableOptions?: Partial<TableOptions<TData>>;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* 构造 TanStack 表格实例,并按需开启各项功能
|
|
20
|
+
*/
|
|
21
|
+
export declare function useDataTable<TData, TValue = unknown>({ data, columns, features, state, initialState, onStateChange, tableOptions, }: UseDataTableOptions<TData, TValue>): {
|
|
22
|
+
table: Table<TData>;
|
|
23
|
+
features: {
|
|
24
|
+
sorting: boolean;
|
|
25
|
+
multiSort: boolean;
|
|
26
|
+
filtering: boolean;
|
|
27
|
+
globalFilter: boolean;
|
|
28
|
+
pagination: boolean;
|
|
29
|
+
rowSelection: boolean;
|
|
30
|
+
columnVisibility: boolean;
|
|
31
|
+
columnOrdering: boolean;
|
|
32
|
+
columnPinning: boolean;
|
|
33
|
+
columnResizing: boolean;
|
|
34
|
+
rowDnd: boolean;
|
|
35
|
+
expanding: boolean;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* 监听容器横向滚动,返回左右阴影显示状态
|
|
40
|
+
*
|
|
41
|
+
* 用于固定列阴影提示
|
|
42
|
+
*/
|
|
43
|
+
export declare function useScrollShadow(wrapperRef: React.RefObject<HTMLElement | null>, containerSelector?: string): ScrollShadowState;
|
|
44
|
+
export {};
|
package/dist/table/index.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export {
|
|
1
|
+
export * from './components/base-table';
|
|
2
|
+
export { DataTable, type DataTableHandle } from './components/data-table';
|
|
3
|
+
export { DataTableColumnHeader } from './components/data-table-column-header';
|
|
4
|
+
export { DataTablePagination } from './components/data-table-pagination';
|
|
5
|
+
export { DataTableToolbar } from './components/data-table-toolbar';
|
|
6
|
+
export { DataTableViewOptions } from './components/data-table-view-options';
|
|
7
|
+
export { DataTableVirtualBody } from './components/data-table-virtual-body';
|
|
8
|
+
export { RowDragHandle, RowDragHandleContext, type RowDragHandleContextValue, } from './components/row-drag-handle';
|
|
9
|
+
export { RowExpandToggle } from './components/row-expand-toggle';
|
|
10
|
+
export { useDataTable, useScrollShadow } from './hooks/use-data-table';
|
|
11
|
+
export type { AnyColumn, CellMergeMeta, ColSpanContext, DataTableColumn, DataTableFeatures, DataTablePropsType, DataTableState, DataTableStateHandlers, DataTableVirtualOptions, RowOrderChangeInfo, RowSpanContext, ScrollShadowState, } from './type';
|
|
12
|
+
export { computeCellSpans, getColumnPinningClassName, getCommonPinningStyles, panelIdFor, } from './utils';
|
|
13
|
+
export type { CellSpan, CellSpanMap } from './utils';
|
package/dist/table/index.js
CHANGED
|
@@ -1,79 +1,25 @@
|
|
|
1
|
-
"use client";
|
|
2
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
function TableBody({ className, ...props }) {
|
|
28
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", {
|
|
29
|
-
"data-slot": "table-body",
|
|
30
|
-
className: require_utils.cn("[&_tr:last-child]:border-0", className),
|
|
31
|
-
...props
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
function TableFooter({ className, ...props }) {
|
|
35
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tfoot", {
|
|
36
|
-
"data-slot": "table-footer",
|
|
37
|
-
className: require_utils.cn("bg-muted/50 border-t font-medium [&>tr]:last:border-b-0", className),
|
|
38
|
-
...props
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
function TableRow({ className, ...props }) {
|
|
42
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", {
|
|
43
|
-
"data-slot": "table-row",
|
|
44
|
-
className: require_utils.cn("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors", className),
|
|
45
|
-
...props
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
function TableHead({ className, ...props }) {
|
|
49
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
50
|
-
"data-slot": "table-head",
|
|
51
|
-
className: require_utils.cn("text-foreground h-10 whitespace-nowrap px-2 text-left align-middle font-medium [&:has([role=checkbox])]:pr-0", className),
|
|
52
|
-
...props
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
function TableCell({ className, ...props }) {
|
|
56
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
57
|
-
"data-slot": "table-cell",
|
|
58
|
-
className: require_utils.cn("whitespace-nowrap p-2 align-middle [&:has([role=checkbox])]:pr-0", className),
|
|
59
|
-
...props
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
function TableCaption({ className, ...props }) {
|
|
63
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("caption", {
|
|
64
|
-
"data-slot": "table-caption",
|
|
65
|
-
className: require_utils.cn("text-muted-foreground mt-4 text-sm", className),
|
|
66
|
-
...props
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
//#endregion
|
|
70
|
-
exports.Table = Table;
|
|
71
|
-
exports.TableBody = TableBody;
|
|
72
|
-
exports.TableCaption = TableCaption;
|
|
73
|
-
exports.TableCell = TableCell;
|
|
74
|
-
exports.TableFooter = TableFooter;
|
|
75
|
-
exports.TableHead = TableHead;
|
|
76
|
-
exports.TableHeader = TableHeader;
|
|
77
|
-
exports.TableRow = TableRow;
|
|
78
|
-
|
|
79
|
-
//# sourceMappingURL=index.js.map
|
|
2
|
+
const require_table = require("../table-FocfdaF7.js");
|
|
3
|
+
exports.DataTable = require_table.DataTable;
|
|
4
|
+
exports.DataTableColumnHeader = require_table.DataTableColumnHeader;
|
|
5
|
+
exports.DataTablePagination = require_table.DataTablePagination;
|
|
6
|
+
exports.DataTableToolbar = require_table.DataTableToolbar;
|
|
7
|
+
exports.DataTableViewOptions = require_table.DataTableViewOptions;
|
|
8
|
+
exports.DataTableVirtualBody = require_table.DataTableVirtualBody;
|
|
9
|
+
exports.RowDragHandle = require_table.RowDragHandle;
|
|
10
|
+
exports.RowDragHandleContext = require_table.RowDragHandleContext;
|
|
11
|
+
exports.RowExpandToggle = require_table.RowExpandToggle;
|
|
12
|
+
exports.Table = require_table.Table;
|
|
13
|
+
exports.TableBody = require_table.TableBody;
|
|
14
|
+
exports.TableCaption = require_table.TableCaption;
|
|
15
|
+
exports.TableCell = require_table.TableCell;
|
|
16
|
+
exports.TableFooter = require_table.TableFooter;
|
|
17
|
+
exports.TableHead = require_table.TableHead;
|
|
18
|
+
exports.TableHeader = require_table.TableHeader;
|
|
19
|
+
exports.TableRow = require_table.TableRow;
|
|
20
|
+
exports.computeCellSpans = require_table.computeCellSpans;
|
|
21
|
+
exports.getColumnPinningClassName = require_table.getColumnPinningClassName;
|
|
22
|
+
exports.getCommonPinningStyles = require_table.getCommonPinningStyles;
|
|
23
|
+
exports.panelIdFor = require_table.panelIdFor;
|
|
24
|
+
exports.useDataTable = require_table.useDataTable;
|
|
25
|
+
exports.useScrollShadow = require_table.useScrollShadow;
|
package/dist/table/index.mjs
CHANGED
|
@@ -1,69 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
import "react";
|
|
5
|
-
//#region src/table/index.tsx
|
|
6
|
-
function Table({ className, ...props }) {
|
|
7
|
-
return /* @__PURE__ */ jsx("div", {
|
|
8
|
-
"data-slot": "table-container",
|
|
9
|
-
className: "relative w-full overflow-x-auto",
|
|
10
|
-
children: /* @__PURE__ */ jsx("table", {
|
|
11
|
-
"data-slot": "table",
|
|
12
|
-
className: cn("w-full caption-bottom text-sm", className),
|
|
13
|
-
...props
|
|
14
|
-
})
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
function TableHeader({ className, ...props }) {
|
|
18
|
-
return /* @__PURE__ */ jsx("thead", {
|
|
19
|
-
"data-slot": "table-header",
|
|
20
|
-
className: cn("[&_tr]:border-b", className),
|
|
21
|
-
...props
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
function TableBody({ className, ...props }) {
|
|
25
|
-
return /* @__PURE__ */ jsx("tbody", {
|
|
26
|
-
"data-slot": "table-body",
|
|
27
|
-
className: cn("[&_tr:last-child]:border-0", className),
|
|
28
|
-
...props
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
function TableFooter({ className, ...props }) {
|
|
32
|
-
return /* @__PURE__ */ jsx("tfoot", {
|
|
33
|
-
"data-slot": "table-footer",
|
|
34
|
-
className: cn("bg-muted/50 border-t font-medium [&>tr]:last:border-b-0", className),
|
|
35
|
-
...props
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
function TableRow({ className, ...props }) {
|
|
39
|
-
return /* @__PURE__ */ jsx("tr", {
|
|
40
|
-
"data-slot": "table-row",
|
|
41
|
-
className: cn("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors", className),
|
|
42
|
-
...props
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
function TableHead({ className, ...props }) {
|
|
46
|
-
return /* @__PURE__ */ jsx("th", {
|
|
47
|
-
"data-slot": "table-head",
|
|
48
|
-
className: cn("text-foreground h-10 whitespace-nowrap px-2 text-left align-middle font-medium [&:has([role=checkbox])]:pr-0", className),
|
|
49
|
-
...props
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
function TableCell({ className, ...props }) {
|
|
53
|
-
return /* @__PURE__ */ jsx("td", {
|
|
54
|
-
"data-slot": "table-cell",
|
|
55
|
-
className: cn("whitespace-nowrap p-2 align-middle [&:has([role=checkbox])]:pr-0", className),
|
|
56
|
-
...props
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
function TableCaption({ className, ...props }) {
|
|
60
|
-
return /* @__PURE__ */ jsx("caption", {
|
|
61
|
-
"data-slot": "table-caption",
|
|
62
|
-
className: cn("text-muted-foreground mt-4 text-sm", className),
|
|
63
|
-
...props
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
//#endregion
|
|
67
|
-
export { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow };
|
|
68
|
-
|
|
69
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
import { C as TableRow, S as TableHeader, _ as TableBody, a as RowDragHandle, b as TableFooter, c as DataTablePagination, d as getColumnPinningClassName, f as getCommonPinningStyles, g as Table, h as useScrollShadow, i as DataTable, l as DataTableColumnHeader, m as useDataTable, n as DataTableToolbar, o as RowDragHandleContext, p as panelIdFor, r as DataTableViewOptions, s as DataTableVirtualBody, t as RowExpandToggle, u as computeCellSpans, v as TableCaption, x as TableHead, y as TableCell } from "../table-BA2BijtZ.mjs";
|
|
2
|
+
export { DataTable, DataTableColumnHeader, DataTablePagination, DataTableToolbar, DataTableViewOptions, DataTableVirtualBody, RowDragHandle, RowDragHandleContext, RowExpandToggle, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, computeCellSpans, getColumnPinningClassName, getCommonPinningStyles, panelIdFor, useDataTable, useScrollShadow };
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { Column, ColumnDef, ColumnFiltersState, ColumnOrderState, ColumnPinningState, ExpandedState, PaginationState, Row, RowData, RowSelectionState, SortingState, TableOptions, Table as TanstackTable, VisibilityState } from '@tanstack/react-table';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
/** 行合并回调上下文 */
|
|
4
|
+
export type RowSpanContext<TData> = {
|
|
5
|
+
row: Row<TData>;
|
|
6
|
+
rows: Row<TData>[];
|
|
7
|
+
rowIndex: number;
|
|
8
|
+
value: unknown;
|
|
9
|
+
};
|
|
10
|
+
/** 列合并回调上下文 */
|
|
11
|
+
export type ColSpanContext<TData> = {
|
|
12
|
+
row: Row<TData>;
|
|
13
|
+
rows: Row<TData>[];
|
|
14
|
+
rowIndex: number;
|
|
15
|
+
column: Column<TData, unknown>;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* 通过 `column.meta` 在 DataTable 中描述单元格合并行为
|
|
19
|
+
*
|
|
20
|
+
* - `rowSpan: true`(等同 `"auto"`):自动合并连续相同值
|
|
21
|
+
* - `rowSpan: (ctx) => number`:返回 rowSpan,`0` 表示该格不渲染
|
|
22
|
+
* - `rowSpanParent`:仅当父字段同时相同才允许合并(如 city 在同 region 下才合并)
|
|
23
|
+
* - `colSpan: (ctx) => number`:返回 colSpan,`0` 表示该格不渲染
|
|
24
|
+
*/
|
|
25
|
+
export type CellMergeMeta<TData = RowData> = {
|
|
26
|
+
rowSpan?: true | "auto" | ((ctx: RowSpanContext<TData>) => number);
|
|
27
|
+
rowSpanParent?: string;
|
|
28
|
+
colSpan?: (ctx: ColSpanContext<TData>) => number;
|
|
29
|
+
};
|
|
30
|
+
declare module "@tanstack/react-table" {
|
|
31
|
+
interface ColumnMeta<TData extends RowData, TValue> extends CellMergeMeta<TData> {
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* 表格容器横向滚动阴影状态
|
|
36
|
+
*/
|
|
37
|
+
export type ScrollShadowState = {
|
|
38
|
+
left: boolean;
|
|
39
|
+
right: boolean;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* 列配置,扩展 TanStack ColumnDef
|
|
43
|
+
*/
|
|
44
|
+
export type DataTableColumn<TData, TValue = unknown> = ColumnDef<TData, TValue>;
|
|
45
|
+
/**
|
|
46
|
+
* 受控状态,所有字段均可选
|
|
47
|
+
*/
|
|
48
|
+
export type DataTableState = {
|
|
49
|
+
sorting?: SortingState;
|
|
50
|
+
columnFilters?: ColumnFiltersState;
|
|
51
|
+
columnVisibility?: VisibilityState;
|
|
52
|
+
columnOrder?: ColumnOrderState;
|
|
53
|
+
columnPinning?: ColumnPinningState;
|
|
54
|
+
rowSelection?: RowSelectionState;
|
|
55
|
+
pagination?: PaginationState;
|
|
56
|
+
globalFilter?: string;
|
|
57
|
+
expanded?: ExpandedState;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* 状态变更回调集合
|
|
61
|
+
*/
|
|
62
|
+
export type DataTableStateHandlers = {
|
|
63
|
+
onSortingChange?: (state: SortingState) => void;
|
|
64
|
+
onColumnFiltersChange?: (state: ColumnFiltersState) => void;
|
|
65
|
+
onColumnVisibilityChange?: (state: VisibilityState) => void;
|
|
66
|
+
onColumnOrderChange?: (state: ColumnOrderState) => void;
|
|
67
|
+
onColumnPinningChange?: (state: ColumnPinningState) => void;
|
|
68
|
+
onRowSelectionChange?: (state: RowSelectionState) => void;
|
|
69
|
+
onPaginationChange?: (state: PaginationState) => void;
|
|
70
|
+
onGlobalFilterChange?: (state: string) => void;
|
|
71
|
+
onExpandedChange?: (state: ExpandedState) => void;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* 各能力开关 + 初始值
|
|
75
|
+
*/
|
|
76
|
+
export type DataTableFeatures = {
|
|
77
|
+
/** 是否启用排序,默认 true */
|
|
78
|
+
sorting?: boolean;
|
|
79
|
+
/** 是否启用多列同时排序,默认 false */
|
|
80
|
+
multiSort?: boolean;
|
|
81
|
+
/** 是否启用列筛选,默认 true */
|
|
82
|
+
filtering?: boolean;
|
|
83
|
+
/** 是否启用全局搜索,默认 false */
|
|
84
|
+
globalFilter?: boolean;
|
|
85
|
+
/** 是否启用分页,默认 true */
|
|
86
|
+
pagination?: boolean;
|
|
87
|
+
/** 是否启用行选择(多选),默认 false */
|
|
88
|
+
rowSelection?: boolean;
|
|
89
|
+
/** 是否启用列显隐控制,默认 true */
|
|
90
|
+
columnVisibility?: boolean;
|
|
91
|
+
/** 是否启用列拖拽排序,默认 false */
|
|
92
|
+
columnOrdering?: boolean;
|
|
93
|
+
/** 是否启用列固定(冻结),默认 false */
|
|
94
|
+
columnPinning?: boolean;
|
|
95
|
+
/** 是否启用列宽调整,默认 false */
|
|
96
|
+
columnResizing?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* 是否启用行拖拽排序,默认 false
|
|
99
|
+
*
|
|
100
|
+
* 开启后会在最左侧自动插入一列拖拽手柄;也可手动在自己的 cell 里放 `<RowDragHandle />`。
|
|
101
|
+
* 需要传 `tableOptions.getRowId` 提供稳定的行标识,并在 `onRowOrderChange` 中接住新顺序。
|
|
102
|
+
* 与 `virtual` 不兼容
|
|
103
|
+
*/
|
|
104
|
+
rowDnd?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* 是否启用行展开,默认 false
|
|
107
|
+
*
|
|
108
|
+
* 嵌套树:在 `tableOptions.getSubRows` 中返回子行,即可在 cell 里用 `<RowExpandToggle row={row} />` 展开。
|
|
109
|
+
* 展开面板:传 `expandedRowRender` 在每行下方渲染自定义面板。
|
|
110
|
+
* 开启 `virtual` 时会被自动忽略
|
|
111
|
+
*/
|
|
112
|
+
expanding?: boolean;
|
|
113
|
+
};
|
|
114
|
+
/** 行拖拽完成后的回调 */
|
|
115
|
+
export type RowOrderChangeInfo = {
|
|
116
|
+
oldIndex: number;
|
|
117
|
+
newIndex: number;
|
|
118
|
+
activeId: string;
|
|
119
|
+
overId: string;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* 行虚拟滚动配置
|
|
123
|
+
*/
|
|
124
|
+
export type DataTableVirtualOptions = {
|
|
125
|
+
/** 估计的行高(px),默认 36 */
|
|
126
|
+
estimateRowHeight?: number;
|
|
127
|
+
/** 滚动容器高度,默认 480 */
|
|
128
|
+
maxHeight?: number | string;
|
|
129
|
+
/** 视口外预渲染行数,默认 10 */
|
|
130
|
+
overscan?: number;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* DataTable 顶层属性
|
|
134
|
+
*/
|
|
135
|
+
export type DataTablePropsType<TData, TValue = unknown> = {
|
|
136
|
+
/** 列定义 */
|
|
137
|
+
columns: DataTableColumn<TData, TValue>[];
|
|
138
|
+
/** 数据源 */
|
|
139
|
+
data: TData[];
|
|
140
|
+
/** 加载状态,显示占位条 */
|
|
141
|
+
loading?: boolean;
|
|
142
|
+
/** 受控状态 */
|
|
143
|
+
state?: DataTableState;
|
|
144
|
+
/** 初始状态(非受控) */
|
|
145
|
+
initialState?: DataTableState;
|
|
146
|
+
/** 状态变更回调 */
|
|
147
|
+
onStateChange?: DataTableStateHandlers;
|
|
148
|
+
/** 功能开关 */
|
|
149
|
+
features?: DataTableFeatures;
|
|
150
|
+
/**
|
|
151
|
+
* 工具栏渲染函数,接收 table 实例;不传则不渲染工具栏
|
|
152
|
+
*
|
|
153
|
+
* 搜索 / 视图设置等控件请在此函数中用 `DataTableToolbar` / `DataTableViewOptions` 自由组合
|
|
154
|
+
*/
|
|
155
|
+
renderToolbar?: (table: TanstackTable<TData>) => ReactNode;
|
|
156
|
+
/** 自定义分页区域 */
|
|
157
|
+
renderPagination?: (table: TanstackTable<TData>) => ReactNode;
|
|
158
|
+
/** 空状态文本或节点 */
|
|
159
|
+
empty?: ReactNode;
|
|
160
|
+
/** 每页可选数量,默认 [10, 20, 30, 50, 100] */
|
|
161
|
+
pageSizeOptions?: number[];
|
|
162
|
+
/** 外层 className */
|
|
163
|
+
className?: string;
|
|
164
|
+
/** 表格容器 className */
|
|
165
|
+
tableClassName?: string;
|
|
166
|
+
/** 是否显示纵向边框(单元格分隔线),默认 `false` */
|
|
167
|
+
bordered?: boolean;
|
|
168
|
+
/** 行点击回调 */
|
|
169
|
+
onRowClick?: (row: TData) => void;
|
|
170
|
+
/** 行拖拽完成后回调,接收重排后的完整数据 */
|
|
171
|
+
onRowOrderChange?: (nextData: TData[], info: RowOrderChangeInfo) => void;
|
|
172
|
+
/**
|
|
173
|
+
* 自定义展开面板渲染;返回任意节点会在该行下方渲染一行,跨满所有列
|
|
174
|
+
*
|
|
175
|
+
* - 需要将 `features.expanding` 设为 true 才会生效
|
|
176
|
+
* - 未自定义 `tableOptions.getRowCanExpand` 时会自动注入 `() => true`,所有行均可展开
|
|
177
|
+
* - 开启 `virtual` 时会被自动忽略
|
|
178
|
+
*/
|
|
179
|
+
expandedRowRender?: (row: Row<TData>) => ReactNode;
|
|
180
|
+
/**
|
|
181
|
+
* 行 DnD 拖拽手柄安放方式,默认 `"auto"` 自动在最左侧追加一列
|
|
182
|
+
*
|
|
183
|
+
* 设为 `"manual"` 则不追加,需要用户在自己的列里放 `<RowDragHandle />`
|
|
184
|
+
*/
|
|
185
|
+
rowDndHandle?: "auto" | "manual";
|
|
186
|
+
/** 透传至底层 useReactTable 的额外配置(服务端模式 / meta 等) */
|
|
187
|
+
tableOptions?: Partial<TableOptions<TData>>;
|
|
188
|
+
/**
|
|
189
|
+
* 行虚拟滚动:`true` 启用默认配置;传对象自定义
|
|
190
|
+
*
|
|
191
|
+
* 开启后会自动关闭分页;列固定与多级表头暂不兼容
|
|
192
|
+
*/
|
|
193
|
+
virtual?: boolean | DataTableVirtualOptions;
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* 列固定 / 拖拽辅助类型
|
|
197
|
+
*/
|
|
198
|
+
export type AnyColumn<TData> = Column<TData, unknown>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Row } from '@tanstack/react-table';
|
|
2
|
+
import { CSSProperties } from 'react';
|
|
3
|
+
import { AnyColumn, ScrollShadowState } from './type';
|
|
4
|
+
/**
|
|
5
|
+
* 展开面板 row 的 DOM id 协议
|
|
6
|
+
*
|
|
7
|
+
* `DataTable` 渲染面板 row 时把这个 id 设到 `<tr id>` 上,
|
|
8
|
+
* `RowExpandToggle` 把它写进按钮的 `aria-controls`,二者必须保持一致
|
|
9
|
+
*/
|
|
10
|
+
export declare const panelIdFor: (rowId: string) => string;
|
|
11
|
+
/**
|
|
12
|
+
* 计算固定列(sticky)需要的样式
|
|
13
|
+
*/
|
|
14
|
+
export declare function getCommonPinningStyles<TData>(column: AnyColumn<TData>): CSSProperties;
|
|
15
|
+
/**
|
|
16
|
+
* 计算固定列阴影 className
|
|
17
|
+
*/
|
|
18
|
+
export declare function getColumnPinningClassName<TData>(column: AnyColumn<TData>, scrollShadow: ScrollShadowState): string;
|
|
19
|
+
/** 单元格合并跨度 */
|
|
20
|
+
export type CellSpan = {
|
|
21
|
+
rowSpan: number;
|
|
22
|
+
colSpan: number;
|
|
23
|
+
};
|
|
24
|
+
/** 内部存储:每行每列对应的跨度 */
|
|
25
|
+
export type CellSpanMap = Map<number, Map<string, CellSpan>>;
|
|
26
|
+
/**
|
|
27
|
+
* 根据每列 `meta.rowSpan` / `meta.colSpan` 计算每行每列的合并跨度
|
|
28
|
+
*
|
|
29
|
+
* `0` 表示该单元格不应渲染(被合并掉了)
|
|
30
|
+
*/
|
|
31
|
+
export declare function computeCellSpans<TData>(rows: Row<TData>[], columns: AnyColumn<TData>[]): CellSpanMap;
|