@drax/media-vue 0.7.0
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 +61 -0
- package/package.json +65 -0
- package/src/components/MediaField.vue +95 -0
- package/src/index.ts +5 -0
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# identity-front
|
|
2
|
+
|
|
3
|
+
This template should help get you started developing with Vue 3 in Vite.
|
|
4
|
+
|
|
5
|
+
## Recommended IDE Setup
|
|
6
|
+
|
|
7
|
+
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).
|
|
8
|
+
|
|
9
|
+
## Type Support for `.vue` Imports in TS
|
|
10
|
+
|
|
11
|
+
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types.
|
|
12
|
+
|
|
13
|
+
## Customize configuration
|
|
14
|
+
|
|
15
|
+
See [Vite Configuration Reference](https://vitejs.dev/config/).
|
|
16
|
+
|
|
17
|
+
## Project Setup
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npm install
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Compile and Hot-Reload for Development
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
npm run dev
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Type-Check, Compile and Minify for Production
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
npm run build
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Run Unit Tests with [Vitest](https://vitest.dev/)
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
npm run test:unit
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Run End-to-End Tests with [Cypress](https://www.cypress.io/)
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
npm run test:e2e:dev
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
This runs the end-to-end tests against the Vite development server.
|
|
48
|
+
It is much faster than the production build.
|
|
49
|
+
|
|
50
|
+
But it's still recommended to test the production build with `test:e2e` before deploying (e.g. in CI environments):
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
npm run build
|
|
54
|
+
npm run test:e2e
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Lint with [ESLint](https://eslint.org/)
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
npm run lint
|
|
61
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@drax/media-vue",
|
|
3
|
+
"publishConfig": {
|
|
4
|
+
"access": "public"
|
|
5
|
+
},
|
|
6
|
+
"version": "0.7.0",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./src/index.ts",
|
|
9
|
+
"module": "./src/index.ts",
|
|
10
|
+
"types": "./src/index.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"src"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"dev": "vite",
|
|
16
|
+
"build": "run-p type-check \"build-only {@}\" --",
|
|
17
|
+
"preview": "vite preview",
|
|
18
|
+
"test:unit": "vitest",
|
|
19
|
+
"test:e2e": "start-server-and-test preview http://localhost:4173 'cypress run --e2e'",
|
|
20
|
+
"test:e2e:dev": "start-server-and-test 'vite dev --port 4173' http://localhost:4173 'cypress open --e2e'",
|
|
21
|
+
"build-only": "vite build",
|
|
22
|
+
"type-check": "vue-tsc --build --force",
|
|
23
|
+
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
|
|
24
|
+
"format": "prettier --write src/"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@drax/media-front": "^0.7.0"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"pinia": "^2.2.2",
|
|
31
|
+
"vue": "^3.5.7",
|
|
32
|
+
"vue-i18n": "^9.14.0",
|
|
33
|
+
"vuetify": "^3.7.2"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@rushstack/eslint-patch": "^1.8.0",
|
|
37
|
+
"@tsconfig/node20": "^20.1.4",
|
|
38
|
+
"@types/jsdom": "^21.1.7",
|
|
39
|
+
"@types/node": "^20.12.5",
|
|
40
|
+
"@vitejs/plugin-vue": "^5.0.4",
|
|
41
|
+
"@vue/eslint-config-prettier": "^9.0.0",
|
|
42
|
+
"@vue/eslint-config-typescript": "^13.0.0",
|
|
43
|
+
"@vue/test-utils": "^2.4.5",
|
|
44
|
+
"@vue/tsconfig": "^0.5.1",
|
|
45
|
+
"cypress": "^13.7.2",
|
|
46
|
+
"eslint": "^8.57.0",
|
|
47
|
+
"eslint-plugin-cypress": "^2.15.1",
|
|
48
|
+
"eslint-plugin-vue": "^9.23.0",
|
|
49
|
+
"jsdom": "^24.0.0",
|
|
50
|
+
"npm-run-all2": "^6.1.2",
|
|
51
|
+
"pinia": "^2.1.7",
|
|
52
|
+
"pinia-plugin-persistedstate": "^3.2.1",
|
|
53
|
+
"prettier": "^3.2.5",
|
|
54
|
+
"start-server-and-test": "^2.0.3",
|
|
55
|
+
"typescript": "~5.4.0",
|
|
56
|
+
"vite": "^5.4.3",
|
|
57
|
+
"vite-plugin-css-injected-by-js": "^3.5.1",
|
|
58
|
+
"vite-plugin-dts": "^3.9.1",
|
|
59
|
+
"vitest": "^1.4.0",
|
|
60
|
+
"vue": "^3.5.3",
|
|
61
|
+
"vue-tsc": "^2.0.11",
|
|
62
|
+
"vuetify": "^3.7.1"
|
|
63
|
+
},
|
|
64
|
+
"gitHead": "244c1ccf07c9e3cf11486dcd013b11bcee505c6d"
|
|
65
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import {MediaSystemFactory} from "@drax/media-front"
|
|
3
|
+
import {type PropType, ref} from "vue";
|
|
4
|
+
|
|
5
|
+
const mediaSystem = MediaSystemFactory.getInstance()
|
|
6
|
+
|
|
7
|
+
const valueModel = defineModel<any>({type: [String], default: false})
|
|
8
|
+
|
|
9
|
+
const {dir} = defineProps({
|
|
10
|
+
prependIcon: {type: String, default: ''},
|
|
11
|
+
// prependInnerIcon: {type: String, default: ''},
|
|
12
|
+
appendIcon: {type: String, default: ''},
|
|
13
|
+
appendInnerIcon: {type: String, default: ''},
|
|
14
|
+
readonly: {type: Boolean, default: false},
|
|
15
|
+
hideDetails: {type: Boolean, default: false},
|
|
16
|
+
singleLine: {type: Boolean, default: false},
|
|
17
|
+
clearable: {type: Boolean, default: false},
|
|
18
|
+
disableRules: {type: Boolean, default: false},
|
|
19
|
+
parentField: {type: String, default: null, required: false},
|
|
20
|
+
index: {type: Number, default: null, required: false},
|
|
21
|
+
name: {type: String, default: 'file'},
|
|
22
|
+
dir: {type: String, default: 'files'},
|
|
23
|
+
label: {type: String, default: 'media.file'},
|
|
24
|
+
accept: {type: String, default: '*'},
|
|
25
|
+
errorMessages: {type: Array as PropType<string[]>, default: []},
|
|
26
|
+
rules: {type: Array as PropType<any>, default: []},
|
|
27
|
+
density: {type: String as PropType<'comfortable' | 'compact' | 'default'>, default: 'default'},
|
|
28
|
+
variant: {
|
|
29
|
+
type: String as PropType<'underlined' | 'outlined' | 'filled' | 'solo' | 'solo-inverted' | 'solo-filled' | 'plain'>,
|
|
30
|
+
default: 'filled'
|
|
31
|
+
},
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
let fileInput = ref()
|
|
35
|
+
|
|
36
|
+
function onFileClick() {
|
|
37
|
+
console.log('File clicked');
|
|
38
|
+
fileInput.value.click();
|
|
39
|
+
console.log('File clicked pass');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
async function onFileChanged(e: Event) {
|
|
44
|
+
if (e.target && (e.target as HTMLInputElement).files) {
|
|
45
|
+
const files = (e.target as HTMLInputElement).files;
|
|
46
|
+
if (files && files[0]) {
|
|
47
|
+
const file = await mediaSystem.uploadFile(files[0],dir);
|
|
48
|
+
valueModel.value = file.url;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
defineEmits(['updateValue'])
|
|
54
|
+
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<template>
|
|
58
|
+
<div>
|
|
59
|
+
<v-text-field
|
|
60
|
+
type="text"
|
|
61
|
+
:name="name"
|
|
62
|
+
:label="label"
|
|
63
|
+
v-model="valueModel"
|
|
64
|
+
:readonly="readonly"
|
|
65
|
+
:error-messages="errorMessages"
|
|
66
|
+
:rules="rules"
|
|
67
|
+
:density="density"
|
|
68
|
+
:variant="variant"
|
|
69
|
+
:clearable="clearable"
|
|
70
|
+
:hide-details="hideDetails"
|
|
71
|
+
:single-line="singleLine"
|
|
72
|
+
prepend-inner-icon="mdi mdi-upload-circle"
|
|
73
|
+
:append-icon="appendIcon"
|
|
74
|
+
:prepend-icon="prependIcon"
|
|
75
|
+
:append-inner-icon="appendInnerIcon"
|
|
76
|
+
@update:modelValue="$emit('updateValue')"
|
|
77
|
+
@click:prepend-inner="onFileClick"
|
|
78
|
+
>
|
|
79
|
+
|
|
80
|
+
</v-text-field>
|
|
81
|
+
|
|
82
|
+
<input
|
|
83
|
+
:accept="accept"
|
|
84
|
+
ref="fileInput"
|
|
85
|
+
class="d-none"
|
|
86
|
+
type="file"
|
|
87
|
+
@change="onFileChanged"
|
|
88
|
+
>
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
</template>
|
|
92
|
+
|
|
93
|
+
<style scoped>
|
|
94
|
+
|
|
95
|
+
</style>
|