-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake-get-system-import.js
112 lines (97 loc) · 3.2 KB
/
make-get-system-import.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import relativise from './relativise.js'
import path from 'path'
let FILE_USE_IS_BEFORE = path.join('Views', 'hooks', 'useIsBefore.js')
let FILE_USE_IS_HOVERED = path.join('Views', 'hooks', 'useIsHovered.js')
let FILE_USE_IS_FOCUSED = path.join('Views', 'hooks', 'useIsFocused.js')
let FILE_USE_IS_MEDIA = path.join('Views', 'hooks', 'useIsMedia.js')
let FILE_USE_DATA = path.join('Views', 'Data.js')
let FILE_USE_DATA_FORMAT = path.join('Views', 'Data', 'format.js')
let FILE_USE_DATA_VALIDATE = path.join('Views', 'Data', 'validate.js')
let FILE_USE_DATA_AGGREGATE = path.join('Views', 'Data', 'aggregate.js')
let FILE_USE_DESIGN_TOKENS = path.join('Views', 'DesignTokens.js')
let FILE_USE_FLOW = path.join('Views', 'Flow.js')
let FILE_USE_PROFILE = path.join('Views', 'Profile.js')
let FILE_USE_STREAM = path.join('Views', 'Stream')
export default function makeGetSystemImport({ as, src }) {
return function getSystemImport(id, file) {
switch (id) {
case 'Column':
// Column is imported from react-virtualized
break
case 'ViewsUseIsMedia':
return `import useIsMedia from '${relativise(
file,
path.join(src, FILE_USE_IS_MEDIA),
src
)}'`
case 'ViewsUseIsBefore':
return `import useIsBefore from '${relativise(
file,
path.join(src, FILE_USE_IS_BEFORE),
src
)}'`
case 'ViewsUseIsHovered':
return `import useIsHovered from '${relativise(
file,
path.join(src, FILE_USE_IS_HOVERED),
src
)}'`
case 'ViewsUseIsFocused':
return `import useIsFocused from '${relativise(
file,
path.join(src, FILE_USE_IS_FOCUSED),
src
)}'`
case 'ViewsUseData':
return `import * as fromData from '${relativise(
file,
path.join(src, FILE_USE_DATA),
src
)}'`
case 'ViewsUseDataFormat':
return `import * as fromViewsFormat from '${relativise(
file,
path.join(src, FILE_USE_DATA_FORMAT),
src
)}'`
case 'ViewsUseDataValidate':
return `import * as fromViewsValidate from '${relativise(
file,
path.join(src, FILE_USE_DATA_VALIDATE),
src
)}'`
case 'ViewsUseDataAggregate':
return `import * as fromViewsAggregate from '${relativise(
file,
path.join(src, FILE_USE_DATA_AGGREGATE),
src
)}'`
case 'ViewsUseDesignTokens':
return `import * as fromDesignTokens from '${relativise(
file,
path.join(src, FILE_USE_DESIGN_TOKENS),
src
)}'`
case 'ViewsUseFlow':
return `import * as fromFlow from '${relativise(
file,
path.join(src, FILE_USE_FLOW),
src
)}'`
case 'ViewsUseProfile':
return `import * as fromProfile from '${relativise(
file,
path.join(src, FILE_USE_PROFILE),
src
)}'`
case 'ViewsUseStream':
return `import ViewsStream from '${relativise(
file,
path.join(src, FILE_USE_STREAM, `${as}.js`),
src
)}'`
default:
return false
}
}
}