@panneau/media 0.0.0-stage → 5.0.0-alpha.4
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/README.md +46 -2
- package/dist/MediaField.css +68 -0
- package/dist/MediaField.d.ts +69 -0
- package/dist/MediaField.d.ts.map +1 -0
- package/dist/MediaField.js +324 -0
- package/dist/MediaField.js.map +1 -0
- package/dist/MediaField.module.js +24 -0
- package/dist/MediaField.module.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/plugin.d.ts +11 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +15 -0
- package/dist/plugin.js.map +1 -0
- package/package.json +47 -5
package/README.md
CHANGED
|
@@ -1,3 +1,47 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @panneau/media
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The media of Panneau: the media field, which references media of a library, makes media of uploads and follows their processing. The media picker and the library come here too.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @panneau/media@^5.0.0-alpha.0 @tanstack/react-query react-aria-components react-intl
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
| Export | Content |
|
|
10
|
+
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
11
|
+
| `@panneau/media` | `MediaField`, `MediaFieldEntry`, `mediaPlugin`, `getLibrary()`, `toMediaReference()`, `toMediaReferences()`, `isProcessing()` |
|
|
12
|
+
|
|
13
|
+
## The media field
|
|
14
|
+
|
|
15
|
+
`MediaField` (the `media` type) references media of a library: a resource of kind `media` ([decision 0026](../../docs/decisions/0026-media-libraries.md)). Its value is a reference, `{ id, label, media, transform }`, or a list of them. A file chosen or dropped becomes a media of the library through the adapter (`create(resource, { file })` of `@panneau/data`): sent to storage first when there is an upload source, then made a media from its upload (`{ upload }`), or sent in `multipart/form-data` without one. The field shows each media with its thumbnail and its status (`pending`, `processing`, `failed`), and reads it again (`get()`) until its file is processed.
|
|
16
|
+
|
|
17
|
+
- `resource` is the library. `MediaFieldEntry` takes the field's `resource`, or the only library of the definition (`getLibrary()`), and its `itemTitle` for the labels. Without a library, the field shows its media and can't add any.
|
|
18
|
+
|
|
19
|
+
- `adapter` defaults to the adapter of `DataAdapterProvider` (`useOptionalDataAdapter()` of `@panneau/data/query`). Without one, the field is read-only, and says so.
|
|
20
|
+
- `uploadSource` defaults to the one of the fields context (`FieldsProvider`, or `FormView` of `@panneau/forms`). The upload core, the file field and the Uppy source are in [`@panneau/fields`](../fields): this package doesn't import Uppy.
|
|
21
|
+
- `accept` and `maxSize` (the field's `accept`, its `accept` rule and its `maxSize` rule) refuse files before they are sent.
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { FieldsProvider, builtInFields } from '@panneau/fields';
|
|
25
|
+
import { createUppyUploadSource } from '@panneau/fields/uppy';
|
|
26
|
+
import { mediaPlugin } from '@panneau/media';
|
|
27
|
+
|
|
28
|
+
const uploadSource =
|
|
29
|
+
definition.uploads?.mode === 'presigned' && adapter.presignedUploads !== undefined
|
|
30
|
+
? createUppyUploadSource(
|
|
31
|
+
adapter.presignedUploads({ endpoint: definition.uploads.endpoint }),
|
|
32
|
+
)
|
|
33
|
+
: null;
|
|
34
|
+
|
|
35
|
+
<DataAdapterProvider adapter={adapter}>
|
|
36
|
+
<FieldsProvider
|
|
37
|
+
components={{ ...builtInFields, ...mediaPlugin.fields }}
|
|
38
|
+
uploadSource={uploadSource}
|
|
39
|
+
>
|
|
40
|
+
…
|
|
41
|
+
</FieldsProvider>
|
|
42
|
+
</DataAdapterProvider>;
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`mediaPlugin` gives the `media` type to `@panneau/core`: pass it after `fieldsPlugin`. The `file` type is built into `@panneau/fields`.
|
|
46
|
+
|
|
47
|
+
The package layout, scripts and API reports are explained in [`docs/packages.md`](../../docs/packages.md).
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
.panneau-media-field-field {
|
|
2
|
+
display: grid;
|
|
3
|
+
gap: var(--panneau-space-2);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.panneau-media-field-media {
|
|
7
|
+
display: grid;
|
|
8
|
+
gap: var(--panneau-space-2);
|
|
9
|
+
margin: 0;
|
|
10
|
+
padding: 0;
|
|
11
|
+
list-style: none;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.panneau-media-field-item {
|
|
15
|
+
display: grid;
|
|
16
|
+
grid-template-columns: 3rem minmax(0, 1fr) auto;
|
|
17
|
+
align-items: center;
|
|
18
|
+
gap: var(--panneau-space-2);
|
|
19
|
+
padding: var(--panneau-space-1);
|
|
20
|
+
background-color: var(--panneau-color-surface-sunken);
|
|
21
|
+
border: var(--panneau-border-width) solid var(--panneau-color-border);
|
|
22
|
+
border-radius: var(--panneau-radius-md);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.panneau-media-field-thumbnail {
|
|
26
|
+
display: grid;
|
|
27
|
+
place-items: center;
|
|
28
|
+
width: 3rem;
|
|
29
|
+
height: 3rem;
|
|
30
|
+
overflow: hidden;
|
|
31
|
+
color: var(--panneau-color-text-muted);
|
|
32
|
+
background-color: var(--panneau-color-surface);
|
|
33
|
+
border-radius: var(--panneau-radius-sm);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.panneau-media-field-thumbnail img {
|
|
37
|
+
width: 100%;
|
|
38
|
+
height: 100%;
|
|
39
|
+
object-fit: cover;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.panneau-media-field-details {
|
|
43
|
+
display: grid;
|
|
44
|
+
gap: var(--panneau-space-1);
|
|
45
|
+
min-width: 0;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.panneau-media-field-name {
|
|
49
|
+
overflow: hidden;
|
|
50
|
+
font-size: var(--panneau-font-size-sm);
|
|
51
|
+
font-weight: var(--panneau-font-weight-medium);
|
|
52
|
+
text-overflow: ellipsis;
|
|
53
|
+
white-space: nowrap;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.panneau-media-field-meta {
|
|
57
|
+
display: flex;
|
|
58
|
+
flex-wrap: wrap;
|
|
59
|
+
align-items: center;
|
|
60
|
+
gap: var(--panneau-space-2);
|
|
61
|
+
font-size: var(--panneau-font-size-sm);
|
|
62
|
+
color: var(--panneau-color-text-muted);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.panneau-media-field-none {
|
|
66
|
+
font-size: var(--panneau-font-size-md);
|
|
67
|
+
color: var(--panneau-color-text-muted);
|
|
68
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { DataAdapter } from '@panneau/data';
|
|
2
|
+
import { type FieldEntryProps, type FieldProps, type UploadSource } from '@panneau/fields';
|
|
3
|
+
import type { Definition, MediaReference } from '@panneau/protocol';
|
|
4
|
+
/** What the media field needs from an adapter: `@panneau/data`'s `DataAdapter` has it. */
|
|
5
|
+
export type MediaAdapter = Pick<DataAdapter, 'create' | 'get'>;
|
|
6
|
+
export interface MediaFieldBaseProps extends Omit<FieldProps<never>, 'value' | 'onChange'> {
|
|
7
|
+
/** The library: a resource of kind `media`, whose items the field references. */
|
|
8
|
+
resource: string;
|
|
9
|
+
/** The field that titles the media of the library, for the label of new references. Defaults to `name`. */
|
|
10
|
+
itemTitle?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Creates media in the library from uploads (`create(resource, { file })`), and reads them
|
|
13
|
+
* again until they are processed (`get()`). Defaults to the adapter of `DataAdapterProvider`.
|
|
14
|
+
* Without one, the field is read-only.
|
|
15
|
+
*/
|
|
16
|
+
adapter?: MediaAdapter | null;
|
|
17
|
+
/**
|
|
18
|
+
* Where files are uploaded directly to storage. Defaults to the one of the fields context.
|
|
19
|
+
* Without one, files are sent in `multipart/form-data` when the media is created.
|
|
20
|
+
*/
|
|
21
|
+
uploadSource?: UploadSource | null;
|
|
22
|
+
accept?: readonly string[] | null;
|
|
23
|
+
maxSize?: number | null;
|
|
24
|
+
/** How often to read a media again until it is ready, in milliseconds. Defaults to 3 s. */
|
|
25
|
+
refreshInterval?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface SingleMediaFieldProps extends MediaFieldBaseProps {
|
|
28
|
+
multiple?: false;
|
|
29
|
+
value?: MediaReference | null;
|
|
30
|
+
onChange?: (value: MediaReference | null) => void;
|
|
31
|
+
}
|
|
32
|
+
export interface MultipleMediaFieldProps extends MediaFieldBaseProps {
|
|
33
|
+
multiple: true;
|
|
34
|
+
value?: readonly MediaReference[] | null;
|
|
35
|
+
/** Called with the media. An empty list is `null`. */
|
|
36
|
+
onChange?: (value: MediaReference[] | null) => void;
|
|
37
|
+
}
|
|
38
|
+
export type MediaFieldProps = SingleMediaFieldProps | MultipleMediaFieldProps;
|
|
39
|
+
/**
|
|
40
|
+
* The reference of a value: a reference, a media item (its `media` and title), or an id, as a
|
|
41
|
+
* product's own API may give them.
|
|
42
|
+
*/
|
|
43
|
+
export declare function toMediaReference(value: unknown, itemTitle?: string): MediaReference | null;
|
|
44
|
+
/** The references of a value, single or multiple. */
|
|
45
|
+
export declare function toMediaReferences(value: unknown, itemTitle?: string): MediaReference[];
|
|
46
|
+
/** Whether the file of a media is still being processed. */
|
|
47
|
+
export declare function isProcessing(reference: MediaReference): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* The library of a `media` field: its `resource`, or the only resource of kind `media` of the
|
|
50
|
+
* definition.
|
|
51
|
+
*/
|
|
52
|
+
export declare function getLibrary(definition: Pick<Definition, 'resources'> | null, resource: string | undefined): Definition['resources'][number] | null;
|
|
53
|
+
/**
|
|
54
|
+
* Media of a library (the `media` type, decision 0026): a file chosen or dropped becomes a media
|
|
55
|
+
* of the library, an item of its resource (`create(resource, { file })`), sent directly to storage
|
|
56
|
+
* first when there is an upload source. Values are references to the media, with their `media`
|
|
57
|
+
* and their `transform` for this use. The field shows each media with its thumbnail and its
|
|
58
|
+
* status, and reads it again until its file is processed. Picking media already in the library
|
|
59
|
+
* comes with the media picker.
|
|
60
|
+
*/
|
|
61
|
+
export declare function MediaField(props: MediaFieldProps): import("react").JSX.Element;
|
|
62
|
+
/**
|
|
63
|
+
* The registry entry of the `media` type: the field's library (`resource`, or the only `media`
|
|
64
|
+
* resource of the definition), `multiple`, `accept` (or its `accept` rule) and `maxSize` rule,
|
|
65
|
+
* with the adapter of `@panneau/data` and the upload source of the fields context. Without a
|
|
66
|
+
* library, the field shows its media and can't add any.
|
|
67
|
+
*/
|
|
68
|
+
export declare function MediaFieldEntry(props: FieldEntryProps): import("react").JSX.Element;
|
|
69
|
+
//# sourceMappingURL=MediaField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MediaField.d.ts","sourceRoot":"","sources":["../src/MediaField.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,EACH,KAAK,eAAe,EACpB,KAAK,UAAU,EAGf,KAAK,YAAY,EAQpB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,UAAU,EAAmB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAKrF,0FAA0F;AAC1F,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,EAAE,QAAQ,GAAG,KAAK,CAAC,CAAC;AAE/D,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IACtF,iFAAiF;IACjF,QAAQ,EAAE,MAAM,CAAC;IACjB,2GAA2G;IAC3G,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IAC9B;;;OAGG;IACH,YAAY,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IACnC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;IAClC,OAAO,C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,EAAE,eAAe,+BAmBrD"}
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import MediaField_module_default from "./MediaField.module.js";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { FileImage, X } from "lucide-react";
|
|
4
|
+
import { useEffect, useRef, useState } from "react";
|
|
5
|
+
import { usePanneau } from "@panneau/core";
|
|
6
|
+
import { useOptionalDataAdapter } from "@panneau/data/query";
|
|
7
|
+
import { FilePicker, UploadList, formatSize, getAccept, getFieldProps, getMaxSize, useFieldsContext, useRejectionMessage, useUploads } from "@panneau/fields";
|
|
8
|
+
import { fieldsMessages, mediaMessages } from "@panneau/intl";
|
|
9
|
+
import { Badge, Fieldset, IconButton, Spinner, usePanneauIntl } from "@panneau/ui";
|
|
10
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
//#region src/MediaField.tsx
|
|
12
|
+
/**
|
|
13
|
+
* The reference of a value: a reference, a media item (its `media` and title), or an id, as a
|
|
14
|
+
* product's own API may give them.
|
|
15
|
+
*/
|
|
16
|
+
function toMediaReference(value, itemTitle = "name") {
|
|
17
|
+
if (typeof value === "string" || typeof value === "number") return { id: String(value) };
|
|
18
|
+
if (typeof value !== "object" || value === null) return null;
|
|
19
|
+
const { id, label, media, transform } = value;
|
|
20
|
+
if (typeof id !== "string" && typeof id !== "number") return null;
|
|
21
|
+
const title = value[itemTitle];
|
|
22
|
+
const reference = { id: String(id) };
|
|
23
|
+
if (typeof label === "string") reference.label = label;
|
|
24
|
+
else if (typeof title === "string") reference.label = title;
|
|
25
|
+
if (typeof media === "object" && media !== null) reference.media = media;
|
|
26
|
+
if (typeof transform === "object") reference.transform = transform;
|
|
27
|
+
return reference;
|
|
28
|
+
}
|
|
29
|
+
/** The references of a value, single or multiple. */
|
|
30
|
+
function toMediaReferences(value, itemTitle) {
|
|
31
|
+
return (Array.isArray(value) ? value : [value]).map((entry) => toMediaReference(entry, itemTitle)).filter((reference) => reference !== null);
|
|
32
|
+
}
|
|
33
|
+
/** Whether the file of a media is still being processed. */
|
|
34
|
+
function isProcessing(reference) {
|
|
35
|
+
const status = reference.media?.status;
|
|
36
|
+
return status === "pending" || status === "processing";
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The library of a `media` field: its `resource`, or the only resource of kind `media` of the
|
|
40
|
+
* definition.
|
|
41
|
+
*/
|
|
42
|
+
function getLibrary(definition, resource) {
|
|
43
|
+
const libraries = (definition?.resources ?? []).filter((candidate) => candidate.kind === "media");
|
|
44
|
+
if (resource !== void 0) return libraries.find((candidate) => candidate.id === resource) ?? null;
|
|
45
|
+
return libraries.length === 1 ? libraries[0] ?? null : null;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Reads media again while they are being ingested, until they are ready or failed, and calls
|
|
49
|
+
* `onRefresh` with the media that changed.
|
|
50
|
+
*/
|
|
51
|
+
function useMediaRefresh(media, resource, adapter, interval, onRefresh) {
|
|
52
|
+
const $ = c(10);
|
|
53
|
+
const latest = useRef(onRefresh);
|
|
54
|
+
let t0;
|
|
55
|
+
if ($[0] !== onRefresh) {
|
|
56
|
+
t0 = () => {
|
|
57
|
+
latest.current = onRefresh;
|
|
58
|
+
};
|
|
59
|
+
$[0] = onRefresh;
|
|
60
|
+
$[1] = t0;
|
|
61
|
+
} else t0 = $[1];
|
|
62
|
+
useEffect(t0);
|
|
63
|
+
let t1;
|
|
64
|
+
if ($[2] !== media) {
|
|
65
|
+
t1 = media.filter(isProcessing).map(_temp).join(",");
|
|
66
|
+
$[2] = media;
|
|
67
|
+
$[3] = t1;
|
|
68
|
+
} else t1 = $[3];
|
|
69
|
+
const key = t1;
|
|
70
|
+
let t2;
|
|
71
|
+
let t3;
|
|
72
|
+
if ($[4] !== adapter || $[5] !== interval || $[6] !== key || $[7] !== resource) {
|
|
73
|
+
t2 = () => {
|
|
74
|
+
if (adapter === null || key === "") return;
|
|
75
|
+
const ids = key.split(",").map(_temp2);
|
|
76
|
+
const controller = new AbortController();
|
|
77
|
+
const timer = setTimeout(() => {
|
|
78
|
+
Promise.all(ids.map((id) => adapter.get(resource, id, { signal: controller.signal }))).then((refreshed) => {
|
|
79
|
+
if (!controller.signal.aborted) latest.current(refreshed);
|
|
80
|
+
}).catch(_temp3);
|
|
81
|
+
}, interval);
|
|
82
|
+
return () => {
|
|
83
|
+
clearTimeout(timer);
|
|
84
|
+
controller.abort();
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
t3 = [
|
|
88
|
+
adapter,
|
|
89
|
+
resource,
|
|
90
|
+
key,
|
|
91
|
+
interval
|
|
92
|
+
];
|
|
93
|
+
$[4] = adapter;
|
|
94
|
+
$[5] = interval;
|
|
95
|
+
$[6] = key;
|
|
96
|
+
$[7] = resource;
|
|
97
|
+
$[8] = t2;
|
|
98
|
+
$[9] = t3;
|
|
99
|
+
} else {
|
|
100
|
+
t2 = $[8];
|
|
101
|
+
t3 = $[9];
|
|
102
|
+
}
|
|
103
|
+
useEffect(t2, t3);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Media of a library (the `media` type, decision 0026): a file chosen or dropped becomes a media
|
|
107
|
+
* of the library, an item of its resource (`create(resource, { file })`), sent directly to storage
|
|
108
|
+
* first when there is an upload source. Values are references to the media, with their `media`
|
|
109
|
+
* and their `transform` for this use. The field shows each media with its thumbnail and its
|
|
110
|
+
* status, and reads it again until its file is processed. Picking media already in the library
|
|
111
|
+
* comes with the media picker.
|
|
112
|
+
*/
|
|
113
|
+
function _temp3() {}
|
|
114
|
+
function _temp2(entry) {
|
|
115
|
+
return entry.slice(0, entry.lastIndexOf(":"));
|
|
116
|
+
}
|
|
117
|
+
function _temp(item) {
|
|
118
|
+
return `${item.id}:${item.media?.status ?? ""}`;
|
|
119
|
+
}
|
|
120
|
+
function MediaField(props) {
|
|
121
|
+
const intl = usePanneauIntl();
|
|
122
|
+
const contextAdapter = useOptionalDataAdapter();
|
|
123
|
+
const context = useFieldsContext();
|
|
124
|
+
const { adapter = contextAdapter, uploadSource = context.uploadSource, accept = null, maxSize = null, refreshInterval = 3e3, resource, itemTitle = "name", label, description, errors = [], disabled, readOnly, required, className, labelClassName, descriptionClassName, errorsClassName } = props;
|
|
125
|
+
const multiple = props.multiple === true;
|
|
126
|
+
const media = toMediaReferences(props.value, itemTitle);
|
|
127
|
+
const editable = adapter !== null && disabled !== true && readOnly !== true;
|
|
128
|
+
const [problems, setProblems] = useState([]);
|
|
129
|
+
const [creating, setCreating] = useState([]);
|
|
130
|
+
const rejectionMessage = useRejectionMessage(maxSize);
|
|
131
|
+
const latest = useRef(media);
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
latest.current = media;
|
|
134
|
+
});
|
|
135
|
+
const set = (next) => {
|
|
136
|
+
latest.current = next;
|
|
137
|
+
if (props.multiple === true) props.onChange?.(next.length > 0 ? next : null);
|
|
138
|
+
else props.onChange?.(next[0] ?? null);
|
|
139
|
+
};
|
|
140
|
+
useMediaRefresh(media, resource, adapter, refreshInterval, (refreshed) => set(latest.current.map((reference) => {
|
|
141
|
+
const item = refreshed.find((candidate) => candidate.id === reference.id);
|
|
142
|
+
const fresh = item !== void 0 ? toMediaReference(item, itemTitle) : null;
|
|
143
|
+
return fresh !== null ? {
|
|
144
|
+
...reference,
|
|
145
|
+
...fresh,
|
|
146
|
+
transform: reference.transform
|
|
147
|
+
} : reference;
|
|
148
|
+
})));
|
|
149
|
+
const upload = useUploads({
|
|
150
|
+
source: uploadSource,
|
|
151
|
+
accept,
|
|
152
|
+
maxSize,
|
|
153
|
+
onUploaded: (file) => {
|
|
154
|
+
if (adapter === null) return;
|
|
155
|
+
const name = file.name;
|
|
156
|
+
setCreating((current) => [...current, name]);
|
|
157
|
+
adapter.create(resource, { file: file instanceof File ? file : { upload: file.upload } }).then((item_0) => {
|
|
158
|
+
const created = toMediaReference(item_0, itemTitle) ?? { id: item_0.id };
|
|
159
|
+
set(multiple ? [...latest.current, created] : [created]);
|
|
160
|
+
}).catch((error) => setProblems((current_0) => [...current_0, intl.formatMessage(fieldsMessages.uploadFailed, { error: `${name}: ${error instanceof Error ? error.message : String(error)}` })])).finally(() => setCreating((current_1) => {
|
|
161
|
+
const at = current_1.indexOf(name);
|
|
162
|
+
return at === -1 ? current_1 : current_1.filter((_, index) => index !== at);
|
|
163
|
+
}));
|
|
164
|
+
},
|
|
165
|
+
onRejected: (file_0, reason) => setProblems((current_2) => [...current_2, rejectionMessage(file_0, reason)])
|
|
166
|
+
});
|
|
167
|
+
const statusBadge = (item_1) => {
|
|
168
|
+
if (item_1.media?.status === "failed") return /* @__PURE__ */ jsx(Badge, {
|
|
169
|
+
tone: "danger",
|
|
170
|
+
children: intl.formatMessage(mediaMessages.statusFailed)
|
|
171
|
+
});
|
|
172
|
+
if (isProcessing(item_1)) return /* @__PURE__ */ jsx(Badge, {
|
|
173
|
+
tone: "warning",
|
|
174
|
+
children: intl.formatMessage(item_1.media?.status === "pending" ? mediaMessages.statusPending : mediaMessages.statusProcessing)
|
|
175
|
+
});
|
|
176
|
+
return null;
|
|
177
|
+
};
|
|
178
|
+
return /* @__PURE__ */ jsx(Fieldset, {
|
|
179
|
+
legend: label,
|
|
180
|
+
description: adapter === null && disabled !== true && readOnly !== true ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
181
|
+
description,
|
|
182
|
+
" ",
|
|
183
|
+
intl.formatMessage(mediaMessages.unavailable)
|
|
184
|
+
] }) : description,
|
|
185
|
+
errors: [...errors, ...problems],
|
|
186
|
+
isRequired: required,
|
|
187
|
+
isDisabled: disabled,
|
|
188
|
+
className,
|
|
189
|
+
legendClassName: labelClassName,
|
|
190
|
+
descriptionClassName,
|
|
191
|
+
errorsClassName,
|
|
192
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
193
|
+
className: MediaField_module_default.field,
|
|
194
|
+
children: [
|
|
195
|
+
media.length > 0 ? /* @__PURE__ */ jsx("ul", {
|
|
196
|
+
className: MediaField_module_default.media,
|
|
197
|
+
children: media.map((item_2) => {
|
|
198
|
+
const name_0 = item_2.label ?? item_2.id;
|
|
199
|
+
const size = item_2.media?.size;
|
|
200
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
201
|
+
className: MediaField_module_default.item,
|
|
202
|
+
children: [
|
|
203
|
+
/* @__PURE__ */ jsx("span", {
|
|
204
|
+
className: MediaField_module_default.thumbnail,
|
|
205
|
+
children: typeof item_2.media?.thumbnailUrl === "string" ? /* @__PURE__ */ jsx("img", {
|
|
206
|
+
src: item_2.media.thumbnailUrl,
|
|
207
|
+
alt: ""
|
|
208
|
+
}) : /* @__PURE__ */ jsx(FileImage, { "aria-hidden": true })
|
|
209
|
+
}),
|
|
210
|
+
/* @__PURE__ */ jsxs("span", {
|
|
211
|
+
className: MediaField_module_default.details,
|
|
212
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
213
|
+
className: MediaField_module_default.name,
|
|
214
|
+
children: name_0
|
|
215
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
216
|
+
className: MediaField_module_default.meta,
|
|
217
|
+
children: [
|
|
218
|
+
item_2.media !== void 0 ? /* @__PURE__ */ jsx("span", { children: item_2.media.type }) : null,
|
|
219
|
+
typeof size === "number" ? /* @__PURE__ */ jsx("span", { children: formatSize(size, intl.locale) }) : null,
|
|
220
|
+
statusBadge(item_2)
|
|
221
|
+
]
|
|
222
|
+
})]
|
|
223
|
+
}),
|
|
224
|
+
editable ? /* @__PURE__ */ jsx(IconButton, {
|
|
225
|
+
icon: X,
|
|
226
|
+
size: "sm",
|
|
227
|
+
label: intl.formatMessage(fieldsMessages.removeFile, { name: name_0 }),
|
|
228
|
+
onPress: () => set(latest.current.filter((entry) => entry.id !== item_2.id))
|
|
229
|
+
}) : null
|
|
230
|
+
]
|
|
231
|
+
}, item_2.id);
|
|
232
|
+
})
|
|
233
|
+
}) : creating.length === 0 && upload.items.length === 0 ? /* @__PURE__ */ jsx("span", {
|
|
234
|
+
className: MediaField_module_default.none,
|
|
235
|
+
children: intl.formatMessage(mediaMessages.noMedia)
|
|
236
|
+
}) : null,
|
|
237
|
+
/* @__PURE__ */ jsx(UploadList, {
|
|
238
|
+
items: upload.items,
|
|
239
|
+
onPause: upload.pause,
|
|
240
|
+
onResume: upload.resume,
|
|
241
|
+
onCancel: upload.cancel,
|
|
242
|
+
onRetry: upload.retry
|
|
243
|
+
}),
|
|
244
|
+
creating.length > 0 ? /* @__PURE__ */ jsxs("span", {
|
|
245
|
+
className: MediaField_module_default.meta,
|
|
246
|
+
role: "status",
|
|
247
|
+
children: [
|
|
248
|
+
/* @__PURE__ */ jsx(Spinner, { size: "sm" }),
|
|
249
|
+
intl.formatMessage(fieldsMessages.uploadCompleting),
|
|
250
|
+
" ",
|
|
251
|
+
creating.join(", ")
|
|
252
|
+
]
|
|
253
|
+
}) : null,
|
|
254
|
+
editable ? /* @__PURE__ */ jsx(FilePicker, {
|
|
255
|
+
accept,
|
|
256
|
+
multiple,
|
|
257
|
+
onSelect: (selected) => {
|
|
258
|
+
setProblems([]);
|
|
259
|
+
upload.add(selected);
|
|
260
|
+
}
|
|
261
|
+
}) : null
|
|
262
|
+
]
|
|
263
|
+
})
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* The registry entry of the `media` type: the field's library (`resource`, or the only `media`
|
|
268
|
+
* resource of the definition), `multiple`, `accept` (or its `accept` rule) and `maxSize` rule,
|
|
269
|
+
* with the adapter of `@panneau/data` and the upload source of the fields context. Without a
|
|
270
|
+
* library, the field shows its media and can't add any.
|
|
271
|
+
*/
|
|
272
|
+
function MediaFieldEntry(props) {
|
|
273
|
+
const $ = c(11);
|
|
274
|
+
const { field, value, onChange } = props;
|
|
275
|
+
const { definition } = usePanneau();
|
|
276
|
+
let common;
|
|
277
|
+
let t0;
|
|
278
|
+
if ($[0] !== definition || $[1] !== field || $[2] !== props || $[3] !== value) {
|
|
279
|
+
const library = getLibrary(definition, field.resource);
|
|
280
|
+
const itemTitle = library?.itemTitle ?? "name";
|
|
281
|
+
common = {
|
|
282
|
+
...getFieldProps(props),
|
|
283
|
+
resource: library?.id ?? field.resource ?? "",
|
|
284
|
+
itemTitle,
|
|
285
|
+
accept: getAccept(field),
|
|
286
|
+
maxSize: getMaxSize(field),
|
|
287
|
+
...library === null ? { adapter: null } : {}
|
|
288
|
+
};
|
|
289
|
+
t0 = toMediaReferences(value, itemTitle);
|
|
290
|
+
$[0] = definition;
|
|
291
|
+
$[1] = field;
|
|
292
|
+
$[2] = props;
|
|
293
|
+
$[3] = value;
|
|
294
|
+
$[4] = common;
|
|
295
|
+
$[5] = t0;
|
|
296
|
+
} else {
|
|
297
|
+
common = $[4];
|
|
298
|
+
t0 = $[5];
|
|
299
|
+
}
|
|
300
|
+
const references = t0;
|
|
301
|
+
let t1;
|
|
302
|
+
if ($[6] !== common || $[7] !== field.multiple || $[8] !== onChange || $[9] !== references) {
|
|
303
|
+
t1 = field.multiple === true ? /* @__PURE__ */ jsx(MediaField, {
|
|
304
|
+
...common,
|
|
305
|
+
multiple: true,
|
|
306
|
+
value: references,
|
|
307
|
+
onChange
|
|
308
|
+
}) : /* @__PURE__ */ jsx(MediaField, {
|
|
309
|
+
...common,
|
|
310
|
+
value: references[0] ?? null,
|
|
311
|
+
onChange
|
|
312
|
+
});
|
|
313
|
+
$[6] = common;
|
|
314
|
+
$[7] = field.multiple;
|
|
315
|
+
$[8] = onChange;
|
|
316
|
+
$[9] = references;
|
|
317
|
+
$[10] = t1;
|
|
318
|
+
} else t1 = $[10];
|
|
319
|
+
return t1;
|
|
320
|
+
}
|
|
321
|
+
//#endregion
|
|
322
|
+
export { MediaField, MediaFieldEntry, getLibrary, isProcessing, toMediaReference, toMediaReferences };
|
|
323
|
+
|
|
324
|
+
//# sourceMappingURL=MediaField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MediaField.js","names":["item","current","file","name","references","onChange","_c","messages","_Fragment","styles"],"sources":["../src/MediaField.tsx"],"sourcesContent":["import { FileImage, X } from 'lucide-react';\nimport { useEffect, useRef, useState } from 'react';\n\nimport { usePanneau } from '@panneau/core';\nimport type { DataAdapter } from '@panneau/data';\nimport { useOptionalDataAdapter } from '@panneau/data/query';\nimport {\n type FieldEntryProps,\n type FieldProps,\n FilePicker,\n UploadList,\n type UploadSource,\n formatSize,\n getAccept,\n getFieldProps,\n getMaxSize,\n useFieldsContext,\n useRejectionMessage,\n useUploads,\n} from '@panneau/fields';\nimport { fieldsMessages, mediaMessages as messages } from '@panneau/intl';\nimport type { Definition, Item, MediaInfo, MediaReference } from '@panneau/protocol';\nimport { Badge, Fieldset, IconButton, Spinner, usePanneauIntl } from '@panneau/ui';\n\nimport styles from './MediaField.module.css';\n\n/** What the media field needs from an adapter: `@panneau/data`'s `DataAdapter` has it. */\nexport type MediaAdapter = Pick<DataAdapter, 'create' | 'get'>;\n\nexport interface MediaFieldBaseProps extends Omit<FieldProps<never>, 'value' | 'onChange'> {\n /** The library: a resource of kind `media`, whose items the field references. */\n resource: string;\n /** The field that titles the media of the library, for the label of new references. Defaults to `name`. */\n itemTitle?: string;\n /**\n * Creates media in the library from uploads (`create(resource, { file })`), and reads them\n * again until they are processed (`get()`). Defaults to the adapter of `DataAdapterProvider`.\n * Without one, the field is read-only.\n */\n adapter?: MediaAdapter | null;\n /**\n * Where files are uploaded directly to storage. Defaults to the one of the fields context.\n * Without one, files are sent in `multipart/form-data` when the media is created.\n */\n uploadSource?: UploadSource | null;\n accept?: readonly string[] | null;\n maxSize?: number | null;\n /** How often to read a media again until it is ready, in milliseconds. Defaults to 3 s. */\n refreshInterval?: number;\n}\n\nexport interface SingleMediaFieldProps extends MediaFieldBaseProps {\n multiple?: false;\n value?: MediaReference | null;\n onChange?: (value: MediaReference | null) => void;\n}\n\nexport interface MultipleMediaFieldProps extends MediaFieldBaseProps {\n multiple: true;\n value?: readonly MediaReference[] | null;\n /** Called with the media. An empty list is `null`. */\n onChange?: (value: MediaReference[] | null) => void;\n}\n\nexport type MediaFieldProps = SingleMediaFieldProps | MultipleMediaFieldProps;\n\n/**\n * The reference of a value: a reference, a media item (its `media` and title), or an id, as a\n * product's own API may give them.\n */\nexport function toMediaReference(value: unknown, itemTitle = 'name'): MediaReference | null {\n if (typeof value === 'string' || typeof value === 'number') {\n return { id: String(value) };\n }\n if (typeof value !== 'object' || value === null) {\n return null;\n }\n const { id, label, media, transform } = value as Record<string, unknown>;\n if (typeof id !== 'string' && typeof id !== 'number') {\n return null;\n }\n const title = (value as Record<string, unknown>)[itemTitle];\n const reference: MediaReference = { id: String(id) };\n if (typeof label === 'string') {\n reference.label = label;\n } else if (typeof title === 'string') {\n reference.label = title;\n }\n if (typeof media === 'object' && media !== null) {\n reference.media = media as MediaInfo;\n }\n if (typeof transform === 'object') {\n reference.transform = transform as MediaReference['transform'];\n }\n return reference;\n}\n\n/** The references of a value, single or multiple. */\nexport function toMediaReferences(value: unknown, itemTitle?: string): MediaReference[] {\n const values: unknown[] = Array.isArray(value) ? value : [value];\n return values\n .map((entry) => toMediaReference(entry, itemTitle))\n .filter((reference): reference is MediaReference => reference !== null);\n}\n\n/** Whether the file of a media is still being processed. */\nexport function isProcessing(reference: MediaReference): boolean {\n const status = reference.media?.status;\n return status === 'pending' || status === 'processing';\n}\n\n/**\n * The library of a `media` field: its `resource`, or the only resource of kind `media` of the\n * definition.\n */\nexport function getLibrary(\n definition: Pick<Definition, 'resources'> | null,\n resource: string | undefined,\n): Definition['resources'][number] | null {\n const libraries = (definition?.resources ?? []).filter(\n (candidate) => candidate.kind === 'media',\n );\n if (resource !== undefined) {\n return libraries.find((candidate) => candidate.id === resource) ?? null;\n }\n return libraries.length === 1 ? (libraries[0] ?? null) : null;\n}\n\n/**\n * Reads media again while they are being ingested, until they are ready or failed, and calls\n * `onRefresh` with the media that changed.\n */\nfunction useMediaRefresh(\n media: readonly MediaReference[],\n resource: string,\n adapter: MediaAdapter | null,\n interval: number,\n onRefresh: (refreshed: Item[]) => void,\n) {\n const latest = useRef(onRefresh);\n useEffect(() => {\n latest.current = onRefresh;\n });\n const waiting = media\n .filter(isProcessing)\n .map((item) => `${item.id}:${item.media?.status ?? ''}`);\n const key = waiting.join(',');\n\n useEffect(() => {\n if (adapter === null || key === '') {\n return undefined;\n }\n const ids = key.split(',').map((entry) => entry.slice(0, entry.lastIndexOf(':')));\n const controller = new AbortController();\n const timer = setTimeout(() => {\n Promise.all(ids.map((id) => adapter.get(resource, id, { signal: controller.signal })))\n .then((refreshed) => {\n if (!controller.signal.aborted) {\n latest.current(refreshed);\n }\n })\n .catch(() => undefined);\n }, interval);\n return () => {\n clearTimeout(timer);\n controller.abort();\n };\n }, [adapter, resource, key, interval]);\n}\n\n/**\n * Media of a library (the `media` type, decision 0026): a file chosen or dropped becomes a media\n * of the library, an item of its resource (`create(resource, { file })`), sent directly to storage\n * first when there is an upload source. Values are references to the media, with their `media`\n * and their `transform` for this use. The field shows each media with its thumbnail and its\n * status, and reads it again until its file is processed. Picking media already in the library\n * comes with the media picker.\n */\nexport function MediaField(props: MediaFieldProps) {\n const intl = usePanneauIntl();\n const contextAdapter = useOptionalDataAdapter();\n const context = useFieldsContext();\n const {\n adapter = contextAdapter,\n uploadSource = context.uploadSource,\n accept = null,\n maxSize = null,\n refreshInterval = 3000,\n resource,\n itemTitle = 'name',\n label,\n description,\n errors = [],\n disabled,\n readOnly,\n required,\n className,\n labelClassName,\n descriptionClassName,\n errorsClassName,\n } = props;\n const multiple = props.multiple === true;\n const media = toMediaReferences(props.value, itemTitle);\n const editable = adapter !== null && disabled !== true && readOnly !== true;\n const [problems, setProblems] = useState<string[]>([]);\n const [creating, setCreating] = useState<string[]>([]);\n const rejectionMessage = useRejectionMessage(maxSize);\n\n const latest = useRef(media);\n useEffect(() => {\n latest.current = media;\n });\n const set = (next: MediaReference[]) => {\n latest.current = next;\n if (props.multiple === true) {\n props.onChange?.(next.length > 0 ? next : null);\n } else {\n props.onChange?.(next[0] ?? null);\n }\n };\n\n useMediaRefresh(media, resource, adapter, refreshInterval, (refreshed) =>\n set(\n latest.current.map((reference) => {\n const item = refreshed.find((candidate) => candidate.id === reference.id);\n const fresh = item !== undefined ? toMediaReference(item, itemTitle) : null;\n return fresh !== null\n ? { ...reference, ...fresh, transform: reference.transform }\n : reference;\n }),\n ),\n );\n\n const upload = useUploads({\n source: uploadSource,\n accept,\n maxSize,\n onUploaded: (file) => {\n if (adapter === null) {\n return;\n }\n const name = file.name;\n setCreating((current) => [...current, name]);\n adapter\n .create(resource, { file: file instanceof File ? file : { upload: file.upload } })\n .then((item) => {\n const created = toMediaReference(item, itemTitle) ?? { id: item.id };\n set(multiple ? [...latest.current, created] : [created]);\n })\n .catch((error: unknown) =>\n setProblems((current) => [\n ...current,\n intl.formatMessage(fieldsMessages.uploadFailed, {\n error: `${name}: ${error instanceof Error ? error.message : String(error)}`,\n }),\n ]),\n )\n .finally(() =>\n setCreating((current) => {\n const at = current.indexOf(name);\n return at === -1 ? current : current.filter((_, index) => index !== at);\n }),\n );\n },\n onRejected: (file, reason) =>\n setProblems((current) => [...current, rejectionMessage(file, reason)]),\n });\n\n const statusBadge = (item: MediaReference) => {\n if (item.media?.status === 'failed') {\n return <Badge tone=\"danger\">{intl.formatMessage(messages.statusFailed)}</Badge>;\n }\n if (isProcessing(item)) {\n return (\n <Badge tone=\"warning\">\n {intl.formatMessage(\n item.media?.status === 'pending'\n ? messages.statusPending\n : messages.statusProcessing,\n )}\n </Badge>\n );\n }\n return null;\n };\n\n return (\n <Fieldset\n legend={label}\n description={\n adapter === null && disabled !== true && readOnly !== true ? (\n <>\n {description} {intl.formatMessage(messages.unavailable)}\n </>\n ) : (\n description\n )\n }\n errors={[...errors, ...problems]}\n isRequired={required}\n isDisabled={disabled}\n className={className}\n legendClassName={labelClassName}\n descriptionClassName={descriptionClassName}\n errorsClassName={errorsClassName}\n >\n <div className={styles.field}>\n {media.length > 0 ? (\n <ul className={styles.media}>\n {media.map((item) => {\n const name = item.label ?? item.id;\n const size = item.media?.size;\n return (\n <li key={item.id} className={styles.item}>\n <span className={styles.thumbnail}>\n {typeof item.media?.thumbnailUrl === 'string' ? (\n <img src={item.media.thumbnailUrl} alt=\"\" />\n ) : (\n <FileImage aria-hidden />\n )}\n </span>\n <span className={styles.details}>\n <span className={styles.name}>{name}</span>\n <span className={styles.meta}>\n {item.media !== undefined ? (\n <span>{item.media.type}</span>\n ) : null}\n {typeof size === 'number' ? (\n <span>{formatSize(size, intl.locale)}</span>\n ) : null}\n {statusBadge(item)}\n </span>\n </span>\n {editable ? (\n <IconButton\n icon={X}\n size=\"sm\"\n label={intl.formatMessage(fieldsMessages.removeFile, {\n name,\n })}\n onPress={() =>\n set(\n latest.current.filter(\n (entry) => entry.id !== item.id,\n ),\n )\n }\n />\n ) : null}\n </li>\n );\n })}\n </ul>\n ) : creating.length === 0 && upload.items.length === 0 ? (\n <span className={styles.none}>{intl.formatMessage(messages.noMedia)}</span>\n ) : null}\n <UploadList\n items={upload.items}\n onPause={upload.pause}\n onResume={upload.resume}\n onCancel={upload.cancel}\n onRetry={upload.retry}\n />\n {creating.length > 0 ? (\n <span className={styles.meta} role=\"status\">\n <Spinner size=\"sm\" />\n {intl.formatMessage(fieldsMessages.uploadCompleting)} {creating.join(', ')}\n </span>\n ) : null}\n {editable ? (\n <FilePicker\n accept={accept}\n multiple={multiple}\n onSelect={(selected) => {\n setProblems([]);\n upload.add(selected);\n }}\n />\n ) : null}\n </div>\n </Fieldset>\n );\n}\n\n/**\n * The registry entry of the `media` type: the field's library (`resource`, or the only `media`\n * resource of the definition), `multiple`, `accept` (or its `accept` rule) and `maxSize` rule,\n * with the adapter of `@panneau/data` and the upload source of the fields context. Without a\n * library, the field shows its media and can't add any.\n */\nexport function MediaFieldEntry(props: FieldEntryProps) {\n const { field, value, onChange } = props;\n const { definition } = usePanneau();\n const library = getLibrary(definition, field.resource);\n const itemTitle = library?.itemTitle ?? 'name';\n const common = {\n ...getFieldProps(props),\n resource: library?.id ?? field.resource ?? '',\n itemTitle,\n accept: getAccept(field),\n maxSize: getMaxSize(field),\n ...(library === null ? { adapter: null } : {}),\n };\n const references = toMediaReferences(value, itemTitle);\n return field.multiple === true ? (\n <MediaField {...common} multiple value={references} onChange={onChange} />\n ) : (\n <MediaField {...common} value={references[0] ?? null} onChange={onChange} />\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAsEA,SAAgB,iBAAiB,OAAgB,YAAY,QAA+B;CACxF,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UAC9C,OAAO,EAAE,IAAI,OAAO,KAAK,EAAE;CAE/B,IAAI,OAAO,UAAU,YAAY,UAAU,MACvC,OAAO;CAEX,MAAM,EAAE,IAAI,OAAO,OAAO,cAAc;CACxC,IAAI,OAAO,OAAO,YAAY,OAAO,OAAO,UACxC,OAAO;CAEX,MAAM,QAAS,MAAkC;CACjD,MAAM,YAA4B,EAAE,IAAI,OAAO,EAAE,EAAE;CACnD,IAAI,OAAO,UAAU,UACjB,UAAU,QAAQ;MACf,IAAI,OAAO,UAAU,UACxB,UAAU,QAAQ;CAEtB,IAAI,OAAO,UAAU,YAAY,UAAU,MACvC,UAAU,QAAQ;CAEtB,IAAI,OAAO,cAAc,UACrB,UAAU,YAAY;CAE1B,OAAO;AACX;;AAGA,SAAgB,kBAAkB,OAAgB,WAAsC;CAEpF,QAD0B,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK,EAAA,CAE1D,KAAK,UAAU,iBAAiB,OAAO,SAAS,CAAC,CAAC,CAClD,QAAQ,cAA2C,cAAc,IAAI;AAC9E;;AAGA,SAAgB,aAAa,WAAoC;CAC7D,MAAM,SAAS,UAAU,OAAO;CAChC,OAAO,WAAW,aAAa,WAAW;AAC9C;;;;;AAMA,SAAgB,WACZ,YACA,UACsC;CACtC,MAAM,aAAa,YAAY,aAAa,CAAA,EAAA,CAAI,QAC3C,cAAc,UAAU,SAAS,OACtC;CACA,IAAI,aAAa,KAAA,GACb,OAAO,UAAU,MAAM,cAAc,UAAU,OAAO,QAAQ,KAAK;CAEvE,OAAO,UAAU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UACb,SAAO,MAAQ,MAAK,YAApB;GAAmC;GAAA,QAErC,UAAU,KAAK;GAAC,SACf,WAAW,KAAK;GAAC,GACtB,YAAY,OAAZ,EAAA,SAA8B,KAAU,IAAxC,CAAwC;EAChD;EACmB,KAAA,kBAAkB,OAAO,SAAS;EAAC,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA;EAAA,SAAA,EAAA;EAAA,KAAA,EAAA;CAAA;CAAtD,MAAA,aAAmB;CAAoC,IAAA;CAAA,IAAA,EAAA,OAAA,UAAA,EAAA,OAAA,MAAA,YAAA,EAAA,OAAA,YAAA,EAAA,OAAA,YAAA;EAChD,KAAA,MAAK,aAAc,OACtB,oBAAC,YAAD;GAAW,GAAK;GAAQ,UAAA;GAAgBF,OAAA;GAAsB;EAAQ,CAAA,IAEtE,oBAAC,YAAD;GAAW,GAAK;GAAe,OAAA,WAAU,MAAV;GAAiC;EAAQ,CAAA;EAC3E,EAAA,KAAA;EAAA,EAAA,KAAA,MAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,MAAA;CAAA,OAAA,KAAA,EAAA;CAAA,OAJM;AAIN"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import "./MediaField.css";
|
|
2
|
+
//#region src/MediaField.module.css
|
|
3
|
+
var field = "panneau-media-field-field";
|
|
4
|
+
var media = "panneau-media-field-media";
|
|
5
|
+
var item = "panneau-media-field-item";
|
|
6
|
+
var thumbnail = "panneau-media-field-thumbnail";
|
|
7
|
+
var details = "panneau-media-field-details";
|
|
8
|
+
var name = "panneau-media-field-name";
|
|
9
|
+
var meta = "panneau-media-field-meta";
|
|
10
|
+
var none = "panneau-media-field-none";
|
|
11
|
+
var MediaField_module_default = {
|
|
12
|
+
field,
|
|
13
|
+
media,
|
|
14
|
+
item,
|
|
15
|
+
thumbnail,
|
|
16
|
+
details,
|
|
17
|
+
name,
|
|
18
|
+
meta,
|
|
19
|
+
none
|
|
20
|
+
};
|
|
21
|
+
//#endregion
|
|
22
|
+
export { MediaField_module_default as default, details, field, item, media, meta, name, none, thumbnail };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=MediaField.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MediaField.module.js","names":[],"sources":["../src/MediaField.module.css"],"sourcesContent":[".field {\n display: grid;\n gap: var(--panneau-space-2);\n}\n\n.media {\n display: grid;\n gap: var(--panneau-space-2);\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.item {\n display: grid;\n grid-template-columns: 3rem minmax(0, 1fr) auto;\n align-items: center;\n gap: var(--panneau-space-2);\n padding: var(--panneau-space-1);\n background-color: var(--panneau-color-surface-sunken);\n border: var(--panneau-border-width) solid var(--panneau-color-border);\n border-radius: var(--panneau-radius-md);\n}\n\n.thumbnail {\n display: grid;\n place-items: center;\n width: 3rem;\n height: 3rem;\n overflow: hidden;\n color: var(--panneau-color-text-muted);\n background-color: var(--panneau-color-surface);\n border-radius: var(--panneau-radius-sm);\n}\n\n.thumbnail img {\n width: 100%;\n height: 100%;\n object-fit: cover;\n}\n\n.details {\n display: grid;\n gap: var(--panneau-space-1);\n min-width: 0;\n}\n\n.name {\n overflow: hidden;\n font-size: var(--panneau-font-size-sm);\n font-weight: var(--panneau-font-weight-medium);\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.meta {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--panneau-space-2);\n font-size: var(--panneau-font-size-sm);\n color: var(--panneau-color-text-muted);\n}\n\n.none {\n font-size: var(--panneau-font-size-md);\n color: var(--panneau-color-text-muted);\n}\n"],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { MediaField, type MediaAdapter, type MediaFieldBaseProps, MediaFieldEntry, type MediaFieldProps, type MultipleMediaFieldProps, type SingleMediaFieldProps, getLibrary, isProcessing, toMediaReference, toMediaReferences, } from './MediaField';
|
|
2
|
+
export { mediaPlugin } from './plugin';
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,EACV,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,eAAe,EACf,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { MediaField, MediaFieldEntry, getLibrary, isProcessing, toMediaReference, toMediaReferences } from "./MediaField.js";
|
|
2
|
+
import { mediaPlugin } from "./plugin.js";
|
|
3
|
+
export { MediaField, MediaFieldEntry, getLibrary, isProcessing, mediaPlugin, toMediaReference, toMediaReferences };
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FieldEntry } from '@panneau/fields';
|
|
2
|
+
/**
|
|
3
|
+
* The `media` field type as a `@panneau/core` plugin. Pass it after `fieldsPlugin`:
|
|
4
|
+
* `createPanneauApp({ plugins: [mediaPlugin] })`. The field makes media through the adapter of
|
|
5
|
+
* `@panneau/data`, and uploads through the upload source of the fields context.
|
|
6
|
+
*/
|
|
7
|
+
export declare const mediaPlugin: {
|
|
8
|
+
id: string;
|
|
9
|
+
fields: Readonly<Record<string, FieldEntry>>;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAIlD;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;CAIhD,CAAC"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { MediaFieldEntry } from "./MediaField.js";
|
|
2
|
+
//#region src/plugin.ts
|
|
3
|
+
/**
|
|
4
|
+
* The `media` field type as a `@panneau/core` plugin. Pass it after `fieldsPlugin`:
|
|
5
|
+
* `createPanneauApp({ plugins: [mediaPlugin] })`. The field makes media through the adapter of
|
|
6
|
+
* `@panneau/data`, and uploads through the upload source of the fields context.
|
|
7
|
+
*/
|
|
8
|
+
var mediaPlugin = {
|
|
9
|
+
id: "panneau-media",
|
|
10
|
+
fields: { media: MediaFieldEntry }
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { mediaPlugin };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import type { FieldEntry } from '@panneau/fields';\n\nimport { MediaFieldEntry } from './MediaField';\n\n/**\n * The `media` field type as a `@panneau/core` plugin. Pass it after `fieldsPlugin`:\n * `createPanneauApp({ plugins: [mediaPlugin] })`. The field makes media through the adapter of\n * `@panneau/data`, and uploads through the upload source of the fields context.\n */\nexport const mediaPlugin: {\n id: string;\n fields: Readonly<Record<string, FieldEntry>>;\n} = {\n id: 'panneau-media',\n fields: { media: MediaFieldEntry },\n};\n"],"mappings":";;;;;;;AASA,IAAa,cAGT;CACA,IAAI;CACJ,QAAQ,EAAE,OAAO,gBAAgB;AACrC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,48 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@panneau/media",
|
|
3
|
+
"version": "5.0.0-alpha.4",
|
|
4
|
+
"description": "The media of Panneau: the media field, which makes media of uploads and follows their ingest.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/folkloreinc/panneau-js.git",
|
|
10
|
+
"directory": "packages/media"
|
|
11
|
+
},
|
|
12
|
+
"sideEffects": [
|
|
13
|
+
"*.css"
|
|
14
|
+
],
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"@panneau/source": "./src/index.ts",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"default": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "vite build && tsc -p tsconfig.build.json",
|
|
28
|
+
"typecheck": "tsc --noEmit",
|
|
29
|
+
"api": "tsc -p tsconfig.build.json && node ../../scripts/api-report.js"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@tanstack/react-query": "^5.0.0",
|
|
36
|
+
"react": "^19.2.0",
|
|
37
|
+
"react-intl": "^12.0.0"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@panneau/core": "5.0.0-alpha.4",
|
|
41
|
+
"@panneau/data": "5.0.0-alpha.4",
|
|
42
|
+
"@panneau/fields": "5.0.0-alpha.4",
|
|
43
|
+
"@panneau/intl": "5.0.0-alpha.4",
|
|
44
|
+
"@panneau/protocol": "5.0.0-alpha.4",
|
|
45
|
+
"@panneau/ui": "5.0.0-alpha.4",
|
|
46
|
+
"lucide-react": "^1.57.0"
|
|
47
|
+
}
|
|
48
|
+
}
|