@dazhicheng/ui 1.5.266 → 1.6.1
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/components/tt-api-component/index.js +4 -3
- package/dist/components/tt-api-component/index.vue2.js +4 -3
- package/dist/components/tt-area/TtArea.vue.js +1 -1
- package/dist/components/tt-area/TtArea.vue3.js +8 -7
- package/dist/components/tt-button/index.js +5 -4
- package/dist/components/tt-button/index.vue2.js +4 -3
- package/dist/components/tt-checkbox/index.js +4 -3
- package/dist/components/tt-checkbox/index.vue.js +4 -3
- package/dist/components/tt-drawer/index.js +4 -3
- package/dist/components/tt-drawer/src/RenderDrawer.vue.js +4 -3
- package/dist/components/tt-drawer/src/components/DrawerFooter.vue.js +8 -7
- package/dist/components/tt-drawer/src/components/DrawerHeader.vue.js +2 -2
- package/dist/components/tt-drawer/src/components/DrawerHeader.vue2.js +3 -2
- package/dist/components/tt-drawer/src/hooks/useResizable.js +2 -2
- package/dist/components/tt-drawer/src/props.js +3 -2
- package/dist/components/tt-drawer/src/utils/drawer-api.js +4 -2
- package/dist/components/tt-empty/index.js +9 -8
- package/dist/components/tt-form/index.js +10 -9
- package/dist/components/tt-form/src/components/ExpandableArrow.vue2.js +3 -2
- package/dist/components/tt-form/src/components/FormActions.vue2.js +4 -2
- package/dist/components/tt-form/src/form/FormDescription.vue.js +3 -2
- package/dist/components/tt-form/src/form/FormItem.vue.js +6 -5
- package/dist/components/tt-form/src/form/FormLabel.vue.js +8 -7
- package/dist/components/tt-form/src/form/RenderContent.vue.js +4 -3
- package/dist/components/tt-form/src/form-render/FormField.vue2.js +30 -28
- package/dist/components/tt-form/src/form-render/FormLabel.vue2.js +4 -2
- package/dist/components/tt-form/src/form-render/array-register/FormArrayRegister.d.ts +3 -3
- package/dist/components/tt-form/src/form-render/array-register/FormArrayRegister.js +1 -0
- package/dist/components/tt-form/src/form-render/array-register/utils.js +6 -4
- package/dist/components/tt-form/src/form-render/dependencies.js +19 -18
- package/dist/components/tt-form/src/form-render/form.vue2.js +4 -2
- package/dist/components/tt-form/src/form-render/helper.js +15 -14
- package/dist/components/tt-form/src/form-render/rootWrapperClass.js +3 -2
- package/dist/components/tt-form/src/formApi.js +3 -2
- package/dist/components/tt-form/src/group-form/GroupForm.vue2.js +4 -3
- package/dist/components/tt-form/src/group-form/GroupSection.vue2.js +2 -0
- package/dist/components/tt-form/src/group-form/LazyFormField.vue.js +4 -2
- package/dist/components/tt-form/src/group-form/groupFormApi.js +4 -3
- package/dist/components/tt-form/src/hooks/useForwardPriorityValues.js +3 -2
- package/dist/components/tt-form/src/hooks/useSelectCollapse.js +28 -27
- package/dist/components/tt-form/src/index.vue2.js +3 -2
- package/dist/components/tt-form/src/useFormContext.js +11 -10
- package/dist/components/tt-form-item-error-tooltip/index.js +5 -4
- package/dist/components/tt-form-item-error-tooltip/index.vue.js +4 -3
- package/dist/components/tt-icon/index.js +6 -5
- package/dist/components/tt-icon/index.vue.js +2 -2
- package/dist/components/tt-image/index.js +6 -5
- package/dist/components/tt-image/src/components/ImageViewer.js +7 -6
- package/dist/components/tt-loading/index.js +4 -3
- package/dist/components/tt-loading/src/directive.js +24 -23
- package/dist/components/tt-loading/src/loading.vue.js +2 -2
- package/dist/components/tt-log/index.js +4 -3
- package/dist/components/tt-log/index.vue.js +3 -2
- package/dist/components/tt-modal/index.js +3 -2
- package/dist/components/tt-modal/src/RenderModal.vue.js +3 -2
- package/dist/components/tt-modal/src/components/ModalFooter.vue2.js +3 -2
- package/dist/components/tt-modal/src/components/ModalHeader.vue2.js +3 -2
- package/dist/components/tt-modal/src/components/ModalWrapper.vue.js +15 -14
- package/dist/components/tt-modal/src/props.js +3 -2
- package/dist/components/tt-modal/src/utils/modal-api.js +4 -2
- package/dist/components/tt-modal-form/index.vue.js +4 -3
- package/dist/components/tt-nav-anchor/index.js +4 -3
- package/dist/components/tt-nav-anchor/src/TtNavAnchor.vue.js +15 -14
- package/dist/components/tt-panel-select/index.js +4 -3
- package/dist/components/tt-panel-select/src/components/PanelMiddle.vue.d.ts +2 -2
- package/dist/components/tt-panel-select/src/hooks/usePanelData.js +95 -87
- package/dist/components/tt-panel-select/src/index.vue.js +4 -2
- package/dist/components/tt-radio-group/index.js +4 -3
- package/dist/components/tt-radio-group/index.vue.js +7 -6
- package/dist/components/tt-select/index.js +4 -3
- package/dist/components/tt-select/src/Select.vue.d.ts +12 -12
- package/dist/components/tt-select/src/Select.vue.js +4 -3
- package/dist/components/tt-select/src/components/SelectTable.vue.d.ts +116 -7
- package/dist/components/tt-select/src/components/SelectTable.vue.js +3 -2
- package/dist/components/tt-select/src/components/Table.vue.d.ts +8 -8
- package/dist/components/tt-select/src/components/Table.vue.js +3 -2
- package/dist/components/tt-select/src/hooks/useDataSource.js +4 -3
- package/dist/components/tt-select/src/hooks/useKeyboard.d.ts +7 -1
- package/dist/components/tt-select/src/hooks/useSelect.js +3 -2
- package/dist/components/tt-select/src/hooks/useSelectTableEvent.d.ts +1 -1
- package/dist/components/tt-select/src/hooks/useSelectTableEvent.js +28 -27
- package/dist/components/tt-select/src/props.d.ts +2 -2
- package/dist/components/tt-table/index.d.ts +526 -361
- package/dist/components/tt-table/index.js +7 -5
- package/dist/components/tt-table/src/Table.vue.d.ts +308 -218
- package/dist/components/tt-table/src/Table.vue.js +406 -618
- package/dist/components/tt-table/src/TableForm.vue.d.ts +384 -19
- package/dist/components/tt-table/src/TableForm.vue.js +219 -229
- package/dist/components/tt-table/src/components/TableAction.vue.js +110 -131
- package/dist/components/tt-table/src/components/TableButtons.js +30 -29
- package/dist/components/tt-table/src/components/TableColumnModal.vue2.js +88 -84
- package/dist/components/tt-table/src/components/TableToolbarTools.vue.d.ts +80 -0
- package/dist/components/tt-table/src/components/{TableToobalTools.vue.js → TableToolbarTools.vue.js} +34 -35
- package/dist/components/tt-table/src/components/TableToolbarTools.vue2.js +4 -0
- package/dist/components/tt-table/src/emits.d.ts +10 -1
- package/dist/components/tt-table/src/emits.js +2 -1
- package/dist/components/tt-table/src/hooks/useColumnPersistence.d.ts +19 -0
- package/dist/components/tt-table/src/hooks/useColumnPersistence.js +64 -0
- package/dist/components/tt-table/src/hooks/useColumns.d.ts +505 -21
- package/dist/components/tt-table/src/hooks/useColumns.js +101 -245
- package/dist/components/tt-table/src/hooks/useGridProps.d.ts +36 -0
- package/dist/components/tt-table/src/hooks/useGridProps.js +121 -0
- package/dist/components/tt-table/src/hooks/useKeyboardNav.d.ts +11 -0
- package/dist/components/tt-table/src/hooks/useKeyboardNav.js +98 -0
- package/dist/components/tt-table/src/hooks/usePagination.d.ts +14 -8
- package/dist/components/tt-table/src/hooks/usePagination.js +30 -33
- package/dist/components/tt-table/src/hooks/useQuery.d.ts +41 -0
- package/dist/components/tt-table/src/hooks/useQuery.js +148 -0
- package/dist/components/tt-table/src/hooks/useRowIdentity.d.ts +22 -0
- package/dist/components/tt-table/src/hooks/useRowIdentity.js +97 -0
- package/dist/components/tt-table/src/hooks/useRowSelection.d.ts +24 -12
- package/dist/components/tt-table/src/hooks/useRowSelection.js +95 -70
- package/dist/components/tt-table/src/hooks/{useLeftRightSlot.d.ts → useSideSlot.d.ts} +25 -17
- package/dist/components/tt-table/src/hooks/useSideSlot.js +78 -0
- package/dist/components/tt-table/src/hooks/useSyncProps.d.ts +12 -0
- package/dist/components/tt-table/src/hooks/useSyncProps.js +56 -0
- package/dist/components/tt-table/src/hooks/useTableData.d.ts +71 -0
- package/dist/components/tt-table/src/hooks/useTableData.js +308 -0
- package/dist/components/tt-table/src/hooks/useTableFooter.d.ts +15 -0
- package/dist/components/tt-table/src/hooks/useTableFooter.js +47 -0
- package/dist/components/tt-table/src/hooks/useTableForm.d.ts +10 -5
- package/dist/components/tt-table/src/hooks/useTableForm.js +56 -48
- package/dist/components/tt-table/src/hooks/useTableMethods.d.ts +165 -0
- package/dist/components/tt-table/src/hooks/useTableMethods.js +183 -0
- package/dist/components/tt-table/src/hooks/useTableRender.d.ts +57 -55
- package/dist/components/tt-table/src/props.d.ts +326 -153
- package/dist/components/tt-table/src/props.js +125 -271
- package/dist/components/tt-table/src/table-defaults.d.ts +25 -0
- package/dist/components/tt-table/src/table-defaults.js +71 -0
- package/dist/components/tt-table/src/table-mutation-events.d.ts +43 -0
- package/dist/components/tt-table/src/table-mutation-events.js +71 -0
- package/dist/components/tt-table/src/types/table.d.ts +223 -88
- package/dist/components/tt-table/src/types/tableAction.d.ts +23 -0
- package/dist/components/tt-table/src/types/tableForm.d.ts +15 -26
- package/dist/components/tt-table/src/utils/action-tab-index.d.ts +2 -0
- package/dist/components/tt-table/src/utils/action-tab-index.js +51 -0
- package/dist/components/tt-table/src/utils/context.js +26 -12
- package/dist/components/tt-table/src/utils/table-api.d.ts +136 -58
- package/dist/components/tt-table/src/utils/table-api.js +200 -165
- package/dist/components/tt-table/src/utils/table-form-api.d.ts +11 -11
- package/dist/components/tt-table/src/utils/table-form-api.js +35 -23
- package/dist/components/tt-text/index.js +4 -3
- package/dist/components/tt-upload/index.js +6 -5
- package/dist/components/tt-upload/src/TtUpload.vue.js +4 -3
- package/dist/components/types.d.ts +0 -20
- package/dist/directives/disabled-tip/index.js +9 -8
- package/dist/hooks/useFormSchemasLink.js +4 -3
- package/dist/hooks/useFormat.d.ts +35 -71
- package/dist/hooks/useFormat.js +28 -39
- package/dist/hooks/usePanelSelectSchemas.js +4 -3
- package/dist/hooks/useScreenshotOss.js +16 -15
- package/dist/hooks/useSetup.js +0 -3
- package/dist/packages/hooks/src/useDebounce.js +6 -5
- package/dist/packages/hooks/src/useElementScreenshot.js +4 -3
- package/dist/packages/hooks/src/usePriorityValue.js +5 -4
- package/dist/packages/utils/src/format.js +48 -0
- package/dist/packages/utils/src/is.js +20 -18
- package/dist/packages/utils/src/tool.js +76 -149
- package/dist/plugins/default/renderCellContent.js +4 -3
- package/dist/plugins/vxeTable/switchStatus.js +14 -13
- package/dist/style.css +1 -1
- package/package.json +3 -3
- package/dist/components/tt-table/src/components/TableToobalTools.vue.d.ts +0 -576
- package/dist/components/tt-table/src/components/TableToobalTools.vue2.js +0 -4
- package/dist/components/tt-table/src/enum.d.ts +0 -2
- package/dist/components/tt-table/src/hooks/useCellArea.d.ts +0 -15
- package/dist/components/tt-table/src/hooks/useCellArea.js +0 -15
- package/dist/components/tt-table/src/hooks/useCustomColumns.d.ts +0 -20
- package/dist/components/tt-table/src/hooks/useCustomColumns.js +0 -65
- package/dist/components/tt-table/src/hooks/useDataSource.d.ts +0 -29
- package/dist/components/tt-table/src/hooks/useDataSource.js +0 -232
- package/dist/components/tt-table/src/hooks/useLeftRightSlot.js +0 -64
- package/dist/components/tt-table/src/hooks/useTable.d.ts +0 -7
- package/dist/components/tt-table/src/hooks/useTableEvent.d.ts +0 -101
- package/dist/components/tt-table/src/hooks/useTableEvent.js +0 -197
- package/dist/components/tt-table/src/hooks/useTableFormEvent.d.ts +0 -10
- package/dist/components/tt-table/src/hooks/useTableHeight.d.ts +0 -15
- package/dist/components/tt-table/src/hooks/useTableSlot.d.ts +0 -11
- package/dist/components/tt-table/src/hooks/useTableSlot.js +0 -17
- package/dist/components/tt-table/src/utils/filters.d.ts +0 -109
- package/dist/components/tt-table/src/utils/vxeTable.d.ts +0 -28
- package/dist/packages/utils/src/check.js +0 -10
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { unref as t, nextTick as c } from "vue";
|
|
2
|
+
import { withTreeExpand as x } from "./useTableData.js";
|
|
3
|
+
function h(r, l, w, {
|
|
4
|
+
clearSelectedRowKeys: d,
|
|
5
|
+
getTableInstance: C,
|
|
6
|
+
runDataOperation: s,
|
|
7
|
+
isActive: n,
|
|
8
|
+
prepareRows: m
|
|
9
|
+
}) {
|
|
10
|
+
const v = () => {
|
|
11
|
+
var e;
|
|
12
|
+
return (e = t(r).treeConfig) == null ? void 0 : e.reserve;
|
|
13
|
+
};
|
|
14
|
+
function R(e, o) {
|
|
15
|
+
return m(e), s(o);
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
/**
|
|
19
|
+
* 从第一行插入临时数据
|
|
20
|
+
* @param records 新数据
|
|
21
|
+
*/
|
|
22
|
+
insert: (e) => s(() => t(l).insert(e)),
|
|
23
|
+
/**
|
|
24
|
+
* 在指定行插入临时数据
|
|
25
|
+
* @param records 新数据
|
|
26
|
+
* @param row 指定行,-1 表示插入到底部
|
|
27
|
+
*/
|
|
28
|
+
insertAt: (e, o) => s(() => t(l).insertAt(e, o)),
|
|
29
|
+
/** 在指定行之后插入临时数据 */
|
|
30
|
+
insertNextAt: (e, o) => s(() => t(l).insertNextAt(e, o)),
|
|
31
|
+
/** 在树节点下插入临时子数据 */
|
|
32
|
+
insertChild: (e, o) => s(() => t(l).insertChild(e, o)),
|
|
33
|
+
/** 在树节点下的指定位置插入临时子数据 */
|
|
34
|
+
insertChildAt: (e, o, a) => s(() => t(l).insertChildAt(e, o, a)),
|
|
35
|
+
/** 在树节点下的指定行之后插入临时子数据 */
|
|
36
|
+
insertChildNextAt: (e, o, a) => s(() => t(l).insertChildNextAt(e, o, a)),
|
|
37
|
+
/**
|
|
38
|
+
* 删除指定行
|
|
39
|
+
* @param rows 指定行
|
|
40
|
+
*/
|
|
41
|
+
remove: (e) => s(() => t(l).remove(e)),
|
|
42
|
+
/** 删除复选框选中的行 */
|
|
43
|
+
removeCheckboxRow: () => s(async () => {
|
|
44
|
+
const e = await t(l).removeCheckboxRow();
|
|
45
|
+
return d(), e;
|
|
46
|
+
}),
|
|
47
|
+
/** 删除单选框选中的行 */
|
|
48
|
+
removeRadioRow: () => s(async () => {
|
|
49
|
+
const e = await t(l).removeRadioRow();
|
|
50
|
+
return d(), e;
|
|
51
|
+
}),
|
|
52
|
+
/** 删除当前行 */
|
|
53
|
+
removeCurrentRow: () => s(() => t(l).removeCurrentRow()),
|
|
54
|
+
/** 删除所有新增的临时数据 */
|
|
55
|
+
removeInsertRow: () => s(() => t(l).removeInsertRow()),
|
|
56
|
+
/** 清除表格的全部数据状态。该操作不改变业务行数据,无需触发 v-model 回写。 */
|
|
57
|
+
clearAll: async () => {
|
|
58
|
+
const e = await t(l).clearAll();
|
|
59
|
+
return d(), e;
|
|
60
|
+
},
|
|
61
|
+
/**
|
|
62
|
+
* 重新加载 VXE 当前同步数据,兼容旧的 syncData 入口。
|
|
63
|
+
* @deprecated VXE 已废弃 syncData,请使用 reloadData 或 getDataSource。
|
|
64
|
+
*/
|
|
65
|
+
syncData: () => s(() => t(l).updateData()),
|
|
66
|
+
/** 重新计算 VXE 的排序、筛选数据视图。该操作不改变业务行数据。 */
|
|
67
|
+
updateData: () => t(l).updateData(),
|
|
68
|
+
/** 修改指定行数据 */
|
|
69
|
+
setRow: (e, o) => s(() => t(l).setRow(e, o)),
|
|
70
|
+
/**
|
|
71
|
+
* 退出编辑并还原行数据
|
|
72
|
+
* @param row 指定行
|
|
73
|
+
*/
|
|
74
|
+
clearEditRevertData: (e) => s(async () => {
|
|
75
|
+
var o, a;
|
|
76
|
+
await ((o = t(l)) == null ? void 0 : o.clearEdit()), await ((a = t(l)) == null ? void 0 : a.revertData(e));
|
|
77
|
+
}),
|
|
78
|
+
/**
|
|
79
|
+
* 指定行激活编辑
|
|
80
|
+
* @param row 指定行
|
|
81
|
+
* @param fieldOrColumn 指定列
|
|
82
|
+
*/
|
|
83
|
+
setEditRow: async (e, o) => {
|
|
84
|
+
var a;
|
|
85
|
+
await ((a = t(l)) == null ? void 0 : a.setEditRow(e, o));
|
|
86
|
+
},
|
|
87
|
+
/**
|
|
88
|
+
* 指定单元格激活编辑
|
|
89
|
+
* @param row 指定行
|
|
90
|
+
* @param fieldOrColumn 指定列
|
|
91
|
+
*/
|
|
92
|
+
setEditCell: async (e, o) => {
|
|
93
|
+
var a;
|
|
94
|
+
await ((a = t(l)) == null ? void 0 : a.setEditCell(e, o));
|
|
95
|
+
},
|
|
96
|
+
/**
|
|
97
|
+
* 加载数据
|
|
98
|
+
* @param rows 数据
|
|
99
|
+
*/
|
|
100
|
+
loadData: (e) => R(
|
|
101
|
+
e,
|
|
102
|
+
() => x(t(l), v(), () => t(l).loadData(e), n)
|
|
103
|
+
),
|
|
104
|
+
/**
|
|
105
|
+
* 加载数据并恢复到初始状态
|
|
106
|
+
* @param rows 数据
|
|
107
|
+
*/
|
|
108
|
+
reloadData: (e) => R(
|
|
109
|
+
e,
|
|
110
|
+
() => x(t(l), v(), () => t(l).reloadData(e), n)
|
|
111
|
+
),
|
|
112
|
+
/**
|
|
113
|
+
* 重新加载列
|
|
114
|
+
* @param columns 列配置
|
|
115
|
+
*/
|
|
116
|
+
reloadColumn: async (e) => {
|
|
117
|
+
const o = t(l).getTreeExpandRecords();
|
|
118
|
+
w.setTableColumns(e), await c(), await c();
|
|
119
|
+
const a = t(l);
|
|
120
|
+
return a && n() && v() && o.length && await a.setTreeExpand(o, !0), w.getTableColumns();
|
|
121
|
+
},
|
|
122
|
+
/**
|
|
123
|
+
* 局部加载行数据并恢复到初始状态
|
|
124
|
+
* @param rows 行
|
|
125
|
+
* @param record 新数据
|
|
126
|
+
* @param field 指定字段名
|
|
127
|
+
*/
|
|
128
|
+
reloadRow: (e, o, a) => s(() => t(l).reloadRow(e, o, a)),
|
|
129
|
+
/** 还原 keep-source 保存的行数据 */
|
|
130
|
+
revertData: (e, o) => s(() => t(l).revertData(e, o)),
|
|
131
|
+
/** 加载树节点的子数据 */
|
|
132
|
+
loadTreeChildren: (e, o) => (m(o), C().loadTreeChildren(e, o)),
|
|
133
|
+
/**
|
|
134
|
+
* 清空单元格内容
|
|
135
|
+
* @param rows 指定行,为空表示整个表格
|
|
136
|
+
* @param field 指定字段名
|
|
137
|
+
*/
|
|
138
|
+
clearData: (e, o) => s(() => t(l).clearData(e, o)),
|
|
139
|
+
/** 移动行到指定行位置 */
|
|
140
|
+
moveRowTo: (e, o, a) => s(() => t(l).moveRowTo(e, o, a)),
|
|
141
|
+
/** 撤销最近一次数据操作 */
|
|
142
|
+
undo: () => s(() => t(l).undo(), "visible"),
|
|
143
|
+
/** 重做最近一次数据操作 */
|
|
144
|
+
redo: () => s(() => t(l).redo(), "visible"),
|
|
145
|
+
/**
|
|
146
|
+
* 重新懒加载展开行并展开内容
|
|
147
|
+
* @param rows 指定行
|
|
148
|
+
*/
|
|
149
|
+
reloadRowExpand: (e) => t(l).reloadRowExpand(e),
|
|
150
|
+
/**
|
|
151
|
+
* 重新懒加载树节点并展开该节点
|
|
152
|
+
* @param rows 指定行
|
|
153
|
+
*/
|
|
154
|
+
reloadTreeExpand: (e) => s(() => t(l).reloadTreeExpand(e)),
|
|
155
|
+
/**
|
|
156
|
+
* 设置空数据提示文字
|
|
157
|
+
* @param text 提示文字
|
|
158
|
+
*/
|
|
159
|
+
setEmptyText: (e) => w.setState({ emptyText: e }),
|
|
160
|
+
/**
|
|
161
|
+
* 校验表格编辑数据。
|
|
162
|
+
*
|
|
163
|
+
* 只是 vxe 校验能力的门面,不加组件自己的校验逻辑,也不改动校验提示的渲染。
|
|
164
|
+
* 两个分支都传 `true`(校验当前表格全部数据):不传时 vxe 只校验临时变动过的行,
|
|
165
|
+
* 而这个方法的用途是提交前的整表校验。
|
|
166
|
+
* @param isFull `true` 走 vxe 的 fullValidate,逐行校验并收集所有错误;
|
|
167
|
+
* 缺省或 `false` 走 validate,遇到第一个不通过的记录即停止
|
|
168
|
+
* @returns 全部通过时为 `undefined`;否则为 vxe 原生形状 —— 以列字段为键,
|
|
169
|
+
* 值是该字段上每条违规的 `{ rules, row, rowIndex, column, columnIndex, field }`
|
|
170
|
+
*/
|
|
171
|
+
validate: (e = !1) => e ? t(l).fullValidate(!0) : t(l).validate(!0),
|
|
172
|
+
/**
|
|
173
|
+
* 校验指定行的指定字段。
|
|
174
|
+
* @param row 行数据
|
|
175
|
+
* @param field 列字段名
|
|
176
|
+
* @returns 通过时为 `undefined`,否则为以列字段为键的错误映射
|
|
177
|
+
*/
|
|
178
|
+
validateField: (e, o) => t(l).validateField(e, o)
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
export {
|
|
182
|
+
h as useTableMethods
|
|
183
|
+
};
|
|
@@ -1,12 +1,46 @@
|
|
|
1
|
-
import { DefineSetupFnComponent } from 'vue';
|
|
2
|
-
import { TtTableExtendedTableApi, TtTableProps } from '../types/table';
|
|
1
|
+
import { DefineSetupFnComponent, SlotsType } from 'vue';
|
|
2
|
+
import { TtTableExtendedTableApi, TtTableProps, TtTableRenderProps, TtTableSlots } from '../types/table';
|
|
3
3
|
import { TtTableExtendedTableFormApi, TtTableFormProps } from '../types/tableForm';
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* 表格渲染组件的事件声明。
|
|
6
|
+
*
|
|
7
|
+
* 不能写成 `Record<string, any>`:Vue 的 `EmitsToProps` 走对象分支时会算
|
|
8
|
+
* `T[K] extends (...args: infer P) => any ? P : ...`,而 `T[K]` 为 `any` 时 `P` 被推断成
|
|
9
|
+
* `unknown[]`,生成的 `on${Capitalize<string>}` 索引签名参数变成 `unknown[]`。
|
|
10
|
+
* 该类型处于参数逆变位置,会让业务侧任何具名参数的回调(`@selection-change="({ rows }) => ..."`)
|
|
11
|
+
* 都无法赋值。值声明为宽松函数签名后,`P` 推断为 `any[]`,与任意回调双向兼容。
|
|
12
|
+
*/
|
|
13
|
+
type TtTableRenderEmits = Record<string, (...args: any[]) => any>;
|
|
14
|
+
/**
|
|
15
|
+
* useTableFormRender 的返回值
|
|
16
|
+
*
|
|
17
|
+
* `Row` 是业务行数据类型,传入后表格插槽作用域与 `tableFormApi.tableApi` 的方法签名跟着推断。
|
|
18
|
+
*/
|
|
19
|
+
export type TtUseTableFormRenderReturnType<Row = any> = [
|
|
20
|
+
DefineSetupFnComponent<TtTableFormProps<Row>, TtTableRenderEmits, SlotsType<TtTableSlots<Row>>>,
|
|
21
|
+
TtTableExtendedTableFormApi<Row>
|
|
22
|
+
];
|
|
23
|
+
/**
|
|
24
|
+
* useTableRender 的返回值
|
|
25
|
+
*
|
|
26
|
+
* `Row` 是业务行数据类型,传入后组件的 `modelValue`、插槽作用域与 `tableApi` 的方法签名跟着推断。
|
|
27
|
+
*/
|
|
28
|
+
export type TtUseTableRenderReturnType<Row = any> = [
|
|
29
|
+
DefineSetupFnComponent<TtTableRenderProps<Row>, TtTableRenderEmits, SlotsType<TtTableSlots<Row>>>,
|
|
30
|
+
TtTableExtendedTableApi<Row>
|
|
31
|
+
];
|
|
5
32
|
/**
|
|
6
33
|
* 用于渲染表单和表格的 hooks。
|
|
7
34
|
*
|
|
8
35
|
* 返回 [FormTable 组件, TableFormApi API]。
|
|
9
36
|
*
|
|
37
|
+
* `options` 用 `NoInfer` 包裹,`Row` 不再从传入的配置反向推断。业务常见写法是在
|
|
38
|
+
* `form.schemas` 的回调里引用解构出来的 api:
|
|
39
|
+
* `const [FormTable, api] = useTableFormRender({ form: { schemas: [{ onChange: () => f(api) }] } })`,
|
|
40
|
+
* 若 `Row` 从 `options` 推断,则 api 的类型依赖 options、options 又引用 api,TS 判定为循环,
|
|
41
|
+
* 整个变量退化成隐式 any 并报 TS7022/TS7023。代价是需要显式写
|
|
42
|
+
* `useTableFormRender<Row>({ ... })` 才能拿到行类型推断,不写则为 `any`。
|
|
43
|
+
*
|
|
10
44
|
* @param options 表格渲染配置项
|
|
11
45
|
* @returns [FormTable组件, TableFormApi API]
|
|
12
46
|
*
|
|
@@ -19,13 +53,25 @@ export type TtUseTableFormRenderReturnType = [DefineSetupFnComponent<TtTableForm
|
|
|
19
53
|
* ...配置
|
|
20
54
|
* })
|
|
21
55
|
*
|
|
56
|
+
* // 需要行类型推断时显式传入
|
|
57
|
+
* const [FormTable, tableApi] = useTableFormRender<OrderRow>({
|
|
58
|
+
* ...配置
|
|
59
|
+
* })
|
|
60
|
+
*
|
|
22
61
|
* // 在模板中使用
|
|
23
62
|
* <FormTable />
|
|
24
63
|
*/
|
|
25
|
-
export declare function useTableFormRender(options: TtTableFormProps): TtUseTableFormRenderReturnType
|
|
64
|
+
export declare function useTableFormRender<Row = any>(options: NoInfer<TtTableFormProps<Row>>): TtUseTableFormRenderReturnType<Row>;
|
|
26
65
|
/**
|
|
27
66
|
* 用于渲染表格的 hooks,返回 [TableRender 组件, 表格API]。
|
|
28
67
|
*
|
|
68
|
+
* options 只接受表格配置;单向数据使用 data,双向数据绑定到返回的 TableRender 组件。
|
|
69
|
+
*
|
|
70
|
+
* `options` 用 `NoInfer` 包裹,`Row` 不从配置反向推断。业务常见写法是初始化时给 `data: []`,
|
|
71
|
+
* 若 `Row` 从空数组推断会退化成 `never`,组件的 `data` prop 类型变成 `MaybeRef<never[]>`,
|
|
72
|
+
* 之后传入任何具体行类型都会报 TS2322。代价是需要显式写 `useTableRender<Row>({ ... })`
|
|
73
|
+
* 才能拿到行类型推断,不写则为 `any`。
|
|
74
|
+
*
|
|
29
75
|
* @param options 表格渲染配置项
|
|
30
76
|
* @returns [TableRender组件, 表格API]
|
|
31
77
|
*
|
|
@@ -37,57 +83,13 @@ export declare function useTableFormRender(options: TtTableFormProps): TtUseTabl
|
|
|
37
83
|
* ...其它配置
|
|
38
84
|
* })
|
|
39
85
|
*
|
|
86
|
+
* // 需要行类型推断时显式传入
|
|
87
|
+
* const [TableRender, tableApi] = useTableRender<OrderRow>({
|
|
88
|
+
* columns: [...],
|
|
89
|
+
* })
|
|
90
|
+
*
|
|
40
91
|
* // 在模板中使用
|
|
41
92
|
* <TableRender />
|
|
42
93
|
*/
|
|
43
|
-
export declare function useTableRender(options: TtTableProps):
|
|
44
|
-
|
|
45
|
-
showTitle?: boolean;
|
|
46
|
-
autoHeight?: boolean;
|
|
47
|
-
offsetHeight?: number;
|
|
48
|
-
loading?: boolean;
|
|
49
|
-
loadingText?: string;
|
|
50
|
-
emptyText?: string;
|
|
51
|
-
noSearchText?: string;
|
|
52
|
-
emptyImageStyle?: import('vue').CSSProperties;
|
|
53
|
-
emptyImageStatus?: "no-data" | "no-search";
|
|
54
|
-
isHanderSubmit?: boolean;
|
|
55
|
-
modelValue?: Array<Recordable>;
|
|
56
|
-
formApi?: Partial<import('../../../tt-form').TtExtendedFormApi>;
|
|
57
|
-
columnsKey?: string | (() => string);
|
|
58
|
-
showSetting?: boolean;
|
|
59
|
-
showSetColumn?: boolean;
|
|
60
|
-
leftSlotWidth?: number;
|
|
61
|
-
rightSlotWidth?: number;
|
|
62
|
-
showLineHeight?: boolean;
|
|
63
|
-
showRefresh?: boolean;
|
|
64
|
-
useHttpCache?: boolean;
|
|
65
|
-
defaultDisplayFields?: string[];
|
|
66
|
-
getColumnsApi?: (params: {
|
|
67
|
-
permissionOnlyCode: string;
|
|
68
|
-
userId: string | number;
|
|
69
|
-
}) => Promise<{
|
|
70
|
-
data: any;
|
|
71
|
-
}>;
|
|
72
|
-
setColumnsApi?: (params: {
|
|
73
|
-
permissionOnlyCode: string;
|
|
74
|
-
json: string;
|
|
75
|
-
userId: string | number;
|
|
76
|
-
}) => Promise<any>;
|
|
77
|
-
updateColumnsApi?: (params: {
|
|
78
|
-
permissionOnlyCode: string;
|
|
79
|
-
json: string;
|
|
80
|
-
userId: string | number;
|
|
81
|
-
id: string | number;
|
|
82
|
-
}) => Promise<any>;
|
|
83
|
-
getSyncSlotComponent?: (column: any, row: any, type: "default" | "edit") => import('vue').VNode | import('vue').VNode[] | string;
|
|
84
|
-
customizeColumn?: (column: import("vxe-table").VxeTableDefines.ColumnOptions) => import("vxe-table").VxeTableDefines.ColumnOptions;
|
|
85
|
-
clearTreeExpand?: boolean;
|
|
86
|
-
isI18n?: boolean;
|
|
87
|
-
isDataCloneDeep?: boolean;
|
|
88
|
-
useSearchForm?: boolean;
|
|
89
|
-
data?: import('vue').MaybeRef<any[]>;
|
|
90
|
-
columns?: import('vue').MaybeRef<import("vxe-table").VxeTableDefines.ColumnOptions[]>;
|
|
91
|
-
testId?: string;
|
|
92
|
-
toolTipErrorPlacement?: "top" | "bottom" | "left" | "right";
|
|
93
|
-
} & Omit<import('vxe-table').VxeGridProps<any>, "data" | "columns"> & import('../..').TtTablePagerProps & import('../..').TtTableColumnsProps & import('../..').TtTableFetchProps & import('../..').TtTableToolbarProps & {}, import('vue').PublicProps>, TtTableExtendedTableApi];
|
|
94
|
+
export declare function useTableRender<Row = any>(options: NoInfer<TtTableProps<Row>>): TtUseTableRenderReturnType<Row>;
|
|
95
|
+
export {};
|