Skip to content

Commit 60f2d21

Browse files
authored
feat: implements element-ui open-delay and show-after rename to show-after and auto-close (#89)
in the el-tooltip
1 parent c66b62e commit 60f2d21

File tree

5 files changed

+78
-1
lines changed

5 files changed

+78
-1
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { runTest } from '../../src/testUtils'
2+
3+
runTest(
4+
'tooltip-rename-attribute',
5+
'tooltip-rename-attribute',
6+
'tooltip-rename-attribute',
7+
'vue',
8+
'vue'
9+
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<template>
2+
<el-tooltip
3+
effect='dark'
4+
content='Bottom Right'
5+
placement='bottom-end'
6+
open-delay='1000'
7+
hide-after='3000'>
8+
<el-button>Button</el-button>
9+
</el-tooltip>
10+
11+
<div
12+
open-delay='1000'
13+
hide-after='3000'>
14+
</div>
15+
</template>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<template>
2+
<el-tooltip
3+
effect='dark'
4+
content='Bottom Right'
5+
placement='bottom-end'
6+
show-after='1000'
7+
auto-close='3000'>
8+
<el-button>Button</el-button>
9+
</el-tooltip>
10+
11+
<div
12+
open-delay='1000'
13+
hide-after='3000'>
14+
</div>
15+
</template>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { Node, VIdentifier } from 'vue-eslint-parser/ast/nodes'
2+
import * as OperationUtil from '../../src/operationUtils'
3+
import type { Operation } from '../../src/operationUtils'
4+
import {
5+
default as wrap,
6+
createTransformAST
7+
} from '../../src/wrapVueTransformation'
8+
9+
export const transformAST = createTransformAST(
10+
nodeFilter,
11+
fix,
12+
'tooltip-rename-attribute'
13+
)
14+
export default wrap(transformAST)
15+
16+
const renameMap: Map<string, string> = new Map([
17+
['open-delay', 'show-after'],
18+
['hide-after', 'auto-close']
19+
])
20+
21+
function nodeFilter(node: Node): boolean {
22+
return (
23+
node.type === 'VIdentifier' &&
24+
renameMap.has(node.name) &&
25+
node.parent?.parent?.parent?.type === 'VElement' &&
26+
node.parent?.parent?.parent?.name === 'el-tooltip'
27+
)
28+
}
29+
30+
function fix(node: VIdentifier): Operation[] {
31+
let fixOperations: Operation[] = []
32+
// @ts-ignore
33+
fixOperations.push(OperationUtil.replaceText(node, renameMap.get(node.name)))
34+
return fixOperations
35+
}

vue-transformations/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ const transformationMap: {
2121
'router-link-event-tag': require('./router-link-event-tag'),
2222
'router-link-exact': require('./router-link-exact'),
2323
'router-view-keep-alive-transition': require('./router-view-keep-alive-transition'),
24-
'time-picker-format-attribute':require('./element-ui/time-picker-format-attribute'),
24+
25+
// element-ui transformation
26+
'time-picker-format-attribute': require('./element-ui/time-picker-format-attribute'),
27+
'tooltip-rename-attribute': require('./element-ui/tooltip-rename-attribute'),
2528

2629
// manual (must be used at the end of list)
2730
'manual-remove-keycode': require('./manual/manual-remove-keycode')

0 commit comments

Comments
 (0)