@are-visual/virtual-table 0.6.0 → 0.8.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 +163 -0
- package/index.d.ts +144 -85
- package/index.esm.js +623 -274
- package/index.esm.js.map +1 -1
- package/middleware/column-resize/index.d.ts +2 -1
- package/middleware/empty/index.d.ts +2 -1
- package/middleware/expandable/index.d.ts +6 -2
- package/middleware/expandable/index.js +8 -8
- package/middleware/expandable/index.js.map +1 -1
- package/middleware/horizontal-scroll-bar/index.d.ts +2 -1
- package/middleware/loading/index.js +21 -8
- package/middleware/loading/index.js.map +1 -1
- package/middleware/selection/index.d.ts +3 -2
- package/middleware/summary/index.d.ts +18 -5
- package/middleware/summary/index.js +30 -6
- package/middleware/summary/index.js.map +1 -1
- package/middleware/summary/styles.css +2 -2
- package/middleware/summary/styles.scss +4 -2
- package/package.json +1 -1
|
@@ -16,4 +16,5 @@ interface ResizeOptions<T = any> {
|
|
|
16
16
|
}
|
|
17
17
|
declare const columnResize: <T = any>(args?: ResizeOptions<T> | undefined) => _are_visual_virtual_table.Middleware<T>;
|
|
18
18
|
|
|
19
|
-
export {
|
|
19
|
+
export { columnResize };
|
|
20
|
+
export type { ResizeOptions };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as _are_visual_virtual_table from '@are-visual/virtual-table';
|
|
2
2
|
import { FixedType, ColumnExtra, ColumnType } from '@are-visual/virtual-table';
|
|
3
|
-
import { ReactNode, Key
|
|
3
|
+
import { MouseEvent, ReactNode, Key } from 'react';
|
|
4
|
+
|
|
5
|
+
declare const ExpandRowHeightKey = "ExpandRow";
|
|
4
6
|
|
|
5
7
|
type TriggerEventHandler<T> = (record: T, event: MouseEvent<HTMLElement>) => void;
|
|
6
8
|
interface RenderExpandIconProps<T> {
|
|
@@ -30,8 +32,10 @@ interface ExpandableConfig<T> {
|
|
|
30
32
|
fixed?: FixedType;
|
|
31
33
|
extraColumnProps?: ColumnExtra;
|
|
32
34
|
}
|
|
35
|
+
|
|
33
36
|
declare const EXPANSION_COLUMN_KEY = "VirtualTable.EXPANSION_COLUMN";
|
|
34
37
|
declare function isExpansionColumn<T = any>(column: ColumnType<T>): boolean;
|
|
35
38
|
declare const tableExpandable: <T = any>(options?: ExpandableConfig<T> | undefined) => _are_visual_virtual_table.Middleware<T>;
|
|
36
39
|
|
|
37
|
-
export { EXPANSION_COLUMN_KEY,
|
|
40
|
+
export { EXPANSION_COLUMN_KEY, ExpandRowHeightKey, isExpansionColumn, tableExpandable };
|
|
41
|
+
export type { ExpandableConfig, ExpandedRowRender, RenderExpandIcon, RenderExpandIconProps, RowClassName };
|
|
@@ -4,18 +4,19 @@ import { useControllableValue } from '@are-visual/virtual-table/middleware/utils
|
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import { useMemo, useRef, useCallback } from 'react';
|
|
6
6
|
|
|
7
|
+
const ExpandRowHeightKey = 'ExpandRow';
|
|
7
8
|
const ExpandRow = props => {
|
|
8
9
|
const {
|
|
9
10
|
className,
|
|
10
11
|
style,
|
|
11
|
-
|
|
12
|
+
rowKey,
|
|
12
13
|
isExpanded,
|
|
13
14
|
colSpan,
|
|
14
15
|
children,
|
|
15
16
|
fixed
|
|
16
17
|
} = props;
|
|
17
18
|
const {
|
|
18
|
-
|
|
19
|
+
setRowHeightByRowKey
|
|
19
20
|
} = useTableRowManager();
|
|
20
21
|
const {
|
|
21
22
|
tableWidth
|
|
@@ -28,7 +29,7 @@ const ExpandRow = props => {
|
|
|
28
29
|
},
|
|
29
30
|
ref: node => {
|
|
30
31
|
if (node == null) return;
|
|
31
|
-
|
|
32
|
+
setRowHeightByRowKey(rowKey, ExpandRowHeightKey, node.offsetHeight);
|
|
32
33
|
},
|
|
33
34
|
children: jsx("td", {
|
|
34
35
|
colSpan: colSpan,
|
|
@@ -131,11 +132,11 @@ function useTableExpandable(ctx, options) {
|
|
|
131
132
|
const {
|
|
132
133
|
rowData,
|
|
133
134
|
rowIndex,
|
|
135
|
+
rowKey: key,
|
|
134
136
|
columnDescriptor
|
|
135
137
|
} = args;
|
|
136
138
|
const isExpandable = rowExpandableRecord[rowIndex];
|
|
137
139
|
if (isExpandable) {
|
|
138
|
-
const key = getRowKey(rowData, rowKey);
|
|
139
140
|
const isExpanded = expansion.includes(key);
|
|
140
141
|
const isRendered = expansionKeys.current.has(key);
|
|
141
142
|
let className = '';
|
|
@@ -147,7 +148,7 @@ function useTableExpandable(ctx, options) {
|
|
|
147
148
|
return jsxs(Fragment, {
|
|
148
149
|
children: [children, isRendered && jsx(ExpandRow, {
|
|
149
150
|
className: className,
|
|
150
|
-
|
|
151
|
+
rowKey: key,
|
|
151
152
|
isExpanded: isExpanded,
|
|
152
153
|
colSpan: columnDescriptor.length,
|
|
153
154
|
fixed: isFixed,
|
|
@@ -156,7 +157,7 @@ function useTableExpandable(ctx, options) {
|
|
|
156
157
|
});
|
|
157
158
|
}
|
|
158
159
|
return children;
|
|
159
|
-
}, [isFixed, rowExpandableRecord,
|
|
160
|
+
}, [isFixed, rowExpandableRecord, expansion, expandedRowClassName, expandedRowRender]);
|
|
160
161
|
const columns = useMemo(() => {
|
|
161
162
|
if (!showExpandColumn) {
|
|
162
163
|
return rawColumns;
|
|
@@ -223,8 +224,7 @@ function useTableExpandable(ctx, options) {
|
|
|
223
224
|
onRow: !expandRowByClick ? undefined : onRow
|
|
224
225
|
};
|
|
225
226
|
}
|
|
226
|
-
/* eslint max-len: ["error", { "code": 120 }] */
|
|
227
227
|
const tableExpandable = createMiddleware(useTableExpandable);
|
|
228
228
|
|
|
229
|
-
export { EXPANSION_COLUMN_KEY, isExpansionColumn, tableExpandable };
|
|
229
|
+
export { EXPANSION_COLUMN_KEY, ExpandRowHeightKey, isExpansionColumn, tableExpandable };
|
|
230
230
|
//# sourceMappingURL=index.js.map
|
|
@@ -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, 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 rowIndex: number\n isExpanded?: boolean\n colSpan?: number\n children?: ReactNode\n fixed?: boolean\n}\n\nconst ExpandRow: FC<ExpandRowProps> = (props) => {\n const {\n className,\n style,\n rowIndex,\n isExpanded,\n colSpan,\n children,\n fixed,\n } = props\n\n const { updateRowHeight } = 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 updateRowHeight(rowIndex, `row(${rowIndex})-expandable`, 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 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 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, columnDescriptor } = args\n\n const isExpandable = rowExpandableRecord[rowIndex]\n if (isExpandable) {\n const key = getRowKey(rowData as T, rowKey)\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 rowIndex={rowIndex}\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 rowKey,\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\n/* eslint max-len: [\"error\", { \"code\": 120 }] */\nexport const tableExpandable = createMiddleware(useTableExpandable)\n"],"names":["ExpandRow","props","className","style","rowIndex","isExpanded","colSpan","children","fixed","updateRowHeight","useTableRowManager","tableWidth","useContainerSize","_jsx","clsx","display","undefined","ref","node","offsetHeight","width","EXPANSION_COLUMN_KEY","isExpansionColumn","column","key","useTableExpandable","ctx","options","disablePlugin","rowKey","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","columnDescriptor","isExpandable","isRendered","has","_jsxs","length","title","render","_value","expandable","expanded","prefixCls","_e","type","onClick","onHeaderCell","onRow","e","stopPropagation","tableExpandable","createMiddleware"],"mappings":";;;;;;AAcA,MAAMA,SAAS,GAAwBC,KAAK,IAAI;EAC9C,MAAM;IACJC,SAAS;IACTC,KAAK;IACLC,QAAQ;IACRC,UAAU;IACVC,OAAO;IACPC,QAAQ;AACRC,IAAAA;AACD,GAAA,GAAGP,KAAK;EAET,MAAM;AAAEQ,IAAAA;GAAiB,GAAGC,kBAAkB,EAAE;EAChD,MAAM;AAAEC,IAAAA;GAAY,GAAGC,gBAAgB,EAAE;EAEzC,OACEC,GAAA,CA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BA,QAAQ;UACvBI,OAAO,EAAEA,MAAK;AACZ1B,YAAAA,iBAAiB,CAACZ,MAAM,EAAE,CAACkC,QAAQ,CAAC;AACtC;AAAC,SAAA,CACD;OAEL;AACDK,MAAAA,YAAYA,GAAA;QACV,OAAO;AAAE7F,UAAAA,SAAS,EAAE;SAA+B;AACrD;KACD,EACD,GAAG6B,UAAU,CACd;GACF,EAAE,CACDS,gBAAgB,EAChBL,WAAW,EACXQ,WAAW,EACXnC,KAAK,EACLuB,UAAU,EACVF,MAAM,EACNoB,mBAAmB,EACnBa,SAAS,EACTzB,UAAU,EACV+B,iBAAiB,EACjBxB,gBAAgB,CACjB,CAAC;EAEF,MAAMoD,KAAK,GAAiBlB,WAAW,CAAC,CAACtB,MAAM,EAAEC,KAAK,KAAI;AACxD,IAAA,IAAIR,mBAAmB,CAACQ,KAAK,CAAC,EAAE;MAC9B,OAAO;QACLqC,OAAO,EAAGG,CAAC,IAAI;UACbA,CAAC,CAACC,eAAe,EAAE;UACnB9B,iBAAiB,CAACZ,MAAM,CAAC;AAC3B;OACD;AACH;AACA,IAAA,OAAO,EAAE;AACX,GAAC,EAAE,CAACP,mBAAmB,EAAEmB,iBAAiB,CAAC,CAAC;AAE5C,EAAA,IAAIxC,aAAa,EAAE;AACjB,IAAA,OAAOF,GAAG;AACZ;EAEA,OAAO;AACL,IAAA,GAAGA,GAAG;IACNI,OAAO;IACP+C,SAAS;AACTmB,IAAAA,KAAK,EAAE,CAAC5D,gBAAgB,GAAGpB,SAAS,GAAGgF;GACxC;AACH;AAEA;MACaG,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-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;AACxD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AO;AAAE7F,UAAAA,SAAS,EAAE;SAA+B;AACrD;KACD,EACD,GAAG4B,UAAU,CACd;GACF,EAAE,CACDS,gBAAgB,EAChBL,WAAW,EACXQ,WAAW,EACXlC,KAAK,EACLsB,UAAU,EACV1B,MAAM,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;;;;"}
|
|
@@ -12,4 +12,5 @@ interface ScrollBarProps {
|
|
|
12
12
|
type HorizontalScrollBarOptions = Omit<ScrollBarProps, 'bodyRef'>;
|
|
13
13
|
declare const horizontalScrollBar: <T = any>(options?: HorizontalScrollBarOptions | undefined) => _are_visual_virtual_table.Middleware<T>;
|
|
14
14
|
|
|
15
|
-
export {
|
|
15
|
+
export { horizontalScrollBar };
|
|
16
|
+
export type { HorizontalScrollBarOptions };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { getKey, useTableSticky,
|
|
3
|
-
import { memo, useState, useEffect, useMemo } from 'react';
|
|
2
|
+
import { getKey, useTableSticky, isValidFixedRight, isValidFixedLeft, isValidFixed, useTableRowManager, findLastIndex, createMiddleware, onResize } from '@are-visual/virtual-table';
|
|
3
|
+
import { memo, useState, useEffect, useMemo, isValidElement, cloneElement } from 'react';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
|
|
6
6
|
function LoadingCell(props) {
|
|
@@ -33,10 +33,10 @@ function LoadingRow(props) {
|
|
|
33
33
|
const {
|
|
34
34
|
descriptor,
|
|
35
35
|
style,
|
|
36
|
-
|
|
36
|
+
rowKey
|
|
37
37
|
} = props;
|
|
38
38
|
const {
|
|
39
|
-
|
|
39
|
+
setRowHeightByRowKey
|
|
40
40
|
} = useTableRowManager();
|
|
41
41
|
const lastFixedLeftColumnIndex = findLastIndex(descriptor, x => {
|
|
42
42
|
if (x.type === 'blank') {
|
|
@@ -55,7 +55,7 @@ function LoadingRow(props) {
|
|
|
55
55
|
style: style,
|
|
56
56
|
ref: node => {
|
|
57
57
|
if (node == null) return;
|
|
58
|
-
|
|
58
|
+
setRowHeightByRowKey(rowKey, 'loading-tr', node.offsetHeight);
|
|
59
59
|
},
|
|
60
60
|
children: descriptor.map((item, index) => {
|
|
61
61
|
const {
|
|
@@ -76,7 +76,6 @@ function LoadingRow(props) {
|
|
|
76
76
|
}
|
|
77
77
|
var LoadingRow$1 = /*#__PURE__*/memo(LoadingRow);
|
|
78
78
|
|
|
79
|
-
const EMPTY_ARR = [];
|
|
80
79
|
function useTableLoading(ctx, options) {
|
|
81
80
|
const {
|
|
82
81
|
loading = false
|
|
@@ -113,7 +112,21 @@ function useTableLoading(ctx, options) {
|
|
|
113
112
|
}
|
|
114
113
|
return {
|
|
115
114
|
...ctx,
|
|
116
|
-
|
|
115
|
+
renderBodyRoot: children => {
|
|
116
|
+
if (/*#__PURE__*/isValidElement(children)) {
|
|
117
|
+
if (Object.prototype.hasOwnProperty.call(children.props, 'style')) {
|
|
118
|
+
const style = children.props.style;
|
|
119
|
+
return /*#__PURE__*/cloneElement(children, {
|
|
120
|
+
style: {
|
|
121
|
+
...style,
|
|
122
|
+
paddingBottom: undefined,
|
|
123
|
+
paddingTop: undefined
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return children;
|
|
129
|
+
},
|
|
117
130
|
renderBodyContent: (_ignore, _ref2) => {
|
|
118
131
|
let {
|
|
119
132
|
columnDescriptor,
|
|
@@ -125,7 +138,7 @@ function useTableLoading(ctx, options) {
|
|
|
125
138
|
height: estimatedRowHeight
|
|
126
139
|
},
|
|
127
140
|
descriptor: columnDescriptor,
|
|
128
|
-
|
|
141
|
+
rowKey: `__loading$-${index + startRowIndex}`
|
|
129
142
|
}, item.key);
|
|
130
143
|
});
|
|
131
144
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../packages/virtual-table/src/middleware/loading/cell.tsx","../../../../packages/virtual-table/src/middleware/loading/row.tsx","../../../../packages/virtual-table/src/middleware/loading/index.tsx"],"sourcesContent":["import type { ColumnType } from '@are-visual/virtual-table'\nimport type { ReactElement } from 'react'\nimport { getKey, isValidFixed, isValidFixedLeft, isValidFixedRight, useTableSticky } from '@are-visual/virtual-table'\nimport clsx from 'clsx'\nimport { memo } from 'react'\n\nexport interface CellProps<T> {\n className?: string\n column: ColumnType<T>\n}\n\nfunction LoadingCell<T>(props: CellProps<T>) {\n const { column, className } = props\n\n const { align, fixed } = column\n const key = getKey(column)\n const { size: stickySizes } = useTableSticky()\n\n return (\n <td\n className={clsx(\n 'virtual-table-cell',\n className,\n align != null && `virtual-table-align-${align}`,\n isValidFixed(fixed) && 'virtual-table-sticky-cell',\n )}\n style={{\n left: isValidFixedLeft(fixed) ? stickySizes.get(key) : undefined,\n right: isValidFixedRight(fixed) ? stickySizes.get(key) : undefined,\n }}\n >\n <div className=\"virtual-table-loading-skeleton\" />\n </td>\n )\n}\n\nexport default memo(LoadingCell) as <T>(props: CellProps<T>) => ReactElement\n","import type { ColumnDescriptor } from '@are-visual/virtual-table'\nimport type { CSSProperties, ReactElement } from 'react'\nimport { findLastIndex, isValidFixedLeft, isValidFixedRight, useTableRowManager } from '@are-visual/virtual-table'\nimport clsx from 'clsx'\nimport { memo } from 'react'\nimport LoadingCell from './cell'\n\nexport interface RowProps<T> {\n style?: CSSProperties\n descriptor: ColumnDescriptor<T>[]\n rowIndex: number\n}\n\nfunction LoadingRow<T>(props: RowProps<T>) {\n const { descriptor, style, rowIndex } = props\n\n const { updateRowHeight } = useTableRowManager()\n\n const lastFixedLeftColumnIndex = findLastIndex(descriptor, (x) => {\n if (x.type === 'blank') {\n return false\n }\n return isValidFixedLeft(x.column.fixed)\n })\n const firstFixedRightColumnIndex = descriptor.findIndex((x) => {\n if (x.type === 'blank') {\n return false\n }\n return isValidFixedRight(x.column.fixed)\n })\n\n return (\n <tr\n className=\"virtual-table-row virtual-table-loading-cell\"\n style={style}\n ref={(node) => {\n if (node == null) return\n updateRowHeight(rowIndex, rowIndex, node.offsetHeight)\n }}\n >\n {descriptor.map((item, index) => {\n const { key } = item\n if (item.type === 'blank') {\n return <td key={key} />\n }\n const { column } = item\n return (\n <LoadingCell\n key={key}\n className={clsx(\n lastFixedLeftColumnIndex === index && 'virtual-table-cell-fix-left-last',\n firstFixedRightColumnIndex === index\n && 'virtual-table-cell-fix-right-first',\n )}\n column={column}\n />\n )\n })}\n </tr>\n )\n}\n\nexport default memo(LoadingRow) as <T>(props: RowProps<T>) => ReactElement\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { MiddlewareContext, MiddlewareResult } from '@are-visual/virtual-table'\nimport { createMiddleware, onResize } from '@are-visual/virtual-table'\nimport { useEffect, useMemo, useState } from 'react'\nimport LoadingRow from './row'\n\nconst EMPTY_ARR: unknown[] = []\n\nfunction useTableLoading<T = any>(\n ctx: MiddlewareContext<T>,\n options?: { loading?: boolean },\n): MiddlewareResult<T> {\n const { loading = false } = options ?? {}\n const { estimatedRowHeight, headerWrapperRef, getScroller } = ctx\n\n const [count, setCount] = useState(10)\n\n useEffect(() => {\n const header = headerWrapperRef.current\n const container = getScroller()\n if (container == null) return\n return onResize(container, ({ height }) => {\n const headerHeight = header?.offsetHeight ?? 0\n setCount(Math.ceil((height - headerHeight) / estimatedRowHeight))\n })\n }, [getScroller, headerWrapperRef, estimatedRowHeight])\n\n const fakeDataSource = useMemo(() => {\n return Array.from({ length: count }, (_, index) => {\n return { key: index }\n })\n }, [count])\n\n if (!loading) {\n return ctx\n }\n\n return {\n ...ctx,\n dataSource: EMPTY_ARR as T[],\n renderBodyContent: (_ignore, { columnDescriptor, startRowIndex }) => {\n return fakeDataSource.map((item, index) => {\n return (\n <LoadingRow\n key={item.key}\n style={{ height: estimatedRowHeight }}\n descriptor={columnDescriptor}\n rowIndex={index + startRowIndex}\n />\n )\n })\n },\n }\n}\n\nexport const tableLoading = createMiddleware(useTableLoading)\n"],"names":["LoadingCell","props","column","className","align","fixed","key","getKey","size","stickySizes","useTableSticky","_jsx","clsx","isValidFixed","style","left","isValidFixedLeft","get","undefined","right","isValidFixedRight","children","memo","LoadingRow","descriptor","rowIndex","updateRowHeight","useTableRowManager","lastFixedLeftColumnIndex","findLastIndex","x","type","firstFixedRightColumnIndex","findIndex","ref","node","offsetHeight","map","item","index","EMPTY_ARR","useTableLoading","ctx","options","loading","estimatedRowHeight","headerWrapperRef","getScroller","count","setCount","useState","useEffect","header","current","container","onResize","_ref","height","headerHeight","Math","ceil","fakeDataSource","useMemo","Array","from","length","_","dataSource","renderBodyContent","_ignore","_ref2","columnDescriptor","startRowIndex","tableLoading","createMiddleware"],"mappings":";;;;;AAWA,SAASA,WAAWA,CAAIC,KAAmB,EAAA;EACzC,MAAM;IAAEC,MAAM;AAAEC,IAAAA;AAAW,GAAA,GAAGF,KAAK;EAEnC,MAAM;IAAEG,KAAK;AAAEC,IAAAA;AAAO,GAAA,GAAGH,MAAM;AAC/B,EAAA,MAAMI,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QACxC,OACE5B,GAAC,CAAAY,YAAU,EAET;AAAAT,UAAAA,KAAK,EAAE;AAAE2C,YAAAA,MAAM,EAAEZ;WAAoB;AACrCrB,UAAAA,UAAU,EAAE+C,gBAAgB;UAC5B9C,QAAQ,EAAEc,KAAK,GAAGiC;AAHb,SAAA,EAAAlC,IAAI,CAAChC,GAAG,CAIb;AAEN,OAAC,CAAC;AACJ;GACD;AACH;MAEamE,YAAY,GAAGC,gBAAgB,CAACjC,eAAe;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../packages/virtual-table/src/middleware/loading/cell.tsx","../../../../packages/virtual-table/src/middleware/loading/row.tsx","../../../../packages/virtual-table/src/middleware/loading/index.tsx"],"sourcesContent":["import type { ColumnType } from '@are-visual/virtual-table'\nimport type { ReactElement } from 'react'\nimport { getKey, isValidFixed, isValidFixedLeft, isValidFixedRight, useTableSticky } from '@are-visual/virtual-table'\nimport clsx from 'clsx'\nimport { memo } from 'react'\n\nexport interface CellProps<T> {\n className?: string\n column: ColumnType<T>\n}\n\nfunction LoadingCell<T>(props: CellProps<T>) {\n const { column, className } = props\n\n const { align, fixed } = column\n const key = getKey(column)\n const { size: stickySizes } = useTableSticky()\n\n return (\n <td\n className={clsx(\n 'virtual-table-cell',\n className,\n align != null && `virtual-table-align-${align}`,\n isValidFixed(fixed) && 'virtual-table-sticky-cell',\n )}\n style={{\n left: isValidFixedLeft(fixed) ? stickySizes.get(key) : undefined,\n right: isValidFixedRight(fixed) ? stickySizes.get(key) : undefined,\n }}\n >\n <div className=\"virtual-table-loading-skeleton\" />\n </td>\n )\n}\n\nexport default memo(LoadingCell) as <T>(props: CellProps<T>) => ReactElement\n","import type { ColumnDescriptor } from '@are-visual/virtual-table'\nimport type { CSSProperties, Key, ReactElement } from 'react'\nimport { findLastIndex, isValidFixedLeft, isValidFixedRight, useTableRowManager } from '@are-visual/virtual-table'\nimport clsx from 'clsx'\nimport { memo } from 'react'\nimport LoadingCell from './cell'\n\nexport interface RowProps<T> {\n style?: CSSProperties\n descriptor: ColumnDescriptor<T>[]\n rowKey: Key\n}\n\nfunction LoadingRow<T>(props: RowProps<T>) {\n const { descriptor, style, rowKey } = props\n\n const { setRowHeightByRowKey } = useTableRowManager()\n\n const lastFixedLeftColumnIndex = findLastIndex(descriptor, (x) => {\n if (x.type === 'blank') {\n return false\n }\n return isValidFixedLeft(x.column.fixed)\n })\n const firstFixedRightColumnIndex = descriptor.findIndex((x) => {\n if (x.type === 'blank') {\n return false\n }\n return isValidFixedRight(x.column.fixed)\n })\n\n return (\n <tr\n className=\"virtual-table-row virtual-table-loading-cell\"\n style={style}\n ref={(node) => {\n if (node == null) return\n setRowHeightByRowKey(rowKey, 'loading-tr', node.offsetHeight)\n }}\n >\n {descriptor.map((item, index) => {\n const { key } = item\n if (item.type === 'blank') {\n return <td key={key} />\n }\n const { column } = item\n return (\n <LoadingCell\n key={key}\n className={clsx(\n lastFixedLeftColumnIndex === index && 'virtual-table-cell-fix-left-last',\n firstFixedRightColumnIndex === index\n && 'virtual-table-cell-fix-right-first',\n )}\n column={column}\n />\n )\n })}\n </tr>\n )\n}\n\nexport default memo(LoadingRow) as <T>(props: RowProps<T>) => ReactElement\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { MiddlewareContext, MiddlewareResult } from '@are-visual/virtual-table'\nimport type { CSSProperties, ReactElement } from 'react'\nimport { createMiddleware, onResize } from '@are-visual/virtual-table'\nimport { cloneElement, isValidElement, useEffect, useMemo, useState } from 'react'\nimport LoadingRow from './row'\n\nfunction useTableLoading<T = any>(\n ctx: MiddlewareContext<T>,\n options?: { loading?: boolean },\n): MiddlewareResult<T> {\n const { loading = false } = options ?? {}\n const { estimatedRowHeight, headerWrapperRef, getScroller } = ctx\n\n const [count, setCount] = useState(10)\n\n useEffect(() => {\n const header = headerWrapperRef.current\n const container = getScroller()\n if (container == null) return\n return onResize(container, ({ height }) => {\n const headerHeight = header?.offsetHeight ?? 0\n setCount(Math.ceil((height - headerHeight) / estimatedRowHeight))\n })\n }, [getScroller, headerWrapperRef, estimatedRowHeight])\n\n const fakeDataSource = useMemo(() => {\n return Array.from({ length: count }, (_, index) => {\n return { key: index }\n })\n }, [count])\n\n if (!loading) {\n return ctx\n }\n\n return {\n ...ctx,\n renderBodyRoot: (children) => {\n if (isValidElement(children)) {\n if (Object.prototype.hasOwnProperty.call(children.props, 'style')) {\n const style = (children.props as { style: CSSProperties }).style\n return cloneElement(children as ReactElement<{ style: CSSProperties }>, {\n style: {\n ...style,\n paddingBottom: undefined,\n paddingTop: undefined,\n },\n })\n }\n }\n return children\n },\n renderBodyContent: (_ignore, { columnDescriptor, startRowIndex }) => {\n return fakeDataSource.map((item, index) => {\n return (\n <LoadingRow\n key={item.key}\n style={{ height: estimatedRowHeight }}\n descriptor={columnDescriptor}\n rowKey={`__loading$-${index + startRowIndex}`}\n />\n )\n })\n },\n }\n}\n\nexport const tableLoading = createMiddleware(useTableLoading)\n"],"names":["LoadingCell","props","column","className","align","fixed","key","getKey","size","stickySizes","useTableSticky","_jsx","clsx","isValidFixed","style","left","isValidFixedLeft","get","undefined","right","isValidFixedRight","children","memo","LoadingRow","descriptor","rowKey","setRowHeightByRowKey","useTableRowManager","lastFixedLeftColumnIndex","findLastIndex","x","type","firstFixedRightColumnIndex","findIndex","ref","node","offsetHeight","map","item","index","useTableLoading","ctx","options","loading","estimatedRowHeight","headerWrapperRef","getScroller","count","setCount","useState","useEffect","header","current","container","onResize","_ref","height","headerHeight","Math","ceil","fakeDataSource","useMemo","Array","from","length","_","renderBodyRoot","isValidElement","Object","prototype","hasOwnProperty","call","cloneElement","paddingBottom","paddingTop","renderBodyContent","_ignore","_ref2","columnDescriptor","startRowIndex","tableLoading","createMiddleware"],"mappings":";;;;;AAWA,SAASA,WAAWA,CAAIC,KAAmB,EAAA;EACzC,MAAM;IAAEC,MAAM;AAAEC,IAAAA;AAAW,GAAA,GAAGF,KAAK;EAEnC,MAAM;IAAEG,KAAK;AAAEC,IAAAA;AA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AAIO,QAAQ,CAACpB,KAAkC,CAACa,KAAK;UAChE,oBAAO0D,YAAY,CAACnD,QAAkD,EAAE;AACtEP,YAAAA,KAAK,EAAE;AACL,cAAA,GAAGA,KAAK;AACR2D,cAAAA,aAAa,EAAEvD,SAAS;AACxBwD,cAAAA,UAAU,EAAExD;AACb;AACF,WAAA,CAAC;AACJ;AACF;AACA,MAAA,OAAOG,QAAQ;KAChB;AACDsD,IAAAA,iBAAiB,EAAEA,CAACC,OAAO,EAAAC,KAAA,KAAyC;MAAA,IAAvC;QAAEC,gBAAgB;AAAEC,QAAAA;AAAe,OAAA,GAAAF,KAAA;MAC9D,OAAOjB,cAAc,CAACvB,GAAG,CAAC,CAACC,IAAI,EAAEC,KAAK,KAAI;QACxC,OACE5B,GAAA,CAACY,YAAU,EAAA;AAETT,UAAAA,KAAK,EAAE;AAAE0C,YAAAA,MAAM,EAAEZ;WAAoB;AACrCpB,UAAAA,UAAU,EAAEsD,gBAAgB;AAC5BrD,UAAAA,MAAM,EAAE,CAAA,WAAA,EAAcc,KAAK,GAAGwC,aAAa,CAAA;AAAE,SAAA,EAHxCzC,IAAI,CAAChC,GAAG,CAIb;AAEN,OAAC,CAAC;AACJ;GACD;AACH;MAEa0E,YAAY,GAAGC,gBAAgB,CAACzC,eAAe;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _are_visual_virtual_table from '@are-visual/virtual-table';
|
|
2
2
|
import { ColumnExtra } from '@are-visual/virtual-table';
|
|
3
|
-
import {
|
|
3
|
+
import { ComponentType, Key, ReactNode, HTMLAttributes, TdHTMLAttributes } from 'react';
|
|
4
4
|
|
|
5
5
|
type RowSelectMethod = 'all' | 'none' | 'invert' | 'single' | 'multiple';
|
|
6
6
|
type SelectionSelectFn<T = any> = (record: T, selected: boolean, selectedRows: T[], nativeEvent: Event) => void;
|
|
@@ -45,4 +45,5 @@ declare const SELECTION_COLUMN_KEY = "VirtualTable.SELECTION_COLUMN";
|
|
|
45
45
|
*/
|
|
46
46
|
declare const tableSelection: <T = any>(options?: TableRowSelection<T> | undefined) => _are_visual_virtual_table.Middleware<T>;
|
|
47
47
|
|
|
48
|
-
export {
|
|
48
|
+
export { SELECTION_COLUMN_KEY, tableSelection };
|
|
49
|
+
export type { GetComponentProps, RowSelectMethod, SelectionColumnTitleProps, SelectionProps, SelectionSelectFn, TableRowSelection };
|
|
@@ -1,15 +1,27 @@
|
|
|
1
1
|
import * as _are_visual_virtual_table from '@are-visual/virtual-table';
|
|
2
|
-
import { ColumnType } from '@are-visual/virtual-table';
|
|
2
|
+
import { ColumnType, ColumnDescriptor } from '@are-visual/virtual-table';
|
|
3
3
|
import * as react from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { DetailedHTMLProps, HTMLAttributes, Key, CSSProperties, ReactNode, MouseEvent, ReactElement } from 'react';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
6
|
|
|
7
7
|
type NativeProps = DetailedHTMLProps<HTMLAttributes<HTMLTableCellElement>, HTMLTableCellElement>;
|
|
8
8
|
interface CellProps extends NativeProps, Pick<ColumnType<unknown>, 'align'> {
|
|
9
|
-
columnKey
|
|
9
|
+
columnKey?: Key;
|
|
10
10
|
colSpan?: number;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
interface FooterProps {
|
|
14
|
+
className?: string;
|
|
15
|
+
style?: CSSProperties;
|
|
16
|
+
/** Summary 位于底部,且设置 fixed 时生效 */
|
|
17
|
+
zIndex?: number;
|
|
18
|
+
/** Summary 位于底部,且设置 fixed 时生效 */
|
|
19
|
+
bottom?: number | string;
|
|
20
|
+
columns: ColumnDescriptor[];
|
|
21
|
+
fixed?: boolean;
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
}
|
|
24
|
+
|
|
13
25
|
interface SummaryOutletProps<T> {
|
|
14
26
|
className?: string;
|
|
15
27
|
style?: CSSProperties;
|
|
@@ -44,10 +56,11 @@ declare module '@are-visual/virtual-table' {
|
|
|
44
56
|
summary?: InlineCellProps<T>;
|
|
45
57
|
}
|
|
46
58
|
}
|
|
47
|
-
interface TableSummaryOptions<T = any> {
|
|
59
|
+
interface TableSummaryOptions<T = any> extends Pick<FooterProps, 'bottom' | 'className' | 'style' | 'zIndex'> {
|
|
48
60
|
summary: (data: T[]) => ReactNode;
|
|
49
61
|
}
|
|
50
62
|
|
|
51
63
|
declare const tableSummary: <T = any>(options?: TableSummaryOptions<T> | undefined) => _are_visual_virtual_table.Middleware<T>;
|
|
52
64
|
|
|
53
|
-
export {
|
|
65
|
+
export { Summary, tableSummary };
|
|
66
|
+
export type { InlineCellProps, TableSummaryOptions };
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
2
2
|
import { useHorizontalScrollContext, Colgroup, useTableSticky, isValidFixedLeft, isValidFixedRight, isValidFixed, createMiddleware } from '@are-visual/virtual-table';
|
|
3
|
-
import { createContext, useState, useRef, useEffect, memo, useMemo, useContext, createElement, Fragment, isValidElement, Children } from 'react';
|
|
4
|
-
import { getScrollbarSize } from '@are-visual/virtual-table/middleware/utils/getScrollbarSize';
|
|
5
3
|
import clsx from 'clsx';
|
|
4
|
+
import { createContext, useState, useRef, useEffect, memo, useMemo, useContext, createElement, isValidElement, cloneElement, Fragment, Children } from 'react';
|
|
5
|
+
import { getScrollbarSize } from '@are-visual/virtual-table/middleware/utils/getScrollbarSize';
|
|
6
6
|
|
|
7
7
|
const SummaryContext = /*#__PURE__*/createContext(null);
|
|
8
8
|
|
|
9
9
|
const Footer = props => {
|
|
10
10
|
const {
|
|
11
|
+
className,
|
|
12
|
+
style,
|
|
13
|
+
zIndex,
|
|
14
|
+
bottom,
|
|
11
15
|
columns,
|
|
12
16
|
fixed,
|
|
13
17
|
children
|
|
@@ -38,8 +42,13 @@ const Footer = props => {
|
|
|
38
42
|
};
|
|
39
43
|
}, [listen, notify]);
|
|
40
44
|
return jsx("div", {
|
|
41
|
-
className: clsx('virtual-table-summary-wrapper', fixed && 'virtual-table-summary-sticky-bottom virtual-table-summary-top-border'),
|
|
45
|
+
className: clsx('virtual-table-summary-wrapper', fixed && 'virtual-table-summary-sticky-bottom virtual-table-summary-top-border', className),
|
|
42
46
|
style: {
|
|
47
|
+
...(fixed ? {
|
|
48
|
+
'--virtual-table-summary-z-index': zIndex,
|
|
49
|
+
'--virtual-table-summary-sticky-bottom': Number.isFinite(bottom) ? `${bottom}px` : bottom
|
|
50
|
+
} : {}),
|
|
51
|
+
...style,
|
|
43
52
|
paddingBottom: scrollbarHeight
|
|
44
53
|
},
|
|
45
54
|
ref: wrapperRef,
|
|
@@ -69,7 +78,7 @@ function Cell(props) {
|
|
|
69
78
|
size: stickySizes,
|
|
70
79
|
fixed: columnsFixed
|
|
71
80
|
} = useTableSticky();
|
|
72
|
-
const stickySize = stickySizes.get(columnKey);
|
|
81
|
+
const stickySize = columnKey == null ? 0 : stickySizes.get(columnKey);
|
|
73
82
|
const fixed = columnsFixed.find(x => x.key === columnKey)?.fixed;
|
|
74
83
|
const {
|
|
75
84
|
left: lastFixedLeftColumnKey,
|
|
@@ -158,8 +167,14 @@ const SummaryRow = _ref => {
|
|
|
158
167
|
const {
|
|
159
168
|
column
|
|
160
169
|
} = item;
|
|
170
|
+
let childNode = children(column, key);
|
|
171
|
+
if (/*#__PURE__*/isValidElement(childNode) && childNode.type === Cell$1) {
|
|
172
|
+
childNode = /*#__PURE__*/cloneElement(childNode, {
|
|
173
|
+
columnKey: key
|
|
174
|
+
});
|
|
175
|
+
}
|
|
161
176
|
return jsx(Fragment, {
|
|
162
|
-
children:
|
|
177
|
+
children: childNode
|
|
163
178
|
}, key);
|
|
164
179
|
})
|
|
165
180
|
});
|
|
@@ -184,6 +199,10 @@ Summary.Outlet = SummaryOutlet;
|
|
|
184
199
|
|
|
185
200
|
function useTableSummary(ctx, options) {
|
|
186
201
|
const {
|
|
202
|
+
className,
|
|
203
|
+
style,
|
|
204
|
+
zIndex,
|
|
205
|
+
bottom,
|
|
187
206
|
summary
|
|
188
207
|
} = options ?? {};
|
|
189
208
|
const {
|
|
@@ -242,7 +261,8 @@ function useTableSummary(ctx, options) {
|
|
|
242
261
|
} = _ref;
|
|
243
262
|
return jsxs(Fragment$1, {
|
|
244
263
|
children: [children, jsx("tfoot", {
|
|
245
|
-
className:
|
|
264
|
+
className: clsx('virtual-table-summary-tfoot', className),
|
|
265
|
+
style: style,
|
|
246
266
|
children: jsx(SummaryContext.Provider, {
|
|
247
267
|
value: columnDescriptor,
|
|
248
268
|
children: topNode
|
|
@@ -258,6 +278,10 @@ function useTableSummary(ctx, options) {
|
|
|
258
278
|
} = _ref2;
|
|
259
279
|
return jsxs(Fragment$1, {
|
|
260
280
|
children: [children, jsx(Footer, {
|
|
281
|
+
className: className,
|
|
282
|
+
style: style,
|
|
283
|
+
zIndex: zIndex,
|
|
284
|
+
bottom: bottom,
|
|
261
285
|
fixed: hasFixedBottom,
|
|
262
286
|
columns: columnDescriptor,
|
|
263
287
|
children: jsx(SummaryContext.Provider, {
|
|
@@ -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 { 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 columns: ColumnDescriptor[]\n fixed?: boolean\n children?: ReactNode\n}\n\nconst Footer: FC<FooterProps> = (props) => {\n const { 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 )}\n style={{ paddingBottom: scrollbarHeight }}\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 = 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, ReactNode } from 'react'\nimport { Fragment, useContext } from 'react'\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 return <Fragment key={key}>{children(column, key)}</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 { SummaryProps } from './summary'\nimport { createMiddleware } from '@are-visual/virtual-table'\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> {\n summary: (data: T[]) => ReactNode\n}\n\nfunction useTableSummary<T = any>(\n ctx: MiddlewareContext<T>,\n options?: TableSummaryOptions<T>,\n): MiddlewareResult<T> {\n const { 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=\"virtual-table-summary-tfoot\">\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 fixed={hasFixedBottom} columns={columnDescriptor}>\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","columns","fixed","children","listen","notify","useHorizontalScrollContext","scrollbarHeight","useState","getScrollbarSize","height","wrapperRef","useRef","useEffect","node","current","key","onScroll","scrollLeft","dispose","addEventListener","removeEventListener","_jsx","className","clsx","style","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","Fragment","Summary","Row","Outlet","useTableSummary","ctx","options","hasFixedTop","hasFixedBottom","summaryNode","topNode","bottomNode","handleRowElement","push","isValidElement","rawChildren","Children","forEach","child","__DEV__","console","warn","error","renderHeader","columnDescriptor","Provider","value","renderContent","_ref2","_Fragment","tableSummary","createMiddleware"],"mappings":";;;;;;AAGO,MAAMA,cAAc,gBAAGC,aAAa,CAA4B,IAAI,CAAC;;ACU5E,MAAMC,MAAM,GAAqBC,KAAK,IAAI;EACxC,MAAM;IAAEC,OAAO;IAAEC,KAAK;AAAEC,IAAAA;AAAQ,GAAE,GAAGH,KAAK;EAE1C,MAAM;IAAEI,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,G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Q,EACTmB,GAAC,CAAAvB,MAAM,EAAC;AAAAG,YAAAA,KAAK,EAAE4E,cAAc;AAAE7E,YAAAA,OAAO,EAAE6F,gBAAgB;AACtD3F,YAAAA,QAAA,EAAAmB,GAAA,CAACzB,cAAc,CAACkG,QAAQ,EAAA;AAACC,cAAAA,KAAK,EAAEF,gBAAgB;AAAA3F,cAAAA,QAAA,EAC7C8E;aAAU;AAEN,WAAA,CAAA;AAAA,SAAA,CACR;AAEP;KACD,GACD,EAAE;GACP;AACH;MAGamB,YAAY,GAAGC,gBAAgB,CAAC3B,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, 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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Ac;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;;;;"}
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
}
|
|
20
20
|
.virtual-table-summary-sticky-bottom {
|
|
21
21
|
position: sticky;
|
|
22
|
-
bottom:
|
|
22
|
+
bottom: var(--virtual-table-summary-sticky-bottom, 0px);
|
|
23
23
|
left: 0;
|
|
24
|
-
z-index: 2;
|
|
24
|
+
z-index: var(--virtual-table-summary-sticky-z-index, 2);
|
|
25
25
|
}
|
|
26
26
|
.virtual-table-summary-tfoot {
|
|
27
27
|
background-color: var(--virtual-table-summary-background, #fff);
|