@sierra-95/svelte-scaffold 1.2.0 → 1.2.2
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/dist/Core/components/Form/Button/default/button.svelte.d.ts +1 -1
- package/dist/{Modules/FilePicker/Cloud/storage.svelte → Core/components/others/Progress/StorageGauge/storagegauge.svelte} +5 -5
- package/dist/{Modules/FilePicker/Cloud/storage.svelte.d.ts → Core/components/others/Progress/StorageGauge/storagegauge.svelte.d.ts} +5 -7
- package/dist/Modules/Editor/Nodes/Images/images.svelte +18 -17
- package/dist/Modules/FilePicker/Actions/delete.svelte +3 -3
- package/dist/Modules/FilePicker/Actions/download.svelte +2 -2
- package/dist/Modules/FilePicker/Actions/properties.svelte +3 -3
- package/dist/Modules/FilePicker/Cloud/cloudStore.svelte +3 -4
- package/dist/Modules/FilePicker/Cloud/content.svelte +3 -3
- package/dist/Modules/FilePicker/Upload/upload.svelte +3 -3
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/stores/modules/editor.d.ts +7 -5
- package/dist/stores/modules/editor.js +9 -5
- package/dist/stores/modules/fileInput.d.ts +5 -3
- package/dist/stores/modules/fileInput.js +8 -4
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
declare const Button: import("svelte").Component<{
|
|
2
2
|
variant?: "contained" | "outlined";
|
|
3
|
-
color?: "none" | "
|
|
3
|
+
color?: "none" | "warning" | "error" | "primary";
|
|
4
4
|
type?: "button" | "submit" | "reset";
|
|
5
5
|
title?: string;
|
|
6
6
|
pill?: boolean;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { onMount } from 'svelte';
|
|
3
|
-
import {
|
|
3
|
+
import { fileInputConfig,CustomProgress, addToast} from '../../../../../index.js';
|
|
4
4
|
|
|
5
5
|
let {
|
|
6
6
|
padding = "0.5rem",
|
|
7
7
|
width = "100%",
|
|
8
|
-
|
|
8
|
+
...rest
|
|
9
9
|
} = $props()
|
|
10
10
|
|
|
11
11
|
let progress = $state(0);
|
|
12
12
|
let progressColor = $state("var(--primary-bg)");
|
|
13
13
|
|
|
14
14
|
onMount(()=>{
|
|
15
|
-
if(!$
|
|
15
|
+
if(!$fileInputConfig.usedBytes || !$fileInputConfig.maxBytes){
|
|
16
16
|
addToast({
|
|
17
17
|
status: 'warning',
|
|
18
18
|
message: 'Unable to calculate storage usage. Please configure your cloud storage settings.',
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
});
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
|
-
progress = ($
|
|
23
|
+
progress = ($fileInputConfig.usedBytes / $fileInputConfig.maxBytes) * 100;
|
|
24
24
|
})
|
|
25
25
|
$effect(()=>{
|
|
26
26
|
if(progress){
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
</script>
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
<div
|
|
37
|
+
<div {...rest} style="padding: 0.5rem {padding}; width: {width};">
|
|
38
38
|
<CustomProgress value={progress} color={progressColor}/>
|
|
39
39
|
<h3 style="font-size: 0.8rem;">{progress.toFixed(2)}% of 100 MB</h3>
|
|
40
40
|
</div>
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
export default
|
|
2
|
-
type
|
|
1
|
+
export default Storagegauge;
|
|
2
|
+
type Storagegauge = {
|
|
3
3
|
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
4
|
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
5
|
};
|
|
6
|
-
declare const
|
|
6
|
+
declare const Storagegauge: import("svelte").Component<{
|
|
7
7
|
padding?: string;
|
|
8
8
|
width?: string;
|
|
9
|
-
|
|
10
|
-
}, {}, "forceRender">;
|
|
9
|
+
} & Record<string, any>, {}, "">;
|
|
11
10
|
type $$ComponentProps = {
|
|
12
11
|
padding?: string;
|
|
13
12
|
width?: string;
|
|
14
|
-
|
|
15
|
-
};
|
|
13
|
+
} & Record<string, any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { insertImageAndMoveCursor } from '../../tools.js';
|
|
3
|
-
import {fileInputStore, resetFileInputStore, editorStore, modalStore, Input, DropdownContainer, MenuItem, addToast} from '../../../../index.js';
|
|
3
|
+
import {fileInputStore, fileInputConfig,resetFileInputStore, editorStore,editorConfig, modalStore, Input, DropdownContainer, MenuItem, addToast} from '../../../../index.js';
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
import type { Editor } from "@tiptap/core";
|
|
@@ -9,11 +9,10 @@
|
|
|
9
9
|
let openDropdown = false;
|
|
10
10
|
function handleInsertImage(){
|
|
11
11
|
if(
|
|
12
|
-
!$
|
|
13
|
-
!$
|
|
14
|
-
!$
|
|
15
|
-
!$
|
|
16
|
-
!$editorStore.serverDownloadUrl
|
|
12
|
+
!$editorConfig.serverGetUrl ||
|
|
13
|
+
!$editorConfig.serverUploadUrl ||
|
|
14
|
+
!$editorConfig.serverDeleteUrl ||
|
|
15
|
+
!$editorConfig.serverDownloadUrl
|
|
17
16
|
){
|
|
18
17
|
addToast({
|
|
19
18
|
status: 'error',
|
|
@@ -22,17 +21,19 @@
|
|
|
22
21
|
});
|
|
23
22
|
return;
|
|
24
23
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
24
|
+
fileInputConfig.update(config => {
|
|
25
|
+
config.serverGetUrl = $editorConfig.serverGetUrl;
|
|
26
|
+
config.serverUploadUrl = $editorConfig.serverUploadUrl;
|
|
27
|
+
config.serverDeleteUrl = $editorConfig.serverDeleteUrl;
|
|
28
|
+
config.serverDownloadUrl = $editorConfig.serverDownloadUrl;
|
|
29
|
+
return config;
|
|
30
|
+
});
|
|
31
|
+
fileInputStore.update(store => {
|
|
32
|
+
store.uploadType = ['image'];
|
|
33
|
+
store.disabledMenuItem = ['Music', 'Videos', 'Documents', 'Others'];
|
|
34
|
+
store.uploadModalOpen = true;
|
|
35
|
+
return store;
|
|
36
|
+
});
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
$: if (
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { get } from "svelte/store";
|
|
3
|
-
import {modalStore, fileInputStore, MenuItem, addToast} from "../../../index.js";
|
|
3
|
+
import {modalStore, fileInputStore, MenuItem, addToast, fileInputConfig} from "../../../index.js";
|
|
4
4
|
|
|
5
5
|
let {
|
|
6
6
|
openActionsMenu = $bindable(),
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
const idsToDelete = store.submissions.map(item => item.id);
|
|
25
25
|
|
|
26
26
|
if (!idsToDelete || idsToDelete.length === 0) return;
|
|
27
|
-
if (!$
|
|
27
|
+
if (!$fileInputConfig.serverDeleteUrl) return;
|
|
28
28
|
|
|
29
29
|
try {
|
|
30
30
|
$fileInputStore.processing = true;
|
|
31
|
-
const response = await fetch($
|
|
31
|
+
const response = await fetch($fileInputConfig.serverDeleteUrl, {
|
|
32
32
|
method: 'DELETE',
|
|
33
33
|
headers: {
|
|
34
34
|
'Content-Type': 'application/json'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { get } from "svelte/store";
|
|
3
|
-
import {MenuItem, fileInputStore, addToast} from "../../../index.js";
|
|
3
|
+
import {MenuItem, fileInputStore, fileInputConfig, addToast} from "../../../index.js";
|
|
4
4
|
|
|
5
5
|
let {
|
|
6
6
|
openActionsMenu = $bindable(),
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
|
|
34
34
|
async function download(id: string) {
|
|
35
35
|
try {
|
|
36
|
-
const downloadURL = $
|
|
36
|
+
const downloadURL = $fileInputConfig.serverDownloadUrl + `?id=${id}`;
|
|
37
37
|
const res = await fetch(downloadURL, {
|
|
38
38
|
method: 'GET',
|
|
39
39
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import {Wrapper, Backdrop, fileInputStore} from "../../../index.js";
|
|
3
|
-
|
|
2
|
+
import {Wrapper, Backdrop, fileInputStore, StorageGauge} from "../../../index.js";
|
|
3
|
+
|
|
4
4
|
let {
|
|
5
5
|
showProperties = $bindable(),
|
|
6
6
|
} = $props();
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
<Backdrop bind:open={showProperties}>
|
|
18
18
|
<Wrapper>
|
|
19
19
|
<div style="display: flex; justify-content: space-between; gap: 1rem">
|
|
20
|
-
<
|
|
20
|
+
<StorageGauge padding="0rem"/>
|
|
21
21
|
<button style="align-self: start;" title="Cancel" onclick={() => showProperties = false} aria-label="Cancel"><i class="fa fa-times"></i></button>
|
|
22
22
|
</div>
|
|
23
23
|
<div style="display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem; max-height: 70vh; overflow-y: auto;">
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { fileInputStore, MenuItem, isDesktop } from '../../../index.js';
|
|
2
|
+
import { fileInputStore, MenuItem, isDesktop, StorageGauge } from '../../../index.js';
|
|
3
3
|
import Content from './content.svelte';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
|
|
6
5
|
const menuItem: { name: 'Documents'| 'Music' | 'Pictures' | 'Videos'| 'Others'; icon: string }[] = [
|
|
7
6
|
{ name: 'Documents', icon: 'fa fa-file-alt' },
|
|
8
7
|
{ name: 'Music', icon: 'fa fa-music' },
|
|
@@ -63,7 +62,7 @@
|
|
|
63
62
|
iconGap="10px">{!$isDesktop ? '' : item.name}
|
|
64
63
|
</MenuItem>
|
|
65
64
|
{/each}
|
|
66
|
-
<
|
|
65
|
+
<StorageGauge hidden={!$isDesktop}/>
|
|
67
66
|
</nav>
|
|
68
67
|
<main>
|
|
69
68
|
<Content/>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { browser } from "$app/environment";
|
|
3
|
-
import { fileInputStore, addToast, PreviewImage, PreviewVideo, PreviewAudio, PreviewDocument, PreviewGenericFile } from "../../../index.js";
|
|
3
|
+
import { fileInputStore, fileInputConfig ,addToast, PreviewImage, PreviewVideo, PreviewAudio, PreviewDocument, PreviewGenericFile } from "../../../index.js";
|
|
4
4
|
import type {FileInputStoreMediaItem} from '../../../index.js';
|
|
5
5
|
|
|
6
6
|
let itemCount = $state(0);
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
Others: []
|
|
29
29
|
});
|
|
30
30
|
async function loadMedia(category: string) {
|
|
31
|
-
if (!$
|
|
31
|
+
if (!$fileInputConfig.serverGetUrl) return;
|
|
32
32
|
try {
|
|
33
33
|
$fileInputStore.processing = true;
|
|
34
|
-
const res = await fetch(`${$
|
|
34
|
+
const res = await fetch(`${$fileInputConfig.serverGetUrl}?category=${category}`);
|
|
35
35
|
const data = await res.json();
|
|
36
36
|
|
|
37
37
|
if (!res.ok) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {fileInputStore,FileInput, addToast} from '../../../index.js'
|
|
2
|
+
import {fileInputStore,FileInput, fileInputConfig, addToast} from '../../../index.js'
|
|
3
3
|
|
|
4
4
|
async function handleUpload() {
|
|
5
|
-
if( $fileInputStore.selectedFiles.length === 0 || !$
|
|
5
|
+
if( $fileInputStore.selectedFiles.length === 0 || !$fileInputConfig.serverUploadUrl) return;
|
|
6
6
|
|
|
7
7
|
try {
|
|
8
8
|
$fileInputStore.processing = true;
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
$fileInputStore.selectedFiles.forEach(file => formData.append('files', file));
|
|
12
12
|
|
|
13
|
-
const res = await fetch($
|
|
13
|
+
const res = await fetch($fileInputConfig.serverUploadUrl, {
|
|
14
14
|
method: 'POST',
|
|
15
15
|
body: formData
|
|
16
16
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import './global.css';
|
|
|
2
2
|
export { default as CircularProgress } from './Core/components/others/Progress/CircularProgress/CircularProgress.svelte';
|
|
3
3
|
export { default as LinearProgress } from './Core/components/others/Progress/LinearProgress/LinearProgress.svelte';
|
|
4
4
|
export { default as CustomProgress } from './Core/components/others/Progress/CustomProgress/customProgress.svelte';
|
|
5
|
+
export { default as StorageGauge } from './Core/components/others/Progress/StorageGauge/storagegauge.svelte';
|
|
5
6
|
export { default as Button } from './Core/components/Form/Button/default/button.svelte';
|
|
6
7
|
export { default as ButtonFlip } from './Core/components/Form/Button/Flip/button.svelte';
|
|
7
8
|
export { default as ButtonMarquee } from './Core/components/Form/Button/Marquee/button.svelte';
|
|
@@ -49,8 +50,8 @@ export { isLoading, isLoggedIn, theme, } from './stores/core/general.js';
|
|
|
49
50
|
export { isMobile, isTablet, isDesktop } from './stores/core/deviceWidth.js';
|
|
50
51
|
export { User, resetUserStore } from './stores/core/user.js';
|
|
51
52
|
export { modalStore, resetModalStore } from './stores/core/modal.js';
|
|
52
|
-
export { editorStore, resetEditorStore } from './stores/modules/editor.js';
|
|
53
|
-
export { fileInputStore, resetFileInputStore } from './stores/modules/fileInput.js';
|
|
53
|
+
export { editorStore, resetEditorStore, editorConfig } from './stores/modules/editor.js';
|
|
54
|
+
export { fileInputStore, resetFileInputStore, fileInputConfig } from './stores/modules/fileInput.js';
|
|
54
55
|
export type { FileInputStoreMediaItem } from './stores/modules/fileInput.js';
|
|
55
56
|
export { layoutStore, resetLayoutStore } from './stores/modules/layout.js';
|
|
56
57
|
export { addToast, removeToast, toasts } from './stores/features/toastManager.js';
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import './global.css';
|
|
|
4
4
|
export { default as CircularProgress } from './Core/components/others/Progress/CircularProgress/CircularProgress.svelte';
|
|
5
5
|
export { default as LinearProgress } from './Core/components/others/Progress/LinearProgress/LinearProgress.svelte';
|
|
6
6
|
export { default as CustomProgress } from './Core/components/others/Progress/CustomProgress/customProgress.svelte';
|
|
7
|
+
export { default as StorageGauge } from './Core/components/others/Progress/StorageGauge/storagegauge.svelte';
|
|
7
8
|
//Buttons
|
|
8
9
|
export { default as Button } from './Core/components/Form/Button/default/button.svelte';
|
|
9
10
|
export { default as ButtonFlip } from './Core/components/Form/Button/Flip/button.svelte';
|
|
@@ -61,8 +62,8 @@ export { isMobile, isTablet, isDesktop } from './stores/core/deviceWidth.js';
|
|
|
61
62
|
export { User, resetUserStore } from './stores/core/user.js';
|
|
62
63
|
export { modalStore, resetModalStore } from './stores/core/modal.js';
|
|
63
64
|
//Modules
|
|
64
|
-
export { editorStore, resetEditorStore } from './stores/modules/editor.js';
|
|
65
|
-
export { fileInputStore, resetFileInputStore } from './stores/modules/fileInput.js';
|
|
65
|
+
export { editorStore, resetEditorStore, editorConfig } from './stores/modules/editor.js';
|
|
66
|
+
export { fileInputStore, resetFileInputStore, fileInputConfig } from './stores/modules/fileInput.js';
|
|
66
67
|
export { layoutStore, resetLayoutStore } from './stores/modules/layout.js';
|
|
67
68
|
export { addToast, removeToast, toasts } from './stores/features/toastManager.js';
|
|
68
69
|
//#######################HOOKS/UTILS########################
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
export type EditorFeature = 'text-formatting' | 'headings' | 'text-color' | 'text-align' | 'lists' | 'images' | 'links' | 'youtube' | 'history' | 'export';
|
|
2
2
|
export type ImageInsertMode = 'filepicker' | 'url';
|
|
3
|
-
export type
|
|
4
|
-
content: any;
|
|
5
|
-
export: boolean;
|
|
6
|
-
onExport: any;
|
|
7
|
-
r2_key: string;
|
|
3
|
+
export type EditorConfig = {
|
|
8
4
|
serverGetUrl: string;
|
|
9
5
|
serverUploadUrl: string;
|
|
10
6
|
serverDeleteUrl: string;
|
|
11
7
|
serverDownloadUrl: string;
|
|
8
|
+
};
|
|
9
|
+
export type EditorState = {
|
|
10
|
+
content: any;
|
|
11
|
+
export: boolean;
|
|
12
|
+
onExport: any;
|
|
12
13
|
enabledFeatures: EditorFeature[];
|
|
13
14
|
insertImageMode: ImageInsertMode[];
|
|
14
15
|
};
|
|
16
|
+
export declare const editorConfig: import("svelte/store").Writable<EditorConfig>;
|
|
15
17
|
export declare const editorStore: import("svelte/store").Writable<EditorState>;
|
|
16
18
|
export declare function resetEditorStore(): void;
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import { writable } from 'svelte/store';
|
|
2
|
+
const defaultConfig = {
|
|
3
|
+
serverGetUrl: '',
|
|
4
|
+
serverUploadUrl: '',
|
|
5
|
+
serverDeleteUrl: '',
|
|
6
|
+
serverDownloadUrl: ''
|
|
7
|
+
};
|
|
2
8
|
const defaultEditorState = {
|
|
3
9
|
content: {},
|
|
4
10
|
export: false,
|
|
5
11
|
onExport: () => { },
|
|
6
|
-
r2_key: '',
|
|
7
|
-
serverGetUrl: '',
|
|
8
|
-
serverUploadUrl: '',
|
|
9
|
-
serverDeleteUrl: '',
|
|
10
|
-
serverDownloadUrl: '',
|
|
11
12
|
enabledFeatures: [],
|
|
12
13
|
insertImageMode: ['filepicker', 'url']
|
|
13
14
|
};
|
|
15
|
+
export const editorConfig = writable({
|
|
16
|
+
...defaultConfig
|
|
17
|
+
});
|
|
14
18
|
export const editorStore = writable({
|
|
15
19
|
...defaultEditorState
|
|
16
20
|
});
|
|
@@ -19,15 +19,17 @@ export type FileInputState = {
|
|
|
19
19
|
manage: boolean;
|
|
20
20
|
submissions: FileInputStoreMediaItem[];
|
|
21
21
|
submissionComplete: boolean;
|
|
22
|
-
|
|
22
|
+
requestReload: boolean;
|
|
23
|
+
processing?: boolean;
|
|
24
|
+
};
|
|
25
|
+
export type FileInputConfig = {
|
|
23
26
|
serverGetUrl: string;
|
|
24
27
|
serverUploadUrl: string;
|
|
25
28
|
serverDeleteUrl: string;
|
|
26
29
|
serverDownloadUrl: string;
|
|
27
|
-
requestReload: boolean;
|
|
28
|
-
processing?: boolean;
|
|
29
30
|
usedBytes: number;
|
|
30
31
|
maxBytes: number;
|
|
31
32
|
};
|
|
33
|
+
export declare const fileInputConfig: import("svelte/store").Writable<FileInputConfig>;
|
|
32
34
|
export declare const fileInputStore: import("svelte/store").Writable<FileInputState>;
|
|
33
35
|
export declare function resetFileInputStore(): void;
|
|
@@ -11,16 +11,20 @@ const defaultFileInputState = {
|
|
|
11
11
|
manage: false,
|
|
12
12
|
submissions: [],
|
|
13
13
|
submissionComplete: false,
|
|
14
|
-
|
|
14
|
+
requestReload: false,
|
|
15
|
+
processing: false,
|
|
16
|
+
};
|
|
17
|
+
const defaultFileInputConfig = {
|
|
15
18
|
serverGetUrl: '',
|
|
16
19
|
serverUploadUrl: '',
|
|
17
20
|
serverDeleteUrl: '',
|
|
18
21
|
serverDownloadUrl: '',
|
|
19
|
-
requestReload: false,
|
|
20
|
-
processing: false,
|
|
21
22
|
usedBytes: 0,
|
|
22
|
-
maxBytes:
|
|
23
|
+
maxBytes: 104857600
|
|
23
24
|
};
|
|
25
|
+
export const fileInputConfig = writable({
|
|
26
|
+
...defaultFileInputConfig
|
|
27
|
+
});
|
|
24
28
|
export const fileInputStore = writable({
|
|
25
29
|
...defaultFileInputState
|
|
26
30
|
});
|