@securancy/file-explorer 1.0.6 → 1.1.1
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/components/FileExplorer.svelte +128 -105
- package/dist/components/FileExplorer.svelte.d.ts +8 -10
- package/dist/components/FileExplorerBreadcrumb.svelte +21 -14
- package/dist/components/FileExplorerBreadcrumb.svelte.d.ts +2 -4
- package/dist/components/FileExplorerCreateDirectory.svelte +25 -23
- package/dist/components/FileExplorerCreateDirectory.svelte.d.ts +2 -4
- package/dist/components/FileExplorerDirectory.svelte +22 -18
- package/dist/components/FileExplorerDirectory.svelte.d.ts +2 -4
- package/dist/components/FileExplorerDirectoryColumn.svelte +39 -35
- package/dist/components/FileExplorerDirectoryColumn.svelte.d.ts +3 -5
- package/dist/components/FileExplorerDirectoryIndex.svelte +20 -14
- package/dist/components/FileExplorerDirectoryIndex.svelte.d.ts +2 -4
- package/dist/components/FileExplorerDisplayModeSwitcher.svelte +14 -10
- package/dist/components/FileExplorerDisplayModeSwitcher.svelte.d.ts +2 -4
- package/dist/components/FileExplorerFileDetailColumn.svelte +23 -18
- package/dist/components/FileExplorerFileDetailColumn.svelte.d.ts +2 -4
- package/dist/components/FileIcon.svelte +47 -41
- package/dist/components/FileIcon.svelte.d.ts +2 -4
- package/dist/file-explorer.pcss +10 -3
- package/dist/models/file-item.d.ts +2 -2
- package/dist/utilities/file-utilities.d.ts +0 -1
- package/dist/utilities/file-utilities.js +7 -7
- package/package.json +20 -32
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
<script context="module"
|
|
1
|
+
<script context="module">export {};
|
|
2
|
+
</script>
|
|
2
3
|
|
|
3
|
-
<script>import { createEventDispatcher, tick } from
|
|
4
|
-
import FileExplorerBreadcrumb from
|
|
5
|
-
import FileExplorerDisplayModeSwitcher from
|
|
6
|
-
import { defaultTranslations, FileExplorerDisplayMode } from
|
|
7
|
-
import FileExplorerCreateDirectory from
|
|
8
|
-
import { Button, Modal } from
|
|
9
|
-
import FileExplorerDirectory from
|
|
10
|
-
import { Icon } from
|
|
11
|
-
import { fade } from
|
|
12
|
-
import { pathsEqual } from
|
|
4
|
+
<script>import { createEventDispatcher, tick } from 'svelte';
|
|
5
|
+
import FileExplorerBreadcrumb from './FileExplorerBreadcrumb.svelte';
|
|
6
|
+
import FileExplorerDisplayModeSwitcher from './FileExplorerDisplayModeSwitcher.svelte';
|
|
7
|
+
import { defaultTranslations, FileExplorerDisplayMode } from '../index.js';
|
|
8
|
+
import FileExplorerCreateDirectory from './FileExplorerCreateDirectory.svelte';
|
|
9
|
+
import { Button, Modal } from '@securancy/svelte-components';
|
|
10
|
+
import FileExplorerDirectory from './FileExplorerDirectory.svelte';
|
|
11
|
+
import { Icon } from '@securancy/svelte-components';
|
|
12
|
+
import { fade } from 'svelte/transition';
|
|
13
|
+
import { pathsEqual } from '../utilities';
|
|
13
14
|
export let displayMode = FileExplorerDisplayMode.Columns;
|
|
14
15
|
export let filePath;
|
|
15
16
|
export let documents;
|
|
@@ -18,128 +19,146 @@ export let routePrefix;
|
|
|
18
19
|
export let canEdit;
|
|
19
20
|
export let translations = defaultTranslations;
|
|
20
21
|
export let getFilePreview;
|
|
21
|
-
|
|
22
|
-
export let
|
|
23
|
-
|
|
22
|
+
// When provided, it will use the default implementation for creating directories, otherwise it will dispatch an event
|
|
23
|
+
export let createDirectory = undefined;
|
|
24
|
+
// When provided, it will use the default implementation for uploading files, otherwise it will dispatch an event
|
|
25
|
+
export let uploadFiles = undefined;
|
|
26
|
+
// When provided, it will use the default implementation for deleting files, otherwise it will dispatch an event
|
|
27
|
+
export let deleteFile = undefined;
|
|
24
28
|
const dispatch = createEventDispatcher();
|
|
25
29
|
const scrollBackButtonThreshold = 200;
|
|
26
30
|
let fileExplorerContentContainer;
|
|
27
31
|
let showScrollBackButton = false;
|
|
32
|
+
// Create directory state
|
|
28
33
|
let createDirectoryPath;
|
|
29
34
|
let createDirectoryModalOpen = false;
|
|
35
|
+
// Delete item state
|
|
30
36
|
let deleteFileModalOpen = false;
|
|
31
37
|
let deleteFileEvent;
|
|
32
38
|
let deleting = false;
|
|
33
39
|
let overrideFilesModalOpen = false;
|
|
34
40
|
let overrideFiles = [];
|
|
35
41
|
let uploadFilesRequest;
|
|
36
|
-
|
|
42
|
+
// If the route changes, always scroll to the right to show the new column
|
|
43
|
+
$: if (filePath)
|
|
44
|
+
tick().then(() => scrollToRight());
|
|
37
45
|
async function scrollToRight() {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
if (!fileExplorerContentContainer)
|
|
47
|
+
return;
|
|
48
|
+
fileExplorerContentContainer.scroll({
|
|
49
|
+
left: fileExplorerContentContainer.scrollWidth,
|
|
50
|
+
behavior: 'smooth',
|
|
51
|
+
});
|
|
43
52
|
}
|
|
44
53
|
function handleScroll() {
|
|
45
|
-
|
|
54
|
+
showScrollBackButton = fileExplorerContentContainer.scrollLeft > scrollBackButtonThreshold;
|
|
46
55
|
}
|
|
47
56
|
function handleScrollBack() {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
57
|
+
fileExplorerContentContainer.scroll({
|
|
58
|
+
left: 0,
|
|
59
|
+
behavior: 'smooth',
|
|
60
|
+
});
|
|
52
61
|
}
|
|
53
62
|
async function handleUploadFile(event) {
|
|
54
|
-
|
|
55
|
-
if (
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
63
|
+
// When the uploadFiles function is set, use the default implementation
|
|
64
|
+
if (uploadFiles) {
|
|
65
|
+
// If the user has dropped files, upload them
|
|
66
|
+
if (event.detail.files) {
|
|
67
|
+
await uploadFilesInternal({
|
|
68
|
+
path: event.detail.path,
|
|
69
|
+
files: event.detail.files,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
// When the user has not dropped files, allow the user to select files from their filesystem
|
|
74
|
+
const input = document.createElement('input');
|
|
75
|
+
input.type = 'file';
|
|
76
|
+
input.multiple = true;
|
|
77
|
+
input.click();
|
|
78
|
+
input.addEventListener('change', async () => {
|
|
79
|
+
if (input.files) {
|
|
80
|
+
await uploadFilesInternal({
|
|
81
|
+
path: event.detail.path,
|
|
82
|
+
files: input.files,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
});
|
|
71
86
|
}
|
|
72
|
-
});
|
|
73
87
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
88
|
+
else {
|
|
89
|
+
// Otherwise, dispatch an event
|
|
90
|
+
dispatch('upload-file', event.detail);
|
|
91
|
+
}
|
|
77
92
|
}
|
|
78
93
|
async function uploadFilesInternal(request) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
94
|
+
const filesInDirectory = Array.from(flattenedFiles($documents)).filter(x => pathsEqual(x.path, request.path));
|
|
95
|
+
const existingFiles = Array.from(request.files).filter(file => filesInDirectory.some(document => document.name === file.name));
|
|
96
|
+
if (existingFiles.length > 0) {
|
|
97
|
+
overrideFiles = existingFiles;
|
|
98
|
+
overrideFilesModalOpen = true;
|
|
99
|
+
uploadFilesRequest = request;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
await uploadFiles(request);
|
|
103
|
+
documents.refresh();
|
|
104
|
+
}
|
|
89
105
|
}
|
|
90
106
|
async function confirmOverrideFiles() {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
107
|
+
await uploadFiles(uploadFilesRequest);
|
|
108
|
+
documents.refresh();
|
|
109
|
+
overrideFilesModalOpen = false;
|
|
110
|
+
overrideFiles = [];
|
|
111
|
+
uploadFilesRequest = undefined;
|
|
96
112
|
}
|
|
97
113
|
async function cancelOverrideFiles() {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
114
|
+
overrideFilesModalOpen = false;
|
|
115
|
+
overrideFiles = [];
|
|
116
|
+
uploadFilesRequest = undefined;
|
|
101
117
|
}
|
|
102
118
|
function handleCreateDirectory(event) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
119
|
+
if (createDirectory) {
|
|
120
|
+
createDirectoryPath = event.detail.path;
|
|
121
|
+
// To avoid closing the modal immediately
|
|
122
|
+
setTimeout(() => createDirectoryModalOpen = true);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
dispatch('create-directory', event.detail);
|
|
126
|
+
}
|
|
109
127
|
}
|
|
110
128
|
function handleDeleteFile(event) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
129
|
+
if (deleteFile) {
|
|
130
|
+
deleteFileEvent = event.detail;
|
|
131
|
+
deleteFileModalOpen = true;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
dispatch('delete-file', event.detail);
|
|
135
|
+
}
|
|
117
136
|
}
|
|
118
137
|
function deleteFileInternal() {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
138
|
+
if (deleteFile && deleteFileEvent) {
|
|
139
|
+
deleting = true;
|
|
140
|
+
deleteFile({
|
|
141
|
+
type: 'file',
|
|
142
|
+
...deleteFileEvent,
|
|
143
|
+
}).then(() => {
|
|
144
|
+
documents.refresh();
|
|
145
|
+
deleteFileModalOpen = false;
|
|
146
|
+
}).catch((error) => {
|
|
147
|
+
console.error('Failed to delete item.', error);
|
|
148
|
+
}).finally(() => {
|
|
149
|
+
deleting = false;
|
|
150
|
+
deleteFileModalOpen = false;
|
|
151
|
+
});
|
|
152
|
+
}
|
|
134
153
|
}
|
|
135
|
-
function* flattenedFiles(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
154
|
+
function* flattenedFiles(documents) {
|
|
155
|
+
for (const document of documents) {
|
|
156
|
+
if (document.type === 'file') {
|
|
157
|
+
yield document;
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
yield* flattenedFiles(document.children);
|
|
140
161
|
}
|
|
141
|
-
yield* flattenedFiles(document2.children);
|
|
142
|
-
}
|
|
143
162
|
}
|
|
144
163
|
</script>
|
|
145
164
|
|
|
@@ -245,7 +264,7 @@ function* flattenedFiles(documents2) {
|
|
|
245
264
|
{translations.overrideFilesConfirmation}
|
|
246
265
|
</div>
|
|
247
266
|
<div class="file-explorer__text file-explorer__text--semi-bold">
|
|
248
|
-
{overrideFiles.map(
|
|
267
|
+
{overrideFiles.map(file => file.name).join(', ')}
|
|
249
268
|
</div>
|
|
250
269
|
<svelte:fragment slot="footer">
|
|
251
270
|
<Button
|
|
@@ -262,8 +281,7 @@ function* flattenedFiles(documents2) {
|
|
|
262
281
|
</Modal>
|
|
263
282
|
{/if}
|
|
264
283
|
|
|
265
|
-
<style
|
|
266
|
-
/**
|
|
284
|
+
<style>/**
|
|
267
285
|
* Media queries and devices
|
|
268
286
|
*/
|
|
269
287
|
/**
|
|
@@ -323,7 +341,7 @@ function* flattenedFiles(documents2) {
|
|
|
323
341
|
z-index: 1;
|
|
324
342
|
}
|
|
325
343
|
.file-explorer__column::after {
|
|
326
|
-
content:
|
|
344
|
+
content: "";
|
|
327
345
|
position: absolute;
|
|
328
346
|
inset: 0;
|
|
329
347
|
pointer-events: none;
|
|
@@ -370,7 +388,7 @@ function* flattenedFiles(documents2) {
|
|
|
370
388
|
margin-left: auto;
|
|
371
389
|
}
|
|
372
390
|
.file-explorer__search {
|
|
373
|
-
padding: calc(var(--file-explorer-default-spacing) * 0.5) calc(var(--file-explorer-default-spacing) * 0.5) 0
|
|
391
|
+
padding: calc(var(--file-explorer-default-spacing) * 0.5) calc(var(--file-explorer-default-spacing) * 0.5) 0;
|
|
374
392
|
}
|
|
375
393
|
.file-explorer__list {
|
|
376
394
|
margin-bottom: var(--file-explorer-default-spacing);
|
|
@@ -508,6 +526,12 @@ function* flattenedFiles(documents2) {
|
|
|
508
526
|
.file-explorer__file-icon--large :global(i) {
|
|
509
527
|
font-size: var(--file-explorer-preview-icon-size);
|
|
510
528
|
}
|
|
529
|
+
.file-explorer__file-name {
|
|
530
|
+
min-width: 0;
|
|
531
|
+
}
|
|
532
|
+
.file-explorer__file-name--directory-index {
|
|
533
|
+
word-break: break-word;
|
|
534
|
+
}
|
|
511
535
|
.file-explorer__text--semi-bold {
|
|
512
536
|
font-weight: var(--file-explorer-text-semi-bold);
|
|
513
537
|
}
|
|
@@ -518,5 +542,4 @@ function* flattenedFiles(documents2) {
|
|
|
518
542
|
min-height: 50px;
|
|
519
543
|
height: 100%;
|
|
520
544
|
font-size: 25px;
|
|
521
|
-
}
|
|
522
|
-
</style>
|
|
545
|
+
}</style>
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
export interface UploadFileEvent {
|
|
3
3
|
path: string;
|
|
4
4
|
files?: FileList;
|
|
5
|
-
}
|
|
6
|
-
export
|
|
5
|
+
}
|
|
6
|
+
export interface CreateDirectoryEvent {
|
|
7
7
|
path: string;
|
|
8
|
-
}
|
|
9
|
-
export
|
|
8
|
+
}
|
|
9
|
+
export interface DeleteFileEvent {
|
|
10
10
|
path: string;
|
|
11
11
|
name: string;
|
|
12
|
-
}
|
|
12
|
+
}
|
|
13
13
|
import type { Refreshable } from '@securancy/svelte-utilities';
|
|
14
14
|
import { type CreateDirectoryRequest, FileExplorerDisplayMode, type FileItem, type FilePreview, type FileSystemItem, type UploadFilesRequest } from '../index.js';
|
|
15
15
|
declare const __propDef: {
|
|
@@ -65,12 +65,10 @@ declare const __propDef: {
|
|
|
65
65
|
slots: {
|
|
66
66
|
search: {};
|
|
67
67
|
};
|
|
68
|
-
exports?: {} | undefined;
|
|
69
|
-
bindings?: string | undefined;
|
|
70
68
|
};
|
|
71
69
|
export type FileExplorerProps = typeof __propDef.props;
|
|
72
70
|
export type FileExplorerEvents = typeof __propDef.events;
|
|
73
71
|
export type FileExplorerSlots = typeof __propDef.slots;
|
|
74
|
-
export default class FileExplorer extends
|
|
72
|
+
export default class FileExplorer extends SvelteComponentTyped<FileExplorerProps, FileExplorerEvents, FileExplorerSlots> {
|
|
75
73
|
}
|
|
76
74
|
export {};
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
<script>import { Icon } from
|
|
1
|
+
<script>import { Icon } from '@securancy/svelte-components';
|
|
2
2
|
export let filePath;
|
|
3
3
|
export let routePrefix;
|
|
4
|
-
$: parts = filePath.split(
|
|
5
|
-
function getHref(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
$: parts = filePath.split('/');
|
|
5
|
+
function getHref(parts, index, routePrefix) {
|
|
6
|
+
const href = [
|
|
7
|
+
...routePrefix.split('/'),
|
|
8
|
+
...parts.slice(0, index + 1),
|
|
9
|
+
]
|
|
10
|
+
.filter(node => node !== '')
|
|
11
|
+
.map(encodeURIComponent)
|
|
12
|
+
.join('/');
|
|
13
|
+
return '/' + href;
|
|
11
14
|
}
|
|
12
15
|
</script>
|
|
13
16
|
|
|
@@ -23,8 +26,7 @@ function getHref(parts2, index, routePrefix2) {
|
|
|
23
26
|
{/each}
|
|
24
27
|
</div>
|
|
25
28
|
|
|
26
|
-
<style
|
|
27
|
-
/**
|
|
29
|
+
<style>/**
|
|
28
30
|
* Media queries and devices
|
|
29
31
|
*/
|
|
30
32
|
/**
|
|
@@ -84,7 +86,7 @@ function getHref(parts2, index, routePrefix2) {
|
|
|
84
86
|
z-index: 1;
|
|
85
87
|
}
|
|
86
88
|
.file-explorer__column::after {
|
|
87
|
-
content:
|
|
89
|
+
content: "";
|
|
88
90
|
position: absolute;
|
|
89
91
|
inset: 0;
|
|
90
92
|
pointer-events: none;
|
|
@@ -131,7 +133,7 @@ function getHref(parts2, index, routePrefix2) {
|
|
|
131
133
|
margin-left: auto;
|
|
132
134
|
}
|
|
133
135
|
.file-explorer__search {
|
|
134
|
-
padding: calc(var(--file-explorer-default-spacing) * 0.5) calc(var(--file-explorer-default-spacing) * 0.5) 0
|
|
136
|
+
padding: calc(var(--file-explorer-default-spacing) * 0.5) calc(var(--file-explorer-default-spacing) * 0.5) 0;
|
|
135
137
|
}
|
|
136
138
|
.file-explorer__list {
|
|
137
139
|
margin-bottom: var(--file-explorer-default-spacing);
|
|
@@ -269,6 +271,12 @@ function getHref(parts2, index, routePrefix2) {
|
|
|
269
271
|
.file-explorer__file-icon--large :global(i) {
|
|
270
272
|
font-size: var(--file-explorer-preview-icon-size);
|
|
271
273
|
}
|
|
274
|
+
.file-explorer__file-name {
|
|
275
|
+
min-width: 0;
|
|
276
|
+
}
|
|
277
|
+
.file-explorer__file-name--directory-index {
|
|
278
|
+
word-break: break-word;
|
|
279
|
+
}
|
|
272
280
|
.file-explorer__text--semi-bold {
|
|
273
281
|
font-weight: var(--file-explorer-text-semi-bold);
|
|
274
282
|
}
|
|
@@ -279,5 +287,4 @@ function getHref(parts2, index, routePrefix2) {
|
|
|
279
287
|
min-height: 50px;
|
|
280
288
|
height: 100%;
|
|
281
289
|
font-size: 25px;
|
|
282
|
-
}
|
|
283
|
-
</style>
|
|
290
|
+
}</style>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
filePath: string;
|
|
@@ -8,12 +8,10 @@ declare const __propDef: {
|
|
|
8
8
|
[evt: string]: CustomEvent<any>;
|
|
9
9
|
};
|
|
10
10
|
slots: {};
|
|
11
|
-
exports?: {} | undefined;
|
|
12
|
-
bindings?: string | undefined;
|
|
13
11
|
};
|
|
14
12
|
export type FileExplorerBreadcrumbProps = typeof __propDef.props;
|
|
15
13
|
export type FileExplorerBreadcrumbEvents = typeof __propDef.events;
|
|
16
14
|
export type FileExplorerBreadcrumbSlots = typeof __propDef.slots;
|
|
17
|
-
export default class FileExplorerBreadcrumb extends
|
|
15
|
+
export default class FileExplorerBreadcrumb extends SvelteComponentTyped<FileExplorerBreadcrumbProps, FileExplorerBreadcrumbEvents, FileExplorerBreadcrumbSlots> {
|
|
18
16
|
}
|
|
19
17
|
export {};
|
|
@@ -1,33 +1,36 @@
|
|
|
1
|
-
<script>import { Button, FormElement, Modal } from
|
|
1
|
+
<script>import { Button, FormElement, Modal } from '@securancy/svelte-components';
|
|
2
2
|
export let createDirectoryPath;
|
|
3
3
|
export let createDirectoryModalOpen = false;
|
|
4
4
|
export let documents;
|
|
5
5
|
export let createDirectory;
|
|
6
6
|
export let translations;
|
|
7
|
-
let request = { path:
|
|
7
|
+
let request = { path: '', name: '' };
|
|
8
8
|
let submitting = false;
|
|
9
|
-
let input =
|
|
9
|
+
let input = undefined;
|
|
10
10
|
$: existingFoldersInPath = getExistingFoldersInPath(createDirectoryPath, $documents);
|
|
11
|
-
$: directoryAlreadyExists = existingFoldersInPath.some(
|
|
12
|
-
$: request.path = createDirectoryPath ??
|
|
13
|
-
|
|
11
|
+
$: directoryAlreadyExists = existingFoldersInPath.some(x => x.name === request.name);
|
|
12
|
+
$: request.path = createDirectoryPath ?? '';
|
|
13
|
+
// Clear inputs when modal is opened
|
|
14
|
+
$: if (input)
|
|
15
|
+
input.focus();
|
|
14
16
|
async function submitFiles() {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
submitting = true;
|
|
18
|
+
await createDirectory(request)
|
|
19
|
+
.then(() => {
|
|
20
|
+
createDirectoryModalOpen = false;
|
|
21
|
+
}).finally(() => {
|
|
22
|
+
submitting = false;
|
|
23
|
+
});
|
|
24
|
+
documents.refresh();
|
|
22
25
|
}
|
|
23
|
-
function getExistingFoldersInPath(path,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
function getExistingFoldersInPath(path, documents) {
|
|
27
|
+
const pathParts = path ? path.split('/') : [];
|
|
28
|
+
let existingFoldersInPath = documents.filter(x => x.type === 'directory');
|
|
29
|
+
for (const pathPart of pathParts) {
|
|
30
|
+
const currentFolder = existingFoldersInPath.find(document => document.name === pathPart);
|
|
31
|
+
existingFoldersInPath = currentFolder ? currentFolder.children.filter(x => x.type === 'directory') : [];
|
|
32
|
+
}
|
|
33
|
+
return existingFoldersInPath;
|
|
31
34
|
}
|
|
32
35
|
</script>
|
|
33
36
|
|
|
@@ -87,5 +90,4 @@ function getExistingFoldersInPath(path, documents2) {
|
|
|
87
90
|
border: 1px solid var(--file-explorer-create-directory-border);
|
|
88
91
|
border-radius: var(--file-explorer-create-directory-border-radius);
|
|
89
92
|
padding: 10px;
|
|
90
|
-
}
|
|
91
|
-
</style>
|
|
93
|
+
}</style>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
import type { Refreshable } from '@securancy/svelte-utilities';
|
|
3
3
|
import type { CreateDirectoryRequest, DocumentTranslations, FileSystemItem } from '../models/index.js';
|
|
4
4
|
declare const __propDef: {
|
|
@@ -13,12 +13,10 @@ declare const __propDef: {
|
|
|
13
13
|
[evt: string]: CustomEvent<any>;
|
|
14
14
|
};
|
|
15
15
|
slots: {};
|
|
16
|
-
exports?: {} | undefined;
|
|
17
|
-
bindings?: string | undefined;
|
|
18
16
|
};
|
|
19
17
|
export type FileExplorerCreateDirectoryProps = typeof __propDef.props;
|
|
20
18
|
export type FileExplorerCreateDirectoryEvents = typeof __propDef.events;
|
|
21
19
|
export type FileExplorerCreateDirectorySlots = typeof __propDef.slots;
|
|
22
|
-
export default class FileExplorerCreateDirectory extends
|
|
20
|
+
export default class FileExplorerCreateDirectory extends SvelteComponentTyped<FileExplorerCreateDirectoryProps, FileExplorerCreateDirectoryEvents, FileExplorerCreateDirectorySlots> {
|
|
23
21
|
}
|
|
24
22
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
<script>import {} from
|
|
2
|
-
import FileExplorerDirectoryColumn from
|
|
3
|
-
import FileExplorerFileDetailColumn from
|
|
4
|
-
import FileExplorerDirectoryIndex from
|
|
1
|
+
<script>import {} from '..';
|
|
2
|
+
import FileExplorerDirectoryColumn from './FileExplorerDirectoryColumn.svelte';
|
|
3
|
+
import FileExplorerFileDetailColumn from './FileExplorerFileDetailColumn.svelte';
|
|
4
|
+
import FileExplorerDirectoryIndex from './FileExplorerDirectoryIndex.svelte';
|
|
5
5
|
export let item;
|
|
6
6
|
export let translations;
|
|
7
7
|
export let routePrefix;
|
|
@@ -9,16 +9,16 @@ export let currentPath;
|
|
|
9
9
|
export let canEdit;
|
|
10
10
|
export let displayMode;
|
|
11
11
|
export let getFilePreview;
|
|
12
|
-
$: currentPathParts = currentPath.split(
|
|
12
|
+
$: currentPathParts = currentPath.split('/');
|
|
13
13
|
$: activeFileItem = item.children.find((fileItem) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
const parts = [
|
|
15
|
+
...fileItem.path.split('/').filter(part => part !== ''),
|
|
16
|
+
fileItem.name,
|
|
17
|
+
];
|
|
18
|
+
return parts.every((part, index) => currentPathParts[index] === part);
|
|
19
19
|
});
|
|
20
|
-
function canEditItem(
|
|
21
|
-
|
|
20
|
+
function canEditItem(item, canEdit) {
|
|
21
|
+
return typeof canEdit === 'function' ? canEdit(item) : canEdit === true;
|
|
22
22
|
}
|
|
23
23
|
</script>
|
|
24
24
|
|
|
@@ -69,8 +69,7 @@ function canEditItem(item2, canEdit2) {
|
|
|
69
69
|
/>
|
|
70
70
|
{/if}
|
|
71
71
|
{/if}
|
|
72
|
-
<style
|
|
73
|
-
/**
|
|
72
|
+
<style>/**
|
|
74
73
|
* Media queries and devices
|
|
75
74
|
*/
|
|
76
75
|
/**
|
|
@@ -130,7 +129,7 @@ function canEditItem(item2, canEdit2) {
|
|
|
130
129
|
z-index: 1;
|
|
131
130
|
}
|
|
132
131
|
.file-explorer__column::after {
|
|
133
|
-
content:
|
|
132
|
+
content: "";
|
|
134
133
|
position: absolute;
|
|
135
134
|
inset: 0;
|
|
136
135
|
pointer-events: none;
|
|
@@ -177,7 +176,7 @@ function canEditItem(item2, canEdit2) {
|
|
|
177
176
|
margin-left: auto;
|
|
178
177
|
}
|
|
179
178
|
.file-explorer__search {
|
|
180
|
-
padding: calc(var(--file-explorer-default-spacing) * 0.5) calc(var(--file-explorer-default-spacing) * 0.5) 0
|
|
179
|
+
padding: calc(var(--file-explorer-default-spacing) * 0.5) calc(var(--file-explorer-default-spacing) * 0.5) 0;
|
|
181
180
|
}
|
|
182
181
|
.file-explorer__list {
|
|
183
182
|
margin-bottom: var(--file-explorer-default-spacing);
|
|
@@ -315,6 +314,12 @@ function canEditItem(item2, canEdit2) {
|
|
|
315
314
|
.file-explorer__file-icon--large :global(i) {
|
|
316
315
|
font-size: var(--file-explorer-preview-icon-size);
|
|
317
316
|
}
|
|
317
|
+
.file-explorer__file-name {
|
|
318
|
+
min-width: 0;
|
|
319
|
+
}
|
|
320
|
+
.file-explorer__file-name--directory-index {
|
|
321
|
+
word-break: break-word;
|
|
322
|
+
}
|
|
318
323
|
.file-explorer__text--semi-bold {
|
|
319
324
|
font-weight: var(--file-explorer-text-semi-bold);
|
|
320
325
|
}
|
|
@@ -325,5 +330,4 @@ function canEditItem(item2, canEdit2) {
|
|
|
325
330
|
min-height: 50px;
|
|
326
331
|
height: 100%;
|
|
327
332
|
font-size: 25px;
|
|
328
|
-
}
|
|
329
|
-
</style>
|
|
333
|
+
}</style>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
import type { FileExplorerDisplayMode, FileSystemItem } from '..';
|
|
3
3
|
import { type DirectoryItem, type DocumentTranslations, type FileItem, type FilePreview } from '..';
|
|
4
4
|
declare const __propDef: {
|
|
@@ -19,12 +19,10 @@ declare const __propDef: {
|
|
|
19
19
|
[evt: string]: CustomEvent<any>;
|
|
20
20
|
};
|
|
21
21
|
slots: {};
|
|
22
|
-
exports?: {} | undefined;
|
|
23
|
-
bindings?: string | undefined;
|
|
24
22
|
};
|
|
25
23
|
export type FileExplorerDirectoryProps = typeof __propDef.props;
|
|
26
24
|
export type FileExplorerDirectoryEvents = typeof __propDef.events;
|
|
27
25
|
export type FileExplorerDirectorySlots = typeof __propDef.slots;
|
|
28
|
-
export default class FileExplorerDirectory extends
|
|
26
|
+
export default class FileExplorerDirectory extends SvelteComponentTyped<FileExplorerDirectoryProps, FileExplorerDirectoryEvents, FileExplorerDirectorySlots> {
|
|
29
27
|
}
|
|
30
28
|
export {};
|