@v-c/table 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Cell/index.js +2 -3
- package/dist/Table.js +10 -8
- package/dist/hooks/useColumns/index.d.ts +4 -2
- package/dist/hooks/useColumns/index.js +12 -2
- package/dist/hooks/useExpand.d.ts +5 -2
- package/dist/hooks/useExpand.js +40 -3
- package/dist/hooks/useFixedInfo.d.ts +1 -1
- package/dist/hooks/useRowInfo.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/interface.d.ts +24 -3
- package/dist/sugar/Column.js +9 -0
- package/dist/sugar/ColumnGroup.js +9 -0
- package/dist/utils/expandUtil.d.ts +5 -1
- package/dist/utils/expandUtil.js +41 -8
- package/dist/utils/valueUtil.d.ts +0 -1
- package/dist/utils/valueUtil.js +1 -5
- package/package.json +3 -3
package/dist/Cell/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { useInjectTableContext } from "../context/TableContext.js";
|
|
2
2
|
import { useInjectPerfContext } from "../context/PerfContext.js";
|
|
3
|
-
import { validateValue } from "../utils/valueUtil.js";
|
|
4
3
|
import useHoverState from "./useHoverState.js";
|
|
5
4
|
import { computed, createVNode, defineComponent, isVNode, mergeProps, shallowRef, toRaw, watch } from "vue";
|
|
6
|
-
import { clsx, warning } from "@v-c/util";
|
|
5
|
+
import { clsx, isNonNullable, warning } from "@v-c/util";
|
|
7
6
|
import { filterEmpty, getStylePxValue } from "@v-c/util/dist/props-util";
|
|
8
7
|
import getValue from "@v-c/util/dist/utils/get";
|
|
9
8
|
//#region src/Cell/index.tsx
|
|
@@ -24,7 +23,7 @@ function isRenderCell(data) {
|
|
|
24
23
|
return data && typeof data === "object" && !Array.isArray(data) && !isVNode(data);
|
|
25
24
|
}
|
|
26
25
|
function resolveCellRender({ record, dataIndex, renderIndex, children, render, perfRecord }) {
|
|
27
|
-
if (
|
|
26
|
+
if (isNonNullable(children)) return [children];
|
|
28
27
|
const value = getValue(record, dataIndex === null || dataIndex === void 0 || dataIndex === "" ? [] : Array.isArray(dataIndex) ? dataIndex : [dataIndex]);
|
|
29
28
|
let returnChildNode = value;
|
|
30
29
|
let returnCellProps;
|
package/dist/Table.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useProvideTableContext } from "./context/TableContext.js";
|
|
2
2
|
import ColGroup from "./ColGroup.js";
|
|
3
|
-
import { getColumnsKey, validNumberValue
|
|
3
|
+
import { getColumnsKey, validNumberValue } from "./utils/valueUtil.js";
|
|
4
4
|
import Body from "./Body/index.js";
|
|
5
5
|
import { EXPAND_COLUMN, INTERNAL_HOOKS } from "./constant.js";
|
|
6
6
|
import FixedHolder from "./FixedHolder/index.js";
|
|
@@ -19,7 +19,7 @@ import Column from "./sugar/Column.js";
|
|
|
19
19
|
import ColumnGroup from "./sugar/ColumnGroup.js";
|
|
20
20
|
import { Fragment, computed, createVNode, defineComponent, isVNode, mergeDefaults, mergeProps, nextTick, onMounted, reactive, ref, shallowRef, watch, watchEffect } from "vue";
|
|
21
21
|
import ResizeObserver from "@v-c/resize-observer";
|
|
22
|
-
import { clsx, get, warning } from "@v-c/util";
|
|
22
|
+
import { clsx, get, isNonNullable, isVueRenderable, warning } from "@v-c/util";
|
|
23
23
|
import canUseDom from "@v-c/util/dist/Dom/canUseDom";
|
|
24
24
|
import { getDOM } from "@v-c/util/dist/Dom/findDOMNode";
|
|
25
25
|
import { getTargetScrollBarSize } from "@v-c/util/dist/getScrollBarSize";
|
|
@@ -86,7 +86,7 @@ var ImmutableTable = /* @__PURE__ */ defineComponent((props, { attrs, slots, exp
|
|
|
86
86
|
});
|
|
87
87
|
const customizeScrollBody = computed(() => getComponent(["body"]));
|
|
88
88
|
const [startRow, endRow, onHover] = useHover();
|
|
89
|
-
const [expandableConfig, expandableType, mergedExpandedKeys, mergedExpandIcon, mergedChildrenColumnName, onTriggerExpand] = useExpand(props, mergedData, getRowKey);
|
|
89
|
+
const [expandableConfig, expandableType, mergedExpandedKeys, mergedExpandIcon, mergedChildrenColumnName, onTriggerExpand, expandAllInfo] = useExpand(props, mergedData, getRowKey);
|
|
90
90
|
const componentWidth = ref(0);
|
|
91
91
|
const slotChildren = shallowRef(null);
|
|
92
92
|
const [columns, flattenColumns, flattenScrollX] = useColumns({
|
|
@@ -99,6 +99,8 @@ var ImmutableTable = /* @__PURE__ */ defineComponent((props, { attrs, slots, exp
|
|
|
99
99
|
getRowKey,
|
|
100
100
|
onTriggerExpand,
|
|
101
101
|
expandIcon: mergedExpandIcon,
|
|
102
|
+
ExpandIcon: computed(() => props.components?.ExpandIcon),
|
|
103
|
+
expandAllInfo,
|
|
102
104
|
rowExpandable: computed(() => expandableConfig.value.rowExpandable),
|
|
103
105
|
expandIconColumnIndex: computed(() => expandableConfig.value.expandIconColumnIndex),
|
|
104
106
|
expandedRowOffset: expandableConfig.value.expandedRowOffset,
|
|
@@ -148,8 +150,8 @@ var ImmutableTable = /* @__PURE__ */ defineComponent((props, { attrs, slots, exp
|
|
|
148
150
|
...stickyOffsets.value,
|
|
149
151
|
isSticky: stickyConfig.value.isSticky
|
|
150
152
|
}));
|
|
151
|
-
const fixHeader = computed(() => !!(props.scroll &&
|
|
152
|
-
const horizonScroll = computed(() => !!(props.scroll &&
|
|
153
|
+
const fixHeader = computed(() => !!(props.scroll && isNonNullable(props.scroll.y)));
|
|
154
|
+
const horizonScroll = computed(() => !!(props.scroll && isNonNullable(mergedScrollX.value)) || !!expandableConfig.value.fixed);
|
|
153
155
|
const fixColumn = computed(() => horizonScroll.value && flattenColumns.value.some(({ fixed }) => fixed));
|
|
154
156
|
const summaryNode = computed(() => props.summary?.(mergedData.value));
|
|
155
157
|
const fixFooter = computed(() => {
|
|
@@ -380,7 +382,7 @@ var ImmutableTable = /* @__PURE__ */ defineComponent((props, { attrs, slots, exp
|
|
|
380
382
|
"colWidths": flattenColumns.value.map(({ width }) => width),
|
|
381
383
|
"columns": flattenColumns.value
|
|
382
384
|
}, null);
|
|
383
|
-
const captionElement = props.caption
|
|
385
|
+
const captionElement = isNonNullable(props.caption) ? createVNode("caption", { "class": `${mergedPrefixCls.value}-caption` }, [props.caption]) : void 0;
|
|
384
386
|
let groupTableNode;
|
|
385
387
|
if (fixHeader.value || stickyConfig.value.isSticky) {
|
|
386
388
|
let bodyContent;
|
|
@@ -406,7 +408,7 @@ var ImmutableTable = /* @__PURE__ */ defineComponent((props, { attrs, slots, exp
|
|
|
406
408
|
captionElement,
|
|
407
409
|
bodyColGroupNode,
|
|
408
410
|
bodyTableNode,
|
|
409
|
-
!fixFooter.value && summaryNode.value && createVNode(Footer, {
|
|
411
|
+
!fixFooter.value && isVueRenderable(summaryNode.value) && createVNode(Footer, {
|
|
410
412
|
"stickyOffsets": mergedStickyOffsets.value,
|
|
411
413
|
"flattenColumns": flattenColumns.value
|
|
412
414
|
}, { default: () => [summaryNode.value] })
|
|
@@ -469,7 +471,7 @@ var ImmutableTable = /* @__PURE__ */ defineComponent((props, { attrs, slots, exp
|
|
|
469
471
|
"flattenColumns": flattenColumns.value
|
|
470
472
|
}), null),
|
|
471
473
|
bodyTableNode,
|
|
472
|
-
!fixFooter.value && summaryNode.value && createVNode(Footer, {
|
|
474
|
+
!fixFooter.value && isVueRenderable(summaryNode.value) && createVNode(Footer, {
|
|
473
475
|
"stickyOffsets": mergedStickyOffsets.value,
|
|
474
476
|
"flattenColumns": flattenColumns.value
|
|
475
477
|
}, { default: () => [summaryNode.value] })
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Ref } from 'vue';
|
|
2
|
-
import { ColumnsType, ColumnType, Direction, FixedType, GetRowKey, Key, RenderExpandIcon, TriggerEventHandler } from '../../interface';
|
|
2
|
+
import { ColumnsType, ColumnType, Direction, ExpandColumnTitle, ExpandIconComponent, ExpandIconProps, FixedType, GetRowKey, Key, RenderExpandIcon, TriggerEventHandler } from '../../interface';
|
|
3
3
|
export declare function convertChildrenToColumns<RecordType>(children: any): ColumnsType<RecordType>;
|
|
4
4
|
export default function useColumns<RecordType>(options: {
|
|
5
5
|
prefixCls?: Ref<string> | string;
|
|
@@ -7,10 +7,12 @@ export default function useColumns<RecordType>(options: {
|
|
|
7
7
|
children?: any;
|
|
8
8
|
expandable: Ref<boolean> | boolean;
|
|
9
9
|
expandedKeys: Ref<Set<Key>> | Set<Key>;
|
|
10
|
-
columnTitle?: Ref<
|
|
10
|
+
columnTitle?: Ref<ExpandColumnTitle | undefined> | ExpandColumnTitle;
|
|
11
11
|
getRowKey: Ref<GetRowKey<RecordType>> | GetRowKey<RecordType>;
|
|
12
12
|
onTriggerExpand: TriggerEventHandler<RecordType>;
|
|
13
13
|
expandIcon?: Ref<RenderExpandIcon<RecordType> | undefined> | RenderExpandIcon<RecordType>;
|
|
14
|
+
ExpandIcon?: Ref<ExpandIconComponent<RecordType> | undefined> | ExpandIconComponent<RecordType>;
|
|
15
|
+
expandAllInfo?: Ref<Pick<ExpandIconProps<RecordType>, 'expanded' | 'expandable' | 'onClick'> | undefined>;
|
|
14
16
|
rowExpandable?: Ref<((record: RecordType) => boolean) | undefined> | ((record: RecordType) => boolean) | undefined;
|
|
15
17
|
expandIconColumnIndex?: Ref<number | undefined> | number;
|
|
16
18
|
expandedRowOffset?: number;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { INTERNAL_COL_DEFINE } from "../../utils/legacyUtil.js";
|
|
2
|
+
import { DefaultExpandIcon } from "../../utils/expandUtil.js";
|
|
2
3
|
import { EXPAND_COLUMN } from "../../constant.js";
|
|
3
4
|
import useWidthColumns from "./useWidthColumns.js";
|
|
4
|
-
import { computed, createVNode, isVNode, toRaw, unref } from "vue";
|
|
5
|
+
import { computed, createVNode, h, isVNode, toRaw, unref } from "vue";
|
|
5
6
|
import { warning } from "@v-c/util";
|
|
6
7
|
import { flattenChildren } from "@v-c/util/dist/props-util";
|
|
7
8
|
//#region src/hooks/useColumns/index.tsx
|
|
@@ -75,12 +76,21 @@ function useColumns(options, transformColumns) {
|
|
|
75
76
|
if (fixed) fixedColumn = fixed;
|
|
76
77
|
else fixedColumn = prevColumn?.fixed;
|
|
77
78
|
const prefixCls = unref(options.prefixCls) || "";
|
|
79
|
+
const MergedExpandIcon = unref(options.ExpandIcon) || DefaultExpandIcon;
|
|
80
|
+
const expandAllInfo = unref(options.expandAllInfo);
|
|
81
|
+
const expandAllNode = expandAllInfo ? h(MergedExpandIcon, {
|
|
82
|
+
type: "all",
|
|
83
|
+
prefixCls,
|
|
84
|
+
...expandAllInfo
|
|
85
|
+
}) : void 0;
|
|
86
|
+
const columnTitle = unref(options.columnTitle);
|
|
87
|
+
const mergedColumnTitle = typeof columnTitle === "function" ? columnTitle({ expandIcon: expandAllNode }) : columnTitle ?? expandAllNode;
|
|
78
88
|
const expandColumn = {
|
|
79
89
|
[INTERNAL_COL_DEFINE]: {
|
|
80
90
|
className: `${prefixCls}-expand-icon-col`,
|
|
81
91
|
columnType: "EXPAND_COLUMN"
|
|
82
92
|
},
|
|
83
|
-
title:
|
|
93
|
+
title: mergedColumnTitle,
|
|
84
94
|
fixed: fixedColumn,
|
|
85
95
|
className: `${prefixCls}-row-expand-icon-cell`,
|
|
86
96
|
width: unref(options.columnWidth),
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { Ref } from 'vue';
|
|
2
|
-
import { ExpandableConfig, ExpandableType, GetRowKey, Key, RenderExpandIcon, TriggerEventHandler } from '../interface';
|
|
2
|
+
import { ExpandableConfig, ExpandableType, ExpandIconProps, GetRowKey, Key, RenderExpandIcon, TriggerEventHandler } from '../interface';
|
|
3
3
|
import { TableProps } from '../Table';
|
|
4
|
+
type ExpandAllInfo<RecordType> = Pick<ExpandIconProps<RecordType>, 'expanded' | 'expandable' | 'onClick'>;
|
|
4
5
|
export default function useExpand<RecordType>(props: TableProps<RecordType>, mergedData: Ref<readonly RecordType[]> | readonly RecordType[], getRowKey: Ref<GetRowKey<RecordType>> | GetRowKey<RecordType>): [
|
|
5
6
|
expandableConfig: Ref<ExpandableConfig<RecordType>>,
|
|
6
7
|
expandableType: Ref<ExpandableType>,
|
|
7
8
|
expandedKeys: Ref<Set<Key>>,
|
|
8
9
|
expandIcon: Ref<RenderExpandIcon<RecordType>>,
|
|
9
10
|
childrenColumnName: Ref<string>,
|
|
10
|
-
onTriggerExpand: TriggerEventHandler<RecordType
|
|
11
|
+
onTriggerExpand: TriggerEventHandler<RecordType>,
|
|
12
|
+
expandAllInfo: Ref<ExpandAllInfo<RecordType> | undefined>
|
|
11
13
|
];
|
|
14
|
+
export {};
|
package/dist/hooks/useExpand.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { getExpandableProps } from "../utils/legacyUtil.js";
|
|
2
|
-
import { findAllChildrenKeys, renderExpandIcon } from "../utils/expandUtil.js";
|
|
2
|
+
import { findAllChildrenKeys, renderExpandIcon, renderRowExpandIcon } from "../utils/expandUtil.js";
|
|
3
3
|
import "../constant.js";
|
|
4
4
|
import { computed, ref, unref } from "vue";
|
|
5
5
|
import { warning } from "@v-c/util";
|
|
6
6
|
//#region src/hooks/useExpand.ts
|
|
7
7
|
function useExpand(props, mergedData, getRowKey) {
|
|
8
8
|
const expandableConfig = computed(() => getExpandableProps(props));
|
|
9
|
-
const mergedExpandIcon = computed(() =>
|
|
9
|
+
const mergedExpandIcon = computed(() => {
|
|
10
|
+
const customizeExpandIcon = props.components?.ExpandIcon;
|
|
11
|
+
if (customizeExpandIcon) return (iconProps) => renderRowExpandIcon(customizeExpandIcon, iconProps);
|
|
12
|
+
return expandableConfig.value.expandIcon || renderExpandIcon;
|
|
13
|
+
});
|
|
10
14
|
const mergedChildrenColumnName = computed(() => expandableConfig.value.childrenColumnName || "children");
|
|
11
15
|
const expandableType = computed(() => {
|
|
12
16
|
if (expandableConfig.value.expandedRowRender) return "row";
|
|
@@ -37,6 +41,38 @@ function useExpand(props, mergedData, getRowKey) {
|
|
|
37
41
|
props["onUpdate:expandedRowKeys"]?.(Array.from(newExpandedKeys));
|
|
38
42
|
event?.stopPropagation?.();
|
|
39
43
|
};
|
|
44
|
+
const expandableRows = computed(() => {
|
|
45
|
+
if (!expandableConfig.value.showExpandAll || expandableType.value !== "row") return [];
|
|
46
|
+
const rowExpandable = expandableConfig.value.rowExpandable;
|
|
47
|
+
return (unref(mergedData) || []).reduce((rows, record, index) => {
|
|
48
|
+
if (!rowExpandable || rowExpandable(record)) rows.push({
|
|
49
|
+
key: unref(getRowKey)(record, index),
|
|
50
|
+
record
|
|
51
|
+
});
|
|
52
|
+
return rows;
|
|
53
|
+
}, []);
|
|
54
|
+
});
|
|
55
|
+
const allExpanded = computed(() => expandableRows.value.length > 0 && expandableRows.value.every(({ key }) => mergedExpandedKeys.value.has(key)));
|
|
56
|
+
const onTriggerExpandAll = (event) => {
|
|
57
|
+
event.stopPropagation();
|
|
58
|
+
if (!expandableRows.value.length) return;
|
|
59
|
+
const nextExpanded = !allExpanded.value;
|
|
60
|
+
const nextExpandedKeys = new Set(mergedExpandedKeys.value);
|
|
61
|
+
expandableRows.value.forEach(({ key }) => {
|
|
62
|
+
if (nextExpanded) nextExpandedKeys.add(key);
|
|
63
|
+
else nextExpandedKeys.delete(key);
|
|
64
|
+
});
|
|
65
|
+
const keys = [...nextExpandedKeys];
|
|
66
|
+
innerExpandedKeys.value = keys;
|
|
67
|
+
expandableConfig.value.onExpandAll?.(nextExpanded);
|
|
68
|
+
expandableConfig.value.onExpandedRowsChange?.(keys);
|
|
69
|
+
props["onUpdate:expandedRowKeys"]?.(keys);
|
|
70
|
+
};
|
|
71
|
+
const expandAllInfo = computed(() => expandableConfig.value.showExpandAll && expandableType.value === "row" ? {
|
|
72
|
+
expanded: allExpanded.value,
|
|
73
|
+
expandable: expandableRows.value.length > 0,
|
|
74
|
+
onClick: onTriggerExpandAll
|
|
75
|
+
} : void 0);
|
|
40
76
|
if (process.env.NODE_ENV !== "production" && expandableConfig.value.expandedRowRender && (unref(mergedData) || []).some((record) => {
|
|
41
77
|
return Array.isArray(record?.[mergedChildrenColumnName.value]);
|
|
42
78
|
})) warning(false, "`expandedRowRender` should not use with nested Table");
|
|
@@ -46,7 +82,8 @@ function useExpand(props, mergedData, getRowKey) {
|
|
|
46
82
|
mergedExpandedKeys,
|
|
47
83
|
mergedExpandIcon,
|
|
48
84
|
mergedChildrenColumnName,
|
|
49
|
-
onTriggerExpand
|
|
85
|
+
onTriggerExpand,
|
|
86
|
+
expandAllInfo
|
|
50
87
|
];
|
|
51
88
|
}
|
|
52
89
|
//#endregion
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Ref } from 'vue';
|
|
2
2
|
import { ColumnType, StickyOffsets } from '../interface';
|
|
3
|
-
export default function useFixedInfo<RecordType>(flattenColumns: Ref<readonly ColumnType<RecordType>[]> | readonly ColumnType<RecordType>[], stickyOffsets: Ref<StickyOffsets> | StickyOffsets):
|
|
3
|
+
export default function useFixedInfo<RecordType>(flattenColumns: Ref<readonly ColumnType<RecordType>[]> | readonly ColumnType<RecordType>[], stickyOffsets: Ref<StickyOffsets> | StickyOffsets): Ref<import('../utils/fixUtil').FixedInfo[], import('../utils/fixUtil').FixedInfo[]>;
|
|
@@ -8,7 +8,7 @@ export default function useRowInfo<RecordType>(record: Ref<RecordType> | RecordT
|
|
|
8
8
|
rowSupportExpand: import('vue').ComputedRef<boolean>;
|
|
9
9
|
expandable: import('vue').ComputedRef<boolean>;
|
|
10
10
|
rowProps: import('vue').ComputedRef<{
|
|
11
|
-
className:
|
|
11
|
+
className: string;
|
|
12
12
|
onClick: (event: MouseEvent) => void;
|
|
13
13
|
innerHTML?: string | undefined | undefined;
|
|
14
14
|
class?: import('vue').ClassValue;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColumnsType, ColumnType, DataIndex, ExpandableConfig, FixedType, GetComponentProps, GetRowKey, Reference, RenderedCell } from './interface';
|
|
1
|
+
import { ColumnsType, ColumnType, DataIndex, ExpandableConfig, ExpandIconComponent, ExpandIconProps, FixedType, GetComponentProps, GetRowKey, Reference, RenderedCell } from './interface';
|
|
2
2
|
import { TableProps, default as Table } from './Table';
|
|
3
3
|
import { VirtualTableProps, default as VirtualTable } from './VirtualTable';
|
|
4
4
|
import { EXPAND_COLUMN, INTERNAL_HOOKS } from './constant';
|
|
@@ -6,6 +6,6 @@ import { FooterComponents as Summary, SummaryCell, SummaryRow } from './Footer';
|
|
|
6
6
|
import { default as Column } from './sugar/Column';
|
|
7
7
|
import { default as ColumnGroup } from './sugar/ColumnGroup';
|
|
8
8
|
import { INTERNAL_COL_DEFINE } from './utils/legacyUtil';
|
|
9
|
-
export type { DataIndex, ExpandableConfig, FixedType, GetComponentProps, GetRowKey, RenderedCell, };
|
|
9
|
+
export type { DataIndex, ExpandableConfig, ExpandIconComponent, ExpandIconProps, FixedType, GetComponentProps, GetRowKey, RenderedCell, };
|
|
10
10
|
export { Column, ColumnGroup, type ColumnsType, type ColumnType, EXPAND_COLUMN, INTERNAL_COL_DEFINE, INTERNAL_HOOKS, type Reference, Summary, SummaryCell, SummaryRow, type TableProps, VirtualTable, type VirtualTableProps, };
|
|
11
11
|
export default Table;
|
package/dist/interface.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VueNode } from '@v-c/util';
|
|
2
|
-
import { CSSProperties, HTMLAttributes, Ref, TdHTMLAttributes } from 'vue';
|
|
2
|
+
import { CSSProperties, HTMLAttributes, Ref, TdHTMLAttributes, Component as VueComponent } from 'vue';
|
|
3
3
|
import { DeepNamePath } from './namePathType';
|
|
4
4
|
export type Key = string | number;
|
|
5
5
|
/**
|
|
@@ -118,6 +118,7 @@ export type CustomizeScrollBody<RecordType = Record<string, any>> = (data: reado
|
|
|
118
118
|
onScroll: OnCustomizeScroll;
|
|
119
119
|
}) => any;
|
|
120
120
|
export interface TableComponents<RecordType> {
|
|
121
|
+
ExpandIcon?: ExpandIconComponent<RecordType>;
|
|
121
122
|
table?: CustomizeComponent;
|
|
122
123
|
header?: {
|
|
123
124
|
table?: CustomizeComponent;
|
|
@@ -142,7 +143,7 @@ export interface LegacyExpandableProps<RecordType> {
|
|
|
142
143
|
expandedRowRender?: ExpandedRowRender<RecordType>;
|
|
143
144
|
/** @deprecated Use `expandable.expandRowByClick` instead */
|
|
144
145
|
expandRowByClick?: boolean;
|
|
145
|
-
/** @deprecated Use `
|
|
146
|
+
/** @deprecated Use `components.ExpandIcon` instead */
|
|
146
147
|
expandIcon?: RenderExpandIcon<RecordType>;
|
|
147
148
|
/** @deprecated Use `expandable.onExpand` instead */
|
|
148
149
|
onExpand?: (expanded: boolean, record: RecordType) => void;
|
|
@@ -169,21 +170,41 @@ export interface RenderExpandIconProps<RecordType> {
|
|
|
169
170
|
onExpand: TriggerEventHandler<RecordType>;
|
|
170
171
|
}
|
|
171
172
|
export type RenderExpandIcon<RecordType> = (props: RenderExpandIconProps<RecordType>) => any;
|
|
173
|
+
export type ExpandIconProps<RecordType> = {
|
|
174
|
+
prefixCls: string;
|
|
175
|
+
expanded: boolean;
|
|
176
|
+
expandable: boolean;
|
|
177
|
+
onClick: (event: MouseEvent) => void;
|
|
178
|
+
} & ({
|
|
179
|
+
type: 'row';
|
|
180
|
+
record: RecordType;
|
|
181
|
+
} | {
|
|
182
|
+
type: 'all';
|
|
183
|
+
record?: never;
|
|
184
|
+
});
|
|
185
|
+
export type ExpandIconComponent<RecordType> = VueComponent<ExpandIconProps<RecordType>>;
|
|
186
|
+
export interface ExpandColumnTitleProps {
|
|
187
|
+
expandIcon: VueNode;
|
|
188
|
+
}
|
|
189
|
+
export type ExpandColumnTitle = VueNode | ((props: ExpandColumnTitleProps) => VueNode);
|
|
172
190
|
export interface ExpandableConfig<RecordType> {
|
|
173
191
|
expandedRowKeys?: readonly Key[];
|
|
174
192
|
defaultExpandedRowKeys?: readonly Key[];
|
|
175
193
|
expandedRowRender?: ExpandedRowRender<RecordType>;
|
|
176
194
|
forceRender?: boolean;
|
|
177
|
-
columnTitle?:
|
|
195
|
+
columnTitle?: ExpandColumnTitle;
|
|
178
196
|
expandRowByClick?: boolean;
|
|
197
|
+
/** @deprecated Please use `components.ExpandIcon` instead. This only customizes row icons. */
|
|
179
198
|
expandIcon?: RenderExpandIcon<RecordType>;
|
|
180
199
|
onExpand?: (expanded: boolean, record: RecordType) => void;
|
|
200
|
+
onExpandAll?: (expanded: boolean) => void;
|
|
181
201
|
onExpandedRowsChange?: (expandedKeys: readonly Key[]) => void;
|
|
182
202
|
defaultExpandAllRows?: boolean;
|
|
183
203
|
indentSize?: number;
|
|
184
204
|
/** @deprecated Please use `EXPAND_COLUMN` in `columns` directly */
|
|
185
205
|
expandIconColumnIndex?: number;
|
|
186
206
|
showExpandColumn?: boolean;
|
|
207
|
+
showExpandAll?: boolean;
|
|
187
208
|
expandedRowClassName?: string | RowClassName<RecordType>;
|
|
188
209
|
childrenColumnName?: string;
|
|
189
210
|
rowExpandable?: (record: RecordType) => boolean;
|
package/dist/sugar/Column.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import { ExpandableConfig, GetRowKey, Key, RenderExpandIconProps } from '../interface';
|
|
1
|
+
import { ExpandableConfig, ExpandIconComponent, ExpandIconProps, GetRowKey, Key, RenderExpandIconProps } from '../interface';
|
|
2
|
+
export declare function DefaultExpandIcon<RecordType>({ prefixCls, type, onClick, expanded, expandable, }: ExpandIconProps<RecordType>): import("vue/jsx-runtime").JSX.Element;
|
|
2
3
|
export declare function renderExpandIcon<RecordType>({ prefixCls, record, onExpand, expanded, expandable, }: RenderExpandIconProps<RecordType>): import("vue/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare function renderRowExpandIcon<RecordType>(ExpandIcon: ExpandIconComponent<RecordType>, props: RenderExpandIconProps<RecordType>): import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}>;
|
|
3
7
|
export declare function findAllChildrenKeys<RecordType>(data: readonly RecordType[], getRowKey: GetRowKey<RecordType>, childrenColumnName: string): Key[];
|
|
4
8
|
export declare function computedExpandedClassName<RecordType>(cls: ExpandableConfig<RecordType>['expandedRowClassName'], record: RecordType, index: number, indent: number): string;
|
package/dist/utils/expandUtil.js
CHANGED
|
@@ -1,21 +1,54 @@
|
|
|
1
|
-
import { createVNode } from "vue";
|
|
1
|
+
import { createVNode, h } from "vue";
|
|
2
2
|
import { clsx } from "@v-c/util";
|
|
3
3
|
//#region src/utils/expandUtil.tsx
|
|
4
|
-
function
|
|
4
|
+
function DefaultExpandIcon({ prefixCls, type, onClick, expanded, expandable }) {
|
|
5
5
|
const expandClassName = `${prefixCls}-row-expand-icon`;
|
|
6
6
|
if (!expandable) return createVNode("span", { "class": clsx(expandClassName, `${prefixCls}-row-spaced`) }, null);
|
|
7
|
+
const className = clsx(expandClassName, {
|
|
8
|
+
[`${prefixCls}-row-expanded`]: expanded,
|
|
9
|
+
[`${prefixCls}-row-collapsed`]: !expanded
|
|
10
|
+
});
|
|
11
|
+
if (type === "all") return createVNode("button", {
|
|
12
|
+
"type": "button",
|
|
13
|
+
"aria-expanded": expanded,
|
|
14
|
+
"aria-label": expanded ? "Collapse all rows" : "Expand all rows",
|
|
15
|
+
"class": className,
|
|
16
|
+
"onClick": onClick
|
|
17
|
+
}, null);
|
|
18
|
+
return createVNode("span", {
|
|
19
|
+
"class": className,
|
|
20
|
+
"onClick": onClick
|
|
21
|
+
}, null);
|
|
22
|
+
}
|
|
23
|
+
function renderExpandIcon({ prefixCls, record, onExpand, expanded, expandable }) {
|
|
7
24
|
const onClick = (event) => {
|
|
8
25
|
onExpand(record, event);
|
|
9
26
|
event.stopPropagation();
|
|
10
27
|
};
|
|
11
|
-
return createVNode(
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
28
|
+
return createVNode(DefaultExpandIcon, {
|
|
29
|
+
"type": "row",
|
|
30
|
+
"prefixCls": prefixCls,
|
|
31
|
+
"record": record,
|
|
32
|
+
"expanded": expanded,
|
|
33
|
+
"expandable": !!expandable,
|
|
16
34
|
"onClick": onClick
|
|
17
35
|
}, null);
|
|
18
36
|
}
|
|
37
|
+
function renderRowExpandIcon(ExpandIcon, props) {
|
|
38
|
+
const { prefixCls, record, onExpand, expanded, expandable } = props;
|
|
39
|
+
const onClick = (event) => {
|
|
40
|
+
onExpand(record, event);
|
|
41
|
+
event.stopPropagation();
|
|
42
|
+
};
|
|
43
|
+
return h(ExpandIcon, {
|
|
44
|
+
type: "row",
|
|
45
|
+
prefixCls,
|
|
46
|
+
record,
|
|
47
|
+
expanded,
|
|
48
|
+
expandable: !!expandable,
|
|
49
|
+
onClick
|
|
50
|
+
});
|
|
51
|
+
}
|
|
19
52
|
function findAllChildrenKeys(data, getRowKey, childrenColumnName) {
|
|
20
53
|
const keys = [];
|
|
21
54
|
function dig(list) {
|
|
@@ -33,4 +66,4 @@ function computedExpandedClassName(cls, record, index, indent) {
|
|
|
33
66
|
return "";
|
|
34
67
|
}
|
|
35
68
|
//#endregion
|
|
36
|
-
export { computedExpandedClassName, findAllChildrenKeys, renderExpandIcon };
|
|
69
|
+
export { DefaultExpandIcon, computedExpandedClassName, findAllChildrenKeys, renderExpandIcon, renderRowExpandIcon };
|
|
@@ -4,5 +4,4 @@ export interface GetColumnKeyColumn<T = any> {
|
|
|
4
4
|
dataIndex?: DataIndex<T>;
|
|
5
5
|
}
|
|
6
6
|
export declare function getColumnsKey<T = any>(columns: readonly GetColumnKeyColumn<T>[]): Key[];
|
|
7
|
-
export declare function validateValue<T>(val: T): boolean;
|
|
8
7
|
export declare function validNumberValue(value: any): boolean;
|
package/dist/utils/valueUtil.js
CHANGED
|
@@ -16,12 +16,8 @@ function getColumnsKey(columns) {
|
|
|
16
16
|
});
|
|
17
17
|
return columnKeys;
|
|
18
18
|
}
|
|
19
|
-
function validateValue(val) {
|
|
20
|
-
if (Array.isArray(val) && val.length === 0) return false;
|
|
21
|
-
return val !== null && val !== void 0;
|
|
22
|
-
}
|
|
23
19
|
function validNumberValue(value) {
|
|
24
20
|
return typeof value === "number" && !Number.isNaN(value);
|
|
25
21
|
}
|
|
26
22
|
//#endregion
|
|
27
|
-
export { getColumnsKey, validNumberValue
|
|
23
|
+
export { getColumnsKey, validNumberValue };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-c/table",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/antdv-next/vue-components/tree/next/packages/table",
|
|
7
7
|
"repository": {
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@v-c/resize-observer": "^1.1.3",
|
|
30
|
-
"@v-c/
|
|
31
|
-
"@v-c/
|
|
30
|
+
"@v-c/util": "^1.2.0",
|
|
31
|
+
"@v-c/virtual-list": "^1.1.1"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|