@makolabs/ripple 2.5.2 → 2.5.3
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.
|
@@ -7,10 +7,15 @@ export declare class S3Adapter extends BaseAdapter {
|
|
|
7
7
|
private basePath;
|
|
8
8
|
private bucket;
|
|
9
9
|
private fileExtensions;
|
|
10
|
+
private displayNameStripPattern;
|
|
11
|
+
/** Default pattern strips common compression extensions (.gz, .bz2, .zip, .zst, .xz, .lz4). */
|
|
12
|
+
private static DEFAULT_STRIP_PATTERN;
|
|
10
13
|
constructor(basePathOrOptions?: string | {
|
|
11
14
|
basePath?: string;
|
|
12
15
|
bucket?: string;
|
|
13
16
|
fileExtensions?: string[];
|
|
17
|
+
/** Regex applied to the filename to produce displayNameKey. @default strips .gz/.bz2/.zip/.zst/.xz/.lz4 */
|
|
18
|
+
displayNameStripPattern?: RegExp;
|
|
14
19
|
}, publicS3BasePath?: string);
|
|
15
20
|
getName(): string;
|
|
16
21
|
isConfigured(): Promise<boolean>;
|
|
@@ -6,15 +6,21 @@ export class S3Adapter extends BaseAdapter {
|
|
|
6
6
|
basePath;
|
|
7
7
|
bucket;
|
|
8
8
|
fileExtensions;
|
|
9
|
+
displayNameStripPattern;
|
|
10
|
+
/** Default pattern strips common compression extensions (.gz, .bz2, .zip, .zst, .xz, .lz4). */
|
|
11
|
+
static DEFAULT_STRIP_PATTERN = /\.(gz|bz2|zip|zst|xz|lz4)$/i;
|
|
9
12
|
constructor(basePathOrOptions, publicS3BasePath) {
|
|
10
13
|
super();
|
|
11
14
|
if (typeof basePathOrOptions === 'object' && basePathOrOptions !== null) {
|
|
12
15
|
this.basePath = basePathOrOptions.basePath || '/';
|
|
13
16
|
this.bucket = basePathOrOptions.bucket;
|
|
14
17
|
this.fileExtensions = basePathOrOptions.fileExtensions;
|
|
18
|
+
this.displayNameStripPattern =
|
|
19
|
+
basePathOrOptions.displayNameStripPattern ?? S3Adapter.DEFAULT_STRIP_PATTERN;
|
|
15
20
|
}
|
|
16
21
|
else {
|
|
17
22
|
this.basePath = basePathOrOptions || publicS3BasePath || '/';
|
|
23
|
+
this.displayNameStripPattern = S3Adapter.DEFAULT_STRIP_PATTERN;
|
|
18
24
|
}
|
|
19
25
|
}
|
|
20
26
|
getName() {
|
|
@@ -98,13 +104,17 @@ export class S3Adapter extends BaseAdapter {
|
|
|
98
104
|
}
|
|
99
105
|
return true;
|
|
100
106
|
})
|
|
101
|
-
.map((file) =>
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
.map((file) => {
|
|
108
|
+
const filename = file.key.slice(normalizedPath.length);
|
|
109
|
+
return {
|
|
110
|
+
key: file.key,
|
|
111
|
+
name: this.removeFileExtensions(filename),
|
|
112
|
+
displayNameKey: filename.replace(this.displayNameStripPattern, ''),
|
|
113
|
+
lastModified: new Date(file.lastModified),
|
|
114
|
+
size: file.size,
|
|
115
|
+
isFolder: false
|
|
116
|
+
};
|
|
117
|
+
});
|
|
108
118
|
// Combine folders and files
|
|
109
119
|
const files = [...folders, ...fileItems];
|
|
110
120
|
// Sort by lastModified in reverse order (newest first), but keep folders first
|
package/dist/ai/ai-types.d.ts
CHANGED
|
@@ -38,6 +38,10 @@ export interface FileBrowserProps {
|
|
|
38
38
|
selectedFiles?: string[];
|
|
39
39
|
/** Controls whether the select-all checkbox selects the current page or all data. @default 'page' */
|
|
40
40
|
selectAllScope?: 'page' | 'all';
|
|
41
|
+
/** Tailwind height class for the browser container. @default 'h-[500px]' */
|
|
42
|
+
height?: string;
|
|
43
|
+
/** Additional CSS classes for the outer container. */
|
|
44
|
+
class?: string;
|
|
41
45
|
infoSection?: (props: {
|
|
42
46
|
selectedFiles: string[];
|
|
43
47
|
navToFileFolder: (fileKey: string) => void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { onMount } from 'svelte';
|
|
3
|
+
import { cn } from '../helper/cls.js';
|
|
3
4
|
import { Button, Table, Color, Size } from '../index.js';
|
|
4
5
|
import type { TableColumn, FileBrowserProps } from '../index.js';
|
|
5
6
|
import { formatDate } from '../utils/dateUtils.js';
|
|
@@ -17,6 +18,8 @@
|
|
|
17
18
|
actions = [],
|
|
18
19
|
infoSection,
|
|
19
20
|
selectAllScope = 'page',
|
|
21
|
+
height = 'h-[500px]',
|
|
22
|
+
class: className = '',
|
|
20
23
|
selectedFiles = $bindable([])
|
|
21
24
|
}: FileBrowserProps = $props();
|
|
22
25
|
|
|
@@ -687,8 +690,14 @@
|
|
|
687
690
|
<span class="text-default-600">{formatDate(file.lastModified, 'DD.MM.YYYY HH:mm')}</span>
|
|
688
691
|
{/snippet}
|
|
689
692
|
|
|
690
|
-
<div
|
|
691
|
-
|
|
693
|
+
<div
|
|
694
|
+
class={cn(
|
|
695
|
+
'border-default-200 relative flex overflow-hidden rounded-lg border bg-white',
|
|
696
|
+
height,
|
|
697
|
+
className
|
|
698
|
+
)}
|
|
699
|
+
>
|
|
700
|
+
<div class="flex min-w-0 flex-1 flex-col">
|
|
692
701
|
{#if !isAuthenticated && adapter.authenticate}
|
|
693
702
|
<div class="flex h-full flex-col items-center justify-center">
|
|
694
703
|
<div class="mb-4 text-center text-lg">
|
|
@@ -698,7 +707,7 @@
|
|
|
698
707
|
</div>
|
|
699
708
|
{:else}
|
|
700
709
|
<div
|
|
701
|
-
class="border-default-100
|
|
710
|
+
class="border-default-100 flex flex-wrap items-center justify-between border-b px-4 py-3"
|
|
702
711
|
>
|
|
703
712
|
<div class="flex flex-wrap items-center">
|
|
704
713
|
{#if breadcrumbs.length > 1}
|
|
@@ -815,40 +824,42 @@
|
|
|
815
824
|
</div>
|
|
816
825
|
</div>
|
|
817
826
|
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
<div class="
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
<div class="
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
<div class="
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
827
|
+
<div class="min-h-0 flex-1 overflow-auto">
|
|
828
|
+
{#if isLoading}
|
|
829
|
+
<div class="flex h-full items-center justify-center py-16">
|
|
830
|
+
<div class="text-default-500">Loading files...</div>
|
|
831
|
+
</div>
|
|
832
|
+
{:else if error}
|
|
833
|
+
<div class="flex h-full flex-col items-center justify-center py-16">
|
|
834
|
+
<div class="text-danger-500 mb-4">{error}</div>
|
|
835
|
+
<Button color={Color.PRIMARY} onclick={() => listFiles(currentPath)}>Retry</Button>
|
|
836
|
+
</div>
|
|
837
|
+
{:else if files.length === 0}
|
|
838
|
+
<div class="flex h-full items-center justify-center py-16">
|
|
839
|
+
<div class="text-default-500">No files found in this directory</div>
|
|
840
|
+
</div>
|
|
841
|
+
{:else}
|
|
842
|
+
<Table
|
|
843
|
+
{columns}
|
|
844
|
+
data={displayFiles}
|
|
845
|
+
loading={isLoading}
|
|
846
|
+
bordered={false}
|
|
847
|
+
onrowclick={handleRowClick}
|
|
848
|
+
rowclass={(row) => {
|
|
849
|
+
let classes = row.isFolder ? 'hover:bg-amber-50 cursor-pointer' : 'hover:bg-blue-50';
|
|
850
|
+
if (isRowSelected(row)) {
|
|
851
|
+
classes += ' bg-primary-50';
|
|
852
|
+
}
|
|
853
|
+
return classes;
|
|
854
|
+
}}
|
|
855
|
+
onsort={handleSort}
|
|
856
|
+
selectable={true}
|
|
857
|
+
{selectAllScope}
|
|
858
|
+
{onselect}
|
|
859
|
+
{selected}
|
|
860
|
+
/>
|
|
861
|
+
{/if}
|
|
862
|
+
</div>
|
|
852
863
|
{/if}
|
|
853
864
|
</div>
|
|
854
865
|
|