@axium/storage 0.18.10 → 0.18.11
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/client/frontend.d.ts +6 -0
- package/dist/client/frontend.js +10 -1
- package/lib/List.svelte +16 -20
- package/lib/SidebarItem.svelte +4 -5
- package/locales/en.json +10 -0
- package/package.json +2 -2
- package/routes/files/trash/+page.svelte +2 -5
- package/routes/tsconfig.json +2 -1
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import type { StorageItemMetadata } from '@axium/storage/common';
|
|
2
2
|
export declare function copyShortURL(item: StorageItemMetadata): Promise<void>;
|
|
3
|
+
/**
|
|
4
|
+
* Formats an item name
|
|
5
|
+
*/
|
|
6
|
+
export declare function formatItemName(item?: {
|
|
7
|
+
name?: string | null;
|
|
8
|
+
} | null): string;
|
package/dist/client/frontend.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import { copy } from '@axium/client/
|
|
1
|
+
import { copy } from '@axium/client/gui';
|
|
2
2
|
import { encodeUUID } from 'utilium';
|
|
3
|
+
import { text } from '@axium/client';
|
|
3
4
|
export function copyShortURL(item) {
|
|
4
5
|
const { href } = new URL('/f/' + encodeUUID(item.id).toBase64({ alphabet: 'base64url', omitPadding: true }), location.origin);
|
|
5
6
|
return copy('text/plain', href);
|
|
6
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Formats an item name
|
|
10
|
+
*/
|
|
11
|
+
export function formatItemName(item) {
|
|
12
|
+
if (!item?.name)
|
|
13
|
+
return text('storage.generic.no_name_in_dialog');
|
|
14
|
+
return `<strong>${item.name.length > 23 ? item.name.slice(0, 20) + '...' : item.name}</strong>`;
|
|
15
|
+
}
|
package/lib/List.svelte
CHANGED
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
import { formatBytes } from '@axium/core/format';
|
|
8
8
|
import { forMime as iconForMime } from '@axium/core/icons';
|
|
9
9
|
import { getDirectoryMetadata, updateItemMetadata } from '@axium/storage/client';
|
|
10
|
-
import { copyShortURL } from '@axium/storage/client/frontend';
|
|
10
|
+
import { copyShortURL, formatItemName } from '@axium/storage/client/frontend';
|
|
11
11
|
import type { StorageItemMetadata } from '@axium/storage/common';
|
|
12
12
|
import Preview from './Preview.svelte';
|
|
13
|
-
import { copy } from '@axium/client/
|
|
13
|
+
import { copy } from '@axium/client/gui';
|
|
14
14
|
|
|
15
15
|
let {
|
|
16
16
|
items = $bindable(),
|
|
@@ -21,11 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
let activeIndex = $state<number>(0);
|
|
23
23
|
const activeItem = $derived(items[activeIndex]);
|
|
24
|
-
const activeItemName = $derived(
|
|
25
|
-
activeItem?.name
|
|
26
|
-
? `<strong>${activeItem.name.length > 23 ? activeItem.name.slice(0, 20) + '...' : activeItem.name}</strong>`
|
|
27
|
-
: 'this'
|
|
28
|
-
);
|
|
24
|
+
const activeItemName = $derived(formatItemName(activeItem));
|
|
29
25
|
const dialogs = $state<Record<string, HTMLDialogElement>>({});
|
|
30
26
|
</script>
|
|
31
27
|
|
|
@@ -90,28 +86,28 @@
|
|
|
90
86
|
>
|
|
91
87
|
{@render action('rename', 'pencil', i)}
|
|
92
88
|
{@render action('share:' + item.id, 'user-group', i)}
|
|
93
|
-
<AccessControlDialog
|
|
94
|
-
bind:dialog={dialogs['share:' + item.id]}
|
|
95
|
-
{item}
|
|
96
|
-
itemType="storage"
|
|
97
|
-
editable={(item.acl?.find(
|
|
98
|
-
a =>
|
|
99
|
-
a.userId == user?.id ||
|
|
100
|
-
(a.role && user?.roles.includes(a.role)) ||
|
|
101
|
-
(a.tag && user?.tags?.includes(a.tag)) ||
|
|
102
|
-
(!a.userId && !a.role && !a.tag)
|
|
103
|
-
)?.manage as boolean | undefined) ?? true}
|
|
104
|
-
/>
|
|
105
89
|
{@render action('download', 'download', i)}
|
|
106
90
|
{@render action('trash', 'trash', i)}
|
|
107
91
|
</div>
|
|
92
|
+
<AccessControlDialog
|
|
93
|
+
bind:dialog={dialogs['share:' + item.id]}
|
|
94
|
+
{item}
|
|
95
|
+
itemType="storage"
|
|
96
|
+
editable={(item.acl?.find(
|
|
97
|
+
a =>
|
|
98
|
+
a.userId == user?.id ||
|
|
99
|
+
(a.role && user?.roles.includes(a.role)) ||
|
|
100
|
+
(a.tag && user?.tags?.includes(a.tag)) ||
|
|
101
|
+
(!a.userId && !a.role && !a.tag)
|
|
102
|
+
)?.manage as boolean | undefined) ?? true}
|
|
103
|
+
/>
|
|
108
104
|
</div>
|
|
109
105
|
{:else}
|
|
110
106
|
<p class="list-empty">{emptyText}</p>
|
|
111
107
|
{/each}
|
|
112
108
|
</div>
|
|
113
109
|
|
|
114
|
-
<dialog bind:this={dialogs.preview} class="preview">
|
|
110
|
+
<dialog bind:this={dialogs.preview} class="preview" onclick={e => e.stopPropagation()}>
|
|
115
111
|
{#if activeItem}
|
|
116
112
|
<Preview
|
|
117
113
|
item={activeItem}
|
package/lib/SidebarItem.svelte
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { text } from '@axium/client';
|
|
3
3
|
import { page } from '$app/state';
|
|
4
|
-
import { copy } from '@axium/client/
|
|
4
|
+
import { copy } from '@axium/client/gui';
|
|
5
5
|
import { FormDialog, Icon } from '@axium/client/components';
|
|
6
6
|
import * as icon from '@axium/core/icons';
|
|
7
7
|
import { deleteItem, updateItemMetadata } from '@axium/storage/client';
|
|
8
8
|
import type { StorageItemMetadata } from '@axium/storage/common';
|
|
9
9
|
import { getDirectory, selection, toggle, toggleRange } from '@axium/storage/sidebar';
|
|
10
10
|
import SidebarItem from './SidebarItem.svelte';
|
|
11
|
+
import { formatItemName } from '@axium/storage/client/frontend';
|
|
11
12
|
|
|
12
13
|
let {
|
|
13
14
|
item = $bindable(),
|
|
@@ -53,9 +54,7 @@
|
|
|
53
54
|
|
|
54
55
|
let children = $state<StorageItemMetadata[]>([]);
|
|
55
56
|
|
|
56
|
-
const itemName = $derived(
|
|
57
|
-
item.name ? `<strong>${item.name.length > 23 ? item.name.slice(0, 20) + '...' : item.name}</strong>` : 'this'
|
|
58
|
-
);
|
|
57
|
+
const itemName = $derived(formatItemName(item));
|
|
59
58
|
</script>
|
|
60
59
|
|
|
61
60
|
{#snippet action(name: string, i: string, label: string)}
|
|
@@ -86,7 +85,7 @@
|
|
|
86
85
|
<SidebarItem bind:item={children[i]} bind:items={children} />
|
|
87
86
|
{/each}
|
|
88
87
|
{:catch error}
|
|
89
|
-
<i class="error
|
|
88
|
+
<i class="error">{error.message}</i>
|
|
90
89
|
{/await}
|
|
91
90
|
</div>
|
|
92
91
|
</details>
|
package/locales/en.json
CHANGED
|
@@ -44,12 +44,22 @@
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
|
+
"permission": {
|
|
48
|
+
"storage": {
|
|
49
|
+
"read": "Read",
|
|
50
|
+
"download": "Download",
|
|
51
|
+
"write": "Write",
|
|
52
|
+
"comment": "Comment",
|
|
53
|
+
"manage": "Manage"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
47
56
|
"storage": {
|
|
48
57
|
"generic": {
|
|
49
58
|
"copy_id": "Copy ID",
|
|
50
59
|
"download": "Download",
|
|
51
60
|
"download_confirm": "Are you sure you want to download {name}?",
|
|
52
61
|
"name": "Name",
|
|
62
|
+
"no_name_in_dialog": "this",
|
|
53
63
|
"no_item": "No item is selected",
|
|
54
64
|
"rename": "Rename",
|
|
55
65
|
"trash": "Trash"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axium/storage",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.11",
|
|
4
4
|
"author": "James Prevett <axium@jamespre.dev>",
|
|
5
5
|
"description": "User file storage for Axium",
|
|
6
6
|
"funding": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"build": "tsc"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@axium/client": ">=0.
|
|
43
|
+
"@axium/client": ">=0.18.0",
|
|
44
44
|
"@axium/core": ">=0.19.0",
|
|
45
45
|
"@axium/server": ">=0.39.0",
|
|
46
46
|
"@sveltejs/kit": "^2.27.3",
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { forMime as iconForMime } from '@axium/core/icons';
|
|
7
7
|
import { deleteItem, updateItemMetadata } from '@axium/storage/client';
|
|
8
8
|
import type { PageProps } from './$types';
|
|
9
|
+
import { formatItemName } from '@axium/storage/client/frontend';
|
|
9
10
|
|
|
10
11
|
const { data }: PageProps = $props();
|
|
11
12
|
let items = $state(data.items);
|
|
@@ -14,11 +15,7 @@
|
|
|
14
15
|
|
|
15
16
|
let activeIndex = $state<number>(-1);
|
|
16
17
|
const activeItem = $derived(activeIndex == -1 ? null : items[activeIndex]);
|
|
17
|
-
const activeItemName = $derived(
|
|
18
|
-
activeItem?.name
|
|
19
|
-
? `<strong>${activeItem.name.length > 23 ? activeItem.name.slice(0, 20) + '...' : activeItem.name}</strong>`
|
|
20
|
-
: 'this'
|
|
21
|
-
);
|
|
18
|
+
const activeItemName = $derived(formatItemName(activeItem));
|
|
22
19
|
|
|
23
20
|
function action(index: number, dialog: () => HTMLDialogElement) {
|
|
24
21
|
return (e: Event) => {
|