@mixd-id/web-scaffold 0.1.230406370 → 0.1.230406372

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mixd-id/web-scaffold",
3
3
  "private": false,
4
- "version": "0.1.230406370",
4
+ "version": "0.1.230406372",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -0,0 +1,119 @@
1
+ <template>
2
+ <div :class="$style.comp"
3
+ @click="onClick">
4
+ <video v-if="actualSrc" ref="video"
5
+ @ended="playing = false">
6
+ <source :src="actualSrc" type="video/mp4">
7
+ </video>
8
+
9
+ <slot v-else name="empty" :instance="this"></slot>
10
+
11
+ <div v-if="!playing && actualSrc" :class="$style.play">
12
+ <button type="button" @click.stop="play" class="w-[36px] h-[36px] flex items-center justify-center rounded-full bg-white/30">
13
+ <svg width="21" height="21" class="fill-white" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.0.0-alpha3 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) --><path d="M176 480C148.6 480 128 457.6 128 432v-352c0-25.38 20.4-47.98 48.01-47.98c8.686 0 17.35 2.352 25.02 7.031l288 176C503.3 223.8 512 239.3 512 256s-8.703 32.23-22.97 40.95l-288 176C193.4 477.6 184.7 480 176 480z"/></svg>
14
+ </button>
15
+ </div>
16
+
17
+ <input v-if="Boolean(editable)" class="hidden" type="file" accept="video/*" ref="file" @change="onChange"/>
18
+ </div>
19
+ </template>
20
+
21
+ <script>
22
+
23
+ export default{
24
+
25
+ emits: [ 'click', 'change' ],
26
+
27
+ props: {
28
+
29
+ editable:{
30
+ type: [ Boolean, String ],
31
+ default: false
32
+ },
33
+
34
+ src: undefined,
35
+
36
+ },
37
+
38
+ data(){
39
+ return {
40
+ actualSrc: null,
41
+ playing: false,
42
+ }
43
+ },
44
+
45
+ methods: {
46
+
47
+ edit(){
48
+ if(this.$refs.file){
49
+ this.$refs.file.click()
50
+ }
51
+ },
52
+
53
+ onChange(e){
54
+ if(e.target.files.length > 0){
55
+ var reader = new FileReader();
56
+ reader.addEventListener('load', () => {
57
+ this.$emit('change', reader.result, e.target.files[0])
58
+ this.$refs.file.value = null
59
+ }, false)
60
+ reader.readAsDataURL(e.target.files[0]);
61
+ }
62
+ },
63
+
64
+ onClick(e){
65
+ if(this.playing){
66
+ this.$refs.video.pause()
67
+ this.playing = false
68
+ }
69
+ else{
70
+ this.$emit('click', e, this)
71
+ }
72
+ },
73
+
74
+ play(){
75
+ this.$refs.video.play()
76
+ this.playing = true
77
+ }
78
+
79
+ },
80
+
81
+ watch: {
82
+
83
+ src: {
84
+ immediate: true,
85
+ handler(to){
86
+ if(to instanceof File){
87
+ var reader = new FileReader();
88
+ reader.addEventListener('load', () => {
89
+ this.actualSrc = reader.result
90
+ }, false)
91
+ reader.readAsDataURL(to);
92
+ }
93
+ else{
94
+ this.actualSrc = to
95
+ //this.actualSrc = 'https://www.kliknss.co.id/images/big_buck_bunny_240p_1mb.mp4'
96
+ }
97
+ }
98
+ }
99
+
100
+ }
101
+
102
+ }
103
+
104
+ </script>
105
+
106
+ <style module>
107
+
108
+ .comp{
109
+ @apply flex-1 flex items-center justify-center relative overflow-hidden;
110
+ }
111
+
112
+ .play{
113
+ @apply absolute;
114
+ top: 50%;
115
+ left: 50%;
116
+ transform: translate(-50%, -50%);
117
+ }
118
+
119
+ </style>
@@ -258,7 +258,7 @@ export default{
258
258
  }
259
259
 
260
260
  this.scrollerCache = {
261
- id: this.items[this.visibleStartIndex].id,
261
+ id: this.items[this.visibleStartIndex]?.id,
262
262
  index: this.visibleStartIndex
263
263
  }
264
264
  },
@@ -614,7 +614,7 @@ export default{
614
614
  }
615
615
 
616
616
  this.scrollerCache = {
617
- id: this.items[this.visibleStartIndex].id,
617
+ id: this.items[this.visibleStartIndex]?.id,
618
618
  index: this.visibleStartIndex
619
619
  }
620
620
  },
package/src/index.js CHANGED
@@ -533,6 +533,7 @@ export default{
533
533
  app.component('IconMenu2', defineAsyncComponent(() => import("./components/IconMenu2.vue")))
534
534
  app.component('IconPlus', defineAsyncComponent(() => import("./components/IconPlus.vue")))
535
535
  app.component('Image', defineAsyncComponent(() => import("./components/Image.vue")))
536
+ app.component('Video', defineAsyncComponent(() => import("./components/Video.vue")))
536
537
  app.component('Image360', defineAsyncComponent(() => import("./components/Image360.vue")))
537
538
  app.component('ImagePreview', defineAsyncComponent(() => import("./components/ImagePreview.vue")))
538
539
  app.component('ImageFullScreen', defineAsyncComponent(() => import("./components/ImageFullScreen.vue")))