@tmagic/table 1.0.0-beta.6 → 1.0.0-rc.2

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/package.json CHANGED
@@ -1,7 +1,9 @@
1
1
  {
2
- "version": "1.0.0-beta.6",
2
+ "version": "1.0.0-rc.2",
3
3
  "name": "@tmagic/table",
4
- "sideEffects": false,
4
+ "sideEffects": [
5
+ "dist/*"
6
+ ],
5
7
  "main": "dist/tmagic-table.umd.js",
6
8
  "module": "dist/tmagic-table.es.js",
7
9
  "types": "dist/types/src/index.d.ts",
@@ -13,8 +15,10 @@
13
15
  "./dist/style.css": {
14
16
  "import": "./dist/style.css",
15
17
  "require": "./dist/style.css"
16
- }
18
+ },
19
+ "./*": "./*"
17
20
  },
21
+ "license": "Apache-2.0",
18
22
  "scripts": {
19
23
  "build": "vite build"
20
24
  },
@@ -26,22 +30,28 @@
26
30
  "url": "https://github.com/Tencent/tmagic-editor.git"
27
31
  },
28
32
  "dependencies": {
29
- "@tmagic/form": "^1.0.0-beta.6",
30
- "element-plus": "^2.0.2",
33
+ "@tmagic/form": "^1.0.0-rc.2",
34
+ "element-plus": "^2.2.0",
31
35
  "lodash-es": "^4.17.21",
32
36
  "vue": "^3.2.0"
33
37
  },
38
+ "peerDependencies": {
39
+ "@tmagic/form": "^1.0.0-rc.1",
40
+ "element-plus": "^2.2.0",
41
+ "vue": "^3.2.0"
42
+ },
34
43
  "devDependencies": {
35
44
  "@types/color": "^3.0.1",
36
45
  "@types/lodash-es": "^4.17.4",
37
46
  "@types/node": "^15.12.4",
38
47
  "@vitejs/plugin-vue": "^1.2.3",
39
48
  "@vue/compiler-sfc": "^3.2.0",
40
- "@vue/test-utils": "^2.0.0-rc.12",
49
+ "@vue/test-utils": "^2.0.0-rc.20",
41
50
  "sass": "^1.35.1",
42
51
  "typescript": "^4.3.4",
43
52
  "vite": "^2.3.7",
44
53
  "vite-plugin-dts": "^0.9.6",
45
54
  "vue-tsc": "^0.0.24"
46
- }
55
+ },
56
+ "gitHead": "3e309780ed33640ab3fc986a93dd0e7b15c167e5"
47
57
  }
@@ -6,7 +6,8 @@
6
6
  v-show="display(action.display, scope.row) && !editState[scope.$index]"
7
7
  v-html="action.text"
8
8
  class="action-btn"
9
- type="text"
9
+ text
10
+ type="primary"
10
11
  size="small"
11
12
  :key="actionIndex"
12
13
  @click="actionHandler(action, scope.row, scope.$index)"
@@ -14,7 +15,8 @@
14
15
  <el-button
15
16
  class="action-btn"
16
17
  v-show="editState[scope.$index]"
17
- type="text"
18
+ text
19
+ type="primary"
18
20
  size="small"
19
21
  @click="save(scope.$index, config)"
20
22
  >保存</el-button
@@ -22,7 +24,8 @@
22
24
  <el-button
23
25
  class="action-btn"
24
26
  v-show="editState[scope.$index]"
25
- type="text"
27
+ text
28
+ type="primary"
26
29
  size="small"
27
30
  @click="editState[scope.$index] = undefined"
28
31
  >取消</el-button
@@ -72,9 +75,9 @@ const display = (fuc: boolean | Function | undefined, row: any) => {
72
75
  return true;
73
76
  };
74
77
 
75
- const success = (msg: string, action: ColumnActionConfig) => {
78
+ const success = (msg: string, action: ColumnActionConfig, row: any) => {
76
79
  ElMessage.success(msg);
77
- action.after?.();
80
+ action.after?.(row);
78
81
  };
79
82
 
80
83
  const error = (msg: string) => ElMessage.error(msg);
@@ -89,7 +92,7 @@ const deleteAction = async (action: ColumnActionConfig, row: any) => {
89
92
  const res = await action.handler?.(row);
90
93
 
91
94
  if (res.ret === 0) {
92
- success('删除成功!', action);
95
+ success('删除成功!', action, row);
93
96
  } else {
94
97
  error(res.msg || '删除失败');
95
98
  }
@@ -106,7 +109,7 @@ const copyHandler = async (action: ColumnActionConfig, row: any) => {
106
109
  const res = await action.handler?.(row);
107
110
 
108
111
  if (res.ret === 0) {
109
- success('复制成功!', action);
112
+ success('复制成功!', action, row);
110
113
  } else {
111
114
  error(`复制失败!${res.msg}`);
112
115
  }
@@ -116,6 +119,7 @@ const copyHandler = async (action: ColumnActionConfig, row: any) => {
116
119
  };
117
120
 
118
121
  const actionHandler = async (action: ColumnActionConfig, row: any, index: number) => {
122
+ await action.before?.(row);
119
123
  if (action.type === 'delete') {
120
124
  await deleteAction(action, row);
121
125
  } else if (action.type === 'copy') {
@@ -124,8 +128,8 @@ const actionHandler = async (action: ColumnActionConfig, row: any, index: number
124
128
  props.editState[index] = row;
125
129
  } else {
126
130
  await action.handler?.(row);
127
- action.after?.();
128
131
  }
132
+ action.after?.(row);
129
133
  };
130
134
 
131
135
  const save = async (index: number, config: ColumnConfig) => {
@@ -9,7 +9,7 @@
9
9
  :data="scope.row[config.prop]"
10
10
  ></m-table>
11
11
  <template #reference>
12
- <el-button type="text"> {{ config.text || formatter(config, scope.row) }}</el-button>
12
+ <el-button text type="primary"> {{ config.text || formatter(config, scope.row) }}</el-button>
13
13
  </template>
14
14
  </el-popover>
15
15
  </template>
package/src/Table.vue CHANGED
@@ -22,7 +22,7 @@
22
22
  <expand-column :config="item" :key="columnIndex"></expand-column>
23
23
  </template>
24
24
 
25
- <template v-if="item.selection">
25
+ <template v-else-if="item.selection">
26
26
  <el-table-column type="selection" :key="columnIndex" width="40" :selectable="item.selectable"></el-table-column>
27
27
  </template>
28
28
 
@@ -95,6 +95,7 @@ export default defineComponent({
95
95
  /** 是否显示表头 */
96
96
  showHeader: {
97
97
  type: Boolean,
98
+ default: true,
98
99
  },
99
100
 
100
101
  /** 空数据时显示的文本内容 */
@@ -204,9 +205,6 @@ export default defineComponent({
204
205
 
205
206
  <style lang="scss">
206
207
  .m-table {
207
- .el-button.action-btn {
208
- margin-right: 10px;
209
- }
210
208
  .el-button.action-btn + .el-button.action-btn {
211
209
  margin-left: 0;
212
210
  }
@@ -18,7 +18,7 @@
18
18
  ></m-form-container>
19
19
  </el-form>
20
20
 
21
- <el-button v-else-if="config.action === 'actionLink'" type="text" @click="config.handler(scope.row)">
21
+ <el-button v-else-if="config.action === 'actionLink'" text type="primary" @click="config.handler(scope.row)">
22
22
  {{ formatter(config, scope.row) }}
23
23
  </el-button>
24
24
 
@@ -34,7 +34,7 @@
34
34
  <template #content>
35
35
  <div>{{ formatter(config, scope.row) }}</div>
36
36
  </template>
37
- <el-button type="text">扩展配置</el-button>
37
+ <el-button text type="primary">扩展配置</el-button>
38
38
  </el-tooltip>
39
39
 
40
40
  <el-tag
package/src/schema.ts CHANGED
@@ -24,7 +24,8 @@ export interface ColumnActionConfig {
24
24
  text: string;
25
25
  name: string;
26
26
  handler?: (row: any) => Promise<any> | any;
27
- after?: () => void;
27
+ before?: (row: any) => void;
28
+ after?: (row: any) => void;
28
29
  action?: (data: { data: any }) => void;
29
30
  }
30
31
 
package/tsconfig.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "baseUrl": "../..",
5
- },
6
- "exclude": [
7
- "**/dist/**/*"
8
- ],
9
- }
package/vite.config.ts DELETED
@@ -1,27 +0,0 @@
1
- /*
2
- * Tencent is pleased to support the open source community by making TMagicEditor available.
3
- *
4
- * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
-
19
- import { defineConfig } from 'vite';
20
-
21
- import { getBaseConfig } from '../vite-config';
22
-
23
- import pkg from './package.json';
24
-
25
- const deps = Object.keys(pkg.dependencies);
26
-
27
- export default defineConfig(getBaseConfig(deps, 'TMagicTable'));