filecove 0.1.0 → 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 +21 -0
- package/dist/components/buttons/toolbar-actions.d.ts +1 -1
- package/dist/components/buttons/tooltip-icon-button.d.ts +1 -1
- package/dist/components/downloads/download-panel.d.ts +1 -1
- package/dist/components/drag/drag-preview.d.ts +24 -0
- package/dist/components/file-manager/announcer.d.ts +1 -1
- package/dist/components/file-manager/content/file-grid.d.ts +1 -1
- package/dist/components/file-manager/content/file-list.d.ts +1 -1
- package/dist/components/file-manager/content/folder-view.d.ts +1 -1
- package/dist/components/file-manager/content/item-icon.d.ts +1 -1
- package/dist/components/file-manager/content/search-results.d.ts +1 -1
- package/dist/components/file-manager/content/search-tabs.d.ts +1 -1
- package/dist/components/file-manager/content/trash-bar.d.ts +1 -1
- package/dist/components/file-manager/context-menu/context-menu.d.ts +1 -1
- package/dist/components/file-manager/dialogs/conflict-step.d.ts +1 -1
- package/dist/components/file-manager/dialogs/delete-dialog.d.ts +3 -2
- package/dist/components/file-manager/dialogs/image-viewer.d.ts +1 -1
- package/dist/components/file-manager/dialogs/name-dialog.d.ts +1 -1
- package/dist/components/file-manager/dialogs/paste-dialog.d.ts +1 -1
- package/dist/components/file-manager/dialogs/preview-dialog.d.ts +2 -2
- package/dist/components/file-manager/dialogs/restore-dialog.d.ts +1 -1
- package/dist/components/file-manager/dialogs/shortcuts-dialog.d.ts +1 -1
- package/dist/components/file-manager/dialogs/transfer-dialog.d.ts +2 -2
- package/dist/components/file-manager/dialogs/upload-dialog.d.ts +1 -1
- package/dist/components/file-manager/file-manager.d.ts +1 -1
- package/dist/components/file-manager/header-bar/header-bar.d.ts +1 -1
- package/dist/components/file-manager/header-bar/history-menu.d.ts +1 -1
- package/dist/components/file-manager/header-bar/path-bar.d.ts +1 -1
- package/dist/components/file-manager/header-bar/search-field.d.ts +1 -1
- package/dist/components/file-manager/header-bar/search-sections-menu.d.ts +1 -1
- package/dist/components/file-manager/header-bar/view-menu.d.ts +1 -1
- package/dist/components/file-manager/notice-bar.d.ts +1 -1
- package/dist/components/file-manager/properties-pane.d.ts +2 -2
- package/dist/components/file-manager/sidebar/location-item.d.ts +1 -1
- package/dist/components/file-manager/sidebar/main-menu.d.ts +1 -1
- package/dist/components/file-manager/sidebar/sidebar.d.ts +2 -2
- package/dist/components/icons/create-icon.d.ts +1 -1
- package/dist/components/icons/icon-provider.d.ts +1 -1
- package/dist/components/icons/icon-slot.d.ts +1 -1
- package/dist/components/icons/icon.d.ts +1 -1
- package/dist/components/media-manager/asset-delete.d.ts +20 -8
- package/dist/components/media-manager/asset-hold.d.ts +1 -1
- package/dist/components/media-manager/asset-option.d.ts +13 -2
- package/dist/components/media-manager/asset-trail.d.ts +1 -1
- package/dist/components/media-manager/choice-list.d.ts +1 -1
- package/dist/components/media-manager/choices-pane.d.ts +1 -1
- package/dist/components/media-manager/group-create.d.ts +1 -1
- package/dist/components/media-manager/group-path.d.ts +8 -2
- package/dist/components/media-manager/library-list.d.ts +4 -2
- package/dist/components/media-manager/media-asset.d.ts +19 -7
- package/dist/components/media-manager/media-edit-many.d.ts +33 -0
- package/dist/components/media-manager/media-fields.d.ts +1 -1
- 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 +3 -1
- package/dist/components/media-manager/media-frame.d.ts +7 -3
- package/dist/components/media-manager/media-grid.d.ts +34 -5
- package/dist/components/media-manager/media-group.d.ts +1 -1
- package/dist/components/media-manager/media-header.d.ts +20 -3
- package/dist/components/media-manager/media-manager.d.ts +33 -10
- package/dist/components/media-manager/media-move.d.ts +19 -11
- package/dist/components/media-manager/media-picker.d.ts +25 -7
- package/dist/components/media-manager/media-picture.d.ts +1 -1
- package/dist/components/media-manager/media-process.d.ts +1 -1
- package/dist/components/media-manager/media-row.d.ts +1 -1
- package/dist/components/media-manager/media-tile.d.ts +1 -1
- package/dist/components/media-manager/media-upload.d.ts +28 -6
- package/dist/components/media-manager/picker-frame.d.ts +6 -2
- package/dist/components/media-manager/selection-bar.d.ts +25 -0
- package/dist/components/media-manager/upload-tile.d.ts +5 -3
- package/dist/components/properties/properties-panel.d.ts +9 -3
- package/dist/components/properties/property-display.d.ts +1 -1
- package/dist/components/properties/property-editor.d.ts +1 -1
- package/dist/components/properties/property-input.d.ts +1 -1
- package/dist/components/transfers/transfer-panel.d.ts +1 -1
- package/dist/components/ui/dialog.d.ts +1 -1
- package/dist/components/ui/root-providers.d.ts +1 -1
- package/dist/components/uploads/upload-panel.d.ts +8 -2
- package/dist/contexts/cut-context.d.ts +1 -1
- package/dist/contexts/data-context.d.ts +3 -3
- package/dist/contexts/direction-context.d.ts +1 -1
- package/dist/contexts/drag-context.d.ts +1 -1
- package/dist/contexts/icon-context.d.ts +1 -1
- package/dist/contexts/locale-context.d.ts +1 -1
- package/dist/contexts/moving-context.d.ts +1 -1
- package/dist/hooks/use-asset-states.d.ts +1 -1
- package/dist/hooks/use-clipboard-follow.d.ts +2 -2
- package/dist/hooks/use-cut-ids.d.ts +1 -1
- package/dist/hooks/use-dev-checks.d.ts +16 -0
- package/dist/hooks/use-download-queue.d.ts +3 -3
- package/dist/hooks/use-dragged-ids.d.ts +1 -1
- package/dist/hooks/use-drop-target.d.ts +1 -1
- package/dist/hooks/use-entry-drag.d.ts +2 -2
- package/dist/hooks/use-files-drop.d.ts +7 -1
- package/dist/hooks/use-folder.d.ts +3 -3
- package/dist/hooks/use-icon-config.d.ts +1 -1
- package/dist/hooks/use-level-filters.d.ts +112 -0
- package/dist/hooks/use-level-search.d.ts +8 -6
- package/dist/hooks/use-locale.d.ts +3 -3
- package/dist/hooks/use-location-history.d.ts +1 -1
- package/dist/hooks/use-long-press.d.ts +1 -1
- package/dist/hooks/use-marquee.d.ts +1 -1
- package/dist/hooks/use-match-count.d.ts +5 -4
- package/dist/hooks/use-media-search.d.ts +22 -8
- package/dist/hooks/use-moving-ids.d.ts +2 -2
- package/dist/hooks/use-preview-contents.d.ts +1 -1
- package/dist/hooks/use-properties.d.ts +2 -2
- package/dist/hooks/use-scroll-measure.d.ts +1 -1
- package/dist/hooks/use-search.d.ts +6 -5
- package/dist/hooks/use-selection.d.ts +1 -1
- package/dist/hooks/use-text-direction.d.ts +1 -1
- package/dist/hooks/use-thumbnail.d.ts +1 -1
- package/dist/hooks/use-transfer-queue.d.ts +5 -5
- package/dist/hooks/use-tree-rows.d.ts +1 -1
- package/dist/hooks/use-tree-selection.d.ts +1 -1
- package/dist/hooks/use-upload-queue.d.ts +7 -5
- package/dist/hooks/use-virtual-lines.d.ts +1 -1
- package/dist/hooks/use-wheel-zoom.d.ts +1 -1
- package/dist/icon-sets/filled.d.ts +1 -1
- package/dist/icon-sets/outlined.d.ts +1 -1
- package/dist/icon-sets/rounded.d.ts +1 -1
- package/dist/icon-sets/sharp.d.ts +1 -1
- package/dist/icon-sets/two-tone.d.ts +1 -1
- package/dist/index.d.ts +18 -18
- package/dist/index.js +4307 -1129
- package/dist/index.js.map +1 -1
- package/dist/locales/en-us.d.ts +1 -1
- package/dist/store/download-queue.d.ts +1 -1
- package/dist/store/folder-store.d.ts +1 -1
- package/dist/store/properties-cache.d.ts +9 -1
- package/dist/store/thumbnail-cache.d.ts +1 -1
- package/dist/store/transfer-across.d.ts +1 -1
- package/dist/store/transfer-queue.d.ts +2 -2
- package/dist/store/upload-queue.d.ts +28 -8
- package/dist/styles/classes.d.ts +30 -2
- package/dist/styles/layout.d.ts +2 -2
- package/dist/styles/media-layout.d.ts +1 -1
- package/dist/styles.css +1095 -367
- package/dist/styles.layer.css +1095 -367
- package/dist/types/action.d.ts +3 -3
- package/dist/types/adapter.d.ts +164 -11
- package/dist/types/api.d.ts +21 -9
- package/dist/types/clipboard.d.ts +2 -2
- package/dist/types/download.d.ts +1 -1
- package/dist/types/drag.d.ts +4 -4
- package/dist/types/folder.d.ts +1 -1
- package/dist/types/index.d.ts +27 -27
- package/dist/types/locale.d.ts +161 -4
- package/dist/types/main-menu.d.ts +1 -1
- package/dist/types/media.d.ts +127 -11
- package/dist/types/menu.d.ts +4 -4
- package/dist/types/navigation.d.ts +2 -2
- package/dist/types/preview.d.ts +1 -1
- package/dist/types/previewer.d.ts +1 -1
- package/dist/types/properties.d.ts +20 -2
- package/dist/types/property-definition.d.ts +58 -1
- package/dist/types/search.d.ts +2 -2
- package/dist/types/section.d.ts +2 -2
- package/dist/types/selection.d.ts +3 -3
- package/dist/types/slots.d.ts +12 -7
- package/dist/types/transfer.d.ts +2 -2
- package/dist/types/tree.d.ts +2 -2
- package/dist/types/undo.d.ts +3 -3
- package/dist/types/upload.d.ts +79 -3
- package/dist/types/view.d.ts +5 -5
- package/dist/utils/action-groups.d.ts +1 -1
- package/dist/utils/clipboard.d.ts +2 -2
- package/dist/utils/dom.d.ts +13 -0
- package/dist/utils/download.d.ts +1 -1
- package/dist/utils/field-errors.d.ts +1 -1
- package/dist/utils/files.d.ts +9 -5
- package/dist/utils/format.d.ts +1 -1
- package/dist/utils/groups.d.ts +1 -1
- package/dist/utils/hidden.d.ts +1 -1
- package/dist/utils/keyboard.d.ts +1 -1
- package/dist/utils/media.d.ts +82 -5
- package/dist/utils/menu-position.d.ts +1 -1
- package/dist/utils/names.d.ts +1 -1
- package/dist/utils/navigation.d.ts +1 -1
- package/dist/utils/path.d.ts +2 -2
- package/dist/utils/permissions.d.ts +2 -2
- package/dist/utils/preview.d.ts +1 -1
- package/dist/utils/property-value.d.ts +3 -1
- package/dist/utils/search.d.ts +1 -1
- package/dist/utils/sections.d.ts +1 -1
- package/dist/utils/selection.d.ts +1 -1
- package/dist/utils/shortcut.d.ts +1 -1
- package/dist/utils/slots.d.ts +2 -2
- package/dist/utils/sort.d.ts +1 -1
- package/dist/utils/transfer.d.ts +1 -1
- package/dist/utils/trash.d.ts +1 -1
- package/dist/utils/undo.d.ts +1 -1
- package/dist/utils/zoom.d.ts +2 -2
- package/docs/README.md +1 -1
- package/docs/adapter.md +66 -6
- package/docs/customizing.md +31 -2
- package/docs/getting-started.md +3 -1
- package/docs/media-manager.md +194 -7
- package/docs/search.md +2 -0
- package/docs/uploads-and-downloads.md +2 -1
- package/package.json +1 -1
- package/dist/components/file-manager/drag-preview.d.ts +0 -22
package/docs/media-manager.md
CHANGED
|
@@ -65,6 +65,30 @@ Each `MediaChoice` has the `asset` as listed (`meta` and all), its `section`, th
|
|
|
65
65
|
- **`canSelect(asset, section, choices, trail)`** is your rule beside what's picked, returning `true`, `false` or why not: "one video at most". A library's own **`selectable(entry)`** is for rules of its backend, "licence expired". An asset has to pass both.
|
|
66
66
|
- **`defaultValue`** starts from an existing pick, such as a carousel being edited; **`value`** and **`onChange`** keep it in your state, for a field in your own form saved by your own button. Without `onChoose`, there's no Choose button.
|
|
67
67
|
|
|
68
|
+
## Managing several at once
|
|
69
|
+
|
|
70
|
+
While it's only browsed, as a library screen of your app is, what's selected is for acting on in place, as in a file manager:
|
|
71
|
+
|
|
72
|
+
- **Selecting**: a click selects one, Ctrl or ⌘ adds or takes one out, Shift selects a range, Ctrl+A selects all that's shown, and Escape clears. A click still goes into a group, so a group is selected with those keys, or by the check it shows as the pointer is over it. On a touch screen, a long-press starts selecting, and every tap then adds or takes out.
|
|
73
|
+
- **The selection bar** at the library's foot says how many, with Select all, **Edit fields…** (below), **Move to…** (the adapter's `move`, the library's levels to pick from) and **Delete** (the adapter's `delete`, asked about first, in place). Delete or Backspace asks too. Each shows only when every item selected allows it.
|
|
74
|
+
- **Dragging** what's selected, or the item grabbed, onto a group, or onto a step of the path above, moves it there; a drag resting on a group goes into it. On a touch screen, it's a long-press and moving on. Pass **`disableDrag`** to turn dragging off, leaving Move to….
|
|
75
|
+
- What's selected is the level's: going elsewhere clears it. Your header `actions` get it as `choices`.
|
|
76
|
+
- When your backend refuses some of a delete, report what went with `onEntryDone` and reject saying why (see [the adapter's `delete`](adapter.md#delete)): what went is gone at once, the rest are named under your message, and Delete tries only them again.
|
|
77
|
+
|
|
78
|
+
While the media manager takes picks, the selection is what's picked, and moving, deleting and changing fields stay one at a time, in an asset's view.
|
|
79
|
+
|
|
80
|
+
### Edit fields…
|
|
81
|
+
|
|
82
|
+
Edit fields… changes the same fields of everything selected at once, such as setting the type "Wiring" on 30 drawings, or adding the tag "German" to 50 datasheets. It shows your [properties](#properties) that are `editable`, those every one of them has (an album's and a track's may differ), each unticked and left as each item has it. Beside each it says what they hold now: the value they share, "Not set", or "Mixed".
|
|
83
|
+
|
|
84
|
+
- **Ticking a field** changes it, to the same value for all of them; one left empty clears it.
|
|
85
|
+
- **A list** (`multiple`, such as tags) is changed one of three ways: **Add** puts its items in each one's list, keeping what's there; **Remove** takes them out; **Replace all** puts them in place of each one's list.
|
|
86
|
+
- **Save** saves only the fields ticked. Done, what's selected stays selected, to go on with.
|
|
87
|
+
- **Which fields**: every `editable` property with an editor (its type's, or your `renderEdit`) is offered, unless it says `editMany: false`, as a name usually should, since every asset's is its own. One drawn by `render` alone (a poster picked among a video's frames) is offered only with `editMany: true`. Their `render` and `renderEdit` are handed `entries`, the items being changed, with `entry` standing in for them (no id).
|
|
88
|
+
- **Saving** goes to the adapter's `updateManyProperties(entries, changes, options)`, once for all of them, when it has one; otherwise each item goes through `updateProperties`, four at a time, with each list as that item's is now, read from `properties` first (see [the adapter's `updateManyProperties`](adapter.md#updatemanyproperties)).
|
|
89
|
+
- **Refused for some**: report each item as it's saved with `onEntryDone` and reject saying why; what was saved is kept, the rest are named under your message, and Save tries only them again.
|
|
90
|
+
- To say what they hold now, it asks `properties` of each item, four at a time, for up to 100 of them; for more, it says nothing beside the fields.
|
|
91
|
+
|
|
68
92
|
## Groups
|
|
69
93
|
|
|
70
94
|
A library can hold groups inside each other, as your backend keeps them: collections, albums, series, seasons. A group is an entry of `kind: "folder"`, listed with `list` one level at a time, so groups need nothing new in the adapter; a library listing no folders is flat.
|
|
@@ -73,9 +97,76 @@ A click goes into a group; the header shows the path walked, any part of which g
|
|
|
73
97
|
|
|
74
98
|
- **`renderGroup`** draws a group's tile, as `renderAsset` does an asset's.
|
|
75
99
|
- **`groupHeader(group, section)`** draws what you like above an open group's contents: its cover, its description, a trailer.
|
|
76
|
-
- **`createGroups`** (`true`, or a function of the parent group) shows New group, made with the adapter's `createFolder` from a name, or from **`groupForm`** with the adapter's `createGroup`. `groupForm` with `updateGroup` gives a group's details an Edit.
|
|
100
|
+
- **`createGroups`** (`true`, or a function of the parent group) shows New group, made with the adapter's `createFolder` from a name, or from **`groupForm`** with the adapter's `createGroup`. `groupForm` with `updateGroup` gives a group's details an Edit. Folders uploaded are made groups by the same rules (see "Folders as groups").
|
|
77
101
|
- **`selectGroups`** lets groups be picked as assets are, a whole album; `onChoose` hands the group back for your backend to expand.
|
|
78
102
|
|
|
103
|
+
## Searching and filtering
|
|
104
|
+
|
|
105
|
+
The header's search (or Ctrl+F) looks from the open level down. With the adapter's `search`, it asks your backend, with the open group's id as `rootId`, a moment after the typing stops, and shows the matches in your order, each found below the level saying which group it's in; groups may be among them. Without `search`, it filters the open level by name.
|
|
106
|
+
|
|
107
|
+
**Filters** narrow it by what your assets are, beside the name: "certificates in German", "only the pictures we may use commercially". A library's `filterForm` is a form as its other forms are, so its fields can follow each other, and `MediaFields` draws them from the same definitions properties use. Its `chips` name what's set, for the chips under the header:
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
import { MediaFields } from "filecove";
|
|
111
|
+
import type { MediaFilterForm, MediaSection } from "filecove";
|
|
112
|
+
|
|
113
|
+
const TYPES = { datasheet: "Datasheet", certificate: "Certificate" };
|
|
114
|
+
const LANGUAGES = { en: "English", de: "German" };
|
|
115
|
+
|
|
116
|
+
const documentFilters: MediaFilterForm = {
|
|
117
|
+
defaults: { languages: [] }, // nothing set
|
|
118
|
+
render: (form) => (
|
|
119
|
+
<MediaFields
|
|
120
|
+
{...form}
|
|
121
|
+
groups={[
|
|
122
|
+
{
|
|
123
|
+
id: "filters",
|
|
124
|
+
properties: [
|
|
125
|
+
{ field: "type", label: "Type", type: "string", options: [
|
|
126
|
+
{ value: "datasheet", label: "Datasheet" },
|
|
127
|
+
{ value: "certificate", label: "Certificate" },
|
|
128
|
+
] },
|
|
129
|
+
{ field: "languages", label: "Language", type: "string", multiple: true, options: [
|
|
130
|
+
{ value: "en", label: "English" },
|
|
131
|
+
{ value: "de", label: "German" },
|
|
132
|
+
] },
|
|
133
|
+
],
|
|
134
|
+
},
|
|
135
|
+
]}
|
|
136
|
+
/>
|
|
137
|
+
),
|
|
138
|
+
// One chip a filter, or a value of a list; each says what the form holds without it.
|
|
139
|
+
chips: ({ values }) => [
|
|
140
|
+
...(values.type
|
|
141
|
+
? [{ key: "type", label: TYPES[values.type as keyof typeof TYPES], remove: ({ type, ...rest }) => rest }]
|
|
142
|
+
: []),
|
|
143
|
+
...(values.languages as string[]).map((language) => ({
|
|
144
|
+
key: `language/${language}`,
|
|
145
|
+
label: LANGUAGES[language as keyof typeof LANGUAGES],
|
|
146
|
+
remove: (current) => ({
|
|
147
|
+
...current,
|
|
148
|
+
languages: (current.languages as string[]).filter((each) => each !== language),
|
|
149
|
+
}),
|
|
150
|
+
})),
|
|
151
|
+
],
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const docs: MediaSection = {
|
|
155
|
+
id: "docs", label: "Documents", kind: "document", rootId: "/documents",
|
|
156
|
+
filterForm: () => documentFilters,
|
|
157
|
+
};
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
- **The Filters button** shows beside the search's where the library has a form and the adapter has `search`, with how many are set in a badge. It opens the form in a card dropping from it over the results, which change behind it. Changes apply as typing does, a moment after the last, so there's nothing to submit; Clear all puts them back to `defaults`, and a press outside the card, Escape or the button folds it away, keeping them. The card is drawn inside the component, not portaled out, so a picker in your own modal dialog keeps the focus.
|
|
161
|
+
- **A dialog instead of the card**: pass `filtersVariant="dialog"` (on `MediaManager` or `MediaPicker`) for the form in a dialog over the whole component, wider than the card (36rem; make it wider through `.fm-media-filters-dialog`), the rest of the component out of reach while it's open. It's for a form too big for a card, such as rules of a field, an operator and a value, or one whose half-finished changes shouldn't search: what's changed in it applies only with its **Apply**, held back while `ready` says no, with why beside it; Clear all clears what it holds; Cancel, Escape or a press around it leaves the filters as they were. A form that needs one way wherever it's used says so itself, `variant: "dialog"` on the `MediaFilterForm`, which comes before the prop. The dialog is drawn inside the component too, covering it rather than the page.
|
|
162
|
+
- **`chips(state)`** names the filters set, each as `{ key, label, remove }`, `remove` being what the form holds without it. They show as chips in a row under the header while any is set, each removing its filter when pressed, beside Clear all, so what narrows the results shows with the card folded away. Without `chips`, only the badge says how many are set, as the media manager can't read your values.
|
|
163
|
+
- **They go to `search` as `options.filters`**, what the form holds, by your keys, and the results are what your backend finds from the open level down that they let through. With a filter set and nothing typed, `search` is called with an empty `query`: return everything below the root the filters let through. What they mean is your backend's; the media manager never reads them. Return groups only if your filters can say something about them.
|
|
164
|
+
- **`defaults` are nothing set.** The badge counts your `chips`, or without them the fields whose values differ from their defaults, an empty text or list counting as nothing, so give a checkbox's default as `false`. `count(state)` counts them yourself instead.
|
|
165
|
+
- **`ready(state)`** holds what's set back until it can be applied, saying why at the card's foot, such as a range whose first day comes after the last; what was applied before stays meanwhile. In the dialog, it holds Apply back instead.
|
|
166
|
+
- **`filterForm(group)`** is handed the group open, or `null` at the root, so a group of datasheets can filter by what only they have, or return `null` for none there.
|
|
167
|
+
- **They're part of the search, not of its field**: setting them runs the search without opening the field, the chips saying what's set, and closing the field (Escape, ✕ with nothing typed, the search button) clears only what's typed. Clear all, removing their chips, or going to another level or library clears them, as `apiRef.closeSearch()` does, which ends the whole search. A controlled `search` holds them as `{ query, filters }`, the field showing while `query` isn't empty or the user opened it, and `apiRef.search(query, filters)` sets both. `MediaPicker` offers a library's filters too.
|
|
168
|
+
- Your `slots.noResults` is handed the applied `filters` beside `query`, to say nothing matched them, or to offer clearing them.
|
|
169
|
+
|
|
79
170
|
## What an asset shows: properties
|
|
80
171
|
|
|
81
172
|
An asset opens in the library's place (its tile's Open button, or Alt+Enter), showing it by your previewers and its fields by your definitions. The adapter's `properties` hands over plain values, and you define what's shown, as a data grid's columns read a row:
|
|
@@ -125,7 +216,8 @@ async properties(entry) {
|
|
|
125
216
|
- **Types** are `"string"`, `"number"`, `"boolean"` and `"date"`. **Kinds** refine how one is shown: `url` on a string, `size` and `duration` on a number, `datetime` on a date. `options` makes it a choice, `multiple` a list.
|
|
126
217
|
- **`valueGetter(value, entry)`** reads it from the raw value or the entry; **`valueFormatter(value, entry)`** gives its text.
|
|
127
218
|
- **`render(params)`** draws it entirely your way (a list of renditions with their progress, say), and **`renderEdit(params)`** its editor. Leave out `type` for a property that's only yours, with `render` required.
|
|
128
|
-
- **`editable: true`** saves through the adapter's `updateProperties`, `{ [field]: value }`.
|
|
219
|
+
- **`editable: true`** saves through the adapter's `updateProperties`, `{ [field]: value }`, and offers it in [Edit fields…](#edit-fields) for several at once, unless it says `editMany: false`.
|
|
220
|
+
- **`upload`** lets files be uploaded into the part of the asset it shows, a video's subtitles or audio tracks, through the adapter's `uploadPart` (see [Uploading into an asset's parts](#uploading-into-an-assets-parts)).
|
|
129
221
|
- `PropertyDisplay`, exported, draws a value the default way, for a `render` that only adds something beside it.
|
|
130
222
|
|
|
131
223
|
## Previewers
|
|
@@ -156,9 +248,10 @@ interface MediaForm<P> {
|
|
|
156
248
|
| Form | Where | Handed |
|
|
157
249
|
|---|---|---|
|
|
158
250
|
| `pickForm(asset, section)` | `MediaManager` / `MediaPicker`, or a library's `pickForm(asset)` | what's asked of each pick for this use of it: a caption, a link text |
|
|
159
|
-
| `uploadForm(files)` | a library | what the backend should make of the files: optimize, convert, stream as HLS |
|
|
251
|
+
| `uploadForm(files, replacing?)` | a library | what the backend should make of the files: optimize, convert, stream as HLS; `replacing` is the asset whose file is being replaced, when it is |
|
|
160
252
|
| `processForm(asset)` | a library | what to make of an asset again |
|
|
161
253
|
| `groupForm({ group, parent })` | a library | a group's own fields |
|
|
254
|
+
| `filterForm(group)` | a library | what the search is narrowed by (see [Searching and filtering](#searching-and-filtering)) |
|
|
162
255
|
|
|
163
256
|
The media manager keeps the values and never reads them, so a form follows itself in plain code: a field turned off while another is, what it held dropped.
|
|
164
257
|
|
|
@@ -219,6 +312,99 @@ A field finds its own with ``errorKey: ({ index }) => `media.${index}.caption` `
|
|
|
219
312
|
|
|
220
313
|
A library takes uploads while its adapter has `upload` and it isn't `readOnly`: the header's Upload, a drop, or a paste. Each file goes through `upload` with what its `uploadForm` held as `values`. While the app takes a pick, what arrives is selected, as WordPress's and Shopify's pickers do.
|
|
221
314
|
|
|
315
|
+
### Folders as groups
|
|
316
|
+
|
|
317
|
+
Where `createGroups` allows a group, a folder dropped, pasted or picked with the header's "Upload a folder" (or `apiRef.uploadFolder()`) becomes a group with its files in it, and the folders inside it groups inside that one, all the way down: a manufacturer's 300 photos sorted into folders by product series land sorted. The upload step shows first, reading the folders and saying how many files and groups each makes, and the library's `uploadForm` is asked once, of every file they hold. Files of types the library doesn't take are left out, and so is a folder left with nothing.
|
|
318
|
+
|
|
319
|
+
- **The groups are made the way New group makes them.** Without a `groupForm`, through the adapter's `createFolder`, named as the folder. With one, a folder brings only its name, so the form says what a group made of it holds, through **`fromFolder`**, which goes to `createGroup`; without `fromFolder`, folders aren't taken there.
|
|
320
|
+
|
|
321
|
+
```tsx
|
|
322
|
+
groupForm: ({ group, parent }) => ({
|
|
323
|
+
// ...the form as New group and Edit show it
|
|
324
|
+
// A folder makes a collection at the root, an album in a collection.
|
|
325
|
+
fromFolder: ({ name }) => ({ name, type: parent ? "Album" : "Collection" }),
|
|
326
|
+
}),
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
The form is asked for the place each group goes, so `parent` is the group it goes in, one just made of the folder around it included. Return `null` to refuse a folder there.
|
|
330
|
+
- **`createGroups` is asked at every depth**, with the group each folder would go in, so a library whose albums hold no groups refuses a folder inside an album folder: that folder fails, with what's in it, and the upload panel lists it under the folder's row. The rest go on.
|
|
331
|
+
- **A folder whose name a group there already has goes into it**, its files kept beside any of the same name, as uploads always are, so dropping the same folder again with more photos adds them. A folder named as an asset there is made under a free name ("Contactors (2)").
|
|
332
|
+
- The group shows as soon as it's made, its tile saying how many of its files are in; the panel's Show goes into it. While the app takes a pick, nothing of a folder is selected, its files being in the group.
|
|
333
|
+
|
|
334
|
+
### A file the backend already has
|
|
335
|
+
|
|
336
|
+
A backend that finds uploads by their checksum, and hands back the asset it already has rather than storing a second copy, says so by resolving `upload` with an `UploadResult` in place of the entry:
|
|
337
|
+
|
|
338
|
+
```ts
|
|
339
|
+
upload: async (file, folderId, options) => {
|
|
340
|
+
const body = await send(file, folderId, options); // your own request
|
|
341
|
+
const entry = toEntry(body.asset);
|
|
342
|
+
|
|
343
|
+
return body.existing
|
|
344
|
+
? { entry, existing: true, trail: body.asset.groups.map(toEntry) }
|
|
345
|
+
: entry;
|
|
346
|
+
},
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
- **`existing: true`** says the backend had the file already. The media manager says "“front.jpg” is already in the library, in Schneider / Contactors", the upload panel's row says "Already there" with where it is, and a button there opens the asset (in `MediaPicker`, its group, with its tile focused). While the app takes a pick, it's selected, as an upload is.
|
|
350
|
+
- **`trail`** is the groups holding it, outermost first, when it isn't in the group the file was uploaded into. Give them from the library's root down, leaving the root out, as a search's trails are, or from higher up, such as the top of your backend: the media manager reads them from below the library's root, wherever that is among them. Give whole entries where a library's `groupHeader` or `groupForm` reads more of a group. Without `trail`, it's taken to be in the group uploaded into.
|
|
351
|
+
- A `trail` without `existing` says the backend put a new file in another group than the one it was uploaded into, which the media manager says too ("“front.jpg” was uploaded to Contactors").
|
|
352
|
+
- An asset in another library, below another root, can't be shown from this one: store the file again there, or reject with an `Error` saying where it is, which the panel shows.
|
|
353
|
+
|
|
354
|
+
### Replacing an asset's file
|
|
355
|
+
|
|
356
|
+
A photo used by twenty products turns out to be the wrong angle: replacing its file once changes it for all twenty, as the asset, its id and its properties stay. Give the adapter `replace`, and the asset view gets a Replace file button:
|
|
357
|
+
|
|
358
|
+
```ts
|
|
359
|
+
replace: async (entry, file, { signal, onProgress, values }) => {
|
|
360
|
+
const body = await send(`/media/${entry.id}/file`, file, { signal, onProgress, values }); // your own request
|
|
361
|
+
|
|
362
|
+
return toEntry(body.asset); // as it is now, with `processing` while it's made into what it's delivered as
|
|
363
|
+
},
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
- The file picked goes through the library's `acceptUploads`, and its `uploadForm` is asked of it, told which asset it replaces (`uploadForm(files, replacing)`), so it can ask something else of a replacement, or `null` to send it at once. What the form holds goes to `replace` as `values`.
|
|
367
|
+
- It runs in the upload panel as an upload does, named by the asset, with its progress, cancel and Try again; the asset's tile and view say "Replacing the file" with a bar meanwhile, and it stays as it was until the new file is in. Picking another file for the same asset while one is still going cancels the first.
|
|
368
|
+
- Once it's in, the library is listed again, so list the asset with `processing` while what's made of the new file is made, and it's followed as an upload is. Its picture, its view and the picks of it follow the new file.
|
|
369
|
+
- Keep the asset's id, or what's kept of it by id (the picks, the view) is lost. Whether it keeps its name or takes the new file's is your backend's call. Reject with an `Error`, such as "This photo is used in an order and can't be changed", to show the message in the panel's row.
|
|
370
|
+
- `MediaPicker` has no asset view, so it doesn't offer it.
|
|
371
|
+
|
|
372
|
+
### Uploading into an asset's parts
|
|
373
|
+
|
|
374
|
+
A video gets a French subtitle file, or an audio track in German, or a poster of its own: files that become part of the asset rather than assets of their own. What the parts are is your backend's; the media manager only carries the file there. A part is a property you already show (see [What an asset shows](#what-an-asset-shows-properties)), so it's declared on that property, with `upload`, and given to the adapter's `uploadPart`:
|
|
375
|
+
|
|
376
|
+
```tsx
|
|
377
|
+
const subtitles: PropertyDefinition = {
|
|
378
|
+
field: "subtitles",
|
|
379
|
+
label: "Subtitles",
|
|
380
|
+
render: (params) => <TrackList {...params} />, // your own drawing of the subtitles it has
|
|
381
|
+
upload: {
|
|
382
|
+
part: "subtitles", // what your backend calls it; the `field` when left out
|
|
383
|
+
label: "Add subtitles", // the button's name; "Upload to Subtitles" when left out
|
|
384
|
+
accept: ".vtt,.srt,text/vtt",
|
|
385
|
+
form: (files) => ({
|
|
386
|
+
defaults: { language: guessLanguage(files[0].name), forced: false },
|
|
387
|
+
render: (form) => <SubtitleFields {...form} />, // a component of your own, outside this function
|
|
388
|
+
ready: ({ values }) => !!values.language || "Choose the language it's in.",
|
|
389
|
+
}),
|
|
390
|
+
},
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
// The adapter
|
|
394
|
+
uploadPart: async (entry, part, file, { signal, onProgress, values }) => {
|
|
395
|
+
const body = await send(`/media/${entry.id}/${part}`, file, { signal, onProgress, values }); // your own request
|
|
396
|
+
|
|
397
|
+
return toEntry(body.asset); // as it is now, with `processing` while the part is being made into what's delivered
|
|
398
|
+
},
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
- **The button**: in the asset view, an Upload button after the property's value, shown even while it has none, opens the browser's file picker with the types `accept` takes (one file, or several with `multiple`). A file of another type is left out, saying so.
|
|
402
|
+
- **The form** is asked of the files before they're sent, over the asset's view, as a library's `uploadForm` is: a subtitle's language and whether it's forced, an audio track's language and whether it's the default. Its params have `partOf` (the asset) and `part`. Return `null`, or leave `form` out, and the files are sent at once, as a poster would be. What it holds goes to `uploadPart` as `values`, the same for every file sent together.
|
|
403
|
+
- **While it's sent**, the files are listed under the property, each with its progress and a way to cancel it, or why it failed and Try again, and the upload panel has them too, with a button opening the asset. The asset's tile and view say "Uploading to Subtitles" with a bar.
|
|
404
|
+
- **Once it's in**, the asset's `properties` are asked for again, so your property shows the new part, and the library is listed again: list the asset with `processing` while your backend makes something of the part (an audio track mixed into its stream, say), with `usable: true` while it still plays, and it's followed as an upload is.
|
|
405
|
+
- **Refusing** it: reject with an `Error`, such as "intro.webm has French subtitles already", and the message shows under the property and in the panel's row. Checks that only need the form's values belong in its `ready`.
|
|
406
|
+
- It's offered for an asset, not a group, where the adapter has `uploadPart`, the library takes files and can be changed, and the asset allows `write`. `MediaPicker` has no asset view, so it doesn't offer it. Linking an asset of another library, such as a group's cover, is a property whose `renderEdit` opens a `MediaPicker` (see [`MediaPicker`](#mediapicker)), not a part.
|
|
407
|
+
|
|
222
408
|
## Processing
|
|
223
409
|
|
|
224
410
|
What an asset is made into after its upload (renditions, sizes, formats) is your backend's. The listing says when it's working on one:
|
|
@@ -271,15 +457,15 @@ As the file manager's, each can be controlled:
|
|
|
271
457
|
|---|---|
|
|
272
458
|
| The library and group open | `location`, `defaultLocation`, `onLocationChange` |
|
|
273
459
|
| What's shown in the library's place | `viewed`, `defaultViewed`, `onViewedChange` |
|
|
274
|
-
| The search | `search`, `defaultSearch`, `onSearchChange` |
|
|
460
|
+
| The search and its filters | `search`, `defaultSearch`, `onSearchChange` (`{ query, filters }`, or `null` while closed) |
|
|
275
461
|
| Each library's layout | `layout`, `defaultLayout`, `onLayoutChange` |
|
|
276
462
|
| What's selected | `value`, `defaultValue`, `onChange` |
|
|
277
463
|
|
|
278
|
-
`apiRef` takes a `MediaManagerApi`: `navigate`, `view`, `closeView`, `search`, `closeSearch`, `select`, `choose`, `upload`, `refresh`, `focus`. `relistAfter` and `limits` work as the file manager's do.
|
|
464
|
+
`apiRef` takes a `MediaManagerApi`: `navigate`, `view`, `closeView`, `search`, `closeSearch`, `select`, `choose`, `upload`, `uploadFolder`, `refresh`, `focus`. `relistAfter` and `limits` work as the file manager's do.
|
|
279
465
|
|
|
280
466
|
## `MediaPicker`
|
|
281
467
|
|
|
282
|
-
One library to find an asset in and choose it, for a field pointing at an asset of another library, such as a series' poster or a product's manual. It has no list of libraries
|
|
468
|
+
One library to find an asset in and choose it, for a field pointing at an asset of another library, such as a series' poster or a product's manual. It has no list of libraries and no asset view, and of managing a library only uploading and making groups, where you allow them; place it in a dialog of your own:
|
|
283
469
|
|
|
284
470
|
```tsx
|
|
285
471
|
import { MediaPicker } from "filecove";
|
|
@@ -289,6 +475,7 @@ import { MediaPicker } from "filecove";
|
|
|
289
475
|
adapter={adapter}
|
|
290
476
|
section={images}
|
|
291
477
|
allowUpload
|
|
478
|
+
allowCreateGroups
|
|
292
479
|
onChoose={([choice]) => {
|
|
293
480
|
setPoster({ library: choice.section.id, id: choice.asset.id });
|
|
294
481
|
close();
|
|
@@ -298,7 +485,7 @@ import { MediaPicker } from "filecove";
|
|
|
298
485
|
</Dialog>;
|
|
299
486
|
```
|
|
300
487
|
|
|
301
|
-
It takes `multiple`, `maxChoices`, `canSelect`, `selectGroups`, `pickForm` (which adds the selected column), `value`, `defaultValue` (as `{ asset, values? }`), `onChange`, `slots`, `slotProps`, `relistAfter`, `limits`, `localeText` and `locale`. `allowUpload` lets the user upload into it; uploads still running
|
|
488
|
+
It takes `multiple`, `maxChoices`, `canSelect`, `selectGroups`, `filtersVariant`, `pickForm` (which adds the selected column), `value`, `defaultValue` (as `{ asset, values? }`), `onChange`, `slots`, `slotProps`, `relistAfter`, `limits`, `localeText` and `locale`. `allowUpload` lets the user upload into it; uploads still running are cancelled when it closes. `allowCreateGroups` adds New group, for uploads that want a group of their own: it's offered where the library's `createGroups` allows one, asks the library's `groupForm` (or only a name, through `createFolder`), and goes into the group once it's made, so the next upload lands there. There's no Move in the picker, so make the group first, then upload into it. With both, folders uploaded are made groups too, as in the media manager.
|
|
302
489
|
|
|
303
490
|
### `MediaPicture`
|
|
304
491
|
|
package/docs/search.md
CHANGED
|
@@ -15,6 +15,7 @@ search?(rootId: string, query: string, options: {
|
|
|
15
15
|
signal: AbortSignal;
|
|
16
16
|
cursor?: string;
|
|
17
17
|
showHidden: boolean;
|
|
18
|
+
filters?: Readonly<Record<string, unknown>>; // a media library's filters; never from the file manager
|
|
18
19
|
}): Promise<SearchResult>;
|
|
19
20
|
|
|
20
21
|
interface SearchResult {
|
|
@@ -35,6 +36,7 @@ interface SearchMatch {
|
|
|
35
36
|
- **Paging** works as `list`'s does: return `nextCursor` for more, and results show as they arrive. To cap the results, stop handing a cursor back.
|
|
36
37
|
- **`showHidden`** says whether hidden files are showing, so the backend can leave out hidden entries and what's in hidden folders.
|
|
37
38
|
- **Reject with an `Error`** to show its message beside that section's results, with Try again.
|
|
39
|
+
- **The media manager** calls the same `search` for its libraries, from the open group down, and hands a library's filters as `filters`, with an empty `query` while only filters are set (see [Searching and filtering](media-manager.md#searching-and-filtering)).
|
|
38
40
|
|
|
39
41
|
```ts
|
|
40
42
|
async search(rootId, query, { signal, cursor, showHidden }) {
|
|
@@ -10,7 +10,7 @@ upload?(file: File, folderId: string, options: {
|
|
|
10
10
|
conflict: "replace" | "keepBoth" | "skip";
|
|
11
11
|
onProgress: (loaded: number, total: number) => void;
|
|
12
12
|
values?: Readonly<Record<string, unknown>>; // a media library's upload form; never set by FileManager
|
|
13
|
-
}): Promise<FileEntry | void>;
|
|
13
|
+
}): Promise<FileEntry | UploadResult | void>;
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
**One file per call.** The file manager decides how many run at once (3 by default, `limits.uploads`), so each file has its own progress, error and cancel. How the bytes travel (a form post, S3 multipart, tus, chunks) is your adapter's business.
|
|
@@ -52,6 +52,7 @@ upload(file, folderId, { signal, conflict, onProgress }) {
|
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
- **Resolve with the file's entry** as it now is. That's how the file manager finds and highlights it, even when it was kept under another name beside one of the same name, and how a copy from another backend can be undone. Resolving with nothing works, but then a file kept under another name isn't found.
|
|
55
|
+
- **Or with an `UploadResult`**, `{ entry, existing?, trail? }`, when the backend already had the file and hands that back (`existing: true`), or put it in another folder (`trail`, the folders holding it). The upload panel's row then says "Already there" and where it is, and the media manager says so and points to it (see [A file the backend already has](media-manager.md#a-file-the-backend-already-has)). The file manager doesn't offer "Show in folder" for a file in another folder, and a copy from another backend that lands on a file the backend already had can't be undone, as undoing it would delete that file.
|
|
55
56
|
- **`conflict`**: the file manager checks the folder's listing first and asks the user about clashing names (Keep both, Replace, Skip). Skipped files aren't sent at all. What it passes is what to do with a clash it didn't see.
|
|
56
57
|
- **Reject with an `Error`** to show its message in the file's row, e.g. "This file is larger than 2 GB."
|
|
57
58
|
- **`onProgress`** is optional to call; without it, the row shows the file as uploading with no figure.
|
package/package.json
CHANGED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { Ref } from "react";
|
|
2
|
-
import type { DropEffect, FileEntry } from "../../types";
|
|
3
|
-
interface DragPreviewProps {
|
|
4
|
-
ref: Ref<HTMLDivElement>;
|
|
5
|
-
/** The entry the drag started from. */
|
|
6
|
-
entry: FileEntry;
|
|
7
|
-
/** How many entries are dragged, that one included. */
|
|
8
|
-
count: number;
|
|
9
|
-
/**
|
|
10
|
-
* A touch drag's, which follows the finger (`useEntryDrag` places it) and shows what letting
|
|
11
|
-
* go would do, where a mouse drag has the cursor say it.
|
|
12
|
-
*/
|
|
13
|
-
touch?: boolean;
|
|
14
|
-
effect?: DropEffect;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* The drag image: the grabbed entry's icon and name on a card, stacked on a card for each other
|
|
18
|
-
* entry up to `MAX_LAYERS`, with a count of them all when others go along, and for a touch drag a
|
|
19
|
-
* "+" where letting go would copy.
|
|
20
|
-
*/
|
|
21
|
-
declare const DragPreview: ({ ref, entry, count, touch, effect }: DragPreviewProps) => import("react").JSX.Element;
|
|
22
|
-
export default DragPreview;
|