@tmagic/table 1.7.6 → 1.7.8-beta.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/LICENSE +235 -164
- package/dist/es/ActionsColumn.js +5 -0
- package/dist/es/ActionsColumn.vue_vue_type_script_setup_true_lang.js +122 -0
- package/dist/es/ComponentColumn.js +5 -0
- package/dist/es/ComponentColumn.vue_vue_type_script_setup_true_lang.js +27 -0
- package/dist/es/ExpandColumn.js +5 -0
- package/dist/es/ExpandColumn.vue_vue_type_script_setup_true_lang.js +42 -0
- package/dist/es/PopoverColumn.js +5 -0
- package/dist/es/PopoverColumn.vue_vue_type_script_setup_true_lang.js +51 -0
- package/dist/es/Table.js +5 -0
- package/dist/es/Table.vue_vue_type_script_setup_true_lang.js +192 -0
- package/dist/es/TextColumn.js +5 -0
- package/dist/es/TextColumn.vue_vue_type_script_setup_true_lang.js +84 -0
- package/dist/es/index.js +9 -0
- package/dist/es/style.css +13 -0
- package/dist/es/utils.js +17 -0
- package/dist/style.css +1 -1
- package/dist/tmagic-table.umd.cjs +2439 -2683
- package/package.json +7 -6
- package/types/index.d.ts +119 -122
- package/dist/tmagic-table.js +0 -652
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createBlock, defineComponent, mergeProps, openBlock, resolveDynamicComponent, toHandlers } from "vue";
|
|
2
|
+
//#region packages/table/src/ComponentColumn.vue?vue&type=script&setup=true&lang.ts
|
|
3
|
+
var ComponentColumn_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
4
|
+
name: "MTableColumn",
|
|
5
|
+
__name: "ComponentColumn",
|
|
6
|
+
props: {
|
|
7
|
+
config: { default: () => ({}) },
|
|
8
|
+
row: {},
|
|
9
|
+
index: {}
|
|
10
|
+
},
|
|
11
|
+
setup(__props) {
|
|
12
|
+
const props = __props;
|
|
13
|
+
const componentProps = (row, index) => {
|
|
14
|
+
if (typeof props.config.props === "function") return props.config.props(row, index) || {};
|
|
15
|
+
return props.config.props || {};
|
|
16
|
+
};
|
|
17
|
+
const componentListeners = (row, index) => {
|
|
18
|
+
if (typeof props.config.listeners === "function") return props.config.listeners(row, index) || {};
|
|
19
|
+
return props.config.listeners || {};
|
|
20
|
+
};
|
|
21
|
+
return (_ctx, _cache) => {
|
|
22
|
+
return openBlock(), createBlock(resolveDynamicComponent(__props.config.component), mergeProps(componentProps(__props.row, __props.index), toHandlers(componentListeners(__props.row, __props.index))), null, 16);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
//#endregion
|
|
27
|
+
export { ComponentColumn_vue_vue_type_script_setup_true_lang_default as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import ExpandColumn_vue_vue_type_script_setup_true_lang_default from "./ExpandColumn.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
+
//#region packages/table/src/ExpandColumn.vue
|
|
3
|
+
var ExpandColumn_default = ExpandColumn_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { ExpandColumn_default as default };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import Table_default from "./Table.js";
|
|
2
|
+
import { Fragment, createBlock, createCommentVNode, createElementBlock, defineComponent, mergeProps, normalizeProps, openBlock, resolveDynamicComponent, unref } from "vue";
|
|
3
|
+
import { MForm } from "@tmagic/form";
|
|
4
|
+
//#region packages/table/src/ExpandColumn.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var _hoisted_1 = ["innerHTML"];
|
|
6
|
+
var ExpandColumn_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
7
|
+
name: "MTableExpandColumn",
|
|
8
|
+
__name: "ExpandColumn",
|
|
9
|
+
props: {
|
|
10
|
+
config: { default: () => ({}) },
|
|
11
|
+
row: {}
|
|
12
|
+
},
|
|
13
|
+
setup(__props) {
|
|
14
|
+
const props = __props;
|
|
15
|
+
const componentProps = (row) => {
|
|
16
|
+
if (typeof props.config.props === "function") return props.config.props(row) || {};
|
|
17
|
+
return props.config.props || {};
|
|
18
|
+
};
|
|
19
|
+
return (_ctx, _cache) => {
|
|
20
|
+
return openBlock(), createElementBlock(Fragment, null, [
|
|
21
|
+
__props.config.table ? (openBlock(), createBlock(Table_default, {
|
|
22
|
+
key: 0,
|
|
23
|
+
"show-header": false,
|
|
24
|
+
columns: __props.config.table,
|
|
25
|
+
data: __props.config.prop && __props.row[__props.config.prop] || []
|
|
26
|
+
}, null, 8, ["columns", "data"])) : createCommentVNode("v-if", true),
|
|
27
|
+
__props.config.form ? (openBlock(), createBlock(unref(MForm), {
|
|
28
|
+
key: 1,
|
|
29
|
+
config: __props.config.form,
|
|
30
|
+
"init-values": __props.config.values || __props.config.prop && __props.row[__props.config.prop] || {}
|
|
31
|
+
}, null, 8, ["config", "init-values"])) : createCommentVNode("v-if", true),
|
|
32
|
+
__props.config.expandContent ? (openBlock(), createElementBlock("div", {
|
|
33
|
+
key: 2,
|
|
34
|
+
innerHTML: __props.config.expandContent(__props.row, __props.config.prop)
|
|
35
|
+
}, null, 8, _hoisted_1)) : createCommentVNode("v-if", true),
|
|
36
|
+
__props.config.component ? (openBlock(), createBlock(resolveDynamicComponent(__props.config.component), normalizeProps(mergeProps({ key: 3 }, componentProps(__props.row))), null, 16)) : createCommentVNode("v-if", true)
|
|
37
|
+
], 64);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
//#endregion
|
|
42
|
+
export { ExpandColumn_vue_vue_type_script_setup_true_lang_default as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import PopoverColumn_vue_vue_type_script_setup_true_lang_default from "./PopoverColumn.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
+
//#region packages/table/src/PopoverColumn.vue
|
|
3
|
+
var PopoverColumn_default = PopoverColumn_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { PopoverColumn_default as default };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { formatter } from "./utils.js";
|
|
2
|
+
import Table_default from "./Table.js";
|
|
3
|
+
import { createBlock, createCommentVNode, createTextVNode, createVNode, defineComponent, openBlock, toDisplayString, unref, withCtx } from "vue";
|
|
4
|
+
import { TMagicButton, TMagicPopover } from "@tmagic/design";
|
|
5
|
+
//#region packages/table/src/PopoverColumn.vue?vue&type=script&setup=true&lang.ts
|
|
6
|
+
var PopoverColumn_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
7
|
+
name: "MTablePopoverColumn",
|
|
8
|
+
__name: "PopoverColumn",
|
|
9
|
+
props: {
|
|
10
|
+
config: { default: () => ({}) },
|
|
11
|
+
row: {},
|
|
12
|
+
index: {}
|
|
13
|
+
},
|
|
14
|
+
setup(__props) {
|
|
15
|
+
return (_ctx, _cache) => {
|
|
16
|
+
return __props.config.popover ? (openBlock(), createBlock(unref(TMagicPopover), {
|
|
17
|
+
key: 0,
|
|
18
|
+
placement: __props.config.popover.placement,
|
|
19
|
+
width: __props.config.popover.width,
|
|
20
|
+
trigger: __props.config.popover.trigger,
|
|
21
|
+
"destroy-on-close": __props.config.popover.destroyOnClose ?? true
|
|
22
|
+
}, {
|
|
23
|
+
reference: withCtx(() => [createVNode(unref(TMagicButton), {
|
|
24
|
+
link: "",
|
|
25
|
+
type: "primary"
|
|
26
|
+
}, {
|
|
27
|
+
default: withCtx(() => [createTextVNode(toDisplayString(__props.config.text || unref(formatter)(__props.config, __props.row, { index: __props.index })), 1)]),
|
|
28
|
+
_: 1
|
|
29
|
+
})]),
|
|
30
|
+
default: withCtx(() => [__props.config.popover.tableEmbed ? (openBlock(), createBlock(Table_default, {
|
|
31
|
+
key: 0,
|
|
32
|
+
"show-header": __props.config.showHeader,
|
|
33
|
+
columns: __props.config.table,
|
|
34
|
+
data: __props.config.prop && __props.row[__props.config.prop] || []
|
|
35
|
+
}, null, 8, [
|
|
36
|
+
"show-header",
|
|
37
|
+
"columns",
|
|
38
|
+
"data"
|
|
39
|
+
])) : createCommentVNode("v-if", true)]),
|
|
40
|
+
_: 1
|
|
41
|
+
}, 8, [
|
|
42
|
+
"placement",
|
|
43
|
+
"width",
|
|
44
|
+
"trigger",
|
|
45
|
+
"destroy-on-close"
|
|
46
|
+
])) : createCommentVNode("v-if", true);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
//#endregion
|
|
51
|
+
export { PopoverColumn_vue_vue_type_script_setup_true_lang_default as default };
|
package/dist/es/Table.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import Table_vue_vue_type_script_setup_true_lang_default from "./Table.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
+
//#region packages/table/src/Table.vue
|
|
3
|
+
var Table_default = Table_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { Table_default as default };
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import ActionsColumn_default from "./ActionsColumn.js";
|
|
2
|
+
import ComponentColumn_default from "./ComponentColumn.js";
|
|
3
|
+
import ExpandColumn_default from "./ExpandColumn.js";
|
|
4
|
+
import PopoverColumn_default from "./PopoverColumn.js";
|
|
5
|
+
import TextColumn_default from "./TextColumn.js";
|
|
6
|
+
import { computed, createBlock, defineComponent, h, openBlock, ref, resolveDirective, unref, useTemplateRef, withDirectives } from "vue";
|
|
7
|
+
import { cloneDeep } from "lodash-es";
|
|
8
|
+
import { TMagicTable } from "@tmagic/design";
|
|
9
|
+
//#region packages/table/src/Table.vue?vue&type=script&setup=true&lang.ts
|
|
10
|
+
var Table_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
11
|
+
name: "MTable",
|
|
12
|
+
__name: "Table",
|
|
13
|
+
props: {
|
|
14
|
+
data: {},
|
|
15
|
+
columns: { default: () => [] },
|
|
16
|
+
spanMethod: {},
|
|
17
|
+
loading: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: false
|
|
20
|
+
},
|
|
21
|
+
bodyHeight: {},
|
|
22
|
+
showHeader: {
|
|
23
|
+
type: Boolean,
|
|
24
|
+
default: true
|
|
25
|
+
},
|
|
26
|
+
emptyText: {},
|
|
27
|
+
defaultExpandAll: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
default: false
|
|
30
|
+
},
|
|
31
|
+
rowkeyName: {},
|
|
32
|
+
border: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
default: false
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
emits: [
|
|
38
|
+
"sort-change",
|
|
39
|
+
"after-action",
|
|
40
|
+
"after-action-cancel",
|
|
41
|
+
"select",
|
|
42
|
+
"select-all",
|
|
43
|
+
"selection-change",
|
|
44
|
+
"expand-change",
|
|
45
|
+
"cell-click"
|
|
46
|
+
],
|
|
47
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
48
|
+
const props = __props;
|
|
49
|
+
const emit = __emit;
|
|
50
|
+
const cellRender = (config, { row = {}, $index }) => {
|
|
51
|
+
if (config.type === "expand") return h(ExpandColumn_default, {
|
|
52
|
+
config,
|
|
53
|
+
row
|
|
54
|
+
});
|
|
55
|
+
if (config.type === "component") return h(ComponentColumn_default, {
|
|
56
|
+
config,
|
|
57
|
+
row,
|
|
58
|
+
index: $index
|
|
59
|
+
});
|
|
60
|
+
if (config.actions) return h(ActionsColumn_default, {
|
|
61
|
+
config,
|
|
62
|
+
row,
|
|
63
|
+
index: $index,
|
|
64
|
+
rowkeyName: props.rowkeyName,
|
|
65
|
+
editState: editState.value,
|
|
66
|
+
columns: props.columns,
|
|
67
|
+
onAfterAction: (payload) => emit("after-action", payload),
|
|
68
|
+
onAfterActionCancel: (payload) => emit("after-action-cancel", payload)
|
|
69
|
+
});
|
|
70
|
+
if (config.type === "popover") return h(PopoverColumn_default, {
|
|
71
|
+
config,
|
|
72
|
+
row,
|
|
73
|
+
index: $index
|
|
74
|
+
});
|
|
75
|
+
return h(TextColumn_default, {
|
|
76
|
+
config,
|
|
77
|
+
row,
|
|
78
|
+
index: $index,
|
|
79
|
+
editState: editState.value
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
const tableColumns = computed(() => props.columns.map((item) => {
|
|
83
|
+
let type = "default";
|
|
84
|
+
if (item.type === "expand") type = "expand";
|
|
85
|
+
else if (item.selection) type = "selection";
|
|
86
|
+
return {
|
|
87
|
+
props: {
|
|
88
|
+
label: item.label,
|
|
89
|
+
fixed: item.fixed,
|
|
90
|
+
width: item.width ?? (item.selection ? 40 : void 0),
|
|
91
|
+
prop: item.prop,
|
|
92
|
+
type,
|
|
93
|
+
selectable: item.selectable
|
|
94
|
+
},
|
|
95
|
+
cell: type === "selection" ? void 0 : ({ row, $index }) => cellRender(item, {
|
|
96
|
+
row,
|
|
97
|
+
$index
|
|
98
|
+
})
|
|
99
|
+
};
|
|
100
|
+
}));
|
|
101
|
+
const tMagicTableRef = useTemplateRef("tMagicTable");
|
|
102
|
+
const editState = ref([]);
|
|
103
|
+
const selectionColumn = computed(() => {
|
|
104
|
+
const column = props.columns.filter((item) => item.selection);
|
|
105
|
+
return column.length ? column[0] : null;
|
|
106
|
+
});
|
|
107
|
+
const tableData = computed(() => {
|
|
108
|
+
if (selectionColumn.value) return props.data || [];
|
|
109
|
+
return cloneDeep(props.data) || [];
|
|
110
|
+
});
|
|
111
|
+
const hasBorder = computed(() => typeof props.border !== "undefined" ? props.border : true);
|
|
112
|
+
const sortChange = (data) => {
|
|
113
|
+
emit("sort-change", data);
|
|
114
|
+
};
|
|
115
|
+
const selectHandler = (selection, row) => {
|
|
116
|
+
const column = selectionColumn.value;
|
|
117
|
+
if (!column) return;
|
|
118
|
+
if (column.selection === "single") {}
|
|
119
|
+
emit("select", selection, row);
|
|
120
|
+
};
|
|
121
|
+
const selectAllHandler = (selection) => {
|
|
122
|
+
emit("select-all", selection);
|
|
123
|
+
};
|
|
124
|
+
const selectionChangeHandler = (selection) => {
|
|
125
|
+
emit("selection-change", selection);
|
|
126
|
+
};
|
|
127
|
+
const cellClickHandler = (...args) => {
|
|
128
|
+
emit("cell-click", ...args);
|
|
129
|
+
};
|
|
130
|
+
const expandChange = (...args) => {
|
|
131
|
+
emit("expand-change", ...args);
|
|
132
|
+
};
|
|
133
|
+
const toggleRowSelection = (row, selected) => {
|
|
134
|
+
tMagicTableRef.value?.toggleRowSelection(row, selected);
|
|
135
|
+
};
|
|
136
|
+
const toggleRowExpansion = (row, expanded) => {
|
|
137
|
+
tMagicTableRef.value?.toggleRowExpansion(row, expanded);
|
|
138
|
+
};
|
|
139
|
+
const clearSelection = () => {
|
|
140
|
+
tMagicTableRef.value?.clearSelection();
|
|
141
|
+
};
|
|
142
|
+
const objectSpanMethod = (data) => {
|
|
143
|
+
if (typeof props.spanMethod === "function") return props.spanMethod(data);
|
|
144
|
+
return () => ({
|
|
145
|
+
rowspan: 0,
|
|
146
|
+
colspan: 0
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
__expose({
|
|
150
|
+
toggleRowSelection,
|
|
151
|
+
toggleRowExpansion,
|
|
152
|
+
clearSelection
|
|
153
|
+
});
|
|
154
|
+
return (_ctx, _cache) => {
|
|
155
|
+
const _directive_loading = resolveDirective("loading");
|
|
156
|
+
return withDirectives((openBlock(), createBlock(unref(TMagicTable), {
|
|
157
|
+
class: "m-table",
|
|
158
|
+
ref: "tMagicTable",
|
|
159
|
+
"show-overflow-tooltip": true,
|
|
160
|
+
"tooltip-effect": "dark",
|
|
161
|
+
"tooltip-options": { popperOptions: { strategy: "absolute" } },
|
|
162
|
+
data: tableData.value,
|
|
163
|
+
"show-header": __props.showHeader,
|
|
164
|
+
"max-height": __props.bodyHeight,
|
|
165
|
+
"default-expand-all": __props.defaultExpandAll,
|
|
166
|
+
border: hasBorder.value,
|
|
167
|
+
"row-key": __props.rowkeyName || "id",
|
|
168
|
+
"tree-props": { children: "children" },
|
|
169
|
+
"empty-text": __props.emptyText || "暂无数据",
|
|
170
|
+
"span-method": objectSpanMethod,
|
|
171
|
+
columns: tableColumns.value,
|
|
172
|
+
onSortChange: sortChange,
|
|
173
|
+
onSelect: selectHandler,
|
|
174
|
+
onSelectAll: selectAllHandler,
|
|
175
|
+
onSelectionChange: selectionChangeHandler,
|
|
176
|
+
onCellClick: cellClickHandler,
|
|
177
|
+
onExpandChange: expandChange
|
|
178
|
+
}, null, 8, [
|
|
179
|
+
"data",
|
|
180
|
+
"show-header",
|
|
181
|
+
"max-height",
|
|
182
|
+
"default-expand-all",
|
|
183
|
+
"border",
|
|
184
|
+
"row-key",
|
|
185
|
+
"empty-text",
|
|
186
|
+
"columns"
|
|
187
|
+
])), [[_directive_loading, __props.loading]]);
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
//#endregion
|
|
192
|
+
export { Table_vue_vue_type_script_setup_true_lang_default as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import TextColumn_vue_vue_type_script_setup_true_lang_default from "./TextColumn.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
+
//#region packages/table/src/TextColumn.vue
|
|
3
|
+
var TextColumn_default = TextColumn_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { TextColumn_default as default };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { formatter } from "./utils.js";
|
|
2
|
+
import { createBlock, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, openBlock, toDisplayString, unref, withCtx } from "vue";
|
|
3
|
+
import { TMagicButton, TMagicTag, TMagicTooltip } from "@tmagic/design";
|
|
4
|
+
import { MForm } from "@tmagic/form";
|
|
5
|
+
import { setValueByKeyPath } from "@tmagic/utils";
|
|
6
|
+
//#region packages/table/src/TextColumn.vue?vue&type=script&setup=true&lang.ts
|
|
7
|
+
var _hoisted_1 = { key: 0 };
|
|
8
|
+
var _hoisted_2 = ["innerHTML"];
|
|
9
|
+
var _hoisted_3 = ["href"];
|
|
10
|
+
var _hoisted_4 = ["src"];
|
|
11
|
+
var _hoisted_5 = ["href"];
|
|
12
|
+
var _hoisted_6 = ["innerHTML"];
|
|
13
|
+
var TextColumn_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
14
|
+
name: "MTableColumn",
|
|
15
|
+
__name: "TextColumn",
|
|
16
|
+
props: {
|
|
17
|
+
config: { default: () => ({}) },
|
|
18
|
+
editState: { default: () => ({}) },
|
|
19
|
+
row: {},
|
|
20
|
+
index: {}
|
|
21
|
+
},
|
|
22
|
+
setup(__props) {
|
|
23
|
+
const props = __props;
|
|
24
|
+
const formChangeHandler = (v, eventData) => {
|
|
25
|
+
if (eventData.changeRecords?.length) {
|
|
26
|
+
for (const record of eventData.changeRecords) if (record.propPath) setValueByKeyPath(record.propPath, record.value, props.editState[props.index]);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
return (_ctx, _cache) => {
|
|
30
|
+
return __props.config.type === "index" ? (openBlock(), createElementBlock("div", _hoisted_1, toDisplayString(__props.config.pageIndex && __props.config.pageSize ? __props.config.pageIndex * __props.config.pageSize + __props.index + 1 : __props.index + 1), 1)) : (__props.config.type || __props.config.editInlineFormConfig) && __props.editState[__props.index] ? (openBlock(), createBlock(unref(MForm), {
|
|
31
|
+
key: 1,
|
|
32
|
+
"label-width": "0",
|
|
33
|
+
config: __props.config.editInlineFormConfig ?? [__props.config],
|
|
34
|
+
"init-values": __props.editState[__props.index],
|
|
35
|
+
onChange: formChangeHandler
|
|
36
|
+
}, null, 8, ["config", "init-values"])) : __props.config.action === "actionLink" && __props.config.prop ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
37
|
+
key: 2,
|
|
38
|
+
link: "",
|
|
39
|
+
type: "primary",
|
|
40
|
+
onClick: _cache[0] || (_cache[0] = ($event) => __props.config.handler?.(__props.row))
|
|
41
|
+
}, {
|
|
42
|
+
default: withCtx(() => [createElementVNode("span", { innerHTML: unref(formatter)(__props.config, __props.row, { index: __props.index }) }, null, 8, _hoisted_2)]),
|
|
43
|
+
_: 1
|
|
44
|
+
})) : __props.config.action === "img" && __props.config.prop ? (openBlock(), createElementBlock("a", {
|
|
45
|
+
key: 3,
|
|
46
|
+
target: "_blank",
|
|
47
|
+
href: __props.row[__props.config.prop]
|
|
48
|
+
}, [createElementVNode("img", {
|
|
49
|
+
src: __props.row[__props.config.prop],
|
|
50
|
+
height: "50"
|
|
51
|
+
}, null, 8, _hoisted_4)], 8, _hoisted_3)) : __props.config.action === "link" && __props.config.prop ? (openBlock(), createElementBlock("a", {
|
|
52
|
+
key: 4,
|
|
53
|
+
target: "_blank",
|
|
54
|
+
href: __props.row[__props.config.prop],
|
|
55
|
+
class: "keep-all"
|
|
56
|
+
}, toDisplayString(__props.row[__props.config.prop]), 9, _hoisted_5)) : __props.config.action === "tip" ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
57
|
+
key: 5,
|
|
58
|
+
placement: "left"
|
|
59
|
+
}, {
|
|
60
|
+
content: withCtx(() => [createElementVNode("div", null, toDisplayString(unref(formatter)(__props.config, __props.row, { index: __props.index })), 1)]),
|
|
61
|
+
default: withCtx(() => [createVNode(unref(TMagicButton), {
|
|
62
|
+
link: "",
|
|
63
|
+
type: "primary"
|
|
64
|
+
}, {
|
|
65
|
+
default: withCtx(() => [createTextVNode(toDisplayString(__props.config.buttonText || "扩展配置"), 1)]),
|
|
66
|
+
_: 1
|
|
67
|
+
})]),
|
|
68
|
+
_: 1
|
|
69
|
+
})) : __props.config.action === "tag" && __props.config.prop ? (openBlock(), createBlock(unref(TMagicTag), {
|
|
70
|
+
key: 6,
|
|
71
|
+
type: typeof __props.config.type === "function" ? __props.config.type(__props.row[__props.config.prop], __props.row) : __props.config.type,
|
|
72
|
+
"close-transition": ""
|
|
73
|
+
}, {
|
|
74
|
+
default: withCtx(() => [createTextVNode(toDisplayString(unref(formatter)(__props.config, __props.row, { index: __props.index })), 1)]),
|
|
75
|
+
_: 1
|
|
76
|
+
}, 8, ["type"])) : (openBlock(), createElementBlock("div", {
|
|
77
|
+
key: 7,
|
|
78
|
+
innerHTML: unref(formatter)(__props.config, __props.row, { index: __props.index })
|
|
79
|
+
}, null, 8, _hoisted_6));
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
//#endregion
|
|
84
|
+
export { TextColumn_vue_vue_type_script_setup_true_lang_default as default };
|
package/dist/es/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createColumns, formatter } from "./utils.js";
|
|
2
|
+
import Table_default from "./Table.js";
|
|
3
|
+
/* empty css */
|
|
4
|
+
//#region packages/table/src/index.ts
|
|
5
|
+
var src_default = { install(app) {
|
|
6
|
+
app.component("m-table", Table_default);
|
|
7
|
+
} };
|
|
8
|
+
//#endregion
|
|
9
|
+
export { Table_default as MagicTable, createColumns, src_default as default, formatter };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
.m-table .el-button.action-btn + .el-button.action-btn {
|
|
2
|
+
margin-left: 0;
|
|
3
|
+
}
|
|
4
|
+
.m-table .keep-all {
|
|
5
|
+
word-break: keep-all;
|
|
6
|
+
}
|
|
7
|
+
.m-table .el-table .cell > div {
|
|
8
|
+
display: inline-block;
|
|
9
|
+
vertical-align: middle;
|
|
10
|
+
}
|
|
11
|
+
.m-table .el-table__row.el-table__row--level-1 {
|
|
12
|
+
color: #999;
|
|
13
|
+
}/*$vite$:1*/
|
package/dist/es/utils.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { datetimeFormatter } from "@tmagic/form";
|
|
2
|
+
//#region packages/table/src/utils.ts
|
|
3
|
+
var formatter = (item, row, data) => {
|
|
4
|
+
if (!item.prop) return "";
|
|
5
|
+
if (item.formatter) {
|
|
6
|
+
if (item.formatter === "datetime") item.formatter = (value) => datetimeFormatter(value);
|
|
7
|
+
try {
|
|
8
|
+
return item.formatter(row[item.prop], row, data);
|
|
9
|
+
} catch (e) {
|
|
10
|
+
console.error("Formatter error:", e);
|
|
11
|
+
return row[item.prop];
|
|
12
|
+
}
|
|
13
|
+
} else return row[item.prop];
|
|
14
|
+
};
|
|
15
|
+
var createColumns = (columns) => columns;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { createColumns, formatter };
|
package/dist/style.css
CHANGED