@a-vision-software/vue-input-components 1.1.42 → 1.1.51
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/README.md +3 -2
- package/package.json +9 -16
- package/src/App.vue +0 -48
- package/src/assets/colors.css +0 -67
- package/src/assets/logo.svg +0 -1
- package/src/assets/main.css +0 -160
- package/src/components/FileUpload.vue +0 -310
- package/src/components/TextInput.vue +0 -368
- package/src/index.ts +0 -6
- package/src/main.ts +0 -21
- package/src/router/index.ts +0 -27
- package/src/types.d.ts +0 -23
- package/src/types.ts +0 -36
- package/src/views/DashboardView.vue +0 -57
- package/src/views/FileUploadTestView.vue +0 -177
- package/src/views/TextInputTestView.vue +0 -348
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ A collection of reusable Vue 3 input components with TypeScript support.
|
|
|
35
35
|
## Installation
|
|
36
36
|
|
|
37
37
|
```bash
|
|
38
|
-
npm install
|
|
38
|
+
npm install npm install git+ssh://github.com:a-vision/vue-input-components.git
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
## Quick Start
|
|
@@ -44,7 +44,7 @@ npm install @a-vision-software/vue-input-components
|
|
|
44
44
|
|
|
45
45
|
```vue
|
|
46
46
|
<script setup>
|
|
47
|
-
import { TextInput, FileUpload } from '
|
|
47
|
+
import { TextInput, FileUpload } from 'vue-input-components'
|
|
48
48
|
</script>
|
|
49
49
|
```
|
|
50
50
|
|
|
@@ -55,6 +55,7 @@ npm install @a-vision-software/vue-input-components
|
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
3. Use the components in your template:
|
|
58
|
+
|
|
58
59
|
```vue
|
|
59
60
|
<template>
|
|
60
61
|
<TextInput v-model="username" label="Username" icon="user" :required="true" />
|
package/package.json
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@a-vision-software/vue-input-components",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.51",
|
|
4
4
|
"description": "A collection of reusable Vue 3 input components with TypeScript support",
|
|
5
5
|
"author": "A-Vision Software",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/a-vision/vue-input-components.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/a-vision/vue-input-components#readme",
|
|
7
12
|
"keywords": [
|
|
8
13
|
"vue",
|
|
9
14
|
"vue3",
|
|
@@ -17,23 +22,11 @@
|
|
|
17
22
|
],
|
|
18
23
|
"type": "module",
|
|
19
24
|
"files": [
|
|
20
|
-
"dist"
|
|
21
|
-
"src"
|
|
25
|
+
"dist"
|
|
22
26
|
],
|
|
23
27
|
"main": "./dist/vue-input-components.cjs.js",
|
|
24
|
-
"module": "./dist/vue-input-components.
|
|
25
|
-
"
|
|
26
|
-
"exports": {
|
|
27
|
-
".": {
|
|
28
|
-
"types": "./dist/index.d.ts",
|
|
29
|
-
"import": "./dist/vue-input-components.cjs.js",
|
|
30
|
-
"default": "./dist/vue-input-components.es.js",
|
|
31
|
-
"require": "./dist/vue-input-components.umd.js"
|
|
32
|
-
},
|
|
33
|
-
"./style": "./dist/vue-input-components.css",
|
|
34
|
-
"./dist/*": "./dist/*",
|
|
35
|
-
"./package.json": "./package.json"
|
|
36
|
-
},
|
|
28
|
+
"module": "./dist/vue-input-components.cjs.js",
|
|
29
|
+
"exports": "./dist/vue-input-components.es.js",
|
|
37
30
|
"sideEffects": [
|
|
38
31
|
"**/*.css"
|
|
39
32
|
],
|
package/src/App.vue
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { RouterView } from 'vue-router'
|
|
3
|
-
</script>
|
|
4
|
-
|
|
5
|
-
<template>
|
|
6
|
-
<div id="app">
|
|
7
|
-
<router-view />
|
|
8
|
-
</div>
|
|
9
|
-
</template>
|
|
10
|
-
|
|
11
|
-
<style>
|
|
12
|
-
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
|
|
13
|
-
|
|
14
|
-
*,
|
|
15
|
-
*::before,
|
|
16
|
-
*::after {
|
|
17
|
-
box-sizing: border-box;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
html,
|
|
21
|
-
body {
|
|
22
|
-
padding: 0;
|
|
23
|
-
margin: 0;
|
|
24
|
-
font-family:
|
|
25
|
-
'Inter',
|
|
26
|
-
-apple-system,
|
|
27
|
-
BlinkMacSystemFont,
|
|
28
|
-
'Segoe UI',
|
|
29
|
-
Roboto,
|
|
30
|
-
Oxygen,
|
|
31
|
-
Ubuntu,
|
|
32
|
-
Cantarell,
|
|
33
|
-
'Fira Sans',
|
|
34
|
-
'Droid Sans',
|
|
35
|
-
'Helvetica Neue',
|
|
36
|
-
sans-serif;
|
|
37
|
-
-webkit-font-smoothing: antialiased;
|
|
38
|
-
-moz-osx-font-smoothing: grayscale;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
#app {
|
|
42
|
-
min-height: 100vh;
|
|
43
|
-
width: 100vw;
|
|
44
|
-
display: grid;
|
|
45
|
-
grid-template-rows: 1fr;
|
|
46
|
-
grid-template-columns: 1fr;
|
|
47
|
-
}
|
|
48
|
-
</style>
|
package/src/assets/colors.css
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
:root {
|
|
2
|
-
/* Base colors */
|
|
3
|
-
--primary-color: #3498db;
|
|
4
|
-
--primary-color-light: rgba(52, 152, 219, 0.2);
|
|
5
|
-
--secondary-color: #2ecc71;
|
|
6
|
-
|
|
7
|
-
/* Text colors */
|
|
8
|
-
--text-color: #2c3e50;
|
|
9
|
-
--text-color-light: #7f8c8d;
|
|
10
|
-
|
|
11
|
-
/* UI colors */
|
|
12
|
-
--border-color: #dcdfe6;
|
|
13
|
-
--icon-color: #95a5a6;
|
|
14
|
-
|
|
15
|
-
/* State colors */
|
|
16
|
-
--error-color: #e74c3c;
|
|
17
|
-
--error-color-light: rgba(231, 76, 60, 0.2);
|
|
18
|
-
--success-color: #2ecc71;
|
|
19
|
-
--success-color-light: rgba(46, 204, 113, 0.2);
|
|
20
|
-
--warning-color: #f1c40f;
|
|
21
|
-
--warning-color-light: rgba(241, 196, 15, 0.2);
|
|
22
|
-
|
|
23
|
-
/* Background colors */
|
|
24
|
-
--disabled-color: #bdc3c7;
|
|
25
|
-
--disabled-background: #f5f7fa;
|
|
26
|
-
--card-bg: #ffffff;
|
|
27
|
-
--background-color: #f8f9fa;
|
|
28
|
-
|
|
29
|
-
/* Input colors */
|
|
30
|
-
--input-bg-color: rgba(255, 255, 255, 0.8);
|
|
31
|
-
--input-bg-hover: rgba(0, 0, 0, 0.05);
|
|
32
|
-
--input-bg-disabled: rgba(0, 0, 0, 0.05);
|
|
33
|
-
|
|
34
|
-
/* Text Colors */
|
|
35
|
-
--text-muted: #6c757d;
|
|
36
|
-
|
|
37
|
-
/* Border Colors */
|
|
38
|
-
--input-bg: #ffffff;
|
|
39
|
-
--input-bg-disabled: #e9ecef;
|
|
40
|
-
|
|
41
|
-
/* Status Colors */
|
|
42
|
-
--danger-color: #dc3545;
|
|
43
|
-
--success-color: #28a745;
|
|
44
|
-
--warning-color: #ffc107;
|
|
45
|
-
|
|
46
|
-
/* Shadow Colors */
|
|
47
|
-
--shadow-color: rgba(74, 108, 247, 0.25);
|
|
48
|
-
|
|
49
|
-
/* Typography */
|
|
50
|
-
--line-height: 20px;
|
|
51
|
-
|
|
52
|
-
/* File Upload Colors */
|
|
53
|
-
--upload-border-color: var(--border-color);
|
|
54
|
-
--upload-bg-color: var(--background-color);
|
|
55
|
-
--upload-dragging-border-color: var(--primary-color);
|
|
56
|
-
--upload-dragging-bg-color: var(--primary-color-light);
|
|
57
|
-
--upload-has-files-border-color: var(--success-color);
|
|
58
|
-
--upload-has-files-bg-color: var(--success-color-light);
|
|
59
|
-
--upload-icon-color: var(--icon-color);
|
|
60
|
-
--upload-text-color: var(--text-color-light);
|
|
61
|
-
--progress-bg-color: var(--disabled-background);
|
|
62
|
-
--progress-color: var(--primary-color);
|
|
63
|
-
--success-bg-color: var(--success-color-light);
|
|
64
|
-
--success-text-color: var(--success-color);
|
|
65
|
-
--error-bg-color: var(--error-color-light);
|
|
66
|
-
--error-text-color: var(--error-color);
|
|
67
|
-
}
|
package/src/assets/logo.svg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 261.76 226.69"><path d="M161.096.001l-30.225 52.351L100.647.001H-.005l130.877 226.688L261.749.001z" fill="#41b883"/><path d="M161.096.001l-30.225 52.351L100.647.001H52.346l78.526 136.01L209.398.001z" fill="#34495e"/></svg>
|
package/src/assets/main.css
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
:root {
|
|
2
|
-
/* Typography */
|
|
3
|
-
--font-family:
|
|
4
|
-
-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
5
|
-
--font-size-xs: 0.75rem;
|
|
6
|
-
--font-size-sm: 0.875rem;
|
|
7
|
-
--font-size-base: 1rem;
|
|
8
|
-
--font-size-lg: 1.125rem;
|
|
9
|
-
--font-size-xl: 1.25rem;
|
|
10
|
-
--font-weight-normal: 400;
|
|
11
|
-
--font-weight-medium: 500;
|
|
12
|
-
--font-weight-bold: 600;
|
|
13
|
-
--line-height-tight: 1.25;
|
|
14
|
-
--line-height-base: 1.5;
|
|
15
|
-
--line-height-loose: 1.75;
|
|
16
|
-
|
|
17
|
-
/* Spacing */
|
|
18
|
-
--spacing-xs: 0.25rem;
|
|
19
|
-
--spacing-sm: 0.5rem;
|
|
20
|
-
--spacing-md: 1rem;
|
|
21
|
-
--spacing-lg: 1.5rem;
|
|
22
|
-
--spacing-xl: 2rem;
|
|
23
|
-
|
|
24
|
-
/* Borders */
|
|
25
|
-
--border-radius-sm: 0.25rem;
|
|
26
|
-
--border-radius-md: 0.375rem;
|
|
27
|
-
--border-radius-lg: 0.5rem;
|
|
28
|
-
--border-width: 1px;
|
|
29
|
-
--border-width-thick: 2px;
|
|
30
|
-
|
|
31
|
-
/* Shadows */
|
|
32
|
-
--shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
|
|
33
|
-
--shadow-md: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
34
|
-
--shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
35
|
-
|
|
36
|
-
/* Transitions */
|
|
37
|
-
--transition-fast: 150ms;
|
|
38
|
-
--transition-base: 200ms;
|
|
39
|
-
--transition-slow: 300ms;
|
|
40
|
-
--transition-timing: ease-in-out;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/* Base styles */
|
|
44
|
-
html {
|
|
45
|
-
box-sizing: border-box;
|
|
46
|
-
font-size: 16px;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
*,
|
|
50
|
-
*:before,
|
|
51
|
-
*:after {
|
|
52
|
-
box-sizing: inherit;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
body {
|
|
56
|
-
margin: 0;
|
|
57
|
-
padding: 0;
|
|
58
|
-
font-family: var(--font-family);
|
|
59
|
-
font-size: var(--font-size-base);
|
|
60
|
-
line-height: var(--line-height-base);
|
|
61
|
-
color: var(--text-color);
|
|
62
|
-
background-color: var(--background-color);
|
|
63
|
-
-webkit-font-smoothing: antialiased;
|
|
64
|
-
-moz-osx-font-smoothing: grayscale;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
h1,
|
|
68
|
-
h2,
|
|
69
|
-
h3,
|
|
70
|
-
h4,
|
|
71
|
-
h5,
|
|
72
|
-
h6 {
|
|
73
|
-
margin: 0;
|
|
74
|
-
font-weight: var(--font-weight-bold);
|
|
75
|
-
line-height: var(--line-height-tight);
|
|
76
|
-
color: var(--text-color);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
p {
|
|
80
|
-
margin: 0 0 var(--spacing-md) 0;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
a {
|
|
84
|
-
color: var(--primary-color);
|
|
85
|
-
text-decoration: none;
|
|
86
|
-
transition: color var(--transition-base) var(--transition-timing);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
a:hover {
|
|
90
|
-
color: var(--primary-color-light);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/* Utility classes */
|
|
94
|
-
.text-error {
|
|
95
|
-
color: var(--error-color);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
.text-success {
|
|
99
|
-
color: var(--success-color);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
.text-warning {
|
|
103
|
-
color: var(--warning-color);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
.text-disabled {
|
|
107
|
-
color: var(--disabled-color);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
.bg-card {
|
|
111
|
-
background-color: var(--card-bg);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
.shadow-sm {
|
|
115
|
-
box-shadow: var(--shadow-sm);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
.shadow-md {
|
|
119
|
-
box-shadow: var(--shadow-md);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
.shadow-lg {
|
|
123
|
-
box-shadow: var(--shadow-lg);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
.rounded-sm {
|
|
127
|
-
border-radius: var(--border-radius-sm);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
.rounded-md {
|
|
131
|
-
border-radius: var(--border-radius-md);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
.rounded-lg {
|
|
135
|
-
border-radius: var(--border-radius-lg);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/* Responsive breakpoints */
|
|
139
|
-
@media (max-width: 640px) {
|
|
140
|
-
html {
|
|
141
|
-
font-size: 14px;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
@media (min-width: 1200px) {
|
|
146
|
-
html {
|
|
147
|
-
font-size: 16px;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/* Print styles */
|
|
152
|
-
@media print {
|
|
153
|
-
body {
|
|
154
|
-
background: white;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
@page {
|
|
158
|
-
margin: 2cm;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="file-upload">
|
|
3
|
-
<div
|
|
4
|
-
class="upload-area"
|
|
5
|
-
:class="{ 'is-dragging': isDragging, 'has-files': files.length > 0 }"
|
|
6
|
-
@dragenter.prevent="handleDragEnter"
|
|
7
|
-
@dragleave.prevent="handleDragLeave"
|
|
8
|
-
@dragover.prevent
|
|
9
|
-
@drop.prevent="handleDrop"
|
|
10
|
-
@click="triggerFileInput"
|
|
11
|
-
>
|
|
12
|
-
<input ref="fileInput" type="file" multiple class="file-input" @change="handleFileSelect" />
|
|
13
|
-
<div class="upload-content">
|
|
14
|
-
<font-awesome-icon :icon="['fas', icon || 'upload']" />
|
|
15
|
-
<p v-if="files.length === 0">Drag & drop files here or click to select</p>
|
|
16
|
-
<div v-else class="selected-files">
|
|
17
|
-
<p>{{ files.length }} file(s) selected</p>
|
|
18
|
-
<div v-for="(file, index) in files" :key="index" class="file-info">
|
|
19
|
-
<span class="file-name">{{ file.name }}</span>
|
|
20
|
-
<span class="file-size">{{ formatFileSize(file.size) }}</span>
|
|
21
|
-
</div>
|
|
22
|
-
</div>
|
|
23
|
-
</div>
|
|
24
|
-
</div>
|
|
25
|
-
<div v-if="error" class="error-message">{{ error }}</div>
|
|
26
|
-
<div v-if="uploadProgress > 0 && uploadProgress < 100" class="progress-bar">
|
|
27
|
-
<div class="progress" :style="{ width: `${uploadProgress}%` }"></div>
|
|
28
|
-
</div>
|
|
29
|
-
<div v-if="uploadStatus" class="status-message" :class="uploadStatus.type">
|
|
30
|
-
{{ uploadStatus.message }}
|
|
31
|
-
</div>
|
|
32
|
-
<button v-if="files.length > 0 && !uploadUrl" class="upload-button" @click="handleStartUpload">
|
|
33
|
-
Upload Files
|
|
34
|
-
</button>
|
|
35
|
-
</div>
|
|
36
|
-
</template>
|
|
37
|
-
|
|
38
|
-
<script setup lang="ts">
|
|
39
|
-
import { ref, watch } from 'vue'
|
|
40
|
-
|
|
41
|
-
const props = defineProps<{
|
|
42
|
-
icon?: string
|
|
43
|
-
uploadUrl?: string
|
|
44
|
-
}>()
|
|
45
|
-
|
|
46
|
-
const emit = defineEmits<{
|
|
47
|
-
(e: 'upload-complete', files: File[]): void
|
|
48
|
-
(e: 'upload-error', error: string): void
|
|
49
|
-
(e: 'files-selected', files: File[]): void
|
|
50
|
-
(e: 'start-upload', files: File[]): void
|
|
51
|
-
}>()
|
|
52
|
-
|
|
53
|
-
const MAX_FILE_SIZE = 20 * 1024 * 1024 // 20MB in bytes
|
|
54
|
-
const fileInput = ref<HTMLInputElement | null>(null)
|
|
55
|
-
const files = ref<File[]>([])
|
|
56
|
-
const isDragging = ref(false)
|
|
57
|
-
const uploadProgress = ref(0)
|
|
58
|
-
const error = ref('')
|
|
59
|
-
const uploadStatus = ref<{ type: 'success' | 'error'; message: string } | null>(null)
|
|
60
|
-
|
|
61
|
-
const formatFileSize = (bytes: number): string => {
|
|
62
|
-
if (bytes === 0) return '0 Bytes'
|
|
63
|
-
const k = 1024
|
|
64
|
-
const sizes = ['Bytes', 'KB', 'MB', 'GB']
|
|
65
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k))
|
|
66
|
-
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const validateFileSize = (file: File): boolean => {
|
|
70
|
-
if (file.size > MAX_FILE_SIZE) {
|
|
71
|
-
error.value = `File "${file.name}" exceeds the maximum size of 20MB`
|
|
72
|
-
return false
|
|
73
|
-
}
|
|
74
|
-
return true
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const handleDragEnter = () => {
|
|
78
|
-
isDragging.value = true
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const handleDragLeave = () => {
|
|
82
|
-
isDragging.value = false
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const handleDrop = (e: DragEvent) => {
|
|
86
|
-
isDragging.value = false
|
|
87
|
-
error.value = ''
|
|
88
|
-
if (e.dataTransfer?.files) {
|
|
89
|
-
const newFiles = Array.from(e.dataTransfer.files)
|
|
90
|
-
if (newFiles.every(validateFileSize)) {
|
|
91
|
-
files.value = [...files.value, ...newFiles]
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const triggerFileInput = () => {
|
|
97
|
-
fileInput.value?.click()
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const handleFileSelect = (e: Event) => {
|
|
101
|
-
error.value = ''
|
|
102
|
-
const input = e.target as HTMLInputElement
|
|
103
|
-
if (input.files) {
|
|
104
|
-
const newFiles = Array.from(input.files)
|
|
105
|
-
if (newFiles.every(validateFileSize)) {
|
|
106
|
-
files.value = [...files.value, ...newFiles]
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
input.value = ''
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const uploadFiles = async () => {
|
|
113
|
-
if (!props.uploadUrl) {
|
|
114
|
-
error.value = 'No upload URL provided'
|
|
115
|
-
return
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (files.value.length === 0) {
|
|
119
|
-
error.value = 'No files selected'
|
|
120
|
-
return
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const formData = new FormData()
|
|
124
|
-
files.value.forEach((file) => {
|
|
125
|
-
formData.append('files', file)
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
try {
|
|
129
|
-
const xhr = new XMLHttpRequest()
|
|
130
|
-
xhr.upload.addEventListener('progress', (e) => {
|
|
131
|
-
if (e.lengthComputable) {
|
|
132
|
-
uploadProgress.value = (e.loaded / e.total) * 100
|
|
133
|
-
}
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
xhr.addEventListener('load', () => {
|
|
137
|
-
if (xhr.status >= 200 && xhr.status < 300) {
|
|
138
|
-
uploadStatus.value = {
|
|
139
|
-
type: 'success',
|
|
140
|
-
message: 'Upload completed successfully',
|
|
141
|
-
}
|
|
142
|
-
emit('upload-complete', files.value)
|
|
143
|
-
files.value = []
|
|
144
|
-
uploadProgress.value = 0
|
|
145
|
-
} else {
|
|
146
|
-
throw new Error(`Upload failed with status ${xhr.status}`)
|
|
147
|
-
}
|
|
148
|
-
})
|
|
149
|
-
|
|
150
|
-
xhr.addEventListener('error', () => {
|
|
151
|
-
throw new Error('Upload failed')
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
xhr.open('POST', props.uploadUrl)
|
|
155
|
-
xhr.send(formData)
|
|
156
|
-
} catch (err) {
|
|
157
|
-
const errorMessage = err instanceof Error ? err.message : 'Upload failed'
|
|
158
|
-
error.value = errorMessage
|
|
159
|
-
uploadStatus.value = {
|
|
160
|
-
type: 'error',
|
|
161
|
-
message: errorMessage,
|
|
162
|
-
}
|
|
163
|
-
emit('upload-error', errorMessage)
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const handleStartUpload = () => {
|
|
168
|
-
emit('start-upload', files.value)
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// Watch for changes in files and automatically upload when files are selected
|
|
172
|
-
watch(files, (newFiles) => {
|
|
173
|
-
if (newFiles.length > 0) {
|
|
174
|
-
if (props.uploadUrl) {
|
|
175
|
-
uploadFiles()
|
|
176
|
-
} else {
|
|
177
|
-
emit('files-selected', newFiles)
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
})
|
|
181
|
-
</script>
|
|
182
|
-
|
|
183
|
-
<style scoped>
|
|
184
|
-
.file-upload {
|
|
185
|
-
width: 100%;
|
|
186
|
-
max-width: 600px;
|
|
187
|
-
margin: 0 auto;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
.upload-area {
|
|
191
|
-
border: 2px dashed var(--upload-border-color);
|
|
192
|
-
border-radius: 0.75rem;
|
|
193
|
-
padding: 2rem;
|
|
194
|
-
text-align: center;
|
|
195
|
-
cursor: pointer;
|
|
196
|
-
transition: all 0.3s ease;
|
|
197
|
-
background-color: var(--upload-bg-color);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
.upload-area.is-dragging {
|
|
201
|
-
border-color: var(--upload-dragging-border-color);
|
|
202
|
-
background-color: var(--upload-dragging-bg-color);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
.upload-area.has-files {
|
|
206
|
-
border-color: var(--upload-has-files-border-color);
|
|
207
|
-
background-color: var(--upload-has-files-bg-color);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
.file-input {
|
|
211
|
-
display: none;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
.upload-content {
|
|
215
|
-
display: flex;
|
|
216
|
-
flex-direction: column;
|
|
217
|
-
align-items: center;
|
|
218
|
-
gap: 1rem;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
.upload-content :deep(svg) {
|
|
222
|
-
font-size: 2rem;
|
|
223
|
-
color: var(--upload-icon-color);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
.selected-files {
|
|
227
|
-
width: 100%;
|
|
228
|
-
text-align: left;
|
|
229
|
-
max-height: 200px;
|
|
230
|
-
overflow-y: auto;
|
|
231
|
-
font-size: 0.75rem;
|
|
232
|
-
color: var(--upload-text-color);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
.file-info {
|
|
236
|
-
display: flex;
|
|
237
|
-
justify-content: space-between;
|
|
238
|
-
align-items: center;
|
|
239
|
-
padding: 0.125rem 0;
|
|
240
|
-
border-radius: 0.25rem;
|
|
241
|
-
gap: 0.5rem;
|
|
242
|
-
font-size: 0.75rem;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
.file-name {
|
|
246
|
-
flex: 1;
|
|
247
|
-
overflow: hidden;
|
|
248
|
-
text-overflow: ellipsis;
|
|
249
|
-
white-space: nowrap;
|
|
250
|
-
margin-right: 0.5rem;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
.file-size {
|
|
254
|
-
font-size: 0.7rem;
|
|
255
|
-
flex-shrink: 0;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
.error-message {
|
|
259
|
-
color: var(--error-text-color);
|
|
260
|
-
margin-top: 1rem;
|
|
261
|
-
font-size: 0.875rem;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
.progress-bar {
|
|
265
|
-
height: 0.5rem;
|
|
266
|
-
background-color: var(--progress-bg-color);
|
|
267
|
-
border-radius: 0.25rem;
|
|
268
|
-
margin-top: 1rem;
|
|
269
|
-
overflow: hidden;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
.progress {
|
|
273
|
-
height: 100%;
|
|
274
|
-
background-color: var(--progress-color);
|
|
275
|
-
transition: width 0.3s ease;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
.status-message {
|
|
279
|
-
margin-top: 1rem;
|
|
280
|
-
padding: 0.5rem;
|
|
281
|
-
border-radius: 0.25rem;
|
|
282
|
-
font-size: 0.875rem;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
.status-message.success {
|
|
286
|
-
background-color: var(--success-bg-color);
|
|
287
|
-
color: var(--success-text-color);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
.status-message.error {
|
|
291
|
-
background-color: var(--error-bg-color);
|
|
292
|
-
color: var(--error-text-color);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
.upload-button {
|
|
296
|
-
margin-top: 1rem;
|
|
297
|
-
padding: 0.5rem 1rem;
|
|
298
|
-
background-color: var(--primary-color);
|
|
299
|
-
color: white;
|
|
300
|
-
border: none;
|
|
301
|
-
border-radius: 0.25rem;
|
|
302
|
-
cursor: pointer;
|
|
303
|
-
font-size: 0.875rem;
|
|
304
|
-
transition: background-color 0.3s ease;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
.upload-button:hover {
|
|
308
|
-
background-color: var(--primary-color-light);
|
|
309
|
-
}
|
|
310
|
-
</style>
|