@panneau/media 5.0.0-alpha.33 → 5.0.0-alpha.34

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 CHANGED
@@ -9,7 +9,7 @@ npm install @panneau/media@^5.0.0-alpha.0 @tanstack/react-query react-aria-compo
9
9
  | Export | Content |
10
10
  | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
11
11
  | `@panneau/media` | `MediaField`, `ImageField`, `MediaFieldEntry`, `mediaPlugin`, `getImageOptions()`, `createResourceMediaSource()`, `getLibrary()`, `toMediaReference()`, `toMediaReferences()`, `isProcessing()` |
12
- | `@panneau/media/picker` | `MediaPicker`, and the types of its sources: `MediaSource`, `MediaQuery`, `MediaPage`, `PickerMedia`, `MediaSort` |
12
+ | `@panneau/media/picker` | `MediaPicker`, `MediaLibrary`, and the types of its sources: `MediaSource`, `MediaQuery`, `MediaPage`, `PickerMedia`, `MediaSort` |
13
13
  | `@panneau/media/editor` | `ImageEditor`, `ImageEditorDialog`, `useImageEditorTools()`, and the types of the editor and its tools: `EditedImage`, `ImageEditorTool`, `ImageEditorToolContext` |
14
14
 
15
15
  ## The media field
@@ -82,6 +82,16 @@ const sources = definition.resources
82
82
  />;
83
83
  ```
84
84
 
85
+ ## The media library
86
+
87
+ `MediaLibrary` (`@panneau/media/picker`, [decision 0080](../../docs/decisions/0080-a-media-library-page.md)) is the same library as a page: the same sources, search, filters, sorts, upload and details as `MediaPicker`, without the dialog and without picking. A click on a media opens its details, where its fields are edited; the grid scrolls with the page and the details stay in view. It takes the options of the picker that are about the library (`sources`, `source`, `accept`, `maxSize`, `filter`, `filters`, `sorts`, `sort`, `stateKey`, `uploadSource`, `refreshInterval`), plus `aria-label` and `className`.
88
+
89
+ ```tsx
90
+ import { MediaLibrary } from '@panneau/media/picker';
91
+
92
+ <MediaLibrary sources={sources} stateKey="media-page" />;
93
+ ```
94
+
85
95
  ## The image editor
86
96
 
87
97
  `ImageEditor` (`@panneau/media/editor`, [decision 0031](../../docs/decisions/0031-image-editor-and-image-field.md)) edits a transform of an image (the protocol's `MediaTransform`): the image as it will be rendered, the overlay of a tool over it, the tool's options on the side, and the result. This entry point only imports `@panneau/ui`, `@panneau/intl` and the runtime of `@panneau/protocol`.
@@ -0,0 +1,9 @@
1
+ import type { MediaLibraryProps } from './types.js';
2
+ /**
3
+ * The library of the picker in a page (decision 0080): the libraries given as sources, their
4
+ * search, type filter, sorts and filters, the details of the media chosen, which edit the
5
+ * source's `fields`, and the uploads, with nothing to pick. Its grid scrolls with the page, and
6
+ * its details stay in view beside it. `MediaPicker` is the same library in a dialog that picks.
7
+ */
8
+ export declare function MediaLibrary({ 'aria-label': ariaLabel, className, ...options }: MediaLibraryProps): import("react").JSX.Element | null;
9
+ //# sourceMappingURL=MediaLibrary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MediaLibrary.d.ts","sourceRoot":"","sources":["../../src/picker/MediaLibrary.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAGjD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,EACzB,YAAY,EAAE,SAAS,EACvB,SAAS,EACT,GAAG,OAAO,EACb,EAAE,iBAAiB,sCAiBnB"}
@@ -0,0 +1,80 @@
1
+ import MediaPicker_module_default from "./MediaPicker.module.js";
2
+ import { useMediaLibrary } from "./useMediaLibrary.js";
3
+ import { c } from "react/compiler-runtime";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ //#region src/picker/MediaLibrary.tsx
6
+ /**
7
+ * The library of the picker in a page (decision 0080): the libraries given as sources, their
8
+ * search, type filter, sorts and filters, the details of the media chosen, which edit the
9
+ * source's `fields`, and the uploads, with nothing to pick. Its grid scrolls with the page, and
10
+ * its details stay in view beside it. `MediaPicker` is the same library in a dialog that picks.
11
+ */
12
+ function MediaLibrary(t0) {
13
+ const $ = c(16);
14
+ let ariaLabel;
15
+ let className;
16
+ let options;
17
+ if ($[0] !== t0) {
18
+ ({"aria-label": ariaLabel, className, ...options} = t0);
19
+ $[0] = t0;
20
+ $[1] = ariaLabel;
21
+ $[2] = className;
22
+ $[3] = options;
23
+ } else {
24
+ ariaLabel = $[1];
25
+ className = $[2];
26
+ options = $[3];
27
+ }
28
+ let t1;
29
+ if ($[4] !== options) {
30
+ t1 = {
31
+ ...options,
32
+ selectable: false,
33
+ scroll: "page"
34
+ };
35
+ $[4] = options;
36
+ $[5] = t1;
37
+ } else t1 = $[5];
38
+ const library = useMediaLibrary(t1);
39
+ if (library.source === null) return null;
40
+ const t2 = ariaLabel ?? library.source.label;
41
+ let t3;
42
+ if ($[6] !== className) {
43
+ t3 = [MediaPicker_module_default.library, className].filter(Boolean);
44
+ $[6] = className;
45
+ $[7] = t3;
46
+ } else t3 = $[7];
47
+ const t4 = t3.join(" ");
48
+ let t5;
49
+ if ($[8] !== library.switcher) {
50
+ t5 = library.switcher !== null ? /* @__PURE__ */ jsx("div", {
51
+ className: MediaPicker_module_default.libraryHeader,
52
+ children: library.switcher
53
+ }) : null;
54
+ $[8] = library.switcher;
55
+ $[9] = t5;
56
+ } else t5 = $[9];
57
+ let t6;
58
+ if ($[10] !== library.tabs || $[11] !== library.unsaved || $[12] !== t2 || $[13] !== t4 || $[14] !== t5) {
59
+ t6 = /* @__PURE__ */ jsxs("section", {
60
+ "aria-label": t2,
61
+ className: t4,
62
+ children: [
63
+ t5,
64
+ library.tabs,
65
+ library.unsaved
66
+ ]
67
+ });
68
+ $[10] = library.tabs;
69
+ $[11] = library.unsaved;
70
+ $[12] = t2;
71
+ $[13] = t4;
72
+ $[14] = t5;
73
+ $[15] = t6;
74
+ } else t6 = $[15];
75
+ return t6;
76
+ }
77
+ //#endregion
78
+ export { MediaLibrary };
79
+
80
+ //# sourceMappingURL=MediaLibrary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MediaLibrary.js","names":["styles","MediaLibraryProps","useMediaLibrary","MediaLibrary","t0","$","_c","ariaLabel","className","options","t1","selectable","scroll","library","source","t2","label","t3","filter","Boolean","t4","join","t5","switcher","libraryHeader","t6","tabs","unsaved","_c","styles"],"sources":["../../src/picker/MediaLibrary.tsx"],"sourcesContent":["import styles from './MediaPicker.module.css';\nimport type { MediaLibraryProps } from './types';\nimport { useMediaLibrary } from './useMediaLibrary';\n\n/**\n * The library of the picker in a page (decision 0080): the libraries given as sources, their\n * search, type filter, sorts and filters, the details of the media chosen, which edit the\n * source's `fields`, and the uploads, with nothing to pick. Its grid scrolls with the page, and\n * its details stay in view beside it. `MediaPicker` is the same library in a dialog that picks.\n */\nexport function MediaLibrary({\n 'aria-label': ariaLabel,\n className,\n ...options\n}: MediaLibraryProps) {\n const library = useMediaLibrary({ ...options, selectable: false, scroll: 'page' });\n if (library.source === null) {\n return null;\n }\n return (\n <section\n aria-label={ariaLabel ?? library.source.label}\n className={[styles.library, className].filter(Boolean).join(' ')}\n >\n {library.switcher !== null ? (\n <div className={styles.libraryHeader}>{library.switcher}</div>\n ) : null}\n {library.tabs}\n {library.unsaved}\n </section>\n );\n}\n"],"mappings":";;;;;;;;;;;AAUA,SAAOG,aAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAJ,EAAA,OAAAD,IAAA;EAAsB,CAAA,CAAA,cAAAG,WAAAC,WAAA,GAAAC,WAAAL;EAITC,EAAA,KAAAD;EAAAC,EAAA,KAAAE;EAAAF,EAAA,KAAAG;EAAAH,EAAA,KAAAI;CAAA,OAAA;EAAAF,YAAAF,EAAA;EAAAG,YAAAH,EAAA;EAAAI,UAAAJ,EAAA;CAAA;CAAA,IAAAK;CAAA,IAAAL,EAAA,OAAAI,SAAA;EACgBC,KAAA;GAAA,GAAKD;GAAOE,YAAc;GAAKC,QAAU;EAAO;EAACP,EAAA,KAAAI;EAAAJ,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAjF,MAAAQ,UAAgBX,gBAAgBQ,EAAiD;CACjF,IAAIG,QAAOC,WAAY,MAAI,OAChB;CAIS,MAAAC,KAAAR,aAAaM,QAAOC,OAAOE;CAAM,IAAAC;CAAA,IAAAZ,EAAA,OAAAG,WAAA;EAClCS,KAAA,CAACjB,2BAAMa,SAAUL,SAAS,CAAC,CAAAU,OAAQC,OAAO;EAACd,EAAA,KAAAG;EAAAH,EAAA,KAAAY;CAAA,OAAAA,KAAAZ,EAAA;CAA3C,MAAAe,KAAAH,GAA2CI,KAAM,GAAG;CAAC,IAAAC;CAAA,IAAAjB,EAAA,OAAAQ,QAAAU,UAAA;EAE/DD,KAAAT,QAAOU,aAAc,OAClB,oBAAA,OAAA;GAAgB,WAAAvB,2BAAMwB;GAAiBX,UAAAA,QAAOU;EAAgB,CAAA,IADjE;EAEOlB,EAAA,KAAAQ,QAAAU;EAAAlB,EAAA,KAAAiB;CAAA,OAAAA,KAAAjB,EAAA;CAAA,IAAAoB;CAAA,IAAApB,EAAA,QAAAQ,QAAAa,QAAArB,EAAA,QAAAQ,QAAAc,WAAAtB,EAAA,QAAAU,MAAAV,EAAA,QAAAe,MAAAf,EAAA,QAAAiB,IAAA;EANZG,KAAA,qBAAA,WAAA;GACgB,cAAAV;GACD,WAAAK;GAFf,UAAA;IAIKE;IAGAT,QAAOa;IACPb,QAAOc;GACF;;EAAAtB,EAAA,MAAAQ,QAAAa;EAAArB,EAAA,MAAAQ,QAAAc;EAAAtB,EAAA,MAAAU;EAAAV,EAAA,MAAAe;EAAAf,EAAA,MAAAiB;EAAAjB,EAAA,MAAAoB;CAAA,OAAAA,KAAApB,EAAA;CAAA,OATVoB;AASU"}
@@ -13,6 +13,34 @@
13
13
  height: min(46rem, calc(100dvh - 2 * var(--panneau-space-4)));
14
14
  }
15
15
 
16
+ /* The library in a page (MediaLibrary, decision 0080): the grid scrolls with the page, and the
17
+ details stay in view beside it. */
18
+ .panneau-media-picker-library {
19
+ --media-picker-card-size: var(
20
+ --panneau-media-picker-card-size,
21
+ calc(var(--panneau-control-height) * 5 - 1.75rem)
22
+ );
23
+
24
+ display: flex;
25
+ flex-direction: column;
26
+ gap: var(--panneau-space-3);
27
+ }
28
+
29
+ .panneau-media-picker-library-header {
30
+ display: flex;
31
+ justify-content: flex-start;
32
+ }
33
+
34
+ .panneau-media-picker-library .panneau-media-picker-scroll {
35
+ overflow-y: visible;
36
+ }
37
+
38
+ .panneau-media-picker-library .panneau-media-picker-details {
39
+ position: sticky;
40
+ top: var(--panneau-space-4);
41
+ max-height: calc(100dvh - 2 * var(--panneau-space-4));
42
+ }
43
+
16
44
  .panneau-media-picker-body {
17
45
  display: flex;
18
46
  flex-direction: column;
@@ -541,6 +569,13 @@
541
569
 
542
570
  /* Phones: a full-screen sheet with two or three media a row, and no Cancel button. */
543
571
  @media (max-width: 30rem) {
572
+ .panneau-media-picker-library {
573
+ --media-picker-card-size: var(
574
+ --panneau-media-picker-card-size-sm,
575
+ calc(var(--panneau-control-height) * 2.5)
576
+ );
577
+ }
578
+
544
579
  .panneau-media-picker-dialog {
545
580
  --media-picker-card-size: var(
546
581
  --panneau-media-picker-card-size-sm,
@@ -3,7 +3,7 @@ import type { MediaPickerProps } from './types.js';
3
3
  * The media picker (decision 0027): browse the libraries given as sources, upload to them, and
4
4
  * pick one media, or several with `multiple`. It returns references with their library
5
5
  * (`resource`). The `media` field opens it, and so can a product's own screens, with their
6
- * sources, title and button.
6
+ * sources, title and button. Its library is `MediaLibrary`'s, in a dialog.
7
7
  */
8
8
  export declare function MediaPicker(props: MediaPickerProps): import("react").JSX.Element | null;
9
9
  //# sourceMappingURL=MediaPicker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MediaPicker.d.ts","sourceRoot":"","sources":["../../src/picker/MediaPicker.tsx"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,gBAAgB,EAAuC,MAAM,SAAS,CAAC;AA2CrF;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,sCAOlD"}
1
+ {"version":3,"file":"MediaPicker.d.ts","sourceRoot":"","sources":["../../src/picker/MediaPicker.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAGhD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,sCAOlD"}