@drax/media-vue 0.7.0 → 0.7.5

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
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.7.0",
6
+ "version": "0.7.5",
7
7
  "type": "module",
8
8
  "main": "./src/index.ts",
9
9
  "module": "./src/index.ts",
@@ -61,5 +61,5 @@
61
61
  "vue-tsc": "^2.0.11",
62
62
  "vuetify": "^3.7.1"
63
63
  },
64
- "gitHead": "244c1ccf07c9e3cf11486dcd013b11bcee505c6d"
64
+ "gitHead": "beb044cac460f71906c156ba66b13d07021286ad"
65
65
  }
@@ -8,7 +8,7 @@ const valueModel = defineModel<any>({type: [String], default: false})
8
8
 
9
9
  const {dir} = defineProps({
10
10
  prependIcon: {type: String, default: ''},
11
- // prependInnerIcon: {type: String, default: ''},
11
+ prependInnerIcon: {type: String, default: ''},
12
12
  appendIcon: {type: String, default: ''},
13
13
  appendInnerIcon: {type: String, default: ''},
14
14
  readonly: {type: Boolean, default: false},
@@ -34,9 +34,7 @@ const {dir} = defineProps({
34
34
  let fileInput = ref()
35
35
 
36
36
  function onFileClick() {
37
- console.log('File clicked');
38
37
  fileInput.value.click();
39
- console.log('File clicked pass');
40
38
  }
41
39
 
42
40
 
@@ -50,12 +48,42 @@ async function onFileChanged(e: Event) {
50
48
  }
51
49
  }
52
50
 
51
+ const handleDrop = async (event: DragEvent) => {
52
+ isDragOver.value = false;
53
+ const files = event.dataTransfer?.files;
54
+ if (files && files[0]) {
55
+ const file = await mediaSystem.uploadFile(files[0],dir);
56
+ valueModel.value = file.url;
57
+ }
58
+ };
59
+
60
+ const isDragOver = ref(false);
61
+
62
+ const handleDragEnter = () => {
63
+ isDragOver.value = true;
64
+ };
65
+
66
+ const handleDragOver = () => {
67
+ isDragOver.value = true;
68
+ };
69
+
70
+ const handleDragLeave = () => {
71
+ isDragOver.value = false;
72
+ };
73
+
53
74
  defineEmits(['updateValue'])
54
75
 
55
76
  </script>
56
77
 
57
78
  <template>
58
- <div>
79
+ <div
80
+ :class="{ 'drop-zone': true, 'dragover': isDragOver }"
81
+ @dragenter.prevent="handleDragEnter"
82
+ @dragover.prevent="handleDragOver"
83
+ @dragleave.prevent="handleDragLeave"
84
+ @drop.prevent="handleDrop"
85
+
86
+ >
59
87
  <v-text-field
60
88
  type="text"
61
89
  :name="name"
@@ -69,7 +97,7 @@ defineEmits(['updateValue'])
69
97
  :clearable="clearable"
70
98
  :hide-details="hideDetails"
71
99
  :single-line="singleLine"
72
- prepend-inner-icon="mdi mdi-upload-circle"
100
+ :prepend-inner-icon="prependInnerIcon"
73
101
  :append-icon="appendIcon"
74
102
  :prepend-icon="prependIcon"
75
103
  :append-inner-icon="appendInnerIcon"
@@ -86,10 +114,24 @@ defineEmits(['updateValue'])
86
114
  type="file"
87
115
  @change="onFileChanged"
88
116
  >
117
+
118
+ <v-btn @click="onFileClick" density="compact" color="grey" variant="text">Click | Drag & Drop</v-btn>
119
+
89
120
  </div>
90
121
 
91
122
  </template>
92
123
 
93
124
  <style scoped>
125
+ .drop-zone {
126
+ border: 2px dashed #ccc;
127
+ padding: 10px;
128
+ text-align: center;
129
+ color: #666;
130
+ transition: background-color 0.3s;
131
+ }
94
132
 
133
+ .drop-zone.dragover {
134
+ background-color: #e0f7fa;
135
+ border-color: #00acc1;
136
+ }
95
137
  </style>