v-uni-app-ui 1.0.2 → 1.0.4
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 +147 -0
- package/components/config/css/basic.scss +19 -0
- package/components/config/interface/basic-type.js +16 -0
- 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 +136 -0
- package/components/config/interface/props/basic-props.ts +88 -0
- package/components/config/interface/props/components/button-props.ts +85 -0
- package/components/config/interface/props/components/input-props.ts +69 -0
- package/components/config/interface/props/props-tools.ts +64 -0
- package/components/config/style/basic.js +346 -0
- package/components/config/style/component-registry.js +142 -0
- package/components/config/style/components/button-style.js +160 -0
- package/components/config/style/components/input-style.js +98 -0
- package/components/config/style/components-style.js +622 -0
- package/components/config/style/property-mapper.js +377 -0
- package/components/config/style/pseudo-processor.js +213 -0
- package/components/config.js +3 -3
- package/components/icon/iconfont.css +87 -0
- package/components/icon/iconfont.js +1 -0
- package/components/icon/iconfont.json +135 -0
- package/components/icon/iconfont.ttf +0 -0
- package/components/icon/iconfont.woff +0 -0
- package/components/icon/iconfont.woff2 +0 -0
- package/components/model/native/v-button/v-button.vue +81 -273
- package/components/model/native/v-input/v-input.vue +132 -321
- package/components/utils/event-modifiers.ts +139 -0
- package/components/utils/validator.ts +451 -0
- package/index.js +372 -0
- package/package.json +12 -4
- package/components/model/native/v-text-button/v-text-button.vue +0 -139
|
@@ -0,0 +1,377 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
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
CHANGED
|
@@ -3,7 +3,7 @@ export const config = {
|
|
|
3
3
|
backgroundColor: {
|
|
4
4
|
default: '#307fff',
|
|
5
5
|
delete: '#ff5e5e',
|
|
6
|
-
|
|
6
|
+
success: '#31d283',
|
|
7
7
|
info: '#888888',
|
|
8
8
|
warn: '#fba000',
|
|
9
9
|
reversal: '#ffffff',
|
|
@@ -13,7 +13,7 @@ export const config = {
|
|
|
13
13
|
fontColor: {
|
|
14
14
|
default: '#307fff',
|
|
15
15
|
delete: '#ff5e5e',
|
|
16
|
-
|
|
16
|
+
success: '#31d283',
|
|
17
17
|
info: '#888888',
|
|
18
18
|
warn: '#fba000',
|
|
19
19
|
mianTitle: '#222222',
|
|
@@ -44,7 +44,7 @@ export const config = {
|
|
|
44
44
|
border: {
|
|
45
45
|
default: '#307fff',
|
|
46
46
|
delete: '#ff5e5e',
|
|
47
|
-
|
|
47
|
+
success: '#31d283',
|
|
48
48
|
info: '#888888',
|
|
49
49
|
warn: '#fba000',
|
|
50
50
|
color: '#e0e0e0'
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
@font-face {
|
|
2
|
+
font-family: "iconfont"; /* Project id 5074649 */
|
|
3
|
+
src: url('iconfont.woff2?t=1768618926322') format('woff2'),
|
|
4
|
+
url('iconfont.woff?t=1768618926322') format('woff'),
|
|
5
|
+
url('iconfont.ttf?t=1768618926322') format('truetype');
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.iconfont {
|
|
9
|
+
font-family: "iconfont" !important;
|
|
10
|
+
font-size: 16px;
|
|
11
|
+
font-style: normal;
|
|
12
|
+
-webkit-font-smoothing: antialiased;
|
|
13
|
+
-moz-osx-font-smoothing: grayscale;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.icon-chenggong:before {
|
|
17
|
+
content: "\e621";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.icon-xiazai:before {
|
|
21
|
+
content: "\e61e";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.icon-guanbi:before {
|
|
25
|
+
content: "\e60d";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.icon-youxiang:before {
|
|
29
|
+
content: "\e623";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.icon-youxiang1:before {
|
|
33
|
+
content: "\e64c";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.icon-shang:before {
|
|
37
|
+
content: "\e63c";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.icon-xia:before {
|
|
41
|
+
content: "\e63d";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.icon-zuo:before {
|
|
45
|
+
content: "\e63e";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.icon-shangchuan:before {
|
|
49
|
+
content: "\e71a";
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.icon-jianshao:before {
|
|
53
|
+
content: "\e638";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.icon-zengjia:before {
|
|
57
|
+
content: "\e640";
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.icon-shoujihao:before {
|
|
61
|
+
content: "\e76d";
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.icon-24gl-infoCircle:before {
|
|
65
|
+
content: "\e97d";
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.icon-24gl-pictureSplit:before {
|
|
69
|
+
content: "\e9ee";
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.icon-jinggao:before {
|
|
73
|
+
content: "\e84f";
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.icon-you:before {
|
|
77
|
+
content: "\e614";
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.icon-shipinjiazaishibai1-01:before {
|
|
81
|
+
content: "\e63f";
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.icon-url:before {
|
|
85
|
+
content: "\e646";
|
|
86
|
+
}
|
|
87
|
+
|