@a2simcode/ui 0.0.61 → 0.0.62

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.
@@ -43,6 +43,34 @@
43
43
  </template>
44
44
  </Demo>
45
45
 
46
+ ## Link 链接
47
+
48
+ 通过列类型 `link` 可以渲染链接,并支持点击事件。
49
+
50
+ <Demo :source-code="tableLinkCode">
51
+ <template #source>
52
+ <table-link />
53
+ </template>
54
+ <template #description>
55
+ 在 `columns` 中设置 `type: 'link'`。
56
+ 通过 `config.click` 设置点击回调函数,参数为 `{ row, column, e, openLayer }`。
57
+ </template>
58
+ </Demo>
59
+
60
+ ## 自定义布局
61
+
62
+ 通过列配置中的 `customLayout` 属性,可以使用 VTable 的 CustomLayout 功能自定义单元格渲染。
63
+
64
+ <Demo :source-code="tableCustomLayoutCode">
65
+ <template #source>
66
+ <table-custom-layout />
67
+ </template>
68
+ <template #description>
69
+ 在列对象中定义 `customLayout` 函数。该函数接收 `args` 参数,其中包含 `customLayout` 类(VTable.CustomLayout),可用于创建 Group, Text, Image 等布局元素。
70
+ 函数需要返回 `{ rootContainer, renderDefault: false }`。
71
+ </template>
72
+ </Demo>
73
+
46
74
  ## 冻结列
47
75
 
48
76
  通过 `columns` 中的 `config.frozen` 属性设置列的冻结方式,支持 `left`(左侧冻结)和 `right`(右侧冻结)。
@@ -204,6 +232,8 @@
204
232
  import TableBasic from '../examples/table/basic.vue'
205
233
  import TableTag from '../examples/table/tag.vue'
206
234
  import TableIcon from '../examples/table/icon.vue'
235
+ import TableLink from '../examples/table/link.vue'
236
+ import TableCustomLayout from '../examples/table/custom-layout.vue'
207
237
  import TableFrozenColumn from '../examples/table/frozen-column.vue'
208
238
  import TableHeightMode from '../examples/table/height-mode.vue'
209
239
  import TableTreeColumn from '../examples/table/tree-column.vue'
@@ -220,6 +250,8 @@ import tableApi from './meta/table'
220
250
  import tableBasicCode from '../examples/table/basic.vue?raw'
221
251
  import tableTagCode from '../examples/table/tag.vue?raw'
222
252
  import tableIconCode from '../examples/table/icon.vue?raw'
253
+ import tableLinkCode from '../examples/table/link.vue?raw'
254
+ import tableCustomLayoutCode from '../examples/table/custom-layout.vue?raw'
223
255
  import tableFrozenColumnCode from '../examples/table/frozen-column.vue?raw'
224
256
  import tableHeightModeCode from '../examples/table/height-mode.vue?raw'
225
257
  import tableTreeColumnCode from '../examples/table/tree-column.vue?raw'
@@ -0,0 +1,115 @@
1
+ <template>
2
+ <div style="position: relative; width: 100%; height: 400px">
3
+ <j-table :columns="columns" :records="records" />
4
+ </div>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import { ref } from 'vue'
9
+
10
+ const columns = ref([
11
+ {
12
+ id: 'id',
13
+ config: {
14
+ label: 'ID',
15
+ width: 80,
16
+ },
17
+ },
18
+ {
19
+ id: 'info',
20
+ config: {
21
+ label: 'User Info (Custom Layout)',
22
+ width: 250,
23
+ },
24
+ customLayout: (args: any) => {
25
+ const { table, row, col, rect, customLayout } = args
26
+ const { Group, Text, Image } = customLayout
27
+ const record = table.getCellOriginRecord(col, row)
28
+ const { name, avatar, role } = record
29
+
30
+ const container = new Group({
31
+ height: rect.height,
32
+ width: rect.width,
33
+ display: 'flex',
34
+ flexDirection: 'row',
35
+ alignItems: 'center',
36
+ padding: [0, 10],
37
+ })
38
+
39
+ // Avatar
40
+ const image = new Image({
41
+ width: 32,
42
+ height: 32,
43
+ image: avatar,
44
+ cornerRadius: 16,
45
+ marginRight: 10,
46
+ })
47
+ container.add(image)
48
+
49
+ // Text Container
50
+ const textContainer = new Group({
51
+ height: 32,
52
+ width: rect.width - 60,
53
+ display: 'flex',
54
+ flexDirection: 'column',
55
+ justifyContent: 'center',
56
+ })
57
+
58
+ const nameText = new Text({
59
+ text: name,
60
+ fontSize: 14,
61
+ fontFamily: 'sans-serif',
62
+ fill: '#333',
63
+ })
64
+ textContainer.add(nameText)
65
+
66
+ const roleText = new Text({
67
+ text: role,
68
+ fontSize: 12,
69
+ fontFamily: 'sans-serif',
70
+ fill: '#999',
71
+ marginTop: 4,
72
+ })
73
+ textContainer.add(roleText)
74
+
75
+ container.add(textContainer)
76
+
77
+ return {
78
+ rootContainer: container,
79
+ renderDefault: false,
80
+ }
81
+ },
82
+ },
83
+ {
84
+ id: 'status',
85
+ config: {
86
+ label: 'Status',
87
+ width: 100,
88
+ },
89
+ },
90
+ ])
91
+
92
+ const records = ref([
93
+ {
94
+ id: 1,
95
+ name: 'John Doe',
96
+ role: 'Software Engineer',
97
+ avatar: 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMiIgaGVpZ2h0PSIzMiIgdmlld0JveD0iMCAwIDMyIDMyIj48cmVjdCB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIGZpbGw9IiMxNjVkZmYiLz48dGV4dCB4PSIxNiIgeT0iMjEiIGZvbnQtc2l6ZT0iMTYiIGZpbGw9IndoaXRlIiB0ZXh0LWFuY2hvcj0ibWlkZGxlIiBmb250LWZhbWlseT0ic2Fucy1zZXJpZiI+SjwvdGV4dD48L3N2Zz4=',
98
+ status: 'Active',
99
+ },
100
+ {
101
+ id: 2,
102
+ name: 'Jane Smith',
103
+ role: 'Product Manager',
104
+ avatar: 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMiIgaGVpZ2h0PSIzMiIgdmlld0JveD0iMCAwIDMyIDMyIj48cmVjdCB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIGZpbGw9IiMwMGI0MmEiLz48dGV4dCB4PSIxNiIgeT0iMjEiIGZvbnQtc2l6ZT0iMTYiIGZpbGw9IndoaXRlIiB0ZXh0LWFuY2hvcj0ibWlkZGxlIiBmb250LWZhbWlseT0ic2Fucy1zZXJpZiI+SjwvdGV4dD48L3N2Zz4=',
105
+ status: 'Inactive',
106
+ },
107
+ {
108
+ id: 3,
109
+ name: 'Bob Johnson',
110
+ role: 'Designer',
111
+ avatar: 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMiIgaGVpZ2h0PSIzMiIgdmlld0JveD0iMCAwIDMyIDMyIj48cmVjdCB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIGZpbGw9IiNmYmI0MDAiLz48dGV4dCB4PSIxNiIgeT0iMjEiIGZvbnQtc2l6ZT0iMTYiIGZpbGw9IndoaXRlIiB0ZXh0LWFuY2hvcj0ibWlkZGxlIiBmb250LWZhbWlseT0ic2Fucy1zZXJpZiI+QjwvdGV4dD48L3N2Zz4=',
112
+ status: 'Active',
113
+ },
114
+ ])
115
+ </script>
@@ -0,0 +1,66 @@
1
+ <template>
2
+ <div style="position: relative; width: 100%; height: 400px">
3
+ <j-table :columns="columns" :records="records" />
4
+ </div>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import { ref } from 'vue'
9
+ import { ElMessage } from 'element-plus'
10
+
11
+ const columns = ref([
12
+ {
13
+ id: 'name',
14
+ type: 'link',
15
+ config: {
16
+ label: '项目名称',
17
+ width: 'auto',
18
+ align: 'left',
19
+ click: ({ row }: { row: any }) => {
20
+ ElMessage.success(`点击了项目: ${row.name}`)
21
+ },
22
+ },
23
+ },
24
+ {
25
+ id: 'status',
26
+ config: {
27
+ label: '状态',
28
+ width: 'auto',
29
+ align: 'center',
30
+ },
31
+ },
32
+ {
33
+ id: 'owner',
34
+ type: 'link',
35
+ config: {
36
+ label: '负责人',
37
+ width: 'auto',
38
+ align: 'center',
39
+ click: ({ row }: { row: any }) => {
40
+ ElMessage.info(`查看负责人: ${row.owner}`)
41
+ },
42
+ },
43
+ },
44
+ ])
45
+
46
+ const records = ref([
47
+ {
48
+ id: '1',
49
+ name: '项目A',
50
+ status: '进行中',
51
+ owner: '张三',
52
+ },
53
+ {
54
+ id: '2',
55
+ name: '项目B',
56
+ status: '已完成',
57
+ owner: '李四',
58
+ },
59
+ {
60
+ id: '3',
61
+ name: '项目C',
62
+ status: '待审核',
63
+ owner: '王五',
64
+ },
65
+ ])
66
+ </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a2simcode/ui",
3
- "version": "0.0.61",
3
+ "version": "0.0.62",
4
4
  "description": "A Vue 3 UI Component Library",
5
5
  "type": "module",
6
6
  "main": "./dist/simcode-ui.umd.js",