@a2simcode/ui 0.0.273 → 0.0.274

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.
@@ -1,199 +1,220 @@
1
- export default {
2
- "props": [
3
- {
4
- "name": "modelValue",
5
- "description": "绑定值",
6
- "type": "string | number | Array | undefined"
7
- },
8
- {
9
- "name": "options",
10
- "description": "树形数据选项列表",
11
- "type": "Array"
12
- },
13
- {
14
- "name": "checkStrictly",
15
- "description": "在点击节点时,是否只关注本级节点而不关注父子节点的关系",
16
- "type": "boolean",
17
- "default": "true"
18
- },
19
- {
20
- "name": "renderAfterExpand",
21
- "description": "是否在第一次展开时才进行渲染",
22
- "type": "boolean",
23
- "default": "true"
24
- },
25
- {
26
- "name": "props",
27
- "description": "配置选项,定义树形节点的相关字段,如 children、label、value 等",
28
- "type": "Record",
29
- "default": "() => ({\n children: 'children',\n label: 'label',\n value: 'value',\n})"
30
- },
31
- {
32
- "name": "size",
33
- "description": "尺寸",
34
- "type": "\"large\" | \"default\" | \"small\"",
35
- "default": "'default'"
36
- },
37
- {
38
- "name": "disabled",
39
- "description": "是否禁用",
40
- "type": "boolean",
41
- "default": "false"
42
- },
43
- {
44
- "name": "readonly",
45
- "description": "是否只读",
46
- "type": "boolean",
47
- "default": "false"
48
- },
49
- {
50
- "name": "clearable",
51
- "description": "是否显示清空按钮",
52
- "type": "boolean",
53
- "default": "true"
54
- },
55
- {
56
- "name": "placeholder",
57
- "description": "输入框占位文本",
58
- "type": "string",
59
- "default": "'请选择'"
60
- },
61
- {
62
- "name": "dataType",
63
- "description": "数据类型,用于从全局数据加载树形数据",
64
- "type": "string",
65
- "default": "''"
66
- },
67
- {
68
- "name": "dataCode",
69
- "description": "数据编码,用于从全局数据加载树形数据",
70
- "type": "string",
71
- "default": "''"
72
- },
73
- {
74
- "name": "labelKey",
75
- "description": "树形标签字段的键名",
76
- "type": "string",
77
- "default": "''"
78
- },
79
- {
80
- "name": "valueKey",
81
- "description": "树形值字段的键名",
82
- "type": "string",
83
- "default": "''"
84
- },
85
- {
86
- "name": "pidKey",
87
- "description": "树形父级ID字段的键名",
88
- "type": "string",
89
- "default": "''"
90
- },
91
- {
92
- "name": "idKey",
93
- "description": "树形ID字段的键名",
94
- "type": "string",
95
- "default": "''"
96
- }
97
- ],
98
- "events": [
99
- {
100
- "name": "update:modelValue",
101
- "description": "",
102
- "type": "union"
103
- },
104
- {
105
- "name": "change",
106
- "description": "",
107
- "type": "union"
108
- }
109
- ],
110
- "slots": [],
111
- "methods": [],
112
- "types": [
113
- {
114
- "name": "TreeSelectProps",
115
- "properties": [
116
- {
117
- "name": "modelValue",
118
- "type": "string | number | (string | number)[] | undefined",
119
- "description": "绑定值"
120
- },
121
- {
122
- "name": "options",
123
- "type": "Record<string, any>[]",
124
- "description": "树形数据选项列表"
125
- },
126
- {
127
- "name": "checkStrictly",
128
- "type": "boolean",
129
- "description": "在点击节点时,是否只关注本级节点而不关注父子节点的关系"
130
- },
131
- {
132
- "name": "renderAfterExpand",
133
- "type": "boolean",
134
- "description": "是否在第一次展开时才进行渲染"
135
- },
136
- {
137
- "name": "props",
138
- "type": "Record<string, any>",
139
- "description": "配置选项,定义树形节点的相关字段,如 children、label、value 等"
140
- },
141
- {
142
- "name": "size",
143
- "type": "'large' | 'default' | 'small'",
144
- "description": "尺寸"
145
- },
146
- {
147
- "name": "disabled",
148
- "type": "boolean",
149
- "description": "是否禁用"
150
- },
151
- {
152
- "name": "readonly",
153
- "type": "boolean",
154
- "description": "是否只读"
155
- },
156
- {
157
- "name": "clearable",
158
- "type": "boolean",
159
- "description": "是否显示清空按钮"
160
- },
161
- {
162
- "name": "placeholder",
163
- "type": "string",
164
- "description": "输入框占位文本"
165
- },
166
- {
167
- "name": "dataType",
168
- "type": "string",
169
- "description": "数据类型,用于从全局数据加载树形数据"
170
- },
171
- {
172
- "name": "dataCode",
173
- "type": "string",
174
- "description": "数据编码,用于从全局数据加载树形数据"
175
- },
176
- {
177
- "name": "labelKey",
178
- "type": "string",
179
- "description": "树形标签字段的键名"
180
- },
181
- {
182
- "name": "valueKey",
183
- "type": "string",
184
- "description": "树形值字段的键名"
185
- },
186
- {
187
- "name": "pidKey",
188
- "type": "string",
189
- "description": "树形父级ID字段的键名"
190
- },
191
- {
192
- "name": "idKey",
193
- "type": "string",
194
- "description": "树形ID字段的键名"
195
- }
196
- ]
197
- }
198
- ]
199
- }
1
+ export default {
2
+ "props": [
3
+ {
4
+ "name": "modelValue",
5
+ "description": "绑定值",
6
+ "type": "string | number | Array | undefined"
7
+ },
8
+ {
9
+ "name": "options",
10
+ "description": "树形数据选项列表",
11
+ "type": "Array"
12
+ },
13
+ {
14
+ "name": "lazy",
15
+ "description": "是否懒加载子节点数据,配合 load 方法使用",
16
+ "type": "boolean",
17
+ "default": "false"
18
+ },
19
+ {
20
+ "name": "load",
21
+ "description": "加载子树数据的方法,仅当 lazy 为 true 时生效",
22
+ "type": "TSFunctionType"
23
+ },
24
+ {
25
+ "name": "checkStrictly",
26
+ "description": "在点击节点时,是否只关注本级节点而不关注父子节点的关系",
27
+ "type": "boolean",
28
+ "default": "true"
29
+ },
30
+ {
31
+ "name": "renderAfterExpand",
32
+ "description": "是否在第一次展开时才进行渲染",
33
+ "type": "boolean",
34
+ "default": "true"
35
+ },
36
+ {
37
+ "name": "props",
38
+ "description": "配置选项,定义树形节点的相关字段,如 children、label、value 等",
39
+ "type": "Record",
40
+ "default": "() => ({\r\n children: 'children',\r\n label: 'label',\r\n value: 'value',\r\n})"
41
+ },
42
+ {
43
+ "name": "size",
44
+ "description": "尺寸",
45
+ "type": "\"large\" | \"default\" | \"small\"",
46
+ "default": "'default'"
47
+ },
48
+ {
49
+ "name": "disabled",
50
+ "description": "是否禁用",
51
+ "type": "boolean",
52
+ "default": "false"
53
+ },
54
+ {
55
+ "name": "readonly",
56
+ "description": "是否只读",
57
+ "type": "boolean",
58
+ "default": "false"
59
+ },
60
+ {
61
+ "name": "clearable",
62
+ "description": "是否显示清空按钮",
63
+ "type": "boolean",
64
+ "default": "true"
65
+ },
66
+ {
67
+ "name": "placeholder",
68
+ "description": "输入框占位文本",
69
+ "type": "string",
70
+ "default": "'请选择'"
71
+ },
72
+ {
73
+ "name": "dataType",
74
+ "description": "数据类型,用于从全局数据加载树形数据",
75
+ "type": "string",
76
+ "default": "''"
77
+ },
78
+ {
79
+ "name": "dataCode",
80
+ "description": "数据编码,用于从全局数据加载树形数据",
81
+ "type": "string",
82
+ "default": "''"
83
+ },
84
+ {
85
+ "name": "labelKey",
86
+ "description": "树形标签字段的键名",
87
+ "type": "string",
88
+ "default": "''"
89
+ },
90
+ {
91
+ "name": "valueKey",
92
+ "description": "树形值字段的键名",
93
+ "type": "string",
94
+ "default": "''"
95
+ },
96
+ {
97
+ "name": "pidKey",
98
+ "description": "树形父级ID字段的键名",
99
+ "type": "string",
100
+ "default": "''"
101
+ },
102
+ {
103
+ "name": "idKey",
104
+ "description": "树形ID字段的键名",
105
+ "type": "string",
106
+ "default": "''"
107
+ }
108
+ ],
109
+ "events": [
110
+ {
111
+ "name": "update:modelValue",
112
+ "description": "",
113
+ "type": "union"
114
+ },
115
+ {
116
+ "name": "change",
117
+ "description": "",
118
+ "type": "union"
119
+ }
120
+ ],
121
+ "slots": [],
122
+ "methods": [],
123
+ "types": [
124
+ {
125
+ "name": "TreeSelectProps",
126
+ "properties": [
127
+ {
128
+ "name": "modelValue",
129
+ "type": "string | number | (string | number)[] | undefined",
130
+ "description": "绑定值"
131
+ },
132
+ {
133
+ "name": "options",
134
+ "type": "Record<string, any>[]",
135
+ "description": "树形数据选项列表"
136
+ },
137
+ {
138
+ "name": "lazy",
139
+ "type": "boolean",
140
+ "description": "是否懒加载子节点数据,配合 load 方法使用"
141
+ },
142
+ {
143
+ "name": "load",
144
+ "type": "(node: Record<string, any>, resolve: (data: Record<string, any>[]) => void) => void",
145
+ "description": "加载子树数据的方法,仅当 lazy 为 true 时生效"
146
+ },
147
+ {
148
+ "name": "checkStrictly",
149
+ "type": "boolean",
150
+ "description": "在点击节点时,是否只关注本级节点而不关注父子节点的关系"
151
+ },
152
+ {
153
+ "name": "renderAfterExpand",
154
+ "type": "boolean",
155
+ "description": "是否在第一次展开时才进行渲染"
156
+ },
157
+ {
158
+ "name": "props",
159
+ "type": "Record<string, any>",
160
+ "description": "配置选项,定义树形节点的相关字段,如 children、label、value 等"
161
+ },
162
+ {
163
+ "name": "size",
164
+ "type": "'large' | 'default' | 'small'",
165
+ "description": "尺寸"
166
+ },
167
+ {
168
+ "name": "disabled",
169
+ "type": "boolean",
170
+ "description": "是否禁用"
171
+ },
172
+ {
173
+ "name": "readonly",
174
+ "type": "boolean",
175
+ "description": "是否只读"
176
+ },
177
+ {
178
+ "name": "clearable",
179
+ "type": "boolean",
180
+ "description": "是否显示清空按钮"
181
+ },
182
+ {
183
+ "name": "placeholder",
184
+ "type": "string",
185
+ "description": "输入框占位文本"
186
+ },
187
+ {
188
+ "name": "dataType",
189
+ "type": "string",
190
+ "description": "数据类型,用于从全局数据加载树形数据"
191
+ },
192
+ {
193
+ "name": "dataCode",
194
+ "type": "string",
195
+ "description": "数据编码,用于从全局数据加载树形数据"
196
+ },
197
+ {
198
+ "name": "labelKey",
199
+ "type": "string",
200
+ "description": "树形标签字段的键名"
201
+ },
202
+ {
203
+ "name": "valueKey",
204
+ "type": "string",
205
+ "description": "树形值字段的键名"
206
+ },
207
+ {
208
+ "name": "pidKey",
209
+ "type": "string",
210
+ "description": "树形父级ID字段的键名"
211
+ },
212
+ {
213
+ "name": "idKey",
214
+ "type": "string",
215
+ "description": "树形ID字段的键名"
216
+ }
217
+ ]
218
+ }
219
+ ]
220
+ }
@@ -13,6 +13,17 @@
13
13
  </template>
14
14
  </Demo>
15
15
 
16
+ ## 懒加载
17
+
18
+ <Demo :source-code="treeSelectLazyCode">
19
+ <template #source>
20
+ <tree-select-lazy />
21
+ </template>
22
+ <template #description>
23
+ 设置 <code>lazy</code> 属性并配合 <code>load</code> 方法可开启懒加载,展开节点时异步加载子节点数据。懒加载模式下优先使用 <code>load</code> 加载数据,节点数据中可通过 <code>isLeaf</code> 字段标识叶子节点。
24
+ </template>
25
+ </Demo>
26
+
16
27
  ## API
17
28
 
18
29
  <ApiTable :data="treeSelectApi" componentName="tree-select" />
@@ -20,5 +31,7 @@
20
31
  <script setup>
21
32
  import TreeSelectBasic from '../examples/tree-select/basic.vue'
22
33
  import treeSelectBasicCode from '../examples/tree-select/basic.vue?raw'
34
+ import TreeSelectLazy from '../examples/tree-select/lazy.vue'
35
+ import treeSelectLazyCode from '../examples/tree-select/lazy.vue?raw'
23
36
  import treeSelectApi from './meta/tree-select'
24
37
  </script>
@@ -0,0 +1,42 @@
1
+ <template>
2
+ <j-tree-select v-model="selectedValue" lazy :load="loadNode" placeholder="请选择" />
3
+ </template>
4
+
5
+ <script setup lang="ts">
6
+ import { ref } from 'vue'
7
+ import JTreeSelect from '../../../packages/components/tree-select'
8
+
9
+ const selectedValue = ref<string>('')
10
+
11
+ let nodeId = 0
12
+
13
+ const loadNode = (node: Record<string, any>, resolve: (data: Record<string, any>[]) => void) => {
14
+ // 根节点:level 为 0,加载一级节点
15
+ if (node.level === 0) {
16
+ return resolve([
17
+ { value: `${++nodeId}`, label: `一级 ${nodeId}` },
18
+ { value: `${++nodeId}`, label: `一级 ${nodeId}` },
19
+ ])
20
+ }
21
+
22
+ // 超过三层不再加载子节点
23
+ if (node.level > 2) {
24
+ return resolve([])
25
+ }
26
+
27
+ // 模拟异步加载子节点数据
28
+ setTimeout(() => {
29
+ resolve([
30
+ {
31
+ value: `${node.data.value}-${++nodeId}`,
32
+ label: `${node.data.label} 的子节点 ${nodeId}`,
33
+ },
34
+ {
35
+ value: `${node.data.value}-${++nodeId}`,
36
+ label: `${node.data.label} 的子节点 ${nodeId}`,
37
+ isLeaf: true,
38
+ },
39
+ ])
40
+ }, 500)
41
+ }
42
+ </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a2simcode/ui",
3
- "version": "0.0.273",
3
+ "version": "0.0.274",
4
4
  "description": "A Vue 3 UI Component Library",
5
5
  "type": "module",
6
6
  "main": "./dist/simcode-ui.umd.js",