@phis/ui 0.7.3 → 0.7.5
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/components/controls/phi-form-control.js +1 -0
- package/components/controls/phi-media-asset-tile-control.d.ts +4 -3
- package/components/controls/phi-media-picker-control.d.ts +9 -11
- package/components/controls/phi-media-picker-control.js +9 -11
- package/components/controls/phi-options-provider.d.ts +14 -1
- package/components/controls/phi-options-provider.js +73 -2
- package/components/forms/form-field-labels.d.ts +3 -3
- package/components/forms/form-field-labels.js +13 -5
- package/components/forms/media-asset-field-keys.d.ts +9 -1
- package/components/forms/media-asset-field-keys.js +13 -1
- package/components/media/label-sets/media.js +4 -0
- package/components/media/media-folder-name-path.d.ts +14 -0
- package/components/media/media-folder-name-path.js +40 -2
- package/components/media/media-library-resource.d.ts +70 -0
- package/components/media/media-library-resource.js +41 -0
- package/components/media/media-widget-labels.d.ts +13 -0
- package/components/media/media-widget-labels.js +2 -0
- package/components/media/phi-area-upload-widget.d.ts +31 -1
- package/components/media/phi-area-upload-widget.js +33 -7
- package/components/media/phi-image-preview-data.d.ts +8 -1
- package/components/media/phi-image-preview-data.js +29 -0
- package/components/media/phi-media-picker-binding.d.ts +22 -20
- package/components/media/phi-media-picker-binding.js +20 -33
- package/components/media/use-media-library-add-picker.d.ts +94 -0
- package/components/media/use-media-library-add-picker.js +40 -0
- package/components/widgets/client/shared/phi-choice-controller.js +22 -15
- package/constants/media-library-provider-keys.d.ts +7 -0
- package/constants/media-library-provider-keys.js +7 -0
- package/constants/runtime-module-ownership.js +1 -0
- package/helpers/preset-tree-contract-check.d.ts +35 -0
- package/helpers/preset-tree-contract-check.js +211 -0
- package/module-page-check.d.ts +6 -0
- package/module-page-check.js +6 -0
- package/package.json +1 -1
- package/plugins/runtime-modules/asset/data-providers.d.ts +56 -38
- package/plugins/runtime-modules/asset/data-providers.js +4 -32
- package/plugins/runtime-modules/asset/definition.d.ts +115 -38
- package/plugins/runtime-modules/asset/definition.js +2 -1
- package/plugins/runtime-modules/asset/form-providers.d.ts +85 -2
- package/plugins/runtime-modules/asset/form-providers.js +70 -11
- package/plugins/runtime-modules/asset/form-ui-provider.js +7 -1
- package/plugins/runtime-modules/asset/media-asset-field.d.ts +7 -7
- package/plugins/runtime-modules/asset/media-asset-field.js +11 -33
- package/plugins/runtime-modules/asset/media-asset-form-control.d.ts +8 -7
- package/plugins/runtime-modules/asset/media-asset-form-control.js +42 -83
- package/plugins/runtime-modules/asset/media-assets-field.d.ts +37 -0
- package/plugins/runtime-modules/asset/media-assets-field.js +81 -0
- package/plugins/runtime-modules/asset/media-assets-form-control.d.ts +27 -0
- package/plugins/runtime-modules/asset/media-assets-form-control.js +182 -0
- package/plugins/runtime-modules/asset/media-field-picker-labels.d.ts +9 -0
- package/plugins/runtime-modules/asset/media-field-picker-labels.js +49 -0
- package/plugins/runtime-modules/asset/services/collection.js +12 -0
- package/plugins/runtime-modules/builder/clients/inspector-config-field.js +11 -6
- package/plugins/runtime-modules/core/widgets/cascader/client.js +13 -12
- package/plugins/runtime-modules/core/widgets/checkbox-group/client.js +5 -4
- package/plugins/runtime-modules/core/widgets/collection-view/asset-binding-tools.d.ts +24 -0
- package/plugins/runtime-modules/core/widgets/collection-view/asset-binding-tools.js +55 -0
- package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.d.ts +26 -2
- package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.js +125 -32
- package/plugins/runtime-modules/core/widgets/collection-view/client.d.ts +7 -2
- package/plugins/runtime-modules/core/widgets/collection-view/client.js +12 -4
- package/plugins/runtime-modules/core/widgets/collection-view/config.d.ts +25 -0
- package/plugins/runtime-modules/core/widgets/collection-view/config.js +34 -0
- package/plugins/runtime-modules/core/widgets/collection-view/image-preview-grid.js +4 -1
- package/plugins/runtime-modules/core/widgets/collection-view/server.d.ts +3 -2
- package/plugins/runtime-modules/core/widgets/collection-view/server.js +20 -18
- package/plugins/runtime-modules/core/widgets/multi-select/client.js +6 -4
- package/plugins/runtime-modules/descriptor-compiler.d.ts +4 -0
- package/plugins/runtime-modules/descriptor-compiler.js +9 -204
- package/plugins/runtime-modules/resolver.js +31 -5
- package/types/collection-view-widget.d.ts +19 -0
- package/types/core-widget-placements.d.ts +9 -0
- package/types/media.d.ts +16 -0
|
@@ -50,45 +50,63 @@ export declare const PHI_ASSET_RUNTIME_MODULE_DEFINITION: {
|
|
|
50
50
|
description: string;
|
|
51
51
|
availableToAuthoringChrome: true;
|
|
52
52
|
resources: {
|
|
53
|
-
resourceKey:
|
|
54
|
-
title:
|
|
55
|
-
itemIdentityPath:
|
|
56
|
-
itemRendererKey: `${string}/${string}`;
|
|
57
|
-
selectionValueSchema: `${string}/signals/${string}`;
|
|
58
|
-
defaultForWidget: true;
|
|
59
|
-
query: {
|
|
60
|
-
search: true;
|
|
61
|
-
pagination: true;
|
|
62
|
-
filterFields:
|
|
63
|
-
key:
|
|
64
|
-
title:
|
|
65
|
-
type: "enum[]";
|
|
66
|
-
}
|
|
67
|
-
key:
|
|
68
|
-
title:
|
|
69
|
-
type: "
|
|
70
|
-
}
|
|
53
|
+
readonly resourceKey: "assets";
|
|
54
|
+
readonly title: "Assets";
|
|
55
|
+
readonly itemIdentityPath: "id";
|
|
56
|
+
readonly itemRendererKey: `${string}/${string}`;
|
|
57
|
+
readonly selectionValueSchema: `${string}/signals/${string}`;
|
|
58
|
+
readonly defaultForWidget: true;
|
|
59
|
+
readonly query: {
|
|
60
|
+
readonly search: true;
|
|
61
|
+
readonly pagination: true;
|
|
62
|
+
readonly filterFields: readonly [{
|
|
63
|
+
readonly key: "kind";
|
|
64
|
+
readonly title: "Kind";
|
|
65
|
+
readonly type: "enum[]";
|
|
66
|
+
}, {
|
|
67
|
+
readonly key: "presentationFlags";
|
|
68
|
+
readonly title: "Flags";
|
|
69
|
+
readonly type: "enum[]";
|
|
70
|
+
}, {
|
|
71
|
+
readonly key: "folderId";
|
|
72
|
+
readonly title: "Folder";
|
|
73
|
+
readonly type: "path";
|
|
74
|
+
}];
|
|
71
75
|
};
|
|
72
|
-
actions:
|
|
73
|
-
key:
|
|
74
|
-
title:
|
|
75
|
-
scope: "resource";
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
76
|
+
readonly actions: readonly [{
|
|
77
|
+
readonly key: "createFolder";
|
|
78
|
+
readonly title: "Create folder";
|
|
79
|
+
readonly scope: "resource";
|
|
80
|
+
}, {
|
|
81
|
+
readonly key: "lockFolder";
|
|
82
|
+
readonly title: "Lock folder";
|
|
83
|
+
readonly scope: "resource";
|
|
84
|
+
}, {
|
|
85
|
+
readonly key: "unlockFolder";
|
|
86
|
+
readonly title: "Unlock folder";
|
|
87
|
+
readonly scope: "resource";
|
|
88
|
+
}, {
|
|
89
|
+
readonly key: "upload";
|
|
90
|
+
readonly title: "Upload";
|
|
91
|
+
readonly scope: "resource";
|
|
92
|
+
readonly panelKey: "upload";
|
|
93
|
+
}, {
|
|
94
|
+
readonly key: "refresh";
|
|
95
|
+
readonly title: "Reload";
|
|
96
|
+
readonly scope: "resource";
|
|
97
|
+
}, {
|
|
98
|
+
readonly key: "update";
|
|
99
|
+
readonly title: "Update";
|
|
100
|
+
readonly scope: "item";
|
|
101
|
+
}, {
|
|
102
|
+
readonly key: "delete";
|
|
103
|
+
readonly title: "Delete";
|
|
104
|
+
readonly scope: "item";
|
|
105
|
+
}];
|
|
106
|
+
readonly panels: readonly [{
|
|
107
|
+
readonly key: "upload";
|
|
108
|
+
readonly title: "Upload assets";
|
|
109
|
+
}];
|
|
92
110
|
}[];
|
|
93
111
|
})[];
|
|
94
112
|
collectionItemRenderers: {
|
|
@@ -155,6 +173,65 @@ export declare const PHI_ASSET_RUNTIME_MODULE_DEFINITION: {
|
|
|
155
173
|
valueType?: undefined;
|
|
156
174
|
options?: undefined;
|
|
157
175
|
})[];
|
|
176
|
+
} | {
|
|
177
|
+
key: `${string}/${string}`;
|
|
178
|
+
ownerModuleId: "@phis/ui/modules/asset";
|
|
179
|
+
title: string;
|
|
180
|
+
description: string;
|
|
181
|
+
valueType: "json";
|
|
182
|
+
presentation: "control";
|
|
183
|
+
settingsFields: ({
|
|
184
|
+
key: string;
|
|
185
|
+
type: "choice";
|
|
186
|
+
mode: "single";
|
|
187
|
+
valueType: "string";
|
|
188
|
+
label: string;
|
|
189
|
+
description: string;
|
|
190
|
+
options: ({
|
|
191
|
+
value: "image";
|
|
192
|
+
label: string;
|
|
193
|
+
} | {
|
|
194
|
+
value: "video";
|
|
195
|
+
label: string;
|
|
196
|
+
} | {
|
|
197
|
+
value: "audio";
|
|
198
|
+
label: string;
|
|
199
|
+
} | {
|
|
200
|
+
value: "pdf";
|
|
201
|
+
label: string;
|
|
202
|
+
} | {
|
|
203
|
+
value: "markdown";
|
|
204
|
+
label: string;
|
|
205
|
+
} | {
|
|
206
|
+
value: "font";
|
|
207
|
+
label: string;
|
|
208
|
+
})[];
|
|
209
|
+
min?: undefined;
|
|
210
|
+
max?: undefined;
|
|
211
|
+
precision?: undefined;
|
|
212
|
+
} | {
|
|
213
|
+
key: string;
|
|
214
|
+
type: "string";
|
|
215
|
+
label: string;
|
|
216
|
+
description: string;
|
|
217
|
+
mode?: undefined;
|
|
218
|
+
valueType?: undefined;
|
|
219
|
+
options?: undefined;
|
|
220
|
+
min?: undefined;
|
|
221
|
+
max?: undefined;
|
|
222
|
+
precision?: undefined;
|
|
223
|
+
} | {
|
|
224
|
+
key: string;
|
|
225
|
+
type: "number";
|
|
226
|
+
label: string;
|
|
227
|
+
description: string;
|
|
228
|
+
min: number;
|
|
229
|
+
max: number;
|
|
230
|
+
precision: number;
|
|
231
|
+
mode?: undefined;
|
|
232
|
+
valueType?: undefined;
|
|
233
|
+
options?: undefined;
|
|
234
|
+
})[];
|
|
158
235
|
})[];
|
|
159
236
|
handlers: ({
|
|
160
237
|
key: `${string}/${string}`;
|
|
@@ -6,7 +6,7 @@ import { PHI_ASSET_RUNTIME_DATA_PROVIDER_DESCRIPTORS } from "./data-providers";
|
|
|
6
6
|
import { PHI_CMS_AREA_KEYS } from "../../../constants/cms-areas";
|
|
7
7
|
import { PHI_CORE_SERVER_BINDING } from "../../../types/server-capabilities";
|
|
8
8
|
import { PHI_ASSET_FOLDER_FORM_HANDLER_PROVIDER_DESCRIPTOR, PHI_ASSET_METADATA_FORM_HANDLER_PROVIDER_DESCRIPTOR, } from "./metadata-form";
|
|
9
|
-
import { PHI_ASSET_FOCAL_RECT_FORM_PROVIDER_DESCRIPTOR, PHI_ASSET_MEDIA_ASSET_FORM_PROVIDER_DESCRIPTOR, } from "./form-providers";
|
|
9
|
+
import { PHI_ASSET_FOCAL_RECT_FORM_PROVIDER_DESCRIPTOR, PHI_ASSET_MEDIA_ASSET_FORM_PROVIDER_DESCRIPTOR, PHI_ASSET_MEDIA_ASSETS_FORM_PROVIDER_DESCRIPTOR, } from "./form-providers";
|
|
10
10
|
import { PHI_MEDIA_SETTINGS_FORM_HANDLER_PROVIDER_DESCRIPTOR, PHI_MEDIA_STORAGE_SETTINGS_FORM_HANDLER_PROVIDER_DESCRIPTOR, } from "./settings-forms";
|
|
11
11
|
export const PHI_ASSET_RUNTIME_MODULE_DEFINITION = {
|
|
12
12
|
...PHI_ASSET_RUNTIME_MODULE_IDENTITY,
|
|
@@ -42,6 +42,7 @@ export const PHI_ASSET_RUNTIME_MODULE_DEFINITION = {
|
|
|
42
42
|
fieldTypes: [
|
|
43
43
|
PHI_ASSET_FOCAL_RECT_FORM_PROVIDER_DESCRIPTOR,
|
|
44
44
|
PHI_ASSET_MEDIA_ASSET_FORM_PROVIDER_DESCRIPTOR,
|
|
45
|
+
PHI_ASSET_MEDIA_ASSETS_FORM_PROVIDER_DESCRIPTOR,
|
|
45
46
|
],
|
|
46
47
|
handlers: [
|
|
47
48
|
PHI_ASSET_METADATA_FORM_HANDLER_PROVIDER_DESCRIPTOR,
|
|
@@ -20,8 +20,6 @@ export declare const PHI_FORM_MEDIA_ASSET_LABEL_KEYS: {
|
|
|
20
20
|
readonly choose: "mediaAssetChoose";
|
|
21
21
|
readonly change: "mediaAssetChange";
|
|
22
22
|
readonly remove: "mediaAssetRemove";
|
|
23
|
-
/** Beneath the field when it offers public Assets only (`config.publicOnly`). */
|
|
24
|
-
readonly publicOnlyHint: "mediaAssetPublicOnlyHint";
|
|
25
23
|
/** Beside a chosen Asset that is not public, where the field offers public ones only. */
|
|
26
24
|
readonly notPublic: "mediaAssetNotPublic";
|
|
27
25
|
/** Where the preview would be, when the Asset could not be read. */
|
|
@@ -78,3 +76,88 @@ export declare const PHI_ASSET_MEDIA_ASSET_FORM_PROVIDER_DESCRIPTOR: {
|
|
|
78
76
|
options?: undefined;
|
|
79
77
|
})[];
|
|
80
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* The most Assets a `media-assets` field holds whatever its config says: the most the Media list answers
|
|
81
|
+
* by id in one read (`GET /api/site/media?id=…`), which is how the field reads its tiles.
|
|
82
|
+
*/
|
|
83
|
+
export declare const PHI_MEDIA_ASSETS_FIELD_MOST = 100;
|
|
84
|
+
/**
|
|
85
|
+
* The `media-assets` field's own wording, read from the Form's Label Set and falling back to English. Its
|
|
86
|
+
* buttons and the picker and upload surface they open say the Media Label Set's words
|
|
87
|
+
* (`PHI_FORM_MEDIA_ASSET_PICKER_LABEL_KEYS`, "Choose from Media library" and the upload toggle among them).
|
|
88
|
+
*/
|
|
89
|
+
export declare const PHI_FORM_MEDIA_ASSETS_LABEL_KEYS: {
|
|
90
|
+
/** A tile's button that takes the Asset out of the value. */
|
|
91
|
+
readonly remove: "mediaAssetsRemove";
|
|
92
|
+
/** The drag handle's name for assistive technology. */
|
|
93
|
+
readonly reorder: "mediaAssetsReorder";
|
|
94
|
+
/** The name on a tile whose Asset the library did not answer. */
|
|
95
|
+
readonly unavailable: "mediaAssetsUnavailable";
|
|
96
|
+
/** Said where the value holds more than `max`, or more were offered than fit; `%1` is `max`. */
|
|
97
|
+
readonly tooMany: "mediaAssetsTooMany";
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* The `media-assets` field type: several Assets of the Site's Media library, as an ordered list of their
|
|
101
|
+
* ids. The Asset Module owns it as it owns `media-asset`. `json`, as the `upload` field's list of Asset
|
|
102
|
+
* ids is: the Form contract's value types have no list of numbers.
|
|
103
|
+
*/
|
|
104
|
+
export declare const PHI_ASSET_MEDIA_ASSETS_FORM_PROVIDER_DESCRIPTOR: {
|
|
105
|
+
key: `${string}/${string}`;
|
|
106
|
+
ownerModuleId: "@phis/ui/modules/asset";
|
|
107
|
+
title: string;
|
|
108
|
+
description: string;
|
|
109
|
+
valueType: "json";
|
|
110
|
+
presentation: "control";
|
|
111
|
+
settingsFields: ({
|
|
112
|
+
key: string;
|
|
113
|
+
type: "choice";
|
|
114
|
+
mode: "single";
|
|
115
|
+
valueType: "string";
|
|
116
|
+
label: string;
|
|
117
|
+
description: string;
|
|
118
|
+
options: ({
|
|
119
|
+
value: "image";
|
|
120
|
+
label: string;
|
|
121
|
+
} | {
|
|
122
|
+
value: "video";
|
|
123
|
+
label: string;
|
|
124
|
+
} | {
|
|
125
|
+
value: "audio";
|
|
126
|
+
label: string;
|
|
127
|
+
} | {
|
|
128
|
+
value: "pdf";
|
|
129
|
+
label: string;
|
|
130
|
+
} | {
|
|
131
|
+
value: "markdown";
|
|
132
|
+
label: string;
|
|
133
|
+
} | {
|
|
134
|
+
value: "font";
|
|
135
|
+
label: string;
|
|
136
|
+
})[];
|
|
137
|
+
min?: undefined;
|
|
138
|
+
max?: undefined;
|
|
139
|
+
precision?: undefined;
|
|
140
|
+
} | {
|
|
141
|
+
key: string;
|
|
142
|
+
type: "string";
|
|
143
|
+
label: string;
|
|
144
|
+
description: string;
|
|
145
|
+
mode?: undefined;
|
|
146
|
+
valueType?: undefined;
|
|
147
|
+
options?: undefined;
|
|
148
|
+
min?: undefined;
|
|
149
|
+
max?: undefined;
|
|
150
|
+
precision?: undefined;
|
|
151
|
+
} | {
|
|
152
|
+
key: string;
|
|
153
|
+
type: "number";
|
|
154
|
+
label: string;
|
|
155
|
+
description: string;
|
|
156
|
+
min: number;
|
|
157
|
+
max: number;
|
|
158
|
+
precision: number;
|
|
159
|
+
mode?: undefined;
|
|
160
|
+
valueType?: undefined;
|
|
161
|
+
options?: undefined;
|
|
162
|
+
})[];
|
|
163
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PHI_ASSET_RUNTIME_MODULE_ID } from "./ids";
|
|
2
2
|
import { PhiMediaKind } from "../../../constants/media";
|
|
3
|
-
import { PHI_MEDIA_ASSET_FORM_FIELD_PROVIDER_KEY } from "../../../constants/media-library-provider-keys";
|
|
3
|
+
import { PHI_MEDIA_ASSET_FORM_FIELD_PROVIDER_KEY, PHI_MEDIA_ASSETS_FORM_FIELD_PROVIDER_KEY, } from "../../../constants/media-library-provider-keys";
|
|
4
4
|
import { createPhiSharedFormProviderKey } from "../../../components/forms/form-provider-contract";
|
|
5
5
|
export const PHI_ASSET_FOCAL_RECT_FORM_PROVIDER_KEY = createPhiSharedFormProviderKey("field", "asset-focal-rect");
|
|
6
6
|
export const PHI_ASSET_FOCAL_RECT_FORM_PROVIDER_DESCRIPTOR = {
|
|
@@ -24,13 +24,20 @@ export const PHI_FORM_MEDIA_ASSET_LABEL_KEYS = {
|
|
|
24
24
|
choose: "mediaAssetChoose",
|
|
25
25
|
change: "mediaAssetChange",
|
|
26
26
|
remove: "mediaAssetRemove",
|
|
27
|
-
/** Beneath the field when it offers public Assets only (`config.publicOnly`). */
|
|
28
|
-
publicOnlyHint: "mediaAssetPublicOnlyHint",
|
|
29
27
|
/** Beside a chosen Asset that is not public, where the field offers public ones only. */
|
|
30
28
|
notPublic: "mediaAssetNotPublic",
|
|
31
29
|
/** Where the preview would be, when the Asset could not be read. */
|
|
32
30
|
unavailable: "mediaAssetUnavailable",
|
|
33
31
|
};
|
|
32
|
+
// The kinds a Media field's picker lists, offered alike by `media-asset` and `media-assets`.
|
|
33
|
+
const MEDIA_FIELD_KIND_OPTIONS = [
|
|
34
|
+
{ value: PhiMediaKind.Image, label: "Image" },
|
|
35
|
+
{ value: PhiMediaKind.Video, label: "Video" },
|
|
36
|
+
{ value: PhiMediaKind.Audio, label: "Audio" },
|
|
37
|
+
{ value: PhiMediaKind.Pdf, label: "PDF" },
|
|
38
|
+
{ value: PhiMediaKind.Markdown, label: "Markdown" },
|
|
39
|
+
{ value: PhiMediaKind.Font, label: "Font" },
|
|
40
|
+
];
|
|
34
41
|
export const PHI_ASSET_MEDIA_ASSET_FORM_PROVIDER_DESCRIPTOR = {
|
|
35
42
|
key: PHI_MEDIA_ASSET_FORM_FIELD_PROVIDER_KEY,
|
|
36
43
|
ownerModuleId: PHI_ASSET_RUNTIME_MODULE_ID,
|
|
@@ -46,14 +53,7 @@ export const PHI_ASSET_MEDIA_ASSET_FORM_PROVIDER_DESCRIPTOR = {
|
|
|
46
53
|
valueType: "string",
|
|
47
54
|
label: "Kind",
|
|
48
55
|
description: "Image when nothing is named.",
|
|
49
|
-
options:
|
|
50
|
-
{ value: PhiMediaKind.Image, label: "Image" },
|
|
51
|
-
{ value: PhiMediaKind.Video, label: "Video" },
|
|
52
|
-
{ value: PhiMediaKind.Audio, label: "Audio" },
|
|
53
|
-
{ value: PhiMediaKind.Pdf, label: "PDF" },
|
|
54
|
-
{ value: PhiMediaKind.Markdown, label: "Markdown" },
|
|
55
|
-
{ value: PhiMediaKind.Font, label: "Font" },
|
|
56
|
-
],
|
|
56
|
+
options: MEDIA_FIELD_KIND_OPTIONS,
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
59
|
key: "publicOnly",
|
|
@@ -69,3 +69,62 @@ export const PHI_ASSET_MEDIA_ASSET_FORM_PROVIDER_DESCRIPTOR = {
|
|
|
69
69
|
},
|
|
70
70
|
],
|
|
71
71
|
};
|
|
72
|
+
/**
|
|
73
|
+
* The most Assets a `media-assets` field holds whatever its config says: the most the Media list answers
|
|
74
|
+
* by id in one read (`GET /api/site/media?id=…`), which is how the field reads its tiles.
|
|
75
|
+
*/
|
|
76
|
+
export const PHI_MEDIA_ASSETS_FIELD_MOST = 100;
|
|
77
|
+
/**
|
|
78
|
+
* The `media-assets` field's own wording, read from the Form's Label Set and falling back to English. Its
|
|
79
|
+
* buttons and the picker and upload surface they open say the Media Label Set's words
|
|
80
|
+
* (`PHI_FORM_MEDIA_ASSET_PICKER_LABEL_KEYS`, "Choose from Media library" and the upload toggle among them).
|
|
81
|
+
*/
|
|
82
|
+
export const PHI_FORM_MEDIA_ASSETS_LABEL_KEYS = {
|
|
83
|
+
/** A tile's button that takes the Asset out of the value. */
|
|
84
|
+
remove: "mediaAssetsRemove",
|
|
85
|
+
/** The drag handle's name for assistive technology. */
|
|
86
|
+
reorder: "mediaAssetsReorder",
|
|
87
|
+
/** The name on a tile whose Asset the library did not answer. */
|
|
88
|
+
unavailable: "mediaAssetsUnavailable",
|
|
89
|
+
/** Said where the value holds more than `max`, or more were offered than fit; `%1` is `max`. */
|
|
90
|
+
tooMany: "mediaAssetsTooMany",
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* The `media-assets` field type: several Assets of the Site's Media library, as an ordered list of their
|
|
94
|
+
* ids. The Asset Module owns it as it owns `media-asset`. `json`, as the `upload` field's list of Asset
|
|
95
|
+
* ids is: the Form contract's value types have no list of numbers.
|
|
96
|
+
*/
|
|
97
|
+
export const PHI_ASSET_MEDIA_ASSETS_FORM_PROVIDER_DESCRIPTOR = {
|
|
98
|
+
key: PHI_MEDIA_ASSETS_FORM_FIELD_PROVIDER_KEY,
|
|
99
|
+
ownerModuleId: PHI_ASSET_RUNTIME_MODULE_ID,
|
|
100
|
+
title: "Media assets",
|
|
101
|
+
description: "Several Assets of the Site's Media library, as their ids in order.",
|
|
102
|
+
valueType: "json",
|
|
103
|
+
presentation: "control",
|
|
104
|
+
settingsFields: [
|
|
105
|
+
{
|
|
106
|
+
key: "mediaType",
|
|
107
|
+
type: "choice",
|
|
108
|
+
mode: "single",
|
|
109
|
+
valueType: "string",
|
|
110
|
+
label: "Kind",
|
|
111
|
+
description: "Image when nothing is named.",
|
|
112
|
+
options: MEDIA_FIELD_KIND_OPTIONS,
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
key: "folderPath",
|
|
116
|
+
type: "string",
|
|
117
|
+
label: "Folder path",
|
|
118
|
+
description: "The Site Folder the picker opens on and uploads go into, by its path (\"Shop Images / Products\"); missing Folders are created on the first upload. {key} puts in a value of the Form; a name whose value is empty is left out. Empty: the root.",
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
key: "max",
|
|
122
|
+
type: "number",
|
|
123
|
+
label: "Most Assets",
|
|
124
|
+
description: `The most Assets the field holds, from 1 to ${PHI_MEDIA_ASSETS_FIELD_MOST} (the default).`,
|
|
125
|
+
min: 1,
|
|
126
|
+
max: PHI_MEDIA_ASSETS_FIELD_MOST,
|
|
127
|
+
precision: 0,
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
};
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { lazyPhiFormFieldControl } from "../../../components/forms/lazy-form-field-control";
|
|
4
4
|
import { createPhiFormProviderRegistry, PhiFormProviderRegistryProvider } from "../../../components/forms/form-provider-registry";
|
|
5
|
-
import { PHI_ASSET_FOCAL_RECT_FORM_PROVIDER_DESCRIPTOR, PHI_ASSET_MEDIA_ASSET_FORM_PROVIDER_DESCRIPTOR, } from "./form-providers";
|
|
5
|
+
import { PHI_ASSET_FOCAL_RECT_FORM_PROVIDER_DESCRIPTOR, PHI_ASSET_MEDIA_ASSET_FORM_PROVIDER_DESCRIPTOR, PHI_ASSET_MEDIA_ASSETS_FORM_PROVIDER_DESCRIPTOR, } from "./form-providers";
|
|
6
6
|
// Loaded when a `media-asset` field first renders: the picker and the Media library binding stay out of
|
|
7
7
|
// every other Form.
|
|
8
8
|
const PhiLazyMediaAssetFormControl = lazyPhiFormFieldControl(() => import("./media-asset-form-control").then((module) => module.PhiMediaAssetFormControl));
|
|
9
|
+
// Loaded when a `media-assets` field first renders, on the same terms.
|
|
10
|
+
const PhiLazyMediaAssetsFormControl = lazyPhiFormFieldControl(() => import("./media-assets-form-control").then((module) => module.PhiMediaAssetsFormControl));
|
|
9
11
|
const PHI_ASSET_FORM_PROVIDER_REGISTRY = createPhiFormProviderRegistry({
|
|
10
12
|
fieldTypes: [
|
|
11
13
|
{
|
|
@@ -16,6 +18,10 @@ const PHI_ASSET_FORM_PROVIDER_REGISTRY = createPhiFormProviderRegistry({
|
|
|
16
18
|
...PHI_ASSET_MEDIA_ASSET_FORM_PROVIDER_DESCRIPTOR,
|
|
17
19
|
Control: PhiLazyMediaAssetFormControl,
|
|
18
20
|
},
|
|
21
|
+
{
|
|
22
|
+
...PHI_ASSET_MEDIA_ASSETS_FORM_PROVIDER_DESCRIPTOR,
|
|
23
|
+
Control: PhiLazyMediaAssetsFormControl,
|
|
24
|
+
},
|
|
19
25
|
],
|
|
20
26
|
});
|
|
21
27
|
export function PhiAssetFormUiProvider({ children }) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { PhiMediaAssetTile, PhiMediaKindValue } from "../../../types/media";
|
|
2
|
+
import { type PhiConfigReader } from "../../../components/widgets/config/strict-config-reader";
|
|
2
3
|
export type PhiMediaAssetFieldConfig = {
|
|
3
4
|
/** Which kind of Asset the picker lists. */
|
|
4
5
|
mediaType: PhiMediaKindValue;
|
|
@@ -14,8 +15,8 @@ export type PhiMediaAssetFieldConfig = {
|
|
|
14
15
|
* root. A path and not an id, so a Module's Form states it for every Site.
|
|
15
16
|
*
|
|
16
17
|
* A name may hold placeholders, `{key}`, read from the Form's values when the picker opens
|
|
17
|
-
* (`
|
|
18
|
-
* as written, placeholders unresolved.
|
|
18
|
+
* (`resolvePhiMediaFolderPathTemplate`, `components/media/media-folder-name-path.ts`): "Shop Images /
|
|
19
|
+
* {category} / {product}". These are the names as written, placeholders unresolved.
|
|
19
20
|
*/
|
|
20
21
|
folderPath: readonly string[];
|
|
21
22
|
};
|
|
@@ -28,12 +29,11 @@ export type PhiMediaAssetFieldConfig = {
|
|
|
28
29
|
*/
|
|
29
30
|
export declare function readPhiMediaAssetFieldConfig(config: Readonly<Record<string, unknown>> | undefined): PhiMediaAssetFieldConfig;
|
|
30
31
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* category is "Shop Images / <product>" -- and a name that comes out empty is left out too.
|
|
32
|
+
* What the `media-asset` and the `media-assets` field read alike: the kind the picker lists and the
|
|
33
|
+
* upload takes (images where none is named), and the Folder path it opens on and uploads into, with its
|
|
34
|
+
* placeholders unresolved -- by the same strict rules, so the two fields cannot read one setting two ways.
|
|
35
35
|
*/
|
|
36
|
-
export declare function
|
|
36
|
+
export declare function readPhiMediaFieldTarget(reader: PhiConfigReader): Pick<PhiMediaAssetFieldConfig, "mediaType" | "folderPath">;
|
|
37
37
|
/**
|
|
38
38
|
* The Asset id a Form value holds, or `null`. A value that is not a positive whole number is not an id,
|
|
39
39
|
* and showing it as one would put a request for Asset `NaN` on the wire.
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { PhiMediaKind, isPhiMediaAssetPublic } from "../../../constants/media";
|
|
2
|
-
import { createPhiConfigReader } from "../../../components/widgets/config/strict-config-reader";
|
|
3
|
-
import { splitPhiMediaFolderNamePath } from "../../../components/media/media-folder-name-path";
|
|
4
|
-
import { readPhiDotPath } from "../../../helpers/dot-path";
|
|
2
|
+
import { createPhiConfigReader, } from "../../../components/widgets/config/strict-config-reader";
|
|
3
|
+
import { isPhiMediaFolderPathTemplate, splitPhiMediaFolderNamePath, } from "../../../components/media/media-folder-name-path";
|
|
5
4
|
const MEDIA_ASSET_FIELD_KINDS = [
|
|
6
5
|
PhiMediaKind.Image,
|
|
7
6
|
PhiMediaKind.Video,
|
|
@@ -20,41 +19,20 @@ const MEDIA_ASSET_FIELD_KINDS = [
|
|
|
20
19
|
export function readPhiMediaAssetFieldConfig(config) {
|
|
21
20
|
const reader = createPhiConfigReader(config ?? {}, "config");
|
|
22
21
|
return {
|
|
23
|
-
|
|
22
|
+
...readPhiMediaFieldTarget(reader),
|
|
24
23
|
publicOnly: reader.boolean("publicOnly") ?? false,
|
|
25
|
-
folderPath: splitPhiMediaFolderNamePath(reader.value("folderPath", "a Folder path whose placeholders read {key}", (value) => typeof value === "string" && isPhiMediaAssetFolderPathTemplate(value) ? value : undefined)),
|
|
26
24
|
};
|
|
27
25
|
}
|
|
28
|
-
/* `{key}`: a Form value's key, a dotted path into it for a value that is a record. */
|
|
29
|
-
const PHI_MEDIA_ASSET_FOLDER_PATH_PLACEHOLDER = /\{([A-Za-z0-9_.-]+)\}/gu;
|
|
30
|
-
function isPhiMediaAssetFolderPathTemplate(value) {
|
|
31
|
-
return !/[{}]/u.test(value.replace(PHI_MEDIA_ASSET_FOLDER_PATH_PLACEHOLDER, ""));
|
|
32
|
-
}
|
|
33
|
-
/*
|
|
34
|
-
* A Form value as a Folder name: a text or a number, trimmed, and a `/` in it a `-`, so a value can name
|
|
35
|
-
* a Folder but never add a level of them. Anything else -- empty, absent, a list, a record -- is no name.
|
|
36
|
-
*/
|
|
37
|
-
function readPhiMediaAssetFolderPathValue(value) {
|
|
38
|
-
const text = typeof value === "string" ? value : typeof value === "number" && Number.isFinite(value) ? String(value) : "";
|
|
39
|
-
return text.replace(/\//gu, "-").replace(/\s+/gu, " ").trim();
|
|
40
|
-
}
|
|
41
26
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* category is "Shop Images / <product>" -- and a name that comes out empty is left out too.
|
|
27
|
+
* What the `media-asset` and the `media-assets` field read alike: the kind the picker lists and the
|
|
28
|
+
* upload takes (images where none is named), and the Folder path it opens on and uploads into, with its
|
|
29
|
+
* placeholders unresolved -- by the same strict rules, so the two fields cannot read one setting two ways.
|
|
46
30
|
*/
|
|
47
|
-
export function
|
|
48
|
-
return
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (!value)
|
|
53
|
-
missing = true;
|
|
54
|
-
return value;
|
|
55
|
-
}).replace(/\s+/gu, " ").trim();
|
|
56
|
-
return missing || !resolved ? [] : [resolved];
|
|
57
|
-
});
|
|
31
|
+
export function readPhiMediaFieldTarget(reader) {
|
|
32
|
+
return {
|
|
33
|
+
mediaType: reader.oneOf("mediaType", MEDIA_ASSET_FIELD_KINDS) ?? PhiMediaKind.Image,
|
|
34
|
+
folderPath: splitPhiMediaFolderNamePath(reader.value("folderPath", "a Folder path whose placeholders read {key}", (value) => typeof value === "string" && isPhiMediaFolderPathTemplate(value) ? value : undefined)),
|
|
35
|
+
};
|
|
58
36
|
}
|
|
59
37
|
/**
|
|
60
38
|
* The Asset id a Form value holds, or `null`. A value that is not a positive whole number is not an id,
|
|
@@ -8,13 +8,14 @@ import type { PhiFormFieldProviderProps } from "../../../components/forms/form-p
|
|
|
8
8
|
* value is the Asset id as a number, `null` for none, and the field keeps no copy of it: what it keeps is
|
|
9
9
|
* the picker's open state.
|
|
10
10
|
*
|
|
11
|
-
* Inside the picker a file from the reader's machine can go up too, into the Folder the picker shows,
|
|
12
|
-
* the
|
|
13
|
-
* chosen as a picked tile would be. It goes into the Site Space, like
|
|
14
|
-
* Core delivers what goes there publicly. What comes back is asked what
|
|
15
|
-
* another kind (a file the browser could not name reaches Core unrefused)
|
|
16
|
-
* one that is not public is left in the list unchosen, and the field says
|
|
17
|
-
* way the Form's submit is held, as the upload field holds it, and closing
|
|
11
|
+
* Inside the picker a file from the reader's machine can go up too, into the Folder the picker shows,
|
|
12
|
+
* through the Media library's own upload surface (`PhiAreaUploadBinding`, one file, Core's upload
|
|
13
|
+
* session); what it made is chosen as a picked tile would be. It goes into the Site Space, like
|
|
14
|
+
* everything the field offers, and Core delivers what goes there publicly. What comes back is asked what
|
|
15
|
+
* a pick is asked: an Asset of another kind (a file the browser could not name reaches Core unrefused)
|
|
16
|
+
* or, for a `publicOnly` field, one that is not public is left in the list unchosen, and the field says
|
|
17
|
+
* why. While the file is on its way the Form's submit is held, as the upload field holds it, and closing
|
|
18
|
+
* the picker stops it.
|
|
18
19
|
* `config.folderPath` names the Folder the picker opens on ("Shop Images / Products"): read in the Site
|
|
19
20
|
* Space each time it opens, without writing anything (`readPhiMediaUploadFolderPathReach`), so a reader
|
|
20
21
|
* who may only choose opens and picks without a refusal; the picker opens on the deepest Folder of the
|