filecove 0.0.0-stage → 0.2.0
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/CHANGELOG.md +38 -0
- package/LICENSE +21 -0
- package/README.md +65 -2
- package/THIRD_PARTY_NOTICES.md +63 -0
- package/dist/components/buttons/toolbar-actions.d.ts +28 -0
- package/dist/components/buttons/tooltip-icon-button.d.ts +14 -0
- package/dist/components/downloads/download-panel.d.ts +23 -0
- package/dist/components/drag/drag-preview.d.ts +24 -0
- package/dist/components/file-manager/announcer.d.ts +14 -0
- package/dist/components/file-manager/content/file-grid.d.ts +8 -0
- package/dist/components/file-manager/content/file-list.d.ts +9 -0
- package/dist/components/file-manager/content/folder-view.d.ts +83 -0
- package/dist/components/file-manager/content/item-icon.d.ts +16 -0
- package/dist/components/file-manager/content/no-sections.d.ts +11 -0
- package/dist/components/file-manager/content/search-results.d.ts +40 -0
- package/dist/components/file-manager/content/search-tabs.d.ts +29 -0
- package/dist/components/file-manager/content/trash-bar.d.ts +13 -0
- package/dist/components/file-manager/context-menu/context-menu.d.ts +20 -0
- package/dist/components/file-manager/dialogs/conflict-step.d.ts +28 -0
- package/dist/components/file-manager/dialogs/delete-dialog.d.ts +49 -0
- package/dist/components/file-manager/dialogs/image-viewer.d.ts +42 -0
- package/dist/components/file-manager/dialogs/name-dialog.d.ts +41 -0
- package/dist/components/file-manager/dialogs/paste-dialog.d.ts +39 -0
- package/dist/components/file-manager/dialogs/preview-dialog.d.ts +75 -0
- package/dist/components/file-manager/dialogs/restore-dialog.d.ts +41 -0
- package/dist/components/file-manager/dialogs/shortcuts-dialog.d.ts +36 -0
- package/dist/components/file-manager/dialogs/transfer-dialog.d.ts +71 -0
- package/dist/components/file-manager/dialogs/upload-dialog.d.ts +34 -0
- package/dist/components/file-manager/file-manager.d.ts +320 -0
- package/dist/components/file-manager/find-layer.d.ts +29 -0
- package/dist/components/file-manager/header-bar/header-bar.d.ts +65 -0
- package/dist/components/file-manager/header-bar/history-menu.d.ts +18 -0
- package/dist/components/file-manager/header-bar/path-bar.d.ts +19 -0
- package/dist/components/file-manager/header-bar/path-field.d.ts +23 -0
- package/dist/components/file-manager/header-bar/search-field.d.ts +27 -0
- package/dist/components/file-manager/header-bar/search-sections-menu.d.ts +25 -0
- package/dist/components/file-manager/header-bar/view-menu.d.ts +39 -0
- package/dist/components/file-manager/notice-bar.d.ts +36 -0
- package/dist/components/file-manager/properties-pane.d.ts +53 -0
- package/dist/components/file-manager/resize-edge.d.ts +39 -0
- package/dist/components/file-manager/selection-bar.d.ts +15 -0
- package/dist/components/file-manager/sidebar/location-item.d.ts +36 -0
- package/dist/components/file-manager/sidebar/main-menu.d.ts +23 -0
- package/dist/components/file-manager/sidebar/sidebar.d.ts +80 -0
- package/dist/components/icons/check-badge.d.ts +3 -0
- package/dist/components/icons/create-icon.d.ts +20 -0
- package/dist/components/icons/file-icon.d.ts +19 -0
- package/dist/components/icons/icon-provider.d.ts +21 -0
- package/dist/components/icons/icon-slot.d.ts +6 -0
- package/dist/components/icons/icon.d.ts +19 -0
- package/dist/components/icons/locked-icon.d.ts +9 -0
- package/dist/components/media-manager/asset-delete.d.ts +29 -0
- package/dist/components/media-manager/asset-hold.d.ts +32 -0
- package/dist/components/media-manager/asset-option.d.ts +74 -0
- package/dist/components/media-manager/asset-trail.d.ts +13 -0
- package/dist/components/media-manager/choice-list.d.ts +29 -0
- package/dist/components/media-manager/choices-pane.d.ts +50 -0
- package/dist/components/media-manager/choose-bar.d.ts +26 -0
- package/dist/components/media-manager/drop-zone.d.ts +7 -0
- package/dist/components/media-manager/group-check.d.ts +13 -0
- package/dist/components/media-manager/group-create.d.ts +20 -0
- package/dist/components/media-manager/group-path.d.ts +24 -0
- package/dist/components/media-manager/library-list.d.ts +23 -0
- package/dist/components/media-manager/media-asset.d.ts +65 -0
- package/dist/components/media-manager/media-edit-many.d.ts +33 -0
- package/dist/components/media-manager/media-fields.d.ts +31 -0
- package/dist/components/media-manager/media-filter-chips.d.ts +17 -0
- package/dist/components/media-manager/media-filters-dialog.d.ts +39 -0
- package/dist/components/media-manager/media-filters.d.ts +37 -0
- package/dist/components/media-manager/media-form.d.ts +29 -0
- package/dist/components/media-manager/media-frame.d.ts +77 -0
- package/dist/components/media-manager/media-grid.d.ts +114 -0
- package/dist/components/media-manager/media-group.d.ts +29 -0
- package/dist/components/media-manager/media-header.d.ts +80 -0
- package/dist/components/media-manager/media-manager.d.ts +309 -0
- package/dist/components/media-manager/media-move.d.ts +30 -0
- package/dist/components/media-manager/media-picker.d.ts +140 -0
- package/dist/components/media-manager/media-picture.d.ts +26 -0
- package/dist/components/media-manager/media-process.d.ts +26 -0
- package/dist/components/media-manager/media-row.d.ts +13 -0
- package/dist/components/media-manager/media-step.d.ts +33 -0
- package/dist/components/media-manager/media-tile.d.ts +15 -0
- package/dist/components/media-manager/media-upload.d.ts +46 -0
- package/dist/components/media-manager/open-button.d.ts +15 -0
- package/dist/components/media-manager/picker-frame.d.ts +33 -0
- package/dist/components/media-manager/selection-bar.d.ts +25 -0
- package/dist/components/media-manager/upload-tile.d.ts +17 -0
- package/dist/components/properties/properties-panel.d.ts +53 -0
- package/dist/components/properties/property-display.d.ts +15 -0
- package/dist/components/properties/property-editor.d.ts +26 -0
- package/dist/components/properties/property-input.d.ts +36 -0
- package/dist/components/transfers/transfer-panel.d.ts +25 -0
- package/dist/components/ui/backdrop.d.ts +7 -0
- package/dist/components/ui/button-base.d.ts +7 -0
- package/dist/components/ui/button.d.ts +18 -0
- package/dist/components/ui/checkbox.d.ts +24 -0
- package/dist/components/ui/chip.d.ts +18 -0
- package/dist/components/ui/circular-progress.d.ts +14 -0
- package/dist/components/ui/collapse.d.ts +9 -0
- package/dist/components/ui/dialog.d.ts +40 -0
- package/dist/components/ui/divider.d.ts +4 -0
- package/dist/components/ui/icon-button.d.ts +12 -0
- package/dist/components/ui/linear-progress.d.ts +13 -0
- package/dist/components/ui/link.d.ts +4 -0
- package/dist/components/ui/menu.d.ts +77 -0
- package/dist/components/ui/root-providers.d.ts +16 -0
- package/dist/components/ui/text-field.d.ts +38 -0
- package/dist/components/ui/text.d.ts +21 -0
- package/dist/components/ui/tooltip.d.ts +24 -0
- package/dist/components/uploads/upload-panel.d.ts +31 -0
- package/dist/contexts/asset-look-context.d.ts +1 -0
- package/dist/contexts/cut-context.d.ts +6 -0
- package/dist/contexts/data-context.d.ts +12 -0
- package/dist/contexts/direction-context.d.ts +2 -0
- package/dist/contexts/drag-context.d.ts +36 -0
- package/dist/contexts/icon-context.d.ts +10 -0
- package/dist/contexts/locale-context.d.ts +2 -0
- package/dist/contexts/moving-context.d.ts +7 -0
- package/dist/create-icon-D2vnnBQX.js +40 -0
- package/dist/create-icon-D2vnnBQX.js.map +1 -0
- package/dist/hooks/use-announcer.d.ts +20 -0
- package/dist/hooks/use-asset-look.d.ts +6 -0
- package/dist/hooks/use-asset-states.d.ts +12 -0
- package/dist/hooks/use-chosen-column.d.ts +16 -0
- package/dist/hooks/use-clipboard-follow.d.ts +12 -0
- package/dist/hooks/use-controlled.d.ts +18 -0
- package/dist/hooks/use-cut-ids.d.ts +3 -0
- package/dist/hooks/use-dev-checks.d.ts +16 -0
- package/dist/hooks/use-download-queue.d.ts +19 -0
- package/dist/hooks/use-dragged-ids.d.ts +3 -0
- package/dist/hooks/use-drop-target.d.ts +48 -0
- package/dist/hooks/use-entry-drag.d.ts +46 -0
- package/dist/hooks/use-files-drop.d.ts +20 -0
- package/dist/hooks/use-folder.d.ts +14 -0
- package/dist/hooks/use-fork-ref.d.ts +6 -0
- package/dist/hooks/use-form-send.d.ts +12 -0
- package/dist/hooks/use-found.d.ts +10 -0
- package/dist/hooks/use-icon-config.d.ts +2 -0
- package/dist/hooks/use-level-filters.d.ts +112 -0
- package/dist/hooks/use-level-search.d.ts +21 -0
- package/dist/hooks/use-locale.d.ts +10 -0
- package/dist/hooks/use-location-history.d.ts +42 -0
- package/dist/hooks/use-long-press.d.ts +25 -0
- package/dist/hooks/use-marquee.d.ts +35 -0
- package/dist/hooks/use-match-count.d.ts +8 -0
- package/dist/hooks/use-media-search.d.ts +44 -0
- package/dist/hooks/use-moving-ids.d.ts +3 -0
- package/dist/hooks/use-picks.d.ts +39 -0
- package/dist/hooks/use-preview-contents.d.ts +33 -0
- package/dist/hooks/use-properties.d.ts +25 -0
- package/dist/hooks/use-scroll-measure.d.ts +34 -0
- package/dist/hooks/use-search.d.ts +12 -0
- package/dist/hooks/use-selection.d.ts +29 -0
- package/dist/hooks/use-setting.d.ts +21 -0
- package/dist/hooks/use-stable-set.d.ts +6 -0
- package/dist/hooks/use-swipe.d.ts +41 -0
- package/dist/hooks/use-text-direction.d.ts +8 -0
- package/dist/hooks/use-thumbnail.d.ts +8 -0
- package/dist/hooks/use-transfer-queue.d.ts +22 -0
- package/dist/hooks/use-tree-rows.d.ts +9 -0
- package/dist/hooks/use-tree-selection.d.ts +19 -0
- package/dist/hooks/use-type-ahead.d.ts +9 -0
- package/dist/hooks/use-type-icons.d.ts +10 -0
- package/dist/hooks/use-upload-queue.d.ts +24 -0
- package/dist/hooks/use-virtual-lines.d.ts +27 -0
- package/dist/hooks/use-virtual-rows.d.ts +31 -0
- package/dist/hooks/use-wheel-zoom.d.ts +10 -0
- package/dist/icon-sets/filled.d.ts +6 -0
- package/dist/icon-sets/filled.js +76 -0
- package/dist/icon-sets/filled.js.map +1 -0
- package/dist/icon-sets/outlined.d.ts +6 -0
- package/dist/icon-sets/outlined.js +73 -0
- package/dist/icon-sets/outlined.js.map +1 -0
- package/dist/icon-sets/rounded.d.ts +6 -0
- package/dist/icon-sets/rounded.js +73 -0
- package/dist/icon-sets/rounded.js.map +1 -0
- package/dist/icon-sets/sharp.d.ts +6 -0
- package/dist/icon-sets/sharp.js +73 -0
- package/dist/icon-sets/sharp.js.map +1 -0
- package/dist/icon-sets/two-tone.d.ts +6 -0
- package/dist/icon-sets/two-tone.js +188 -0
- package/dist/icon-sets/two-tone.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +32651 -0
- package/dist/index.js.map +1 -0
- package/dist/locales/en-us.d.ts +7 -0
- package/dist/store/download-queue.d.ts +37 -0
- package/dist/store/folder-store.d.ts +79 -0
- package/dist/store/keyboard-layout.d.ts +11 -0
- package/dist/store/properties-cache.d.ts +73 -0
- package/dist/store/thumbnail-cache.d.ts +30 -0
- package/dist/store/transfer-across.d.ts +24 -0
- package/dist/store/transfer-queue.d.ts +59 -0
- package/dist/store/upload-queue.d.ts +83 -0
- package/dist/styles/arrived.d.ts +6 -0
- package/dist/styles/classes.d.ts +212 -0
- package/dist/styles/layout.d.ts +55 -0
- package/dist/styles/media-layout.d.ts +36 -0
- package/dist/styles/order.d.ts +1 -0
- package/dist/styles.css +7632 -0
- package/dist/styles.layer.css +7634 -0
- package/dist/types/action.d.ts +296 -0
- package/dist/types/adapter.d.ts +922 -0
- package/dist/types/api.d.ts +192 -0
- package/dist/types/clipboard.d.ts +45 -0
- package/dist/types/download.d.ts +41 -0
- package/dist/types/drag.d.ts +57 -0
- package/dist/types/folder.d.ts +47 -0
- package/dist/types/icon.d.ts +20 -0
- package/dist/types/index.d.ts +27 -0
- package/dist/types/limits.d.ts +49 -0
- package/dist/types/locale.d.ts +1132 -0
- package/dist/types/main-menu.d.ts +20 -0
- package/dist/types/media.d.ts +631 -0
- package/dist/types/menu.d.ts +82 -0
- package/dist/types/navigation.d.ts +88 -0
- package/dist/types/preview.d.ts +54 -0
- package/dist/types/previewer.d.ts +67 -0
- package/dist/types/properties.d.ts +111 -0
- package/dist/types/property-definition.d.ts +286 -0
- package/dist/types/search.d.ts +46 -0
- package/dist/types/section.d.ts +98 -0
- package/dist/types/selection.d.ts +52 -0
- package/dist/types/slots.d.ts +218 -0
- package/dist/types/transfer.d.ts +68 -0
- package/dist/types/tree.d.ts +97 -0
- package/dist/types/undo.d.ts +133 -0
- package/dist/types/upload.d.ts +189 -0
- package/dist/types/view.d.ts +192 -0
- package/dist/utils/action-groups.d.ts +17 -0
- package/dist/utils/bidi.d.ts +15 -0
- package/dist/utils/clipboard.d.ts +30 -0
- package/dist/utils/cx.d.ts +2 -0
- package/dist/utils/dom.d.ts +36 -0
- package/dist/utils/download.d.ts +30 -0
- package/dist/utils/field-errors.d.ts +26 -0
- package/dist/utils/files.d.ts +48 -0
- package/dist/utils/format.d.ts +10 -0
- package/dist/utils/groups.d.ts +29 -0
- package/dist/utils/hidden.d.ts +3 -0
- package/dist/utils/keyboard.d.ts +21 -0
- package/dist/utils/limits.d.ts +7 -0
- package/dist/utils/media.d.ts +146 -0
- package/dist/utils/menu-position.d.ts +13 -0
- package/dist/utils/names.d.ts +21 -0
- package/dist/utils/navigation.d.ts +28 -0
- package/dist/utils/path.d.ts +33 -0
- package/dist/utils/permissions.d.ts +56 -0
- package/dist/utils/preview.d.ts +27 -0
- package/dist/utils/property-value.d.ts +41 -0
- package/dist/utils/resize.d.ts +2 -0
- package/dist/utils/search.d.ts +24 -0
- package/dist/utils/sections.d.ts +11 -0
- package/dist/utils/selection.d.ts +30 -0
- package/dist/utils/sets.d.ts +2 -0
- package/dist/utils/shortcut.d.ts +74 -0
- package/dist/utils/slots.d.ts +15 -0
- package/dist/utils/sort.d.ts +47 -0
- package/dist/utils/transfer.d.ts +48 -0
- package/dist/utils/trash.d.ts +25 -0
- package/dist/utils/undo.d.ts +63 -0
- package/dist/utils/zoom.d.ts +14 -0
- package/docs/README.md +55 -0
- package/docs/actions.md +301 -0
- package/docs/adapter.md +229 -0
- package/docs/copy-move-trash-undo.md +97 -0
- package/docs/customizing.md +247 -0
- package/docs/getting-started.md +168 -0
- package/docs/locale-and-rtl.md +58 -0
- package/docs/media-manager.md +498 -0
- package/docs/previewing.md +124 -0
- package/docs/properties.md +125 -0
- package/docs/recipes/in-memory-adapter.md +149 -0
- package/docs/recipes/rest-adapter.md +225 -0
- package/docs/recipes/s3-adapter.md +137 -0
- package/docs/search.md +73 -0
- package/docs/sections.md +119 -0
- package/docs/state-and-api.md +190 -0
- package/docs/uploads-and-downloads.md +144 -0
- package/package.json +90 -4
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Clash, EntryClash, FileAdapter, FileEntry, MovingIds, MovingKind, MovingKinds, TransferItem, TransferKind } from "../types/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* The names of `entries`, or of files and folders being uploaded, that a folder's listing already
|
|
4
|
+
* has, which a transfer or upload into it would clash with, with what has each there, and whether
|
|
5
|
+
* it can be replaced or merged into (`replaceable`, given the entry there).
|
|
6
|
+
*/
|
|
7
|
+
export declare const findClashes: (entries: readonly Pick<FileEntry, "name" | "kind">[], listing: FileEntry[] | undefined, replaceable: (entry: FileEntry) => boolean) => Clash[];
|
|
8
|
+
/**
|
|
9
|
+
* The clashes of entries going into a folder together, in their order: with what its listing has,
|
|
10
|
+
* as `findClashes` finds them, and else with an entry before them of the same name, as entries
|
|
11
|
+
* from several folders may share names (`shared`). Those go in after it, so it's there by then.
|
|
12
|
+
*/
|
|
13
|
+
export declare const entryClashes: (entries: readonly FileEntry[], listing: FileEntry[] | undefined, replaceable: (entry: FileEntry) => boolean) => EntryClash[];
|
|
14
|
+
/**
|
|
15
|
+
* Whether entries `from` serves can be copied, or moved (`kind`), into a folder `to` serves: by the
|
|
16
|
+
* adapter's own `copy` or `move` when it's the same one, and otherwise by the file manager, which
|
|
17
|
+
* reads them through `from`'s `list` and `content`, writes them through `to`'s `upload`, and
|
|
18
|
+
* `createFolder` for folders, and for a move deletes each through `from`'s `delete` once it's there
|
|
19
|
+
* (see `transferAcross`).
|
|
20
|
+
*/
|
|
21
|
+
export declare const carries: (kind: TransferKind, from: FileAdapter, to: FileAdapter, entries: readonly FileEntry[]) => boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Whether entries an adapter serves can be carried anywhere at all, so they're dragged: moved or
|
|
24
|
+
* copied by it, or read to be copied into another adapter's folder.
|
|
25
|
+
*/
|
|
26
|
+
export declare const canCarry: (adapter: FileAdapter) => boolean;
|
|
27
|
+
/** Whether two of the entries share a name, so they have to go into one folder one after another. */
|
|
28
|
+
export declare const sharesNames: (entries: readonly FileEntry[]) => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Ids of the folders in a folder's listing that a transfer of `entries` into it with "replace"
|
|
31
|
+
* merges folders of their names into, so what's in them may change all the way down: those that
|
|
32
|
+
* can be merged into (`replaceable`).
|
|
33
|
+
*/
|
|
34
|
+
export declare const mergedFolders: (entries: readonly FileEntry[], listing: FileEntry[] | undefined, replaceable: (entry: FileEntry) => boolean) => string[];
|
|
35
|
+
/** Whether a copy or move is a move still to end, waiting or under way; a failed one has stopped. */
|
|
36
|
+
export declare const isMoving: (item: TransferItem) => boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The entries the moves among `items` are moving, by the adapter serving them (`isMoving`), and
|
|
39
|
+
* those `held` otherwise, as entries going to the trash or coming back from it are, each with what
|
|
40
|
+
* holds it.
|
|
41
|
+
*/
|
|
42
|
+
export declare const movingIds: (items: readonly TransferItem[], held?: readonly {
|
|
43
|
+
adapter: FileAdapter;
|
|
44
|
+
entries: readonly FileEntry[];
|
|
45
|
+
kind: MovingKind;
|
|
46
|
+
}[]) => MovingIds;
|
|
47
|
+
/** The ids of the entries held through `adapter`, each with what holds it. */
|
|
48
|
+
export declare const movingThrough: (moving: MovingIds, adapter: FileAdapter | undefined) => MovingKinds;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { FileAdapter, FileEntry, FolderRef, Section, TrashInfo, TrashResult, UndoFolder } from "../types/index.js";
|
|
2
|
+
/** Whether the folder at `trail` is the root of a trash (`Section.trash`), where entries are restored from. */
|
|
3
|
+
export declare const inTrashRoot: (section: Section, trail: readonly FolderRef[]) => boolean;
|
|
4
|
+
/** The trash sections `served` serves, in the sidebar's order. */
|
|
5
|
+
export declare const trashesOf: (sections: Iterable<Section>, adapter: FileAdapter, served: FileAdapter) => Section[];
|
|
6
|
+
/**
|
|
7
|
+
* The folder an entry in the trash was moved there from, as a folder of a section: the first, in
|
|
8
|
+
* the sidebar's order, served by `served`, not a trash, whose root is in the entry's trail, with
|
|
9
|
+
* the trail below its root, one that isn't `readOnly` coming first, as the entry may go back to
|
|
10
|
+
* the trash from there. Null when no section shows it, as ids are never parsed.
|
|
11
|
+
*/
|
|
12
|
+
export declare const trashOrigin: (sections: Iterable<Section>, adapter: FileAdapter, served: FileAdapter, { trail }: TrashInfo) => UndoFolder | null;
|
|
13
|
+
/**
|
|
14
|
+
* Where an entry in the trash was moved there from, written out as a search's results show where
|
|
15
|
+
* they are: the section's label and the folders below its root, or, with no section showing it,
|
|
16
|
+
* every folder of its trail.
|
|
17
|
+
*/
|
|
18
|
+
export declare const trashedLocation: (sections: Iterable<Section>, adapter: FileAdapter, served: FileAdapter, info: TrashInfo) => string;
|
|
19
|
+
/**
|
|
20
|
+
* The date an entry goes by: in the trash's root, when it was moved there, which the list shows and
|
|
21
|
+
* orders by in place of when it was modified, and elsewhere, when it was modified.
|
|
22
|
+
*/
|
|
23
|
+
export declare const trashedDate: (entry: FileEntry) => Date | undefined;
|
|
24
|
+
/** The entries `trash` or `restore` says it moved, when it says. */
|
|
25
|
+
export declare const trashMade: (result: TrashResult | void) => FileEntry[] | undefined;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { ConflictPolicy, EntryGroup, FileAdapter, FileEntry, MadePair, Section, UndoAction, UndoDirection, UndoFolders, UndoHistory, UndoStep, WentEntry } from "../types/index.js";
|
|
2
|
+
/** How many changes are kept to undo, unless `FileManagerLimits.undoSteps` says otherwise. */
|
|
3
|
+
export declare const UNDO_STEPS = 20;
|
|
4
|
+
export declare const NO_HISTORY: UndoHistory;
|
|
5
|
+
/** The other list of the history: what undoing a step leaves to redo, and the other way round. */
|
|
6
|
+
export declare const otherWay: (direction: UndoDirection) => UndoDirection;
|
|
7
|
+
/**
|
|
8
|
+
* Two actions of a kind carried out in parts as one, `first`'s parts first, as what's left of an
|
|
9
|
+
* undo or redo that failed partway joins what it did then; null for any but a move to the trash's
|
|
10
|
+
* or a restore's.
|
|
11
|
+
*/
|
|
12
|
+
export declare const joinActions: (first: UndoAction, then: UndoAction) => UndoAction | null;
|
|
13
|
+
/** The latest `limit` steps of a list, `Infinity` keeping them all. */
|
|
14
|
+
export declare const latestSteps: (steps: UndoStep[], limit: number) => UndoStep[];
|
|
15
|
+
/**
|
|
16
|
+
* What each entry a copy or move took became, from what the adapter says it made
|
|
17
|
+
* (`TransferResult`), or null when that can't be told, so it can't be undone: nothing was said,
|
|
18
|
+
* "replace" took the place of what was there, which is gone, or what came back doesn't answer what
|
|
19
|
+
* was given. Kept both, every entry went, in their order; skipped, those that went kept their names.
|
|
20
|
+
*/
|
|
21
|
+
export declare const madePairs: (given: readonly FileEntry[], made: readonly FileEntry[] | undefined, conflict: ConflictPolicy) => MadePair[] | null;
|
|
22
|
+
/**
|
|
23
|
+
* What each entry a copy or move that stopped partway took became, from what the adapter reported
|
|
24
|
+
* of each as it went (`WentEntry`), or null when that can't be told: it didn't say what one became,
|
|
25
|
+
* or "replace" took the place of what was there.
|
|
26
|
+
*/
|
|
27
|
+
export declare const wentPairs: (went: readonly WentEntry[], conflict: ConflictPolicy) => MadePair[] | null;
|
|
28
|
+
/**
|
|
29
|
+
* Entries as a folder's listing now has them, each by its id, with the kind and name it had, and,
|
|
30
|
+
* `exactly`, the size, date modified and, for a folder, the count of what's in it it had, where both
|
|
31
|
+
* say: `found` in their order, and those that aren't (`changed`), renamed, replaced, changed, moved
|
|
32
|
+
* or gone since.
|
|
33
|
+
*/
|
|
34
|
+
export declare const asLeft: (listed: readonly FileEntry[], expected: readonly FileEntry[], exactly: boolean) => {
|
|
35
|
+
found: FileEntry[];
|
|
36
|
+
changed: FileEntry[];
|
|
37
|
+
};
|
|
38
|
+
/** The groups of entries an action acts on, where they are now. */
|
|
39
|
+
export declare const actionGroups: (action: UndoAction) => EntryGroup[];
|
|
40
|
+
/**
|
|
41
|
+
* The folders a step changes, by the adapter serving them, which show the progress bar while it
|
|
42
|
+
* runs. The trash a move to the trash or a restore goes through isn't named by it, and is the file
|
|
43
|
+
* manager's to add.
|
|
44
|
+
*/
|
|
45
|
+
export declare const changedFolders: ({ action, adapter }: UndoStep) => UndoFolders[];
|
|
46
|
+
/**
|
|
47
|
+
* Every section a step names, with the adapter it was served by: where its entries are, and where
|
|
48
|
+
* it puts what it makes or moves.
|
|
49
|
+
*/
|
|
50
|
+
export declare const stepSections: ({ action, adapter }: UndoStep) => {
|
|
51
|
+
section: Section;
|
|
52
|
+
adapter: FileAdapter;
|
|
53
|
+
}[];
|
|
54
|
+
/**
|
|
55
|
+
* Whether a step still means what it did: every section it names is the file manager's, rooted where
|
|
56
|
+
* it was and served by the adapter it was, as another adapter's ids, or another root's trails, name
|
|
57
|
+
* something else.
|
|
58
|
+
*/
|
|
59
|
+
export declare const stepHolds: (step: UndoStep, sectionsById: ReadonlyMap<string, Section>, adapter: FileAdapter) => boolean;
|
|
60
|
+
/** The history without the steps that no longer mean what they did (`stepHolds`), the same object when none goes. */
|
|
61
|
+
export declare const heldHistory: (history: UndoHistory, sectionsById: ReadonlyMap<string, Section>, adapter: FileAdapter) => UndoHistory;
|
|
62
|
+
/** Whether an adapter can undo a change of some kind, for the main menu and the keys to be offered at all. */
|
|
63
|
+
export declare const canUndoWith: (adapter: FileAdapter) => boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ViewMode, ViewZoom, ZoomStep } from "../types/index.js";
|
|
2
|
+
export declare const DEFAULT_ZOOM: ViewZoom;
|
|
3
|
+
/** The side of a list entry's icon or thumbnail at a zoom, in rem. */
|
|
4
|
+
export declare const listIconSize: (zoom: number) => number;
|
|
5
|
+
/** The grid's icon and column sizes at a zoom, in rem. */
|
|
6
|
+
export declare const gridSize: (zoom: number) => import("../types/index.js").GridSize;
|
|
7
|
+
/** Whether two zooms are the same, view by view. */
|
|
8
|
+
export declare const sameZoom: (a: ViewZoom, b: ViewZoom) => boolean;
|
|
9
|
+
/** Whether a view can zoom a step in or out, or back to its start, from where it shows. */
|
|
10
|
+
export declare const canZoom: (zoom: ViewZoom, view: ViewMode, step: ZoomStep) => boolean;
|
|
11
|
+
/** The zoom with a view zoomed a step in or out from where it shows, or back to its start. */
|
|
12
|
+
export declare const zoomedBy: (zoom: ViewZoom, view: ViewMode, step: ZoomStep) => ViewZoom;
|
|
13
|
+
/** A view's size as a share of the one it starts at, 1.5 for 150%, as the view menu shows it. */
|
|
14
|
+
export declare const zoomScale: (zoom: ViewZoom, view: ViewMode) => number;
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# filecove documentation
|
|
2
|
+
|
|
3
|
+
filecove is a file manager for React apps, and a media manager built on the same parts. It runs entirely in the browser and has no idea what your backend is. You give it an **adapter**, an object of async functions that list folders and, optionally, rename, upload, delete and so on, and it gives you a complete file manager: a sidebar, a list and a grid, search, drag and drop, uploads, downloads, a preview, a properties panel, a trash, undo, keyboard navigation, screen reader support and right-to-left layouts.
|
|
4
|
+
|
|
5
|
+
It ships as three components:
|
|
6
|
+
|
|
7
|
+
- **`FileManager`** browses folders, as a desktop file manager does.
|
|
8
|
+
- **`MediaManager`** looks through libraries of media (pictures, videos, audio, documents) and picks from them, as a CMS's media library does.
|
|
9
|
+
- **`MediaPicker`** is one library to find, or upload, an asset in, for a field pointing at one.
|
|
10
|
+
|
|
11
|
+
It needs React 19, and has no styling runtime: one stylesheet you import, themed with CSS custom properties.
|
|
12
|
+
|
|
13
|
+
## Where to start
|
|
14
|
+
|
|
15
|
+
1. [Getting started](getting-started.md): install, the stylesheet, a first adapter, a first render, and the mistakes that cost the most time.
|
|
16
|
+
2. [The adapter](adapter.md): the backend contract. Read this before writing one for real.
|
|
17
|
+
3. [Actions](actions.md): the context menu is yours to fill. This page has a complete set to copy.
|
|
18
|
+
|
|
19
|
+
## Guides
|
|
20
|
+
|
|
21
|
+
| Page | What's in it |
|
|
22
|
+
|---|---|
|
|
23
|
+
| [Sections](sections.md) | the sidebar's roots, one or several backends, read-only sections, the trash section |
|
|
24
|
+
| [Actions](actions.md) | the context menu, the header's, the preview's and the properties' buttons, shortcuts, the main menu |
|
|
25
|
+
| [Opening and previewing](previewing.md) | `onOpenFile`, the built-in preview, previewers of your own, thumbnails |
|
|
26
|
+
| [Uploads and downloads](uploads-and-downloads.md) | `upload`, `content`, `download`, limiting what a section takes |
|
|
27
|
+
| [Copy, move, trash and undo](copy-move-trash-undo.md) | what the adapter returns so the user can undo, copying between backends, the trash |
|
|
28
|
+
| [Search](search.md) | the folder search and search everywhere |
|
|
29
|
+
| [Properties](properties.md) | the properties panel, the backend's fields, editing them, folder totals |
|
|
30
|
+
| [State and the API](state-and-api.md) | controlled props, keeping the location in the URL, `apiRef` |
|
|
31
|
+
| [Customizing](customizing.md) | theming, the two stylesheets, stable class names, slots, `slotProps`, icons |
|
|
32
|
+
| [Text, languages and right to left](locale-and-rtl.md) | `localeText`, `locale`, `dir="rtl"` |
|
|
33
|
+
| [Media manager](media-manager.md) | libraries, groups, picking, moving and deleting several, dragging, forms, processing, `MediaPicker` |
|
|
34
|
+
|
|
35
|
+
## Recipes
|
|
36
|
+
|
|
37
|
+
Complete adapters to start from:
|
|
38
|
+
|
|
39
|
+
- [An in-memory adapter](recipes/in-memory-adapter.md), for trying things out and for tests.
|
|
40
|
+
- [An adapter over a REST API](recipes/rest-adapter.md), the usual case.
|
|
41
|
+
- [An adapter over S3 with presigned URLs](recipes/s3-adapter.md), for a bucket your server signs requests to.
|
|
42
|
+
|
|
43
|
+
## Reference
|
|
44
|
+
|
|
45
|
+
The type definitions are the reference. Every public prop and type has a doc comment, so your editor shows it on hover, and the `.d.ts` files in `node_modules/filecove/dist/` can be read directly: `components/file-manager/file-manager.d.ts` for `FileManager`'s props, `types/adapter.d.ts` for the adapter, `types/action.d.ts` for actions, and so on. These pages explain how the pieces fit together; the types say exactly what each member takes.
|
|
46
|
+
|
|
47
|
+
## For AI coding assistants
|
|
48
|
+
|
|
49
|
+
If you're an agent integrating filecove into an app:
|
|
50
|
+
|
|
51
|
+
- These docs ship inside the package, at `node_modules/filecove/docs/`, and match the installed version.
|
|
52
|
+
- Start from [getting-started.md](getting-started.md) and a recipe in [recipes/](recipes/). Write the adapter first, then the actions.
|
|
53
|
+
- The context menu is empty until you pass `actions`. Copy the set in [actions.md](actions.md).
|
|
54
|
+
- Check member names against `node_modules/filecove/dist/types/*.d.ts` rather than guessing; the API isn't MUI's or any other library's.
|
|
55
|
+
- Keep `adapter` and `sections` stable across renders (module scope or `useMemo`). A new adapter object each render resets the file manager.
|
package/docs/actions.md
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
# Actions
|
|
2
|
+
|
|
3
|
+
filecove adds nothing to its menus by itself. Every item in the context menu, and every button you add to the header, the preview or the properties panel, is an **action** of yours: you choose its label, icon, shortcut and place. What the file manager gives you is an `ActionContext`, saying what was targeted and offering the operations that can run there.
|
|
4
|
+
|
|
5
|
+
## How an action works
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
interface FileAction {
|
|
9
|
+
id: string;
|
|
10
|
+
label: string;
|
|
11
|
+
icon?: IconSource; // an icon name or your own element
|
|
12
|
+
target?: "selection" | "folder"; // only for entries, or only for a folder's empty space
|
|
13
|
+
single?: boolean; // only when exactly one entry is targeted
|
|
14
|
+
acrossFolders?: boolean; // also for a search's results from several folders
|
|
15
|
+
visible?: (context: ActionContext) => boolean;
|
|
16
|
+
disabled?: (context: ActionContext) => boolean;
|
|
17
|
+
shortcut?: string; // "Ctrl+C", "Shift+Ctrl+N", "F2", "Delete"
|
|
18
|
+
destructive?: boolean; // shown in the error colour
|
|
19
|
+
onSelect: (context: ActionContext) => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface ActionGroup {
|
|
23
|
+
id: string;
|
|
24
|
+
actions: FileAction[]; // a rule divides each group from the next
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The context menu opens on a right-click, the ⋮ buttons, the Menu key or Shift+F10, and a long-press on touch. It's built from your groups, leaving out actions whose `target`, `single`, `acrossFolders` or `visible` rule them out, and groups left empty. When nothing applies, the browser's own menu is left alone.
|
|
29
|
+
|
|
30
|
+
### The context
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
interface ActionContext {
|
|
34
|
+
target: "selection" | "folder";
|
|
35
|
+
entries: FileEntry[]; // what's selected, or none for a folder's empty space
|
|
36
|
+
folder: FolderRef; // the folder they're in, or the folder itself
|
|
37
|
+
section: Section;
|
|
38
|
+
byFolder?: ContextFolder[]; // a search's results from several folders, grouped
|
|
39
|
+
readOnly: boolean; // the folder can't change
|
|
40
|
+
moving: boolean; // a move under way holds the entries
|
|
41
|
+
refresh(): void;
|
|
42
|
+
openFolder(entry: FileEntry): void;
|
|
43
|
+
properties(): void; // always there
|
|
44
|
+
|
|
45
|
+
// Each of the rest is optional, `() => void`, and there only when it can run here:
|
|
46
|
+
// open, openLocation, openOrigin, select, preview, closePreview, download,
|
|
47
|
+
// createFolder, createFolderInto, rename, copyTo, moveTo, cut, copy, paste, pasteInto,
|
|
48
|
+
// delete, trash, restore, emptyTrash, upload (takes optional files), uploadFolder, undo, redo
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**An operation is missing when it can't run here**: the adapter lacks the method (`rename` without `adapter.rename`), the permissions or a read-only section refuse it, the target doesn't fit (`rename` with several entries, `paste` with nothing to paste), or it's the wrong kind of place (`restore` outside a trash). So the usual pattern is to show an action only while its operation is there:
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
visible: (context) => !!context.rename,
|
|
56
|
+
onSelect: (context) => context.rename?.(),
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Or keep it in the menu, greyed out, as Paste usually is:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
disabled: (context) => !context.paste,
|
|
63
|
+
onSelect: (context) => context.paste?.(),
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The operations open the file manager's own dialogs where they need to ask something (a name, a destination, a confirmation), run in the background where they take a while, and show their errors.
|
|
67
|
+
|
|
68
|
+
### Actions of your own
|
|
69
|
+
|
|
70
|
+
An action doesn't have to call an operation. Anything of your app's goes in `onSelect`, with the context saying what it's for:
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
{
|
|
74
|
+
id: "share",
|
|
75
|
+
label: "Share",
|
|
76
|
+
icon: "share",
|
|
77
|
+
target: "selection",
|
|
78
|
+
acrossFolders: true,
|
|
79
|
+
visible: (context) => !context.section.trash,
|
|
80
|
+
onSelect: (context) => openShareDialog(context.entries),
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
id: "compress",
|
|
84
|
+
label: "Compress…",
|
|
85
|
+
target: "selection",
|
|
86
|
+
// The archive goes beside the entries, which a read-only folder can't take.
|
|
87
|
+
visible: (context) => !context.readOnly && !context.moving,
|
|
88
|
+
onSelect: async (context) => {
|
|
89
|
+
await api.compress(context.folder.id, context.entries.map((entry) => entry.id));
|
|
90
|
+
context.refresh();
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Call `context.refresh()` after changing the backend yourself, so the folder is listed again.
|
|
96
|
+
|
|
97
|
+
### A search's results from several folders
|
|
98
|
+
|
|
99
|
+
A search everywhere's selection may hold entries from several folders, even several sections. Most adapter calls take entries sharing one folder, so actions are left out for such a selection unless marked `acrossFolders: true`. Mark an action so when it goes by `entries` alone, by `byFolder`, or calls the context's own operations, which all handle several folders. Leave it off for an action that acts on `context.folder` or `context.section`, which aren't where all the entries are.
|
|
100
|
+
|
|
101
|
+
### Shortcuts
|
|
102
|
+
|
|
103
|
+
`shortcut` is shown beside the label and bound to the keyboard: a press runs the action for the selection if it applies there, or else for the open folder. Write keys joined by `+`, as `"Ctrl+C"`, `"Shift+Ctrl+N"`, `"Alt+Enter"`, `"F2"` or `"Delete"`.
|
|
104
|
+
|
|
105
|
+
- `Ctrl` also matches ⌘ on macOS.
|
|
106
|
+
- A letter or digit is the key printed with it, on any keyboard layout: Ctrl+Z is the key marked Z on AZERTY and QWERTZ too, and on a Russian or Arabic layout, the key with the Latin Z printed beside its own letter.
|
|
107
|
+
- Your shortcuts come before the file manager's own keys, so an action bound to Space or Enter takes them in the content.
|
|
108
|
+
- A shortcut on a disabled action still takes the key, so the browser does nothing with it. The paste key is the exception, as the browser's paste may carry files from the desktop to upload.
|
|
109
|
+
- Browsers keep some keys for themselves: Chrome never passes Ctrl+N, Ctrl+T or Ctrl+W to a page.
|
|
110
|
+
|
|
111
|
+
Every shortcut you give is listed in the file manager's keyboard shortcuts window (Ctrl+?).
|
|
112
|
+
|
|
113
|
+
## A complete set to start from
|
|
114
|
+
|
|
115
|
+
This is the set the development playground uses, without its demo actions. Copy it, change the labels to your app's wording or language, and remove what you don't want. Every item hides itself where it can't run.
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
import type { ActionGroup } from "filecove";
|
|
119
|
+
|
|
120
|
+
export const fileActions: ActionGroup[] = [
|
|
121
|
+
{
|
|
122
|
+
id: "open",
|
|
123
|
+
actions: [
|
|
124
|
+
{ id: "open", label: "Open", icon: "folderOpen", target: "selection", single: true,
|
|
125
|
+
visible: (c) => !!c.open, onSelect: (c) => c.open?.() },
|
|
126
|
+
// Only on a search's result: opens the folder it's in.
|
|
127
|
+
{ id: "open-location", label: "Open item location", icon: "folder", target: "selection", single: true,
|
|
128
|
+
visible: (c) => !!c.openLocation, onSelect: (c) => c.openLocation?.() },
|
|
129
|
+
// Only on an entry in the trash: opens the folder it came from.
|
|
130
|
+
{ id: "open-origin", label: "Open original location", icon: "folder", target: "selection", single: true,
|
|
131
|
+
visible: (c) => !!c.openOrigin, onSelect: (c) => c.openOrigin?.() },
|
|
132
|
+
// Only after a long-press on a folder in the sidebar tree, for its touch selection mode.
|
|
133
|
+
{ id: "select", label: "Select", icon: "selectMode", target: "selection",
|
|
134
|
+
visible: (c) => !!c.select, onSelect: (c) => c.select?.() },
|
|
135
|
+
{ id: "preview", label: "Preview", icon: "preview", shortcut: "Space", target: "selection", acrossFolders: true,
|
|
136
|
+
visible: (c) => !!c.preview, onSelect: (c) => c.preview?.() },
|
|
137
|
+
// On a folder's empty space or a section row, downloads the folder itself.
|
|
138
|
+
{ id: "download", label: "Download", icon: "download", acrossFolders: true,
|
|
139
|
+
visible: (c) => !!c.download, onSelect: (c) => c.download?.() },
|
|
140
|
+
],
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
id: "create",
|
|
144
|
+
actions: [
|
|
145
|
+
{ id: "new-folder", label: "New folder…", icon: "newFolder", shortcut: "Shift+Ctrl+N", target: "folder",
|
|
146
|
+
visible: (c) => !!c.createFolder, onSelect: (c) => c.createFolder?.() },
|
|
147
|
+
{ id: "new-folder-inside", label: "New folder inside…", icon: "newFolder", target: "selection", single: true,
|
|
148
|
+
visible: (c) => !!c.createFolderInto, onSelect: (c) => c.createFolderInto?.() },
|
|
149
|
+
{ id: "upload", label: "Upload files…", icon: "upload", target: "folder",
|
|
150
|
+
visible: (c) => !!c.upload, onSelect: (c) => c.upload?.() },
|
|
151
|
+
{ id: "upload-folder", label: "Upload folder…", icon: "uploadFolder", target: "folder",
|
|
152
|
+
visible: (c) => !!c.uploadFolder, onSelect: (c) => c.uploadFolder?.() },
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
id: "clipboard",
|
|
157
|
+
actions: [
|
|
158
|
+
{ id: "cut", label: "Cut", icon: "cut", shortcut: "Ctrl+X", target: "selection", acrossFolders: true,
|
|
159
|
+
visible: (c) => !!c.cut, onSelect: (c) => c.cut?.() },
|
|
160
|
+
{ id: "copy", label: "Copy", icon: "copy", shortcut: "Ctrl+C", target: "selection", acrossFolders: true,
|
|
161
|
+
visible: (c) => !!c.copy, onSelect: (c) => c.copy?.() },
|
|
162
|
+
// Greyed out while there's nothing to paste; hidden in the trash, which takes nothing.
|
|
163
|
+
{ id: "paste", label: "Paste", icon: "paste", shortcut: "Ctrl+V", target: "folder",
|
|
164
|
+
visible: (c) => !c.section.trash, disabled: (c) => !c.paste, onSelect: (c) => c.paste?.() },
|
|
165
|
+
{ id: "paste-into", label: "Paste into folder", icon: "paste", target: "selection", single: true,
|
|
166
|
+
visible: (c) => c.entries[0].kind === "folder" && !c.section.trash,
|
|
167
|
+
disabled: (c) => !c.pasteInto, onSelect: (c) => c.pasteInto?.() },
|
|
168
|
+
],
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
id: "organize",
|
|
172
|
+
actions: [
|
|
173
|
+
{ id: "copy-to", label: "Copy to…", icon: "copy", target: "selection", acrossFolders: true,
|
|
174
|
+
visible: (c) => !!c.copyTo, onSelect: (c) => c.copyTo?.() },
|
|
175
|
+
{ id: "move-to", label: "Move to…", icon: "move", target: "selection", acrossFolders: true,
|
|
176
|
+
visible: (c) => !!c.moveTo, onSelect: (c) => c.moveTo?.() },
|
|
177
|
+
{ id: "rename", label: "Rename…", icon: "rename", shortcut: "F2", target: "selection", single: true,
|
|
178
|
+
visible: (c) => !!c.rename, onSelect: (c) => c.rename?.() },
|
|
179
|
+
],
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
id: "trash",
|
|
183
|
+
actions: [
|
|
184
|
+
{ id: "restore", label: "Restore", icon: "restore", target: "selection",
|
|
185
|
+
visible: (c) => !!c.restore, onSelect: (c) => c.restore?.() },
|
|
186
|
+
{ id: "empty-trash", label: "Empty trash…", icon: "deleteForever", target: "folder", destructive: true,
|
|
187
|
+
visible: (c) => !!c.emptyTrash, onSelect: (c) => c.emptyTrash?.() },
|
|
188
|
+
],
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
id: "delete",
|
|
192
|
+
actions: [
|
|
193
|
+
// Where the adapter has a trash, Delete moves there and Shift+Delete deletes for good.
|
|
194
|
+
{ id: "trash", label: "Move to trash", icon: "delete", shortcut: "Delete", target: "selection", acrossFolders: true,
|
|
195
|
+
visible: (c) => !!c.trash, onSelect: (c) => c.trash?.() },
|
|
196
|
+
{ id: "delete-for-good", label: "Delete permanently…", icon: "deleteForever", shortcut: "Shift+Delete",
|
|
197
|
+
target: "selection", acrossFolders: true, destructive: true,
|
|
198
|
+
visible: (c) => !!c.delete && !!c.trash, onSelect: (c) => c.delete?.() },
|
|
199
|
+
// Where there's no trash, Delete deletes for good, after asking.
|
|
200
|
+
{ id: "delete", label: "Delete…", icon: "delete", shortcut: "Delete", target: "selection",
|
|
201
|
+
acrossFolders: true, destructive: true,
|
|
202
|
+
visible: (c) => !!c.delete && !c.trash && !c.section.trash, onSelect: (c) => c.delete?.() },
|
|
203
|
+
// In the trash itself.
|
|
204
|
+
{ id: "delete-from-trash", label: "Delete permanently…", icon: "deleteForever", shortcut: "Delete",
|
|
205
|
+
target: "selection", destructive: true,
|
|
206
|
+
visible: (c) => !!c.delete && !!c.section.trash, onSelect: (c) => c.delete?.() },
|
|
207
|
+
],
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
id: "view",
|
|
211
|
+
actions: [
|
|
212
|
+
{ id: "refresh", label: "Refresh", icon: "refresh", shortcut: "F5", target: "folder",
|
|
213
|
+
onSelect: (c) => c.refresh() },
|
|
214
|
+
{ id: "properties", label: "Properties", icon: "info", acrossFolders: true,
|
|
215
|
+
onSelect: (c) => c.properties() },
|
|
216
|
+
],
|
|
217
|
+
},
|
|
218
|
+
];
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Keep the array outside your component (or memoized) so it isn't rebuilt on every render.
|
|
222
|
+
|
|
223
|
+
Undo and redo don't need actions: Ctrl+Z, Shift+Ctrl+Z and the sidebar's main menu do them. `context.undo` and `context.redo` are there for a toolbar of your own.
|
|
224
|
+
|
|
225
|
+
## Buttons in the header
|
|
226
|
+
|
|
227
|
+
`headerActions` puts actions in the header bar, for the content's selection, or with nothing selected, the open folder itself (`target: "folder"`):
|
|
228
|
+
|
|
229
|
+
```tsx
|
|
230
|
+
const headerActions: ActionGroup[] = [
|
|
231
|
+
{
|
|
232
|
+
id: "header",
|
|
233
|
+
actions: [
|
|
234
|
+
{ id: "new-folder", label: "New folder", icon: "newFolder", target: "folder",
|
|
235
|
+
visible: (c) => !!c.createFolder, onSelect: (c) => c.createFolder?.() },
|
|
236
|
+
{ id: "upload", label: "Upload files", icon: "upload", target: "folder",
|
|
237
|
+
visible: (c) => !!c.upload, onSelect: (c) => c.upload?.() },
|
|
238
|
+
{ id: "share", label: "Share", icon: "share", target: "selection",
|
|
239
|
+
onSelect: (c) => openShareDialog(c.entries) },
|
|
240
|
+
],
|
|
241
|
+
},
|
|
242
|
+
];
|
|
243
|
+
|
|
244
|
+
<FileManager headerActions={headerActions} /* ... */ />;
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Two actions with an icon show as buttons while the file manager is at least 900px wide; the rest, and those without an icon, go in a "More actions" menu, as do all of them when it's narrower. Their shortcuts work anywhere in the file manager outside a text field. The same action objects can be in `actions` too.
|
|
248
|
+
|
|
249
|
+
## Buttons in the preview's and the properties' headers
|
|
250
|
+
|
|
251
|
+
`previewActions` and `propertiesActions` work the same way, for the file shown in the preview and for what the properties panel shows. The preview shows up to four as buttons, the properties panel two.
|
|
252
|
+
|
|
253
|
+
In the preview's context, `preview` is missing (it's previewing already) and `closePreview` is there, for an action taking the user elsewhere, such as an editor of yours:
|
|
254
|
+
|
|
255
|
+
```ts
|
|
256
|
+
const previewActions: ActionGroup[] = [
|
|
257
|
+
{
|
|
258
|
+
id: "file",
|
|
259
|
+
actions: [
|
|
260
|
+
{ id: "rename", label: "Rename…", icon: "rename", shortcut: "F2",
|
|
261
|
+
visible: (c) => !!c.rename, onSelect: (c) => c.rename?.() },
|
|
262
|
+
{ id: "edit", label: "Open in editor", icon: "edit",
|
|
263
|
+
visible: (c) => c.entries[0].permissions?.write !== false,
|
|
264
|
+
onSelect: (c) => { c.closePreview?.(); openEditor(c.entries[0]); } },
|
|
265
|
+
],
|
|
266
|
+
},
|
|
267
|
+
];
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Rename, Delete, Move to… and Copy to… open their dialogs over the preview, which follows what they did.
|
|
271
|
+
|
|
272
|
+
## The main menu
|
|
273
|
+
|
|
274
|
+
The ☰ button in the sidebar's header opens the main menu, for what belongs to your app rather than to entries: preferences, help, about. The file manager puts Undo and Redo at its top and "Keyboard shortcuts" at its end.
|
|
275
|
+
|
|
276
|
+
```tsx
|
|
277
|
+
import type { MainMenuGroup } from "filecove";
|
|
278
|
+
|
|
279
|
+
const mainMenu: MainMenuGroup[] = [
|
|
280
|
+
{
|
|
281
|
+
id: "app",
|
|
282
|
+
items: [
|
|
283
|
+
{ id: "preferences", label: "Preferences", icon: "settings", shortcut: "Ctrl+,", onSelect: openPreferences },
|
|
284
|
+
{ id: "about", label: "About", onSelect: openAbout },
|
|
285
|
+
],
|
|
286
|
+
},
|
|
287
|
+
];
|
|
288
|
+
|
|
289
|
+
<FileManager mainMenu={mainMenu} /* ... */ />;
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
An item's `shortcut` works anywhere in the file manager.
|
|
293
|
+
|
|
294
|
+
## Calling operations from outside
|
|
295
|
+
|
|
296
|
+
A toolbar of your own, outside the file manager, gets the same context from `apiRef.current.actionContext(entries?, location?)` (see [State and the API](state-and-api.md#the-api)):
|
|
297
|
+
|
|
298
|
+
```ts
|
|
299
|
+
const context = apiRef.current?.actionContext(); // the open folder
|
|
300
|
+
context?.createFolder?.();
|
|
301
|
+
```
|