@are-visual/virtual-table 0.10.2 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -10
- package/index.d.ts +12 -6
- package/index.esm.js +249 -301
- package/index.esm.js.map +1 -1
- package/middleware/column-resize/index.d.ts +2 -0
- package/middleware/column-resize/index.js +6 -6
- package/middleware/column-resize/index.js.map +1 -1
- package/middleware/expandable/index.d.ts +1 -1
- package/middleware/expandable/index.js.map +1 -1
- package/middleware/horizontal-scroll-bar/index.js +3 -26
- package/middleware/horizontal-scroll-bar/index.js.map +1 -1
- package/middleware/selection/index.d.ts +1 -1
- package/middleware/summary/index.d.ts +1 -0
- package/middleware/summary/index.js +13 -29
- package/middleware/summary/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { createMiddleware, getKey } from '@are-visual/virtual-table';
|
|
2
|
+
import { createMiddleware, getKey, getColumnWidth } from '@are-visual/virtual-table';
|
|
3
3
|
import { useState, useCallback, isValidElement, useMemo } from 'react';
|
|
4
4
|
import { Resizable } from 'react-resizable';
|
|
5
5
|
|
|
@@ -53,7 +53,8 @@ function useColumnResize(ctx, args) {
|
|
|
53
53
|
max
|
|
54
54
|
} = args ?? {};
|
|
55
55
|
const {
|
|
56
|
-
columns: rawColumns
|
|
56
|
+
columns: rawColumns,
|
|
57
|
+
instance
|
|
57
58
|
} = ctx;
|
|
58
59
|
const [columnWidths, setColumnWidths] = useState(() => {
|
|
59
60
|
if (storageKey == null) {
|
|
@@ -75,14 +76,13 @@ function useColumnResize(ctx, args) {
|
|
|
75
76
|
}, [storageKey]);
|
|
76
77
|
const renderHeaderCell = useCallback((children, options) => {
|
|
77
78
|
const {
|
|
78
|
-
column
|
|
79
|
-
columnWidths
|
|
79
|
+
column
|
|
80
80
|
} = options;
|
|
81
81
|
if (column.disableResize) {
|
|
82
82
|
return children;
|
|
83
83
|
}
|
|
84
84
|
const key = getKey(column);
|
|
85
|
-
const width =
|
|
85
|
+
const width = getColumnWidth(column, instance.getCurrentProps().defaultColumnWidth);
|
|
86
86
|
if (process.env.NODE_ENV === 'development') {
|
|
87
87
|
if (/*#__PURE__*/isValidElement(children) && children.type === Resizable) {
|
|
88
88
|
throw new Error('The columnResize plugin was registered multiple times.');
|
|
@@ -104,7 +104,7 @@ function useColumnResize(ctx, args) {
|
|
|
104
104
|
},
|
|
105
105
|
children: children
|
|
106
106
|
});
|
|
107
|
-
}, [handleResize, max, min]);
|
|
107
|
+
}, [handleResize, instance, max, min]);
|
|
108
108
|
const columns = useMemo(() => {
|
|
109
109
|
return rawColumns.map(column => {
|
|
110
110
|
const key = getKey(column).toString();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../packages/virtual-table/src/middleware/column-resize/index.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { ColumnType, MiddlewareContext, MiddlewareRenderHeaderCell, MiddlewareResult } from '@are-visual/virtual-table'\nimport type { Key } from 'react'\nimport { createMiddleware, getKey } from '@are-visual/virtual-table'\nimport { isValidElement, useCallback, useMemo, useState } from 'react'\nimport { Resizable } from 'react-resizable'\n\ndeclare module '@are-visual/virtual-table' {\n interface ColumnExtra {\n disableResize?: boolean\n /** Resize 时限制最大列宽 */\n maxWidth?: number\n }\n}\n\ntype Constraint<T> = number | ((column: ColumnType<T>) => (number | undefined | null))\n\nexport interface ResizeOptions<T = any> {\n storageKey: string\n min?: Constraint<T>\n max?: Constraint<T>\n}\n\nfunction isObject(obj: unknown): obj is Record<string, unknown> {\n return typeof obj === 'object' && obj != null\n}\n\nfunction getValue<T, Args>(maybeValue: T | ((args: Args) => T), args: Args): T {\n if (typeof maybeValue === 'function') {\n return (maybeValue as (args: Args) => T)(args)\n }\n return maybeValue\n}\n\nfunction getConstraintValue<T>(\n constraint: Constraint<T> | undefined,\n column: ColumnType<T>,\n): [width: number, height: number] | undefined {\n if (constraint == null) return undefined\n const result = getValue(constraint, column)\n if (result == null) {\n return undefined\n }\n return [result, 0]\n}\n\nconst resizeStorage = {\n key(storageKey: string) {\n return `${storageKey}_resize`\n },\n get(storageKey: string): Record<string, number> {\n try {\n const raw = window.localStorage.getItem(resizeStorage.key(storageKey)) ?? '{}'\n const result = JSON.parse(raw)\n if (isObject(result)) {\n Object.entries(result).forEach(([k, v]) => {\n if (!Number.isFinite(v)) {\n delete result[k]\n }\n })\n return result as Record<string, number>\n }\n return {}\n } catch (_err) {\n return {}\n }\n },\n set(storageKey: string, value: Record<string, number>) {\n window.localStorage.setItem(resizeStorage.key(storageKey), JSON.stringify(value))\n },\n}\n\nfunction useColumnResize<T = any>(\n ctx: MiddlewareContext<T>,\n args?: ResizeOptions<T>,\n): MiddlewareResult<T> {\n const { storageKey, min, max } = args ?? {}\n const { columns: rawColumns } = ctx\n const [columnWidths, setColumnWidths] = useState<Record<string, number>>(() => {\n if (storageKey == null) {\n return {}\n }\n return resizeStorage.get(storageKey)\n })\n\n const handleResize = useCallback((columnKey: Key, newWidth: number) => {\n setColumnWidths((prevState) => {\n const result = {\n ...prevState,\n [`${columnKey}`]: newWidth,\n }\n if (storageKey != null) {\n resizeStorage.set(storageKey, result)\n }\n return result\n })\n }, [storageKey])\n\n const renderHeaderCell: MiddlewareRenderHeaderCell<T> = useCallback((children, options) => {\n const { column
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../packages/virtual-table/src/middleware/column-resize/index.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { ColumnType, MiddlewareContext, MiddlewareRenderHeaderCell, MiddlewareResult } from '@are-visual/virtual-table'\nimport type { Key } from 'react'\nimport { createMiddleware, getColumnWidth, getKey } from '@are-visual/virtual-table'\nimport { isValidElement, useCallback, useMemo, useState } from 'react'\nimport { Resizable } from 'react-resizable'\n\ndeclare module '@are-visual/virtual-table' {\n interface ColumnExtra {\n disableResize?: boolean\n /** Resize 时限制最小列宽 */\n minWidth?: number\n /** Resize 时限制最大列宽 */\n maxWidth?: number\n }\n}\n\ntype Constraint<T> = number | ((column: ColumnType<T>) => (number | undefined | null))\n\nexport interface ResizeOptions<T = any> {\n storageKey: string\n min?: Constraint<T>\n max?: Constraint<T>\n}\n\nfunction isObject(obj: unknown): obj is Record<string, unknown> {\n return typeof obj === 'object' && obj != null\n}\n\nfunction getValue<T, Args>(maybeValue: T | ((args: Args) => T), args: Args): T {\n if (typeof maybeValue === 'function') {\n return (maybeValue as (args: Args) => T)(args)\n }\n return maybeValue\n}\n\nfunction getConstraintValue<T>(\n constraint: Constraint<T> | undefined,\n column: ColumnType<T>,\n): [width: number, height: number] | undefined {\n if (constraint == null) return undefined\n const result = getValue(constraint, column)\n if (result == null) {\n return undefined\n }\n return [result, 0]\n}\n\nconst resizeStorage = {\n key(storageKey: string) {\n return `${storageKey}_resize`\n },\n get(storageKey: string): Record<string, number> {\n try {\n const raw = window.localStorage.getItem(resizeStorage.key(storageKey)) ?? '{}'\n const result: unknown = JSON.parse(raw)\n if (isObject(result)) {\n Object.entries(result).forEach(([k, v]) => {\n if (!Number.isFinite(v)) {\n delete result[k]\n }\n })\n return result as Record<string, number>\n }\n return {}\n } catch (_err) {\n return {}\n }\n },\n set(storageKey: string, value: Record<string, number>) {\n window.localStorage.setItem(resizeStorage.key(storageKey), JSON.stringify(value))\n },\n}\n\nfunction useColumnResize<T = any>(\n ctx: MiddlewareContext<T>,\n args?: ResizeOptions<T>,\n): MiddlewareResult<T> {\n const { storageKey, min, max } = args ?? {}\n const { columns: rawColumns, instance } = ctx\n const [columnWidths, setColumnWidths] = useState<Record<string, number>>(() => {\n if (storageKey == null) {\n return {}\n }\n return resizeStorage.get(storageKey)\n })\n\n const handleResize = useCallback((columnKey: Key, newWidth: number) => {\n setColumnWidths((prevState) => {\n const result = {\n ...prevState,\n [`${columnKey}`]: newWidth,\n }\n if (storageKey != null) {\n resizeStorage.set(storageKey, result)\n }\n return result\n })\n }, [storageKey])\n\n const renderHeaderCell: MiddlewareRenderHeaderCell<T> = useCallback((children, options) => {\n const { column } = options\n\n if (column.disableResize) {\n return children\n }\n\n const key = getKey(column)\n const width = getColumnWidth(column, instance.getCurrentProps().defaultColumnWidth)\n\n if (__DEV__) {\n if (isValidElement(children) && children.type === Resizable) {\n throw new Error('The columnResize plugin was registered multiple times.')\n }\n }\n\n return (\n <Resizable\n width={width}\n axis=\"x\"\n minConstraints={getConstraintValue(column.minWidth ?? min, column)}\n maxConstraints={getConstraintValue(column.maxWidth ?? max, column)}\n handle={(\n <div className=\"virtual-table-column-resize-handle\" />\n )}\n onResize={(_e, { size }) => {\n handleResize(key, size.width)\n }}\n >\n {children}\n </Resizable>\n )\n }, [handleResize, instance, max, min])\n\n const columns = useMemo(() => {\n return rawColumns.map((column) => {\n const key = getKey(column).toString()\n const width = columnWidths[key] as number | undefined\n if (width != null && width !== column.width) {\n return { ...column, width }\n }\n return column\n })\n }, [columnWidths, rawColumns])\n\n return { ...ctx, columns, renderHeaderCell }\n}\n\nexport const columnResize = createMiddleware(useColumnResize)\n"],"names":["isObject","obj","getValue","maybeValue","args","getConstraintValue","constraint","column","undefined","result","resizeStorage","key","storageKey","get","raw","window","localStorage","getItem","JSON","parse","Object","entries","forEach","_ref","k","v","Number","isFinite","_err","set","value","setItem","stringify","useColumnResize","ctx","min","max","columns","rawColumns","instance","columnWidths","setColumnWidths","useState","handleResize","useCallback","columnKey","newWidth","prevState","renderHeaderCell","children","options","disableResize","getKey","width","getColumnWidth","getCurrentProps","defaultColumnWidth","__DEV__","isValidElement","type","Resizable","Error","_jsx","axis","minConstraints","minWidth","maxConstraints","maxWidth","handle","className","onResize","_e","_ref2","size","useMemo","map","toString","columnResize","createMiddleware"],"mappings":";;;;;AAyBA,SAASA,QAAQA,CAACC,GAAY,EAAA;AAC5B,EAAA,OAAO,OAAOA,GAAG,KAAK,QAAQ,IAAIA,GAAG,IAAI,IAAI;AAC/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AOpC,UAAU,CAACqC,GAAG,CAAEpE,MAAM,IAAI;MAC/B,MAAMI,GAAG,GAAGyC,MAAM,CAAC7C,MAAM,CAAC,CAACqE,QAAQ,EAAE;AACrC,MAAA,MAAMvB,KAAK,GAAGb,YAAY,CAAC7B,GAAG,CAAuB;MACrD,IAAI0C,KAAK,IAAI,IAAI,IAAIA,KAAK,KAAK9C,MAAM,CAAC8C,KAAK,EAAE;QAC3C,OAAO;AAAE,UAAA,GAAG9C,MAAM;AAAE8C,UAAAA;SAAO;AAC7B;AACA,MAAA,OAAO9C,MAAM;AACf,KAAC,CAAC;AACJ,GAAC,EAAE,CAACiC,YAAY,EAAEF,UAAU,CAAC,CAAC;EAE9B,OAAO;AAAE,IAAA,GAAGJ,GAAG;IAAEG,OAAO;AAAEW,IAAAA;GAAkB;AAC9C;MAEa6B,YAAY,GAAGC,gBAAgB,CAAC7C,eAAe;;;;"}
|
|
@@ -28,7 +28,7 @@ interface ExpandableConfig<T> {
|
|
|
28
28
|
showExpandColumn?: boolean;
|
|
29
29
|
expandedRowClassName?: string | RowClassName<T>;
|
|
30
30
|
rowExpandable?: (record: T) => boolean;
|
|
31
|
-
columnWidth?: number
|
|
31
|
+
columnWidth?: number;
|
|
32
32
|
fixed?: FixedType;
|
|
33
33
|
extraColumnProps?: ColumnExtra;
|
|
34
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../packages/virtual-table/src/middleware/expandable/expand-row.tsx","../../../../packages/virtual-table/src/middleware/expandable/index.tsx"],"sourcesContent":["import type { CSSProperties, FC, Key, ReactNode } from 'react'\nimport { useContainerSize, useTableRowManager } from '@are-visual/virtual-table'\nimport clsx from 'clsx'\n\nexport interface ExpandRowProps {\n className?: string\n style?: CSSProperties\n rowKey: Key\n isExpanded?: boolean\n colSpan?: number\n children?: ReactNode\n fixed?: boolean\n}\n\nexport const ExpandRowHeightKey = 'ExpandRow'\n\nconst ExpandRow: FC<ExpandRowProps> = (props) => {\n const {\n className,\n style,\n rowKey,\n isExpanded,\n colSpan,\n children,\n fixed,\n } = props\n\n const { setRowHeightByRowKey } = useTableRowManager()\n const { tableWidth } = useContainerSize()\n\n return (\n <tr\n className={clsx('virtual-table-expanded-row', className)}\n style={{ ...style, display: isExpanded ? undefined : 'none' }}\n ref={(node) => {\n if (node == null) return\n setRowHeightByRowKey(rowKey, ExpandRowHeightKey, node.offsetHeight)\n }}\n >\n <td colSpan={colSpan}>\n <div\n className={clsx(\n 'virtual-table-cell',\n fixed && 'virtual-table-expanded-row-fixed',\n )}\n style={{ width: tableWidth <= 0 ? undefined : tableWidth }}\n >\n {children}\n </div>\n </td>\n </tr>\n )\n}\n\nexport default ExpandRow\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type {\n AnyObject,\n ColumnExtra,\n ColumnType,\n FixedType,\n MiddlewareContext,\n MiddlewareRenderRow,\n MiddlewareResult,\n OnRowType,\n} from '@are-visual/virtual-table'\nimport type { Key, MouseEvent, ReactNode } from 'react'\nimport { createMiddleware, getRowKey, isValidFixed, useShallowMemo, useStableFn } from '@are-visual/virtual-table'\nimport { useControllableValue } from '@are-visual/virtual-table/middleware/utils/useControllableValue'\nimport clsx from 'clsx'\nimport { useCallback, useMemo, useRef } from 'react'\nimport ExpandRow, { ExpandRowHeightKey } from './expand-row'\n\ntype TriggerEventHandler<T> = (record: T, event: MouseEvent<HTMLElement>) => void\nexport interface RenderExpandIconProps<T> {\n prefixCls: string\n expanded: boolean\n record: T\n expandable: boolean\n onExpand: TriggerEventHandler<T>\n}\nexport type RowClassName<T> = (record: T, index: number, indent: number) => string\nexport type RenderExpandIcon<T> = (props: RenderExpandIconProps<T>) => ReactNode\nexport type ExpandedRowRender<T> = (record: T, index: number, indent: number, expanded: boolean) => ReactNode\n\nexport interface ExpandableConfig<T> {\n expandedRowKeys?: readonly Key[]\n defaultExpandedRowKeys?: readonly Key[]\n expandedRowRender?: ExpandedRowRender<T>\n columnTitle?: ReactNode\n expandRowByClick?: boolean\n expandIcon?: RenderExpandIcon<T>\n onExpand?: (expanded: boolean, record: T) => void\n onExpandedRowsChange?: (expandedKeys: readonly Key[]) => void\n defaultExpandAllRows?: boolean\n showExpandColumn?: boolean\n expandedRowClassName?: string | RowClassName<T>\n rowExpandable?: (record: T) => boolean\n columnWidth?: number | string\n fixed?: FixedType\n extraColumnProps?: ColumnExtra\n}\n\nexport { ExpandRowHeightKey }\nexport const EXPANSION_COLUMN_KEY = 'VirtualTable.EXPANSION_COLUMN'\n\nexport function isExpansionColumn<T = any>(column: ColumnType<T>) {\n return column.key === EXPANSION_COLUMN_KEY\n}\n\nfunction useTableExpandable<T = any>(\n ctx: MiddlewareContext<T>,\n options?: ExpandableConfig<T>,\n): MiddlewareResult<T> {\n const disablePlugin = options == null\n\n const { rowKey, columns: rawColumns, dataSource } = ctx\n const {\n // expandedRowKeys,\n // onExpandedRowsChange,\n defaultExpandedRowKeys,\n expandedRowRender,\n columnTitle,\n expandRowByClick = false,\n expandIcon,\n onExpand,\n\n defaultExpandAllRows = false,\n\n // TODO: 未实现\n // indentSize: _indentSize,\n\n showExpandColumn = true,\n expandedRowClassName,\n\n rowExpandable,\n columnWidth = 50,\n fixed,\n extraColumnProps,\n } = options ?? {}\n\n const _rowExpandableValue = useMemo(() => {\n return dataSource.map((row) => {\n if (!rowExpandable) return false\n return rowExpandable(row)\n })\n }, [dataSource, rowExpandable])\n\n // useShallowMemo 每一次渲染时候都会重新求值,这对于某些开销较大的计算不太友好,\n // 所以使用 useMemo 求值再通过 useShallowMemo 浅比较\n // useMemo 标记 deps 后,若 deps 不变也就不需要重新求值\n // 使用 useShallowMemo 主要是为了防止重新求值后结果不变但地址指针变化,导致不必要的渲染\n const rowExpandableRecord = useShallowMemo(() => _rowExpandableValue)\n\n // 即使 defaultExpandAllRows 变更之后,此插件也不要响应变化,只使用初始值,所以存储一下\n const defaultExpandAll = useRef(\n // options 中有 expandedRowKeys 则表示受控模式,那么 defaultExpandAllRows 不生效\n 'expandedRowKeys' in (options ?? {}) || 'defaultExpandedRowKeys' in (options ?? {})\n ? false\n : defaultExpandAllRows,\n )\n const defaultExpandKey = useShallowMemo((): readonly Key[] => {\n if (defaultExpandAll.current) {\n const expandKeys = dataSource.map((record, index): Key | null => {\n if (rowExpandableRecord[index]) {\n const key = (record as AnyObject)[rowKey as string] as string | number\n return key\n }\n return null\n })\n return expandKeys.filter((x) => x != null)\n }\n return []\n })\n\n const expansionKeys = useRef(new Set<Key>(defaultExpandedRowKeys ?? defaultExpandKey))\n const [expansion, setExpansion] = useControllableValue<readonly Key[]>(\n options ?? {},\n {\n trigger: 'onExpandedRowsChange',\n valuePropName: 'expandedRowKeys',\n defaultValue: defaultExpandedRowKeys ?? defaultExpandKey,\n },\n )\n\n const onUpdateExpansion = useStableFn((rowData: T, shouldExpand?: boolean) => {\n const key = getRowKey(rowData, rowKey)\n expansionKeys.current.add(key)\n if (shouldExpand == null) {\n if (expansion.includes(key)) {\n setExpansion(expansion.filter((x) => x !== key))\n onExpand?.(false, rowData)\n } else {\n setExpansion([...expansion, key])\n onExpand?.(true, rowData)\n }\n } else if (shouldExpand) {\n setExpansion([...expansion, key])\n onExpand?.(true, rowData)\n } else {\n setExpansion(expansion.filter((x) => x !== key))\n onExpand?.(false, rowData)\n }\n })\n\n const isFixed = isValidFixed(fixed)\n\n const renderRow: MiddlewareRenderRow = useCallback((children, args) => {\n const { rowData, rowIndex, rowKey: key, columnDescriptor } = args\n\n const isExpandable = rowExpandableRecord[rowIndex]\n if (isExpandable) {\n const isExpanded: boolean | undefined = expansion.includes(key)\n const isRendered = expansionKeys.current.has(key)\n\n let className = ''\n if (typeof expandedRowClassName === 'string') {\n className = expandedRowClassName\n } else if (typeof expandedRowClassName === 'function') {\n className = expandedRowClassName(rowData as T, rowIndex, 0)\n }\n\n return (\n <>\n {children}\n {isRendered && (\n <ExpandRow\n className={className}\n rowKey={key}\n isExpanded={isExpanded}\n colSpan={columnDescriptor.length}\n fixed={isFixed}\n >\n {expandedRowRender?.(rowData as T, rowIndex, 0, isExpanded)}\n </ExpandRow>\n )}\n </>\n )\n }\n return children\n }, [\n isFixed,\n rowExpandableRecord,\n expansion,\n expandedRowClassName,\n expandedRowRender,\n ])\n\n const columns = useMemo((): ColumnType<T>[] => {\n if (!showExpandColumn) {\n return rawColumns\n }\n\n return [\n {\n ...extraColumnProps,\n key: EXPANSION_COLUMN_KEY,\n title: columnTitle,\n width: columnWidth,\n fixed,\n render(_value, record, index) {\n const key = getRowKey(record, rowKey)\n\n const expandable = rowExpandableRecord[index] ?? false\n const expanded = expansion.includes(key)\n\n if (typeof expandIcon === 'function') {\n return expandIcon({\n expandable,\n expanded,\n record,\n prefixCls: 'virtual-table',\n onExpand: (rowData: T, _e) => {\n onUpdateExpansion(rowData)\n },\n })\n }\n\n if (!expandable) {\n return null\n }\n\n return (\n <button\n className={clsx(\n 'virtual-table-row-expand-icon',\n expanded\n ? 'virtual-table-row-expand-icon-expanded'\n : 'virtual-table-row-expand-icon-collapsed',\n )}\n type=\"button\"\n aria-label={expanded ? '关闭行' : '展开行'}\n aria-expanded={expanded}\n onClick={() => {\n onUpdateExpansion(record, !expanded)\n }}\n />\n )\n },\n onHeaderCell() {\n return { className: 'virtual-table-expand-column' }\n },\n },\n ...rawColumns,\n ]\n }, [\n showExpandColumn,\n columnTitle,\n columnWidth,\n fixed,\n rawColumns,\n rowKey,\n rowExpandableRecord,\n expansion,\n expandIcon,\n onUpdateExpansion,\n extraColumnProps,\n ])\n\n const onRow: OnRowType<T> = useCallback((record, index) => {\n if (rowExpandableRecord[index]) {\n return {\n onClick: (e) => {\n e.stopPropagation()\n onUpdateExpansion(record)\n },\n }\n }\n return {}\n }, [rowExpandableRecord, onUpdateExpansion])\n\n if (disablePlugin) {\n return ctx\n }\n\n return {\n ...ctx,\n columns,\n renderRow,\n onRow: !expandRowByClick ? undefined : onRow,\n }\n}\n\nexport const tableExpandable = createMiddleware(useTableExpandable)\n"],"names":["ExpandRowHeightKey","ExpandRow","props","className","style","rowKey","isExpanded","colSpan","children","fixed","setRowHeightByRowKey","useTableRowManager","tableWidth","useContainerSize","_jsx","clsx","display","undefined","ref","node","offsetHeight","width","EXPANSION_COLUMN_KEY","isExpansionColumn","column","key","useTableExpandable","ctx","options","disablePlugin","columns","rawColumns","dataSource","defaultExpandedRowKeys","expandedRowRender","columnTitle","expandRowByClick","expandIcon","onExpand","defaultExpandAllRows","showExpandColumn","expandedRowClassName","rowExpandable","columnWidth","extraColumnProps","_rowExpandableValue","useMemo","map","row","rowExpandableRecord","useShallowMemo","defaultExpandAll","useRef","defaultExpandKey","current","expandKeys","record","index","filter","x","expansionKeys","Set","expansion","setExpansion","useControllableValue","trigger","valuePropName","defaultValue","onUpdateExpansion","useStableFn","rowData","shouldExpand","getRowKey","add","includes","isFixed","isValidFixed","renderRow","useCallback","args","rowIndex","columnDescriptor","isExpandable","isRendered","has","_jsxs","length","title","render","_value","expandable","expanded","prefixCls","_e","type","onClick","onHeaderCell","onRow","e","stopPropagation","tableExpandable","createMiddleware"],"mappings":";;;;;;AAcO,MAAMA,kBAAkB,GAAG;AAElC,MAAMC,SAAS,GAAwBC,KAAK,IAAI;EAC9C,MAAM;IACJC,SAAS;IACTC,KAAK;IACLC,MAAM;IACNC,UAAU;IACVC,OAAO;IACPC,QAAQ;AACRC,IAAAA;AACD,GAAA,GAAGP,KAAK;EAET,MAAM;AAAEQ,IAAAA;GAAsB,GAAGC,kBAAkB,EAAE;EACrD,MAAM;AAAEC,IAAAA;GAAY,GAAGC,gBAAgB,EAAE;EAEzC,OACEC,GAAA,CAAA,IAAA,EAAA;AACEX,IAAAA,SAAS,EAAEY,IAAI,CAAC,4BAA4B,EAAEZ,SAAS,CAAC;AACxDC,IAAAA,KAAK,EAAE;AAAE,MAAA,GAAGA,KAAK;AAAEY,MAAAA,OAAO,EAAEV,UAAU,GAAGW,SAAS,GAAG;KAAQ;IAC7DC,GAAG,EAAGC,IAAI,IAAI;MACZ,IAAIA,IAAI,I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AM,EACN4C,mBAAmB,EACnBa,SAAS,EACTzB,UAAU,EACV+B,iBAAiB,EACjBxB,gBAAgB,CACjB,CAAC;EAEF,MAAMqD,KAAK,GAAiBnB,WAAW,CAAC,CAACtB,MAAM,EAAEC,KAAK,KAAI;AACxD,IAAA,IAAIR,mBAAmB,CAACQ,KAAK,CAAC,EAAE;MAC9B,OAAO;QACLsC,OAAO,EAAGG,CAAC,IAAI;UACbA,CAAC,CAACC,eAAe,EAAE;UACnB/B,iBAAiB,CAACZ,MAAM,CAAC;AAC3B;OACD;AACH;AACA,IAAA,OAAO,EAAE;AACX,GAAC,EAAE,CAACP,mBAAmB,EAAEmB,iBAAiB,CAAC,CAAC;AAE5C,EAAA,IAAIvC,aAAa,EAAE;AACjB,IAAA,OAAOF,GAAG;AACZ;EAEA,OAAO;AACL,IAAA,GAAGA,GAAG;IACNG,OAAO;IACP+C,SAAS;AACToB,IAAAA,KAAK,EAAE,CAAC7D,gBAAgB,GAAGnB,SAAS,GAAGgF;GACxC;AACH;MAEaG,eAAe,GAAGC,gBAAgB,CAAC3E,kBAAkB;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../packages/virtual-table/src/middleware/expandable/expand-row.tsx","../../../../packages/virtual-table/src/middleware/expandable/index.tsx"],"sourcesContent":["import type { CSSProperties, FC, Key, ReactNode } from 'react'\nimport { useContainerSize, useTableRowManager } from '@are-visual/virtual-table'\nimport clsx from 'clsx'\n\nexport interface ExpandRowProps {\n className?: string\n style?: CSSProperties\n rowKey: Key\n isExpanded?: boolean\n colSpan?: number\n children?: ReactNode\n fixed?: boolean\n}\n\nexport const ExpandRowHeightKey = 'ExpandRow'\n\nconst ExpandRow: FC<ExpandRowProps> = (props) => {\n const {\n className,\n style,\n rowKey,\n isExpanded,\n colSpan,\n children,\n fixed,\n } = props\n\n const { setRowHeightByRowKey } = useTableRowManager()\n const { tableWidth } = useContainerSize()\n\n return (\n <tr\n className={clsx('virtual-table-expanded-row', className)}\n style={{ ...style, display: isExpanded ? undefined : 'none' }}\n ref={(node) => {\n if (node == null) return\n setRowHeightByRowKey(rowKey, ExpandRowHeightKey, node.offsetHeight)\n }}\n >\n <td colSpan={colSpan}>\n <div\n className={clsx(\n 'virtual-table-cell',\n fixed && 'virtual-table-expanded-row-fixed',\n )}\n style={{ width: tableWidth <= 0 ? undefined : tableWidth }}\n >\n {children}\n </div>\n </td>\n </tr>\n )\n}\n\nexport default ExpandRow\n","/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type {\n AnyObject,\n ColumnExtra,\n ColumnType,\n FixedType,\n MiddlewareContext,\n MiddlewareRenderRow,\n MiddlewareResult,\n OnRowType,\n} from '@are-visual/virtual-table'\nimport type { Key, MouseEvent, ReactNode } from 'react'\nimport { createMiddleware, getRowKey, isValidFixed, useShallowMemo, useStableFn } from '@are-visual/virtual-table'\nimport { useControllableValue } from '@are-visual/virtual-table/middleware/utils/useControllableValue'\nimport clsx from 'clsx'\nimport { useCallback, useMemo, useRef } from 'react'\nimport ExpandRow, { ExpandRowHeightKey } from './expand-row'\n\ntype TriggerEventHandler<T> = (record: T, event: MouseEvent<HTMLElement>) => void\nexport interface RenderExpandIconProps<T> {\n prefixCls: string\n expanded: boolean\n record: T\n expandable: boolean\n onExpand: TriggerEventHandler<T>\n}\nexport type RowClassName<T> = (record: T, index: number, indent: number) => string\nexport type RenderExpandIcon<T> = (props: RenderExpandIconProps<T>) => ReactNode\nexport type ExpandedRowRender<T> = (record: T, index: number, indent: number, expanded: boolean) => ReactNode\n\nexport interface ExpandableConfig<T> {\n expandedRowKeys?: readonly Key[]\n defaultExpandedRowKeys?: readonly Key[]\n expandedRowRender?: ExpandedRowRender<T>\n columnTitle?: ReactNode\n expandRowByClick?: boolean\n expandIcon?: RenderExpandIcon<T>\n onExpand?: (expanded: boolean, record: T) => void\n onExpandedRowsChange?: (expandedKeys: readonly Key[]) => void\n defaultExpandAllRows?: boolean\n showExpandColumn?: boolean\n expandedRowClassName?: string | RowClassName<T>\n rowExpandable?: (record: T) => boolean\n columnWidth?: number\n fixed?: FixedType\n extraColumnProps?: ColumnExtra\n}\n\nexport { ExpandRowHeightKey }\nexport const EXPANSION_COLUMN_KEY = 'VirtualTable.EXPANSION_COLUMN'\n\nexport function isExpansionColumn<T = any>(column: ColumnType<T>) {\n return column.key === EXPANSION_COLUMN_KEY\n}\n\nfunction useTableExpandable<T = any>(\n ctx: MiddlewareContext<T>,\n options?: ExpandableConfig<T>,\n): MiddlewareResult<T> {\n const disablePlugin = options == null\n\n const { rowKey, columns: rawColumns, dataSource } = ctx\n const {\n // expandedRowKeys,\n // onExpandedRowsChange,\n defaultExpandedRowKeys,\n expandedRowRender,\n columnTitle,\n expandRowByClick = false,\n expandIcon,\n onExpand,\n\n defaultExpandAllRows = false,\n\n // TODO: 未实现\n // indentSize: _indentSize,\n\n showExpandColumn = true,\n expandedRowClassName,\n\n rowExpandable,\n columnWidth = 50,\n fixed,\n extraColumnProps,\n } = options ?? {}\n\n const _rowExpandableValue = useMemo(() => {\n return dataSource.map((row) => {\n if (!rowExpandable) return false\n return rowExpandable(row)\n })\n }, [dataSource, rowExpandable])\n\n // useShallowMemo 每一次渲染时候都会重新求值,这对于某些开销较大的计算不太友好,\n // 所以使用 useMemo 求值再通过 useShallowMemo 浅比较\n // useMemo 标记 deps 后,若 deps 不变也就不需要重新求值\n // 使用 useShallowMemo 主要是为了防止重新求值后结果不变但地址指针变化,导致不必要的渲染\n const rowExpandableRecord = useShallowMemo(() => _rowExpandableValue)\n\n // 即使 defaultExpandAllRows 变更之后,此插件也不要响应变化,只使用初始值,所以存储一下\n const defaultExpandAll = useRef(\n // options 中有 expandedRowKeys 则表示受控模式,那么 defaultExpandAllRows 不生效\n 'expandedRowKeys' in (options ?? {}) || 'defaultExpandedRowKeys' in (options ?? {})\n ? false\n : defaultExpandAllRows,\n )\n const defaultExpandKey = useShallowMemo((): readonly Key[] => {\n if (defaultExpandAll.current) {\n const expandKeys = dataSource.map((record, index): Key | null => {\n if (rowExpandableRecord[index]) {\n const key = (record as AnyObject)[rowKey as string] as string | number\n return key\n }\n return null\n })\n return expandKeys.filter((x) => x != null)\n }\n return []\n })\n\n const expansionKeys = useRef(new Set<Key>(defaultExpandedRowKeys ?? defaultExpandKey))\n const [expansion, setExpansion] = useControllableValue<readonly Key[]>(\n options ?? {},\n {\n trigger: 'onExpandedRowsChange',\n valuePropName: 'expandedRowKeys',\n defaultValue: defaultExpandedRowKeys ?? defaultExpandKey,\n },\n )\n\n const onUpdateExpansion = useStableFn((rowData: T, shouldExpand?: boolean) => {\n const key = getRowKey(rowData, rowKey)\n expansionKeys.current.add(key)\n if (shouldExpand == null) {\n if (expansion.includes(key)) {\n setExpansion(expansion.filter((x) => x !== key))\n onExpand?.(false, rowData)\n } else {\n setExpansion([...expansion, key])\n onExpand?.(true, rowData)\n }\n } else if (shouldExpand) {\n setExpansion([...expansion, key])\n onExpand?.(true, rowData)\n } else {\n setExpansion(expansion.filter((x) => x !== key))\n onExpand?.(false, rowData)\n }\n })\n\n const isFixed = isValidFixed(fixed)\n\n const renderRow: MiddlewareRenderRow = useCallback((children, args) => {\n const { rowData, rowIndex, rowKey: key, columnDescriptor } = args\n\n const isExpandable = rowExpandableRecord[rowIndex]\n if (isExpandable) {\n const isExpanded: boolean | undefined = expansion.includes(key)\n const isRendered = expansionKeys.current.has(key)\n\n let className = ''\n if (typeof expandedRowClassName === 'string') {\n className = expandedRowClassName\n } else if (typeof expandedRowClassName === 'function') {\n className = expandedRowClassName(rowData as T, rowIndex, 0)\n }\n\n return (\n <>\n {children}\n {isRendered && (\n <ExpandRow\n className={className}\n rowKey={key}\n isExpanded={isExpanded}\n colSpan={columnDescriptor.length}\n fixed={isFixed}\n >\n {expandedRowRender?.(rowData as T, rowIndex, 0, isExpanded)}\n </ExpandRow>\n )}\n </>\n )\n }\n return children\n }, [\n isFixed,\n rowExpandableRecord,\n expansion,\n expandedRowClassName,\n expandedRowRender,\n ])\n\n const columns = useMemo((): ColumnType<T>[] => {\n if (!showExpandColumn) {\n return rawColumns\n }\n\n return [\n {\n ...extraColumnProps,\n key: EXPANSION_COLUMN_KEY,\n title: columnTitle,\n width: columnWidth,\n fixed,\n render(_value, record, index) {\n const key = getRowKey(record, rowKey)\n\n const expandable = rowExpandableRecord[index] ?? false\n const expanded = expansion.includes(key)\n\n if (typeof expandIcon === 'function') {\n return expandIcon({\n expandable,\n expanded,\n record,\n prefixCls: 'virtual-table',\n onExpand: (rowData: T, _e) => {\n onUpdateExpansion(rowData)\n },\n })\n }\n\n if (!expandable) {\n return null\n }\n\n return (\n <button\n className={clsx(\n 'virtual-table-row-expand-icon',\n expanded\n ? 'virtual-table-row-expand-icon-expanded'\n : 'virtual-table-row-expand-icon-collapsed',\n )}\n type=\"button\"\n aria-label={expanded ? '关闭行' : '展开行'}\n aria-expanded={expanded}\n onClick={() => {\n onUpdateExpansion(record, !expanded)\n }}\n />\n )\n },\n onHeaderCell() {\n return { className: 'virtual-table-expand-column' }\n },\n },\n ...rawColumns,\n ]\n }, [\n showExpandColumn,\n columnTitle,\n columnWidth,\n fixed,\n rawColumns,\n rowKey,\n rowExpandableRecord,\n expansion,\n expandIcon,\n onUpdateExpansion,\n extraColumnProps,\n ])\n\n const onRow: OnRowType<T> = useCallback((record, index) => {\n if (rowExpandableRecord[index]) {\n return {\n onClick: (e) => {\n e.stopPropagation()\n onUpdateExpansion(record)\n },\n }\n }\n return {}\n }, [rowExpandableRecord, onUpdateExpansion])\n\n if (disablePlugin) {\n return ctx\n }\n\n return {\n ...ctx,\n columns,\n renderRow,\n onRow: !expandRowByClick ? undefined : onRow,\n }\n}\n\nexport const tableExpandable = createMiddleware(useTableExpandable)\n"],"names":["ExpandRowHeightKey","ExpandRow","props","className","style","rowKey","isExpanded","colSpan","children","fixed","setRowHeightByRowKey","useTableRowManager","tableWidth","useContainerSize","_jsx","clsx","display","undefined","ref","node","offsetHeight","width","EXPANSION_COLUMN_KEY","isExpansionColumn","column","key","useTableExpandable","ctx","options","disablePlugin","columns","rawColumns","dataSource","defaultExpandedRowKeys","expandedRowRender","columnTitle","expandRowByClick","expandIcon","onExpand","defaultExpandAllRows","showExpandColumn","expandedRowClassName","rowExpandable","columnWidth","extraColumnProps","_rowExpandableValue","useMemo","map","row","rowExpandableRecord","useShallowMemo","defaultExpandAll","useRef","defaultExpandKey","current","expandKeys","record","index","filter","x","expansionKeys","Set","expansion","setExpansion","useControllableValue","trigger","valuePropName","defaultValue","onUpdateExpansion","useStableFn","rowData","shouldExpand","getRowKey","add","includes","isFixed","isValidFixed","renderRow","useCallback","args","rowIndex","columnDescriptor","isExpandable","isRendered","has","_jsxs","length","title","render","_value","expandable","expanded","prefixCls","_e","type","onClick","onHeaderCell","onRow","e","stopPropagation","tableExpandable","createMiddleware"],"mappings":";;;;;;AAcO,MAAMA,kBAAkB,GAAG;AAElC,MAAMC,SAAS,GAAwBC,KAAK,IAAI;EAC9C,MAAM;IACJC,SAAS;IACTC,KAAK;IACLC,MAAM;IACNC,UAAU;IACVC,OAAO;IACPC,QAAQ;AACRC,IAAAA;AACD,GAAA,GAAGP,KAAK;EAET,MAAM;AAAEQ,IAAAA;GAAsB,GAAGC,kBAAkB,EAAE;EACrD,MAAM;AAAEC,IAAAA;GAAY,GAAGC,gBAAgB,EAAE;EAEzC,OACEC,GAAA,CAAA,IAAA,EAAA;AACEX,IAAAA,SAAS,EAAEY,IAAI,CAAC,4BAA4B,EAAEZ,SAAS,CAAC;AACxDC,IAAAA,KAAK,EAAE;AAAE,MAAA,GAAGA,KAAK;AAAEY,MAAAA,OAAO,EAAEV,UAAU,GAAGW,SAAS,GAAG;KAAQ;IAC7DC,GAAG,EAAGC,IAAI,IAAI;MACZ,IAAIA,IAAI,IAAI,IAAI,EAAE;MAClBT,oBAAoB,CAACL,MAAM,EAAEL,kBAAkB,EAAEmB,IAAI,CAACC,YAAY,CAAC;KACpE;cAEDN,GAAI,CAAA,IAAA,EAAA;AAAA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ACtB,MAAM,EAAEC,KAAK,KAAI;AACxD,IAAA,IAAIR,mBAAmB,CAACQ,KAAK,CAAC,EAAE;MAC9B,OAAO;QACLsC,OAAO,EAAGG,CAAC,IAAI;UACbA,CAAC,CAACC,eAAe,EAAE;UACnB/B,iBAAiB,CAACZ,MAAM,CAAC;AAC3B;OACD;AACH;AACA,IAAA,OAAO,EAAE;AACX,GAAC,EAAE,CAACP,mBAAmB,EAAEmB,iBAAiB,CAAC,CAAC;AAE5C,EAAA,IAAIvC,aAAa,EAAE;AACjB,IAAA,OAAOF,GAAG;AACZ;EAEA,OAAO;AACL,IAAA,GAAGA,GAAG;IACNG,OAAO;IACP+C,SAAS;AACToB,IAAAA,KAAK,EAAE,CAAC7D,gBAAgB,GAAGnB,SAAS,GAAGgF;GACxC;AACH;MAEaG,eAAe,GAAGC,gBAAgB,CAAC3E,kBAAkB;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { useScrollSynchronize, onResize, createMiddleware } from '@are-visual/virtual-table';
|
|
3
3
|
import { getScrollbarSize } from '@are-visual/virtual-table/middleware/utils/getScrollbarSize';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
|
-
import {
|
|
5
|
+
import { useState, useEffect } from 'react';
|
|
6
6
|
|
|
7
7
|
const ScrollBar = props => {
|
|
8
8
|
const {
|
|
@@ -12,30 +12,7 @@ const ScrollBar = props => {
|
|
|
12
12
|
zIndex,
|
|
13
13
|
bodyRef
|
|
14
14
|
} = props;
|
|
15
|
-
const
|
|
16
|
-
listen,
|
|
17
|
-
notify
|
|
18
|
-
} = useHorizontalScrollContext();
|
|
19
|
-
const wrapperRef = useRef(null);
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
const node = wrapperRef.current;
|
|
22
|
-
if (node == null) return;
|
|
23
|
-
const key = 'virtual-table-sticky-bottom-scroll';
|
|
24
|
-
const onScroll = () => {
|
|
25
|
-
notify(key, {
|
|
26
|
-
scrollLeft: () => node.scrollLeft,
|
|
27
|
-
node
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
const dispose = listen(key, scrollLeft => {
|
|
31
|
-
node.scrollLeft = scrollLeft;
|
|
32
|
-
});
|
|
33
|
-
node.addEventListener('scroll', onScroll);
|
|
34
|
-
return () => {
|
|
35
|
-
node.removeEventListener('scroll', onScroll);
|
|
36
|
-
dispose();
|
|
37
|
-
};
|
|
38
|
-
}, [listen, notify]);
|
|
15
|
+
const wrapperRef = useScrollSynchronize('virtual-table-sticky-bottom-scroll');
|
|
39
16
|
const [width, setWidth] = useState(0);
|
|
40
17
|
useEffect(() => {
|
|
41
18
|
const body = bodyRef.current;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../packages/virtual-table/src/middleware/horizontal-scroll-bar/scroll-bar.tsx","../../../../packages/virtual-table/src/middleware/horizontal-scroll-bar/index.tsx"],"sourcesContent":["import type { CSSProperties, FC, RefObject } from 'react'\nimport { onResize,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../packages/virtual-table/src/middleware/horizontal-scroll-bar/scroll-bar.tsx","../../../../packages/virtual-table/src/middleware/horizontal-scroll-bar/index.tsx"],"sourcesContent":["import type { CSSProperties, FC, RefObject } from 'react'\nimport { onResize, useScrollSynchronize } from '@are-visual/virtual-table'\nimport { getScrollbarSize } from '@are-visual/virtual-table/middleware/utils/getScrollbarSize'\nimport clsx from 'clsx'\nimport { useEffect, useState } from 'react'\n\nexport interface ScrollBarProps {\n className?: string\n style?: CSSProperties\n bottom?: number | string\n zIndex?: number\n bodyRef: RefObject<HTMLTableElement>\n}\n\nconst ScrollBar: FC<ScrollBarProps> = (props) => {\n const { className, style, bottom, zIndex, bodyRef } = props\n\n const wrapperRef = useScrollSynchronize<HTMLDivElement>('virtual-table-sticky-bottom-scroll')\n\n const [width, setWidth] = useState(0)\n useEffect(() => {\n const body = bodyRef.current\n if (body == null) return\n return onResize(body, ({ width }) => {\n if (width === 0) return\n setWidth(width)\n })\n }, [bodyRef])\n\n const [size] = useState(getScrollbarSize)\n\n return (\n <div\n className={clsx('virtual-table-sticky-scroll', className)}\n style={{\n ...style,\n // @ts-expect-error 使用 css 变量覆盖 bottom,而不是 bottom,这样需要高优先级的时候,就可以使用 style 代替\n '--virtual-table-sticky-scroll-bottom': Number.isFinite(bottom) ? `${bottom}px` : bottom,\n 'paddingTop': size.height > 0 ? 0 : 15,\n 'marginTop': size.height > 0 ? 0 : size.height * -1,\n 'height': size.height + 1,\n zIndex,\n }}\n ref={wrapperRef}\n >\n <div className=\"virtual-table-sticky-scroll-bar\" style={{ width }}></div>\n </div>\n )\n}\n\nexport default ScrollBar\n","import type { MiddlewareContext, MiddlewareResult } from '@are-visual/virtual-table'\nimport type { ScrollBarProps } from './scroll-bar'\nimport { createMiddleware } from '@are-visual/virtual-table'\nimport ScrollBar from './scroll-bar'\n\nexport type HorizontalScrollBarOptions = Omit<ScrollBarProps, 'bodyRef'>\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction useHorizontalScrollBar<T = any>(\n ctx: MiddlewareContext<T>,\n options?: HorizontalScrollBarOptions,\n): MiddlewareResult<T> {\n const { bodyRootRef } = ctx\n\n return {\n ...ctx,\n renderContent(children) {\n return (\n <>\n {children}\n <ScrollBar\n bodyRef={bodyRootRef}\n {...options}\n />\n </>\n )\n },\n }\n}\n\nexport const horizontalScrollBar = createMiddleware(useHorizontalScrollBar)\n"],"names":["ScrollBar","props","className","style","bottom","zIndex","bodyRef","wrapperRef","useScrollSynchronize","width","setWidth","useState","useEffect","body","current","onResize","_ref","size","getScrollbarSize","_jsx","clsx","Number","isFinite","height","ref","children","useHorizontalScrollBar","ctx","options","bodyRootRef","renderContent","_jsxs","_Fragment","horizontalScrollBar","createMiddleware"],"mappings":";;;;;;AAcA,MAAMA,SAAS,GAAwBC,KAAK,IAAI;EAC9C,MAAM;IAAEC,SAAS;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fkB,IAAAA,QAAA,EAAAN,GAAA,CAAA,KAAA,EAAA;AAAKjB,MAAAA,SAAS,EAAC,iCAAiC;AAACC,MAAAA,KAAK,EAAE;AAAEM,QAAAA;;KAAe;AAAA,GAAA,CACrE;AAEV,CAAC;;ACzCD;AACA,SAASiB,sBAAsBA,CAC7BC,GAAyB,EACzBC,OAAoC,EAAA;EAEpC,MAAM;AAAEC,IAAAA;AAAa,GAAA,GAAGF,GAAG;EAE3B,OAAO;AACL,IAAA,GAAGA,GAAG;IACNG,aAAaA,CAACL,QAAQ,EAAA;MACpB,OACEM,IAAA,CAAAC,QAAA,EAAA;AAAAP,QAAAA,QAAA,EAAA,CACGA,QAAQ,EACTN,IAACnB,SAAS,EAAA;AACRM,UAAAA,OAAO,EAAEuB,WAAW;UAChB,GAAAD;AACJ,SAAA,CAAA;AAAA,OAAA,CACD;AAEP;GACD;AACH;MAEaK,mBAAmB,GAAGC,gBAAgB,CAACR,sBAAsB;;;;"}
|
|
@@ -25,7 +25,7 @@ interface TableRowSelection<T = any> {
|
|
|
25
25
|
onSelect?: SelectionSelectFn<T>;
|
|
26
26
|
hideSelectAll?: boolean;
|
|
27
27
|
fixed?: boolean;
|
|
28
|
-
columnWidth?:
|
|
28
|
+
columnWidth?: number;
|
|
29
29
|
columnTitle?: ReactNode | ((checkboxNode: ReactNode, props: SelectionColumnTitleProps) => ReactNode);
|
|
30
30
|
renderCell?: (value: boolean, record: T, index: number, originNode: ReactNode) => ReactNode;
|
|
31
31
|
onCell?: GetComponentProps<T>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { useScrollSynchronize, Colgroup, useTableSticky, isValidFixedLeft, isValidFixedRight, isValidFixed, createMiddleware } from '@are-visual/virtual-table';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
-
import { createContext, useState,
|
|
4
|
+
import { createContext, useState, memo, useMemo, useContext, createElement, isValidElement, cloneElement, Fragment, Children } from 'react';
|
|
5
5
|
import { getScrollbarSize } from '@are-visual/virtual-table/middleware/utils/getScrollbarSize';
|
|
6
6
|
|
|
7
7
|
const SummaryContext = /*#__PURE__*/createContext(null);
|
|
@@ -14,33 +14,11 @@ const Footer = props => {
|
|
|
14
14
|
bottom,
|
|
15
15
|
columns,
|
|
16
16
|
fixed,
|
|
17
|
-
children
|
|
17
|
+
children,
|
|
18
|
+
defaultColumnWidth
|
|
18
19
|
} = props;
|
|
19
|
-
const {
|
|
20
|
-
listen,
|
|
21
|
-
notify
|
|
22
|
-
} = useHorizontalScrollContext();
|
|
23
20
|
const [scrollbarHeight] = useState(() => getScrollbarSize().height);
|
|
24
|
-
const wrapperRef =
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
const node = wrapperRef.current;
|
|
27
|
-
if (node == null) return;
|
|
28
|
-
const key = 'virtual-table-summary';
|
|
29
|
-
const onScroll = () => {
|
|
30
|
-
notify(key, {
|
|
31
|
-
scrollLeft: () => node.scrollLeft,
|
|
32
|
-
node
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
const dispose = listen(key, scrollLeft => {
|
|
36
|
-
node.scrollLeft = scrollLeft;
|
|
37
|
-
});
|
|
38
|
-
node.addEventListener('scroll', onScroll);
|
|
39
|
-
return () => {
|
|
40
|
-
node.removeEventListener('scroll', onScroll);
|
|
41
|
-
dispose();
|
|
42
|
-
};
|
|
43
|
-
}, [listen, notify]);
|
|
21
|
+
const wrapperRef = useScrollSynchronize('virtual-table-summary');
|
|
44
22
|
return jsx("div", {
|
|
45
23
|
className: clsx('virtual-table-summary-wrapper', fixed && 'virtual-table-summary-sticky-bottom virtual-table-summary-top-border', className),
|
|
46
24
|
style: {
|
|
@@ -55,7 +33,8 @@ const Footer = props => {
|
|
|
55
33
|
children: jsxs("table", {
|
|
56
34
|
className: "virtual-table-summary",
|
|
57
35
|
children: [jsx(Colgroup, {
|
|
58
|
-
columns: columns
|
|
36
|
+
columns: columns,
|
|
37
|
+
defaultColumnWidth: defaultColumnWidth
|
|
59
38
|
}), jsx("tfoot", {
|
|
60
39
|
className: "virtual-table-summary-tfoot",
|
|
61
40
|
children: children
|
|
@@ -206,7 +185,8 @@ function useTableSummary(ctx, options) {
|
|
|
206
185
|
summary
|
|
207
186
|
} = options ?? {};
|
|
208
187
|
const {
|
|
209
|
-
dataSource
|
|
188
|
+
dataSource,
|
|
189
|
+
instance
|
|
210
190
|
} = ctx;
|
|
211
191
|
let hasFixedTop = false;
|
|
212
192
|
let hasFixedBottom = false;
|
|
@@ -276,6 +256,9 @@ function useTableSummary(ctx, options) {
|
|
|
276
256
|
let {
|
|
277
257
|
columnDescriptor
|
|
278
258
|
} = _ref2;
|
|
259
|
+
const {
|
|
260
|
+
defaultColumnWidth
|
|
261
|
+
} = instance.getCurrentProps();
|
|
279
262
|
return jsxs(Fragment$1, {
|
|
280
263
|
children: [children, jsx(Footer, {
|
|
281
264
|
className: className,
|
|
@@ -284,6 +267,7 @@ function useTableSummary(ctx, options) {
|
|
|
284
267
|
bottom: bottom,
|
|
285
268
|
fixed: hasFixedBottom,
|
|
286
269
|
columns: columnDescriptor,
|
|
270
|
+
defaultColumnWidth: defaultColumnWidth,
|
|
287
271
|
children: jsx(SummaryContext.Provider, {
|
|
288
272
|
value: columnDescriptor,
|
|
289
273
|
children: bottomNode
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../packages/virtual-table/src/middleware/summary/context/columns.tsx","../../../../packages/virtual-table/src/middleware/summary/footer.tsx","../../../../packages/virtual-table/src/middleware/summary/cell.tsx","../../../../packages/virtual-table/src/middleware/summary/outlet.tsx","../../../../packages/virtual-table/src/middleware/summary/row.tsx","../../../../packages/virtual-table/src/middleware/summary/summary.tsx","../../../../packages/virtual-table/src/middleware/summary/index.tsx"],"sourcesContent":["import type { ColumnDescriptor } from '@are-visual/virtual-table'\nimport { createContext } from 'react'\n\nexport const SummaryContext = createContext<ColumnDescriptor[] | null>(null)\n","import type { ColumnDescriptor } from '@are-visual/virtual-table'\nimport type { CSSProperties, FC, ReactNode } from 'react'\nimport { Colgroup, useHorizontalScrollContext } from '@are-visual/virtual-table'\nimport { getScrollbarSize } from '@are-visual/virtual-table/middleware/utils/getScrollbarSize'\nimport clsx from 'clsx'\nimport { useEffect, useRef, useState } from 'react'\n\nexport interface FooterProps {\n className?: string\n style?: CSSProperties\n /** Summary 位于底部,且设置 fixed 时生效 */\n zIndex?: number\n /** Summary 位于底部,且设置 fixed 时生效 */\n bottom?: number | string\n columns: ColumnDescriptor[]\n fixed?: boolean\n children?: ReactNode\n}\n\nconst Footer: FC<FooterProps> = (props) => {\n const { className, style, zIndex, bottom, columns, fixed, children } = props\n\n const { listen, notify } = useHorizontalScrollContext()\n const [scrollbarHeight] = useState(() => getScrollbarSize().height)\n\n const wrapperRef = useRef<HTMLDivElement>(null)\n useEffect(() => {\n const node = wrapperRef.current\n if (node == null) return\n const key = 'virtual-table-summary'\n const onScroll = () => {\n notify(key, { scrollLeft: () => node.scrollLeft, node })\n }\n const dispose = listen(key, (scrollLeft) => {\n node.scrollLeft = scrollLeft\n })\n node.addEventListener('scroll', onScroll)\n return () => {\n node.removeEventListener('scroll', onScroll)\n dispose()\n }\n }, [listen, notify])\n\n return (\n <div\n className={clsx(\n 'virtual-table-summary-wrapper',\n fixed && 'virtual-table-summary-sticky-bottom virtual-table-summary-top-border',\n className,\n )}\n\n style={{\n ...(fixed\n ? {\n '--virtual-table-summary-z-index': zIndex,\n '--virtual-table-summary-sticky-bottom': Number.isFinite(bottom) ? `${bottom}px` : bottom,\n }\n : {}),\n ...style,\n paddingBottom: scrollbarHeight,\n }}\n ref={wrapperRef}\n >\n <table className=\"virtual-table-summary\">\n <Colgroup columns={columns} />\n <tfoot className=\"virtual-table-summary-tfoot\">{children}</tfoot>\n </table>\n </div>\n )\n}\n\nexport default Footer\n","import type { ColumnType } from '@are-visual/virtual-table'\nimport type { DetailedHTMLProps, HTMLAttributes, Key } from 'react'\nimport { isValidFixed, isValidFixedLeft, isValidFixedRight, useTableSticky } from '@are-visual/virtual-table'\nimport clsx from 'clsx'\nimport { memo, useMemo } from 'react'\n\ntype NativeProps = DetailedHTMLProps<\n HTMLAttributes<HTMLTableCellElement>,\n HTMLTableCellElement\n>\n\nexport interface CellProps extends NativeProps, Pick<ColumnType<unknown>, 'align'> {\n columnKey?: Key\n colSpan?: number\n}\n\nfunction Cell(props: CellProps) {\n const {\n className,\n style,\n children,\n align,\n colSpan,\n columnKey,\n ...restProps\n } = props\n\n const { size: stickySizes, fixed: columnsFixed } = useTableSticky()\n\n const stickySize = columnKey == null ? 0 : stickySizes.get(columnKey)\n const fixed = columnsFixed.find((x) => x.key === columnKey)?.fixed\n\n const { left: lastFixedLeftColumnKey, right: firstFixedRightColumnKey } = useMemo(() => {\n const left = columnsFixed.reduce<Key | undefined>((result, x) => {\n if (isValidFixedLeft(x.fixed)) {\n return x.key\n }\n return result\n }, undefined)\n const right = columnsFixed.find((x) => isValidFixedRight(x.fixed))?.key\n return { left, right }\n }, [columnsFixed])\n\n if (colSpan === 0) {\n return null\n }\n\n return (\n <td\n {...restProps}\n colSpan={colSpan}\n className={clsx(\n 'virtual-table-cell virtual-table-summary-cell',\n align != null && `virtual-table-align-${align}`,\n isValidFixed(fixed) && 'virtual-table-sticky-cell',\n lastFixedLeftColumnKey === columnKey && 'virtual-table-cell-fix-left-last',\n firstFixedRightColumnKey === columnKey && 'virtual-table-cell-fix-right-first',\n className,\n )}\n style={{\n ...style,\n left: isValidFixedLeft(fixed) ? stickySize : undefined,\n right: isValidFixedRight(fixed) ? stickySize : undefined,\n }}\n >\n {children}\n </td>\n )\n}\n\nexport default memo(Cell)\n","import type { CSSProperties, MouseEvent } from 'react'\nimport { useContext } from 'react'\n\nimport Cell from './cell'\nimport { SummaryContext } from './context/columns'\n\nexport interface SummaryOutletProps<T> {\n className?: string\n style?: CSSProperties\n dataSource: T[]\n onClick?: (e?: MouseEvent<HTMLElement>) => void\n}\n\nfunction SummaryOutlet<T>(props: SummaryOutletProps<T>) {\n const { dataSource, ...restProps } = props\n const descriptor = useContext(SummaryContext)\n\n if (descriptor == null) {\n throw new Error(\n 'SummaryOutlet is missing the columns context and cannot use children as a function.',\n )\n }\n\n return (\n <tr {...restProps}>\n {descriptor.map((item) => {\n const { key } = item\n if (item.type === 'blank') {\n return <td key={key} />\n }\n const { column } = item\n const { render, ...cellProps } = column.summary ?? {}\n return (\n <Cell {...cellProps} key={key} columnKey={key}>\n {render?.(dataSource)}\n </Cell>\n )\n })}\n </tr>\n )\n}\n\nexport default SummaryOutlet\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { ColumnType } from '@are-visual/virtual-table'\nimport type { CSSProperties, FC, Key, MouseEvent, ReactElement, ReactNode } from 'react'\nimport type { CellProps } from './cell'\nimport { cloneElement, Fragment, isValidElement, useContext } from 'react'\nimport SummaryCell from './cell'\nimport { SummaryContext } from './context/columns'\n\nexport interface SummaryRowProps {\n children?: ReactNode | ((column: ColumnType<any>, key: Key) => ReactNode)\n className?: string\n style?: CSSProperties\n onClick?: (e?: MouseEvent<HTMLElement>) => void\n}\n\nconst SummaryRow: FC<SummaryRowProps> = ({ children, ...props }) => {\n const descriptor = useContext(SummaryContext)\n\n if (typeof children === 'function') {\n if (descriptor != null) {\n return (\n <tr {...props}>\n {descriptor.map((item) => {\n const { key } = item\n if (item.type === 'blank') {\n return <td key={key} />\n }\n const { column } = item\n let childNode = children(column, key)\n if (isValidElement(childNode) && childNode.type === SummaryCell) {\n childNode = cloneElement(childNode as ReactElement<CellProps>, { columnKey: key })\n }\n return <Fragment key={key}>{childNode}</Fragment>\n })}\n </tr>\n )\n }\n throw new Error('SummaryRow is missing the columns context and cannot use children as a function.')\n }\n\n return <tr {...props}>{children}</tr>\n}\n\nexport default SummaryRow\n","import type { ReactElement, ReactNode } from 'react'\n\nimport Cell from './cell'\nimport Outlet from './outlet'\nimport Row from './row'\n\nexport interface SummaryProps {\n fixed?: boolean | 'top' | 'bottom'\n children?: ReactNode\n}\n\nfunction Summary({ children }: SummaryProps) {\n return children as ReactElement\n}\n\nSummary.Row = Row\nSummary.Cell = Cell\nSummary.Outlet = Outlet\n\nexport default Summary\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { MiddlewareContext, MiddlewareResult } from '@are-visual/virtual-table'\nimport type { ReactElement, ReactNode } from 'react'\nimport type { CellProps } from './cell'\nimport type { FooterProps } from './footer'\nimport type { SummaryProps } from './summary'\nimport { createMiddleware } from '@are-visual/virtual-table'\nimport clsx from 'clsx'\nimport { Children, Fragment, isValidElement } from 'react'\nimport { SummaryContext } from './context/columns'\nimport Footer from './footer'\nimport Summary from './summary'\n\nexport interface InlineCellProps<T> extends Omit<CellProps, 'ref' | 'columnKey' | 'render' | 'children'> {\n render?: (dataSource: T[]) => ReactNode\n}\n\ndeclare module '@are-visual/virtual-table' {\n interface ColumnExtra<T = any> {\n summary?: InlineCellProps<T>\n }\n}\n\nexport interface TableSummaryOptions<T = any> extends Pick<FooterProps, 'bottom' | 'className' | 'style' | 'zIndex'> {\n summary: (data: T[]) => ReactNode\n}\n\nfunction useTableSummary<T = any>(\n ctx: MiddlewareContext<T>,\n options?: TableSummaryOptions<T>,\n): MiddlewareResult<T> {\n const { className, style, zIndex, bottom, summary } = options ?? {}\n const { dataSource } = ctx\n\n let hasFixedTop = false\n let hasFixedBottom = false\n\n const summaryNode = summary?.(dataSource)\n const topNode: ReactNode[] = []\n const bottomNode: ReactNode[] = []\n\n const handleRowElement = (node: ReactElement<SummaryProps>) => {\n const fixed = node.props.fixed\n if (fixed === 'top') {\n hasFixedTop = true\n topNode.push(node)\n } else {\n if (fixed === 'bottom' || fixed === true) {\n hasFixedBottom = true\n }\n bottomNode.push(node)\n }\n }\n\n if (summary == null) {\n return ctx\n }\n\n if (isValidElement(summaryNode)) {\n if (summaryNode.type === Fragment) {\n const rawChildren = (summaryNode.props as { children?: ReactNode }).children\n // eslint-disable-next-line @eslint-react/no-children-for-each\n Children.forEach(rawChildren, (child) => {\n if (isValidElement(child) && child.type === Summary) {\n handleRowElement(child as ReactElement<SummaryProps>)\n } else {\n if (__DEV__) {\n console.warn(child, 'The summary function does not support components other than Fragment and Summary.')\n }\n }\n })\n } else if (summaryNode.type === Summary) {\n handleRowElement(summaryNode as ReactElement<SummaryProps>)\n } else {\n if (__DEV__) {\n console.error(summaryNode, 'The summary function does not support components other than Fragment and Summary.')\n throw new Error('The summary function does not support components other than Fragment and Summary.')\n }\n }\n } else {\n return ctx\n }\n\n return {\n ...ctx,\n ...(hasFixedTop as boolean\n ? {\n renderHeader: (children, { columnDescriptor }) => {\n return (\n <>\n {children}\n <tfoot className={clsx('virtual-table-summary-tfoot', className)} style={style}>\n <SummaryContext.Provider value={columnDescriptor}>\n {topNode}\n </SummaryContext.Provider>\n </tfoot>\n </>\n )\n },\n }\n : {}),\n ...(hasFixedBottom as boolean\n ? {\n renderContent(children, { columnDescriptor }) {\n return (\n <>\n {children}\n <Footer\n className={className}\n style={style}\n zIndex={zIndex}\n bottom={bottom}\n fixed={hasFixedBottom}\n columns={columnDescriptor}\n >\n <SummaryContext.Provider value={columnDescriptor}>\n {bottomNode}\n </SummaryContext.Provider>\n </Footer>\n </>\n )\n },\n }\n : {}),\n }\n}\n\nexport { default as Summary } from './summary'\nexport const tableSummary = createMiddleware(useTableSummary)\n"],"names":["SummaryContext","createContext","Footer","props","className","style","zIndex","bottom","columns","fixed","children","listen","notify","useHorizontalScrollContext","scrollbarHeight","useState","getScrollbarSize","height","wrapperRef","useRef","useEffect","node","current","key","onScroll","scrollLeft","dispose","addEventListener","removeEventListener","_jsx","clsx","Number","isFinite","paddingBottom","ref","_jsxs","Colgroup","Cell","align","colSpan","columnKey","restProps","size","stickySizes","columnsFixed","useTableSticky","stickySize","get","find","x","left","lastFixedLeftColumnKey","right","firstFixedRightColumnKey","useMemo","reduce","result","isValidFixedLeft","undefined","isValidFixedRight","isValidFixed","memo","SummaryOutlet","dataSource","descriptor","useContext","Error","map","item","type","column","render","cellProps","summary","_createElement","SummaryRow","_ref","childNode","isValidElement","SummaryCell","cloneElement","Fragment","Summary","Row","Outlet","useTableSummary","ctx","options","hasFixedTop","hasFixedBottom","summaryNode","topNode","bottomNode","handleRowElement","push","rawChildren","Children","forEach","child","__DEV__","console","warn","error","renderHeader","columnDescriptor","_Fragment","Provider","value","renderContent","_ref2","tableSummary","createMiddleware"],"mappings":";;;;;;AAGO,MAAMA,cAAc,gBAAGC,aAAa,CAA4B,IAAI,CAAC;;ACgB5E,MAAMC,MAAM,GAAqBC,KAAK,IAAI;EACxC,MAAM;IAAEC,SAAS;IAAEC,KAAK;IAAEC,MAAM;IAAEC,MAAM;IAAEC,OAAO;IAAEC,KAAK;AAAEC,IAAAA;AAAU,GAAA,GAAGP,KAAK;EAE5E,MAAM;IAAEQ,MAAM;AAAEC,IAAAA;GAAQ,GAAGC,0BAA0B,EAAE;AACvD,EAAA,MAAM,CAACC,eAAe,CAAC,GAAGC,QAAQ,CAAC,MAAMC,gBAAgB,EAAE,CAACC,MAAM,CAAC;AAEnE,EAAA,MAAMC,UAAU,GAAGC,MAAM,CAAiB,IAAI,CAAC;AAC/CC,EAAAA,SAAS,CAAC,MAAK;AACb,IAAA,MAAMC,IAAI,GAAGH,UAAU,CAACI,OAAO;IAC/B,IAAID,IAAI,IAAI,IAAI,EAAE;IAClB,MAAME,GAAG,GAAG,uBAAuB;IACnC,MAAMC,QAAQ,GAAGA,MAAK;MACpBZ,MAAM,CAACW,GAAG,EAAE;AAAEE,QAAAA,UAAU,EAAEA,MAAMJ,IAAI,CAACI,UAAU;AAAEJ,QAAAA;AAAI,OAAE,CAAC;KACzD;AACD,IAAA,MAAMK,OAAO,GAAGf,MAAM,CAACY,GAAG,EAAGE,UAAU,IAAI;MACzCJ,IAAI,CAACI,UAAU,GAAGA,UAAU;AAC9B,KAAC,CAAC;AACFJ,IAAAA,IAAI,CAACM,gBAAgB,CAAC,QAAQ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QAAQ;AAACC,cAAAA,KAAK,EAAEH,gBAAgB;AAAA9F,cAAAA,QAAA,EAC7CiF;aAAO;AAEJ,WAAA,CAAA;AAAA,SAAA,CACP;AAEP;KACD,GACD,EAAE,CAAC;AACP,IAAA,IAAIF,cAAyB,GACzB;AACEmB,MAAAA,aAAaA,CAAClG,QAAQ,EAAAmG,KAAA,EAAsB;QAAA,IAApB;AAAEL,UAAAA;AAAkB,SAAA,GAAAK,KAAA;QAC1C,OACE1E;qBACGzB,QAAQ,EACTmB,IAAC3B,MAAM,EAAA;AACLE,YAAAA,SAAS,EAAEA,SAAS;AACpBC,YAAAA,KAAK,EAAEA,KAAK;AACZC,YAAAA,MAAM,EAAEA,MAAM;AACdC,YAAAA,MAAM,EAAEA,MAAM;AACdE,YAAAA,KAAK,EAAEgF,cAAc;AACrBjF,YAAAA,OAAO,EAAEgG,gBAAgB;AAAA9F,YAAAA,QAAA,EAEzBmB,IAAC7B,cAAc,CAAC0G,QAAQ,EAAC;AAAAC,cAAAA,KAAK,EAAEH,gBAAgB;AAAA9F,cAAAA,QAAA,EAC7CkF;aACuB;AAAA,WAAA,CACnB;AACR,SAAA,CAAA;AAEP;KACD,GACD,EAAE;GACP;AACH;MAGakB,YAAY,GAAGC,gBAAgB,CAAC1B,eAAe;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../packages/virtual-table/src/middleware/summary/context/columns.tsx","../../../../packages/virtual-table/src/middleware/summary/footer.tsx","../../../../packages/virtual-table/src/middleware/summary/cell.tsx","../../../../packages/virtual-table/src/middleware/summary/outlet.tsx","../../../../packages/virtual-table/src/middleware/summary/row.tsx","../../../../packages/virtual-table/src/middleware/summary/summary.tsx","../../../../packages/virtual-table/src/middleware/summary/index.tsx"],"sourcesContent":["import type { ColumnDescriptor } from '@are-visual/virtual-table'\nimport { createContext } from 'react'\n\nexport const SummaryContext = createContext<ColumnDescriptor[] | null>(null)\n","import type { ColumnDescriptor } from '@are-visual/virtual-table'\nimport type { CSSProperties, FC, ReactNode } from 'react'\nimport { Colgroup, useScrollSynchronize } from '@are-visual/virtual-table'\nimport { getScrollbarSize } from '@are-visual/virtual-table/middleware/utils/getScrollbarSize'\nimport clsx from 'clsx'\nimport { useState } from 'react'\n\nexport interface FooterProps {\n className?: string\n style?: CSSProperties\n /** Summary 位于底部,且设置 fixed 时生效 */\n zIndex?: number\n /** Summary 位于底部,且设置 fixed 时生效 */\n bottom?: number | string\n columns: ColumnDescriptor[]\n fixed?: boolean\n children?: ReactNode\n defaultColumnWidth: number\n}\n\nconst Footer: FC<FooterProps> = (props) => {\n const { className, style, zIndex, bottom, columns, fixed, children, defaultColumnWidth } = props\n\n const [scrollbarHeight] = useState(() => getScrollbarSize().height)\n const wrapperRef = useScrollSynchronize<HTMLDivElement>('virtual-table-summary')\n\n return (\n <div\n className={clsx(\n 'virtual-table-summary-wrapper',\n fixed && 'virtual-table-summary-sticky-bottom virtual-table-summary-top-border',\n className,\n )}\n\n style={{\n ...(fixed\n ? {\n '--virtual-table-summary-z-index': zIndex,\n '--virtual-table-summary-sticky-bottom': Number.isFinite(bottom) ? `${bottom}px` : bottom,\n }\n : {}),\n ...style,\n paddingBottom: scrollbarHeight,\n }}\n ref={wrapperRef}\n >\n <table className=\"virtual-table-summary\">\n <Colgroup columns={columns} defaultColumnWidth={defaultColumnWidth} />\n <tfoot className=\"virtual-table-summary-tfoot\">{children}</tfoot>\n </table>\n </div>\n )\n}\n\nexport default Footer\n","import type { ColumnType } from '@are-visual/virtual-table'\nimport type { DetailedHTMLProps, HTMLAttributes, Key } from 'react'\nimport { isValidFixed, isValidFixedLeft, isValidFixedRight, useTableSticky } from '@are-visual/virtual-table'\nimport clsx from 'clsx'\nimport { memo, useMemo } from 'react'\n\ntype NativeProps = DetailedHTMLProps<\n HTMLAttributes<HTMLTableCellElement>,\n HTMLTableCellElement\n>\n\nexport interface CellProps extends NativeProps, Pick<ColumnType<unknown>, 'align'> {\n columnKey?: Key\n colSpan?: number\n}\n\nfunction Cell(props: CellProps) {\n const {\n className,\n style,\n children,\n align,\n colSpan,\n columnKey,\n ...restProps\n } = props\n\n const { size: stickySizes, fixed: columnsFixed } = useTableSticky()\n\n const stickySize = columnKey == null ? 0 : stickySizes.get(columnKey)\n const fixed = columnsFixed.find((x) => x.key === columnKey)?.fixed\n\n const { left: lastFixedLeftColumnKey, right: firstFixedRightColumnKey } = useMemo(() => {\n const left = columnsFixed.reduce<Key | undefined>((result, x) => {\n if (isValidFixedLeft(x.fixed)) {\n return x.key\n }\n return result\n }, undefined)\n const right = columnsFixed.find((x) => isValidFixedRight(x.fixed))?.key\n return { left, right }\n }, [columnsFixed])\n\n if (colSpan === 0) {\n return null\n }\n\n return (\n <td\n {...restProps}\n colSpan={colSpan}\n className={clsx(\n 'virtual-table-cell virtual-table-summary-cell',\n align != null && `virtual-table-align-${align}`,\n isValidFixed(fixed) && 'virtual-table-sticky-cell',\n lastFixedLeftColumnKey === columnKey && 'virtual-table-cell-fix-left-last',\n firstFixedRightColumnKey === columnKey && 'virtual-table-cell-fix-right-first',\n className,\n )}\n style={{\n ...style,\n left: isValidFixedLeft(fixed) ? stickySize : undefined,\n right: isValidFixedRight(fixed) ? stickySize : undefined,\n }}\n >\n {children}\n </td>\n )\n}\n\nexport default memo(Cell)\n","import type { CSSProperties, MouseEvent } from 'react'\nimport { useContext } from 'react'\n\nimport Cell from './cell'\nimport { SummaryContext } from './context/columns'\n\nexport interface SummaryOutletProps<T> {\n className?: string\n style?: CSSProperties\n dataSource: T[]\n onClick?: (e?: MouseEvent<HTMLElement>) => void\n}\n\nfunction SummaryOutlet<T>(props: SummaryOutletProps<T>) {\n const { dataSource, ...restProps } = props\n const descriptor = useContext(SummaryContext)\n\n if (descriptor == null) {\n throw new Error(\n 'SummaryOutlet is missing the columns context and cannot use children as a function.',\n )\n }\n\n return (\n <tr {...restProps}>\n {descriptor.map((item) => {\n const { key } = item\n if (item.type === 'blank') {\n return <td key={key} />\n }\n const { column } = item\n const { render, ...cellProps } = column.summary ?? {}\n return (\n <Cell {...cellProps} key={key} columnKey={key}>\n {render?.(dataSource)}\n </Cell>\n )\n })}\n </tr>\n )\n}\n\nexport default SummaryOutlet\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { ColumnType } from '@are-visual/virtual-table'\nimport type { CSSProperties, FC, Key, MouseEvent, ReactElement, ReactNode } from 'react'\nimport type { CellProps } from './cell'\nimport { cloneElement, Fragment, isValidElement, useContext } from 'react'\nimport SummaryCell from './cell'\nimport { SummaryContext } from './context/columns'\n\nexport interface SummaryRowProps {\n children?: ReactNode | ((column: ColumnType<any>, key: Key) => ReactNode)\n className?: string\n style?: CSSProperties\n onClick?: (e?: MouseEvent<HTMLElement>) => void\n}\n\nconst SummaryRow: FC<SummaryRowProps> = ({ children, ...props }) => {\n const descriptor = useContext(SummaryContext)\n\n if (typeof children === 'function') {\n if (descriptor != null) {\n return (\n <tr {...props}>\n {descriptor.map((item) => {\n const { key } = item\n if (item.type === 'blank') {\n return <td key={key} />\n }\n const { column } = item\n let childNode = children(column, key)\n if (isValidElement(childNode) && childNode.type === SummaryCell) {\n childNode = cloneElement(childNode as ReactElement<CellProps>, { columnKey: key })\n }\n return <Fragment key={key}>{childNode}</Fragment>\n })}\n </tr>\n )\n }\n throw new Error('SummaryRow is missing the columns context and cannot use children as a function.')\n }\n\n return <tr {...props}>{children}</tr>\n}\n\nexport default SummaryRow\n","import type { ReactElement, ReactNode } from 'react'\n\nimport Cell from './cell'\nimport Outlet from './outlet'\nimport Row from './row'\n\nexport interface SummaryProps {\n fixed?: boolean | 'top' | 'bottom'\n children?: ReactNode\n}\n\nfunction Summary({ children }: SummaryProps) {\n return children as ReactElement\n}\n\nSummary.Row = Row\nSummary.Cell = Cell\nSummary.Outlet = Outlet\n\nexport default Summary\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { MiddlewareContext, MiddlewareResult } from '@are-visual/virtual-table'\nimport type { ReactElement, ReactNode } from 'react'\nimport type { CellProps } from './cell'\nimport type { FooterProps } from './footer'\nimport type { SummaryProps } from './summary'\nimport { createMiddleware } from '@are-visual/virtual-table'\nimport clsx from 'clsx'\nimport { Children, Fragment, isValidElement } from 'react'\nimport { SummaryContext } from './context/columns'\nimport Footer from './footer'\nimport Summary from './summary'\n\nexport interface InlineCellProps<T> extends Omit<CellProps, 'ref' | 'columnKey' | 'render' | 'children'> {\n render?: (dataSource: T[]) => ReactNode\n}\n\ndeclare module '@are-visual/virtual-table' {\n interface ColumnExtra<T = any> {\n summary?: InlineCellProps<T>\n }\n}\n\nexport interface TableSummaryOptions<T = any> extends Pick<FooterProps, 'bottom' | 'className' | 'style' | 'zIndex'> {\n summary: (data: T[]) => ReactNode\n}\n\nfunction useTableSummary<T = any>(\n ctx: MiddlewareContext<T>,\n options?: TableSummaryOptions<T>,\n): MiddlewareResult<T> {\n const { className, style, zIndex, bottom, summary } = options ?? {}\n const { dataSource, instance } = ctx\n\n let hasFixedTop = false\n let hasFixedBottom = false\n\n const summaryNode = summary?.(dataSource)\n const topNode: ReactNode[] = []\n const bottomNode: ReactNode[] = []\n\n const handleRowElement = (node: ReactElement<SummaryProps>) => {\n const fixed = node.props.fixed\n if (fixed === 'top') {\n hasFixedTop = true\n topNode.push(node)\n } else {\n if (fixed === 'bottom' || fixed === true) {\n hasFixedBottom = true\n }\n bottomNode.push(node)\n }\n }\n\n if (summary == null) {\n return ctx\n }\n\n if (isValidElement(summaryNode)) {\n if (summaryNode.type === Fragment) {\n const rawChildren = (summaryNode.props as { children?: ReactNode }).children\n // eslint-disable-next-line @eslint-react/no-children-for-each\n Children.forEach(rawChildren, (child) => {\n if (isValidElement(child) && child.type === Summary) {\n handleRowElement(child as ReactElement<SummaryProps>)\n } else {\n if (__DEV__) {\n console.warn(child, 'The summary function does not support components other than Fragment and Summary.')\n }\n }\n })\n } else if (summaryNode.type === Summary) {\n handleRowElement(summaryNode as ReactElement<SummaryProps>)\n } else {\n if (__DEV__) {\n console.error(summaryNode, 'The summary function does not support components other than Fragment and Summary.')\n throw new Error('The summary function does not support components other than Fragment and Summary.')\n }\n }\n } else {\n return ctx\n }\n\n return {\n ...ctx,\n ...(hasFixedTop as boolean\n ? {\n renderHeader: (children, { columnDescriptor }) => {\n return (\n <>\n {children}\n <tfoot className={clsx('virtual-table-summary-tfoot', className)} style={style}>\n <SummaryContext.Provider value={columnDescriptor}>\n {topNode}\n </SummaryContext.Provider>\n </tfoot>\n </>\n )\n },\n }\n : {}),\n ...(hasFixedBottom as boolean\n ? {\n renderContent(children, { columnDescriptor }) {\n const { defaultColumnWidth } = instance.getCurrentProps()\n return (\n <>\n {children}\n <Footer\n className={className}\n style={style}\n zIndex={zIndex}\n bottom={bottom}\n fixed={hasFixedBottom}\n columns={columnDescriptor}\n defaultColumnWidth={defaultColumnWidth}\n >\n <SummaryContext.Provider value={columnDescriptor}>\n {bottomNode}\n </SummaryContext.Provider>\n </Footer>\n </>\n )\n },\n }\n : {}),\n }\n}\n\nexport { default as Summary } from './summary'\nexport const tableSummary = createMiddleware(useTableSummary)\n"],"names":["SummaryContext","createContext","Footer","props","className","style","zIndex","bottom","columns","fixed","children","defaultColumnWidth","scrollbarHeight","useState","getScrollbarSize","height","wrapperRef","useScrollSynchronize","_jsx","clsx","Number","isFinite","paddingBottom","ref","_jsxs","Colgroup","Cell","align","colSpan","columnKey","restProps","size","stickySizes","columnsFixed","useTableSticky","stickySize","get","find","x","key","left","lastFixedLeftColumnKey","right","firstFixedRightColumnKey","useMemo","reduce","result","isValidFixedLeft","undefined","isValidFixedRight","isValidFixed","memo","SummaryOutlet","dataSource","descriptor","useContext","Error","map","item","type","column","render","cellProps","summary","_createElement","SummaryRow","_ref","childNode","isValidElement","SummaryCell","cloneElement","Fragment","Summary","Row","Outlet","useTableSummary","ctx","options","instance","hasFixedTop","hasFixedBottom","summaryNode","topNode","bottomNode","handleRowElement","node","push","rawChildren","Children","forEach","child","__DEV__","console","warn","error","renderHeader","columnDescriptor","_Fragment","Provider","value","renderContent","_ref2","getC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