1
1
import type { ComponentInfo , ComponentResolver , SideEffectsInfo } from '../../types'
2
- import { camelCase } from '../utils'
3
2
4
3
const matchComponents = [
5
4
{
@@ -100,6 +99,10 @@ const layerRE = /^(layer|LayLayer)$/
100
99
const iconsRE = / ^ ( [ A - Z ] [ \w ] + I c o n | L a y I c o n ) $ /
101
100
let libName = '@layui/layui-vue'
102
101
102
+ function lowerCamelCase ( str : string ) {
103
+ return str . charAt ( 0 ) . toLowerCase ( ) + str . slice ( 1 )
104
+ }
105
+
103
106
function getSideEffects ( importName : string , options : LayuiVueResolverOptions ) : SideEffectsInfo | undefined {
104
107
const { importStyle = 'css' } = options
105
108
if ( ! importStyle )
@@ -108,7 +111,7 @@ function getSideEffects(importName: string, options: LayuiVueResolverOptions): S
108
111
if ( libName !== '@layui/layui-vue' )
109
112
return `${ libName } /lib/index.css`
110
113
111
- let styleDir : string | undefined = camelCase ( importName . slice ( 3 ) ) // LayBackTop -> backTop
114
+ let styleDir : string | undefined = lowerCamelCase ( importName . slice ( 3 ) ) // LayBackTop -> backTop
112
115
for ( const item of matchComponents ) {
113
116
if ( item . pattern . test ( importName ) ) {
114
117
styleDir = item . styleDir
@@ -136,7 +139,7 @@ function resolveComponent(importName: string, options: LayuiVueResolverOptions):
136
139
name = importName
137
140
libName = '@layui/layer-vue'
138
141
}
139
- else if ( importName . match ( layuiRE ) ) {
142
+ else if ( importName . match ( layuiRE ) && ! importName . match ( iconsRE ) ) {
140
143
name = importName
141
144
libName = '@layui/layui-vue'
142
145
}
0 commit comments