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,20 @@
|
|
|
1
|
+
import type { IconSource } from "./icon.js";
|
|
2
|
+
/** An item of the sidebar's main menu, for what belongs to the app rather than to entries. */
|
|
3
|
+
export interface MainMenuItem {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
icon?: IconSource;
|
|
7
|
+
/**
|
|
8
|
+
* Shown beside the label, e.g. "Ctrl+,", and bound to the keyboard anywhere in the file
|
|
9
|
+
* manager, as an action's `shortcut` is, except that a key typing into the search field is
|
|
10
|
+
* left to it unless Ctrl or Alt is held.
|
|
11
|
+
*/
|
|
12
|
+
shortcut?: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
onSelect: () => void;
|
|
15
|
+
}
|
|
16
|
+
/** Items of the main menu shown together, divided from the next group by a rule. */
|
|
17
|
+
export interface MainMenuGroup {
|
|
18
|
+
id: string;
|
|
19
|
+
items: MainMenuItem[];
|
|
20
|
+
}
|
|
@@ -0,0 +1,631 @@
|
|
|
1
|
+
import type { Dispatch, ReactNode, SetStateAction } from "react";
|
|
2
|
+
import type { AssetState, FileAdapter, FileEntry } from "./adapter.js";
|
|
3
|
+
import type { IconSource } from "./icon.js";
|
|
4
|
+
import type { FilePreviewer } from "./previewer.js";
|
|
5
|
+
import type { FieldErrors, PropertyDefinitionGroup } from "./property-definition.js";
|
|
6
|
+
import type { FolderRef, Section } from "./section.js";
|
|
7
|
+
/**
|
|
8
|
+
* The one kind of asset a media manager's library holds, which decides the shape of its tiles
|
|
9
|
+
* (pictures square, videos wide with their length, audio square, documents as pages) and how it's
|
|
10
|
+
* shown unless it says otherwise (`MediaSection.layouts`): audio as rows, the others as tiles.
|
|
11
|
+
*/
|
|
12
|
+
export type MediaKind = "image" | "video" | "audio" | "document";
|
|
13
|
+
/** How a library shows its assets: as tiles in a grid, or as rows in a list. */
|
|
14
|
+
export type MediaLayout = "grid" | "list";
|
|
15
|
+
/**
|
|
16
|
+
* The layout the user is shown each library in, of those it offers (`MediaSection.layouts`), by its
|
|
17
|
+
* `id`. A library left out, or set to one it doesn't offer, shows the first it offers.
|
|
18
|
+
*/
|
|
19
|
+
export type MediaLayouts = Readonly<Record<string, MediaLayout>>;
|
|
20
|
+
/**
|
|
21
|
+
* Where a media manager is: the library shown (`sectionId`) and the groups gone into from its root to
|
|
22
|
+
* the one open (`trail`), none at its root. Handed over with the groups as they were listed, `meta` and
|
|
23
|
+
* all, which `groupHeader` and a group's form read. One the app rebuilds from ids and names, such as from
|
|
24
|
+
* a URL, can give `{ id, name, kind: "folder" }` for each group, which is all that's known of them then.
|
|
25
|
+
*/
|
|
26
|
+
export interface MediaLocation {
|
|
27
|
+
sectionId: string;
|
|
28
|
+
trail: readonly FileEntry[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Why the location changed: the user, or the app through `apiRef`, went there ("navigate"), or what
|
|
32
|
+
* was there changed under it ("replace"): a group on the way deleted, moved or renamed, or the library
|
|
33
|
+
* gone, rooted elsewhere or served by another adapter. An app keeping it in the URL pushes an entry of
|
|
34
|
+
* the browser's history for the first, and replaces the one it's on for the second.
|
|
35
|
+
*/
|
|
36
|
+
export type MediaLocationChangeReason = "navigate" | "replace";
|
|
37
|
+
/**
|
|
38
|
+
* The asset, or the group's details, shown in a library's place (`entry`), in the library it's in
|
|
39
|
+
* (`sectionId`), among the groups it's in from that library's root (`trail`), which a search may have
|
|
40
|
+
* found below the one open. Handed over with `trail` always; leave it out for the groups open. Shown
|
|
41
|
+
* only while its library is the one shown.
|
|
42
|
+
*/
|
|
43
|
+
export interface MediaViewed {
|
|
44
|
+
sectionId: string;
|
|
45
|
+
entry: FileEntry;
|
|
46
|
+
trail?: readonly FileEntry[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A media manager's search, while it's open: what's typed, as typed, and what the library's filters
|
|
50
|
+
* hold. Closed, it's null, so a closed search has no query and no filters. It's an object so it can
|
|
51
|
+
* grow, by addition, without changing what's there.
|
|
52
|
+
*/
|
|
53
|
+
export interface MediaSearch {
|
|
54
|
+
query: string;
|
|
55
|
+
/**
|
|
56
|
+
* What the library's filter form holds as the user set it (`MediaSection.filterForm`), by the
|
|
57
|
+
* app's own keys; left out, the form's defaults, which is nothing set.
|
|
58
|
+
*/
|
|
59
|
+
filters?: Readonly<Record<string, unknown>>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* What the app's form is handed each time it's drawn. The media manager keeps what it holds, and the
|
|
63
|
+
* form changes it, so anything in it can follow anything else: a field off as another is unticked,
|
|
64
|
+
* and what it held gone. What it holds is the app's, by its own keys, and the media manager never
|
|
65
|
+
* reads it.
|
|
66
|
+
*/
|
|
67
|
+
export interface MediaFormParams<V = Record<string, unknown>> {
|
|
68
|
+
/** What it holds now: its `defaults` until it's changed. */
|
|
69
|
+
values: V;
|
|
70
|
+
/** Puts other values in their place, all of them, or a function of those there, as React's own setter does. */
|
|
71
|
+
setValues: Dispatch<SetStateAction<V>>;
|
|
72
|
+
/** The library it's for. */
|
|
73
|
+
section: MediaSection;
|
|
74
|
+
/** That library's adapter, its own or the media manager's. */
|
|
75
|
+
adapter: FileAdapter;
|
|
76
|
+
/**
|
|
77
|
+
* What's wrong with what it holds, by the backend's own keys, a message or several each: a pick's
|
|
78
|
+
* as the app passed them (`MediaManager`'s `errors`), empty for a pick the backend never saw; an
|
|
79
|
+
* upload's or a process form's as its refusal said (`MediaFormRefusal`), until it's sent again.
|
|
80
|
+
* `MediaFields` shows each field's under it, by its `errorKey`.
|
|
81
|
+
*/
|
|
82
|
+
errors: FieldErrors;
|
|
83
|
+
/**
|
|
84
|
+
* The place the keys in `errors` are made from: a pick's in the order the app was handed the
|
|
85
|
+
* picks in, from 0; always 0 in an upload's or a process form, which are about one thing.
|
|
86
|
+
*/
|
|
87
|
+
index: number;
|
|
88
|
+
}
|
|
89
|
+
/** What a library's upload form is handed (`MediaSection.uploadForm`). */
|
|
90
|
+
export interface MediaUploadFormParams<V = Record<string, unknown>> extends MediaFormParams<V> {
|
|
91
|
+
/** The files about to be uploaded. */
|
|
92
|
+
files: readonly File[];
|
|
93
|
+
/**
|
|
94
|
+
* The asset whose file the one in `files` is about to take the place of, from its view's Replace
|
|
95
|
+
* file (`FileAdapter.replace`); undefined for an upload.
|
|
96
|
+
*/
|
|
97
|
+
replacing?: FileEntry;
|
|
98
|
+
/**
|
|
99
|
+
* The asset the files go into as a part of it, from a property's Upload in its view
|
|
100
|
+
* (`PropertyDefinition.upload`, `FileAdapter.uploadPart`), with `part`, the part's name; both
|
|
101
|
+
* undefined for an upload into the library.
|
|
102
|
+
*/
|
|
103
|
+
partOf?: FileEntry;
|
|
104
|
+
part?: string;
|
|
105
|
+
/** Whether its `validate` is being answered, while nothing in it should change. */
|
|
106
|
+
sending: boolean;
|
|
107
|
+
}
|
|
108
|
+
/** What a library's process form is handed (`MediaSection.processForm`). */
|
|
109
|
+
export interface MediaProcessFormParams<V = Record<string, unknown>> extends MediaFormParams<V> {
|
|
110
|
+
/**
|
|
111
|
+
* The asset as it's listed now, a new object each time its backend's work moves on, so anything
|
|
112
|
+
* loaded from it goes by `asset.id`.
|
|
113
|
+
*/
|
|
114
|
+
asset: FileEntry;
|
|
115
|
+
/** Whether it's being sent to the adapter's `process`, while nothing in it should change. */
|
|
116
|
+
sending: boolean;
|
|
117
|
+
}
|
|
118
|
+
/** What a library's group form is asked for (`MediaSection.groupForm`). */
|
|
119
|
+
export interface MediaGroupTarget {
|
|
120
|
+
/** The group being edited, or `null` for one being made. */
|
|
121
|
+
group: FileEntry | null;
|
|
122
|
+
/** The group it's in, or would be made in, `null` at the library's root. */
|
|
123
|
+
parent: FileEntry | null;
|
|
124
|
+
}
|
|
125
|
+
/** What a library's group form is handed (`MediaSection.groupForm`). */
|
|
126
|
+
export interface MediaGroupFormParams<V = Record<string, unknown>> extends MediaFormParams<V>, MediaGroupTarget {
|
|
127
|
+
/** The group again, or nothing for one being made, so `<MediaFields {...form} />` has it as its asset. */
|
|
128
|
+
asset: FileEntry | undefined;
|
|
129
|
+
/** Whether it's being sent to the adapter, while nothing in it should change. */
|
|
130
|
+
sending: boolean;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* What a library's filter form is handed (`MediaSection.filterForm`). Its `errors` are always empty,
|
|
134
|
+
* as nothing refuses a filter, and its `index` 0.
|
|
135
|
+
*/
|
|
136
|
+
export interface MediaFilterFormParams<V = Record<string, unknown>> extends MediaFormParams<V> {
|
|
137
|
+
/** The group open, which the search goes down from, or `null` at the library's root. */
|
|
138
|
+
group: FileEntry | null;
|
|
139
|
+
}
|
|
140
|
+
/** What a pick's form is handed (`MediaManager`'s `pickForm`). */
|
|
141
|
+
export interface MediaPickFormParams<V = Record<string, unknown>> extends MediaFormParams<V> {
|
|
142
|
+
asset: FileEntry;
|
|
143
|
+
/** Every pick as it stands now, this one too, in the order set, for rules across them. */
|
|
144
|
+
choices: readonly MediaChoice<V>[];
|
|
145
|
+
/** Changes what another pick's form holds, as `setValues` does this one's. */
|
|
146
|
+
setChoiceValues: (choice: MediaChoice<V>, next: SetStateAction<V>) => void;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* What a form's own functions are handed: what it's drawn with, without what changes it, as they only
|
|
150
|
+
* read it, and are asked of a pick's form while it isn't open too.
|
|
151
|
+
*/
|
|
152
|
+
export type MediaFormState<P> = Omit<P, "setValues" | "setChoiceValues">;
|
|
153
|
+
type FormDefaults<V> = {} extends V ? {
|
|
154
|
+
defaults?: V;
|
|
155
|
+
} : {
|
|
156
|
+
defaults: V;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* A form of the app's: what it holds as it's shown, how it's drawn, and whether it's ready to go.
|
|
160
|
+
* `MediaFields` draws fields from their definitions, for all of it or a part, and anything else the
|
|
161
|
+
* app likes can go around them or in their place.
|
|
162
|
+
*/
|
|
163
|
+
export type MediaForm<P extends {
|
|
164
|
+
values: unknown;
|
|
165
|
+
} = MediaFormParams> = FormDefaults<P["values"]> & {
|
|
166
|
+
/**
|
|
167
|
+
* Draws it, each time what it holds changes, as a component of its own, so it may use hooks. Return
|
|
168
|
+
* the app's own component as an element, `(form) => <VideoFields {...form} />`, defined outside
|
|
169
|
+
* this function, or it would start over each time, which the console warns of.
|
|
170
|
+
*/
|
|
171
|
+
render(params: P): ReactNode;
|
|
172
|
+
/**
|
|
173
|
+
* Whether what it holds can go on: `true`, or `false`, or why not, in the app's language. Until
|
|
174
|
+
* it can, its button (Upload, Process or Choose) is held back, with why beside it, and a pick's row
|
|
175
|
+
* says so too. Without it, it always can, the backend having the last word.
|
|
176
|
+
*/
|
|
177
|
+
ready?(params: MediaFormState<P>): boolean | string;
|
|
178
|
+
};
|
|
179
|
+
/** A pick's form (`MediaManager`'s `pickForm`). */
|
|
180
|
+
export type MediaPickForm<V = Record<string, unknown>> = MediaForm<MediaPickFormParams<V>> & {
|
|
181
|
+
/**
|
|
182
|
+
* The backend's keys for the fields it has now, one entry a field, each a key or the keys of a field
|
|
183
|
+
* holding several, made from `index` and what it holds, so what's gone from it isn't counted. Its row
|
|
184
|
+
* in the selected column says how many of them have a message, while the form isn't open.
|
|
185
|
+
*/
|
|
186
|
+
errorKeys?(params: MediaFormState<MediaPickFormParams<V>>): ReadonlyArray<string | readonly string[]>;
|
|
187
|
+
};
|
|
188
|
+
/** A library's upload form (`MediaSection.uploadForm`). */
|
|
189
|
+
export type MediaUploadForm<V = Record<string, unknown>> = MediaForm<MediaUploadFormParams<V>> & {
|
|
190
|
+
/**
|
|
191
|
+
* Asks the backend about what it holds as Upload is pressed, since the files go one by one in the
|
|
192
|
+
* background after that, with the form gone. Rejecting keeps it open, saying why as `process`
|
|
193
|
+
* does (`MediaFormRefusal`). Aborted when the user leaves meanwhile.
|
|
194
|
+
*/
|
|
195
|
+
validate?(params: MediaFormState<MediaUploadFormParams<V>>, options: {
|
|
196
|
+
signal: AbortSignal;
|
|
197
|
+
}): void | Promise<void>;
|
|
198
|
+
};
|
|
199
|
+
/** A library's process form (`MediaSection.processForm`). */
|
|
200
|
+
export type MediaProcessForm<V = Record<string, unknown>> = MediaForm<MediaProcessFormParams<V>>;
|
|
201
|
+
/**
|
|
202
|
+
* A filter that's set, as a chip under the library's header (`MediaFilterForm.chips`), which removes
|
|
203
|
+
* it when pressed.
|
|
204
|
+
*/
|
|
205
|
+
export interface MediaFilterChip<V = Record<string, unknown>> {
|
|
206
|
+
/** Tells it from the others, as a React key, the same for as long as it's set. */
|
|
207
|
+
key: string;
|
|
208
|
+
/** What it says, in the app's language: "Certificate", "German", "Taken in 2024". */
|
|
209
|
+
label: string;
|
|
210
|
+
/** What the form holds without it, from what it holds now: `({ type, ...rest }) => rest`. */
|
|
211
|
+
remove(values: V): V;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* How a library's filter form is shown, from the header's Filters button (`MediaManager`'s and
|
|
215
|
+
* `MediaPicker`'s `filtersVariant`, or the form's own `variant`):
|
|
216
|
+
*
|
|
217
|
+
* - `"card"`, a card dropping from the button over the results, as a menu does, the results changing
|
|
218
|
+
* behind it as the filters do: what's changed applies a moment after, as typing does, and a press
|
|
219
|
+
* outside folds it away. For a few fields.
|
|
220
|
+
* - `"dialog"`, a dialog over the whole component, the rest of it out of reach meanwhile, wider than the
|
|
221
|
+
* card: what's changed applies only with its Apply, and Cancel, Escape or a press around it leaves the
|
|
222
|
+
* filters as they were. For a form too big for the card, such as rules of a field, an operator and a
|
|
223
|
+
* value, or one whose half-finished changes shouldn't search.
|
|
224
|
+
*
|
|
225
|
+
* Both are drawn inside the component rather than portaled out, so a picker in an app's own modal
|
|
226
|
+
* dialog keeps the focus.
|
|
227
|
+
*/
|
|
228
|
+
export type MediaFiltersVariant = "card" | "dialog";
|
|
229
|
+
/**
|
|
230
|
+
* A library's filter form (`MediaSection.filterForm`). Its `defaults` are nothing set, so they're
|
|
231
|
+
* required to mean that: a checkbox left unticked as `false`, a list as `[]`. Its `ready` keeps what
|
|
232
|
+
* it holds from being applied until it says so, such as a range with only one end: in the card, the
|
|
233
|
+
* filters applied before staying meanwhile, with why under them; in the dialog, its Apply held back,
|
|
234
|
+
* with why beside it.
|
|
235
|
+
*/
|
|
236
|
+
export type MediaFilterForm<V = Record<string, unknown>> = MediaForm<MediaFilterFormParams<V>> & {
|
|
237
|
+
/**
|
|
238
|
+
* How it's shown, in place of the component's `filtersVariant`, for a form that needs one way
|
|
239
|
+
* wherever it's used, as rules of a field, an operator and a value need the dialog's width.
|
|
240
|
+
*/
|
|
241
|
+
variant?: MediaFiltersVariant;
|
|
242
|
+
/**
|
|
243
|
+
* The filters set, each as a chip under the header, in a row that shows while any is, each
|
|
244
|
+
* removing itself when pressed, beside Clear all: one a field, or one a value of a list, as a
|
|
245
|
+
* language among several. Without it, only the badge on the header's Filters button says how many
|
|
246
|
+
* are set, as the component can't read what the form holds.
|
|
247
|
+
*/
|
|
248
|
+
chips?(params: MediaFormState<MediaFilterFormParams<V>>): readonly MediaFilterChip<V>[];
|
|
249
|
+
/**
|
|
250
|
+
* How many filters are set, for the badge on the header's Filters button and whether anything is
|
|
251
|
+
* being filtered at all, as a range from two fields is one filter. Without it, how many `chips`
|
|
252
|
+
* there are, or else the fields whose values differ from `defaults`, an empty text or list
|
|
253
|
+
* counting as no value.
|
|
254
|
+
*/
|
|
255
|
+
count?(params: MediaFormState<MediaFilterFormParams<V>>): number;
|
|
256
|
+
};
|
|
257
|
+
/** A library's group form (`MediaSection.groupForm`). */
|
|
258
|
+
export type MediaGroupForm<V = Record<string, unknown>> = MediaForm<MediaGroupFormParams<V>> & {
|
|
259
|
+
/**
|
|
260
|
+
* Its step's title, "New season" or "Edit “Season 1”", and for one being made, the name of the
|
|
261
|
+
* header's button; "New group" and "Edit “name”" without it.
|
|
262
|
+
*/
|
|
263
|
+
title?: string;
|
|
264
|
+
/** Its main button; "Create" or "Save" without it. */
|
|
265
|
+
submitLabel?: string;
|
|
266
|
+
/**
|
|
267
|
+
* What it starts from when editing, in place of `defaults`, such as what the adapter's `properties`
|
|
268
|
+
* hands over or the app's own API: the form shows once it's answered, with Try again should it be
|
|
269
|
+
* refused, as a listing rarely has all of what a form asks. Not asked for a group being made.
|
|
270
|
+
*/
|
|
271
|
+
load?(params: {
|
|
272
|
+
group: FileEntry;
|
|
273
|
+
section: MediaSection;
|
|
274
|
+
adapter: FileAdapter;
|
|
275
|
+
}, options: {
|
|
276
|
+
signal: AbortSignal;
|
|
277
|
+
}): Promise<V>;
|
|
278
|
+
/**
|
|
279
|
+
* What a group made of a folder uploaded holds, as a folder brings nothing but its name, handed to
|
|
280
|
+
* the adapter's `createGroup` with nothing asked: `{ name: folder.name }` in the form's own shape,
|
|
281
|
+
* say, and anything else such a group needs, such as a type chosen by where it's made (the form
|
|
282
|
+
* being asked for that place, `parent` the group it goes in, or one just made of the folder around
|
|
283
|
+
* it). `null` refuses a group of that folder there: one given at the level open is left out, saying
|
|
284
|
+
* so, and one inside it fails, with everything in it. Without it, folders aren't taken where this
|
|
285
|
+
* form makes the groups, as the component can't fill it in.
|
|
286
|
+
*/
|
|
287
|
+
fromFolder?(folder: {
|
|
288
|
+
name: string;
|
|
289
|
+
}): V | null;
|
|
290
|
+
};
|
|
291
|
+
/**
|
|
292
|
+
* What the adapter's `process` or `createGroup` or `updateGroup`, or an upload form's `validate`, rejects with: its `message` shows over
|
|
293
|
+
* the form, and `errors`, the backend's by its own keys, under the fields their `errorKey`s name, as
|
|
294
|
+
* Laravel's validation answers: `Object.assign(new Error(body.message), { errors: body.errors })`.
|
|
295
|
+
*/
|
|
296
|
+
export interface MediaFormRefusal extends Error {
|
|
297
|
+
errors?: FieldErrors;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* What an app's `renderAsset` is handed for an asset in its library, each time it changes. Spread
|
|
301
|
+
* onto `MediaTile` or `MediaRow`, it draws the asset as the media manager does.
|
|
302
|
+
*/
|
|
303
|
+
export interface MediaAssetParams {
|
|
304
|
+
asset: FileEntry;
|
|
305
|
+
/** Its library's kind. */
|
|
306
|
+
kind: MediaKind;
|
|
307
|
+
/** What it's drawn as now: a tile (`MediaTile`), or a row (`MediaRow`). */
|
|
308
|
+
layout: MediaLayout;
|
|
309
|
+
section: MediaSection;
|
|
310
|
+
/** Its library's adapter, its own or the media manager's. */
|
|
311
|
+
adapter: FileAdapter;
|
|
312
|
+
/**
|
|
313
|
+
* The URL of its picture, as the adapter's `thumbnail` gave it for the layout and the kind's size,
|
|
314
|
+
* once it has loaded; null until then, and for an asset with none. Cached and asked for a few at a time, so
|
|
315
|
+
* use this rather than asking the adapter.
|
|
316
|
+
*/
|
|
317
|
+
thumbnail: string | null;
|
|
318
|
+
selected: boolean;
|
|
319
|
+
/**
|
|
320
|
+
* Why it can't be chosen now, or the backend's work on it while it can. `MediaTile` and `MediaRow`
|
|
321
|
+
* show it; under anything else, the media manager does.
|
|
322
|
+
*/
|
|
323
|
+
hold: AssetHold | undefined;
|
|
324
|
+
/**
|
|
325
|
+
* Where it is below the level searched, the groups on the way, outermost first, while it's a
|
|
326
|
+
* result of the adapter's `search` from further down. `MediaTile` and `MediaRow` show it; under
|
|
327
|
+
* anything else, the media manager does.
|
|
328
|
+
*/
|
|
329
|
+
trail?: readonly FolderRef[];
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* The media manager's own look of an asset, `MediaTile` or `MediaRow`: what `renderAsset` hands over,
|
|
333
|
+
* spread onto it, and what to change. Each part left out stays as it is, and `null` takes it away.
|
|
334
|
+
*/
|
|
335
|
+
export interface MediaAssetLookProps extends Pick<MediaAssetParams, "asset" | "kind" | "thumbnail" | "hold" | "trail"> {
|
|
336
|
+
/** In place of its name. */
|
|
337
|
+
title?: ReactNode;
|
|
338
|
+
/**
|
|
339
|
+
* The line under its name, in place of its size or its type and size. While it can't be chosen
|
|
340
|
+
* or is being processed, why is said there instead (`hold`). `null` leaves the line empty, still
|
|
341
|
+
* as tall, so every asset is drawn the same height.
|
|
342
|
+
*/
|
|
343
|
+
detail?: ReactNode;
|
|
344
|
+
/** Over a tile's picture, or at a row's end, in place of its length. */
|
|
345
|
+
badge?: ReactNode;
|
|
346
|
+
/** In place of its thumbnail or icon, in the same box. */
|
|
347
|
+
picture?: ReactNode;
|
|
348
|
+
/** A class of the app's for the look's root, after the look's own. */
|
|
349
|
+
className?: string;
|
|
350
|
+
}
|
|
351
|
+
/** `renderAsset` as a library's assets draw with it, its section already in hand (internal). */
|
|
352
|
+
export type MediaAssetDraw = (params: Omit<MediaAssetParams, "section">) => ReactNode;
|
|
353
|
+
/**
|
|
354
|
+
* A media manager's library: a section holding assets of one kind, as its adapter lists them under
|
|
355
|
+
* `rootId`, its own adapter or the media manager's. Each is an independent root, with its own
|
|
356
|
+
* backend's way of delivering what it holds, so how its assets are previewed is its own too
|
|
357
|
+
* (`previewers`). The media manager trusts the listing, and doesn't sort files into kinds itself.
|
|
358
|
+
*/
|
|
359
|
+
export interface MediaSection extends Pick<Section, "id" | "label" | "icon" | "rootId" | "adapter" | "readOnly" | "acceptUploads"> {
|
|
360
|
+
kind: MediaKind;
|
|
361
|
+
/**
|
|
362
|
+
* How this library may show its assets, the first as it starts: `["list"]` only as rows,
|
|
363
|
+
* `["grid", "list"]` as tiles with a button in the header switching to rows. Without it, there's
|
|
364
|
+
* no button, and audio shows as rows and the others as tiles. What the user switches to can be
|
|
365
|
+
* kept across visits with `MediaManager`'s `layout` and `onLayoutChange`.
|
|
366
|
+
*/
|
|
367
|
+
layouts?: readonly MediaLayout[];
|
|
368
|
+
/**
|
|
369
|
+
* How this library's assets are shown as one is opened, as its backend delivers them: an HLS
|
|
370
|
+
* player for a backend handing over a manifest in `FileEntry.meta`, say. Asked before the media
|
|
371
|
+
* manager's own `previewers`, in order; the asset's thumbnail when none accepts it. The media
|
|
372
|
+
* manager plays nothing itself.
|
|
373
|
+
*/
|
|
374
|
+
previewers?: FilePreviewer[];
|
|
375
|
+
/**
|
|
376
|
+
* What this library's assets, and its groups, show as one is opened, in groups of fields: the
|
|
377
|
+
* app's definitions of the values its adapter's `properties` hands over (`values`), as this
|
|
378
|
+
* backend's data has its own shape, renditions with how far each is along, say. One list for
|
|
379
|
+
* all it holds, or a function of the entry, for what differs between them, as an album's fields
|
|
380
|
+
* do from a track's (a group is an entry of `kind: "folder"`). Used in place of the media
|
|
381
|
+
* manager's `properties`; without either, the adapter's own groups show.
|
|
382
|
+
*/
|
|
383
|
+
properties?: PropertyDefinitionGroup[] | ((entry: FileEntry) => PropertyDefinitionGroup[]);
|
|
384
|
+
/**
|
|
385
|
+
* What's asked of each pick from this library, or `null` for nothing, for what comes with its
|
|
386
|
+
* backend wherever it's picked: a stock photo's credit, say. Used in place of the media manager's
|
|
387
|
+
* or the picker's `pickForm`, even when it returns `null`, so a library can ask nothing of its
|
|
388
|
+
* picks; what's about one use belongs on that component's. Keep it outside the component, or
|
|
389
|
+
* memoized.
|
|
390
|
+
*/
|
|
391
|
+
pickForm?(asset: FileEntry): MediaPickForm<any> | null;
|
|
392
|
+
/**
|
|
393
|
+
* Draws this library's assets, in place of the media manager's `renderAsset` and its own look.
|
|
394
|
+
* Return `MediaTile` or `MediaRow` with what to change, for a small change, or anything else, going
|
|
395
|
+
* by `layout` if the library offers both. It
|
|
396
|
+
* only draws: selecting, the keys, the check and the Open button at a tile's top corners or a
|
|
397
|
+
* row's end stay the media manager's, as does why an asset can't be chosen, under what it draws,
|
|
398
|
+
* so it's for showing, with no buttons or links of its own. May use hooks. Every asset of a
|
|
399
|
+
* library, and every group, must be drawn the same height, whatever it holds: only the assets in or
|
|
400
|
+
* near view are rendered, laid out in lines as tall as the first one rendered. Keep it outside the
|
|
401
|
+
* component, or memoized, as a new function draws every asset again.
|
|
402
|
+
*/
|
|
403
|
+
renderAsset?: (params: MediaAssetParams) => ReactNode;
|
|
404
|
+
/**
|
|
405
|
+
* Draws this library's groups (a collection, an album, a season: whatever it lists as an entry of
|
|
406
|
+
* `kind: "folder"`), in place of the media manager's `renderGroup` and its own look, which is its
|
|
407
|
+
* thumbnail if the adapter gives one, its name and how many it holds. It's handed the group as
|
|
408
|
+
* `asset`, so `MediaTile` or `MediaRow` take what it's handed, with what to change, as they do in
|
|
409
|
+
* `renderAsset`, and what's said there of drawing goes here too. What a group is, and what it
|
|
410
|
+
* has of its own, such as a cover, is the app's: the media manager only goes into it.
|
|
411
|
+
*/
|
|
412
|
+
renderGroup?: (params: MediaAssetParams) => ReactNode;
|
|
413
|
+
/**
|
|
414
|
+
* Draws what's above a group's contents while it's open, scrolling with them, such as an album's
|
|
415
|
+
* cover and description: it's outside the list of assets, so it may have buttons and links of its
|
|
416
|
+
* own, and may use hooks. Nothing without it. The group is as it was listed when it was opened,
|
|
417
|
+
* `meta` and all.
|
|
418
|
+
*/
|
|
419
|
+
groupHeader?: (group: FileEntry, section: MediaSection) => ReactNode;
|
|
420
|
+
/**
|
|
421
|
+
* Whether new groups can be made in this library, which puts New group in its header at the levels
|
|
422
|
+
* that say so: one answer for all of them, or a function of the group open (`null` at the root),
|
|
423
|
+
* for a backend whose albums hold no more groups, say. It asks only for a name, through the
|
|
424
|
+
* adapter's `createFolder`, the group's details opening next where it has any, for the rest of what
|
|
425
|
+
* the app defines. Off by default, as an adapter's `createFolder` doesn't say this library holds
|
|
426
|
+
* groups, and a `readOnly` library never makes them. Moving a group goes by it too, so it can't go
|
|
427
|
+
* where this says no; left out, moving asks nothing of it, and the backend has the say. So do
|
|
428
|
+
* folders uploaded, dropped, pasted or picked, where the library takes files: each is made a group
|
|
429
|
+
* with its files in it, and its folders groups inside it, asked of this with the group each goes
|
|
430
|
+
* in, a folder where it says no failing with what's in it.
|
|
431
|
+
*/
|
|
432
|
+
createGroups?: boolean | ((parent: FileEntry | null) => boolean);
|
|
433
|
+
/**
|
|
434
|
+
* What's asked of a group as it's made and edited, a form as `processForm` is, drawing anything and
|
|
435
|
+
* holding what it likes under the app's own keys, so what a group has, a cover, a teaser, is the
|
|
436
|
+
* app's: told which group and where, it returns the form, or `null` for none. Where there's one,
|
|
437
|
+
* New group shows it (where `createGroups` says one can be made) and hands what it holds to the
|
|
438
|
+
* adapter's `createGroup`, and a group's details have Edit, handing it to `updateGroup`. Without
|
|
439
|
+
* one, New group asks only a name, through `createFolder`, and there's no Edit, and so are groups
|
|
440
|
+
* made of folders uploaded; with one, those take what its `fromFolder` makes of each folder's name.
|
|
441
|
+
*/
|
|
442
|
+
groupForm?: (target: MediaGroupTarget) => MediaGroupForm | null;
|
|
443
|
+
/**
|
|
444
|
+
* What's asked of files uploaded into this library, before they're sent: the processing its
|
|
445
|
+
* backend offers, such as whether a video is streamed as HLS, or a picture made smaller or turned
|
|
446
|
+
* into WebP or AVIF. Handed the files, it returns the form for them, or `null` when there's
|
|
447
|
+
* nothing to ask, as of pictures already in WebP, and they're sent at once. Shown once a batch,
|
|
448
|
+
* picked, dropped or pasted, in the library's place. What it holds goes to the adapter's `upload`
|
|
449
|
+
* with every file sent together (`UploadOptions.values`), which decides what it means. Asked too of
|
|
450
|
+
* a new file put in an asset's place from its view (`FileAdapter.replace`), handed that asset as
|
|
451
|
+
* `replacing`, so it can ask otherwise of it, or `null` to send it at once.
|
|
452
|
+
*/
|
|
453
|
+
uploadForm?(files: readonly File[], replacing?: FileEntry): MediaUploadForm<any> | null;
|
|
454
|
+
/**
|
|
455
|
+
* What can be asked of an asset already uploaded, from its view: anything its backend can make
|
|
456
|
+
* of it or make again, such as a video's HLS, a picture's responsive sizes or a piece of audio's
|
|
457
|
+
* transcript. Handed the asset, it returns the form for it, or `null` when nothing can be done
|
|
458
|
+
* with it now, as for a video already being processed, and nothing is offered. What it holds goes
|
|
459
|
+
* to the adapter's `process`, which decides what it means. Needs the adapter's `process`, and a
|
|
460
|
+
* library that isn't `readOnly`. Asked again as the asset changes, so an open form follows it, and
|
|
461
|
+
* `null` by then holds Process back rather than closing what's being filled in.
|
|
462
|
+
*/
|
|
463
|
+
processForm?(asset: FileEntry): MediaProcessForm<any> | null;
|
|
464
|
+
/**
|
|
465
|
+
* Filters beside the search, by what this library's assets are, such as a document's language or a
|
|
466
|
+
* picture's usage: a form as `uploadForm` is, drawing anything and holding what it likes under the
|
|
467
|
+
* app's own keys, `MediaFields` drawing fields from their definitions, or `null` for none at that
|
|
468
|
+
* level. Handed the group open, `null` at the root, so a group of datasheets can filter by what only
|
|
469
|
+
* they have. It shows in a card dropping from the header's Filters button, over the results, or in
|
|
470
|
+
* a dialog over the component (`filtersVariant`, `MediaFilterForm.variant`), and the filters set
|
|
471
|
+
* show as chips under the header while it's closed, when the form names them (`chips`). What it
|
|
472
|
+
* holds goes to the adapter's `search` as `filters`, a moment after it last changed, or with the
|
|
473
|
+
* dialog's Apply, the results being what's found from the open level down, as the search's are,
|
|
474
|
+
* with something typed or not. It's part of the search, but not of its field, which it doesn't
|
|
475
|
+
* open: closing the field clears only what's typed, and going to another level or library clears
|
|
476
|
+
* it. Needs the adapter's `search`, as the backend applies them. Return the same form object each
|
|
477
|
+
* time, not one made in the function.
|
|
478
|
+
*/
|
|
479
|
+
filterForm?(group: FileEntry | null): MediaFilterForm<any> | null;
|
|
480
|
+
/**
|
|
481
|
+
* Whether an asset of this library may be chosen, by the app's own rules, such as a stock photo
|
|
482
|
+
* whose licence has run out: `true`, or `false`, or why not, in the app's language, which its
|
|
483
|
+
* tile shows in place of its size. One that can't is still shown and opened, but isn't
|
|
484
|
+
* selected, and one selected already, as given with `defaultValue`, holds Choose back until
|
|
485
|
+
* it's taken out. An asset being processed (`FileEntry.processing`) can't be chosen either, unless
|
|
486
|
+
* it's `usable`, whatever this says. The app's backend still has the last word when it saves the
|
|
487
|
+
* picks.
|
|
488
|
+
*/
|
|
489
|
+
selectable?(entry: FileEntry): boolean | string;
|
|
490
|
+
}
|
|
491
|
+
/** Which of the groups shown can be selected, and why those that say so can't (internal). */
|
|
492
|
+
export interface GroupPicks {
|
|
493
|
+
checks: ReadonlySet<string>;
|
|
494
|
+
refusals: ReadonlyMap<string, AssetHold>;
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* What the frames ask of the grid of a level (internal): an asset or group to take the focus, by its
|
|
498
|
+
* index, as only those in or near view are rendered; false for an index it doesn't show.
|
|
499
|
+
*/
|
|
500
|
+
export interface MediaGridHandle {
|
|
501
|
+
focusAt: (index: number) => boolean;
|
|
502
|
+
}
|
|
503
|
+
/** Assets being processed, followed through the adapter serving them (internal). */
|
|
504
|
+
export interface FollowedAssets {
|
|
505
|
+
adapter: FileAdapter;
|
|
506
|
+
entries: readonly FileEntry[];
|
|
507
|
+
}
|
|
508
|
+
/** How assets being processed stand, as their backends last said, by adapter and id (internal). */
|
|
509
|
+
export type AssetStates = ReadonlyMap<FileAdapter, ReadonlyMap<string, AssetState>>;
|
|
510
|
+
/**
|
|
511
|
+
* Why an asset can't be chosen now: its backend's work on it under way or failed
|
|
512
|
+
* (`FileEntry.processing`), its library refusing it (`MediaSection.selectable`), the app refusing it
|
|
513
|
+
* for this use (`canSelect`) or there being no room for it (`maxChoices`), or, once it's picked, its
|
|
514
|
+
* form not ready (`MediaForm.ready`), as its tile, its row among those selected and its view show
|
|
515
|
+
* it, in one line, with a bar while it's processed.
|
|
516
|
+
*/
|
|
517
|
+
export interface AssetHold {
|
|
518
|
+
status: "processing" | "failed" | "refused" | "unfilled";
|
|
519
|
+
/** How far along the processing is, from 0 to 1, when the backend says. */
|
|
520
|
+
progress?: number;
|
|
521
|
+
/** The line shown: what it's doing and how far along, that it failed, or why it's refused or unfilled. */
|
|
522
|
+
text: string;
|
|
523
|
+
/** Why it failed, as the backend said, for its description. */
|
|
524
|
+
detail?: string;
|
|
525
|
+
}
|
|
526
|
+
/** Libraries shown together in the list of libraries, under an optional heading. */
|
|
527
|
+
export interface MediaSectionGroup {
|
|
528
|
+
id: string;
|
|
529
|
+
title?: string;
|
|
530
|
+
sections: MediaSection[];
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* An asset picked for this use: as it was listed, `meta` and all, the library it was picked in, and
|
|
534
|
+
* what the app's form holds for it (`values`). What's chosen may come from several libraries, such
|
|
535
|
+
* as pictures and videos for a product's carousel, in the order set. An asset is known by its
|
|
536
|
+
* library's adapter and its id, since ids are only unique within an adapter, so an app keeps
|
|
537
|
+
* `section.id` with `asset.id` to find it again. With `selectGroups`, `asset` may be a group, of
|
|
538
|
+
* `kind: "folder"`, for the app's backend to expand.
|
|
539
|
+
*/
|
|
540
|
+
export interface MediaChoice<V = Record<string, unknown>> {
|
|
541
|
+
asset: FileEntry;
|
|
542
|
+
section: MediaSection;
|
|
543
|
+
/**
|
|
544
|
+
* What the app's form (`pickForm`) holds for this use of the asset, which the media manager keeps
|
|
545
|
+
* with the pick and hands back, a copy of its own at Choose. The form's `defaults` as they are now
|
|
546
|
+
* until something is changed, or as given with `defaultValue`.
|
|
547
|
+
*/
|
|
548
|
+
values: V;
|
|
549
|
+
/**
|
|
550
|
+
* The groups it was picked among, from its library's root, none at its root, for a `canSelect` to
|
|
551
|
+
* tell what's inside what. Handed over with it, so it's kept by giving a choice back as it is, and
|
|
552
|
+
* unset for one given without it, whose place isn't known. Those a search went through hold only what
|
|
553
|
+
* the adapter's trail gave.
|
|
554
|
+
*/
|
|
555
|
+
trail?: readonly FileEntry[];
|
|
556
|
+
}
|
|
557
|
+
/** What an action of the app's in the media manager's header is told (`MediaAction`). */
|
|
558
|
+
export interface MediaActionContext<V = Record<string, unknown>> {
|
|
559
|
+
/** The library shown. */
|
|
560
|
+
section: MediaSection;
|
|
561
|
+
/** What serves it: its own adapter, or else the media manager's. */
|
|
562
|
+
adapter: FileAdapter;
|
|
563
|
+
/** The group open, or nothing at the library's root. */
|
|
564
|
+
group: FileEntry | null;
|
|
565
|
+
/** The groups gone into from the library's root, to the one open; none at its root. */
|
|
566
|
+
trail: readonly FileEntry[];
|
|
567
|
+
/**
|
|
568
|
+
* The asset or group shown in the library's place, with the groups it's in, which a search may have
|
|
569
|
+
* found below those open; nothing while the library itself shows.
|
|
570
|
+
*/
|
|
571
|
+
viewed: {
|
|
572
|
+
entry: FileEntry;
|
|
573
|
+
trail: readonly FileEntry[];
|
|
574
|
+
} | null;
|
|
575
|
+
/**
|
|
576
|
+
* What's selected, of every library, in the order set, each with its own `section`, as `onChange`
|
|
577
|
+
* hands it over: those that can't be chosen yet too, so what's done with them is the app's to check.
|
|
578
|
+
* None while the media manager takes no picks.
|
|
579
|
+
*/
|
|
580
|
+
choices: readonly MediaChoice<V>[];
|
|
581
|
+
/**
|
|
582
|
+
* Whether nothing can be changed where this is, the level open or what's `viewed`: the library is
|
|
583
|
+
* `readOnly`, or the listing's or the group's `permissions` refuse writing. An action changing it can
|
|
584
|
+
* hide with `visible: (context) => !context.readOnly`.
|
|
585
|
+
*/
|
|
586
|
+
readOnly: boolean;
|
|
587
|
+
/**
|
|
588
|
+
* Lists again what's open, what a search found and what's `viewed`, after the action changed them
|
|
589
|
+
* through the app's own API, in every library on this adapter.
|
|
590
|
+
*/
|
|
591
|
+
refresh: () => void;
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* One of the app's actions in the media manager's header, for what the component leaves to it, such as
|
|
595
|
+
* reordering a group, or moving several at once.
|
|
596
|
+
*/
|
|
597
|
+
export interface MediaAction<V = Record<string, unknown>> {
|
|
598
|
+
id: string;
|
|
599
|
+
label: string;
|
|
600
|
+
/** Shown as a button where there's room, a few at most; without one, it's in "More actions". */
|
|
601
|
+
icon?: IconSource;
|
|
602
|
+
/** Narrows when it's offered, e.g. to a group, or to one library. */
|
|
603
|
+
visible?: (context: MediaActionContext<V>) => boolean;
|
|
604
|
+
disabled?: (context: MediaActionContext<V>) => boolean;
|
|
605
|
+
/**
|
|
606
|
+
* Shown beside the label, e.g. "Alt+R", and bound to the keyboard while the focus is in the
|
|
607
|
+
* media manager and not in a field. Written as `FileAction.shortcut` is, and a key something here
|
|
608
|
+
* uses itself stays with it.
|
|
609
|
+
*/
|
|
610
|
+
shortcut?: string;
|
|
611
|
+
/** Styles it as destructive, for actions such as delete. */
|
|
612
|
+
destructive?: boolean;
|
|
613
|
+
onSelect: (context: MediaActionContext<V>) => void;
|
|
614
|
+
}
|
|
615
|
+
/** Actions shown together, divided from the next group by a rule in "More actions". */
|
|
616
|
+
export interface MediaActionGroup<V = Record<string, unknown>> {
|
|
617
|
+
id: string;
|
|
618
|
+
actions: readonly MediaAction<V>[];
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* What a `MediaPicker` is given as selected. It has one library, so a pick needs no `section`, and what
|
|
622
|
+
* `onChoose` and `onChange` hand over can be given back as it is. Without `values`, it holds the form's
|
|
623
|
+
* `defaults`, and follows them until it's changed.
|
|
624
|
+
*/
|
|
625
|
+
export interface MediaPickerValue<V = Record<string, unknown>> {
|
|
626
|
+
asset: FileEntry;
|
|
627
|
+
values?: V;
|
|
628
|
+
/** The groups it's among, from the library's root, as `MediaChoice.trail`; its place is unknown without it. */
|
|
629
|
+
trail?: readonly FileEntry[];
|
|
630
|
+
}
|
|
631
|
+
export {};
|