@makolabs/ripple 0.0.1-dev.73 → 0.0.1-dev.75
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.
|
@@ -16,11 +16,13 @@
|
|
|
16
16
|
adapter,
|
|
17
17
|
startPath = '',
|
|
18
18
|
actions = [],
|
|
19
|
-
infoSection
|
|
19
|
+
infoSection,
|
|
20
|
+
selectedFiles = $bindable([])
|
|
20
21
|
} = $props<{
|
|
21
22
|
adapter: StorageAdapter;
|
|
22
23
|
startPath?: string;
|
|
23
24
|
actions?: FileAction[];
|
|
25
|
+
selectedFiles?: string[];
|
|
24
26
|
infoSection?: (props: {
|
|
25
27
|
selectedFiles: string[];
|
|
26
28
|
navToFileFolder: (fileKey: string) => void;
|
|
@@ -36,8 +38,6 @@
|
|
|
36
38
|
let breadcrumbs = $state<Breadcrumb[]>([]);
|
|
37
39
|
let searchQuery = $state('');
|
|
38
40
|
|
|
39
|
-
let selectedFiles = $state<string[]>([]);
|
|
40
|
-
|
|
41
41
|
let sortState = $state<{ column: string | null; direction: 'asc' | 'desc' | 'default' | null }>({
|
|
42
42
|
column: null,
|
|
43
43
|
direction: null
|
|
@@ -393,12 +393,26 @@
|
|
|
393
393
|
|
|
394
394
|
// Ensure our selectedFiles state is updated when the Table selection changes
|
|
395
395
|
function onselect(selectedItems: FileItem[]) {
|
|
396
|
-
//
|
|
397
|
-
|
|
398
|
-
|
|
396
|
+
// Filter out files that aren't allowed to be selected based on actions' isAllowed logic
|
|
397
|
+
const allowedItems = selectedItems.filter((item) => {
|
|
398
|
+
// Check if any single action allows this file
|
|
399
|
+
const hasAllowedAction = actions.some((action: FileAction) => {
|
|
400
|
+
// Only check single file actions for individual file selection
|
|
401
|
+
if ('action' in action && typeof action.action === 'function') {
|
|
402
|
+
return action.isAllowed(item);
|
|
403
|
+
}
|
|
404
|
+
return false;
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
// Always allow folders to be selected (for recursive selection)
|
|
408
|
+
return item.isFolder || hasAllowedAction;
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
// Get keys from allowed selected items
|
|
412
|
+
const newSelectedKeys = allowedItems.map((item) => item.key);
|
|
399
413
|
|
|
400
|
-
// Update the global selection state
|
|
401
|
-
handleSelectByKeys(newSelectedKeys,
|
|
414
|
+
// Update the global selection state with only allowed items
|
|
415
|
+
handleSelectByKeys(newSelectedKeys, allowedItems);
|
|
402
416
|
}
|
|
403
417
|
|
|
404
418
|
// Handle selection based on keys to avoid redundant code
|
|
@@ -3,11 +3,12 @@ type $$ComponentProps = {
|
|
|
3
3
|
adapter: StorageAdapter;
|
|
4
4
|
startPath?: string;
|
|
5
5
|
actions?: FileAction[];
|
|
6
|
+
selectedFiles?: string[];
|
|
6
7
|
infoSection?: (props: {
|
|
7
8
|
selectedFiles: string[];
|
|
8
9
|
navToFileFolder: (fileKey: string) => void;
|
|
9
10
|
}) => any;
|
|
10
11
|
};
|
|
11
|
-
declare const FileBrowser: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
12
|
+
declare const FileBrowser: import("svelte").Component<$$ComponentProps, {}, "selectedFiles">;
|
|
12
13
|
type FileBrowser = ReturnType<typeof FileBrowser>;
|
|
13
14
|
export default FileBrowser;
|
package/dist/index.d.ts
CHANGED
|
@@ -844,3 +844,13 @@ export type CompactFiltersProps = {
|
|
|
844
844
|
export { CompactFilters } from './filters/index.js';
|
|
845
845
|
export * from './file-browser/index.js';
|
|
846
846
|
export * from './adapters/storage/index.js';
|
|
847
|
+
export interface FileBrowserProps {
|
|
848
|
+
adapter: any;
|
|
849
|
+
startPath?: string;
|
|
850
|
+
actions?: any[];
|
|
851
|
+
selectedFiles?: string[];
|
|
852
|
+
infoSection?: (props: {
|
|
853
|
+
selectedFiles: string[];
|
|
854
|
+
navToFileFolder: (fileKey: string) => void;
|
|
855
|
+
}) => any;
|
|
856
|
+
}
|