1
- <template >
2
- <div class =" file-selector" >
3
- <div
4
- v-for =" (file, i) in Object.keys(store.files)"
5
- class =" file"
6
- :class =" { active: store.activeFilename === file }"
7
- @click =" setActive(file)" >
8
- <span class =" label" >{{ file }}</span >
9
- <span v-if =" i > 0" class =" remove" @click.stop =" deleteFile(file)" >
10
- <svg width =" 12" height =" 12" viewBox =" 0 0 24 24" class =" svelte-cghqrp" ><line stroke =" #999" x1 =" 18" y1 =" 6" x2 =" 6" y2 =" 18" ></line ><line stroke =" #999" x1 =" 6" y1 =" 6" x2 =" 18" y2 =" 18" ></line ></svg >
11
- </span >
12
- </div >
13
- <div v-if =" pending" class =" file" >
14
- <input
15
- v-model =" pendingFilename"
16
- spellcheck =" false"
17
- @keyup.enter =" doneAddFile"
18
- @keyup.esc =" cancelAddFile"
19
- @vnodeMounted =" focus" >
20
- </div >
21
- <button class =" add" @click =" startAddFile" >+</button >
22
- </div >
23
- </template >
24
-
25
1
<script setup lang="ts">
26
2
import { store , addFile , deleteFile , setActive } from ' ../store'
27
- import { ref } from ' vue'
28
- import type { VNode } from ' vue'
3
+ import { ref , VNode } from ' vue'
29
4
30
5
const pending = ref (false )
31
6
const pendingFilename = ref (' Comp.vue' )
@@ -39,7 +14,7 @@ function cancelAddFile() {
39
14
}
40
15
41
16
function focus({ el }: VNode ) {
42
- (el as HTMLInputElement ).focus ()
17
+ ; (el as HTMLInputElement ).focus ()
43
18
}
44
19
45
20
function doneAddFile() {
@@ -50,7 +25,9 @@ function doneAddFile() {
50
25
! filename .endsWith (' .js' ) &&
51
26
filename !== ' import-map.json'
52
27
) {
53
- store .errors = [` Playground only supports *.vue, *.js files or import-map.json. ` ]
28
+ store .errors = [
29
+ ` Playground only supports *.vue, *.js files or import-map.json. `
30
+ ]
54
31
return
55
32
}
56
33
@@ -66,6 +43,35 @@ function doneAddFile() {
66
43
}
67
44
</script >
68
45
46
+ <template >
47
+ <div class =" file-selector" >
48
+ <div
49
+ v-for =" (file, i) in Object.keys(store.files)"
50
+ class =" file"
51
+ :class =" { active: store.activeFilename === file }"
52
+ @click =" setActive(file)"
53
+ >
54
+ <span class =" label" >{{ file }}</span >
55
+ <span v-if =" i > 0" class =" remove" @click.stop =" deleteFile(file)" >
56
+ <svg width =" 12" height =" 12" viewBox =" 0 0 24 24" class =" svelte-cghqrp" >
57
+ <line stroke =" #999" x1 =" 18" y1 =" 6" x2 =" 6" y2 =" 18" ></line >
58
+ <line stroke =" #999" x1 =" 6" y1 =" 6" x2 =" 18" y2 =" 18" ></line >
59
+ </svg >
60
+ </span >
61
+ </div >
62
+ <div v-if =" pending" class =" file" >
63
+ <input
64
+ v-model =" pendingFilename"
65
+ spellcheck =" false"
66
+ @keyup.enter =" doneAddFile"
67
+ @keyup.esc =" cancelAddFile"
68
+ @vnodeMounted =" focus"
69
+ />
70
+ </div >
71
+ <button class =" add" @click =" startAddFile" >+</button >
72
+ </div >
73
+ </template >
74
+
69
75
<style scoped>
70
76
.file-selector {
71
77
box-sizing : border-box ;
0 commit comments