@gx-design-vue/pro-table 0.2.0-alpha.20 → 0.2.0-alpha.22
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/ProTable.js +61 -2
- package/dist/components/Drag/Handle.d.ts +90 -0
- package/dist/components/Drag/Handle.js +64 -0
- package/dist/components/Drag/Tbody.d.ts +17 -0
- package/dist/components/Drag/Tbody.js +27 -0
- package/dist/components/EllipsisText/index.d.ts +50 -0
- package/dist/components/EllipsisText/index.js +65 -0
- package/dist/components/ScrollBar/Bar.d.ts +1 -1
- package/dist/components/SearchForm/FormItemContainer.d.ts +1 -1
- package/dist/components/SearchForm/FormItemWrapper.d.ts +1 -1
- package/dist/components/SearchForm/SearchForm.d.ts +1 -1
- package/dist/components/Toolbar/ListToolBar.d.ts +3 -3
- package/dist/components/Toolbar/index.d.ts +3 -3
- package/dist/hooks/index.d.ts +4 -1
- package/dist/hooks/index.js +4 -1
- package/dist/hooks/useAutoScroll.d.ts +32 -0
- package/dist/hooks/useAutoScroll.js +127 -0
- package/dist/hooks/useBreakpoints.js +1 -0
- package/dist/hooks/useCellRender.js +14 -2
- package/dist/hooks/useColumnResize.js +2 -0
- package/dist/hooks/useDragHandleColumn.d.ts +26 -0
- package/dist/hooks/useDragHandleColumn.js +52 -0
- package/dist/hooks/useEllipsis.d.ts +20 -0
- package/dist/hooks/useEllipsis.js +51 -0
- package/dist/hooks/useRowDrag.d.ts +42 -0
- package/dist/hooks/useRowDrag.js +268 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/interface.d.ts +49 -10
- package/dist/pro-table.esm.js +6157 -613
- package/dist/pro-table.js +4 -1
- package/dist/style/ellipsis.d.ts +13 -0
- package/dist/style/ellipsis.js +16 -0
- package/dist/style/index.js +4 -0
- package/dist/style/row-drag.d.ts +8 -0
- package/dist/style/row-drag.js +44 -0
- package/dist/utils/arrayMove.d.ts +9 -0
- package/dist/utils/arrayMove.js +15 -0
- package/dist/utils/ellipsis.d.ts +19 -0
- package/dist/utils/ellipsis.js +30 -0
- package/dist/utils/flipAnimate.d.ts +25 -0
- package/dist/utils/flipAnimate.js +40 -0
- package/dist/utils/formConstants.js +3 -3
- package/package.json +15 -13
package/dist/ProTable.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createDragTbody } from "./components/Drag/Tbody.js";
|
|
1
2
|
import Bar_default from "./components/ScrollBar/Bar.js";
|
|
2
3
|
import { useProBreakpoints } from "./hooks/useBreakpoints.js";
|
|
3
4
|
import ProTableSearchForm from "./components/SearchForm/SearchForm.js";
|
|
@@ -6,12 +7,14 @@ import { useProvideTableContext } from "./context/TableContext.js";
|
|
|
6
7
|
import { Toolbar } from "./components/Toolbar/index.js";
|
|
7
8
|
import { useCellRender } from "./hooks/useCellRender.js";
|
|
8
9
|
import { applyIndexColumn, useColumns } from "./hooks/useColumns.js";
|
|
10
|
+
import { useDragHandleColumn } from "./hooks/useDragHandleColumn.js";
|
|
9
11
|
import { useColumnResize } from "./hooks/useColumnResize.js";
|
|
10
12
|
import { useFetchData } from "./hooks/useFetchData.js";
|
|
11
13
|
import { useFitPage } from "./hooks/useFitPage.js";
|
|
12
14
|
import { useKeepAliveReload } from "./hooks/useKeepAliveReload.js";
|
|
13
15
|
import { useLoading } from "./hooks/useLoading.js";
|
|
14
16
|
import { usePagination } from "./hooks/usePagination.js";
|
|
17
|
+
import { useRowDrag } from "./hooks/useRowDrag.js";
|
|
15
18
|
import { useRowSelection } from "./hooks/useRowSelection.js";
|
|
16
19
|
import { useTableForm } from "./hooks/useTableForm.js";
|
|
17
20
|
import { useTableScroll } from "./hooks/useTableScroll.js";
|
|
@@ -117,8 +120,15 @@ const ForwardProTable = /* @__PURE__ */ defineComponent((props, { attrs, slots,
|
|
|
117
120
|
screenWidth,
|
|
118
121
|
scrollPolicy: computed(() => props.scrollPolicy)
|
|
119
122
|
});
|
|
120
|
-
const
|
|
123
|
+
const rowDraggableRef = computed(() => props.rowDraggable);
|
|
124
|
+
const { dragColumns } = useDragHandleColumn({
|
|
121
125
|
columns: computed(() => props.columns ?? []),
|
|
126
|
+
rowDraggable: rowDraggableRef,
|
|
127
|
+
prefixCls,
|
|
128
|
+
cssVarCls
|
|
129
|
+
});
|
|
130
|
+
const { tableColumns, cacheColumns, setColumns } = useColumns({
|
|
131
|
+
columns: dragColumns,
|
|
122
132
|
align: computed(() => props.align ?? "left"),
|
|
123
133
|
indexColumn: computed(() => props.indexColumn),
|
|
124
134
|
shouldFixActionColumn,
|
|
@@ -131,6 +141,10 @@ const ForwardProTable = /* @__PURE__ */ defineComponent((props, { attrs, slots,
|
|
|
131
141
|
columns: tableColumns,
|
|
132
142
|
onResize: (w, col) => emit("resizeColumn", w, col)
|
|
133
143
|
});
|
|
144
|
+
const dragTbodyRef = ref();
|
|
145
|
+
const DragTbody = createDragTbody(dragTbodyRef);
|
|
146
|
+
if (props.virtual && props.rowDraggable) console.warn("[GProTable] rowDraggable 与 virtual 模式不兼容(虚拟滚动下行未挂载,拖拽不可靠),已忽略行拖拽。");
|
|
147
|
+
const rowDragEnabled = computed(() => !!props.rowDraggable && !props.virtual);
|
|
134
148
|
const formConfig = computed(() => props.form === false ? void 0 : props.form);
|
|
135
149
|
const formAutoRequest = computed(() => {
|
|
136
150
|
if (props.form === false) return props.autoRequest ?? true;
|
|
@@ -187,6 +201,40 @@ const ForwardProTable = /* @__PURE__ */ defineComponent((props, { attrs, slots,
|
|
|
187
201
|
...policyTableScroll.value ?? {},
|
|
188
202
|
...fitPageScrollY.value > 0 ? { y: fitPageScrollY.value } : {}
|
|
189
203
|
}));
|
|
204
|
+
const { getRowProps } = useRowDrag({
|
|
205
|
+
tbodyEl: dragTbodyRef,
|
|
206
|
+
scrollEl,
|
|
207
|
+
dataSource,
|
|
208
|
+
rowKey: computed(() => props.rowKey),
|
|
209
|
+
rowDraggable: rowDraggableRef,
|
|
210
|
+
onSortEnd: (from, to, newData, record) => {
|
|
211
|
+
emit("rowSortEnd", {
|
|
212
|
+
from,
|
|
213
|
+
to,
|
|
214
|
+
data: newData,
|
|
215
|
+
record
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
const mergedOnRow = computed(() => {
|
|
220
|
+
if (!rowDragEnabled.value) return props.onRow;
|
|
221
|
+
const userOnRow = props.onRow;
|
|
222
|
+
return (record, index) => ({
|
|
223
|
+
...userOnRow?.(record, index) ?? {},
|
|
224
|
+
...getRowProps(record, index)
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
const mergedComponents = computed(() => {
|
|
228
|
+
const base = props.draggable ? resizableComponents.value : {};
|
|
229
|
+
if (!rowDragEnabled.value) return passThroughProps.value.components ?? base;
|
|
230
|
+
return {
|
|
231
|
+
...base,
|
|
232
|
+
body: {
|
|
233
|
+
...base?.body ?? {},
|
|
234
|
+
wrapper: DragTbody
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
});
|
|
190
238
|
useProvideTableContext({
|
|
191
239
|
reload,
|
|
192
240
|
setPagination,
|
|
@@ -401,7 +449,8 @@ const ForwardProTable = /* @__PURE__ */ defineComponent((props, { attrs, slots,
|
|
|
401
449
|
"scroll": tableScroll.value,
|
|
402
450
|
"dataSource": dataSource.value,
|
|
403
451
|
"columns": props.draggable ? resizableColumns.value : tableColumns.value,
|
|
404
|
-
"components":
|
|
452
|
+
"components": mergedComponents.value,
|
|
453
|
+
"onRow": mergedOnRow.value,
|
|
405
454
|
"rowKey": props.rowKey,
|
|
406
455
|
"size": tableSize.value,
|
|
407
456
|
"pagination": paginationInfo.value,
|
|
@@ -564,6 +613,15 @@ const ForwardProTable = /* @__PURE__ */ defineComponent((props, { attrs, slots,
|
|
|
564
613
|
required: false,
|
|
565
614
|
default: void 0
|
|
566
615
|
},
|
|
616
|
+
rowDraggable: {
|
|
617
|
+
type: [Boolean, Object],
|
|
618
|
+
required: false,
|
|
619
|
+
default: void 0
|
|
620
|
+
},
|
|
621
|
+
onRowSortEnd: {
|
|
622
|
+
type: Function,
|
|
623
|
+
required: false
|
|
624
|
+
},
|
|
567
625
|
keepAliveReload: {
|
|
568
626
|
type: Boolean,
|
|
569
627
|
required: false,
|
|
@@ -855,6 +913,7 @@ const ForwardProTable = /* @__PURE__ */ defineComponent((props, { attrs, slots,
|
|
|
855
913
|
"sizeChange",
|
|
856
914
|
"resizeColumn",
|
|
857
915
|
"fullscreenChange",
|
|
916
|
+
"rowSortEnd",
|
|
858
917
|
"update:expandedRowKeys",
|
|
859
918
|
"scroll"
|
|
860
919
|
],
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { CustomRender } from "@gx-design-vue/pro-utils";
|
|
2
|
+
|
|
3
|
+
//#region src/components/Drag/Handle.d.ts
|
|
4
|
+
interface DragHandleProps {
|
|
5
|
+
/** 自定义把手渲染(覆盖默认图标) */
|
|
6
|
+
handleRender?: (record: any, index: number) => CustomRender;
|
|
7
|
+
/** 当前行数据 */
|
|
8
|
+
record?: any;
|
|
9
|
+
/** 当前行索引 */
|
|
10
|
+
index?: number;
|
|
11
|
+
/** 是否禁用拖拽 */
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
/** 样式前缀 */
|
|
14
|
+
prefixCls?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 行拖拽把手 —— 默认渲染 HolderOutlined 图标,`handleRender` 可覆盖。
|
|
18
|
+
*
|
|
19
|
+
* 根元素带 `data-drag-handle` 标记,`useRowDrag` 通过它识别拖拽入口;
|
|
20
|
+
* 禁用时 `data-drag-disabled` 标记 + not-allowed 光标。
|
|
21
|
+
*/
|
|
22
|
+
declare const DragHandle: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
23
|
+
handleRender: {
|
|
24
|
+
type: FunctionConstructor;
|
|
25
|
+
default: any;
|
|
26
|
+
};
|
|
27
|
+
record: {
|
|
28
|
+
type: ObjectConstructor;
|
|
29
|
+
default: any;
|
|
30
|
+
};
|
|
31
|
+
index: {
|
|
32
|
+
type: NumberConstructor;
|
|
33
|
+
default: any;
|
|
34
|
+
};
|
|
35
|
+
disabled: {
|
|
36
|
+
type: BooleanConstructor;
|
|
37
|
+
default: boolean;
|
|
38
|
+
};
|
|
39
|
+
prefixCls: {
|
|
40
|
+
type: StringConstructor;
|
|
41
|
+
default: string;
|
|
42
|
+
};
|
|
43
|
+
hashId: {
|
|
44
|
+
type: StringConstructor;
|
|
45
|
+
default: string;
|
|
46
|
+
};
|
|
47
|
+
cssVarCls: {
|
|
48
|
+
type: StringConstructor;
|
|
49
|
+
default: string;
|
|
50
|
+
};
|
|
51
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
52
|
+
handleRender: {
|
|
53
|
+
type: FunctionConstructor;
|
|
54
|
+
default: any;
|
|
55
|
+
};
|
|
56
|
+
record: {
|
|
57
|
+
type: ObjectConstructor;
|
|
58
|
+
default: any;
|
|
59
|
+
};
|
|
60
|
+
index: {
|
|
61
|
+
type: NumberConstructor;
|
|
62
|
+
default: any;
|
|
63
|
+
};
|
|
64
|
+
disabled: {
|
|
65
|
+
type: BooleanConstructor;
|
|
66
|
+
default: boolean;
|
|
67
|
+
};
|
|
68
|
+
prefixCls: {
|
|
69
|
+
type: StringConstructor;
|
|
70
|
+
default: string;
|
|
71
|
+
};
|
|
72
|
+
hashId: {
|
|
73
|
+
type: StringConstructor;
|
|
74
|
+
default: string;
|
|
75
|
+
};
|
|
76
|
+
cssVarCls: {
|
|
77
|
+
type: StringConstructor;
|
|
78
|
+
default: string;
|
|
79
|
+
};
|
|
80
|
+
}>> & Readonly<{}>, {
|
|
81
|
+
prefixCls: string;
|
|
82
|
+
hashId: string;
|
|
83
|
+
record: Record<string, any>;
|
|
84
|
+
handleRender: Function;
|
|
85
|
+
index: number;
|
|
86
|
+
disabled: boolean;
|
|
87
|
+
cssVarCls: string;
|
|
88
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
89
|
+
//#endregion
|
|
90
|
+
export { DragHandle, DragHandleProps };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { createVNode, defineComponent } from "vue";
|
|
2
|
+
import { GIcon } from "@gx-design-vue/icon";
|
|
3
|
+
//#region src/components/Drag/Handle.tsx
|
|
4
|
+
/**
|
|
5
|
+
* 行拖拽把手 —— 默认渲染 HolderOutlined 图标,`handleRender` 可覆盖。
|
|
6
|
+
*
|
|
7
|
+
* 根元素带 `data-drag-handle` 标记,`useRowDrag` 通过它识别拖拽入口;
|
|
8
|
+
* 禁用时 `data-drag-disabled` 标记 + not-allowed 光标。
|
|
9
|
+
*/
|
|
10
|
+
const DragHandle = /* @__PURE__ */ defineComponent({
|
|
11
|
+
name: "ProTableDragHandle",
|
|
12
|
+
inheritAttrs: false,
|
|
13
|
+
props: {
|
|
14
|
+
handleRender: {
|
|
15
|
+
type: Function,
|
|
16
|
+
default: void 0
|
|
17
|
+
},
|
|
18
|
+
record: {
|
|
19
|
+
type: Object,
|
|
20
|
+
default: void 0
|
|
21
|
+
},
|
|
22
|
+
index: {
|
|
23
|
+
type: Number,
|
|
24
|
+
default: void 0
|
|
25
|
+
},
|
|
26
|
+
disabled: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: false
|
|
29
|
+
},
|
|
30
|
+
prefixCls: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: ""
|
|
33
|
+
},
|
|
34
|
+
hashId: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: ""
|
|
37
|
+
},
|
|
38
|
+
cssVarCls: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: ""
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
setup(props) {
|
|
44
|
+
return () => {
|
|
45
|
+
const customNode = props.handleRender?.(props.record, props.index ?? 0);
|
|
46
|
+
if (customNode !== void 0 && customNode !== null && customNode !== false) return createVNode("span", {
|
|
47
|
+
"class": `${props.prefixCls}-drag-handle`,
|
|
48
|
+
"data-drag-handle": "true",
|
|
49
|
+
"data-drag-disabled": props.disabled ? "true" : void 0
|
|
50
|
+
}, [customNode]);
|
|
51
|
+
return createVNode("span", {
|
|
52
|
+
"class": [
|
|
53
|
+
props.cssVarCls,
|
|
54
|
+
`${props.prefixCls}-drag-handle`,
|
|
55
|
+
props.disabled ? `${props.prefixCls}-drag-handle-disabled` : ""
|
|
56
|
+
],
|
|
57
|
+
"data-drag-handle": "true",
|
|
58
|
+
"data-drag-disabled": props.disabled ? "true" : void 0
|
|
59
|
+
}, [createVNode(GIcon, { "type": "HolderOutlined" }, null)]);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
//#endregion
|
|
64
|
+
export { DragHandle };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Ref } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/components/Drag/Tbody.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* 透传 `<tbody>` 并捕获其 DOM 引用。
|
|
6
|
+
*
|
|
7
|
+
* 用于 `components.body.wrapper` 覆写,让 `useRowDrag` 能拿到 tbody 元素,
|
|
8
|
+
* 从而 `querySelectorAll('tr[data-row-key]')` 获取所有行。
|
|
9
|
+
*
|
|
10
|
+
* 对标 `useColumnResize` 覆写 `components.header.cell` 的手法:
|
|
11
|
+
* attrs 全部透传给 `<tbody>`,slots 原样保留。
|
|
12
|
+
*/
|
|
13
|
+
declare function createDragTbody(tbodyRef: Ref<HTMLElement | undefined>): import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { createDragTbody };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defineComponent, h } from "vue";
|
|
2
|
+
//#region src/components/Drag/Tbody.ts
|
|
3
|
+
/**
|
|
4
|
+
* 透传 `<tbody>` 并捕获其 DOM 引用。
|
|
5
|
+
*
|
|
6
|
+
* 用于 `components.body.wrapper` 覆写,让 `useRowDrag` 能拿到 tbody 元素,
|
|
7
|
+
* 从而 `querySelectorAll('tr[data-row-key]')` 获取所有行。
|
|
8
|
+
*
|
|
9
|
+
* 对标 `useColumnResize` 覆写 `components.header.cell` 的手法:
|
|
10
|
+
* attrs 全部透传给 `<tbody>`,slots 原样保留。
|
|
11
|
+
*/
|
|
12
|
+
function createDragTbody(tbodyRef) {
|
|
13
|
+
return defineComponent({
|
|
14
|
+
name: "ProTableDragTbody",
|
|
15
|
+
inheritAttrs: false,
|
|
16
|
+
setup(_, { attrs, slots }) {
|
|
17
|
+
return () => h("tbody", {
|
|
18
|
+
...attrs,
|
|
19
|
+
ref: (el) => {
|
|
20
|
+
tbodyRef.value = el instanceof HTMLElement ? el : void 0;
|
|
21
|
+
}
|
|
22
|
+
}, slots.default?.());
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { createDragTbody };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { NormalizedEllipsis } from "../../utils/ellipsis.js";
|
|
2
|
+
import { PropType } from "vue";
|
|
3
|
+
|
|
4
|
+
//#region src/components/EllipsisText/index.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* 单元格文本溢出渲染:
|
|
7
|
+
* - 视觉省略由 CSS `-webkit-line-clamp` 承担;
|
|
8
|
+
* - 是否溢出由 useEllipsis(@chenglou/pretext)判断;
|
|
9
|
+
* - 溢出且未关闭 tooltip 时挂 Tooltip,getPopupContainer 指向表格滚动容器(滚动时跟随)。
|
|
10
|
+
*/
|
|
11
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
12
|
+
/** 纯文本:用于 pretext 测量与 tooltip title */text: {
|
|
13
|
+
type: StringConstructor;
|
|
14
|
+
default: string;
|
|
15
|
+
}; /** 归一化后的溢出配置 */
|
|
16
|
+
ellipsis: {
|
|
17
|
+
type: PropType<NormalizedEllipsis>;
|
|
18
|
+
required: true;
|
|
19
|
+
};
|
|
20
|
+
prefixCls: {
|
|
21
|
+
type: StringConstructor;
|
|
22
|
+
required: true;
|
|
23
|
+
};
|
|
24
|
+
hashId: {
|
|
25
|
+
type: StringConstructor;
|
|
26
|
+
default: string;
|
|
27
|
+
};
|
|
28
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
29
|
+
/** 纯文本:用于 pretext 测量与 tooltip title */text: {
|
|
30
|
+
type: StringConstructor;
|
|
31
|
+
default: string;
|
|
32
|
+
}; /** 归一化后的溢出配置 */
|
|
33
|
+
ellipsis: {
|
|
34
|
+
type: PropType<NormalizedEllipsis>;
|
|
35
|
+
required: true;
|
|
36
|
+
};
|
|
37
|
+
prefixCls: {
|
|
38
|
+
type: StringConstructor;
|
|
39
|
+
required: true;
|
|
40
|
+
};
|
|
41
|
+
hashId: {
|
|
42
|
+
type: StringConstructor;
|
|
43
|
+
default: string;
|
|
44
|
+
};
|
|
45
|
+
}>> & Readonly<{}>, {
|
|
46
|
+
text: string;
|
|
47
|
+
hashId: string;
|
|
48
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
49
|
+
//#endregion
|
|
50
|
+
export { _default as default };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useInjectScrollBarContext } from "../ScrollBar/context.js";
|
|
2
|
+
import { useEllipsis } from "../../hooks/useEllipsis.js";
|
|
3
|
+
import { computed, createVNode, defineComponent, isVNode, mergeProps, ref, toRef } from "vue";
|
|
4
|
+
import { Tooltip } from "antdv-next";
|
|
5
|
+
//#region src/components/EllipsisText/index.tsx
|
|
6
|
+
/**
|
|
7
|
+
* 单元格文本溢出渲染:
|
|
8
|
+
* - 视觉省略由 CSS `-webkit-line-clamp` 承担;
|
|
9
|
+
* - 是否溢出由 useEllipsis(@chenglou/pretext)判断;
|
|
10
|
+
* - 溢出且未关闭 tooltip 时挂 Tooltip,getPopupContainer 指向表格滚动容器(滚动时跟随)。
|
|
11
|
+
*/
|
|
12
|
+
function _isSlot(s) {
|
|
13
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
14
|
+
}
|
|
15
|
+
var EllipsisText_default = /* @__PURE__ */ defineComponent({
|
|
16
|
+
name: "ProTableEllipsisText",
|
|
17
|
+
props: {
|
|
18
|
+
/** 纯文本:用于 pretext 测量与 tooltip title */
|
|
19
|
+
text: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: ""
|
|
22
|
+
},
|
|
23
|
+
/** 归一化后的溢出配置 */
|
|
24
|
+
ellipsis: {
|
|
25
|
+
type: Object,
|
|
26
|
+
required: true
|
|
27
|
+
},
|
|
28
|
+
prefixCls: {
|
|
29
|
+
type: String,
|
|
30
|
+
required: true
|
|
31
|
+
},
|
|
32
|
+
hashId: {
|
|
33
|
+
type: String,
|
|
34
|
+
default: ""
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
setup(props, { slots }) {
|
|
38
|
+
const contentRef = ref();
|
|
39
|
+
const { isOverflow } = useEllipsis(toRef(props, "text"), computed(() => props.ellipsis.lines), contentRef);
|
|
40
|
+
const scrollContext = useInjectScrollBarContext();
|
|
41
|
+
const getScrollContainer = () => scrollContext?.wrapElement?.value ?? document.body;
|
|
42
|
+
return () => {
|
|
43
|
+
let _slot;
|
|
44
|
+
const children = slots.default ? slots.default() : props.text;
|
|
45
|
+
const lineClampStyle = {
|
|
46
|
+
WebkitLineClamp: props.ellipsis.lines,
|
|
47
|
+
lineClamp: props.ellipsis.lines
|
|
48
|
+
};
|
|
49
|
+
const renderCell = (extra) => createVNode("div", mergeProps({
|
|
50
|
+
"ref": contentRef,
|
|
51
|
+
"class": [`${props.prefixCls}-cell-ellipsis`, props.hashId],
|
|
52
|
+
"style": lineClampStyle
|
|
53
|
+
}, extra ?? {}), [children]);
|
|
54
|
+
if (props.ellipsis.showTitle) return renderCell({ title: props.text });
|
|
55
|
+
const tooltipConfig = props.ellipsis.tooltip;
|
|
56
|
+
if (tooltipConfig === false || !isOverflow.value) return renderCell();
|
|
57
|
+
return createVNode(Tooltip, mergeProps({ "title": props.text }, tooltipConfig, {
|
|
58
|
+
"getPopupContainer": getScrollContainer,
|
|
59
|
+
"destroyOnHidden": true
|
|
60
|
+
}), _isSlot(_slot = renderCell()) ? _slot : { default: () => [_slot] });
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
//#endregion
|
|
65
|
+
export { EllipsisText_default as default };
|
|
@@ -68,11 +68,11 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
68
68
|
};
|
|
69
69
|
}>> & Readonly<{}>, {
|
|
70
70
|
readonly always: boolean;
|
|
71
|
-
readonly minSize: number;
|
|
72
71
|
readonly barStyle: {
|
|
73
72
|
x: CSSProperties;
|
|
74
73
|
y: CSSProperties;
|
|
75
74
|
};
|
|
75
|
+
readonly minSize: number;
|
|
76
76
|
readonly hasScrollY: boolean;
|
|
77
77
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
78
78
|
//#endregion
|
|
@@ -65,9 +65,9 @@ declare const FormItemContainer: import("vue").DefineComponent<import("vue").Ext
|
|
|
65
65
|
default: any;
|
|
66
66
|
};
|
|
67
67
|
}>> & Readonly<{}>, {
|
|
68
|
-
onSubmit: () => void;
|
|
69
68
|
loading: boolean;
|
|
70
69
|
autoRequest: boolean;
|
|
70
|
+
onSubmit: () => void;
|
|
71
71
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
72
72
|
//#endregion
|
|
73
73
|
export { FormItemContainer };
|
|
@@ -69,10 +69,10 @@ declare const FormItemWrapper: import("vue").DefineComponent<import("vue").Extra
|
|
|
69
69
|
};
|
|
70
70
|
}>> & Readonly<{}>, {
|
|
71
71
|
label: any;
|
|
72
|
+
hashId: string;
|
|
72
73
|
labelWidth: string | number;
|
|
73
74
|
labelAlign: "left" | "right" | "center";
|
|
74
75
|
colon: boolean;
|
|
75
|
-
hashId: string;
|
|
76
76
|
formItemStyle: CSSProperties;
|
|
77
77
|
globalLabelGap: number;
|
|
78
78
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -109,7 +109,6 @@ declare const ProTableSearchForm: import("vue").DefineComponent<import("vue").Ex
|
|
|
109
109
|
default: any;
|
|
110
110
|
};
|
|
111
111
|
}>> & Readonly<{}>, {
|
|
112
|
-
onReset: (params: Record<string, any>) => void;
|
|
113
112
|
formColumns: ProSearchMap<"text", string>[];
|
|
114
113
|
formConfig: FormConfig;
|
|
115
114
|
formAutoRequest: boolean;
|
|
@@ -123,6 +122,7 @@ declare const ProTableSearchForm: import("vue").DefineComponent<import("vue").Ex
|
|
|
123
122
|
cardBordered: boolean;
|
|
124
123
|
proClasses: Record<string, string>;
|
|
125
124
|
proStyles: Record<string, any>;
|
|
125
|
+
onReset: (params: Record<string, any>) => void;
|
|
126
126
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
127
127
|
//#endregion
|
|
128
128
|
export { ProTableSearchForm as default };
|
|
@@ -96,14 +96,14 @@ declare const ListToolBar: import("vue").DefineComponent<import("vue").ExtractPr
|
|
|
96
96
|
}>[];
|
|
97
97
|
proClasses: Record<string, any>;
|
|
98
98
|
proStyles: Record<string, any>;
|
|
99
|
-
titleTipText: string;
|
|
100
|
-
actionsPlacement: ToolbarPlacement;
|
|
101
99
|
headerTitle: any;
|
|
102
|
-
listToolAfter: any;
|
|
103
100
|
headerTitleTip: any;
|
|
101
|
+
titleTipText: string;
|
|
104
102
|
settings: VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
105
103
|
[key: string]: any;
|
|
106
104
|
}>[];
|
|
105
|
+
actionsPlacement: ToolbarPlacement;
|
|
106
|
+
listToolAfter: any;
|
|
107
107
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
108
108
|
//#endregion
|
|
109
109
|
export { ListToolBar, ListToolBarSetting };
|
|
@@ -90,12 +90,12 @@ declare const Toolbar: import("vue").DefineComponent<import("vue").ExtractPropTy
|
|
|
90
90
|
}>[];
|
|
91
91
|
proClasses: Record<string, any>;
|
|
92
92
|
proStyles: Record<string, any>;
|
|
93
|
-
|
|
93
|
+
headerTitle: any;
|
|
94
|
+
headerTitleTip: any;
|
|
94
95
|
titleTipText: string;
|
|
95
96
|
actionsPlacement: ToolbarPlacement;
|
|
96
|
-
headerTitle: any;
|
|
97
97
|
listToolAfter: any;
|
|
98
|
-
|
|
98
|
+
options: any;
|
|
99
99
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
100
100
|
//#endregion
|
|
101
101
|
export { Toolbar, Toolbar as default };
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -2,15 +2,18 @@ import { UseProBreakpointsReturn, useProBreakpoints } from "./useBreakpoints.js"
|
|
|
2
2
|
import { UseCellRenderOptions, useCellRender } from "./useCellRender.js";
|
|
3
3
|
import { UseColumnResizeOptions, UseColumnResizeReturn, useColumnResize } from "./useColumnResize.js";
|
|
4
4
|
import { UseColumnsOptions, UseColumnsReturn, useColumns } from "./useColumns.js";
|
|
5
|
+
import { UseDragHandleColumnOptions, UseDragHandleColumnReturn, applyDragHandleColumn, useDragHandleColumn } from "./useDragHandleColumn.js";
|
|
6
|
+
import { UseEllipsisReturn, useEllipsis } from "./useEllipsis.js";
|
|
5
7
|
import { FetchDataAction, FetchDataConfig, useFetchData } from "./useFetchData.js";
|
|
6
8
|
import { UseFitPageOptions, UseFitPageReturn, useFitPage } from "./useFitPage.js";
|
|
7
9
|
import { UseKeepAliveReloadOptions, UseKeepAliveReloadReturn, useKeepAliveReload } from "./useKeepAliveReload.js";
|
|
8
10
|
import { UseLoadingOptions, UseLoadingReturn, useLoading } from "./useLoading.js";
|
|
9
11
|
import { usePagination } from "./usePagination.js";
|
|
10
12
|
import { UseRequestOptionsParams, UseRequestOptionsReturn, useRequestOptions } from "./useRequestOptions.js";
|
|
13
|
+
import { UseRowDragOptions, UseRowDragReturn, useRowDrag } from "./useRowDrag.js";
|
|
11
14
|
import { UseRowSelectionOptions, UseRowSelectionReturn, useRowSelection } from "./useRowSelection.js";
|
|
12
15
|
import { UseTableOptions, UseTableReturn, useTable } from "./useTable.js";
|
|
13
16
|
import { UseTableFormOptions, UseTableFormReturn, useTableForm } from "./useTableForm.js";
|
|
14
17
|
import { NormalizedTableScrollPolicy, UseTableScrollOptions, UseTableScrollReturn, useTableScroll } from "./useTableScroll.js";
|
|
15
18
|
import { UseTableSizeOptions, UseTableSizeReturn, useTableSize } from "./useTableSize.js";
|
|
16
|
-
export { type FetchDataAction, type FetchDataConfig, type NormalizedTableScrollPolicy, type UseCellRenderOptions, type UseColumnResizeOptions, type UseColumnResizeReturn, type UseColumnsOptions, type UseColumnsReturn, type UseFitPageOptions, type UseFitPageReturn, type UseKeepAliveReloadOptions, type UseKeepAliveReloadReturn, type UseLoadingOptions, type UseLoadingReturn, type UseProBreakpointsReturn, type UseRequestOptionsParams, type UseRequestOptionsReturn, type UseRowSelectionOptions, type UseRowSelectionReturn, type UseTableFormOptions, type UseTableFormReturn, type UseTableOptions, type UseTableReturn, type UseTableScrollOptions, type UseTableScrollReturn, type UseTableSizeOptions, type UseTableSizeReturn, useCellRender, useColumnResize, useColumns, useFetchData, useFitPage, useKeepAliveReload, useLoading, usePagination, useProBreakpoints, useRequestOptions, useRowSelection, useTable, useTableForm, useTableScroll, useTableSize };
|
|
19
|
+
export { type FetchDataAction, type FetchDataConfig, type NormalizedTableScrollPolicy, type UseCellRenderOptions, type UseColumnResizeOptions, type UseColumnResizeReturn, type UseColumnsOptions, type UseColumnsReturn, type UseDragHandleColumnOptions, type UseDragHandleColumnReturn, type UseEllipsisReturn, type UseFitPageOptions, type UseFitPageReturn, type UseKeepAliveReloadOptions, type UseKeepAliveReloadReturn, type UseLoadingOptions, type UseLoadingReturn, type UseProBreakpointsReturn, type UseRequestOptionsParams, type UseRequestOptionsReturn, type UseRowDragOptions, type UseRowDragReturn, type UseRowSelectionOptions, type UseRowSelectionReturn, type UseTableFormOptions, type UseTableFormReturn, type UseTableOptions, type UseTableReturn, type UseTableScrollOptions, type UseTableScrollReturn, type UseTableSizeOptions, type UseTableSizeReturn, applyDragHandleColumn, useCellRender, useColumnResize, useColumns, useDragHandleColumn, useEllipsis, useFetchData, useFitPage, useKeepAliveReload, useLoading, usePagination, useProBreakpoints, useRequestOptions, useRowDrag, useRowSelection, useTable, useTableForm, useTableScroll, useTableSize };
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { useProBreakpoints } from "./useBreakpoints.js";
|
|
2
2
|
import { useRequestOptions } from "./useRequestOptions.js";
|
|
3
|
+
import { useEllipsis } from "./useEllipsis.js";
|
|
3
4
|
import { useCellRender } from "./useCellRender.js";
|
|
4
5
|
import { useColumns } from "./useColumns.js";
|
|
6
|
+
import { applyDragHandleColumn, useDragHandleColumn } from "./useDragHandleColumn.js";
|
|
5
7
|
import { useColumnResize } from "./useColumnResize.js";
|
|
6
8
|
import { useFetchData } from "./useFetchData.js";
|
|
7
9
|
import { useFitPage } from "./useFitPage.js";
|
|
8
10
|
import { useKeepAliveReload } from "./useKeepAliveReload.js";
|
|
9
11
|
import { useLoading } from "./useLoading.js";
|
|
10
12
|
import { usePagination } from "./usePagination.js";
|
|
13
|
+
import { useRowDrag } from "./useRowDrag.js";
|
|
11
14
|
import { useRowSelection } from "./useRowSelection.js";
|
|
12
15
|
import { useTable } from "./useTable.js";
|
|
13
16
|
import { useTableForm } from "./useTableForm.js";
|
|
14
17
|
import { useTableScroll } from "./useTableScroll.js";
|
|
15
18
|
import { useTableSize } from "./useTableSize.js";
|
|
16
|
-
export { useCellRender, useColumnResize, useColumns, useFetchData, useFitPage, useKeepAliveReload, useLoading, usePagination, useProBreakpoints, useRequestOptions, useRowSelection, useTable, useTableForm, useTableScroll, useTableSize };
|
|
19
|
+
export { applyDragHandleColumn, useCellRender, useColumnResize, useColumns, useDragHandleColumn, useEllipsis, useFetchData, useFitPage, useKeepAliveReload, useLoading, usePagination, useProBreakpoints, useRequestOptions, useRowDrag, useRowSelection, useTable, useTableForm, useTableScroll, useTableSize };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ComputedRef, Ref } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/hooks/useAutoScroll.d.ts
|
|
4
|
+
interface UseAutoScrollOptions {
|
|
5
|
+
/** 边缘激活区域占容器高度比例,默认 0.2(对齐 dnd-kit detectScrollIntent threshold) */
|
|
6
|
+
threshold?: number;
|
|
7
|
+
/** 滚动加速度(基础速度),默认 18 */
|
|
8
|
+
acceleration?: number;
|
|
9
|
+
/** 指针超出边缘的容差(px),默认 10 */
|
|
10
|
+
tolerance?: number;
|
|
11
|
+
/** 滚动后回调,用于同步拖拽元素和让位元素位置 */
|
|
12
|
+
onScroll?: () => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 纵向自动滚动 —— 精简复刻 `@dnd-kit/dom` 的 `detectScrollIntent` + `Scroller` 思路,
|
|
16
|
+
* 与 pro-layout Tabs 的横向 `useAutoScroll` 同构(仅轴向不同)。
|
|
17
|
+
*
|
|
18
|
+
* 指针进入 `scrollEl` 上/下边缘 threshold 区域时,按距边缘的比例计算速度
|
|
19
|
+
* (越靠边越快)。滚动方向必须先被用户同向移动解锁;如果当前方向已经到达边界,
|
|
20
|
+
* 则不产生滚动 intent,避免触底后因为鼠标还在边缘区被反复重新激活。
|
|
21
|
+
*
|
|
22
|
+
* 关键:`maxScrollTop` 在 `start()` 时快照一次(`??` 仅在 undefined 时 fallback 到实时值),
|
|
23
|
+
* 拖拽全程都用快照值判定能否滚动。这样即使拖拽中 `transform` 撑大了 `scrollHeight`,
|
|
24
|
+
* 也不会污染滚动判定,避免死循环。
|
|
25
|
+
*/
|
|
26
|
+
declare function useAutoScroll(scrollEl: Ref<HTMLElement | undefined> | ComputedRef<HTMLElement | undefined>, getPointerY: () => number | null, options?: UseAutoScrollOptions): {
|
|
27
|
+
scroll: () => boolean;
|
|
28
|
+
start: () => void;
|
|
29
|
+
stop: () => void;
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
export { UseAutoScrollOptions, useAutoScroll };
|