v-uni-app-ui 1.0.4 → 1.0.6
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 +62 -82
- package/dist/v-uni-app-ui.css +1 -0
- package/dist/v-uni-app-ui.es.js +6569 -0
- package/dist/v-uni-app-ui.umd.js +7 -0
- package/package.json +17 -5
- package/components/config/css/basic.scss +0 -19
- package/components/config/interface/basic-type.js +0 -16
- package/components/config/interface/components-interface.ts +0 -0
- package/components/config/interface/monitor/components/input-monitor.js +0 -0
- package/components/config/interface/monitor/property-monitor.ts +0 -136
- package/components/config/interface/props/basic-props.ts +0 -88
- package/components/config/interface/props/components/button-props.ts +0 -85
- package/components/config/interface/props/components/input-props.ts +0 -69
- package/components/config/interface/props/props-tools.ts +0 -64
- package/components/config/style/basic.js +0 -346
- package/components/config/style/component-registry.js +0 -142
- package/components/config/style/components/button-style.js +0 -160
- package/components/config/style/components/input-style.js +0 -98
- package/components/config/style/components-style.js +0 -622
- package/components/config/style/property-mapper.js +0 -377
- package/components/config/style/pseudo-processor.js +0 -213
- package/components/config.js +0 -123
- package/components/icon/iconfont.css +0 -87
- package/components/icon/iconfont.js +0 -1
- package/components/icon/iconfont.json +0 -135
- package/components/icon/iconfont.ttf +0 -0
- package/components/icon/iconfont.woff +0 -0
- package/components/icon/iconfont.woff2 +0 -0
- package/components/layout/v-card/v-card.vue +0 -108
- package/components/layout/v-grid/v-grid.vue +0 -162
- package/components/layout/v-icon-grid/v-icon-grid.vue +0 -195
- package/components/layout/v-infinite-scroll/v-infinite-scroll.vue +0 -172
- package/components/layout/v-list/v-list.vue +0 -43
- package/components/layout/v-row/v-row.vue +0 -142
- package/components/layout/v-waterfall/v-waterfall.vue +0 -79
- package/components/model/compound/v-checkbox-group/v-checkbox-group.vue +0 -96
- package/components/model/compound/v-console/v-console.js +0 -20
- package/components/model/compound/v-console/v-console.vue +0 -299
- package/components/model/compound/v-date-time/v-date-time.vue +0 -261
- package/components/model/compound/v-dialog/v-dialog.vue +0 -178
- package/components/model/compound/v-drum-select-picker/v-drum-select-picker.vue +0 -83
- package/components/model/compound/v-form/v-form.vue +0 -226
- package/components/model/compound/v-form-item/v-form-item.vue +0 -255
- package/components/model/compound/v-image/v-image.vue +0 -357
- package/components/model/compound/v-input-desensitize/v-input-desensitize.vue +0 -101
- package/components/model/compound/v-page/v-page.vue +0 -11
- package/components/model/compound/v-pages/v-pages.vue +0 -141
- package/components/model/compound/v-picker-list/v-picker-list.vue +0 -109
- package/components/model/compound/v-popup/v-popup.vue +0 -151
- package/components/model/compound/v-radio-group/v-radio-group.vue +0 -86
- package/components/model/compound/v-select-picker/v-select-picker.vue +0 -202
- package/components/model/compound/v-series-picker-list/v-series-picker-list.vue +0 -221
- package/components/model/compound/v-series-select-picker/v-series-select-picker.vue +0 -203
- package/components/model/compound/v-switch/v-switch.vue +0 -136
- package/components/model/compound/v-tabs-page/v-tabs-page.vue +0 -138
- package/components/model/native/v-badge/v-badge.vue +0 -143
- package/components/model/native/v-button/v-button.vue +0 -81
- package/components/model/native/v-carousel/v-carousel.vue +0 -138
- package/components/model/native/v-checkbox/v-checkbox.vue +0 -215
- package/components/model/native/v-collapse/v-collapse.vue +0 -190
- package/components/model/native/v-header-navigation-bar/v-header-navigation-bar.vue +0 -92
- package/components/model/native/v-input/v-input.vue +0 -163
- package/components/model/native/v-input-code/v-input-code.vue +0 -146
- package/components/model/native/v-loading/v-loading.vue +0 -206
- package/components/model/native/v-menu/v-menu.vue +0 -222
- package/components/model/native/v-menu-slide/v-menu-slide.vue +0 -364
- package/components/model/native/v-min-loading/v-min-loading.vue +0 -80
- package/components/model/native/v-null/v-null.vue +0 -97
- package/components/model/native/v-overlay/v-overlay.vue +0 -96
- package/components/model/native/v-pull-up-refresh/v-pull-up-refresh.vue +0 -157
- package/components/model/native/v-radio/v-radio.vue +0 -138
- package/components/model/native/v-scroll-list/v-scroll-list.vue +0 -169
- package/components/model/native/v-steps/v-steps.vue +0 -253
- package/components/model/native/v-table/v-table.vue +0 -203
- package/components/model/native/v-tabs/v-tabs.vue +0 -235
- package/components/model/native/v-tag/v-tag.vue +0 -206
- package/components/model/native/v-text/v-text.vue +0 -187
- package/components/model/native/v-textarea/v-textarea.vue +0 -178
- package/components/model/native/v-title/v-title.vue +0 -91
- package/components/model/native/v-toast/info.png +0 -0
- package/components/model/native/v-toast/success.png +0 -0
- package/components/model/native/v-toast/v-toast.vue +0 -198
- package/components/model/native/v-toast/warn.png +0 -0
- package/components/model/native/v-upload-file-button/v-upload-file-button.vue +0 -296
- package/components/model/native/v-video/v-video.vue +0 -175
- package/components/model/native/v-window/v-window.vue +0 -158
- package/components/utils/event-modifiers.ts +0 -139
- package/components/utils/validator.ts +0 -451
- package/index.js +0 -372
|
@@ -1,377 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
styleConfig
|
|
3
|
-
} from '@/components/config/style/basic.js'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 属性映射规则配置
|
|
7
|
-
* 定义属性名如何映射到样式
|
|
8
|
-
*/
|
|
9
|
-
export const PropertyMappingRules = {
|
|
10
|
-
// 通用属性映射规则
|
|
11
|
-
common: {
|
|
12
|
-
// 尺寸属性 - 映射到尺寸相关的样式
|
|
13
|
-
size: {
|
|
14
|
-
target: 'size',
|
|
15
|
-
transform: (value, componentConfig, props) => {
|
|
16
|
-
return componentConfig.size && componentConfig.size[value] ?
|
|
17
|
-
componentConfig.size[value] :
|
|
18
|
-
null
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
// 类型属性 - 映射到类型相关的样式
|
|
23
|
-
type: {
|
|
24
|
-
target: 'type',
|
|
25
|
-
transform: (value, componentConfig, props) => {
|
|
26
|
-
const typeKey = otherTypeClassName(props, value)
|
|
27
|
-
return componentConfig.type && componentConfig.type[typeKey] ?
|
|
28
|
-
componentConfig.type[typeKey] :
|
|
29
|
-
null
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
// 形状/模型属性 - 映射到形状相关的样式
|
|
34
|
-
shape: {
|
|
35
|
-
target: 'shape',
|
|
36
|
-
transform: (value, componentConfig) => {
|
|
37
|
-
return componentConfig.shape && componentConfig.shape[value] ?
|
|
38
|
-
componentConfig.shape[value] :
|
|
39
|
-
null
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
// 状态属性 - 映射到状态相关的样式
|
|
44
|
-
disabled: {
|
|
45
|
-
target: 'status',
|
|
46
|
-
transform: (value, componentConfig) => {
|
|
47
|
-
if (!value) return null
|
|
48
|
-
return componentConfig.status && componentConfig.status.disabled ?
|
|
49
|
-
componentConfig.status.disabled : {
|
|
50
|
-
opacity: styleConfig.basic.opacity.disabled,
|
|
51
|
-
cursor: 'not-allowed'
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
loading: {
|
|
57
|
-
target: 'status',
|
|
58
|
-
transform: (value, componentConfig) => {
|
|
59
|
-
if (!value) return null
|
|
60
|
-
return componentConfig.status && componentConfig.status.loading ?
|
|
61
|
-
componentConfig.status.loading : {
|
|
62
|
-
opacity: styleConfig.basic.opacity.disabled,
|
|
63
|
-
cursor: 'progress'
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
// 变体属性
|
|
69
|
-
variant: {
|
|
70
|
-
target: 'variant',
|
|
71
|
-
transform: (value, componentConfig) => {
|
|
72
|
-
return componentConfig.variant && componentConfig.variant[value] ?
|
|
73
|
-
componentConfig.variant[value] :
|
|
74
|
-
null
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
// 布尔属性
|
|
79
|
-
block: {
|
|
80
|
-
target: 'overrides',
|
|
81
|
-
transform: (value, componentConfig) => {
|
|
82
|
-
if (!value) return null
|
|
83
|
-
return componentConfig.overrides && componentConfig.overrides.block ?
|
|
84
|
-
componentConfig.overrides.block : {
|
|
85
|
-
width: '100%',
|
|
86
|
-
display: 'flex'
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
iconOnly: {
|
|
92
|
-
target: 'overrides',
|
|
93
|
-
transform: (value, componentConfig) => {
|
|
94
|
-
if (!value) return null
|
|
95
|
-
return componentConfig.overrides && componentConfig.overrides.iconOnly ?
|
|
96
|
-
componentConfig.overrides.iconOnly : {
|
|
97
|
-
padding: '0',
|
|
98
|
-
display: 'flex',
|
|
99
|
-
alignItems: 'center',
|
|
100
|
-
justifyContent: 'center'
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
plain: {
|
|
106
|
-
target: 'type',
|
|
107
|
-
transform: () => null
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
text: {
|
|
111
|
-
target: 'type',
|
|
112
|
-
transform: () => null
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
|
|
116
|
-
// 组件特定的属性映射规则(可以覆盖通用规则)
|
|
117
|
-
componentSpecific: {
|
|
118
|
-
button: {
|
|
119
|
-
// 按钮特有的属性映射
|
|
120
|
-
stabilizationTime: {
|
|
121
|
-
target: 'custom',
|
|
122
|
-
transform: (value) => value > 0 ? {
|
|
123
|
-
transition: 'all 0.3s ease'
|
|
124
|
-
} : null
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function otherTypeClassName(props, value) {
|
|
131
|
-
// 处理镂空类型
|
|
132
|
-
if (props.plain) {
|
|
133
|
-
return `${value}-plain`
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// 处理文本类型
|
|
137
|
-
if (props.text) {
|
|
138
|
-
return `${value}-text`
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return value
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* 属性映射器
|
|
146
|
-
*/
|
|
147
|
-
export class PropertyMapper {
|
|
148
|
-
constructor(componentName, componentConfig, customMaps = {}) {
|
|
149
|
-
this.componentName = componentName
|
|
150
|
-
this.componentConfig = componentConfig
|
|
151
|
-
this.customMaps = customMaps
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* 映射单个属性
|
|
156
|
-
*/
|
|
157
|
-
mapProperty(propName, propValue, allProps) {
|
|
158
|
-
// 获取映射规则
|
|
159
|
-
let rule = this.getRule(propName)
|
|
160
|
-
|
|
161
|
-
if (!rule) {
|
|
162
|
-
// 如果没有找到规则,使用通用映射
|
|
163
|
-
return this.mapGenericProperty(propName, propValue)
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// 应用转换规则
|
|
167
|
-
const result = rule.transform(propValue, this.componentConfig, allProps)
|
|
168
|
-
|
|
169
|
-
return result
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* 获取属性映射规则
|
|
174
|
-
*/
|
|
175
|
-
getRule(propName) {
|
|
176
|
-
// 1. 首先检查组件特定规则
|
|
177
|
-
const componentRules = PropertyMappingRules.componentSpecific[this.componentName]
|
|
178
|
-
if (componentRules && componentRules[propName]) {
|
|
179
|
-
return componentRules[propName]
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// 2. 检查通用规则
|
|
183
|
-
if (PropertyMappingRules.common[propName]) {
|
|
184
|
-
return PropertyMappingRules.common[propName]
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// 3. 检查自定义映射
|
|
188
|
-
for (const mapType of Object.keys(this.customMaps)) {
|
|
189
|
-
if (this.customMaps[mapType] && this.customMaps[mapType][propName]) {
|
|
190
|
-
return {
|
|
191
|
-
target: mapType,
|
|
192
|
-
transform: (value) => this.customMaps[mapType][propName][value] || null
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return null
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* 映射通用属性(用于没有明确规则的属性)
|
|
202
|
-
*/
|
|
203
|
-
mapGenericProperty(propName, propValue) {
|
|
204
|
-
// 如果属性值本身就是样式对象
|
|
205
|
-
if (propValue && typeof propValue === 'object' && !Array.isArray(propValue)) {
|
|
206
|
-
return propValue
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// 根据属性名猜测映射
|
|
210
|
-
const lowerName = propName.toLowerCase()
|
|
211
|
-
|
|
212
|
-
// 检查是否是颜色属性
|
|
213
|
-
if (lowerName.includes('color') || lowerName.includes('background')) {
|
|
214
|
-
if (typeof propValue === 'string' && propValue.startsWith('#')) {
|
|
215
|
-
return {
|
|
216
|
-
[propName]: propValue
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
// 检查是否是尺寸属性
|
|
222
|
-
if (lowerName.includes('width') || lowerName.includes('height') ||
|
|
223
|
-
lowerName.includes('size') || lowerName.includes('padding') ||
|
|
224
|
-
lowerName.includes('margin')) {
|
|
225
|
-
if (typeof propValue === 'string' || typeof propValue === 'number') {
|
|
226
|
-
return {
|
|
227
|
-
[propName]: propValue
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// 检查是否是边框属性
|
|
233
|
-
if (lowerName.includes('border') || lowerName.includes('radius')) {
|
|
234
|
-
if (typeof propValue === 'string' || typeof propValue === 'number') {
|
|
235
|
-
return {
|
|
236
|
-
[propName]: propValue
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
return null
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* 映射所有属性
|
|
246
|
-
*/
|
|
247
|
-
mapAllProperties(props) {
|
|
248
|
-
const style = {}
|
|
249
|
-
|
|
250
|
-
// 1. 首先应用组件的默认样式(不包括 _pseudo)
|
|
251
|
-
this.applyDefaultStyle(style)
|
|
252
|
-
|
|
253
|
-
// 2. 遍历所有属性
|
|
254
|
-
for (const [propName, propValue] of Object.entries(props)) {
|
|
255
|
-
// 跳过不需要处理的属性
|
|
256
|
-
if (this.shouldSkipProperty(propName)) {
|
|
257
|
-
continue
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
// 映射属性
|
|
261
|
-
const mappedStyle = this.mapProperty(propName, propValue, props)
|
|
262
|
-
// 合并到结果
|
|
263
|
-
if (mappedStyle && typeof mappedStyle === 'object') {
|
|
264
|
-
Object.assign(style, mappedStyle)
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
// 3. 处理自定义映射
|
|
269
|
-
this.applyCustomMaps(style, props)
|
|
270
|
-
|
|
271
|
-
// 4. 最后应用自定义样式(来自props.style)
|
|
272
|
-
this.applyInlineStyle(style, props)
|
|
273
|
-
return style
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* 应用组件的默认样式
|
|
278
|
-
*/
|
|
279
|
-
applyDefaultStyle(style) {
|
|
280
|
-
// 如果组件配置中有default对象,将其样式合并(排除 _pseudo)
|
|
281
|
-
if (this.componentConfig && this.componentConfig.default) {
|
|
282
|
-
const {
|
|
283
|
-
_pseudo,
|
|
284
|
-
...defaultStyles
|
|
285
|
-
} = this.componentConfig.default
|
|
286
|
-
Object.assign(style, defaultStyles)
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* 获取组件的伪类样式配置
|
|
292
|
-
*/
|
|
293
|
-
getPseudoStyles() {
|
|
294
|
-
if (this.componentConfig && this.componentConfig.default && this.componentConfig.default._pseudo) {
|
|
295
|
-
return this.componentConfig.default._pseudo
|
|
296
|
-
}
|
|
297
|
-
return {}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* 应用内联样式
|
|
302
|
-
*/
|
|
303
|
-
applyInlineStyle(style, props) {
|
|
304
|
-
if (props.style && typeof props.style === 'object') {
|
|
305
|
-
Object.assign(style, props.style)
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* 检查是否应该跳过该属性
|
|
311
|
-
*/
|
|
312
|
-
shouldSkipProperty(propName) {
|
|
313
|
-
// 跳过 Vue 内置属性
|
|
314
|
-
const skipProps = ['key', 'ref', 'class', 'style', 'id', 'slot', 'boxStyle', 'className']
|
|
315
|
-
if (skipProps.includes(propName)) {
|
|
316
|
-
return true
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
// 跳过事件处理器
|
|
320
|
-
if (propName.startsWith('on') || propName.startsWith('@')) {
|
|
321
|
-
return true
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
return false
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* 应用自定义映射
|
|
329
|
-
*/
|
|
330
|
-
applyCustomMaps(style, props) {
|
|
331
|
-
// 处理自定义尺寸映射
|
|
332
|
-
if (this.customMaps.size && props.size && this.customMaps.size[props.size]) {
|
|
333
|
-
Object.assign(style, this.customMaps.size[props.size])
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
// 处理自定义类型映射
|
|
337
|
-
if (this.customMaps.type && props.type) {
|
|
338
|
-
const typeKey = props.plain ? `${props.type}-plain` : props.type
|
|
339
|
-
if (this.customMaps.type[typeKey]) {
|
|
340
|
-
Object.assign(style, this.customMaps.type[typeKey])
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
// 处理其他自定义映射
|
|
345
|
-
for (const [mapType, mapConfig] of Object.entries(this.customMaps)) {
|
|
346
|
-
if (mapType === 'size' || mapType === 'type') {
|
|
347
|
-
continue
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
if (typeof mapConfig === 'object') {
|
|
351
|
-
for (const [key, value] of Object.entries(mapConfig)) {
|
|
352
|
-
if (props[key] !== undefined && value[props[key]]) {
|
|
353
|
-
Object.assign(style, value[props[key]])
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* 注册新的属性映射规则
|
|
363
|
-
*/
|
|
364
|
-
export function registerPropertyRule(componentName, propName, rule) {
|
|
365
|
-
if (!PropertyMappingRules.componentSpecific[componentName]) {
|
|
366
|
-
PropertyMappingRules.componentSpecific[componentName] = {}
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
PropertyMappingRules.componentSpecific[componentName][propName] = rule
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* 注册通用属性映射规则
|
|
374
|
-
*/
|
|
375
|
-
export function registerCommonPropertyRule(propName, rule) {
|
|
376
|
-
PropertyMappingRules.common[propName] = rule
|
|
377
|
-
}
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
export class PseudoProcessor {
|
|
2
|
-
constructor(config = {}) {
|
|
3
|
-
// 默认配置
|
|
4
|
-
this.config = {
|
|
5
|
-
// 变体优先级顺序
|
|
6
|
-
variantPriority: ['type', 'mode', 'size', 'shape', 'status'],
|
|
7
|
-
|
|
8
|
-
// 状态属性映射
|
|
9
|
-
stateMapping: {
|
|
10
|
-
plain: {
|
|
11
|
-
mode: 'outline'
|
|
12
|
-
},
|
|
13
|
-
text: {
|
|
14
|
-
mode: 'text'
|
|
15
|
-
},
|
|
16
|
-
disabled: {
|
|
17
|
-
status: 'disabled'
|
|
18
|
-
},
|
|
19
|
-
loading: {
|
|
20
|
-
status: 'loading'
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
// 查找策略配置
|
|
25
|
-
lookupStrategies: [
|
|
26
|
-
// 策略1: 完全匹配的组合键 (如: 'default-outline-small')
|
|
27
|
-
(obj, props, variantKey) => obj.combined && obj.combined[variantKey],
|
|
28
|
-
|
|
29
|
-
// 策略2: 基础类型匹配 (如: 'default')
|
|
30
|
-
(obj, props) => obj.type && obj.type[props.type || 'default'],
|
|
31
|
-
|
|
32
|
-
// 策略3: 状态属性匹配 (plain, text, disabled, loading)
|
|
33
|
-
(obj, props) => {
|
|
34
|
-
if (props.plain && obj.plain !== undefined) return obj.plain;
|
|
35
|
-
if (props.text && obj.text !== undefined) return obj.text;
|
|
36
|
-
if (props.disabled && obj.disabled !== undefined) return obj.disabled;
|
|
37
|
-
if (props.loading && obj.loading !== undefined) return obj.loading;
|
|
38
|
-
return null;
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
// 策略4: 变体属性匹配 (variant, size, shape)
|
|
42
|
-
(obj, props) => {
|
|
43
|
-
const variantProps = ['variant', 'size', 'shape', 'mode', 'status'];
|
|
44
|
-
for (const prop of variantProps) {
|
|
45
|
-
if (props[prop] && obj[prop] && obj[prop][props[prop]]) {
|
|
46
|
-
return obj[prop][props[prop]];
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return null;
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
// 策略5: 默认值
|
|
53
|
-
(obj) => obj.default
|
|
54
|
-
]
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
// 合并自定义配置
|
|
58
|
-
if (config.variantPriority) this.config.variantPriority = config.variantPriority;
|
|
59
|
-
if (config.stateMapping) this.config.stateMapping = config.stateMapping;
|
|
60
|
-
if (config.lookupStrategies) this.config.lookupStrategies = config.lookupStrategies;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* 构建变体键名
|
|
65
|
-
*/
|
|
66
|
-
buildVariantKey(props) {
|
|
67
|
-
const parts = [props.type || 'default'];
|
|
68
|
-
|
|
69
|
-
// 合并状态映射
|
|
70
|
-
const allVariants = {
|
|
71
|
-
...props
|
|
72
|
-
};
|
|
73
|
-
for (const [state, mapping] of Object.entries(this.config.stateMapping)) {
|
|
74
|
-
if (props[state]) {
|
|
75
|
-
Object.assign(allVariants, mapping);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// 按优先级添加变体
|
|
80
|
-
for (const variant of this.config.variantPriority) {
|
|
81
|
-
if (allVariants[variant] && allVariants[variant] !== 'default') {
|
|
82
|
-
parts.push(allVariants[variant]);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return parts.join('-');
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* 查找匹配的值
|
|
91
|
-
*/
|
|
92
|
-
findValue(value, props) {
|
|
93
|
-
// 如果是普通值,直接返回
|
|
94
|
-
if (typeof value !== 'object' || Array.isArray(value)) {
|
|
95
|
-
return value;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// 构建变体键
|
|
99
|
-
const variantKey = this.buildVariantKey(props);
|
|
100
|
-
|
|
101
|
-
// 按策略优先级查找值
|
|
102
|
-
for (const strategy of this.config.lookupStrategies) {
|
|
103
|
-
const result = strategy(value, props, variantKey);
|
|
104
|
-
if (result !== undefined && result !== null) {
|
|
105
|
-
return result;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return null;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* 合并伪类样式
|
|
114
|
-
*/
|
|
115
|
-
mergeWithPseudo(baseStyle, pseudoStyles, pseudoKey, isActive, componentProps = {}) {
|
|
116
|
-
if (!isActive || !pseudoStyles?.[pseudoKey]) {
|
|
117
|
-
return {
|
|
118
|
-
...baseStyle
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const mergedStyle = {
|
|
123
|
-
...baseStyle
|
|
124
|
-
};
|
|
125
|
-
const pseudoStyle = pseudoStyles[pseudoKey];
|
|
126
|
-
|
|
127
|
-
for (const [property, value] of Object.entries(pseudoStyle)) {
|
|
128
|
-
if (value == null) continue;
|
|
129
|
-
|
|
130
|
-
const resolvedValue = this.findValue(value, componentProps);
|
|
131
|
-
if (resolvedValue != null) {
|
|
132
|
-
mergedStyle[property] = resolvedValue;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return mergedStyle;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* 批量合并伪类
|
|
141
|
-
*/
|
|
142
|
-
mergeMultiplePseudo(baseStyle, pseudoStyles, activePseudoStates, componentProps = {}) {
|
|
143
|
-
let result = {
|
|
144
|
-
...baseStyle
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
// 按定义的顺序合并伪类(优先级)
|
|
148
|
-
const pseudoOrder = ['--disabled', '--focus', '--hover', '--active'];
|
|
149
|
-
|
|
150
|
-
for (const pseudoKey of pseudoOrder) {
|
|
151
|
-
if (activePseudoStates[pseudoKey]) {
|
|
152
|
-
result = this.mergeWithPseudo(
|
|
153
|
-
result,
|
|
154
|
-
pseudoStyles,
|
|
155
|
-
pseudoKey,
|
|
156
|
-
true,
|
|
157
|
-
componentProps
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return result;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* 简化版合并方法 - 兼容原方法签名
|
|
167
|
-
*/
|
|
168
|
-
merge(baseStyle, pseudoStyles, pseudoKey, isActive, componentProps = {}) {
|
|
169
|
-
return this.mergeWithPseudo(
|
|
170
|
-
baseStyle,
|
|
171
|
-
pseudoStyles,
|
|
172
|
-
pseudoKey,
|
|
173
|
-
isActive,
|
|
174
|
-
componentProps
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* 添加自定义查找策略
|
|
180
|
-
*/
|
|
181
|
-
addStrategy(strategyFn, priority = 0) {
|
|
182
|
-
this.config.lookupStrategies.push({
|
|
183
|
-
fn: strategyFn,
|
|
184
|
-
priority
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
// 按优先级排序
|
|
188
|
-
this.config.lookupStrategies.sort((a, b) => b.priority - a.priority);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* 自定义状态映射
|
|
193
|
-
*/
|
|
194
|
-
addStateMapping(state, mapping) {
|
|
195
|
-
this.config.stateMapping[state] = mapping;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// 创建默认处理器实例
|
|
200
|
-
export const defaultPseudoProcessor = new PseudoProcessor();
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* 创建快捷函数
|
|
204
|
-
*/
|
|
205
|
-
export function mergeWithPseudo(baseStyle, pseudoStyles, pseudoKey, isActive, componentProps = {}) {
|
|
206
|
-
return defaultPseudoProcessor.mergeWithPseudo(
|
|
207
|
-
baseStyle,
|
|
208
|
-
pseudoStyles,
|
|
209
|
-
pseudoKey,
|
|
210
|
-
isActive,
|
|
211
|
-
componentProps
|
|
212
|
-
);
|
|
213
|
-
}
|
package/components/config.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
export const config = {
|
|
2
|
-
//背景颜色
|
|
3
|
-
backgroundColor: {
|
|
4
|
-
default: '#307fff',
|
|
5
|
-
delete: '#ff5e5e',
|
|
6
|
-
success: '#31d283',
|
|
7
|
-
info: '#888888',
|
|
8
|
-
warn: '#fba000',
|
|
9
|
-
reversal: '#ffffff',
|
|
10
|
-
disabled: '#f5f5f5'
|
|
11
|
-
},
|
|
12
|
-
//字体颜色
|
|
13
|
-
fontColor: {
|
|
14
|
-
default: '#307fff',
|
|
15
|
-
delete: '#ff5e5e',
|
|
16
|
-
success: '#31d283',
|
|
17
|
-
info: '#888888',
|
|
18
|
-
warn: '#fba000',
|
|
19
|
-
mianTitle: '#222222',
|
|
20
|
-
subTitle: '#666666',
|
|
21
|
-
mainText: '#333333',
|
|
22
|
-
text: '#969696',
|
|
23
|
-
hintText: '#cccccc',
|
|
24
|
-
reversal: '#ffffff'
|
|
25
|
-
},
|
|
26
|
-
//字体大小
|
|
27
|
-
fontSize: {
|
|
28
|
-
largeTitle: '42.5rpx',
|
|
29
|
-
mediumTitle: '34.5rpx',
|
|
30
|
-
smallTitle: '31.5rpx',
|
|
31
|
-
largeText: '29.5rpx',
|
|
32
|
-
mediumText: '25.5rpx',
|
|
33
|
-
smallText: '22.5rpx',
|
|
34
|
-
messageText: '20.5rpx',
|
|
35
|
-
hintText: '18.5rpx'
|
|
36
|
-
},
|
|
37
|
-
//字体其他
|
|
38
|
-
fontOther: {
|
|
39
|
-
fontFamily: "'Noto Sans CJK'"
|
|
40
|
-
},
|
|
41
|
-
//文字间距
|
|
42
|
-
letterSpacing: {},
|
|
43
|
-
//边框
|
|
44
|
-
border: {
|
|
45
|
-
default: '#307fff',
|
|
46
|
-
delete: '#ff5e5e',
|
|
47
|
-
success: '#31d283',
|
|
48
|
-
info: '#888888',
|
|
49
|
-
warn: '#fba000',
|
|
50
|
-
color: '#e0e0e0'
|
|
51
|
-
},
|
|
52
|
-
borderRadius: {
|
|
53
|
-
semicircle: '8rpx',
|
|
54
|
-
square: '0',
|
|
55
|
-
circle: '35rpx'
|
|
56
|
-
},
|
|
57
|
-
//透明度
|
|
58
|
-
opacity: {
|
|
59
|
-
//悬浮
|
|
60
|
-
hover: 0.9,
|
|
61
|
-
//点击
|
|
62
|
-
click: 0.8,
|
|
63
|
-
//禁用
|
|
64
|
-
disabled: 0.7,
|
|
65
|
-
//消息提示
|
|
66
|
-
toast: 0.7,
|
|
67
|
-
//遮罩层
|
|
68
|
-
mask: 0.4,
|
|
69
|
-
//边框
|
|
70
|
-
border: 0.3
|
|
71
|
-
},
|
|
72
|
-
//暗黑模式
|
|
73
|
-
darkMode: {
|
|
74
|
-
backgroundColor: '#333333',
|
|
75
|
-
fontColor: '#ffffff',
|
|
76
|
-
border: '#e0e0e0'
|
|
77
|
-
},
|
|
78
|
-
//图片
|
|
79
|
-
VImage: {
|
|
80
|
-
prefix: '/21cqttttttttttttttttttttttttttt/ldxyb/static/images/'
|
|
81
|
-
},
|
|
82
|
-
//文本框
|
|
83
|
-
VInput: {
|
|
84
|
-
boxShadow: '0 0 0 4rpx rgba(24, 144, 255, 0.2)'
|
|
85
|
-
},
|
|
86
|
-
//表单
|
|
87
|
-
VTable: {
|
|
88
|
-
backgroundColor: '#f5f5f5'
|
|
89
|
-
},
|
|
90
|
-
//上传图片按钮
|
|
91
|
-
VUploadFileButton: {
|
|
92
|
-
backgroundColor: '#f5f5f5'
|
|
93
|
-
},
|
|
94
|
-
//菜单
|
|
95
|
-
VMenu: {
|
|
96
|
-
backgroundColor: '#f5f5f5',
|
|
97
|
-
highlightBackgroundColor: '#e0e0e0'
|
|
98
|
-
},
|
|
99
|
-
//步骤条
|
|
100
|
-
VSteps: {
|
|
101
|
-
lineBackgroundColor: '#e0e0e0'
|
|
102
|
-
},
|
|
103
|
-
//下拉框
|
|
104
|
-
VSelectPicker: {
|
|
105
|
-
backgroundColor: '#f5f5f5'
|
|
106
|
-
},
|
|
107
|
-
//时间选择器
|
|
108
|
-
VDateTime: {
|
|
109
|
-
backgroundColor: '#f5f5f5'
|
|
110
|
-
},
|
|
111
|
-
//表单行
|
|
112
|
-
VFormItem: {
|
|
113
|
-
borderColor: '#e0e0e0'
|
|
114
|
-
},
|
|
115
|
-
//开关
|
|
116
|
-
VSwitch: {
|
|
117
|
-
backgroundColor: '#f5f5f5'
|
|
118
|
-
},
|
|
119
|
-
//宫格布局
|
|
120
|
-
VGrid:{
|
|
121
|
-
backgroundColor: '#f5f5f5'
|
|
122
|
-
}
|
|
123
|
-
};
|