@gx-design-vue/pro-table 0.2.0-alpha.20 → 0.2.0-alpha.21
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/SearchForm/CollapseToggle.d.ts +1 -1
- package/dist/components/SearchForm/FormItemWrapper.d.ts +1 -1
- package/dist/components/SearchForm/SearchForm.d.ts +2 -2
- package/dist/components/Toolbar/ListToolBar.d.ts +4 -4
- package/dist/components/Toolbar/index.d.ts +5 -5
- 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/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 +47 -9
- package/dist/pro-table.esm.js +6156 -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
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//#region src/style/row-drag.ts
|
|
2
|
+
const genProTableRowDrag = (token) => {
|
|
3
|
+
const draggingZIndex = token.zIndexPopupBase;
|
|
4
|
+
return { [token.componentCls]: {
|
|
5
|
+
[`${token.componentCls}-drag-handle`]: {
|
|
6
|
+
display: "inline-flex",
|
|
7
|
+
alignItems: "center",
|
|
8
|
+
justifyContent: "center",
|
|
9
|
+
padding: 4,
|
|
10
|
+
fontSize: 12,
|
|
11
|
+
color: token.colorTextSecondary,
|
|
12
|
+
cursor: "grab",
|
|
13
|
+
borderRadius: token.borderRadius,
|
|
14
|
+
transition: "all 0.2s",
|
|
15
|
+
userSelect: "none",
|
|
16
|
+
"&:hover": {
|
|
17
|
+
color: token.colorText,
|
|
18
|
+
backgroundColor: token.colorFillSecondary
|
|
19
|
+
},
|
|
20
|
+
"&:active": { cursor: "grabbing" }
|
|
21
|
+
},
|
|
22
|
+
[`${token.componentCls}-drag-handle-disabled`]: {
|
|
23
|
+
cursor: "not-allowed",
|
|
24
|
+
opacity: .45,
|
|
25
|
+
"&:hover": {
|
|
26
|
+
color: token.colorTextSecondary,
|
|
27
|
+
backgroundColor: "transparent"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
[`${token.antCls}-table-tbody tr.row-dragging`]: {
|
|
31
|
+
position: "relative",
|
|
32
|
+
backgroundColor: `${token.colorPrimaryBg} !important`,
|
|
33
|
+
boxShadow: `0 4px 12px ${token.boxShadowTertiary}`,
|
|
34
|
+
zIndex: draggingZIndex,
|
|
35
|
+
[`> ${token.antCls}-table-cell`]: {
|
|
36
|
+
backgroundColor: `${token.colorPrimaryBg} !important`,
|
|
37
|
+
zIndex: draggingZIndex
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
[`${token.antCls}-table-tbody > tr`]: { willChange: "auto" }
|
|
41
|
+
} };
|
|
42
|
+
};
|
|
43
|
+
//#endregion
|
|
44
|
+
export { genProTableRowDrag };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/utils/arrayMove.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* 将数组中 `from` 位置的元素移动到 `to` 位置,返回新数组(不修改原数组)。
|
|
4
|
+
*
|
|
5
|
+
* 对标 `@dnd-kit/helpers` 的 `arrayMove`,用于行拖拽排序后的数据重排。
|
|
6
|
+
*/
|
|
7
|
+
declare function arrayMove<T>(array: readonly T[], from: number, to: number): T[];
|
|
8
|
+
//#endregion
|
|
9
|
+
export { arrayMove };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/utils/arrayMove.ts
|
|
2
|
+
/**
|
|
3
|
+
* 将数组中 `from` 位置的元素移动到 `to` 位置,返回新数组(不修改原数组)。
|
|
4
|
+
*
|
|
5
|
+
* 对标 `@dnd-kit/helpers` 的 `arrayMove`,用于行拖拽排序后的数据重排。
|
|
6
|
+
*/
|
|
7
|
+
function arrayMove(array, from, to) {
|
|
8
|
+
if (from === to || from < 0 || from >= array.length) return [...array];
|
|
9
|
+
const result = [...array];
|
|
10
|
+
const [moved] = result.splice(from, 1);
|
|
11
|
+
result.splice(to, 0, moved);
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { arrayMove };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ProColumnEllipsis } from "../interface.js";
|
|
2
|
+
import { TooltipProps } from "antdv-next";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/ellipsis.d.ts
|
|
5
|
+
/** 归一化后的列溢出配置,供渲染层消费 */
|
|
6
|
+
interface NormalizedEllipsis {
|
|
7
|
+
/** 是否启用溢出处理 */
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
/** 省略行数,≥1 */
|
|
10
|
+
lines: number;
|
|
11
|
+
/** 是否使用原生 title 属性展示完整文本 */
|
|
12
|
+
showTitle: boolean;
|
|
13
|
+
/** tooltip 配置;false 表示仅省略不显示 tooltip */
|
|
14
|
+
tooltip: false | TooltipProps;
|
|
15
|
+
}
|
|
16
|
+
/** 将 column.ellipsis 归一化为渲染层统一消费的结构 */
|
|
17
|
+
declare function normalizeEllipsis(ellipsis?: boolean | ProColumnEllipsis): NormalizedEllipsis;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { NormalizedEllipsis, normalizeEllipsis };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { isObject } from "@gx-design-vue/pro-utils";
|
|
2
|
+
//#region src/utils/ellipsis.ts
|
|
3
|
+
/** 将 column.ellipsis 归一化为渲染层统一消费的结构 */
|
|
4
|
+
function normalizeEllipsis(ellipsis) {
|
|
5
|
+
if (ellipsis === true) return {
|
|
6
|
+
enabled: true,
|
|
7
|
+
lines: 1,
|
|
8
|
+
showTitle: false,
|
|
9
|
+
tooltip: {}
|
|
10
|
+
};
|
|
11
|
+
if (isObject(ellipsis)) {
|
|
12
|
+
const rawLines = ellipsis.lines;
|
|
13
|
+
const lines = Number.isFinite(rawLines) && rawLines >= 1 ? Math.floor(rawLines) : 1;
|
|
14
|
+
const rawTooltip = ellipsis.tooltip;
|
|
15
|
+
return {
|
|
16
|
+
enabled: true,
|
|
17
|
+
lines,
|
|
18
|
+
showTitle: ellipsis.showTitle ?? false,
|
|
19
|
+
tooltip: rawTooltip === false ? false : { ...rawTooltip ?? {} }
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
enabled: false,
|
|
24
|
+
lines: 1,
|
|
25
|
+
showTitle: false,
|
|
26
|
+
tooltip: {}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { normalizeEllipsis };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/utils/flipAnimate.d.ts
|
|
2
|
+
interface FlipAnimateOptions {
|
|
3
|
+
/** 动画时长 ms,默认 200 */
|
|
4
|
+
duration?: number;
|
|
5
|
+
/** 缓动函数,默认 cubic-bezier(0.2,0,0,1)(对齐 dnd-kit motionEase) */
|
|
6
|
+
easing?: string;
|
|
7
|
+
}
|
|
8
|
+
interface FlipEntry {
|
|
9
|
+
/** 行唯一标识,支持 string | number(rowKey 可能是数字 id) */
|
|
10
|
+
key: string | number;
|
|
11
|
+
el: HTMLElement;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* FLIP 动画 —— 精简复刻 `@dnd-kit/dom` 的 `sortable#animate`。
|
|
15
|
+
*
|
|
16
|
+
* 用 Web Animations API(`element.animate`)+ CSS `translate` 属性(非 transform):
|
|
17
|
+
* 1. 取消元素上 transform/translate/scale 的 CSS transition(避免 getBoundingClientRect 取到中间帧)
|
|
18
|
+
* 2. 测新旧位置算 `delta = prev.top - next.top`(同时支持 X/Y)
|
|
19
|
+
* 3. `el.animate({ translate: [delta, 0] }, { duration, easing })`
|
|
20
|
+
*
|
|
21
|
+
* 命中 `prefers-reduced-motion` 时 duration 置 0。
|
|
22
|
+
*/
|
|
23
|
+
declare function flipAnimate(entries: FlipEntry[], prevRects: Map<string | number, DOMRect>, options?: FlipAnimateOptions): void;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { FlipAnimateOptions, FlipEntry, flipAnimate };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//#region src/utils/flipAnimate.ts
|
|
2
|
+
/**
|
|
3
|
+
* FLIP 动画 —— 精简复刻 `@dnd-kit/dom` 的 `sortable#animate`。
|
|
4
|
+
*
|
|
5
|
+
* 用 Web Animations API(`element.animate`)+ CSS `translate` 属性(非 transform):
|
|
6
|
+
* 1. 取消元素上 transform/translate/scale 的 CSS transition(避免 getBoundingClientRect 取到中间帧)
|
|
7
|
+
* 2. 测新旧位置算 `delta = prev.top - next.top`(同时支持 X/Y)
|
|
8
|
+
* 3. `el.animate({ translate: [delta, 0] }, { duration, easing })`
|
|
9
|
+
*
|
|
10
|
+
* 命中 `prefers-reduced-motion` 时 duration 置 0。
|
|
11
|
+
*/
|
|
12
|
+
function flipAnimate(entries, prevRects, options = {}) {
|
|
13
|
+
const { duration = 200, easing = "cubic-bezier(0.2,0,0,1)" } = options;
|
|
14
|
+
const finalDuration = typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches ? 0 : duration;
|
|
15
|
+
for (const { key, el } of entries) {
|
|
16
|
+
const prev = prevRects.get(key);
|
|
17
|
+
if (!prev) continue;
|
|
18
|
+
for (const animation of el.getAnimations()) {
|
|
19
|
+
const transitionProperty = animation.transitionProperty;
|
|
20
|
+
if (transitionProperty === "transform" || transitionProperty === "translate" || transitionProperty === "scale") animation.cancel();
|
|
21
|
+
}
|
|
22
|
+
const next = el.getBoundingClientRect();
|
|
23
|
+
const deltaX = prev.left - next.left;
|
|
24
|
+
const deltaY = prev.top - next.top;
|
|
25
|
+
if (deltaX === 0 && deltaY === 0) continue;
|
|
26
|
+
const animation = el.animate({ translate: [`${deltaX}px ${deltaY}px`, "0px 0px"] }, {
|
|
27
|
+
duration: finalDuration,
|
|
28
|
+
easing
|
|
29
|
+
});
|
|
30
|
+
const clearTranslate = () => {
|
|
31
|
+
el.style.translate = "";
|
|
32
|
+
};
|
|
33
|
+
if ("addEventListener" in animation) {
|
|
34
|
+
animation.addEventListener("finish", clearTranslate, { once: true });
|
|
35
|
+
animation.addEventListener("cancel", clearTranslate, { once: true });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { flipAnimate };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gx-design-vue/pro-table",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.0-alpha.
|
|
4
|
+
"version": "0.2.0-alpha.21",
|
|
5
5
|
"description": "Gx Design Pro Table",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "gx12358",
|
|
@@ -38,12 +38,13 @@
|
|
|
38
38
|
],
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@antdv-next/cssinjs": "^1.0.6",
|
|
41
|
-
"@
|
|
42
|
-
"@gx-design-vue/
|
|
43
|
-
"@gx-design-vue/
|
|
44
|
-
"@gx-design-vue/pro-
|
|
45
|
-
"@gx-design-vue/pro-
|
|
46
|
-
"
|
|
41
|
+
"@chenglou/pretext": "^0.0.8",
|
|
42
|
+
"@gx-design-vue/context": "^0.0.5-alpha.8",
|
|
43
|
+
"@gx-design-vue/icon": "^0.0.1-alpha.13",
|
|
44
|
+
"@gx-design-vue/pro-hooks": "^0.2.0-alpha.8",
|
|
45
|
+
"@gx-design-vue/pro-provider": "^0.1.0-alpha.17",
|
|
46
|
+
"@gx-design-vue/pro-utils": "^0.2.0-alpha.10",
|
|
47
|
+
"antdv-next": "^1.4.1",
|
|
47
48
|
"vue": ">=3.2.0"
|
|
48
49
|
},
|
|
49
50
|
"dependencies": {
|
|
@@ -54,13 +55,14 @@
|
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
56
57
|
"@antdv-next/cssinjs": "^1.0.6",
|
|
57
|
-
"
|
|
58
|
+
"@chenglou/pretext": "^0.0.8",
|
|
59
|
+
"antdv-next": "^1.4.1",
|
|
58
60
|
"vue": "^3.5.38",
|
|
59
|
-
"@gx-design-vue/icon": "^0.0.1-alpha.
|
|
60
|
-
"@gx-design-vue/
|
|
61
|
-
"@gx-design-vue/pro-
|
|
62
|
-
"@gx-design-vue/pro-
|
|
63
|
-
"@gx-design-vue/
|
|
61
|
+
"@gx-design-vue/icon": "^0.0.1-alpha.13",
|
|
62
|
+
"@gx-design-vue/pro-hooks": "^0.2.0-alpha.8",
|
|
63
|
+
"@gx-design-vue/pro-provider": "^0.1.0-alpha.17",
|
|
64
|
+
"@gx-design-vue/pro-utils": "^0.2.0-alpha.10",
|
|
65
|
+
"@gx-design-vue/context": "^0.0.5-alpha.8"
|
|
64
66
|
},
|
|
65
67
|
"browserslist": [
|
|
66
68
|
"> 1%",
|