@webx-ui/module-media 0.5.0 → 0.6.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/README.md CHANGED
@@ -56,6 +56,23 @@ file** — one picture used by two articles needs two captions. The address is w
56
56
  `path` when the page is drawn, so the library can move to another disk without touching a single
57
57
  article.
58
58
 
59
+ Four fields in all, which are also the four types a [described screen](https://webx-ui.github.io/webx-ui/guide/screens)
60
+ may use — the server half registers the same names for storing them:
61
+
62
+ | Export | Screen type | Value | What it draws |
63
+ | ---------------- | ------------ | -------------------- | -------------------------------- |
64
+ | `WxMediaField` | `wx-media` | `MediaValue \| null` | one picture in a frame |
65
+ | `WxGalleryField` | `wx-gallery` | `MediaValue[]` | a grid of thumbnails, in order |
66
+ | `WxFileField` | `wx-file` | `MediaValue \| null` | one file card: glyph, name, size |
67
+ | `WxFilesField` | `wx-files` | `MediaValue[]` | those cards a line each |
68
+
69
+ Three names rather than `wx-media` with `multiple`, because the type is what an author picks from
70
+ a list: nobody picks "media with `multiple: true` and `accept: document`", they pick "Files".
71
+ Underneath there is one component and one set of rules.
72
+
73
+ `openMediaFiles({ accept: 'image', max: 10 })` is the dialog those lists open — the same library
74
+ with multiple selection on, resolving with `MediaFile[]`.
75
+
59
76
  ## What it draws
60
77
 
61
78
  `WxMediaManager` is the section itself: a folder tree, a grid of cards with rubber-band
@@ -0,0 +1,10 @@
1
+ import { MediaValue } from './types';
2
+ type __VLS_PublicProps = {
3
+ modelValue?: MediaValue | null;
4
+ };
5
+ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
6
+ "update:modelValue": (value: MediaValue | null) => any;
7
+ }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
8
+ "onUpdate:modelValue"?: ((value: MediaValue | null) => any) | undefined;
9
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
10
+ export default _default;
@@ -0,0 +1,10 @@
1
+ import { MediaValue } from './types';
2
+ type __VLS_PublicProps = {
3
+ modelValue?: MediaValue[];
4
+ };
5
+ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
6
+ "update:modelValue": (value: MediaValue[]) => any;
7
+ }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
8
+ "onUpdate:modelValue"?: ((value: MediaValue[]) => any) | undefined;
9
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
10
+ export default _default;
@@ -0,0 +1,10 @@
1
+ import { MediaValue } from './types';
2
+ type __VLS_PublicProps = {
3
+ modelValue?: MediaValue[];
4
+ };
5
+ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
6
+ "update:modelValue": (value: MediaValue[]) => any;
7
+ }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
8
+ "onUpdate:modelValue"?: ((value: MediaValue[]) => any) | undefined;
9
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
10
+ export default _default;
@@ -0,0 +1,51 @@
1
+ import { MediaAspect, MediaKind, MediaValue } from './types';
2
+ /**
3
+ * Several files on a form, in an order somebody chose.
4
+ *
5
+ * One component under `wx-gallery`, `wx-file` and `wx-files`: what differs between them is a
6
+ * layout and a limit, and everything else — picking, ordering, captions, the card of a file
7
+ * that is no longer there — is the same work. The three names exist for the person choosing a
8
+ * field type, not for the code.
9
+ *
10
+ * What is stored is `{ path, alt?, title? }` per item and the order they are in. Everything
11
+ * else on screen — the preview, the name, the size — is asked of the library on every read,
12
+ * because the address of a file is not a thing worth writing into a thousand records.
13
+ */
14
+ type __VLS_Props = {
15
+ label?: string;
16
+ /** Cards side by side for pictures, a line each for documents. */
17
+ layout?: 'grid' | 'rows';
18
+ /** Narrow what the library offers. The server checks the same thing on the way in. */
19
+ accept?: MediaKind | null;
20
+ /** Off where a caption is noise — a row of logos, a set of downloads. */
21
+ captions?: boolean;
22
+ max?: number | null;
23
+ min?: number | null;
24
+ /** A fixed number of columns instead of as many as fit. */
25
+ columns?: number | null;
26
+ /** Shape of a thumbnail in the grid: a preset, or anything CSS reads as a ratio. */
27
+ aspect?: MediaAspect | null;
28
+ /** One file, kept as a list of one — what `wx-file` is. */
29
+ single?: boolean;
30
+ disabled?: boolean;
31
+ };
32
+ type __VLS_PublicProps = {
33
+ modelValue?: MediaValue[];
34
+ } & __VLS_Props;
35
+ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
36
+ "update:modelValue": (value: MediaValue[]) => any;
37
+ }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
38
+ "onUpdate:modelValue"?: ((value: MediaValue[]) => any) | undefined;
39
+ }>, {
40
+ label: string;
41
+ single: boolean;
42
+ disabled: boolean;
43
+ captions: boolean;
44
+ accept: MediaKind | null;
45
+ max: number | null;
46
+ layout: "grid" | "rows";
47
+ min: number | null;
48
+ columns: number | null;
49
+ aspect: MediaAspect | null;
50
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
51
+ export default _default;
@@ -14,14 +14,28 @@ type __VLS_Props = {
14
14
  picking?: boolean;
15
15
  /** Only these kinds can be chosen, when picking. */
16
16
  accept?: MediaKind | null;
17
+ /**
18
+ * A picker that takes several files at once.
19
+ *
20
+ * What this switches on is the selection the manager already has for its batch operations:
21
+ * the rubber band, the tap that toggles, the run held with shift. A picker with a way of
22
+ * marking files of its own would be a second thing to learn for the very same job.
23
+ */
24
+ multiple?: boolean;
25
+ /** The most that may be held at once, when picking several. */
26
+ max?: number | null;
17
27
  };
18
28
  declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
19
29
  pick: (file: MediaFile) => any;
30
+ selection: (files: MediaFile[]) => any;
20
31
  }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
21
32
  onPick?: ((file: MediaFile) => any) | undefined;
33
+ onSelection?: ((files: MediaFile[]) => any) | undefined;
22
34
  }>, {
23
- picking: boolean;
35
+ multiple: boolean;
24
36
  accept: MediaKind | null;
37
+ picking: boolean;
38
+ max: number | null;
25
39
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
26
40
  root: HTMLDivElement;
27
41
  picker: HTMLInputElement;
@@ -10,10 +10,16 @@ type __VLS_Props = {
10
10
  title?: string;
11
11
  /** Opened to manage the library rather than to choose from it. */
12
12
  manage?: boolean;
13
+ /** Several files at once, handed back as a list. */
14
+ multiple?: boolean;
15
+ /** The most that may be chosen, when choosing several. */
16
+ max?: number | null;
13
17
  };
14
18
  declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
15
19
  title: string;
20
+ multiple: boolean;
16
21
  accept: MediaKind | null;
22
+ max: number | null;
17
23
  manage: boolean;
18
24
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
19
25
  export default _default;
@@ -0,0 +1,4 @@
1
+ /** Bytes as somebody would say them: 32 MB, not 33 554 432. */
2
+ export declare function readable(bytes: number): string;
3
+ /** The file name out of a stored key, for a file the library can no longer be asked about. */
4
+ export declare function nameFromPath(path: string): string;
package/dist/index.d.ts CHANGED
@@ -14,9 +14,12 @@ export interface MediaOptions {
14
14
  export declare function media(options?: MediaOptions): AdminModule;
15
15
  export { mediaMessages };
16
16
  export { createMediaApi, type MediaApi } from './api';
17
- export { openMediaLibrary, openMediaPicker, type MediaPickerOptions } from './openMediaPicker';
17
+ export { openMediaFiles, openMediaLibrary, openMediaPicker, type MediaFilesOptions, type MediaPickerOptions, } from './openMediaPicker';
18
18
  export { default as WxMediaManager } from './MediaManager';
19
19
  export { default as WxMediaPage } from './MediaPage';
20
20
  export { default as WxMediaPicker } from './MediaPicker';
21
21
  export { default as WxMediaField } from './MediaField';
22
+ export { default as WxGalleryField } from './GalleryField';
23
+ export { default as WxFileField } from './FileField';
24
+ export { default as WxFilesField } from './FilesField';
22
25
  export type { DirectoryNotEmpty, EditOperations, FileQuery, MediaDirectory, MediaFile, MediaAspect, MediaKind, MediaPage, MediaValue, } from './types';