@idooel/components 0.0.2-beta.3 → 0.0.2-beta.30
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/README.md +98 -98
- package/dist/@idooel/components.esm.js +3622 -1592
- package/dist/@idooel/components.umd.js +3676 -1647
- package/jsconfig.json +7 -7
- package/package.json +64 -50
- package/packages/alert/index.js +4 -4
- package/packages/alert/src/index.vue +45 -45
- package/packages/batch-export/index.js +4 -4
- package/packages/batch-export/src/index.vue +104 -104
- package/packages/business-components/modal-fsm/index.js +4 -4
- package/packages/business-components/modal-fsm/src/index.vue +163 -163
- package/packages/business-components/modal-import/index.js +4 -4
- package/packages/business-components/modal-import/src/index.vue +222 -139
- package/packages/business-components/modal-timeline/index.js +4 -4
- package/packages/business-components/modal-timeline/src/index.vue +77 -77
- package/packages/business-components/tabs-sub-center/index.js +4 -4
- package/packages/business-components/tabs-sub-center/src/index.vue +116 -116
- package/packages/button/index.js +4 -4
- package/packages/button/src/index.vue +65 -65
- package/packages/checkbox/index.js +4 -4
- package/packages/checkbox/src/index.vue +52 -52
- package/packages/composite-components/button-group/index.js +4 -4
- package/packages/composite-components/button-group/src/index.vue +151 -151
- package/packages/composite-components/form-attachment/src/index.vue +14 -14
- package/packages/composite-components/form-img-crop/index.js +4 -4
- package/packages/composite-components/form-img-crop/src/index.vue +131 -131
- package/packages/composite-components/modal-confirm/index.js +4 -4
- package/packages/composite-components/modal-confirm/src/index.vue +103 -103
- package/packages/composite-components/modal-form/index.js +4 -4
- package/packages/composite-components/modal-form/src/index.vue +230 -230
- package/packages/composite-components/modal-img-crop/index.js +4 -4
- package/packages/composite-components/modal-img-crop/src/index.vue +298 -298
- package/packages/composite-components/modal-table/index.js +4 -4
- package/packages/composite-components/modal-table/src/index.vue +155 -155
- package/packages/composite-components/modal-tree/index.js +4 -4
- package/packages/composite-components/modal-tree/src/index.vue +75 -75
- package/packages/composite-components/search-area/index.js +4 -4
- package/packages/composite-components/search-area/src/index.vue +239 -237
- package/packages/composite-components/search-area/src/label.vue +35 -35
- package/packages/composite-components/select-entity-modal-table/index.js +4 -4
- package/packages/composite-components/select-entity-modal-table/src/index.vue +171 -171
- package/packages/date/index.js +4 -4
- package/packages/date/src/index.vue +112 -112
- package/packages/date-range/index.js +4 -4
- package/packages/date-range/src/index.vue +47 -47
- package/packages/form/index.js +4 -4
- package/packages/form/src/index.vue +393 -319
- package/packages/icon/index.js +4 -4
- package/packages/icon/src/index.vue +31 -31
- package/packages/index.js +159 -153
- package/packages/input/index.js +4 -4
- package/packages/input/src/index.vue +35 -35
- package/packages/input-number/index.js +4 -4
- package/packages/input-number/src/index.vue +23 -23
- package/packages/loading/index.js +4 -4
- package/packages/loading/src/index.vue +36 -36
- package/packages/meta/provider.js +4 -0
- package/packages/modal/index.js +4 -4
- package/packages/modal/src/index.vue +184 -184
- package/packages/models/form-group-model/index.js +4 -4
- package/packages/models/form-group-model/src/index.vue +271 -273
- package/packages/models/form-model/index.js +4 -4
- package/packages/models/form-model/src/index.vue +236 -232
- package/packages/models/step-model/index.js +4 -4
- package/packages/models/step-model/src/index.vue +224 -224
- package/packages/models/tree-table-model/README.md +0 -0
- package/packages/models/tree-table-model/index.js +4 -4
- package/packages/models/tree-table-model/src/index.vue +964 -689
- package/packages/pagination/index.js +5 -0
- package/packages/pagination/src/index.vue +372 -0
- package/packages/radio/index.js +4 -4
- package/packages/radio/src/index.vue +56 -56
- package/packages/select/index.js +4 -4
- package/packages/select/src/index.vue +113 -105
- package/packages/select-entity/index.js +4 -4
- package/packages/select-entity/src/index.vue +119 -119
- package/packages/table/index.js +4 -4
- package/packages/table/src/action.vue +176 -172
- package/packages/table/src/index.vue +605 -319
- package/packages/tabs/index.js +4 -4
- package/packages/tabs/src/index.vue +55 -55
- package/packages/text/index.js +4 -4
- package/packages/text/src/index.vue +47 -47
- package/packages/text-editor/index.js +4 -4
- package/packages/text-editor/src/index.vue +72 -72
- package/packages/textarea/index.js +4 -4
- package/packages/textarea/src/index.vue +57 -57
- package/packages/theme/form.scss +21 -21
- package/packages/theme/index.scss +43 -43
- package/packages/theme/overrid.scss +7 -7
- package/packages/theme/styleClass.scss +2 -2
- package/packages/theme/variables.scss +55 -55
- package/packages/timeline/index.js +4 -4
- package/packages/timeline/src/index.vue +257 -257
- package/packages/tpl/index.js +4 -4
- package/packages/tpl/src/index.vue +55 -55
- package/packages/tree/index.js +4 -4
- package/packages/tree/src/TreeNode.vue +29 -29
- package/packages/tree/src/index.vue +101 -101
- package/packages/tree-select/index.js +4 -4
- package/packages/tree-select/src/index.vue +142 -142
- package/packages/upload/index.js +4 -4
- package/packages/upload/src/index.vue +998 -494
- package/packages/utils/README.md +172 -0
- package/packages/utils/index.js +66 -62
- package/packages/utils/runtime-context/dataPoolAPI.js +501 -0
- package/packages/utils/runtime-context/globalDataPool.js +279 -0
- package/packages/utils/runtime-context/index.js +76 -0
- package/packages/utils/runtime-context/modelSchema.js +174 -0
- package/scripts/rollup.config.js +42 -42
- package/scripts/rollup.esm.config.js +11 -11
- package/scripts/rollup.umd.config.js +17 -14
- package/vitest.config.js +17 -0
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { createDataPool } from '@idooel/runtime-context'
|
|
2
|
+
import { TREE_TABLE_FIELDS, getFieldDefaults, validateFieldType, getSupportedFields } from './modelSchema.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 全局数据池管理器
|
|
6
|
+
* 挂载到 window.__idooel_data_pool__,提供统一的数据和实例方法管理
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
class BaseModelMethods {
|
|
10
|
+
constructor(instanceId, dataPool) {
|
|
11
|
+
this.instanceId = instanceId
|
|
12
|
+
this.dataPool = dataPool
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// 基础数据操作 - 保留,实际在使用
|
|
16
|
+
setData(key, value) {
|
|
17
|
+
// 验证字段类型(可选)
|
|
18
|
+
const supportedFields = getSupportedFields()
|
|
19
|
+
if (supportedFields.includes(key)) {
|
|
20
|
+
const fieldDef = TREE_TABLE_FIELDS[key]
|
|
21
|
+
if (fieldDef && !validateFieldType(value, fieldDef.type)) {
|
|
22
|
+
console.warn(`Field type mismatch for ${key}: expected ${fieldDef.type}, got ${typeof value}`)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
this.dataPool.manager.setData(this.instanceId, key, value)
|
|
27
|
+
return this
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getData(key, defaultValue = null) {
|
|
31
|
+
return this.dataPool.manager.getData(this.instanceId, key, defaultValue)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 事件订阅 - 保留,实际在使用
|
|
35
|
+
subscribe(key, callback) {
|
|
36
|
+
return this.dataPool.manager.subscribe({
|
|
37
|
+
instanceId: this.instanceId,
|
|
38
|
+
key
|
|
39
|
+
}, callback)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// 数据清理 - 保留,实际在使用
|
|
43
|
+
cleanup() {
|
|
44
|
+
this.dataPool.manager.clearModelData(this.instanceId)
|
|
45
|
+
return this
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// 获取数据池引用 - 保留,实际在使用
|
|
49
|
+
getDataPool() {
|
|
50
|
+
return this.dataPool
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
class TreeTableModelMethods extends BaseModelMethods {
|
|
55
|
+
constructor(instanceId, dataPool) {
|
|
56
|
+
super(instanceId, dataPool)
|
|
57
|
+
// 初始化 TreeTable 特有的数据结构 - 只保留必要的字段
|
|
58
|
+
this._initTreeTableData()
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
_initTreeTableData() {
|
|
62
|
+
// 设置初始元数据
|
|
63
|
+
this.setData('__meta__', {
|
|
64
|
+
type: 'tree-table',
|
|
65
|
+
instanceId: this.instanceId,
|
|
66
|
+
createdAt: Date.now()
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
// 使用 schema 初始化数据字段
|
|
70
|
+
const defaults = getFieldDefaults(TREE_TABLE_FIELDS)
|
|
71
|
+
for (const [fieldName, defaultValue] of Object.entries(defaults)) {
|
|
72
|
+
this.setData(fieldName, defaultValue)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// TreeTable 核心方法 - 只保留实际使用的
|
|
77
|
+
setCurrentRowData(data) {
|
|
78
|
+
this.setData('currentRowData', data)
|
|
79
|
+
return this
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
getCurrentRowData() {
|
|
83
|
+
return this.getData('currentRowData', {})
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// 共享数据操作(与 modal table 交互)- 保留,实际在使用
|
|
87
|
+
setSharedData(data) {
|
|
88
|
+
if (data && Object.keys(data).length > 0) {
|
|
89
|
+
this.dataPool.manager.setSharedData('modalTable', 'parentCurrentRowData', data)
|
|
90
|
+
}
|
|
91
|
+
return this
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
getSharedData() {
|
|
95
|
+
return this.dataPool.manager.getSharedData('modalTable', 'parentCurrentRowData')
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// 订阅共享数据变化 - 保留,实际在使用
|
|
99
|
+
subscribeShared(callback) {
|
|
100
|
+
return this.dataPool.manager.subscribe({
|
|
101
|
+
namespace: 'modalTable',
|
|
102
|
+
key: 'parentCurrentRowData'
|
|
103
|
+
}, callback)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
class GlobalDataManager {
|
|
108
|
+
constructor() {
|
|
109
|
+
this.models = new Map()
|
|
110
|
+
this.runtimeContext = createDataPool()
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// 注册模型实例 - 保留,实际在使用
|
|
114
|
+
registerModel(modelType, instanceId, methods) {
|
|
115
|
+
if (this.models.has(instanceId)) {
|
|
116
|
+
console.warn(`Model instance ${instanceId} already exists`)
|
|
117
|
+
return this
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
this.models.set(instanceId, {
|
|
121
|
+
type: modelType,
|
|
122
|
+
instanceId,
|
|
123
|
+
methods,
|
|
124
|
+
createdAt: Date.now()
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
return this
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// 注销模型实例 - 保留,实际在使用
|
|
131
|
+
unregisterModel(instanceId) {
|
|
132
|
+
if (this.models.has(instanceId)) {
|
|
133
|
+
this.clearModelData(instanceId)
|
|
134
|
+
this.models.delete(instanceId)
|
|
135
|
+
}
|
|
136
|
+
return this
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// 获取模型实例 - 保留,实际在使用
|
|
140
|
+
getModel(instanceId) {
|
|
141
|
+
const model = this.models.get(instanceId)
|
|
142
|
+
return model ? model.methods : null
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// 获取指定类型的所有模型 - 保留,dataPoolAPI 中使用
|
|
146
|
+
getAllModels(modelType = null) {
|
|
147
|
+
const result = {}
|
|
148
|
+
for (const [instanceId, model] of this.models) {
|
|
149
|
+
if (!modelType || model.type === modelType) {
|
|
150
|
+
result[instanceId] = model.methods
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return result
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// 设置模型数据 - 保留,实际在使用
|
|
157
|
+
setData(instanceId, key, value) {
|
|
158
|
+
const model = this.models.get(instanceId)
|
|
159
|
+
if (!model) {
|
|
160
|
+
console.error(`Model instance ${instanceId} not found`)
|
|
161
|
+
return this
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
this.runtimeContext.set(instanceId, key, value)
|
|
165
|
+
return this
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// 获取模型数据 - 保留,实际在使用
|
|
169
|
+
getData(instanceId, key, defaultValue = null) {
|
|
170
|
+
const model = this.models.get(instanceId)
|
|
171
|
+
if (!model) {
|
|
172
|
+
return defaultValue
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return this.runtimeContext.get(instanceId, key, defaultValue)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// 设置共享数据 - 保留,实际在使用(modal table 交互)
|
|
179
|
+
setSharedData(namespace, key, value) {
|
|
180
|
+
const prefixedNamespace = `shared.${namespace}`
|
|
181
|
+
this.runtimeContext.set(prefixedNamespace, key, value)
|
|
182
|
+
return this
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// 获取共享数据 - 保留,实际在使用
|
|
186
|
+
getSharedData(namespace, key, defaultValue = null) {
|
|
187
|
+
const prefixedNamespace = `shared.${namespace}`
|
|
188
|
+
return this.runtimeContext.get(prefixedNamespace, key, defaultValue)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// 订阅系统 - 保留,实际在使用
|
|
192
|
+
subscribe(filter, callback) {
|
|
193
|
+
return this.runtimeContext.subscribe(filter, callback)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// 清理模型数据 - 保留,实际在使用
|
|
197
|
+
clearModelData(instanceId) {
|
|
198
|
+
const model = this.models.get(instanceId)
|
|
199
|
+
if (model) {
|
|
200
|
+
this.runtimeContext.clear(instanceId)
|
|
201
|
+
}
|
|
202
|
+
return this
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// 模型工厂 - 简化版,只支持 tree-table
|
|
207
|
+
class ModelFactory {
|
|
208
|
+
static createModel(modelType, instanceId, options = {}) {
|
|
209
|
+
if (modelType !== 'tree-table') {
|
|
210
|
+
throw new Error(`Unsupported model type: ${modelType}. Only 'tree-table' is supported.`)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// 注册到全局数据池
|
|
214
|
+
window.__idooel_data_pool__.manager.registerModel(
|
|
215
|
+
modelType,
|
|
216
|
+
instanceId,
|
|
217
|
+
null // 占位符
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
// 创建 TreeTable 模型实例
|
|
221
|
+
const methods = new TreeTableModelMethods(instanceId, window.__idooel_data_pool__)
|
|
222
|
+
|
|
223
|
+
// 更新注册的方法引用
|
|
224
|
+
const model = window.__idooel_data_pool__.manager.models.get(instanceId)
|
|
225
|
+
if (model) {
|
|
226
|
+
model.methods = methods
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return methods
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// 初始化全局数据池 - 简化版
|
|
234
|
+
function initGlobalDataPool() {
|
|
235
|
+
if (window.__idooel_data_pool__) {
|
|
236
|
+
return window.__idooel_data_pool__
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const dataPool = {
|
|
240
|
+
// 全局管理接口
|
|
241
|
+
manager: new GlobalDataManager(),
|
|
242
|
+
|
|
243
|
+
// 模型工厂
|
|
244
|
+
factory: ModelFactory,
|
|
245
|
+
|
|
246
|
+
// 工具方法 - 只保留实际使用的
|
|
247
|
+
utils: {
|
|
248
|
+
// 生成唯一 ID - dataPoolAPI 中使用
|
|
249
|
+
generateId: (prefix = 'model') => `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`,
|
|
250
|
+
|
|
251
|
+
// 获取时间戳 - dataPoolAPI 中使用
|
|
252
|
+
now: () => Date.now(),
|
|
253
|
+
|
|
254
|
+
// 深拷贝 - dataPoolAPI 中使用
|
|
255
|
+
deepClone: (obj) => JSON.parse(JSON.stringify(obj)),
|
|
256
|
+
|
|
257
|
+
// 类型检查 - dataPoolAPI 中使用
|
|
258
|
+
isObject: (val) => val !== null && typeof val === 'object',
|
|
259
|
+
isEmpty: (val) => {
|
|
260
|
+
if (val == null) return true
|
|
261
|
+
if (Array.isArray(val) || typeof val === 'string') return val.length === 0
|
|
262
|
+
if (typeof val === 'object') return Object.keys(val).length === 0
|
|
263
|
+
return false
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// 挂载到 window
|
|
269
|
+
window.__idooel_data_pool__ = dataPool
|
|
270
|
+
|
|
271
|
+
return dataPool
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// 初始化
|
|
275
|
+
const globalDataPool = initGlobalDataPool()
|
|
276
|
+
|
|
277
|
+
// 导出函数和实例
|
|
278
|
+
export { BaseModelMethods, TreeTableModelMethods, GlobalDataManager, ModelFactory, initGlobalDataPool }
|
|
279
|
+
export default globalDataPool
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime Context 数据池模块
|
|
3
|
+
* 统一导出所有 runtime-context 相关的功能
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// 核心架构 - 确保全局数据池初始化
|
|
7
|
+
import globalDataPoolInstance, { initGlobalDataPool, BaseModelMethods, TreeTableModelMethods, GlobalDataManager, ModelFactory } from './globalDataPool.js'
|
|
8
|
+
// 确保全局数据池在使用前已初始化(全局数据池在模块加载时已经初始化)
|
|
9
|
+
export { initGlobalDataPool, BaseModelMethods, TreeTableModelMethods, GlobalDataManager, ModelFactory }
|
|
10
|
+
|
|
11
|
+
// API 接口
|
|
12
|
+
import createDataPoolAPIDefault, { dataPoolAPI } from './dataPoolAPI.js'
|
|
13
|
+
export { createDataPoolAPIDefault as createDataPoolAPI, dataPoolAPI }
|
|
14
|
+
export {
|
|
15
|
+
createTreeTableModel,
|
|
16
|
+
getModel,
|
|
17
|
+
getAllModels,
|
|
18
|
+
destroyModel,
|
|
19
|
+
setModelData,
|
|
20
|
+
getModelData,
|
|
21
|
+
setBatchModelData,
|
|
22
|
+
getAllModelData,
|
|
23
|
+
setUserInfo,
|
|
24
|
+
getUserInfo,
|
|
25
|
+
setUserPermissions,
|
|
26
|
+
setSystemConfig,
|
|
27
|
+
getSystemConfig,
|
|
28
|
+
setSystemTheme,
|
|
29
|
+
getSystemTheme,
|
|
30
|
+
setModalParentData,
|
|
31
|
+
getModalParentData,
|
|
32
|
+
setBusinessDictionaries,
|
|
33
|
+
getBusinessDictionaries,
|
|
34
|
+
subscribeModelData,
|
|
35
|
+
subscribeUserInfo,
|
|
36
|
+
subscribeSystemConfig,
|
|
37
|
+
subscribeSystemTheme,
|
|
38
|
+
subscribeModalParentData,
|
|
39
|
+
exportModelData,
|
|
40
|
+
importModelData,
|
|
41
|
+
clearModelData,
|
|
42
|
+
getDebugInfo,
|
|
43
|
+
generateId,
|
|
44
|
+
deepClone,
|
|
45
|
+
isEmpty,
|
|
46
|
+
isObject,
|
|
47
|
+
now
|
|
48
|
+
} from './dataPoolAPI.js'
|
|
49
|
+
|
|
50
|
+
// 模型字段定义
|
|
51
|
+
export {
|
|
52
|
+
FIELD_TYPES,
|
|
53
|
+
TREE_TABLE_FIELDS,
|
|
54
|
+
SHARED_FIELDS,
|
|
55
|
+
META_FIELDS,
|
|
56
|
+
getFieldDefaults,
|
|
57
|
+
validateFieldType,
|
|
58
|
+
getFieldDefinition,
|
|
59
|
+
getAllFields,
|
|
60
|
+
getSupportedFields
|
|
61
|
+
} from './modelSchema.js'
|
|
62
|
+
|
|
63
|
+
// 便捷的工厂函数
|
|
64
|
+
export const createGlobalDataPool = () => {
|
|
65
|
+
if (!window.__idooel_data_pool__) {
|
|
66
|
+
throw new Error('Global data pool not initialized. Please import runtime-context/globalDataPool.js first.')
|
|
67
|
+
}
|
|
68
|
+
return window.__idooel_data_pool__
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// 默认导出主要功能
|
|
72
|
+
export default {
|
|
73
|
+
initGlobalDataPool,
|
|
74
|
+
createDataPoolAPI: createDataPoolAPIDefault,
|
|
75
|
+
createGlobalDataPool
|
|
76
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 模型字段定义
|
|
3
|
+
* 定义 TreeTable 模型支持的数据字段和类型
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 字段类型定义
|
|
8
|
+
*/
|
|
9
|
+
export const FIELD_TYPES = {
|
|
10
|
+
OBJECT: 'object',
|
|
11
|
+
ARRAY: 'array',
|
|
12
|
+
STRING: 'string',
|
|
13
|
+
NUMBER: 'number',
|
|
14
|
+
BOOLEAN: 'boolean'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* TreeTable 模型字段定义
|
|
19
|
+
*/
|
|
20
|
+
export const TREE_TABLE_FIELDS = {
|
|
21
|
+
// 当前选中的行数据 - 核心字段
|
|
22
|
+
currentRowData: {
|
|
23
|
+
type: FIELD_TYPES.OBJECT,
|
|
24
|
+
default: {},
|
|
25
|
+
description: '当前表格选中的行数据'
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 共享数据字段定义
|
|
31
|
+
*/
|
|
32
|
+
export const SHARED_FIELDS = {
|
|
33
|
+
// Modal Table 父级数据
|
|
34
|
+
parentCurrentRowData: {
|
|
35
|
+
type: FIELD_TYPES.OBJECT,
|
|
36
|
+
default: null,
|
|
37
|
+
description: 'Modal Table 的父级表格当前行数据'
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 模型元数据字段
|
|
43
|
+
*/
|
|
44
|
+
export const META_FIELDS = {
|
|
45
|
+
// 基础元数据
|
|
46
|
+
type: {
|
|
47
|
+
type: FIELD_TYPES.STRING,
|
|
48
|
+
default: 'tree-table',
|
|
49
|
+
description: '模型类型'
|
|
50
|
+
},
|
|
51
|
+
instanceId: {
|
|
52
|
+
type: FIELD_TYPES.STRING,
|
|
53
|
+
required: true,
|
|
54
|
+
description: '模型实例ID'
|
|
55
|
+
},
|
|
56
|
+
createdAt: {
|
|
57
|
+
type: FIELD_TYPES.NUMBER,
|
|
58
|
+
required: true,
|
|
59
|
+
description: '创建时间戳'
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 获取字段默认值
|
|
65
|
+
* @param {object} schema 字段schema
|
|
66
|
+
* @returns {object} 默认值对象
|
|
67
|
+
*/
|
|
68
|
+
export const getFieldDefaults = (schema) => {
|
|
69
|
+
const defaults = {}
|
|
70
|
+
|
|
71
|
+
for (const [fieldName, fieldConfig] of Object.entries(schema)) {
|
|
72
|
+
if (fieldConfig.default !== undefined) {
|
|
73
|
+
defaults[fieldName] = fieldConfig.default
|
|
74
|
+
} else if (fieldConfig.required) {
|
|
75
|
+
// 必填字段但没有默认值的处理
|
|
76
|
+
switch (fieldConfig.type) {
|
|
77
|
+
case FIELD_TYPES.OBJECT:
|
|
78
|
+
defaults[fieldName] = {}
|
|
79
|
+
break
|
|
80
|
+
case FIELD_TYPES.ARRAY:
|
|
81
|
+
defaults[fieldName] = []
|
|
82
|
+
break
|
|
83
|
+
case FIELD_TYPES.STRING:
|
|
84
|
+
defaults[fieldName] = ''
|
|
85
|
+
break
|
|
86
|
+
case FIELD_TYPES.NUMBER:
|
|
87
|
+
defaults[fieldName] = 0
|
|
88
|
+
break
|
|
89
|
+
case FIELD_TYPES.BOOLEAN:
|
|
90
|
+
defaults[fieldName] = false
|
|
91
|
+
break
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return defaults
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* 验证字段值是否符合类型要求
|
|
101
|
+
* @param {*} value 要验证的值
|
|
102
|
+
* @param {string} expectedType 期望的类型
|
|
103
|
+
* @returns {boolean} 是否有效
|
|
104
|
+
*/
|
|
105
|
+
export const validateFieldType = (value, expectedType) => {
|
|
106
|
+
if (value === null || value === undefined) {
|
|
107
|
+
return true // 允许空值
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const actualType = Array.isArray(value) ? FIELD_TYPES.ARRAY : typeof value
|
|
111
|
+
|
|
112
|
+
// 宽松的类型检查
|
|
113
|
+
switch (expectedType) {
|
|
114
|
+
case FIELD_TYPES.OBJECT:
|
|
115
|
+
return actualType === FIELD_TYPES.OBJECT
|
|
116
|
+
case FIELD_TYPES.ARRAY:
|
|
117
|
+
return actualType === FIELD_TYPES.ARRAY
|
|
118
|
+
case FIELD_TYPES.STRING:
|
|
119
|
+
return actualType === FIELD_TYPES.STRING
|
|
120
|
+
case FIELD_TYPES.NUMBER:
|
|
121
|
+
return actualType === FIELD_TYPES.NUMBER
|
|
122
|
+
case FIELD_TYPES.BOOLEAN:
|
|
123
|
+
return actualType === FIELD_TYPES.BOOLEAN
|
|
124
|
+
default:
|
|
125
|
+
return true
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* 获取字段定义信息
|
|
131
|
+
* @param {string} fieldName 字段名
|
|
132
|
+
* @returns {object|null} 字段定义
|
|
133
|
+
*/
|
|
134
|
+
export const getFieldDefinition = (fieldName) => {
|
|
135
|
+
// 优先在 TreeTable 字段中查找
|
|
136
|
+
if (TREE_TABLE_FIELDS[fieldName]) {
|
|
137
|
+
return TREE_TABLE_FIELDS[fieldName]
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// 然后在共享字段中查找
|
|
141
|
+
if (SHARED_FIELDS[fieldName]) {
|
|
142
|
+
return SHARED_FIELDS[fieldName]
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// 最后在元数据字段中查找
|
|
146
|
+
if (META_FIELDS[fieldName]) {
|
|
147
|
+
return META_FIELDS[fieldName]
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return null
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* 获取所有字段定义
|
|
155
|
+
* @returns {object} 所有字段定义
|
|
156
|
+
*/
|
|
157
|
+
export const getAllFields = () => {
|
|
158
|
+
return {
|
|
159
|
+
...TREE_TABLE_FIELDS,
|
|
160
|
+
...SHARED_FIELDS,
|
|
161
|
+
...META_FIELDS
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* 获取模型支持的字段列表
|
|
167
|
+
* @returns {string[]} 字段名列表
|
|
168
|
+
*/
|
|
169
|
+
export const getSupportedFields = () => {
|
|
170
|
+
return Object.keys({
|
|
171
|
+
...TREE_TABLE_FIELDS,
|
|
172
|
+
...SHARED_FIELDS
|
|
173
|
+
})
|
|
174
|
+
}
|
package/scripts/rollup.config.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
import { nodeResolve } from '@rollup/plugin-node-resolve'
|
|
3
|
-
import { terser } from 'rollup-plugin-terser'
|
|
4
|
-
import strip from '@rollup/plugin-strip'
|
|
5
|
-
import vue from 'rollup-plugin-vue'
|
|
6
|
-
import postcss from 'rollup-plugin-postcss'
|
|
7
|
-
import postcssImport from 'postcss-import'
|
|
8
|
-
import { babel } from '@rollup/plugin-babel'
|
|
9
|
-
import alias from '@rollup/plugin-alias'
|
|
10
|
-
import { resolve } from 'path'
|
|
11
|
-
|
|
12
|
-
//TODO: bundle all packages in future
|
|
13
|
-
|
|
14
|
-
/** @type { import('rollup').RollupOptions } */
|
|
15
|
-
export default {
|
|
16
|
-
input: 'packages/index.js',
|
|
17
|
-
external: ['vue', '@idooel/shared', 'vue-upload-component', 'moment'],
|
|
18
|
-
plugins: [
|
|
19
|
-
nodeResolve(),
|
|
20
|
-
vue({
|
|
21
|
-
css: true,
|
|
22
|
-
compileTemplate: true
|
|
23
|
-
}),
|
|
24
|
-
alias({
|
|
25
|
-
entries: [
|
|
26
|
-
{ find: '@/utils', replacement: resolve(__dirname, '../packages/utils') }
|
|
27
|
-
]
|
|
28
|
-
}),
|
|
29
|
-
babel({
|
|
30
|
-
babelHelpers: 'bundled',
|
|
31
|
-
presets: ['@vue/babel-preset-jsx'],
|
|
32
|
-
extensions: ['.js', '.jsx', '.es', '.es6', '.mjs', '.vue'],
|
|
33
|
-
filter: id=>{
|
|
34
|
-
return /(\.js|\.jsx|\.es6|\.es|\.mjs)$/.test(id) && !/node_modules/.test(id)
|
|
35
|
-
}
|
|
36
|
-
}),
|
|
37
|
-
postcss({
|
|
38
|
-
extensions: ['.css', '.scss'],
|
|
39
|
-
extract: true,
|
|
40
|
-
plugins: [postcssImport()]
|
|
41
|
-
})
|
|
42
|
-
]
|
|
1
|
+
|
|
2
|
+
import { nodeResolve } from '@rollup/plugin-node-resolve'
|
|
3
|
+
import { terser } from 'rollup-plugin-terser'
|
|
4
|
+
import strip from '@rollup/plugin-strip'
|
|
5
|
+
import vue from 'rollup-plugin-vue'
|
|
6
|
+
import postcss from 'rollup-plugin-postcss'
|
|
7
|
+
import postcssImport from 'postcss-import'
|
|
8
|
+
import { babel } from '@rollup/plugin-babel'
|
|
9
|
+
import alias from '@rollup/plugin-alias'
|
|
10
|
+
import { resolve } from 'path'
|
|
11
|
+
|
|
12
|
+
//TODO: bundle all packages in future
|
|
13
|
+
|
|
14
|
+
/** @type { import('rollup').RollupOptions } */
|
|
15
|
+
export default {
|
|
16
|
+
input: 'packages/index.js',
|
|
17
|
+
external: ['vue', '@idooel/runtime-context', '@idooel/shared', '@idooel/expression', 'vue-upload-component', 'moment'],
|
|
18
|
+
plugins: [
|
|
19
|
+
nodeResolve(),
|
|
20
|
+
vue({
|
|
21
|
+
css: true,
|
|
22
|
+
compileTemplate: true
|
|
23
|
+
}),
|
|
24
|
+
alias({
|
|
25
|
+
entries: [
|
|
26
|
+
{ find: '@/utils', replacement: resolve(__dirname, '../packages/utils') }
|
|
27
|
+
]
|
|
28
|
+
}),
|
|
29
|
+
babel({
|
|
30
|
+
babelHelpers: 'bundled',
|
|
31
|
+
presets: ['@vue/babel-preset-jsx'],
|
|
32
|
+
extensions: ['.js', '.jsx', '.es', '.es6', '.mjs', '.vue'],
|
|
33
|
+
filter: id=>{
|
|
34
|
+
return /(\.js|\.jsx|\.es6|\.es|\.mjs)$/.test(id) && !/node_modules/.test(id)
|
|
35
|
+
}
|
|
36
|
+
}),
|
|
37
|
+
postcss({
|
|
38
|
+
extensions: ['.css', '.scss'],
|
|
39
|
+
extract: true,
|
|
40
|
+
plugins: [postcssImport()]
|
|
41
|
+
})
|
|
42
|
+
]
|
|
43
43
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import baseConfig from './rollup.config.js'
|
|
2
|
-
import { module } from '../package.json'
|
|
3
|
-
|
|
4
|
-
/** @type { import('rollup').RollupOptions } */
|
|
5
|
-
export default {
|
|
6
|
-
...baseConfig,
|
|
7
|
-
output: {
|
|
8
|
-
name: '__ele__esm__components__',
|
|
9
|
-
file: module,
|
|
10
|
-
format: 'es'
|
|
11
|
-
}
|
|
1
|
+
import baseConfig from './rollup.config.js'
|
|
2
|
+
import { module } from '../package.json'
|
|
3
|
+
|
|
4
|
+
/** @type { import('rollup').RollupOptions } */
|
|
5
|
+
export default {
|
|
6
|
+
...baseConfig,
|
|
7
|
+
output: {
|
|
8
|
+
name: '__ele__esm__components__',
|
|
9
|
+
file: module,
|
|
10
|
+
format: 'es'
|
|
11
|
+
}
|
|
12
12
|
}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import baseConfig from './rollup.config.js'
|
|
2
|
-
import { main } from '../package.json'
|
|
3
|
-
/** @type { import('rollup').RollupOptions } */
|
|
4
|
-
export default {
|
|
5
|
-
...baseConfig,
|
|
6
|
-
output: {
|
|
7
|
-
name: '__ele__umd__components__',
|
|
8
|
-
file: main,
|
|
9
|
-
format: 'umd',
|
|
10
|
-
globals: {
|
|
11
|
-
vue: 'Vue'
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import baseConfig from './rollup.config.js'
|
|
2
|
+
import { main } from '../package.json'
|
|
3
|
+
/** @type { import('rollup').RollupOptions } */
|
|
4
|
+
export default {
|
|
5
|
+
...baseConfig,
|
|
6
|
+
output: {
|
|
7
|
+
name: '__ele__umd__components__',
|
|
8
|
+
file: main,
|
|
9
|
+
format: 'umd',
|
|
10
|
+
globals: {
|
|
11
|
+
vue: 'Vue',
|
|
12
|
+
'@idooel/runtime-context': '@idooel/runtime-context',
|
|
13
|
+
'@idooel/shared': '@idooel/shared',
|
|
14
|
+
'@idooel/expression': '@idooel/expression'
|
|
15
|
+
},
|
|
16
|
+
exports: 'named'
|
|
17
|
+
}
|
|
15
18
|
}
|
package/vitest.config.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config'
|
|
2
|
+
import vue from '@vitejs/plugin-vue2'
|
|
3
|
+
import path from 'path'
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
plugins: [vue()],
|
|
7
|
+
resolve: {
|
|
8
|
+
alias: {
|
|
9
|
+
'@': path.resolve(__dirname, 'packages')
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
test: {
|
|
13
|
+
environment: 'jsdom',
|
|
14
|
+
globals: true,
|
|
15
|
+
setupFiles: ['__tests__/setup.js']
|
|
16
|
+
}
|
|
17
|
+
})
|