@phis/ui 0.7.2 → 0.7.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/components/controls/phi-collection-reorder-context.d.ts +21 -0
- package/components/controls/phi-collection-reorder-context.js +6 -0
- package/components/controls/phi-collection-sortable-layout-control.d.ts +17 -0
- package/components/controls/phi-collection-sortable-layout-control.js +72 -0
- package/components/controls/phi-collection-view-control.d.ts +1 -1
- package/components/controls/phi-collection-view-control.js +15 -1
- package/components/controls/phi-media-asset-tile-control.d.ts +14 -6
- package/components/controls/phi-media-picker-control.d.ts +13 -2
- package/components/controls/phi-media-picker-control.js +9 -2
- package/components/forms/compound-form-controls.d.ts +1 -1
- package/components/forms/compound-form-controls.js +6 -4
- package/components/forms/form-field-labels.d.ts +4 -2
- package/components/forms/form-field-labels.js +30 -9
- package/components/forms/form-provider-contract.js +2 -1
- package/components/forms/media-asset-field-keys.d.ts +13 -2
- package/components/forms/media-asset-field-keys.js +17 -2
- package/components/forms/table-field-keys.d.ts +8 -0
- package/components/forms/table-field-keys.js +8 -0
- package/components/forms/table-field-labels.d.ts +16 -0
- package/components/forms/table-field-labels.js +16 -0
- package/components/forms/table-field-text.d.ts +9 -0
- package/components/forms/table-field-text.js +20 -0
- package/components/forms/upload-field-refusal-labels.d.ts +10 -0
- package/components/forms/upload-field-refusal-labels.js +24 -0
- package/components/forms/upload-form-control.js +3 -16
- 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-upload-flow.d.ts +13 -1
- package/components/media/media-upload-flow.js +16 -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 +50 -1
- package/components/media/phi-media-picker-binding.js +86 -6
- package/components/media/phi-media-upload.d.ts +7 -1
- package/components/media/phi-media-upload.js +17 -5
- 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-collection-reorder.d.ts +45 -0
- package/components/widgets/client/shared/phi-collection-reorder.js +110 -0
- package/components/widgets/client/shared/phi-collection-view-binding.js +2 -1
- package/components/widgets/label-sets/collection-view.d.ts +4 -0
- package/components/widgets/label-sets/collection-view.js +16 -0
- package/components/widgets/label-sets/table.d.ts +6 -0
- package/components/widgets/label-sets/table.js +10 -0
- package/components/widgets/label-types/collection-view.d.ts +8 -0
- package/components/widgets/label-types/collection-view.js +4 -0
- 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/controls.d.ts +1 -1
- 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 +123 -38
- package/plugins/runtime-modules/asset/definition.js +2 -1
- package/plugins/runtime-modules/asset/form-providers.d.ts +93 -2
- package/plugins/runtime-modules/asset/form-providers.js +76 -11
- package/plugins/runtime-modules/asset/form-ui-provider.js +7 -1
- package/plugins/runtime-modules/asset/media-asset-field.d.ts +34 -4
- package/plugins/runtime-modules/asset/media-asset-field.js +30 -5
- package/plugins/runtime-modules/asset/media-asset-form-control.d.ts +14 -0
- package/plugins/runtime-modules/asset/media-asset-form-control.js +72 -37
- 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/page-meta-form.js +6 -6
- 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 +10 -0
- package/plugins/runtime-modules/core/widgets/collection-view/client.js +59 -5
- package/plugins/runtime-modules/core/widgets/collection-view/config.d.ts +53 -2
- package/plugins/runtime-modules/core/widgets/collection-view/config.js +47 -0
- package/plugins/runtime-modules/core/widgets/collection-view/image-preview-grid.js +4 -1
- package/plugins/runtime-modules/core/widgets/collection-view/plugin.js +1 -1
- package/plugins/runtime-modules/core/widgets/collection-view/server.d.ts +5 -1
- package/plugins/runtime-modules/core/widgets/collection-view/server.js +26 -9
- 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-provider.d.ts +7 -0
- package/types/collection-view-widget.d.ts +30 -0
- package/types/core-widget-placements.d.ts +14 -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: {
|
|
@@ -146,6 +164,73 @@ export declare const PHI_ASSET_RUNTIME_MODULE_DEFINITION: {
|
|
|
146
164
|
mode?: undefined;
|
|
147
165
|
valueType?: undefined;
|
|
148
166
|
options?: undefined;
|
|
167
|
+
} | {
|
|
168
|
+
key: string;
|
|
169
|
+
type: "string";
|
|
170
|
+
label: string;
|
|
171
|
+
description: string;
|
|
172
|
+
mode?: undefined;
|
|
173
|
+
valueType?: undefined;
|
|
174
|
+
options?: undefined;
|
|
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;
|
|
149
234
|
})[];
|
|
150
235
|
})[];
|
|
151
236
|
handlers: ({
|
|
@@ -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. */
|
|
@@ -68,5 +66,98 @@ export declare const PHI_ASSET_MEDIA_ASSET_FORM_PROVIDER_DESCRIPTOR: {
|
|
|
68
66
|
mode?: undefined;
|
|
69
67
|
valueType?: undefined;
|
|
70
68
|
options?: undefined;
|
|
69
|
+
} | {
|
|
70
|
+
key: string;
|
|
71
|
+
type: "string";
|
|
72
|
+
label: string;
|
|
73
|
+
description: string;
|
|
74
|
+
mode?: undefined;
|
|
75
|
+
valueType?: undefined;
|
|
76
|
+
options?: undefined;
|
|
77
|
+
})[];
|
|
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;
|
|
71
162
|
})[];
|
|
72
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",
|
|
@@ -61,5 +61,70 @@ export const PHI_ASSET_MEDIA_ASSET_FORM_PROVIDER_DESCRIPTOR = {
|
|
|
61
61
|
label: "Public only",
|
|
62
62
|
description: "Offer only Assets that are delivered publicly. The picker greys out the others; the Server that takes the value decides.",
|
|
63
63
|
},
|
|
64
|
+
{
|
|
65
|
+
key: "folderPath",
|
|
66
|
+
type: "string",
|
|
67
|
+
label: "Folder path",
|
|
68
|
+
description: "The Site Folder the picker opens on and uploads 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.",
|
|
69
|
+
},
|
|
70
|
+
],
|
|
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
|
+
},
|
|
64
129
|
],
|
|
65
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,16 +1,39 @@
|
|
|
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;
|
|
5
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Whether Assets that are not delivered publicly are greyed out in the picker -- and an uploaded one
|
|
8
|
+
* that is not is left unchosen. Core delivers what goes into the Site Space publicly by default.
|
|
9
|
+
*/
|
|
6
10
|
publicOnly: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* The Folder of the Site Space the picker opens on, by its path of names from the root ("Shop Images /
|
|
13
|
+
* Products"): it opens on the deepest of them that is there, and an upload from there creates the
|
|
14
|
+
* missing ones and goes into the whole path. Empty: the Folder the picker last showed, at first the
|
|
15
|
+
* root. A path and not an id, so a Module's Form states it for every Site.
|
|
16
|
+
*
|
|
17
|
+
* A name may hold placeholders, `{key}`, read from the Form's values when the picker opens
|
|
18
|
+
* (`resolvePhiMediaFolderPathTemplate`, `components/media/media-folder-name-path.ts`): "Shop Images /
|
|
19
|
+
* {category} / {product}". These are the names as written, placeholders unresolved.
|
|
20
|
+
*/
|
|
21
|
+
folderPath: readonly string[];
|
|
7
22
|
};
|
|
8
23
|
/**
|
|
9
|
-
* The field's config, read strictly (`strict-config-reader.ts`): a kind the picker does not list,
|
|
10
|
-
* `publicOnly` that is not a boolean,
|
|
11
|
-
*
|
|
24
|
+
* The field's config, read strictly (`strict-config-reader.ts`): a kind the picker does not list, a
|
|
25
|
+
* `publicOnly` that is not a boolean, or a `folderPath` that is not a text or holds a brace that opens no
|
|
26
|
+
* placeholder (`{}`, `{a`, `a}`, `{a{b}}`) is a `PhiConfigError` naming the field, never a default put in
|
|
27
|
+
* its place -- a typo in `mediaType` would otherwise quietly offer another kind of file, and a broken
|
|
28
|
+
* placeholder would become a Folder named after it.
|
|
12
29
|
*/
|
|
13
30
|
export declare function readPhiMediaAssetFieldConfig(config: Readonly<Record<string, unknown>> | undefined): PhiMediaAssetFieldConfig;
|
|
31
|
+
/**
|
|
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
|
+
*/
|
|
36
|
+
export declare function readPhiMediaFieldTarget(reader: PhiConfigReader): Pick<PhiMediaAssetFieldConfig, "mediaType" | "folderPath">;
|
|
14
37
|
/**
|
|
15
38
|
* The Asset id a Form value holds, or `null`. A value that is not a positive whole number is not an id,
|
|
16
39
|
* and showing it as one would put a request for Asset `NaN` on the wire.
|
|
@@ -18,3 +41,10 @@ export declare function readPhiMediaAssetFieldConfig(config: Readonly<Record<str
|
|
|
18
41
|
export declare function readPhiMediaAssetFieldValue(value: unknown): number | null;
|
|
19
42
|
/** Whether the picker lets one Asset be chosen: always, unless the field offers public Assets only. */
|
|
20
43
|
export declare function isPhiMediaAssetFieldSelectable(config: PhiMediaAssetFieldConfig, asset: Pick<PhiMediaAssetTile, "deliveryPolicy" | "lifecycleStatus">): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Whether an Asset uploaded in the field's picker is one it lets be chosen, and if not, why: of the kind
|
|
46
|
+
* the picker lists, and public where the field offers public Assets only. The same question a pick
|
|
47
|
+
* answers, asked of what the upload made -- Core does not know the field's kind, and a file the browser
|
|
48
|
+
* could not name reaches it unrefused.
|
|
49
|
+
*/
|
|
50
|
+
export declare function readPhiMediaAssetFieldUploadRefusal(config: PhiMediaAssetFieldConfig, asset: Pick<PhiMediaAssetTile, "kind" | "deliveryPolicy" | "lifecycleStatus">): "kind" | "notPublic" | null;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PhiMediaKind, isPhiMediaAssetPublic } from "../../../constants/media";
|
|
2
|
-
import { createPhiConfigReader } from "../../../components/widgets/config/strict-config-reader";
|
|
2
|
+
import { createPhiConfigReader, } from "../../../components/widgets/config/strict-config-reader";
|
|
3
|
+
import { isPhiMediaFolderPathTemplate, splitPhiMediaFolderNamePath, } from "../../../components/media/media-folder-name-path";
|
|
3
4
|
const MEDIA_ASSET_FIELD_KINDS = [
|
|
4
5
|
PhiMediaKind.Image,
|
|
5
6
|
PhiMediaKind.Video,
|
|
@@ -9,17 +10,30 @@ const MEDIA_ASSET_FIELD_KINDS = [
|
|
|
9
10
|
PhiMediaKind.Font,
|
|
10
11
|
];
|
|
11
12
|
/**
|
|
12
|
-
* The field's config, read strictly (`strict-config-reader.ts`): a kind the picker does not list,
|
|
13
|
-
* `publicOnly` that is not a boolean,
|
|
14
|
-
*
|
|
13
|
+
* The field's config, read strictly (`strict-config-reader.ts`): a kind the picker does not list, a
|
|
14
|
+
* `publicOnly` that is not a boolean, or a `folderPath` that is not a text or holds a brace that opens no
|
|
15
|
+
* placeholder (`{}`, `{a`, `a}`, `{a{b}}`) is a `PhiConfigError` naming the field, never a default put in
|
|
16
|
+
* its place -- a typo in `mediaType` would otherwise quietly offer another kind of file, and a broken
|
|
17
|
+
* placeholder would become a Folder named after it.
|
|
15
18
|
*/
|
|
16
19
|
export function readPhiMediaAssetFieldConfig(config) {
|
|
17
20
|
const reader = createPhiConfigReader(config ?? {}, "config");
|
|
18
21
|
return {
|
|
19
|
-
|
|
22
|
+
...readPhiMediaFieldTarget(reader),
|
|
20
23
|
publicOnly: reader.boolean("publicOnly") ?? false,
|
|
21
24
|
};
|
|
22
25
|
}
|
|
26
|
+
/**
|
|
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.
|
|
30
|
+
*/
|
|
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
|
+
};
|
|
36
|
+
}
|
|
23
37
|
/**
|
|
24
38
|
* The Asset id a Form value holds, or `null`. A value that is not a positive whole number is not an id,
|
|
25
39
|
* and showing it as one would put a request for Asset `NaN` on the wire.
|
|
@@ -31,3 +45,14 @@ export function readPhiMediaAssetFieldValue(value) {
|
|
|
31
45
|
export function isPhiMediaAssetFieldSelectable(config, asset) {
|
|
32
46
|
return !config.publicOnly || isPhiMediaAssetPublic(asset.deliveryPolicy, asset.lifecycleStatus);
|
|
33
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Whether an Asset uploaded in the field's picker is one it lets be chosen, and if not, why: of the kind
|
|
50
|
+
* the picker lists, and public where the field offers public Assets only. The same question a pick
|
|
51
|
+
* answers, asked of what the upload made -- Core does not know the field's kind, and a file the browser
|
|
52
|
+
* could not name reaches it unrefused.
|
|
53
|
+
*/
|
|
54
|
+
export function readPhiMediaAssetFieldUploadRefusal(config, asset) {
|
|
55
|
+
if (asset.kind !== config.mediaType)
|
|
56
|
+
return "kind";
|
|
57
|
+
return isPhiMediaAssetFieldSelectable(config, asset) ? null : "notPublic";
|
|
58
|
+
}
|
|
@@ -8,6 +8,20 @@ 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
|
+
* 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.
|
|
19
|
+
* `config.folderPath` names the Folder the picker opens on ("Shop Images / Products"): read in the Site
|
|
20
|
+
* Space each time it opens, without writing anything (`readPhiMediaUploadFolderPathReach`), so a reader
|
|
21
|
+
* who may only choose opens and picks without a refusal; the picker opens on the deepest Folder of the
|
|
22
|
+
* path that is there. An upload from there goes into the whole path, the missing Folders created the way
|
|
23
|
+
* `area-upload` creates them (`resolvePhiMediaUploadFolderPathId`).
|
|
24
|
+
*
|
|
11
25
|
* Only the Site Space is offered, in every Area (`siteSpaceOnly`): a Form stores a reference everybody
|
|
12
26
|
* who reads the stored value will follow, and a personal or a group Space cannot honestly stand behind
|
|
13
27
|
* that. `config.publicOnly` greys out the Assets that are not delivered publicly, from the delivery
|