@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,30 @@
|
|
|
1
|
+
import { createVNode, defineComponent } from "vue";
|
|
2
|
+
import { useIntl } from "@antdv-vue/pro-provider";
|
|
3
|
+
import { isBrowser, useEffect, useState } from "@antdv-vue/pro-utils";
|
|
4
|
+
import { Tooltip } from "antdv-next";
|
|
5
|
+
import { FullscreenExitOutlined, FullscreenOutlined } from "@antdv-next/icons";
|
|
6
|
+
//#region src/components/ToolBar/FullScreenIcon.tsx
|
|
7
|
+
const FullScreenIcon = /* @__PURE__ */ defineComponent(() => {
|
|
8
|
+
const intl = useIntl();
|
|
9
|
+
const [fullscreen, setFullscreen] = useState(false);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (!isBrowser()) return;
|
|
12
|
+
document.onfullscreenchange = () => {
|
|
13
|
+
setFullscreen(!!document.fullscreenElement);
|
|
14
|
+
};
|
|
15
|
+
}, []);
|
|
16
|
+
return () => {
|
|
17
|
+
return fullscreen.value ? createVNode(Tooltip, { "title": intl.value.getMessage({
|
|
18
|
+
id: "tableToolBar.exitFullScreen",
|
|
19
|
+
defaultMessage: "全屏"
|
|
20
|
+
}) }, { default: () => [createVNode(FullscreenExitOutlined, null, null)] }) : createVNode(Tooltip, { "title": intl.value.getMessage({
|
|
21
|
+
id: "tableToolBar.fullScreen",
|
|
22
|
+
defaultMessage: "全屏"
|
|
23
|
+
}) }, { default: () => [createVNode(FullscreenOutlined, null, null)] });
|
|
24
|
+
};
|
|
25
|
+
}, {
|
|
26
|
+
name: "FullScreenIcon",
|
|
27
|
+
inheritAttrs: false
|
|
28
|
+
});
|
|
29
|
+
//#endregion
|
|
30
|
+
export { FullScreenIcon as default };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as _$vue from "vue";
|
|
2
|
+
import { Key, VueNode } from "@antdv-vue/pro-utils";
|
|
3
|
+
|
|
4
|
+
//#region src/components/ToolBar/HeaderMenu.d.ts
|
|
5
|
+
interface ToolBarMenuItem {
|
|
6
|
+
key: Key;
|
|
7
|
+
label: VueNode;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface ToolBarHeaderMenuProps {
|
|
11
|
+
type?: 'inline' | 'dropdown' | 'tab';
|
|
12
|
+
activeKey?: Key;
|
|
13
|
+
defaultActiveKey?: Key;
|
|
14
|
+
items?: ToolBarMenuItem[];
|
|
15
|
+
onChange?: (activeKey?: Key) => void;
|
|
16
|
+
prefixCls?: string;
|
|
17
|
+
hashId?: string;
|
|
18
|
+
cssVarCls?: string;
|
|
19
|
+
}
|
|
20
|
+
declare const HeaderMenu: _$vue.DefineSetupFnComponent<ToolBarHeaderMenuProps, {}, {}, ToolBarHeaderMenuProps & {}, _$vue.PublicProps>;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { ToolBarHeaderMenuProps, ToolBarMenuItem, HeaderMenu as default };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { createVNode, defineComponent, toRef } from "vue";
|
|
2
|
+
import { classNames, useMergedState } from "@v-c/util";
|
|
3
|
+
import { Dropdown, Space, Tabs } from "antdv-next";
|
|
4
|
+
import { DownOutlined } from "@antdv-next/icons";
|
|
5
|
+
//#region src/components/ToolBar/HeaderMenu.tsx
|
|
6
|
+
const HeaderMenu = /* @__PURE__ */ defineComponent((props) => {
|
|
7
|
+
const [activeKey, setActiveKey] = useMergedState(props.activeKey || props.defaultActiveKey, {
|
|
8
|
+
value: toRef(() => props.activeKey),
|
|
9
|
+
onChange: props.onChange
|
|
10
|
+
});
|
|
11
|
+
return () => {
|
|
12
|
+
const { items = [], hashId, cssVarCls, type = "inline", prefixCls } = props;
|
|
13
|
+
if (items.length < 1) return null;
|
|
14
|
+
const activeItem = items.find((item) => {
|
|
15
|
+
return item.key === activeKey.value;
|
|
16
|
+
}) || items[0];
|
|
17
|
+
if (type === "inline") return createVNode("div", { "class": classNames(`${prefixCls}-menu`, `${prefixCls}-inline-menu`, hashId, cssVarCls) }, [items.map((item, index) => createVNode("div", {
|
|
18
|
+
"key": item.key || index,
|
|
19
|
+
"onClick": () => setActiveKey(item.key),
|
|
20
|
+
"class": classNames(`${prefixCls}-inline-menu-item`, activeItem?.key === item.key ? `${prefixCls}-inline-menu-item-active` : void 0, hashId, cssVarCls)
|
|
21
|
+
}, [item.label]))]);
|
|
22
|
+
if (type === "tab") return createVNode(Tabs, {
|
|
23
|
+
"activeKey": activeItem?.key,
|
|
24
|
+
"items": items.map((item) => ({
|
|
25
|
+
...item,
|
|
26
|
+
key: item.key?.toString()
|
|
27
|
+
})),
|
|
28
|
+
"onTabClick": (key) => setActiveKey(key)
|
|
29
|
+
}, null);
|
|
30
|
+
return createVNode("div", { "class": classNames(`${prefixCls}-menu`, `${prefixCls}-dropdownmenu`, hashId, cssVarCls) }, [createVNode(Dropdown, {
|
|
31
|
+
"trigger": ["click"],
|
|
32
|
+
"menu": {
|
|
33
|
+
selectedKeys: [activeItem?.key],
|
|
34
|
+
onClick: (item) => {
|
|
35
|
+
setActiveKey(item.key);
|
|
36
|
+
},
|
|
37
|
+
items: items.map((item, index) => ({
|
|
38
|
+
key: item.key || index,
|
|
39
|
+
disabled: item.disabled,
|
|
40
|
+
label: item.label
|
|
41
|
+
}))
|
|
42
|
+
}
|
|
43
|
+
}, { default: () => createVNode(Space, { "class": classNames(`${prefixCls}-dropdownmenu-label`, hashId, cssVarCls) }, { default: () => [activeItem?.label, createVNode(DownOutlined, null, null)] }) })]);
|
|
44
|
+
};
|
|
45
|
+
}, {
|
|
46
|
+
props: {
|
|
47
|
+
type: {
|
|
48
|
+
type: String,
|
|
49
|
+
required: false
|
|
50
|
+
},
|
|
51
|
+
activeKey: {
|
|
52
|
+
type: [String, Number],
|
|
53
|
+
required: false
|
|
54
|
+
},
|
|
55
|
+
defaultActiveKey: {
|
|
56
|
+
type: [String, Number],
|
|
57
|
+
required: false
|
|
58
|
+
},
|
|
59
|
+
items: {
|
|
60
|
+
type: Array,
|
|
61
|
+
required: false
|
|
62
|
+
},
|
|
63
|
+
onChange: {
|
|
64
|
+
type: Function,
|
|
65
|
+
required: false
|
|
66
|
+
},
|
|
67
|
+
prefixCls: {
|
|
68
|
+
type: String,
|
|
69
|
+
required: false
|
|
70
|
+
},
|
|
71
|
+
hashId: {
|
|
72
|
+
type: String,
|
|
73
|
+
required: false
|
|
74
|
+
},
|
|
75
|
+
cssVarCls: {
|
|
76
|
+
type: String,
|
|
77
|
+
required: false
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
name: "ToolBarHeaderMenu",
|
|
81
|
+
inheritAttrs: false
|
|
82
|
+
});
|
|
83
|
+
//#endregion
|
|
84
|
+
export { HeaderMenu as default };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { OptionsRender, ToolBarRender } from "../../RenderTypings.js";
|
|
2
|
+
import { ColumnSettingProps } from "../ColumnSetting/index.js";
|
|
3
|
+
import { ToolBarHeaderMenuProps } from "./HeaderMenu.js";
|
|
4
|
+
import { ActionType, OptionSearchProps, ProColumns, SearchProps } from "../../typing.js";
|
|
5
|
+
import * as _$vue from "vue";
|
|
6
|
+
import { VNode } from "vue";
|
|
7
|
+
import { ProFieldValueObjectType, ProFieldValueType, ProSchemaComponentTypes, VueNode, WithFalse } from "@antdv-vue/pro-utils";
|
|
8
|
+
import { TabPaneProps } from "antdv-next";
|
|
9
|
+
import { FormItemTooltipType } from "antdv-next/dist/form/FormItemLabel";
|
|
10
|
+
import { Key as Key$1 } from "@v-c/util/dist/type";
|
|
11
|
+
|
|
12
|
+
//#region src/components/ToolBar/index.d.ts
|
|
13
|
+
type OptionsFunctionType<T> = (e: MouseEvent, action?: ActionType<any, T>) => void;
|
|
14
|
+
type OptionsType<T> = OptionsFunctionType<T> | boolean;
|
|
15
|
+
interface ToolBarSetting {
|
|
16
|
+
icon: VueNode;
|
|
17
|
+
tooltip?: FormItemTooltipType | string;
|
|
18
|
+
key?: string;
|
|
19
|
+
onClick?: (key?: string) => void;
|
|
20
|
+
}
|
|
21
|
+
/** Antd 默认直接导出了 vc 组件中的 Tab.Pane 组件。 */
|
|
22
|
+
type TabPaneProps$1 = TabPaneProps & {
|
|
23
|
+
key?: string;
|
|
24
|
+
};
|
|
25
|
+
interface ToolBarTabs {
|
|
26
|
+
activeKey?: string;
|
|
27
|
+
defaultActiveKey?: string;
|
|
28
|
+
onChange?: (activeKey: Key$1) => void;
|
|
29
|
+
items?: TabPaneProps$1[];
|
|
30
|
+
}
|
|
31
|
+
type ToolBarMenu = ToolBarHeaderMenuProps;
|
|
32
|
+
type SearchPropType = WithFalse<(SearchProps & {
|
|
33
|
+
onSearch: (searchValue: string, event?: Event | MouseEvent | KeyboardEvent, info?: {
|
|
34
|
+
source?: 'clear' | 'input';
|
|
35
|
+
}) => Promise<false | void> | false | void;
|
|
36
|
+
}) | VNode>;
|
|
37
|
+
type SettingPropType = VNode | ToolBarSetting;
|
|
38
|
+
interface OptionConfig<T, ValueType> {
|
|
39
|
+
density?: boolean;
|
|
40
|
+
fullScreen?: OptionsType<T>;
|
|
41
|
+
reload?: OptionsType<T>;
|
|
42
|
+
setting?: boolean | ColumnSettingProps<T, ValueType>;
|
|
43
|
+
search?: (OptionSearchProps & {
|
|
44
|
+
name?: string;
|
|
45
|
+
}) | boolean;
|
|
46
|
+
reloadIcon?: VNode | string | number | boolean | VNode[] | (() => VNode | VNode[]);
|
|
47
|
+
densityIcon?: VNode | string | number | boolean | VNode[] | (() => VNode | VNode[]);
|
|
48
|
+
}
|
|
49
|
+
interface BaseToolbarProps {
|
|
50
|
+
prefixCls?: string;
|
|
51
|
+
/** 标题 */
|
|
52
|
+
title?: VueNode;
|
|
53
|
+
/** 副标题 */
|
|
54
|
+
subTitle?: VueNode;
|
|
55
|
+
/** 标题提示 */
|
|
56
|
+
tooltip?: string | FormItemTooltipType;
|
|
57
|
+
/** 搜索输入栏相关配置 */
|
|
58
|
+
search?: SearchPropType;
|
|
59
|
+
/** 搜索回调 */
|
|
60
|
+
onSearch?: (keyWords: string) => void;
|
|
61
|
+
/** 工具栏右侧操作区 */
|
|
62
|
+
actions?: VueNode[];
|
|
63
|
+
/** 工作栏右侧设置区 */
|
|
64
|
+
settings?: SettingPropType[];
|
|
65
|
+
/** 是否多行展示 */
|
|
66
|
+
multipleLine?: boolean;
|
|
67
|
+
/** 过滤区,通常配合 LightFilter 使用 */
|
|
68
|
+
filter?: VueNode;
|
|
69
|
+
/** 标签页配置,仅当 `multipleLine` 为 true 时有效 */
|
|
70
|
+
tabs?: ToolBarTabs;
|
|
71
|
+
/** 菜单配置 */
|
|
72
|
+
menu?: ToolBarMenu;
|
|
73
|
+
}
|
|
74
|
+
interface ToolBarProps<T, ValueType> {
|
|
75
|
+
prefixCls?: string;
|
|
76
|
+
headerTitle?: VueNode;
|
|
77
|
+
tooltip?: string | FormItemTooltipType;
|
|
78
|
+
toolbar?: BaseToolbarProps;
|
|
79
|
+
toolBarRender?: ToolBarRender<T>;
|
|
80
|
+
action?: ActionType<Record<string, any>, T>;
|
|
81
|
+
options?: OptionConfig<T, ValueType> | false;
|
|
82
|
+
optionsRender?: OptionsRender<T, ValueType>;
|
|
83
|
+
loading?: boolean;
|
|
84
|
+
type?: ProSchemaComponentTypes;
|
|
85
|
+
selectedRowKeys?: (string | number)[];
|
|
86
|
+
selectedRows?: (T | undefined)[];
|
|
87
|
+
onSearch?: (keyWords: string) => void;
|
|
88
|
+
columns?: ProColumns<T, ValueType>[];
|
|
89
|
+
onFormSearchSubmit?: (params: Record<string, any>) => void;
|
|
90
|
+
searchNode?: VueNode;
|
|
91
|
+
hideToolbar?: boolean;
|
|
92
|
+
}
|
|
93
|
+
declare const Toolbar: new <T extends Record<string, any>, U extends Record<string, any>, ValueType extends (ProFieldValueType | ProFieldValueObjectType) = "text">(props: ToolBarProps<T, ValueType> & {} & _$vue.VNodeProps & _$vue.AllowedComponentProps & _$vue.ComponentCustomProps) => _$vue.CreateComponentPublicInstanceWithMixins<ToolBarProps<T, ValueType> & {}, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, _$vue.PublicProps, {}, false, {}, {}, {}, {}, string, {}, any, _$vue.ComponentProvideOptions, {
|
|
94
|
+
P: {};
|
|
95
|
+
B: {};
|
|
96
|
+
D: {};
|
|
97
|
+
C: {};
|
|
98
|
+
M: {};
|
|
99
|
+
Defaults: {};
|
|
100
|
+
}, ToolBarProps<T, ValueType> & {}, {}, {}, {}, {}, {}>;
|
|
101
|
+
//#endregion
|
|
102
|
+
export { BaseToolbarProps, OptionConfig, OptionsFunctionType, OptionsType, SearchPropType, ToolBarMenu, ToolBarProps, ToolBarSetting, ToolBarTabs, Toolbar as default };
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import { useTableContextInject } from "../../Store/Provide.js";
|
|
2
|
+
import ColumnSetting from "../ColumnSetting/index.js";
|
|
3
|
+
import DensityIcon from "./DensityIcon.js";
|
|
4
|
+
import FullScreenIcon from "./FullScreenIcon.js";
|
|
5
|
+
import HeaderMenu from "./HeaderMenu.js";
|
|
6
|
+
import style_default from "./style/index.js";
|
|
7
|
+
import { Fragment, cloneVNode, computed, createVNode, defineComponent, isVNode, mergeProps } from "vue";
|
|
8
|
+
import { proTheme, useIntl } from "@antdv-vue/pro-provider";
|
|
9
|
+
import { LabelIconTip, isSpecialNode, omitUndefined, useEffect, useState } from "@antdv-vue/pro-utils";
|
|
10
|
+
import { classNames } from "@v-c/util";
|
|
11
|
+
import { useConfig } from "antdv-next/config-provider/context";
|
|
12
|
+
import { InputSearch, Tabs, Tooltip } from "antdv-next";
|
|
13
|
+
import { unit } from "@antdv-next/cssinjs";
|
|
14
|
+
import { ReloadOutlined } from "@antdv-next/icons";
|
|
15
|
+
import ResizeObserver from "@v-c/resize-observer";
|
|
16
|
+
//#region src/components/ToolBar/index.tsx
|
|
17
|
+
/** Antd 默认直接导出了 vc 组件中的 Tab.Pane 组件。 */
|
|
18
|
+
/**
|
|
19
|
+
* 获取配置区域 DOM Item
|
|
20
|
+
*
|
|
21
|
+
* @param setting 配置项
|
|
22
|
+
*/
|
|
23
|
+
function getSettingItem(setting) {
|
|
24
|
+
if (isVNode(setting)) return setting;
|
|
25
|
+
if (setting) {
|
|
26
|
+
const { icon, tooltip, onClick, key } = setting;
|
|
27
|
+
if (icon && tooltip) {
|
|
28
|
+
if (!(isVNode(tooltip) || typeof tooltip === "string" || typeof tooltip === "number" || typeof tooltip === "boolean" || typeof tooltip === "function")) return tooltip;
|
|
29
|
+
return createVNode(Tooltip, { "title": tooltip }, { default: () => [createVNode("span", {
|
|
30
|
+
"key": key,
|
|
31
|
+
"onClick": () => {
|
|
32
|
+
if (onClick) onClick(key);
|
|
33
|
+
}
|
|
34
|
+
}, [icon])] });
|
|
35
|
+
}
|
|
36
|
+
return createVNode("span", {
|
|
37
|
+
"key": key,
|
|
38
|
+
"onClick": () => {
|
|
39
|
+
if (onClick) onClick(key);
|
|
40
|
+
}
|
|
41
|
+
}, [icon]);
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const ToolBarTabBar = ({ prefixCls, hashId, tabs, multipleLine, filtersNode }) => {
|
|
46
|
+
if (!multipleLine) return null;
|
|
47
|
+
return createVNode("div", { "class": classNames(`${prefixCls}-extra-line`, hashId) }, [tabs?.items && tabs?.items.length ? createVNode(Tabs, {
|
|
48
|
+
"style": { width: "100%" },
|
|
49
|
+
"defaultActiveKey": tabs.defaultActiveKey,
|
|
50
|
+
"activeKey": tabs.activeKey,
|
|
51
|
+
"items": tabs.items?.map((item, index) => ({
|
|
52
|
+
label: item.tab,
|
|
53
|
+
...item,
|
|
54
|
+
key: item.key?.toString() || index?.toString()
|
|
55
|
+
})),
|
|
56
|
+
"onChange": tabs.onChange,
|
|
57
|
+
"tabBarExtraContent": filtersNode
|
|
58
|
+
}, null) : filtersNode]);
|
|
59
|
+
};
|
|
60
|
+
function getButtonText({ intl }, options) {
|
|
61
|
+
return {
|
|
62
|
+
reload: {
|
|
63
|
+
text: intl.getMessage({
|
|
64
|
+
id: "tableToolBar.reload",
|
|
65
|
+
defaultMessage: "刷新"
|
|
66
|
+
}),
|
|
67
|
+
icon: options.reloadIcon ?? createVNode(ReloadOutlined, null, null)
|
|
68
|
+
},
|
|
69
|
+
density: {
|
|
70
|
+
text: intl.getMessage({
|
|
71
|
+
id: "tableToolBar.density",
|
|
72
|
+
defaultMessage: "表格密度"
|
|
73
|
+
}),
|
|
74
|
+
icon: createVNode(DensityIcon, { "icon": options.densityIcon }, null)
|
|
75
|
+
},
|
|
76
|
+
fullScreen: {
|
|
77
|
+
text: intl.getMessage({
|
|
78
|
+
id: "tableToolBar.fullScreen",
|
|
79
|
+
defaultMessage: "全屏"
|
|
80
|
+
}),
|
|
81
|
+
icon: createVNode(FullScreenIcon, null, null)
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* 渲染默认的 工具栏
|
|
87
|
+
*
|
|
88
|
+
* @param options
|
|
89
|
+
* @param defaultOptions
|
|
90
|
+
* @param actions
|
|
91
|
+
* @param columns
|
|
92
|
+
*/
|
|
93
|
+
function renderDefaultOption(options, defaultOptions, actions, columns, loading) {
|
|
94
|
+
return Object.keys(options).filter((item) => item).map((key) => {
|
|
95
|
+
const value = options[key];
|
|
96
|
+
if (!value) return null;
|
|
97
|
+
let onClick = value === true ? defaultOptions[key] : (event) => value?.(event, actions);
|
|
98
|
+
if (typeof onClick !== "function") onClick = () => {};
|
|
99
|
+
if (key === "setting") return createVNode(ColumnSetting, mergeProps(options[key], {
|
|
100
|
+
"columns": columns,
|
|
101
|
+
"key": key
|
|
102
|
+
}), null);
|
|
103
|
+
if (key === "fullScreen") return createVNode("span", {
|
|
104
|
+
"key": key,
|
|
105
|
+
"onClick": onClick
|
|
106
|
+
}, [createVNode(FullScreenIcon, null, null)]);
|
|
107
|
+
const optionItem = getButtonText(defaultOptions, options)[key];
|
|
108
|
+
if (optionItem) return createVNode("span", {
|
|
109
|
+
"key": key,
|
|
110
|
+
"onClick": onClick
|
|
111
|
+
}, [createVNode(Tooltip, { "title": optionItem.text }, { default: () => [key === "reload" ? cloneVNode(optionItem.icon, {
|
|
112
|
+
...optionItem.icon.props,
|
|
113
|
+
spin: loading
|
|
114
|
+
}) : optionItem.icon] })]);
|
|
115
|
+
return null;
|
|
116
|
+
}).filter((item) => item);
|
|
117
|
+
}
|
|
118
|
+
const Toolbar = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
|
|
119
|
+
const counter = useTableContextInject();
|
|
120
|
+
const intl = useIntl();
|
|
121
|
+
const config = useConfig();
|
|
122
|
+
const prefixCls = computed(() => props.prefixCls || config.value.getPrefixCls("pro"));
|
|
123
|
+
const baseClassName = computed(() => `${prefixCls.value}-table-list-toolbar`);
|
|
124
|
+
const { token } = proTheme.useToken();
|
|
125
|
+
const [hashId, cssVarCls] = style_default(baseClassName);
|
|
126
|
+
const [isMobile, setIsMobile] = useState(false);
|
|
127
|
+
const searchConfig = computed(() => {
|
|
128
|
+
if (props.toolbar?.search !== void 0) return props.toolbar.search;
|
|
129
|
+
if (!props.options) return false;
|
|
130
|
+
if (!props.options.search) return false;
|
|
131
|
+
/** 受控的value 和 onChange */
|
|
132
|
+
const defaultSearchConfig = {
|
|
133
|
+
value: counter.keyWords?.value,
|
|
134
|
+
onChange: (e) => counter.setKeyWords?.(e.target.value)
|
|
135
|
+
};
|
|
136
|
+
if (props.options.search === true) return defaultSearchConfig;
|
|
137
|
+
return {
|
|
138
|
+
...defaultSearchConfig,
|
|
139
|
+
...props.options.search
|
|
140
|
+
};
|
|
141
|
+
});
|
|
142
|
+
/**
|
|
143
|
+
* 获取搜索栏 DOM
|
|
144
|
+
*
|
|
145
|
+
*/
|
|
146
|
+
const searchNode = computed(() => {
|
|
147
|
+
if (!searchConfig.value) return null;
|
|
148
|
+
if (isVNode(searchConfig.value)) return searchConfig.value;
|
|
149
|
+
const { onSearch, ...inputSearchProps } = searchConfig.value;
|
|
150
|
+
return createVNode(InputSearch, mergeProps(inputSearchProps, {
|
|
151
|
+
"style": { width: unit(200) },
|
|
152
|
+
"placeholder": intl.value.getMessage({
|
|
153
|
+
id: "tableForm.inputPlaceholder",
|
|
154
|
+
defaultMessage: "请输入"
|
|
155
|
+
}),
|
|
156
|
+
"onSearch": async (...restParams) => {
|
|
157
|
+
if (await onSearch?.(...restParams) !== false) props.onSearch?.(restParams?.[0]);
|
|
158
|
+
}
|
|
159
|
+
}), null);
|
|
160
|
+
});
|
|
161
|
+
/** 轻量筛选组件 */
|
|
162
|
+
const filtersNode = computed(() => {
|
|
163
|
+
if (props.searchNode || props.toolbar?.filter) return createVNode("div", { "class": classNames(`${baseClassName.value}-filter`, hashId.value, cssVarCls.value) }, [props.searchNode, props.toolbar?.filter]);
|
|
164
|
+
return null;
|
|
165
|
+
});
|
|
166
|
+
/** 有没有 title,需要结合多个场景判断 */
|
|
167
|
+
const hasTitle = computed(() => props.toolbar?.menu || props.headerTitle || props.toolbar?.title || props.toolbar?.subTitle || props.toolbar?.tooltip);
|
|
168
|
+
const actions = computed(() => [...props.toolbar?.actions || [], ...props.toolBarRender ? props.toolBarRender(props.action, {
|
|
169
|
+
selectedRowKeys: props.selectedRowKeys,
|
|
170
|
+
selectedRows: props.selectedRows
|
|
171
|
+
}) : []]);
|
|
172
|
+
const actionDom = computed(() => {
|
|
173
|
+
if (!Array.isArray(actions.value)) return actions.value;
|
|
174
|
+
if (actions.value.length < 1) return null;
|
|
175
|
+
return createVNode("div", { "style": {
|
|
176
|
+
display: "flex",
|
|
177
|
+
alignItems: "center",
|
|
178
|
+
gap: `${token.value.marginXS}px`
|
|
179
|
+
} }, [actions.value.map((action, index) => {
|
|
180
|
+
if (!isVNode(action) || isVNode(action) && isSpecialNode(action)) return createVNode(Fragment, { "key": index }, [action]);
|
|
181
|
+
return cloneVNode(action, { ...action?.props });
|
|
182
|
+
})]);
|
|
183
|
+
});
|
|
184
|
+
const onSearch = async (keyword) => {
|
|
185
|
+
const { options, onFormSearchSubmit, action } = props;
|
|
186
|
+
if (!options || !options.search) return;
|
|
187
|
+
const { name = "keyword" } = options.search === true ? {} : options.search;
|
|
188
|
+
if (await options.search?.onSearch?.(keyword) === false) return;
|
|
189
|
+
action?.setPageInfo?.({ current: 1 });
|
|
190
|
+
onFormSearchSubmit?.(omitUndefined({
|
|
191
|
+
_timestamp: Date.now(),
|
|
192
|
+
[name]: keyword
|
|
193
|
+
}));
|
|
194
|
+
};
|
|
195
|
+
useEffect(() => {
|
|
196
|
+
if (counter.keyWords?.value === void 0) onSearch?.("");
|
|
197
|
+
}, [() => counter.keyWords?.value]);
|
|
198
|
+
const optionDom = computed(() => {
|
|
199
|
+
if (props.toolbar?.settings !== void 0) return props.toolbar.settings;
|
|
200
|
+
const defaultOptions = {
|
|
201
|
+
reload: () => props.action?.reload?.(),
|
|
202
|
+
density: true,
|
|
203
|
+
setting: true,
|
|
204
|
+
search: false,
|
|
205
|
+
fullScreen: () => props.action?.fullScreen?.()
|
|
206
|
+
};
|
|
207
|
+
if (props.options === false) return [];
|
|
208
|
+
const settings = renderDefaultOption({
|
|
209
|
+
...defaultOptions,
|
|
210
|
+
fullScreen: false,
|
|
211
|
+
...props.options
|
|
212
|
+
}, {
|
|
213
|
+
...defaultOptions,
|
|
214
|
+
intl: intl.value
|
|
215
|
+
}, props.action, props.columns, props.loading);
|
|
216
|
+
if (props.optionsRender) return props.optionsRender({
|
|
217
|
+
headerTitle: props.headerTitle,
|
|
218
|
+
tooltip: props.tooltip,
|
|
219
|
+
toolBarRender: props.toolBarRender,
|
|
220
|
+
action: props.action,
|
|
221
|
+
options: props.options,
|
|
222
|
+
selectedRowKeys: props.selectedRowKeys,
|
|
223
|
+
selectedRows: props.selectedRows,
|
|
224
|
+
toolbar: {
|
|
225
|
+
filter: props.searchNode,
|
|
226
|
+
...props.toolbar
|
|
227
|
+
},
|
|
228
|
+
onSearch,
|
|
229
|
+
columns: props.columns,
|
|
230
|
+
optionsRender: props.optionsRender
|
|
231
|
+
}, settings);
|
|
232
|
+
return settings;
|
|
233
|
+
});
|
|
234
|
+
const hasEnd = computed(() => !!(hasTitle.value && searchNode.value || !props.toolbar?.multipleLine && filtersNode.value || actionDom.value || optionDom.value?.length));
|
|
235
|
+
const hasStart = computed(() => props.tooltip || props.headerTitle || props.toolbar?.title || props.toolbar?.subTitle || props.toolbar?.menu || !hasTitle.value && searchNode.value);
|
|
236
|
+
const startTitleDom = computed(() => {
|
|
237
|
+
if (!hasStart.value && hasEnd.value) return createVNode("div", { "class": classNames(`${baseClassName.value}-left`, hashId.value, cssVarCls.value) }, null);
|
|
238
|
+
if (!props.toolbar?.menu && (hasTitle.value || !searchNode.value)) return createVNode("div", { "class": classNames(`${baseClassName.value}-left`, hashId.value, cssVarCls.value) }, [createVNode("div", { "class": classNames(`${baseClassName.value}-title`, hashId.value, cssVarCls.value) }, [createVNode(LabelIconTip, {
|
|
239
|
+
"tooltip": props.tooltip || props.toolbar?.tooltip,
|
|
240
|
+
"label": props.headerTitle || props.toolbar?.title,
|
|
241
|
+
"subTitle": props.toolbar?.subTitle
|
|
242
|
+
}, null)])]);
|
|
243
|
+
return createVNode("div", { "class": classNames(`${baseClassName.value}-left`, hashId.value, cssVarCls.value, {
|
|
244
|
+
[`${baseClassName.value}-left-has-tabs`]: props.toolbar?.menu?.type === "tab",
|
|
245
|
+
[`${baseClassName.value}-left-has-dropdown`]: props.toolbar?.menu?.type === "dropdown",
|
|
246
|
+
[`${baseClassName.value}-left-has-inline-menu`]: props.toolbar?.menu?.type === "inline"
|
|
247
|
+
}) }, [
|
|
248
|
+
hasTitle.value && !props.toolbar?.menu && createVNode("div", { "class": classNames(`${baseClassName.value}-title`, hashId.value, cssVarCls.value) }, [createVNode(LabelIconTip, {
|
|
249
|
+
"tooltip": props.tooltip,
|
|
250
|
+
"label": props.toolbar?.title,
|
|
251
|
+
"subTitle": props.toolbar?.subTitle
|
|
252
|
+
}, null)]),
|
|
253
|
+
props.toolbar?.menu && createVNode(HeaderMenu, mergeProps(props.toolbar?.menu, {
|
|
254
|
+
"prefixCls": baseClassName.value,
|
|
255
|
+
"hashId": hashId.value,
|
|
256
|
+
"cssVarCls": cssVarCls.value
|
|
257
|
+
}), null),
|
|
258
|
+
!hasTitle.value && searchNode.value ? createVNode("div", { "class": classNames(`${prefixCls.value}-search`, hashId.value, cssVarCls.value) }, [searchNode.value]) : null
|
|
259
|
+
]);
|
|
260
|
+
});
|
|
261
|
+
const endTitleDom = computed(() => {
|
|
262
|
+
if (!hasEnd.value) return null;
|
|
263
|
+
return createVNode("div", {
|
|
264
|
+
"class": classNames(`${baseClassName.value}-right`, hashId.value),
|
|
265
|
+
"style": isMobile.value ? {} : { alignItems: "center" }
|
|
266
|
+
}, [
|
|
267
|
+
!props.toolbar?.multipleLine ? filtersNode.value : null,
|
|
268
|
+
hasTitle.value && searchNode.value ? createVNode("div", { "class": classNames(`${baseClassName.value}-search`, hashId.value) }, [searchNode.value]) : null,
|
|
269
|
+
actionDom.value,
|
|
270
|
+
optionDom.value?.length ? createVNode("div", { "class": classNames(`${baseClassName.value}-setting-items`, hashId.value) }, [optionDom.value.map((setting, index) => {
|
|
271
|
+
const settingItem = getSettingItem(setting);
|
|
272
|
+
return createVNode("div", {
|
|
273
|
+
"key": index,
|
|
274
|
+
"class": classNames(`${baseClassName.value}-setting-item`, hashId.value)
|
|
275
|
+
}, [settingItem]);
|
|
276
|
+
})]) : null
|
|
277
|
+
]);
|
|
278
|
+
});
|
|
279
|
+
const titleNode = computed(() => {
|
|
280
|
+
if (!hasEnd.value && !hasStart.value) return null;
|
|
281
|
+
return createVNode("div", { "class": classNames(`${baseClassName.value}-container`, hashId.value, { [`${baseClassName.value}-container-mobile`]: isMobile.value }) }, [startTitleDom.value, endTitleDom.value]);
|
|
282
|
+
});
|
|
283
|
+
expose({});
|
|
284
|
+
return () => {
|
|
285
|
+
const { hideToolbar, toolbar } = props;
|
|
286
|
+
if (hideToolbar) return null;
|
|
287
|
+
return createVNode(ResizeObserver, { "onResize": ({ width }) => {
|
|
288
|
+
if (width < 375 !== isMobile.value) setIsMobile(width < 375);
|
|
289
|
+
} }, { default: () => [createVNode("div", {
|
|
290
|
+
"class": classNames(baseClassName.value, hashId.value, attrs.class),
|
|
291
|
+
"style": attrs.style
|
|
292
|
+
}, [titleNode.value, createVNode(ToolBarTabBar, {
|
|
293
|
+
"filtersNode": filtersNode.value,
|
|
294
|
+
"hashId": hashId.value,
|
|
295
|
+
"prefixCls": prefixCls.value,
|
|
296
|
+
"tabs": toolbar?.tabs,
|
|
297
|
+
"multipleLine": toolbar?.multipleLine
|
|
298
|
+
}, null)])] });
|
|
299
|
+
};
|
|
300
|
+
}, {
|
|
301
|
+
name: "Toolbar",
|
|
302
|
+
inheritAttrs: false,
|
|
303
|
+
props: [
|
|
304
|
+
"action",
|
|
305
|
+
"type",
|
|
306
|
+
"columns",
|
|
307
|
+
"headerTitle",
|
|
308
|
+
"onSearch",
|
|
309
|
+
"options",
|
|
310
|
+
"optionsRender",
|
|
311
|
+
"selectedRowKeys",
|
|
312
|
+
"selectedRows",
|
|
313
|
+
"toolBarRender",
|
|
314
|
+
"toolbar",
|
|
315
|
+
"tooltip",
|
|
316
|
+
"searchNode",
|
|
317
|
+
"hideToolbar",
|
|
318
|
+
"loading"
|
|
319
|
+
]
|
|
320
|
+
});
|
|
321
|
+
//#endregion
|
|
322
|
+
export { Toolbar as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as _$vue from "vue";
|
|
2
|
+
import { ProAliasCssVarToken } from "@antdv-vue/pro-provider";
|
|
3
|
+
|
|
4
|
+
//#region src/components/ToolBar/style/index.d.ts
|
|
5
|
+
interface ProTableToolBarToken extends ProAliasCssVarToken {}
|
|
6
|
+
declare const _default: (prefixCls: _$vue.Ref<string>, rootCls?: _$vue.Ref<string | undefined>) => readonly [_$vue.Ref<string, string>, _$vue.ComputedRef<string | undefined>];
|
|
7
|
+
//#endregion
|
|
8
|
+
export { ProTableToolBarToken, _default as default };
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { useStyle } from "@antdv-vue/pro-provider";
|
|
2
|
+
import { mergeToken } from "@antdv-next/cssinjs";
|
|
3
|
+
//#region src/components/ToolBar/style/index.tsx
|
|
4
|
+
const genProTableToolBarStyle = (token) => {
|
|
5
|
+
return { [token.componentCls]: {
|
|
6
|
+
lineHeight: "1",
|
|
7
|
+
"&-container": {
|
|
8
|
+
display: "flex",
|
|
9
|
+
justifyContent: "space-between",
|
|
10
|
+
paddingBlock: token.padding,
|
|
11
|
+
paddingInline: 0,
|
|
12
|
+
"&-mobile": { flexDirection: "column" }
|
|
13
|
+
},
|
|
14
|
+
"&-title": {
|
|
15
|
+
display: "flex",
|
|
16
|
+
alignItems: "center",
|
|
17
|
+
justifyContent: "flex-start",
|
|
18
|
+
color: token.colorTextHeading,
|
|
19
|
+
fontWeight: "500",
|
|
20
|
+
fontSize: token.fontSizeLG
|
|
21
|
+
},
|
|
22
|
+
"&-search:not(:last-child)": {
|
|
23
|
+
display: "flex",
|
|
24
|
+
alignItems: "center",
|
|
25
|
+
justifyContent: "flex-start"
|
|
26
|
+
},
|
|
27
|
+
"&-setting-item": {
|
|
28
|
+
marginBlock: 0,
|
|
29
|
+
marginInline: 4,
|
|
30
|
+
color: token.colorIconHover,
|
|
31
|
+
fontSize: token.fontSizeLG,
|
|
32
|
+
cursor: "pointer",
|
|
33
|
+
"> span": {
|
|
34
|
+
display: "block",
|
|
35
|
+
width: "100%",
|
|
36
|
+
height: "100%"
|
|
37
|
+
},
|
|
38
|
+
"&:hover": { color: token.colorPrimary }
|
|
39
|
+
},
|
|
40
|
+
"&-left": {
|
|
41
|
+
display: "flex",
|
|
42
|
+
flexWrap: "wrap",
|
|
43
|
+
alignItems: "center",
|
|
44
|
+
gap: token.marginXS,
|
|
45
|
+
justifyContent: "flex-start",
|
|
46
|
+
maxWidth: "calc(100% - 200px)",
|
|
47
|
+
[`${token.antCls}-tabs`]: { width: "100%" },
|
|
48
|
+
"&-has-tabs": { overflow: "hidden" }
|
|
49
|
+
},
|
|
50
|
+
"&-right": {
|
|
51
|
+
flex: 1,
|
|
52
|
+
display: "flex",
|
|
53
|
+
flexWrap: "wrap",
|
|
54
|
+
justifyContent: "flex-end",
|
|
55
|
+
gap: token.marginXS
|
|
56
|
+
},
|
|
57
|
+
"&-extra-line": { marginBlockEnd: token.margin },
|
|
58
|
+
"&-setting-items": {
|
|
59
|
+
display: "flex",
|
|
60
|
+
gap: token.marginXS,
|
|
61
|
+
lineHeight: "32px",
|
|
62
|
+
alignItems: "center"
|
|
63
|
+
},
|
|
64
|
+
"&-filter": {
|
|
65
|
+
"&:not(:last-child)": { marginInlineEnd: token.margin },
|
|
66
|
+
display: "flex",
|
|
67
|
+
alignItems: "center",
|
|
68
|
+
[`div$${token.antCls}-pro-table-search`]: {
|
|
69
|
+
marginBlock: 0,
|
|
70
|
+
marginInline: 0,
|
|
71
|
+
paddingBlock: 0,
|
|
72
|
+
paddingInline: 0
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"&-inline-menu-item": {
|
|
76
|
+
display: "inline-block",
|
|
77
|
+
marginInlineEnd: token.marginLG,
|
|
78
|
+
cursor: "pointer",
|
|
79
|
+
opacity: "0.75",
|
|
80
|
+
"&-active": {
|
|
81
|
+
fontWeight: "bold",
|
|
82
|
+
opacity: "1"
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
[`${token.antCls}-tabs-top > ${token.antCls}-tabs-nav`]: {
|
|
86
|
+
marginBlockEnd: 0,
|
|
87
|
+
"&::before": { borderBlockEnd: 0 },
|
|
88
|
+
[`${token.antCls}-tabs-nav-list`]: {
|
|
89
|
+
marginBlockStart: 0,
|
|
90
|
+
"${token.antCls}-tabs-tab": { paddingBlockStart: 0 }
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"&-dropdownmenu-label": {
|
|
94
|
+
fontWeight: "bold",
|
|
95
|
+
fontSize: token.fontSizeIcon,
|
|
96
|
+
textAlign: "center",
|
|
97
|
+
cursor: "pointer"
|
|
98
|
+
},
|
|
99
|
+
"@media (max-width: 768px)": { [token.componentCls]: {
|
|
100
|
+
"&-container": {
|
|
101
|
+
display: "flex",
|
|
102
|
+
flexWrap: "wrap",
|
|
103
|
+
flexDirection: "column"
|
|
104
|
+
},
|
|
105
|
+
"&-left": {
|
|
106
|
+
marginBlockEnd: "16px",
|
|
107
|
+
maxWidth: "100%"
|
|
108
|
+
}
|
|
109
|
+
} }
|
|
110
|
+
} };
|
|
111
|
+
};
|
|
112
|
+
var style_default = useStyle(`ProTableToolBar`, (token) => {
|
|
113
|
+
return [genProTableToolBarStyle(mergeToken(token, {}))];
|
|
114
|
+
});
|
|
115
|
+
//#endregion
|
|
116
|
+
export { style_default as default };
|