1
- import type { ComponentResolver , SideEffectsInfo } from '../../types'
2
- import { kebabCase } from '../utils'
1
+ import type { ComponentResolver } from '../../types'
3
2
4
3
export interface TDesignResolverOptions {
5
- /**
6
- * import style along with components
7
- * @default 'css'
8
- */
9
- importStyle ?: boolean | 'css' | 'less'
10
-
11
4
/**
12
5
* select the specified library
13
6
* @default 'vue'
@@ -33,69 +26,6 @@ export interface TDesignResolverOptions {
33
26
exclude ?: string | RegExp | ( string | RegExp ) [ ]
34
27
}
35
28
36
- function getSideEffects ( importName : string , options : TDesignResolverOptions ) : SideEffectsInfo | undefined {
37
- const { library = 'vue' , importStyle = 'css' } = options
38
- let fileName = kebabCase ( importName )
39
-
40
- if ( ! importStyle )
41
- return
42
-
43
- if ( [ 'config-provider' , 'icon' ] . includes ( fileName ) )
44
- return
45
-
46
- if ( fileName . includes ( '-' ) && fileName !== 'input-number' ) {
47
- const prefix = fileName . slice ( 0 , fileName . indexOf ( '-' ) )
48
- const container = [ 'anchor' , 'avatar' , 'breadcrumb' , 'checkbox' , 'dropdown' , 'form' , 'input' , 'list' , 'menu' , 'radio' , 'slider' , 'swiper' , 'color-picker' , 'text' , 'collapse' , 'timeline' ]
49
-
50
- if ( container . includes ( prefix ) )
51
- fileName = prefix
52
- }
53
-
54
- if ( [ 'row' , 'col' ] . includes ( fileName ) )
55
- fileName = 'grid'
56
-
57
- if ( fileName === 'addon' )
58
- fileName = 'input'
59
-
60
- if ( [ 'aside' , 'layout' , 'header' , 'footer' , 'content' ] . includes ( fileName ) )
61
- fileName = 'layout'
62
-
63
- if ( [ 'head-menu' , 'submenu' ] . includes ( fileName ) )
64
- fileName = 'menu'
65
-
66
- if ( [ 'option' , 'option-group' ] . includes ( fileName ) )
67
- fileName = 'select'
68
-
69
- if ( [ 'tab-nav' , 'tab-panel' ] . includes ( fileName ) )
70
- fileName = 'tabs'
71
-
72
- if ( fileName === 'step-item' )
73
- fileName = 'steps'
74
-
75
- if ( fileName === 'check-tag' )
76
- fileName = 'tag'
77
-
78
- if ( [ 'time-range-picker' , 'time-range-picker-panel' , 'time-picker-panel' ] . includes ( fileName ) )
79
- fileName = 'time-picker'
80
-
81
- if ( [ 'date-range-picker' , 'date-range-picker-panel' , 'date-picker-panel' ] . includes ( fileName ) )
82
- fileName = 'date-picker'
83
-
84
- if ( [ 'color-picker' , 'color-picker-panel' ] . includes ( fileName ) )
85
- fileName = 'color-picker'
86
-
87
- if ( [ 'enhanced-table' , 'base-table' ] . includes ( fileName ) )
88
- fileName = 'table'
89
-
90
- if ( [ 'pagination-mini' ] . includes ( fileName ) )
91
- fileName = 'pagination'
92
-
93
- if ( importStyle === 'less' )
94
- return `tdesign-${ library } /esm/${ fileName } /style`
95
-
96
- return `tdesign-${ library } /es/${ fileName } /style`
97
- }
98
-
99
29
export function TDesignResolver ( options : TDesignResolverOptions = { } ) : ComponentResolver {
100
30
return {
101
31
type : 'component' ,
@@ -119,7 +49,6 @@ export function TDesignResolver(options: TDesignResolverOptions = {}): Component
119
49
return {
120
50
name : importName ,
121
51
from : `tdesign-${ library } ${ importFrom } ` ,
122
- sideEffects : getSideEffects ( importName , options ) ,
123
52
}
124
53
}
125
54
} ,
0 commit comments