@bexis2/bexis2-core-ui 0.0.3 → 0.0.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/.eslintignore +13 -0
- package/.eslintrc.cjs +20 -0
- package/.prettierignore +13 -0
- package/.prettierrc +9 -0
- package/package.json +36 -168
- package/playwright.config.ts +11 -0
- package/postcss.config.cjs +6 -0
- package/src/app.d.ts +11 -0
- package/src/app.html +15 -0
- package/src/app.postcss +2 -0
- package/src/index.test.ts +7 -0
- package/src/lib/components/File/FileUploader.svelte +217 -0
- package/src/lib/components/ListView.svelte +13 -0
- package/src/lib/components/Spinner/Spinner.svelte +8 -0
- package/src/lib/css/themes/theme-bexis2.css +98 -0
- package/src/lib/index.ts +19 -0
- package/src/lib/models/Models.ts +39 -0
- package/{services/Api.js → src/lib/services/Api.ts} +25 -11
- package/src/lib/stores/apistore.ts +32 -0
- package/src/routes/+layout.svelte +10 -0
- package/src/routes/+page.svelte +0 -0
- package/static/favicon.png +0 -0
- package/svelte.config.js +18 -0
- package/tailwind.config.cjs +9 -0
- package/tests/test.ts +6 -0
- package/tsconfig.json +19 -0
- package/vite.config.ts +9 -0
- package/TableView.svelte.d.ts +0 -23
- package/components/File/FileIcon.svelte.d.ts +0 -23
- package/components/File/FileInfo.svelte.d.ts +0 -27
- package/components/File/FileUploader.svelte +0 -135
- package/components/File/FileUploader.svelte.d.ts +0 -27
- package/components/ListView.svelte +0 -6
- package/components/ListView.svelte.d.ts +0 -14
- package/index.d.ts +0 -9
- package/index.js +0 -9
- package/models/Models.d.ts +0 -31
- package/models/Models.js +0 -1
- package/services/Api.d.ts +0 -7
- package/stores/apistore.d.ts +0 -4
- package/stores/apistore.js +0 -22
- /package/{TableView.svelte → src/lib/TableView.svelte} +0 -0
- /package/{components → src/lib/components}/File/FileIcon.svelte +0 -0
- /package/{components → src/lib/components}/File/FileInfo.svelte +0 -0
- /package/{css → src/lib/css}/core.ui.postcss +0 -0
- /package/{css → src/lib/css}/themes/theme-crimson.css +0 -0
- /package/{css → src/lib/css}/themes/theme-gold-nouveau.css +0 -0
- /package/{css → src/lib/css}/themes/theme-hamlindigo.css +0 -0
- /package/{css → src/lib/css}/themes/theme-modern.css +0 -0
- /package/{css → src/lib/css}/themes/theme-rocket.css +0 -0
- /package/{css → src/lib/css}/themes/theme-sahara.css +0 -0
- /package/{css → src/lib/css}/themes/theme-seafoam.css +0 -0
- /package/{css → src/lib/css}/themes/theme-seasonal.css +0 -0
- /package/{css → src/lib/css}/themes/theme-skeleton.css +0 -0
- /package/{css → src/lib/css}/themes/theme-vintage.css +0 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
/* =~= Theme Properties =~= */
|
|
3
|
+
--theme-font-family-base: system-ui;
|
|
4
|
+
--theme-font-family-heading: system-ui;
|
|
5
|
+
--theme-font-color-base: 0 0 0;
|
|
6
|
+
--theme-font-color-dark: 255 255 255;
|
|
7
|
+
--theme-rounded-base: 4px;
|
|
8
|
+
--theme-rounded-container: 4px;
|
|
9
|
+
--theme-border-base: 1px;
|
|
10
|
+
/* =~= Theme On-X Colors =~= */
|
|
11
|
+
--on-primary: 0 0 0;
|
|
12
|
+
--on-secondary: 0 0 0;
|
|
13
|
+
--on-tertiary: 0 0 0;
|
|
14
|
+
--on-success: 0 0 0;
|
|
15
|
+
--on-warning: 255 255 255;
|
|
16
|
+
--on-error: 255 255 255;
|
|
17
|
+
--on-surface: 0 0 0;
|
|
18
|
+
/* =~= Theme Colors =~= */
|
|
19
|
+
/* primary | #45b2a1 */
|
|
20
|
+
--color-primary-50: 227 243 241; /* ⬅ #e3f3f1 */
|
|
21
|
+
--color-primary-100: 218 240 236; /* ⬅ #daf0ec */
|
|
22
|
+
--color-primary-200: 209 236 232; /* ⬅ #d1ece8 */
|
|
23
|
+
--color-primary-300: 181 224 217; /* ⬅ #b5e0d9 */
|
|
24
|
+
--color-primary-400: 125 201 189; /* ⬅ #7dc9bd */
|
|
25
|
+
--color-primary-500: 69 178 161; /* ⬅ #45b2a1 */
|
|
26
|
+
--color-primary-600: 62 160 145; /* ⬅ #3ea091 */
|
|
27
|
+
--color-primary-700: 52 134 121; /* ⬅ #348679 */
|
|
28
|
+
--color-primary-800: 41 107 97; /* ⬅ #296b61 */
|
|
29
|
+
--color-primary-900: 34 87 79; /* ⬅ #22574f */
|
|
30
|
+
/* secondary | #ff9700 */
|
|
31
|
+
--color-secondary-50: 255 239 217; /* ⬅ #ffefd9 */
|
|
32
|
+
--color-secondary-100: 255 234 204; /* ⬅ #ffeacc */
|
|
33
|
+
--color-secondary-200: 255 229 191; /* ⬅ #ffe5bf */
|
|
34
|
+
--color-secondary-300: 255 213 153; /* ⬅ #ffd599 */
|
|
35
|
+
--color-secondary-400: 255 182 77; /* ⬅ #ffb64d */
|
|
36
|
+
--color-secondary-500: 255 151 0; /* ⬅ #ff9700 */
|
|
37
|
+
--color-secondary-600: 230 136 0; /* ⬅ #e68800 */
|
|
38
|
+
--color-secondary-700: 191 113 0; /* ⬅ #bf7100 */
|
|
39
|
+
--color-secondary-800: 153 91 0; /* ⬅ #995b00 */
|
|
40
|
+
--color-secondary-900: 125 74 0; /* ⬅ #7d4a00 */
|
|
41
|
+
/* tertiary | #bee1da */
|
|
42
|
+
--color-tertiary-50: 245 251 249; /* ⬅ #f5fbf9 */
|
|
43
|
+
--color-tertiary-100: 242 249 248; /* ⬅ #f2f9f8 */
|
|
44
|
+
--color-tertiary-200: 239 248 246; /* ⬅ #eff8f6 */
|
|
45
|
+
--color-tertiary-300: 229 243 240; /* ⬅ #e5f3f0 */
|
|
46
|
+
--color-tertiary-400: 210 234 229; /* ⬅ #d2eae5 */
|
|
47
|
+
--color-tertiary-500: 190 225 218; /* ⬅ #bee1da */
|
|
48
|
+
--color-tertiary-600: 171 203 196; /* ⬅ #abcbc4 */
|
|
49
|
+
--color-tertiary-700: 143 169 164; /* ⬅ #8fa9a4 */
|
|
50
|
+
--color-tertiary-800: 114 135 131; /* ⬅ #728783 */
|
|
51
|
+
--color-tertiary-900: 93 110 107; /* ⬅ #5d6e6b */
|
|
52
|
+
/* success | #4BB543 */
|
|
53
|
+
--color-success-50: 228 244 227; /* ⬅ #e4f4e3 */
|
|
54
|
+
--color-success-100: 219 240 217; /* ⬅ #dbf0d9 */
|
|
55
|
+
--color-success-200: 210 237 208; /* ⬅ #d2edd0 */
|
|
56
|
+
--color-success-300: 183 225 180; /* ⬅ #b7e1b4 */
|
|
57
|
+
--color-success-400: 129 203 123; /* ⬅ #81cb7b */
|
|
58
|
+
--color-success-500: 75 181 67; /* ⬅ #4BB543 */
|
|
59
|
+
--color-success-600: 68 163 60; /* ⬅ #44a33c */
|
|
60
|
+
--color-success-700: 56 136 50; /* ⬅ #388832 */
|
|
61
|
+
--color-success-800: 45 109 40; /* ⬅ #2d6d28 */
|
|
62
|
+
--color-success-900: 37 89 33; /* ⬅ #255921 */
|
|
63
|
+
/* warning | #ef4444 */
|
|
64
|
+
--color-warning-50: 253 227 227; /* ⬅ #fde3e3 */
|
|
65
|
+
--color-warning-100: 252 218 218; /* ⬅ #fcdada */
|
|
66
|
+
--color-warning-200: 251 208 208; /* ⬅ #fbd0d0 */
|
|
67
|
+
--color-warning-300: 249 180 180; /* ⬅ #f9b4b4 */
|
|
68
|
+
--color-warning-400: 244 124 124; /* ⬅ #f47c7c */
|
|
69
|
+
--color-warning-500: 239 68 68; /* ⬅ #ef4444 */
|
|
70
|
+
--color-warning-600: 215 61 61; /* ⬅ #d73d3d */
|
|
71
|
+
--color-warning-700: 179 51 51; /* ⬅ #b33333 */
|
|
72
|
+
--color-warning-800: 143 41 41; /* ⬅ #8f2929 */
|
|
73
|
+
--color-warning-900: 117 33 33; /* ⬅ #752121 */
|
|
74
|
+
/* error | #FF0000 */
|
|
75
|
+
--color-error-50: 255 217 217; /* ⬅ #ffd9d9 */
|
|
76
|
+
--color-error-100: 255 204 204; /* ⬅ #ffcccc */
|
|
77
|
+
--color-error-200: 255 191 191; /* ⬅ #ffbfbf */
|
|
78
|
+
--color-error-300: 255 153 153; /* ⬅ #ff9999 */
|
|
79
|
+
--color-error-400: 255 77 77; /* ⬅ #ff4d4d */
|
|
80
|
+
--color-error-500: 255 0 0; /* ⬅ #FF0000 */
|
|
81
|
+
--color-error-600: 230 0 0; /* ⬅ #e60000 */
|
|
82
|
+
--color-error-700: 191 0 0; /* ⬅ #bf0000 */
|
|
83
|
+
--color-error-800: 153 0 0; /* ⬅ #990000 */
|
|
84
|
+
--color-error-900: 125 0 0; /* ⬅ #7d0000 */
|
|
85
|
+
/* surface | #FFFFFF */
|
|
86
|
+
--color-surface-50: 255 255 255; /* ⬅ #ffffff */
|
|
87
|
+
--color-surface-100: 255 255 255; /* ⬅ #ffffff */
|
|
88
|
+
--color-surface-200: 255 255 255; /* ⬅ #ffffff */
|
|
89
|
+
--color-surface-300: 255 255 255; /* ⬅ #ffffff */
|
|
90
|
+
--color-surface-400: 255 255 255; /* ⬅ #ffffff */
|
|
91
|
+
--color-surface-500: 255 255 255; /* ⬅ #FFFFFF */
|
|
92
|
+
--color-surface-600: 230 230 230; /* ⬅ #e6e6e6 */
|
|
93
|
+
--color-surface-700: 191 191 191; /* ⬅ #bfbfbf */
|
|
94
|
+
/* dark mode surface | #1f2937 */
|
|
95
|
+
--color-surface-800: 19 25 33; /* ⬅ #131921 */
|
|
96
|
+
--color-surface-900: 15 20 27; /* ⬅ #0f141b */
|
|
97
|
+
|
|
98
|
+
}
|
package/src/lib/index.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
// Reexport your entry components here
|
|
3
|
+
import ListView from './components/ListView.svelte'
|
|
4
|
+
|
|
5
|
+
import TableView from './TableView.svelte'
|
|
6
|
+
import FileIcon from './components/File/FileIcon.svelte'
|
|
7
|
+
import FileInfo from './components/File/FileInfo.svelte'
|
|
8
|
+
import FileUploader from './components/File/FileUploader.svelte'
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export {ListView,TableView, FileInfo, FileIcon, FileUploader }
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export {Api} from './services/Api.js'
|
|
16
|
+
export {host,username,password,setApiConfig} from './stores/apistore.js'
|
|
17
|
+
|
|
18
|
+
export type {user, FileUploaderModel} from './models/Models.js'
|
|
19
|
+
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
|
|
2
|
+
export interface FileInfo {
|
|
3
|
+
name:string,
|
|
4
|
+
type:string,
|
|
5
|
+
lenght:number,
|
|
6
|
+
description:string,
|
|
7
|
+
validationHash:string,
|
|
8
|
+
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export interface FileUploaderModel{
|
|
13
|
+
accept:string[],
|
|
14
|
+
existingFiles:FileInfo[],
|
|
15
|
+
descriptionType:number,
|
|
16
|
+
multiple:boolean,
|
|
17
|
+
maxSize:number,
|
|
18
|
+
lastModification:Date
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface Files {
|
|
22
|
+
accepted:Blob[],
|
|
23
|
+
rejected:Blob[]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
export type user = {
|
|
28
|
+
name:string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface FileObj{
|
|
32
|
+
path:string,
|
|
33
|
+
lastModified:number,
|
|
34
|
+
lastModifiedDate:Date,
|
|
35
|
+
name:string,
|
|
36
|
+
size:number,
|
|
37
|
+
type:string,
|
|
38
|
+
webkitRelativePath:string
|
|
39
|
+
}
|
|
@@ -1,44 +1,58 @@
|
|
|
1
1
|
// Api.js
|
|
2
2
|
import axios from "axios";
|
|
3
3
|
import { host, username, password } from "../stores/apistore";
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
console.log("setup axios")
|
|
6
|
+
|
|
7
|
+
|
|
5
8
|
// implement a method to execute all the request from here.
|
|
6
9
|
const apiRequest = (method, url, request) => {
|
|
10
|
+
|
|
11
|
+
|
|
7
12
|
// Create a instance of axios to use the same base url.
|
|
8
13
|
const axiosAPI = axios.create({
|
|
9
|
-
|
|
14
|
+
baseURL : host
|
|
10
15
|
});
|
|
16
|
+
|
|
11
17
|
const headers = {
|
|
12
18
|
authorization: 'Basic ' + btoa(username + ":" + password)
|
|
13
19
|
};
|
|
20
|
+
|
|
14
21
|
//using the axios instance to perform the request that received from each http method
|
|
15
22
|
return axiosAPI({
|
|
16
23
|
method,
|
|
17
24
|
url,
|
|
18
25
|
data: request,
|
|
19
26
|
headers
|
|
20
|
-
|
|
27
|
+
}).then(res => {
|
|
28
|
+
|
|
21
29
|
return Promise.resolve(res);
|
|
22
|
-
|
|
23
|
-
|
|
30
|
+
})
|
|
31
|
+
.catch(err => {
|
|
24
32
|
return Promise.reject(err);
|
|
25
|
-
|
|
33
|
+
});
|
|
26
34
|
};
|
|
35
|
+
|
|
27
36
|
// function to execute the http get request
|
|
28
|
-
const get = (url, request
|
|
37
|
+
const get = (url, request="") => apiRequest("get",url,request);
|
|
38
|
+
|
|
29
39
|
// function to execute the http delete request
|
|
30
|
-
const deleteRequest = (url, request) =>
|
|
40
|
+
const deleteRequest = (url, request) => apiRequest("delete", url, request);
|
|
41
|
+
|
|
31
42
|
// function to execute the http post request
|
|
32
43
|
const post = (url, request) => apiRequest("post", url, request);
|
|
44
|
+
|
|
33
45
|
// function to execute the http put request
|
|
34
46
|
const put = (url, request) => apiRequest("put", url, request);
|
|
47
|
+
|
|
35
48
|
// function to execute the http path request
|
|
36
|
-
const patch = (url, request) =>
|
|
49
|
+
const patch = (url, request) => apiRequest("patch", url, request);
|
|
50
|
+
|
|
37
51
|
// expose your method to other services or actions
|
|
38
|
-
export const Api =
|
|
52
|
+
export const Api ={
|
|
39
53
|
get,
|
|
40
54
|
delete: deleteRequest,
|
|
41
55
|
post,
|
|
42
56
|
put,
|
|
43
57
|
patch
|
|
44
|
-
};
|
|
58
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { writable } from 'svelte/store'
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export let host = "window.location.origin";
|
|
5
|
+
export let username = "";
|
|
6
|
+
export let password = "";
|
|
7
|
+
|
|
8
|
+
const hostStore = writable(""); //writable(window.location.origin);
|
|
9
|
+
const usernameStore = writable("");
|
|
10
|
+
const passwordStore = writable("");
|
|
11
|
+
|
|
12
|
+
hostStore.subscribe(value => {
|
|
13
|
+
host = value;
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
usernameStore.subscribe(value => {
|
|
17
|
+
username = value;
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
passwordStore.subscribe(value => {
|
|
21
|
+
password = value;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
export function setApiConfig(_host:string ,_user:string,_pw:string)
|
|
27
|
+
{
|
|
28
|
+
console.log("overwrite settings");
|
|
29
|
+
hostStore.update(h=>h = _host);
|
|
30
|
+
usernameStore.update(u=>u = _user);
|
|
31
|
+
passwordStore.update(p=>p = _pw);
|
|
32
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script lang='ts'>
|
|
2
|
+
// The ordering of these imports is critical to your app working properly
|
|
3
|
+
import '@skeletonlabs/skeleton/themes/theme-skeleton.css';
|
|
4
|
+
// If you have source.organizeImports set to true in VSCode, then it will auto change this ordering
|
|
5
|
+
import '@skeletonlabs/skeleton/styles/all.css';
|
|
6
|
+
// Most of your app wide CSS should be put in this file
|
|
7
|
+
import '../app.postcss';
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<slot />
|
|
File without changes
|
|
Binary file
|
package/svelte.config.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import adapter from '@sveltejs/adapter-auto';
|
|
2
|
+
import { vitePreprocess } from '@sveltejs/kit/vite';
|
|
3
|
+
|
|
4
|
+
/** @type {import('@sveltejs/kit').Config} */
|
|
5
|
+
const config = {
|
|
6
|
+
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
|
|
7
|
+
// for more information about preprocessors
|
|
8
|
+
preprocess: vitePreprocess(),
|
|
9
|
+
|
|
10
|
+
kit: {
|
|
11
|
+
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
|
|
12
|
+
// If your environment is not supported or you settled on a specific environment, switch out the adapter.
|
|
13
|
+
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
|
|
14
|
+
adapter: adapter()
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default config;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** @type {import('tailwindcss').Config} */
|
|
2
|
+
module.exports = {
|
|
3
|
+
darkMode: 'class',
|
|
4
|
+
content: ['./src/**/*.{html,js,svelte,ts}', require('path').join(require.resolve('@skeletonlabs/skeleton'), '../**/*.{html,js,svelte,ts}')],
|
|
5
|
+
theme: {
|
|
6
|
+
extend: {},
|
|
7
|
+
},
|
|
8
|
+
plugins: [...require('@skeletonlabs/skeleton/tailwind/skeleton.cjs')()],
|
|
9
|
+
}
|
package/tests/test.ts
ADDED
package/tsconfig.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./.svelte-kit/tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"allowJs": true,
|
|
5
|
+
"checkJs": true,
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"forceConsistentCasingInFileNames": true,
|
|
8
|
+
"resolveJsonModule": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"sourceMap": true,
|
|
11
|
+
"strict": true,
|
|
12
|
+
"noImplicitAny": false
|
|
13
|
+
},
|
|
14
|
+
"exclude": ["node_modules"]
|
|
15
|
+
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
|
|
16
|
+
//
|
|
17
|
+
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
|
|
18
|
+
// from the referenced tsconfig.json - TypeScript does not merge them in
|
|
19
|
+
}
|
package/vite.config.ts
ADDED
package/TableView.svelte.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/** @typedef {typeof __propDef.props} TableViewProps */
|
|
2
|
-
/** @typedef {typeof __propDef.events} TableViewEvents */
|
|
3
|
-
/** @typedef {typeof __propDef.slots} TableViewSlots */
|
|
4
|
-
export default class TableView extends SvelteComponentTyped<{
|
|
5
|
-
[x: string]: never;
|
|
6
|
-
}, {
|
|
7
|
-
[evt: string]: CustomEvent<any>;
|
|
8
|
-
}, {}> {
|
|
9
|
-
}
|
|
10
|
-
export type TableViewProps = typeof __propDef.props;
|
|
11
|
-
export type TableViewEvents = typeof __propDef.events;
|
|
12
|
-
export type TableViewSlots = typeof __propDef.slots;
|
|
13
|
-
import { SvelteComponentTyped } from "svelte";
|
|
14
|
-
declare const __propDef: {
|
|
15
|
-
props: {
|
|
16
|
-
[x: string]: never;
|
|
17
|
-
};
|
|
18
|
-
events: {
|
|
19
|
-
[evt: string]: CustomEvent<any>;
|
|
20
|
-
};
|
|
21
|
-
slots: {};
|
|
22
|
-
};
|
|
23
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/** @typedef {typeof __propDef.props} FileIconProps */
|
|
2
|
-
/** @typedef {typeof __propDef.events} FileIconEvents */
|
|
3
|
-
/** @typedef {typeof __propDef.slots} FileIconSlots */
|
|
4
|
-
export default class FileIcon extends SvelteComponentTyped<{
|
|
5
|
-
type?: string | undefined;
|
|
6
|
-
}, {
|
|
7
|
-
[evt: string]: CustomEvent<any>;
|
|
8
|
-
}, {}> {
|
|
9
|
-
}
|
|
10
|
-
export type FileIconProps = typeof __propDef.props;
|
|
11
|
-
export type FileIconEvents = typeof __propDef.events;
|
|
12
|
-
export type FileIconSlots = typeof __propDef.slots;
|
|
13
|
-
import { SvelteComponentTyped } from "svelte";
|
|
14
|
-
declare const __propDef: {
|
|
15
|
-
props: {
|
|
16
|
-
type?: string | undefined;
|
|
17
|
-
};
|
|
18
|
-
events: {
|
|
19
|
-
[evt: string]: CustomEvent<any>;
|
|
20
|
-
};
|
|
21
|
-
slots: {};
|
|
22
|
-
};
|
|
23
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/** @typedef {typeof __propDef.props} FileInfoProps */
|
|
2
|
-
/** @typedef {typeof __propDef.events} FileInfoEvents */
|
|
3
|
-
/** @typedef {typeof __propDef.slots} FileInfoSlots */
|
|
4
|
-
export default class FileInfo extends SvelteComponentTyped<{
|
|
5
|
-
type?: string | undefined;
|
|
6
|
-
name?: string | undefined;
|
|
7
|
-
size?: string | undefined;
|
|
8
|
-
}, {
|
|
9
|
-
[evt: string]: CustomEvent<any>;
|
|
10
|
-
}, {}> {
|
|
11
|
-
}
|
|
12
|
-
export type FileInfoProps = typeof __propDef.props;
|
|
13
|
-
export type FileInfoEvents = typeof __propDef.events;
|
|
14
|
-
export type FileInfoSlots = typeof __propDef.slots;
|
|
15
|
-
import { SvelteComponentTyped } from "svelte";
|
|
16
|
-
declare const __propDef: {
|
|
17
|
-
props: {
|
|
18
|
-
type?: string | undefined;
|
|
19
|
-
name?: string | undefined;
|
|
20
|
-
size?: string | undefined;
|
|
21
|
-
};
|
|
22
|
-
events: {
|
|
23
|
-
[evt: string]: CustomEvent<any>;
|
|
24
|
-
};
|
|
25
|
-
slots: {};
|
|
26
|
-
};
|
|
27
|
-
export {};
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
<script >import DropZone from "svelte-file-dropzone/src/index";
|
|
2
|
-
import { Fa } from "svelte-fa/src/index.js";
|
|
3
|
-
import { Spinner, Button, Row, Col, Input } from "sveltestrap";
|
|
4
|
-
import { createEventDispatcher } from "svelte";
|
|
5
|
-
import { faTrash } from "@fortawesome/free-solid-svg-icons";
|
|
6
|
-
import { faSave } from "@fortawesome/free-regular-svg-icons";
|
|
7
|
-
import { faFileUpload } from "@fortawesome/free-solid-svg-icons";
|
|
8
|
-
import { Api } from "../../services/Api.js";
|
|
9
|
-
export let id = 0;
|
|
10
|
-
export let version = 1;
|
|
11
|
-
import { onMount } from "svelte";
|
|
12
|
-
export let start = "";
|
|
13
|
-
export let submit = "";
|
|
14
|
-
export let context = "";
|
|
15
|
-
export let data;
|
|
16
|
-
$:
|
|
17
|
-
model = data;
|
|
18
|
-
$:
|
|
19
|
-
submitBt = "submit";
|
|
20
|
-
let maxSize = 0;
|
|
21
|
-
const dispatch = createEventDispatcher();
|
|
22
|
-
let fx;
|
|
23
|
-
let files = { accepted: [], rejected: [] };
|
|
24
|
-
$:
|
|
25
|
-
files;
|
|
26
|
-
onMount(async () => {
|
|
27
|
-
console.log("fileupload - OnMount", data);
|
|
28
|
-
if (!data) {
|
|
29
|
-
load();
|
|
30
|
-
} else {
|
|
31
|
-
model = data;
|
|
32
|
-
}
|
|
33
|
-
if (model) {
|
|
34
|
-
submitBt += context;
|
|
35
|
-
maxSize = model.maxSize * 1024 * 1024;
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
async function load() {
|
|
39
|
-
let url = start + "?id=" + id + "&version=" + version;
|
|
40
|
-
const res = await Api.get(url);
|
|
41
|
-
model = await res.json();
|
|
42
|
-
console.log("fileupload", model);
|
|
43
|
-
}
|
|
44
|
-
function handleFilesSelect(e) {
|
|
45
|
-
console.log("handleFilesSelect", e);
|
|
46
|
-
console.log("files", files);
|
|
47
|
-
const { acceptedFiles, fileRejections } = e.detail;
|
|
48
|
-
files.accepted = [...files.accepted, ...acceptedFiles];
|
|
49
|
-
files.rejected = [...files.rejected, ...fileRejections];
|
|
50
|
-
console.log("acceptedFiles", acceptedFiles);
|
|
51
|
-
console.log("files.accepted", files.accepted);
|
|
52
|
-
if (fileRejections.length > 0) {
|
|
53
|
-
console.log("the dropped file is not supported.");
|
|
54
|
-
console.log(files.rejected);
|
|
55
|
-
let messages = [""];
|
|
56
|
-
for (let index = 0; index < fileRejections.length; index++) {
|
|
57
|
-
const element = fileRejections[index];
|
|
58
|
-
messages.push(getErrorMessage(element));
|
|
59
|
-
}
|
|
60
|
-
console.log(messages);
|
|
61
|
-
dispatch("error", { messages });
|
|
62
|
-
files.rejected = [];
|
|
63
|
-
}
|
|
64
|
-
if (acceptedFiles.length > 0) {
|
|
65
|
-
document.getElementById(submitBt)?.click();
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function getErrorMessage(rejected) {
|
|
69
|
-
let message = "";
|
|
70
|
-
message = rejected.file.path + " : ";
|
|
71
|
-
let errors = rejected.errors;
|
|
72
|
-
for (let index = 0; index < errors.length; index++) {
|
|
73
|
-
const error = errors[index];
|
|
74
|
-
message += error.message;
|
|
75
|
-
}
|
|
76
|
-
return message;
|
|
77
|
-
}
|
|
78
|
-
async function handleSubmit() {
|
|
79
|
-
console.log("SUBMIT");
|
|
80
|
-
dispatch("submit");
|
|
81
|
-
let url = submit + "?id=" + id;
|
|
82
|
-
console.log("SUBMIT");
|
|
83
|
-
if (files.accepted.length > 0) {
|
|
84
|
-
console.log(files);
|
|
85
|
-
const formData = new FormData();
|
|
86
|
-
formData.append("files", "123");
|
|
87
|
-
for (var i = 0; i < files.accepted.length; i++) {
|
|
88
|
-
formData.append(files.accepted[i].name, files.accepted[i]);
|
|
89
|
-
}
|
|
90
|
-
const response = await Api.post(url, formData);
|
|
91
|
-
if (response.status == 200) {
|
|
92
|
-
dispatch("submited");
|
|
93
|
-
let message = files.accepted.length + " is/are uploaded";
|
|
94
|
-
dispatch("success", { text: message });
|
|
95
|
-
files.accepted = [];
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
</script>
|
|
100
|
-
|
|
101
|
-
<form on:submit|preventDefault={handleSubmit}>
|
|
102
|
-
{#if model}
|
|
103
|
-
<!--if model exist -->
|
|
104
|
-
<Row>
|
|
105
|
-
|
|
106
|
-
<DropZone
|
|
107
|
-
on:drop={handleFilesSelect}
|
|
108
|
-
accept={model.accept}
|
|
109
|
-
multiple={model.multiple}
|
|
110
|
-
{maxSize}>
|
|
111
|
-
|
|
112
|
-
<b style="font-size:xx-large"><Fa icon={faFileUpload}/></b>
|
|
113
|
-
<span><b>Drag 'n' drop some files here, or click to select files</b>
|
|
114
|
-
<b>max file : {model.maxSize} mb</b></span>
|
|
115
|
-
<p>
|
|
116
|
-
{#if model.accept}
|
|
117
|
-
{#each model.accept as ext}
|
|
118
|
-
{ext} ,
|
|
119
|
-
{/each}
|
|
120
|
-
{/if}
|
|
121
|
-
</p>
|
|
122
|
-
</DropZone>
|
|
123
|
-
|
|
124
|
-
</Row>
|
|
125
|
-
|
|
126
|
-
<Button id="{submitBt}" color="primary" style="display:none" ><Fa icon={faSave}/></Button>
|
|
127
|
-
|
|
128
|
-
{:else} <!-- while data is not loaded show a loading information -->
|
|
129
|
-
|
|
130
|
-
<Spinner color="info" size="sm" type ="grow" />
|
|
131
|
-
{/if}
|
|
132
|
-
|
|
133
|
-
</form>
|
|
134
|
-
|
|
135
|
-
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type { FileUploaderModel } from '../../models/Models.js';
|
|
3
|
-
declare const __propDef: {
|
|
4
|
-
props: {
|
|
5
|
-
id?: number | undefined;
|
|
6
|
-
version?: number | undefined;
|
|
7
|
-
start?: string | undefined;
|
|
8
|
-
submit?: string | undefined;
|
|
9
|
-
context?: string | undefined;
|
|
10
|
-
data: FileUploaderModel | undefined;
|
|
11
|
-
};
|
|
12
|
-
events: {
|
|
13
|
-
error: CustomEvent<any>;
|
|
14
|
-
submit: CustomEvent<any>;
|
|
15
|
-
submited: CustomEvent<any>;
|
|
16
|
-
success: CustomEvent<any>;
|
|
17
|
-
} & {
|
|
18
|
-
[evt: string]: CustomEvent<any>;
|
|
19
|
-
};
|
|
20
|
-
slots: {};
|
|
21
|
-
};
|
|
22
|
-
export type FileUploaderProps = typeof __propDef.props;
|
|
23
|
-
export type FileUploaderEvents = typeof __propDef.events;
|
|
24
|
-
export type FileUploaderSlots = typeof __propDef.slots;
|
|
25
|
-
export default class FileUploader extends SvelteComponentTyped<FileUploaderProps, FileUploaderEvents, FileUploaderSlots> {
|
|
26
|
-
}
|
|
27
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
declare const __propDef: {
|
|
3
|
-
props: Record<string, never>;
|
|
4
|
-
events: {
|
|
5
|
-
[evt: string]: CustomEvent<any>;
|
|
6
|
-
};
|
|
7
|
-
slots: {};
|
|
8
|
-
};
|
|
9
|
-
export type ListViewProps = typeof __propDef.props;
|
|
10
|
-
export type ListViewEvents = typeof __propDef.events;
|
|
11
|
-
export type ListViewSlots = typeof __propDef.slots;
|
|
12
|
-
export default class ListView extends SvelteComponentTyped<ListViewProps, ListViewEvents, ListViewSlots> {
|
|
13
|
-
}
|
|
14
|
-
export {};
|
package/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import ListView from './components/ListView.svelte';
|
|
2
|
-
import TableView from './TableView.svelte';
|
|
3
|
-
import FileIcon from './components/File/FileIcon.svelte';
|
|
4
|
-
import FileInfo from './components/File/FileInfo.svelte';
|
|
5
|
-
import FileUploader from './components/File/FileUploader.svelte';
|
|
6
|
-
export { ListView, TableView, FileInfo, FileIcon, FileUploader };
|
|
7
|
-
export { Api } from './services/Api.js';
|
|
8
|
-
export { host, username, password, setApiConfig } from './stores/apistore.js';
|
|
9
|
-
export type { user, FileUploaderModel } from './models/Models.js';
|
package/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// Reexport your entry components here
|
|
2
|
-
import ListView from './components/ListView.svelte';
|
|
3
|
-
import TableView from './TableView.svelte';
|
|
4
|
-
import FileIcon from './components/File/FileIcon.svelte';
|
|
5
|
-
import FileInfo from './components/File/FileInfo.svelte';
|
|
6
|
-
import FileUploader from './components/File/FileUploader.svelte';
|
|
7
|
-
export { ListView, TableView, FileInfo, FileIcon, FileUploader };
|
|
8
|
-
export { Api } from './services/Api.js';
|
|
9
|
-
export { host, username, password, setApiConfig } from './stores/apistore.js';
|
package/models/Models.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export interface FileInfo {
|
|
2
|
-
name: string;
|
|
3
|
-
type: string;
|
|
4
|
-
lenght: number;
|
|
5
|
-
description: string;
|
|
6
|
-
validationHash: string;
|
|
7
|
-
}
|
|
8
|
-
export interface FileUploaderModel {
|
|
9
|
-
accept: string[];
|
|
10
|
-
existingFiles: FileInfo[];
|
|
11
|
-
descriptionType: number;
|
|
12
|
-
multiple: boolean;
|
|
13
|
-
maxSize: number;
|
|
14
|
-
lastModification: Date;
|
|
15
|
-
}
|
|
16
|
-
export interface Files {
|
|
17
|
-
accepted: Blob[];
|
|
18
|
-
rejected: Blob[];
|
|
19
|
-
}
|
|
20
|
-
export type user = {
|
|
21
|
-
name: string;
|
|
22
|
-
};
|
|
23
|
-
export interface FileObj {
|
|
24
|
-
path: string;
|
|
25
|
-
lastModified: number;
|
|
26
|
-
lastModifiedDate: Date;
|
|
27
|
-
name: string;
|
|
28
|
-
size: number;
|
|
29
|
-
type: string;
|
|
30
|
-
webkitRelativePath: string;
|
|
31
|
-
}
|
package/models/Models.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|