@antdv-vue/pro-table 0.0.0-stage → 2.0.3
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/CHANGELOG.md +255 -0
- package/README.md +106 -2
- package/dist/InternalTable.d.ts +360 -0
- package/dist/InternalTable.js +444 -0
- package/dist/RenderTypings.d.ts +33 -0
- package/dist/RenderTypings.js +1 -0
- package/dist/ResizableTableTitle.d.ts +24 -0
- package/dist/ResizableTableTitle.js +89 -0
- package/dist/Store/Provide.d.ts +68 -0
- package/dist/Store/Provide.js +132 -0
- package/dist/Table.d.ts +363 -0
- package/dist/Table.js +151 -0
- package/dist/TableRender.d.ts +54 -0
- package/dist/TableRender.js +295 -0
- package/dist/components/Alert/index.d.ts +45 -0
- package/dist/components/Alert/index.js +94 -0
- package/dist/components/Alert/style/index.d.ts +8 -0
- package/dist/components/Alert/style/index.js +11 -0
- package/dist/components/ColumnSetting/CheckboxList.d.ts +24 -0
- package/dist/components/ColumnSetting/CheckboxList.js +138 -0
- package/dist/components/ColumnSetting/CheckboxListItem.d.ts +17 -0
- package/dist/components/ColumnSetting/CheckboxListItem.js +84 -0
- package/dist/components/ColumnSetting/GroupCheckboxList.d.ts +22 -0
- package/dist/components/ColumnSetting/GroupCheckboxList.js +82 -0
- package/dist/components/ColumnSetting/ToolTipIcon.d.ts +12 -0
- package/dist/components/ColumnSetting/ToolTipIcon.js +47 -0
- package/dist/components/ColumnSetting/index.d.ts +26 -0
- package/dist/components/ColumnSetting/index.js +117 -0
- package/dist/components/ColumnSetting/style/index.d.ts +8 -0
- package/dist/components/ColumnSetting/style/index.js +73 -0
- package/dist/components/DragSortTable/index.d.ts +375 -0
- package/dist/components/DragSortTable/index.js +166 -0
- package/dist/components/DragSortTable/style/index.d.ts +8 -0
- package/dist/components/DragSortTable/style/index.js +25 -0
- package/dist/components/Dropdown/Button.d.ts +20 -0
- package/dist/components/Dropdown/Button.js +155 -0
- package/dist/components/Dropdown/index.d.ts +27 -0
- package/dist/components/Dropdown/index.js +149 -0
- package/dist/components/EditableTable/CellEditorTable.d.ts +63 -0
- package/dist/components/EditableTable/CellEditorTable.js +167 -0
- package/dist/components/EditableTable/EditableTable.d.ts +67 -0
- package/dist/components/EditableTable/EditableTable.js +141 -0
- package/dist/components/EditableTable/InternalEditableTable.d.ts +189 -0
- package/dist/components/EditableTable/InternalEditableTable.js +508 -0
- package/dist/components/EditableTable/RowEditorTable.d.ts +63 -0
- package/dist/components/EditableTable/RowEditorTable.js +147 -0
- package/dist/components/EditableTable/context.d.ts +9 -0
- package/dist/components/EditableTable/context.js +11 -0
- package/dist/components/EditableTable/index.d.ts +5 -0
- package/dist/components/EditableTable/index.js +5 -0
- package/dist/components/Form/FormRender.d.ts +77 -0
- package/dist/components/Form/FormRender.js +198 -0
- package/dist/components/Form/index.d.ts +33 -0
- package/dist/components/Form/index.js +91 -0
- package/dist/components/ToolBar/DensityIcon.d.ts +22 -0
- package/dist/components/ToolBar/DensityIcon.js +71 -0
- package/dist/components/ToolBar/FullScreenIcon.d.ts +6 -0
- package/dist/components/ToolBar/FullScreenIcon.js +30 -0
- package/dist/components/ToolBar/HeaderMenu.d.ts +22 -0
- package/dist/components/ToolBar/HeaderMenu.js +84 -0
- package/dist/components/ToolBar/index.d.ts +102 -0
- package/dist/components/ToolBar/index.js +322 -0
- package/dist/components/ToolBar/style/index.d.ts +8 -0
- package/dist/components/ToolBar/style/index.js +116 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +10 -0
- package/dist/pro-table.esm.js +3274 -0
- package/dist/style/index.d.ts +11 -0
- package/dist/style/index.js +162 -0
- package/dist/typing.d.ts +409 -0
- package/dist/typing.js +1 -0
- package/dist/useFetchData.d.ts +10 -0
- package/dist/useFetchData.js +243 -0
- package/dist/utils/cellRenderToFromItem.d.ts +52 -0
- package/dist/utils/cellRenderToFromItem.js +163 -0
- package/dist/utils/columnRender.d.ts +54 -0
- package/dist/utils/columnRender.js +148 -0
- package/dist/utils/columnSort.d.ts +7 -0
- package/dist/utils/columnSort.js +17 -0
- package/dist/utils/genProColumnsToColumns.d.ts +69 -0
- package/dist/utils/genProColumnsToColumns.js +197 -0
- package/dist/utils/index.d.ts +122 -0
- package/dist/utils/index.js +227 -0
- package/dist/utils/useDragSort.d.ts +182 -0
- package/dist/utils/useDragSort.js +162 -0
- package/package.json +67 -3
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import * as _$vue from "vue";
|
|
2
|
+
import { ComputedRef, FunctionalComponent, Ref } from "vue";
|
|
3
|
+
import { GlobalToken } from "antdv-next";
|
|
4
|
+
import * as _$_v_c_table0 from "@v-c/table";
|
|
5
|
+
import * as _$_vue_shared0 from "@vue/shared";
|
|
6
|
+
import * as _$_v_c_table_dist_interface_js0 from "@v-c/table/dist/interface.js";
|
|
7
|
+
import { TableComponents } from "@v-c/table/dist/interface.js";
|
|
8
|
+
|
|
9
|
+
//#region src/utils/useDragSort.d.ts
|
|
10
|
+
interface UseDragSortOptions<T = any> {
|
|
11
|
+
dataSource?: ComputedRef<T[]>;
|
|
12
|
+
onDragSortEnd?: (beforeIndex?: number | string, afterIndex?: number | string, newDataSource?: T[]) => Promise<void> | void;
|
|
13
|
+
token: ComputedRef<GlobalToken> | Ref<GlobalToken>;
|
|
14
|
+
dragSortKey?: Ref<string | undefined>;
|
|
15
|
+
components?: Ref<TableComponents<T> | undefined>;
|
|
16
|
+
rowKey: Ref<any>;
|
|
17
|
+
dragHandle: FunctionalComponent<any>;
|
|
18
|
+
}
|
|
19
|
+
declare function useDragSort(props: UseDragSortOptions): {
|
|
20
|
+
DndContext: FunctionalComponent<any, {}, any, {}>;
|
|
21
|
+
components: {
|
|
22
|
+
ExpandIcon?: FunctionalComponent<_$_v_c_table0.ExpandIconProps<any>, {}, any, {}> | {
|
|
23
|
+
new (...args: any[]): _$_v_c_table0.ExpandIconProps<any>;
|
|
24
|
+
__isFragment?: never;
|
|
25
|
+
__isTeleport?: never;
|
|
26
|
+
__isSuspense?: never;
|
|
27
|
+
} | {
|
|
28
|
+
[x: string]: any;
|
|
29
|
+
setup?: ((this: void, props: _$_vue_shared0.LooseRequired<_$_v_c_table0.ExpandIconProps<any> & {}>, ctx: {
|
|
30
|
+
attrs: _$vue.Attrs;
|
|
31
|
+
slots: Readonly<{
|
|
32
|
+
[name: string]: _$vue.Slot<any> | undefined;
|
|
33
|
+
}>;
|
|
34
|
+
emit: ((event: unknown, ...args: any[]) => void) | ((event: string, ...args: any[]) => void);
|
|
35
|
+
expose: <Exposed extends Record<string, any> = Record<string, any>>(exposed?: Exposed) => void;
|
|
36
|
+
}) => any) | undefined;
|
|
37
|
+
name?: string | undefined;
|
|
38
|
+
template?: string | object | undefined;
|
|
39
|
+
render?: Function | undefined;
|
|
40
|
+
components?: Record<string, _$vue.Component<any, any, any, _$vue.ComputedOptions, _$vue.MethodOptions, {}, any>> | undefined;
|
|
41
|
+
directives?: Record<string, _$vue.Directive<any, any, string, any>> | undefined;
|
|
42
|
+
inheritAttrs?: boolean | undefined;
|
|
43
|
+
emits?: any;
|
|
44
|
+
slots?: {} | undefined;
|
|
45
|
+
expose?: string[] | undefined;
|
|
46
|
+
serverPrefetch?: (() => void | Promise<any>) | undefined;
|
|
47
|
+
compilerOptions?: {
|
|
48
|
+
isCustomElement?: ((tag: string) => boolean) | undefined;
|
|
49
|
+
whitespace?: "preserve" | "condense" | undefined;
|
|
50
|
+
comments?: boolean | undefined;
|
|
51
|
+
delimiters?: [string, string] | undefined;
|
|
52
|
+
} | undefined;
|
|
53
|
+
call?: ((this: unknown, ...args: unknown[]) => never) | undefined;
|
|
54
|
+
__isFragment?: never | undefined;
|
|
55
|
+
__isTeleport?: never | undefined;
|
|
56
|
+
__isSuspense?: never | undefined;
|
|
57
|
+
__defaults?: {} | undefined;
|
|
58
|
+
compatConfig?: {
|
|
59
|
+
GLOBAL_MOUNT?: boolean | "suppress-warning" | undefined;
|
|
60
|
+
GLOBAL_MOUNT_CONTAINER?: boolean | "suppress-warning" | undefined;
|
|
61
|
+
GLOBAL_EXTEND?: boolean | "suppress-warning" | undefined;
|
|
62
|
+
GLOBAL_PROTOTYPE?: boolean | "suppress-warning" | undefined;
|
|
63
|
+
GLOBAL_SET?: boolean | "suppress-warning" | undefined;
|
|
64
|
+
GLOBAL_DELETE?: boolean | "suppress-warning" | undefined;
|
|
65
|
+
GLOBAL_OBSERVABLE?: boolean | "suppress-warning" | undefined;
|
|
66
|
+
GLOBAL_PRIVATE_UTIL?: boolean | "suppress-warning" | undefined;
|
|
67
|
+
CONFIG_SILENT?: boolean | "suppress-warning" | undefined;
|
|
68
|
+
CONFIG_DEVTOOLS?: boolean | "suppress-warning" | undefined;
|
|
69
|
+
CONFIG_KEY_CODES?: boolean | "suppress-warning" | undefined;
|
|
70
|
+
CONFIG_PRODUCTION_TIP?: boolean | "suppress-warning" | undefined;
|
|
71
|
+
CONFIG_IGNORED_ELEMENTS?: boolean | "suppress-warning" | undefined;
|
|
72
|
+
CONFIG_WHITESPACE?: boolean | "suppress-warning" | undefined;
|
|
73
|
+
CONFIG_OPTION_MERGE_STRATS?: boolean | "suppress-warning" | undefined;
|
|
74
|
+
INSTANCE_SET?: boolean | "suppress-warning" | undefined;
|
|
75
|
+
INSTANCE_DELETE?: boolean | "suppress-warning" | undefined;
|
|
76
|
+
INSTANCE_DESTROY?: boolean | "suppress-warning" | undefined;
|
|
77
|
+
INSTANCE_EVENT_EMITTER?: boolean | "suppress-warning" | undefined;
|
|
78
|
+
INSTANCE_EVENT_HOOKS?: boolean | "suppress-warning" | undefined;
|
|
79
|
+
INSTANCE_CHILDREN?: boolean | "suppress-warning" | undefined;
|
|
80
|
+
INSTANCE_LISTENERS?: boolean | "suppress-warning" | undefined;
|
|
81
|
+
INSTANCE_SCOPED_SLOTS?: boolean | "suppress-warning" | undefined;
|
|
82
|
+
INSTANCE_ATTRS_CLASS_STYLE?: boolean | "suppress-warning" | undefined;
|
|
83
|
+
OPTIONS_DATA_FN?: boolean | "suppress-warning" | undefined;
|
|
84
|
+
OPTIONS_DATA_MERGE?: boolean | "suppress-warning" | undefined;
|
|
85
|
+
OPTIONS_BEFORE_DESTROY?: boolean | "suppress-warning" | undefined;
|
|
86
|
+
OPTIONS_DESTROYED?: boolean | "suppress-warning" | undefined;
|
|
87
|
+
WATCH_ARRAY?: boolean | "suppress-warning" | undefined;
|
|
88
|
+
PROPS_DEFAULT_THIS?: boolean | "suppress-warning" | undefined;
|
|
89
|
+
V_ON_KEYCODE_MODIFIER?: boolean | "suppress-warning" | undefined;
|
|
90
|
+
CUSTOM_DIR?: boolean | "suppress-warning" | undefined;
|
|
91
|
+
ATTR_FALSE_VALUE?: boolean | "suppress-warning" | undefined;
|
|
92
|
+
ATTR_ENUMERATED_COERCION?: boolean | "suppress-warning" | undefined;
|
|
93
|
+
TRANSITION_CLASSES?: boolean | "suppress-warning" | undefined;
|
|
94
|
+
TRANSITION_GROUP_ROOT?: boolean | "suppress-warning" | undefined;
|
|
95
|
+
COMPONENT_ASYNC?: boolean | "suppress-warning" | undefined;
|
|
96
|
+
COMPONENT_FUNCTIONAL?: boolean | "suppress-warning" | undefined;
|
|
97
|
+
COMPONENT_V_MODEL?: boolean | "suppress-warning" | undefined;
|
|
98
|
+
RENDER_FUNCTION?: boolean | "suppress-warning" | undefined;
|
|
99
|
+
FILTERS?: boolean | "suppress-warning" | undefined;
|
|
100
|
+
PRIVATE_APIS?: boolean | "suppress-warning" | undefined;
|
|
101
|
+
MODE?: 2 | 3 | ((comp: _$vue.Component | null) => 2 | 3) | undefined;
|
|
102
|
+
} | undefined;
|
|
103
|
+
data?: ((this: _$vue.CreateComponentPublicInstanceWithMixins<_$_v_c_table0.ExpandIconProps<any>, {}, {}, {}, _$vue.MethodOptions, any, any, {}, _$_v_c_table0.ExpandIconProps<any>, {}, false, {}, {}, {}, {}, string, {}, any, _$vue.ComponentProvideOptions, {
|
|
104
|
+
P: {};
|
|
105
|
+
B: {};
|
|
106
|
+
D: {};
|
|
107
|
+
C: _$vue.ComputedOptions;
|
|
108
|
+
M: _$vue.MethodOptions;
|
|
109
|
+
Defaults: {};
|
|
110
|
+
} & {
|
|
111
|
+
P: {};
|
|
112
|
+
B: {};
|
|
113
|
+
D: {};
|
|
114
|
+
C: {};
|
|
115
|
+
M: {};
|
|
116
|
+
Defaults: {};
|
|
117
|
+
}, {} & _$_v_c_table0.ExpandIconProps<any>, {}, {}, _$vue.ComputedOptions, _$vue.MethodOptions, {}>, vm: _$vue.CreateComponentPublicInstanceWithMixins<_$_v_c_table0.ExpandIconProps<any>, {}, {}, {}, _$vue.MethodOptions, any, any, {}, _$_v_c_table0.ExpandIconProps<any>, {}, false, {}, {}, {}, {}, string, {}, any, _$vue.ComponentProvideOptions, {
|
|
118
|
+
P: {};
|
|
119
|
+
B: {};
|
|
120
|
+
D: {};
|
|
121
|
+
C: _$vue.ComputedOptions;
|
|
122
|
+
M: _$vue.MethodOptions;
|
|
123
|
+
Defaults: {};
|
|
124
|
+
} & {
|
|
125
|
+
P: {};
|
|
126
|
+
B: {};
|
|
127
|
+
D: {};
|
|
128
|
+
C: {};
|
|
129
|
+
M: {};
|
|
130
|
+
Defaults: {};
|
|
131
|
+
}, {} & _$_v_c_table0.ExpandIconProps<any>, {}, {}, _$vue.ComputedOptions, _$vue.MethodOptions, {}>) => any) | undefined;
|
|
132
|
+
computed?: _$vue.ComputedOptions | undefined;
|
|
133
|
+
methods?: _$vue.MethodOptions | undefined;
|
|
134
|
+
watch?: {
|
|
135
|
+
[x: string]: (string | _$vue.WatchCallback | ({
|
|
136
|
+
handler: _$vue.WatchCallback | string;
|
|
137
|
+
} & _$vue.WatchOptions<boolean>)) | (string | _$vue.WatchCallback | ({
|
|
138
|
+
handler: _$vue.WatchCallback | string;
|
|
139
|
+
} & _$vue.WatchOptions<boolean>))[];
|
|
140
|
+
} | undefined;
|
|
141
|
+
provide?: _$vue.ComponentProvideOptions | undefined;
|
|
142
|
+
inject?: {} | string[] | undefined;
|
|
143
|
+
filters?: Record<string, Function> | undefined;
|
|
144
|
+
mixins?: any[] | undefined;
|
|
145
|
+
extends?: any;
|
|
146
|
+
beforeCreate?: (() => any) | undefined;
|
|
147
|
+
created?: (() => any) | undefined;
|
|
148
|
+
beforeMount?: (() => any) | undefined;
|
|
149
|
+
mounted?: (() => any) | undefined;
|
|
150
|
+
beforeUpdate?: (() => any) | undefined;
|
|
151
|
+
updated?: (() => any) | undefined;
|
|
152
|
+
activated?: (() => any) | undefined;
|
|
153
|
+
deactivated?: (() => any) | undefined;
|
|
154
|
+
beforeDestroy?: (() => any) | undefined;
|
|
155
|
+
beforeUnmount?: (() => any) | undefined;
|
|
156
|
+
destroyed?: (() => any) | undefined;
|
|
157
|
+
unmounted?: (() => any) | undefined;
|
|
158
|
+
renderTracked?: ((e: _$vue.DebuggerEvent) => void) | undefined;
|
|
159
|
+
renderTriggered?: ((e: _$vue.DebuggerEvent) => void) | undefined;
|
|
160
|
+
errorCaptured?: ((err: unknown, instance: _$vue.ComponentPublicInstance | null, info: string) => boolean | void) | undefined;
|
|
161
|
+
delimiters?: [string, string] | undefined;
|
|
162
|
+
__differentiator?: string | number | symbol | undefined;
|
|
163
|
+
__isBuiltIn?: boolean | undefined;
|
|
164
|
+
__file?: string | undefined;
|
|
165
|
+
__name?: string | undefined;
|
|
166
|
+
} | undefined;
|
|
167
|
+
table?: _$_v_c_table_dist_interface_js0.CustomizeComponent;
|
|
168
|
+
header?: {
|
|
169
|
+
table?: _$_v_c_table_dist_interface_js0.CustomizeComponent;
|
|
170
|
+
wrapper?: _$_v_c_table_dist_interface_js0.CustomizeComponent;
|
|
171
|
+
row?: _$_v_c_table_dist_interface_js0.CustomizeComponent;
|
|
172
|
+
cell?: _$_v_c_table_dist_interface_js0.CustomizeComponent;
|
|
173
|
+
} | undefined;
|
|
174
|
+
body?: _$_v_c_table_dist_interface_js0.CustomizeScrollBody<any> | {
|
|
175
|
+
wrapper?: _$_v_c_table_dist_interface_js0.CustomizeComponent;
|
|
176
|
+
row?: _$_v_c_table_dist_interface_js0.CustomizeComponent;
|
|
177
|
+
cell?: _$_v_c_table_dist_interface_js0.CustomizeComponent;
|
|
178
|
+
} | undefined;
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
//#endregion
|
|
182
|
+
export { UseDragSortOptions, useDragSort };
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { cloneVNode, computed, createVNode, defineComponent, inject, isVNode, markRaw, mergeProps, provide, reactive, ref, shallowRef } from "vue";
|
|
2
|
+
import { childrenToArray, isSpecialNode, useEffect } from "@antdv-vue/pro-utils";
|
|
3
|
+
import { FastColor } from "@ant-design/fast-color";
|
|
4
|
+
import { RestrictToVerticalAxis } from "@dnd-kit/abstract/modifiers";
|
|
5
|
+
import { PointerSensor } from "@dnd-kit/dom";
|
|
6
|
+
import { arrayMove } from "@dnd-kit/helpers";
|
|
7
|
+
import { DragDropProvider } from "@dnd-kit/vue";
|
|
8
|
+
import { isSortable, isSortableOperation, useSortable } from "@dnd-kit/vue/sortable";
|
|
9
|
+
//#region src/utils/useDragSort.tsx
|
|
10
|
+
function _isSlot(s) {
|
|
11
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
12
|
+
}
|
|
13
|
+
const sortableItemValueContextKey = Symbol("sortableItemValueContext");
|
|
14
|
+
const SortableItemContextValue = { Provider: /* @__PURE__ */ defineComponent({
|
|
15
|
+
name: "Provider",
|
|
16
|
+
inheritAttrs: false,
|
|
17
|
+
props: { value: {
|
|
18
|
+
type: Object,
|
|
19
|
+
default: void 0
|
|
20
|
+
} },
|
|
21
|
+
setup(props, { slots }) {
|
|
22
|
+
provide(sortableItemValueContextKey, { handle: props.value?.handle });
|
|
23
|
+
return () => slots.default?.();
|
|
24
|
+
}
|
|
25
|
+
}) };
|
|
26
|
+
/**
|
|
27
|
+
* 拖拽排序表格的行,
|
|
28
|
+
* 如果有 DragHandle 回给 dragSortKey 所在的行注入 provide 和 handle
|
|
29
|
+
* 如果没有整个行都支持拖拽
|
|
30
|
+
* @param props
|
|
31
|
+
*/
|
|
32
|
+
function SortableRow(props, { slots }) {
|
|
33
|
+
const { dragHandle: DragHandle, sortable, token, dragSortKey, handleRef, ...rest } = props;
|
|
34
|
+
if (dragSortKey) {
|
|
35
|
+
const doms = [];
|
|
36
|
+
childrenToArray(slots.default?.()).forEach((child, index) => {
|
|
37
|
+
if (isVNode(child) && !isSpecialNode(child)) {
|
|
38
|
+
if (child.props?.column?.key === dragSortKey) {
|
|
39
|
+
let _slot;
|
|
40
|
+
doms.push(createVNode(SortableItemContextValue.Provider, {
|
|
41
|
+
"key": child.key || index,
|
|
42
|
+
"value": { handle: createVNode(DragHandle, {
|
|
43
|
+
"ref": handleRef,
|
|
44
|
+
"rowData": child?.props?.record,
|
|
45
|
+
"index": child?.props?.index
|
|
46
|
+
}, null) }
|
|
47
|
+
}, _isSlot(_slot = cloneVNode(child, {
|
|
48
|
+
...child.props,
|
|
49
|
+
sortable,
|
|
50
|
+
token
|
|
51
|
+
})) ? _slot : { default: () => [_slot] }));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
doms.push(cloneVNode(child, {
|
|
56
|
+
...child.props,
|
|
57
|
+
sortable,
|
|
58
|
+
token
|
|
59
|
+
}));
|
|
60
|
+
});
|
|
61
|
+
return createVNode("tr", rest, [doms]);
|
|
62
|
+
}
|
|
63
|
+
return createVNode("tr", rest, [slots.default?.()]);
|
|
64
|
+
}
|
|
65
|
+
function SortContainer(props, { slots }) {
|
|
66
|
+
const { ref: $ref, ...rest } = props;
|
|
67
|
+
return createVNode("tbody", mergeProps(rest, { "ref": $ref }), [slots.default?.()]);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 拖拽排序表格的 cell,用与判断要不要展示 handle
|
|
71
|
+
*/
|
|
72
|
+
function SortableItemCell(props, { slots }) {
|
|
73
|
+
const { dragSortKey, sortable, token, ...rest } = props;
|
|
74
|
+
const bg = new FastColor(token.colorFillAlter).onBackground(token.colorBgContainer).toHexString();
|
|
75
|
+
const { handle } = inject(sortableItemValueContextKey, { handle: null });
|
|
76
|
+
if (handle) return createVNode("td", mergeProps(rest, { "style": {
|
|
77
|
+
...rest.style,
|
|
78
|
+
background: sortable?.isDragging?.value ? bg : void 0
|
|
79
|
+
} }), [createVNode("div", { "style": {
|
|
80
|
+
display: "flex",
|
|
81
|
+
alignItems: "center"
|
|
82
|
+
} }, [handle, slots.default?.()])]);
|
|
83
|
+
return createVNode("td", mergeProps(rest, { "style": {
|
|
84
|
+
...rest.style,
|
|
85
|
+
background: sortable?.isDragging?.value ? bg : void 0
|
|
86
|
+
} }), [slots.default?.()]);
|
|
87
|
+
}
|
|
88
|
+
function useDragSort(props) {
|
|
89
|
+
const components = reactive(props.components?.value || {});
|
|
90
|
+
const element = ref(null);
|
|
91
|
+
const DraggableContainer = (p, ctx) => SortContainer({
|
|
92
|
+
...p,
|
|
93
|
+
ref: element
|
|
94
|
+
}, ctx);
|
|
95
|
+
const DraggableBodyRow = /* @__PURE__ */ defineComponent((_, { attrs, slots }) => {
|
|
96
|
+
const itemRef = shallowRef(null);
|
|
97
|
+
const handleRef = shallowRef(null);
|
|
98
|
+
const rowId = computed(() => attrs["data-row-key"]);
|
|
99
|
+
const sortable = useSortable({
|
|
100
|
+
id: rowId,
|
|
101
|
+
index: computed(() => {
|
|
102
|
+
const dataSource = props.dataSource?.value || [];
|
|
103
|
+
const rowKey = props.rowKey.value ?? "index";
|
|
104
|
+
return dataSource.findIndex((item, itemIndex) => {
|
|
105
|
+
const itemKey = typeof rowKey === "function" ? rowKey(item, itemIndex) : item?.[rowKey];
|
|
106
|
+
return itemKey === rowId.value || String(itemKey) === String(rowId.value);
|
|
107
|
+
});
|
|
108
|
+
}),
|
|
109
|
+
type: "row",
|
|
110
|
+
accept: "row",
|
|
111
|
+
element: itemRef,
|
|
112
|
+
handle: handleRef
|
|
113
|
+
});
|
|
114
|
+
return () => SortableRow({
|
|
115
|
+
...attrs,
|
|
116
|
+
id: rowId.value,
|
|
117
|
+
dragSortKey: props.dragSortKey?.value,
|
|
118
|
+
dragHandle: props.dragHandle,
|
|
119
|
+
ref: itemRef,
|
|
120
|
+
token: props.token.value,
|
|
121
|
+
handleRef,
|
|
122
|
+
sortable
|
|
123
|
+
}, { slots });
|
|
124
|
+
}, {
|
|
125
|
+
name: "DraggableBodyRow",
|
|
126
|
+
inheritAttrs: false
|
|
127
|
+
});
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
if (props.dragSortKey?.value) components.body = {
|
|
130
|
+
...props.components?.value?.body || {},
|
|
131
|
+
wrapper: (props.components?.value?.body || {}).wrapper || DraggableContainer,
|
|
132
|
+
row: (props.components?.value?.body || {}).row || markRaw(DraggableBodyRow),
|
|
133
|
+
cell: (props.components?.value?.body || {}).cell || SortableItemCell
|
|
134
|
+
};
|
|
135
|
+
}, [props.dragSortKey]);
|
|
136
|
+
const handleDragEnd = (event) => {
|
|
137
|
+
if (event.canceled) return;
|
|
138
|
+
if (isSortableOperation(event.operation)) {
|
|
139
|
+
const { source } = event.operation;
|
|
140
|
+
if (isSortable(source)) {
|
|
141
|
+
const { initialIndex, index } = source;
|
|
142
|
+
if (initialIndex !== index) {
|
|
143
|
+
const newData = arrayMove(props.dataSource?.value || [], initialIndex, index);
|
|
144
|
+
props.onDragSortEnd?.(initialIndex, index, newData || []);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
const DndContext = (_, { slots }) => {
|
|
150
|
+
return createVNode(DragDropProvider, {
|
|
151
|
+
onDragEnd: handleDragEnd,
|
|
152
|
+
sensors: [PointerSensor],
|
|
153
|
+
modifiers: [RestrictToVerticalAxis]
|
|
154
|
+
}, slots);
|
|
155
|
+
};
|
|
156
|
+
return {
|
|
157
|
+
DndContext,
|
|
158
|
+
components
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
//#endregion
|
|
162
|
+
export { useDragSort };
|
package/package.json
CHANGED
|
@@ -1,6 +1,70 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antdv-vue/pro-table",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "2.0.3",
|
|
5
|
+
"description": "@antdv-vue/pro-table",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/bunnyblueair/pro-components.git",
|
|
9
|
+
"directory": "packages/table"
|
|
10
|
+
},
|
|
11
|
+
"sideEffects": [
|
|
12
|
+
"./dist/pro-table.esm.js"
|
|
13
|
+
],
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.js",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./dist/*": {
|
|
21
|
+
"types": "./dist/*.d.ts",
|
|
22
|
+
"import": "./dist/*.js",
|
|
23
|
+
"default": "./dist/*.js"
|
|
24
|
+
},
|
|
25
|
+
"./dist/pro-table.esm.js": "./dist/pro-table.esm.js"
|
|
26
|
+
},
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"module": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"files": [
|
|
31
|
+
"CHANGELOG.md",
|
|
32
|
+
"LICENSE",
|
|
33
|
+
"README.md",
|
|
34
|
+
"dist",
|
|
35
|
+
"package.json"
|
|
36
|
+
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "run-s build:esm build:full-esm",
|
|
39
|
+
"build:esm": "tsdown --config-loader unrun",
|
|
40
|
+
"build:full-esm": "vite build"
|
|
41
|
+
},
|
|
42
|
+
"browserslist": [
|
|
43
|
+
"last 2 versions",
|
|
44
|
+
"Firefox ESR",
|
|
45
|
+
"> 1%",
|
|
46
|
+
"ie >= 11"
|
|
47
|
+
],
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"antdv-next": ">=1.8.0",
|
|
50
|
+
"vue": ">=3.5.30"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@antdv-vue/pro-card": "3.0.2",
|
|
54
|
+
"@antdv-vue/pro-field": "2.0.2",
|
|
55
|
+
"@antdv-vue/pro-form": "2.1.1",
|
|
56
|
+
"@antdv-vue/pro-provider": "2.0.0",
|
|
57
|
+
"@antdv-vue/pro-utils": "2.1.1",
|
|
58
|
+
"@dnd-kit/abstract": "^0.4.0",
|
|
59
|
+
"@dnd-kit/collision": "^0.4.0",
|
|
60
|
+
"@dnd-kit/dom": "^0.4.0",
|
|
61
|
+
"@dnd-kit/helpers": "^0.4.0",
|
|
62
|
+
"@dnd-kit/vue": "^0.4.0"
|
|
63
|
+
},
|
|
64
|
+
"publishConfig": {
|
|
65
|
+
"access": "public"
|
|
66
|
+
},
|
|
67
|
+
"authors": [
|
|
68
|
+
"lucasjeke <lucasjekeqd@gmail.com> (https://github.com/lucasjeke)"
|
|
69
|
+
]
|
|
6
70
|
}
|