@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
|
@@ -9,6 +9,9 @@ import { PHI_AUTHORING_OPTION_PROVIDER_KEYS } from "../../../../../constants/aut
|
|
|
9
9
|
import { readPhiLengthValue } from "../../../../../types/length";
|
|
10
10
|
import { readBoolean, readNumber, readNumberList, readString } from "../../../../../components/widgets/config/parser-primitives";
|
|
11
11
|
import { isPhiRecord } from "../../../../../helpers/is-record";
|
|
12
|
+
import { PhiMediaKind } from "../../../../../constants/media";
|
|
13
|
+
import { isPhiMediaFolderPathTemplate } from "../../../../../components/media/media-folder-name-path";
|
|
14
|
+
import { createPhiConfigReader } from "../../../../../components/widgets/config/strict-config-reader";
|
|
12
15
|
function readCardPresentation(value) {
|
|
13
16
|
if (!isPhiRecord(value)) {
|
|
14
17
|
return undefined;
|
|
@@ -80,6 +83,21 @@ function readToolbarActions(value) {
|
|
|
80
83
|
}];
|
|
81
84
|
});
|
|
82
85
|
}
|
|
86
|
+
const MEDIA_KINDS = Object.values(PhiMediaKind);
|
|
87
|
+
/*
|
|
88
|
+
* The Media renderer's settings (`features.media`), read strictly: a path whose braces open no
|
|
89
|
+
* placeholder or a kind the Media library does not know is a `PhiConfigError` naming the key, never a default put in its place -- a broken placeholder would
|
|
90
|
+
* become a Folder named after it.
|
|
91
|
+
*/
|
|
92
|
+
function readMediaFeatures(value) {
|
|
93
|
+
const reader = createPhiConfigReader(value, "features.media");
|
|
94
|
+
const folderPath = reader.value("folderPath", "a Folder path whose placeholders read {key}", (entry) => typeof entry === "string" && isPhiMediaFolderPathTemplate(entry) ? entry.trim() : undefined);
|
|
95
|
+
const mediaType = reader.oneOf("mediaType", MEDIA_KINDS);
|
|
96
|
+
return {
|
|
97
|
+
...(folderPath ? { folderPath } : {}),
|
|
98
|
+
...(mediaType ? { mediaType } : {}),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
83
101
|
function readInitialQuery(value) {
|
|
84
102
|
if (!isPhiRecord(value))
|
|
85
103
|
return undefined;
|
|
@@ -109,6 +127,8 @@ function normalizePhiCmsCollectionViewWidgetConfig(config) {
|
|
|
109
127
|
const search = isPhiRecord(features.search) ? features.search : null;
|
|
110
128
|
const actions = isPhiRecord(features.actions) ? features.actions : {};
|
|
111
129
|
const pagination = isPhiRecord(features.pagination) ? features.pagination : null;
|
|
130
|
+
const reorder = isPhiRecord(features.reorder) ? features.reorder : null;
|
|
131
|
+
const media = isPhiRecord(features.media) ? features.media : null;
|
|
112
132
|
return {
|
|
113
133
|
presentation: {
|
|
114
134
|
title: readString(presentation.title),
|
|
@@ -134,6 +154,11 @@ function normalizePhiCmsCollectionViewWidgetConfig(config) {
|
|
|
134
154
|
} : undefined,
|
|
135
155
|
filters: readFilters(features.filters),
|
|
136
156
|
actions: { toolbar: readToolbarActions(actions.toolbar) },
|
|
157
|
+
reorder: reorder ? {
|
|
158
|
+
enabled: readBoolean(reorder.enabled) ?? false,
|
|
159
|
+
actionKey: readString(reorder.actionKey)?.trim() || undefined,
|
|
160
|
+
} : undefined,
|
|
161
|
+
media: media ? readMediaFeatures(media) : undefined,
|
|
137
162
|
pagination: pagination ? {
|
|
138
163
|
enabled: readBoolean(pagination.enabled) ?? true,
|
|
139
164
|
pageSize: readNumber(pagination.pageSize),
|
|
@@ -175,6 +200,8 @@ export const PHI_COLLECTION_VIEW_WIDGET_DEFINITION = {
|
|
|
175
200
|
],
|
|
176
201
|
listens: [
|
|
177
202
|
{ id: "reload", channel: "reload", action: "activate", valueType: "none" },
|
|
203
|
+
// Laid over `source.params` and handed to the Provider, as the Table takes them.
|
|
204
|
+
{ id: "bindingParamsChange", channel: "bindingParams", action: "change", valueType: "json", valueSchema: PHI_SIGNAL_VALUE_SCHEMAS.tableBindingParams },
|
|
178
205
|
],
|
|
179
206
|
},
|
|
180
207
|
fields: [
|
|
@@ -334,6 +361,26 @@ export const PHI_COLLECTION_VIEW_WIDGET_DEFINITION = {
|
|
|
334
361
|
},
|
|
335
362
|
],
|
|
336
363
|
},
|
|
364
|
+
/*
|
|
365
|
+
* Drag reordering through the bound Provider's action (`itemKeys`, every key in the new order); off
|
|
366
|
+
* in masonry, while a search or a filter narrows the list, and while it spans more than one page.
|
|
367
|
+
*/
|
|
368
|
+
{ key: "features.reorder.enabled", type: "boolean", label: "Drag Reordering" },
|
|
369
|
+
{ key: "features.reorder.actionKey", type: "string", label: "Reorder Action Key", placeholder: "reorder" },
|
|
370
|
+
/*
|
|
371
|
+
* The Media renderer's: where its upload goes and its picker opens (placeholders from the binding
|
|
372
|
+
* params), the kind both offer, and whether only public Assets may be added. Other renderers ignore them.
|
|
373
|
+
*/
|
|
374
|
+
{ key: "features.media.folderPath", type: "string", label: "Media Folder Path", placeholder: "Shop Images / {category}" },
|
|
375
|
+
{
|
|
376
|
+
key: "features.media.mediaType",
|
|
377
|
+
type: "choice",
|
|
378
|
+
label: "Media Kind",
|
|
379
|
+
presentation: "select",
|
|
380
|
+
options: MEDIA_KINDS.map((kind) => ({ value: kind, label: kind })),
|
|
381
|
+
emptyOption: { value: "", label: "Every kind" },
|
|
382
|
+
emptyValue: null,
|
|
383
|
+
},
|
|
337
384
|
{ key: "features.pagination.enabled", type: "boolean", label: "Pagination" },
|
|
338
385
|
{ key: "features.pagination.pageSize", type: "number", label: "Page Size", min: 1, precision: 0 },
|
|
339
386
|
{ key: "features.pagination.compact", type: "boolean", label: "Compact Pagination" },
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { PHI_MEDIA_WIDGET_DEFAULT_LABELS } from "../../../../../components/media/media-widget-labels";
|
|
3
3
|
import { PHI_ASSET_COLLECTION_DATA_SOURCE } from "../../../../../components/media/asset-collection-runtime";
|
|
4
|
+
import { PHI_MEDIA_LIBRARY_ASSET_RESOURCE } from "../../../../../components/media/media-library-resource";
|
|
4
5
|
import { PhiCollectionViewWidget } from "./client";
|
|
5
6
|
export function PhiAssetPreviewGridWidget({ config, labels, mediaLabels, renderMode }) {
|
|
6
7
|
return (_jsx(PhiCollectionViewWidget, { config: {
|
|
@@ -12,5 +13,7 @@ export function PhiAssetPreviewGridWidget({ config, labels, mediaLabels, renderM
|
|
|
12
13
|
},
|
|
13
14
|
features: { tools: { mode: "external" }, pagination: { enabled: false } },
|
|
14
15
|
source: PHI_ASSET_COLLECTION_DATA_SOURCE,
|
|
15
|
-
}, labels: { ...(mediaLabels ?? PHI_MEDIA_WIDGET_DEFAULT_LABELS), grid: labels },
|
|
16
|
+
}, labels: { ...(mediaLabels ?? PHI_MEDIA_WIDGET_DEFAULT_LABELS), grid: labels },
|
|
17
|
+
// No page registry reaches this: the resource's declaration is handed over, so its tiles keep their delete.
|
|
18
|
+
resourceDescriptor: PHI_MEDIA_LIBRARY_ASSET_RESOURCE, renderMode: renderMode }));
|
|
16
19
|
}
|
|
@@ -5,7 +5,7 @@ import { readPhiRuntimeTreeRenderMode } from "../../../render-mode";
|
|
|
5
5
|
import { PHI_COLLECTION_VIEW_WIDGET_DEFINITION, PHI_COLLECTION_VIEW_WIDGET_PLUGIN_TYPE, } from "./config";
|
|
6
6
|
export const PHI_COLLECTION_VIEW_WIDGET_PLUGIN = {
|
|
7
7
|
...PHI_COLLECTION_VIEW_WIDGET_DEFINITION,
|
|
8
|
-
render: ({ widget, runtime, config }) => (_jsx(PhiCollectionViewWidgetServer, { runtime: runtime, config: config, widgetId: widget.id, renderMode: readPhiRuntimeTreeRenderMode(widget.config) }, `widget-${widget.id}`)),
|
|
8
|
+
render: ({ widget, runtime, registry, config }) => (_jsx(PhiCollectionViewWidgetServer, { runtime: runtime, registry: registry, config: config, widgetId: widget.id, renderMode: readPhiRuntimeTreeRenderMode(widget.config) }, `widget-${widget.id}`)),
|
|
9
9
|
renderPreview: ({ widget, runtime, registry, config }) => (_jsx(PhiWidgetInertPreview, { children: _jsx(PhiCollectionViewWidgetServer, { runtime: runtime, registry: registry, config: config, widgetId: widget.id, renderMode: readPhiRuntimeTreeRenderMode(widget.config), preview: true }, `widget-${widget.id}`) })),
|
|
10
10
|
};
|
|
11
11
|
export { PHI_COLLECTION_VIEW_WIDGET_PLUGIN_TYPE };
|
|
@@ -5,7 +5,11 @@ import type { PhiCmsInstanceId } from "../../../../../types/cms-instance-id";
|
|
|
5
5
|
import type { PhiRenderableBlockRenderMode } from "../../../../../types/renderable-block";
|
|
6
6
|
export type PhiCollectionViewWidgetServerProps = {
|
|
7
7
|
runtime: Pick<PhiBlockRuntime, "locale">;
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* The Area's declarations: the preview judges the binding against them, and the live Widget reads the
|
|
10
|
+
* bound resource's declaration there -- its renderer, `itemIdentityPath` and tools. Absent outside a
|
|
11
|
+
* page render.
|
|
12
|
+
*/
|
|
9
13
|
registry?: Pick<PhiCmsRuntimeRenderRegistry, "dataProviderDescriptorsByKey">;
|
|
10
14
|
config?: PhiCmsCollectionViewWidgetConfig | null;
|
|
11
15
|
widgetId?: PhiCmsInstanceId | null;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
|
|
3
|
-
import {
|
|
3
|
+
import { PHI_MEDIA_LIBRARY_ITEM_RENDERER_KEY } from "../../../../../constants/media-library-provider-keys";
|
|
4
4
|
import { getPhiMediaWidgetLabels } from "../../../../../components/media/label-sets/media";
|
|
5
|
+
import { getPhiCollectionViewWidgetLabels } from "../../../../../components/widgets/label-sets/collection-view";
|
|
5
6
|
import { buildPhiWidgetLabelTranslatorOptions } from "../../../../../components/widgets/label-sets/runtime-options";
|
|
6
7
|
import { PhiRuntimeModuleRenderClientHost } from "../../../../../components/runtime/runtime-module-render-client-manifest";
|
|
7
8
|
import { readPhiCollectionViewDeclaredFailure } from "../../../../../components/widgets/shared/collection-source-failure";
|
|
@@ -27,13 +28,29 @@ export async function PhiCollectionViewWidgetServer({ runtime, config, widgetId,
|
|
|
27
28
|
return (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.CollectionView, componentProps: { config, widgetId, renderMode, preview: true } }));
|
|
28
29
|
}
|
|
29
30
|
/*
|
|
30
|
-
* The
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
31
|
+
* The bound resource as the Area's Modules declare it: the renderer it names, the key path of its
|
|
32
|
+
* items (what a reorder sends as `itemKeys`) and the actions, filters and panels its tools may offer.
|
|
33
|
+
* The Provider's Client registration does not carry them, the declaration does, so the Server hands
|
|
34
|
+
* it on and the renderer offers what the resource declares (`PhiCollectionProviderResourceDescriptor`).
|
|
34
35
|
*/
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
const source = config?.source;
|
|
37
|
+
const providerDescriptor = source ? registry?.dataProviderDescriptorsByKey.get(source.providerKey) : undefined;
|
|
38
|
+
const resourceDescriptor = providerDescriptor?.kind === "collection"
|
|
39
|
+
? providerDescriptor.resources.find((resource) => resource.resourceKey === source?.resourceKey) ?? null
|
|
40
|
+
: null;
|
|
41
|
+
const rendererKey = config?.itemRendererKey ?? resourceDescriptor?.itemRendererKey ?? null;
|
|
42
|
+
/*
|
|
43
|
+
* The Media renderer says the Media Label Set's words (the toolbar, the flag filter, the grid, the
|
|
44
|
+
* upload surface) and Core may not import the Asset Module to get them, so they are the Foundation's
|
|
45
|
+
* and loaded here -- for a Widget whose items that renderer draws, whichever Provider it is bound to
|
|
46
|
+
* (the Media library, a gallery of references), and for no other. `config.presentation.labels` still
|
|
47
|
+
* lays over them.
|
|
48
|
+
*/
|
|
49
|
+
const translatorOptions = buildPhiWidgetLabelTranslatorOptions(runtime);
|
|
50
|
+
const [labels, reorderLabels] = await Promise.all([
|
|
51
|
+
rendererKey === PHI_MEDIA_LIBRARY_ITEM_RENDERER_KEY ? getPhiMediaWidgetLabels(translatorOptions) : undefined,
|
|
52
|
+
// The Widget's own words, only for one that offers reordering.
|
|
53
|
+
config?.features.reorder?.enabled ? getPhiCollectionViewWidgetLabels(translatorOptions) : undefined,
|
|
54
|
+
]);
|
|
55
|
+
return (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.CollectionView, componentProps: { config, widgetId, renderMode, preview: false, labels, reorderLabels, resourceDescriptor } }));
|
|
39
56
|
}
|
|
@@ -115,6 +115,10 @@ type PhiCmsPresetTreeForm = {
|
|
|
115
115
|
descriptor: PhiFormDescriptor;
|
|
116
116
|
};
|
|
117
117
|
/**
|
|
118
|
+
* The preset tree contract, enforced: the first of `checkPhiPresetTreeContract`'s findings
|
|
119
|
+
* (`helpers/preset-tree-contract-check.ts`, which a Module runs in its own tests from
|
|
120
|
+
* `@phis/ui/module/page-check`) is thrown, and the Page answers 500.
|
|
121
|
+
*
|
|
118
122
|
* `forms` are the Forms the compiler can see -- the ones the catalog's Modules ship, by id. A Form it
|
|
119
123
|
* cannot see (one stored on the Site, one of a Module outside the catalog) is not judged.
|
|
120
124
|
*/
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import { isPhiCmsAreaKey, resolvePhiCmsAreaMask, } from "../../constants/cms-areas";
|
|
2
2
|
import { collectPhiTourDefinitionErrors } from "../../types/tours";
|
|
3
3
|
import { PhiCmsPageType, PhiCmsRegionType, PhiCmsStatus } from "../../constants/phi-cms";
|
|
4
|
-
import {
|
|
5
|
-
import { createPhiPresetCmsInstanceId, createPhiPresetCmsPageId, isPhiCmsInstanceId, readPhiCmsInstanceIdDescriptor, } from "../../types/cms-instance-id";
|
|
4
|
+
import { createPhiPresetCmsInstanceId, createPhiPresetCmsPageId, readPhiCmsInstanceIdDescriptor, } from "../../types/cms-instance-id";
|
|
6
5
|
import { resolvePhiRuntimeModuleSourceLocale } from "../../types/runtime-module-locale";
|
|
7
6
|
import { canPhiViewerAccess, PHI_VIEWER_ACCESS_ANYONE, } from "../../types/access";
|
|
8
7
|
import { mergePhiCmsShellTrees, omitPhiCmsShellCompositionNodes, } from "./shell-tree-composition";
|
|
9
8
|
import { resolvePhiRuntimeModuleAreaRoutePath } from "../../helpers/runtime-module-route-path";
|
|
10
9
|
import { createPhiPageReference } from "../../types/references";
|
|
11
10
|
import { choosePhiAreaRootApplicant, describePhiAreaShellSettingsError, orderPhiAreaPathClaimsByCover, isPhiAssignablePublicRoutePath, } from "../../helpers/cms-area-config";
|
|
12
|
-
import {
|
|
13
|
-
import { PHI_DIALOG_BLEED_BODY_CONFIG, PHI_DIALOG_BODY_CONFIG, PHI_DIALOG_COMMANDS_CONFIG, PHI_DIALOG_WIDTH, isPhiFormSingleColumn, } from "../../helpers/cms-dialog";
|
|
14
|
-
import { PhiCmsWidgetType } from "../../constants/cms-widget-types";
|
|
15
|
-
import { buildPhiBasePageLayoutNode, PHI_BASE_PAGE_LAYOUT_NODE_ID, } from "../../components/regions/presets/phi-base-page-layout";
|
|
11
|
+
import { checkPhiPresetTreeContract } from "../../helpers/preset-tree-contract-check";
|
|
16
12
|
import { concatPhiCmsTreeControllerSettings } from "../../helpers/cms-tree-controller-settings";
|
|
17
13
|
import { createPhiModuleMediaResolver } from "../../helpers/module-media";
|
|
18
14
|
const PHI_CMS_REGION_TYPE_VALUES = new Set(Object.values(PhiCmsRegionType));
|
|
@@ -1523,150 +1519,18 @@ function createSyntheticPresetPage({ siteId, area, path, flags = 0, }) {
|
|
|
1523
1519
|
layoutConfig: {},
|
|
1524
1520
|
};
|
|
1525
1521
|
}
|
|
1526
|
-
function stablePresetNodeJson(value) {
|
|
1527
|
-
if (Array.isArray(value)) {
|
|
1528
|
-
return `[${value.map(stablePresetNodeJson).join(",")}]`;
|
|
1529
|
-
}
|
|
1530
|
-
if (value && typeof value === "object") {
|
|
1531
|
-
return `{${Object.entries(value)
|
|
1532
|
-
.filter(([, entry]) => entry !== undefined)
|
|
1533
|
-
.sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0))
|
|
1534
|
-
.map(([key, entry]) => `${JSON.stringify(key)}:${stablePresetNodeJson(entry)}`)
|
|
1535
|
-
.join(",")}}`;
|
|
1536
|
-
}
|
|
1537
|
-
return JSON.stringify(value) ?? "undefined";
|
|
1538
|
-
}
|
|
1539
|
-
/**
|
|
1540
|
-
* Equal id must mean equal node: the shared page scaffold carries the same instance id in every
|
|
1541
|
-
* built-in preset tree, which stays sound only while every copy is the canonical node. A preset that
|
|
1542
|
-
* wants different chrome gets its own Layout node in a slot -- a deviating copy of the scaffold is a
|
|
1543
|
-
* contract violation, not a customisation.
|
|
1544
|
-
*/
|
|
1545
|
-
function assertPhiCmsBasePageLayoutNode(tree, layoutsById) {
|
|
1546
|
-
for (const node of [...tree.overlays, ...tree.contentWidgets]) {
|
|
1547
|
-
if (node.id === PHI_BASE_PAGE_LAYOUT_NODE_ID) {
|
|
1548
|
-
throw new Error("The base page layout instance id is reserved for the scaffold Layout node.");
|
|
1549
|
-
}
|
|
1550
|
-
}
|
|
1551
|
-
const node = layoutsById.get(PHI_BASE_PAGE_LAYOUT_NODE_ID);
|
|
1552
|
-
if (!node) {
|
|
1553
|
-
return;
|
|
1554
|
-
}
|
|
1555
|
-
const canonical = buildPhiBasePageLayoutNode(tree.page);
|
|
1556
|
-
const mismatch = Object.keys(canonical)
|
|
1557
|
-
.find((key) => stablePresetNodeJson(node[key]) !== stablePresetNodeJson(canonical[key]));
|
|
1558
|
-
if (mismatch) {
|
|
1559
|
-
throw new Error(`Preset tree carries a deviating base page layout node: "${String(mismatch)}" is ` +
|
|
1560
|
-
`${stablePresetNodeJson(node[mismatch])}, canonical is ${stablePresetNodeJson(canonical[mismatch])}.`);
|
|
1561
|
-
}
|
|
1562
|
-
}
|
|
1563
1522
|
/**
|
|
1523
|
+
* The preset tree contract, enforced: the first of `checkPhiPresetTreeContract`'s findings
|
|
1524
|
+
* (`helpers/preset-tree-contract-check.ts`, which a Module runs in its own tests from
|
|
1525
|
+
* `@phis/ui/module/page-check`) is thrown, and the Page answers 500.
|
|
1526
|
+
*
|
|
1564
1527
|
* `forms` are the Forms the compiler can see -- the ones the catalog's Modules ship, by id. A Form it
|
|
1565
1528
|
* cannot see (one stored on the Site, one of a Module outside the catalog) is not judged.
|
|
1566
1529
|
*/
|
|
1567
1530
|
export function assertPhiCmsPresetTreeContract(tree, expectedPage, forms) {
|
|
1568
|
-
const
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
(tree.page.siteId !== expectedPage.siteId ||
|
|
1572
|
-
tree.page.areaMask !== expectedPage.areaMask ||
|
|
1573
|
-
tree.page.path !== expectedPage.path)) {
|
|
1574
|
-
throw new Error("Preset loader returned a Page outside its requested context.");
|
|
1575
|
-
}
|
|
1576
|
-
for (const node of tree.overlays) {
|
|
1577
|
-
if (!isPhiCmsInstanceId(node.id) || readPhiCmsInstanceIdDescriptor(node.id)?.origin !== "preset") {
|
|
1578
|
-
throw new Error(`Preset Overlay has invalid instance id "${String(node.id)}".`);
|
|
1579
|
-
}
|
|
1580
|
-
if (allIds.has(node.id)) {
|
|
1581
|
-
throw new Error(`Preset tree contains duplicate instance id "${node.id}".`);
|
|
1582
|
-
}
|
|
1583
|
-
allIds.add(node.id);
|
|
1584
|
-
}
|
|
1585
|
-
for (const node of tree.layoutNodes) {
|
|
1586
|
-
if (!isPhiCmsInstanceId(node.id) || readPhiCmsInstanceIdDescriptor(node.id)?.origin !== "preset") {
|
|
1587
|
-
throw new Error(`Preset layout node has invalid instance id "${String(node.id)}".`);
|
|
1588
|
-
}
|
|
1589
|
-
if (allIds.has(node.id)) {
|
|
1590
|
-
throw new Error(`Preset tree contains duplicate instance id "${node.id}".`);
|
|
1591
|
-
}
|
|
1592
|
-
allIds.add(node.id);
|
|
1593
|
-
layoutIds.add(node.id);
|
|
1594
|
-
}
|
|
1595
|
-
for (const node of tree.contentWidgets) {
|
|
1596
|
-
if (!isPhiCmsInstanceId(node.id) || readPhiCmsInstanceIdDescriptor(node.id)?.origin !== "preset") {
|
|
1597
|
-
throw new Error(`Preset widget node has invalid instance id "${String(node.id)}".`);
|
|
1598
|
-
}
|
|
1599
|
-
if (allIds.has(node.id)) {
|
|
1600
|
-
throw new Error(`Preset tree contains duplicate instance id "${node.id}".`);
|
|
1601
|
-
}
|
|
1602
|
-
allIds.add(node.id);
|
|
1603
|
-
}
|
|
1604
|
-
for (const node of tree.layoutNodes) {
|
|
1605
|
-
if (node.parentLayoutNodeId != null && !layoutIds.has(node.parentLayoutNodeId)) {
|
|
1606
|
-
throw new Error(`Preset layout "${node.id}" has unresolved parent "${node.parentLayoutNodeId}".`);
|
|
1607
|
-
}
|
|
1608
|
-
}
|
|
1609
|
-
for (const node of tree.contentWidgets) {
|
|
1610
|
-
if (!layoutIds.has(node.parentLayoutNodeId)) {
|
|
1611
|
-
throw new Error(`Preset widget "${node.id}" has unresolved parent "${node.parentLayoutNodeId}".`);
|
|
1612
|
-
}
|
|
1613
|
-
}
|
|
1614
|
-
for (const region of tree.regions) {
|
|
1615
|
-
if (expectedPage && region.pageId !== expectedPage.id) {
|
|
1616
|
-
throw new Error(`Preset region "${region.regionType}" belongs to a different Page.`);
|
|
1617
|
-
}
|
|
1618
|
-
if (!layoutIds.has(region.rootLayoutNodeId)) {
|
|
1619
|
-
throw new Error(`Preset region "${region.regionType}" has unresolved root "${region.rootLayoutNodeId}".`);
|
|
1620
|
-
}
|
|
1621
|
-
}
|
|
1622
|
-
const layoutsById = new Map(tree.layoutNodes.map((node) => [node.id, node]));
|
|
1623
|
-
assertPhiCmsBasePageLayoutNode(tree, layoutsById);
|
|
1624
|
-
for (const overlay of tree.overlays) {
|
|
1625
|
-
if (!layoutIds.has(overlay.bodyLayoutNodeId)) {
|
|
1626
|
-
throw new Error(`Preset Overlay "${overlay.id}" has unresolved Body root "${overlay.bodyLayoutNodeId}".`);
|
|
1627
|
-
}
|
|
1628
|
-
if (overlay.headerLayoutNodeId != null && !layoutIds.has(overlay.headerLayoutNodeId)) {
|
|
1629
|
-
throw new Error(`Preset Overlay "${overlay.id}" has unresolved Header root "${overlay.headerLayoutNodeId}".`);
|
|
1630
|
-
}
|
|
1631
|
-
if (overlay.footerPresentation === "none") {
|
|
1632
|
-
continue;
|
|
1633
|
-
}
|
|
1634
|
-
const footerLayout = layoutsById.get(overlay.footerLayoutNodeId);
|
|
1635
|
-
if (!footerLayout) {
|
|
1636
|
-
throw new Error(`Preset Overlay "${overlay.id}" has unresolved Footer root "${overlay.footerLayoutNodeId}".`);
|
|
1637
|
-
}
|
|
1638
|
-
if (overlay.footerPresentation === "actions") {
|
|
1639
|
-
if (footerLayout.widgetType !== PhiCmsLayoutType.Flex) {
|
|
1640
|
-
throw new Error(`Preset Overlay "${overlay.id}" actions Footer must use the Phi Flex Layout.`);
|
|
1641
|
-
}
|
|
1642
|
-
const expectedConfig = resolvePhiLayoutCreationPreset("flex", "overlay-actions");
|
|
1643
|
-
const mismatch = Object.entries(expectedConfig).find(([key, value]) => JSON.stringify(footerLayout.config[key]) !== JSON.stringify(value));
|
|
1644
|
-
if (mismatch) {
|
|
1645
|
-
throw new Error(`Preset Overlay "${overlay.id}" actions Footer does not match the canonical Layout preset at "${mismatch[0]}".`);
|
|
1646
|
-
}
|
|
1647
|
-
if (overlay.overlayType === "modal") {
|
|
1648
|
-
assertPhiCmsDialogCommands(overlay.id, footerLayout.id, tree.contentWidgets);
|
|
1649
|
-
}
|
|
1650
|
-
}
|
|
1651
|
-
}
|
|
1652
|
-
for (const overlay of tree.overlays) {
|
|
1653
|
-
if (overlay.overlayType === "modal") {
|
|
1654
|
-
assertPhiCmsDialogBody(overlay.id, layoutsById.get(overlay.bodyLayoutNodeId));
|
|
1655
|
-
if (forms)
|
|
1656
|
-
assertPhiCmsDialogWidth(overlay, tree, forms);
|
|
1657
|
-
}
|
|
1658
|
-
}
|
|
1659
|
-
for (const rootLayoutNodeId of [
|
|
1660
|
-
tree.page.heroRootLayoutNodeId,
|
|
1661
|
-
tree.page.headerBottomRootLayoutNodeId,
|
|
1662
|
-
tree.page.siderRightRootLayoutNodeId,
|
|
1663
|
-
tree.page.footerTopRootLayoutNodeId,
|
|
1664
|
-
tree.page.drawerRightRootLayoutNodeId,
|
|
1665
|
-
tree.page.contentRootLayoutNodeId,
|
|
1666
|
-
]) {
|
|
1667
|
-
if (rootLayoutNodeId != null && !layoutIds.has(rootLayoutNodeId)) {
|
|
1668
|
-
throw new Error(`Preset Page has unresolved root "${rootLayoutNodeId}".`);
|
|
1669
|
-
}
|
|
1531
|
+
const [finding] = checkPhiPresetTreeContract(tree, { page: expectedPage, forms });
|
|
1532
|
+
if (finding) {
|
|
1533
|
+
throw new Error(finding.message);
|
|
1670
1534
|
}
|
|
1671
1535
|
}
|
|
1672
1536
|
function assertPhiCmsAreaOverlayTree(descriptor, tree, page, forms) {
|
|
@@ -1795,62 +1659,3 @@ export async function instantiatePhiCmsRoutePreset({ binding, catalog, activeMod
|
|
|
1795
1659
|
assertPhiCmsPresetTreeContract(tree, page, catalog.formDefinitionsById);
|
|
1796
1660
|
return tree;
|
|
1797
1661
|
}
|
|
1798
|
-
/*
|
|
1799
|
-
* A dialog's body and actions are one answer for every dialog (`helpers/cms-dialog.ts`), checked here as
|
|
1800
|
-
* the footer Layout is: a Preset that builds its dialog node by node must arrive at the same look as one
|
|
1801
|
-
* that calls `dialog`. A vertical Flex carries the whole body config; a Layout of another kind -- a Stack
|
|
1802
|
-
* of tabs -- carries the ground and the inset, which are what make it the dialog's body.
|
|
1803
|
-
*/
|
|
1804
|
-
function assertPhiCmsDialogBody(overlayId, body) {
|
|
1805
|
-
// The bleed body is the other answer, for content that runs to the edge; it is matched whole.
|
|
1806
|
-
const bleed = PHI_DIALOG_BLEED_BODY_CONFIG.padding === body.config.padding;
|
|
1807
|
-
const required = bleed
|
|
1808
|
-
? PHI_DIALOG_BLEED_BODY_CONFIG
|
|
1809
|
-
: body.widgetType === PhiCmsLayoutType.FlexVertical
|
|
1810
|
-
? PHI_DIALOG_BODY_CONFIG
|
|
1811
|
-
: { surface: PHI_DIALOG_BODY_CONFIG.surface, padding: PHI_DIALOG_BODY_CONFIG.padding };
|
|
1812
|
-
const mismatch = Object.entries(required).find(([key, value]) => JSON.stringify(body.config[key]) !== JSON.stringify(value));
|
|
1813
|
-
if (mismatch) {
|
|
1814
|
-
throw new Error(`Preset Overlay "${overlayId}" Body "${body.id}" does not match the dialog body (${bleed ? "PHI_DIALOG_BLEED_BODY_CONFIG" : "PHI_DIALOG_BODY_CONFIG"}) at "${mismatch[0]}".`);
|
|
1815
|
-
}
|
|
1816
|
-
}
|
|
1817
|
-
function assertPhiCmsDialogCommands(overlayId, footerLayoutId, widgets) {
|
|
1818
|
-
for (const widget of widgets) {
|
|
1819
|
-
if (widget.parentLayoutNodeId !== footerLayoutId || widget.widgetType !== PhiCmsWidgetType.CommandToolbar)
|
|
1820
|
-
continue;
|
|
1821
|
-
const mismatch = Object.entries(PHI_DIALOG_COMMANDS_CONFIG).find(([key, value]) => widget.config[key] !== value);
|
|
1822
|
-
if (mismatch) {
|
|
1823
|
-
throw new Error(`Preset Overlay "${overlayId}" actions "${widget.id}" do not match the dialog actions (PHI_DIALOG_COMMANDS_CONFIG) at "${mismatch[0]}".`);
|
|
1824
|
-
}
|
|
1825
|
-
}
|
|
1826
|
-
}
|
|
1827
|
-
/*
|
|
1828
|
-
* A dialog is as wide as its Form needs (`helpers/cms-dialog.ts`): one column takes
|
|
1829
|
-
* `PHI_DIALOG_WIDTH_SINGLE_COLUMN`, two keep `PHI_DIALOG_WIDTH`. What is refused is the one width a Preset
|
|
1830
|
-
* did not choose -- the default, holding nothing but Forms of one column. Any other width was stated, by a
|
|
1831
|
-
* caller that knows what else the body holds; a Form the compiler cannot see is not judged.
|
|
1832
|
-
*/
|
|
1833
|
-
function assertPhiCmsDialogWidth(overlay, tree, forms) {
|
|
1834
|
-
if (stablePresetNodeJson(overlay.config.width) !== stablePresetNodeJson(PHI_DIALOG_WIDTH))
|
|
1835
|
-
return;
|
|
1836
|
-
const bodyLayoutIds = new Set([overlay.bodyLayoutNodeId]);
|
|
1837
|
-
for (let grown = true; grown;) {
|
|
1838
|
-
grown = false;
|
|
1839
|
-
for (const node of tree.layoutNodes) {
|
|
1840
|
-
if (node.parentLayoutNodeId != null && bodyLayoutIds.has(node.parentLayoutNodeId) && !bodyLayoutIds.has(node.id)) {
|
|
1841
|
-
bodyLayoutIds.add(node.id);
|
|
1842
|
-
grown = true;
|
|
1843
|
-
}
|
|
1844
|
-
}
|
|
1845
|
-
}
|
|
1846
|
-
const formIds = tree.contentWidgets
|
|
1847
|
-
.filter((widget) => widget.widgetType === PhiCmsWidgetType.Form && bodyLayoutIds.has(widget.parentLayoutNodeId))
|
|
1848
|
-
.map((widget) => widget.config.formId);
|
|
1849
|
-
if (formIds.length === 0)
|
|
1850
|
-
return;
|
|
1851
|
-
const descriptors = formIds.map((formId) => (typeof formId === "string" ? forms.get(formId) : undefined)?.descriptor);
|
|
1852
|
-
if (descriptors.every((descriptor) => descriptor != null && isPhiFormSingleColumn(descriptor))) {
|
|
1853
|
-
throw new Error(`Preset Overlay "${overlay.id}" holds the one-column Form "${String(formIds[0])}" at the full dialog width ` +
|
|
1854
|
-
"(PHI_DIALOG_WIDTH). Hand the Form to `dialog` as `body.form`, or state `width: PHI_DIALOG_WIDTH_SINGLE_COLUMN`.");
|
|
1855
|
-
}
|
|
1856
|
-
}
|
|
@@ -9,7 +9,8 @@ import { PHI_VIEWER_ACCESS_ANYONE, } from "../../types/access";
|
|
|
9
9
|
import { stripRenderableBlockDefaults } from "../../helpers/renderable-block-serialization";
|
|
10
10
|
import { PhiCmsWidgetType } from "../../constants/cms-widget-types";
|
|
11
11
|
import { parsePhiFormWidgetConfig } from "../../components/forms/form-widget-config";
|
|
12
|
-
import { PHI_MEDIA_ASSET_FORM_FIELD_PROVIDER_KEY, PHI_MEDIA_LIBRARY_DATA_PROVIDER_KEYS, } from "../../constants/media-library-provider-keys";
|
|
12
|
+
import { PHI_MEDIA_ASSET_FORM_FIELD_PROVIDER_KEY, PHI_MEDIA_ASSETS_FORM_FIELD_PROVIDER_KEY, PHI_MEDIA_LIBRARY_DATA_PROVIDER_KEYS, PHI_MEDIA_LIBRARY_ITEM_RENDERER_KEY, } from "../../constants/media-library-provider-keys";
|
|
13
|
+
import { isPhiRecord } from "../../helpers/is-record";
|
|
13
14
|
import { buildPhiRecordDeclarationsByKey } from "../../helpers/record-fields";
|
|
14
15
|
function loadRuntimeWidgetPlugin(entry) {
|
|
15
16
|
return entry.loadRuntime();
|
|
@@ -362,6 +363,18 @@ function collectDataProviderKeysFromValue(value, knownProviderKeys, collected) {
|
|
|
362
363
|
collectDataProviderKeysFromValue(entry, knownProviderKeys, collected);
|
|
363
364
|
}
|
|
364
365
|
}
|
|
366
|
+
/** The renderer a Collection View's items are drawn by: its own `itemRendererKey`, else its resource's. */
|
|
367
|
+
function readPhiCollectionViewItemRendererKey(config, moduleSet) {
|
|
368
|
+
if (typeof config.itemRendererKey === "string" && config.itemRendererKey)
|
|
369
|
+
return config.itemRendererKey;
|
|
370
|
+
const source = isPhiRecord(config.source) ? config.source : null;
|
|
371
|
+
const descriptor = typeof source?.providerKey === "string"
|
|
372
|
+
? moduleSet.dataProviderDescriptorsByKey.get(source.providerKey)
|
|
373
|
+
: undefined;
|
|
374
|
+
return descriptor?.kind === "collection"
|
|
375
|
+
? descriptor.resources.find((resource) => resource.resourceKey === source?.resourceKey)?.itemRendererKey ?? null
|
|
376
|
+
: null;
|
|
377
|
+
}
|
|
365
378
|
export function collectPhiRuntimeDataProviderKeys({ moduleSet, trees, }) {
|
|
366
379
|
/*
|
|
367
380
|
* What the browser mounts. A `record` Provider has no Client half -- it is asked on the server while the
|
|
@@ -381,17 +394,30 @@ export function collectPhiRuntimeDataProviderKeys({ moduleSet, trees, }) {
|
|
|
381
394
|
collected.add(providerKey);
|
|
382
395
|
}
|
|
383
396
|
}
|
|
397
|
+
/*
|
|
398
|
+
* A Collection View the Media renderer draws -- the Media library's own, or another Provider's
|
|
399
|
+
* Collection of Assets whose resource or placement names that renderer -- opens the Media library's
|
|
400
|
+
* picker and its upload wall, which read the library. The renderer is what needs it, so the scan says
|
|
401
|
+
* so here rather than every such resource naming the library's Provider.
|
|
402
|
+
*/
|
|
403
|
+
if (widget.widgetType === PhiCmsWidgetType.CollectionView &&
|
|
404
|
+
knownProviderKeys.has(PHI_MEDIA_LIBRARY_DATA_PROVIDER_KEYS.collection) &&
|
|
405
|
+
readPhiCollectionViewItemRendererKey(widgetConfig, moduleSet) === PHI_MEDIA_LIBRARY_ITEM_RENDERER_KEY) {
|
|
406
|
+
collected.add(PHI_MEDIA_LIBRARY_DATA_PROVIDER_KEYS.collection);
|
|
407
|
+
}
|
|
384
408
|
if (widget.widgetType === PhiCmsWidgetType.Form) {
|
|
385
409
|
const formId = parsePhiFormWidgetConfig(widgetConfig).formId;
|
|
386
410
|
const form = formId ? moduleSet.formDefinitionsById.get(formId) : null;
|
|
387
411
|
if (form) {
|
|
388
412
|
collectDataProviderKeysFromValue(form.descriptor, knownProviderKeys, collected);
|
|
389
413
|
/*
|
|
390
|
-
* A `media-asset` field reads the Media library through the picker,
|
|
391
|
-
* no Provider of its own to find it by. The
|
|
392
|
-
* once, here, instead of every Form that has
|
|
414
|
+
* A `media-asset` field reads the Media library through the picker, a `media-assets` field its
|
|
415
|
+
* tiles and picker too, and a field descriptor names no Provider of its own to find it by. The
|
|
416
|
+
* field type is what needs it, so the scan says so once, here, instead of every Form that has
|
|
417
|
+
* one repeating the Provider in its descriptor.
|
|
393
418
|
*/
|
|
394
|
-
if (form.descriptor.fields.some((field) => field.fieldProviderKey === PHI_MEDIA_ASSET_FORM_FIELD_PROVIDER_KEY
|
|
419
|
+
if (form.descriptor.fields.some((field) => field.fieldProviderKey === PHI_MEDIA_ASSET_FORM_FIELD_PROVIDER_KEY ||
|
|
420
|
+
field.fieldProviderKey === PHI_MEDIA_ASSETS_FORM_FIELD_PROVIDER_KEY) &&
|
|
395
421
|
knownProviderKeys.has(PHI_MEDIA_LIBRARY_DATA_PROVIDER_KEYS.collection)) {
|
|
396
422
|
collected.add(PHI_MEDIA_LIBRARY_DATA_PROVIDER_KEYS.collection);
|
|
397
423
|
}
|
|
@@ -96,6 +96,13 @@ export type PhiCollectionProviderActionRequest = {
|
|
|
96
96
|
itemKey?: string | number | null;
|
|
97
97
|
item?: Record<string, unknown> | null;
|
|
98
98
|
selectedItemKeys?: (string | number)[];
|
|
99
|
+
/**
|
|
100
|
+
* Every item key of the collection, in the order a reader dragged them into (`collection-view`'s
|
|
101
|
+
* `features.reorder`): the whole collection, never a page of it or a search's share. Sent with the
|
|
102
|
+
* reorder action's key; the Provider stores the order or refuses, and answers the collection as it
|
|
103
|
+
* now stands.
|
|
104
|
+
*/
|
|
105
|
+
itemKeys?: (string | number)[];
|
|
99
106
|
query?: PhiCollectionProviderQuery;
|
|
100
107
|
params?: Record<string, unknown>;
|
|
101
108
|
signal: AbortSignal;
|
|
@@ -4,6 +4,7 @@ import type { PhiCollectionProviderQuery } from "./collection-provider";
|
|
|
4
4
|
import type { PhiProviderResourceSource } from "./runtime-data-provider";
|
|
5
5
|
import type { PhiSignalRouteSet } from "./signals";
|
|
6
6
|
import type { PhiCssLength } from "./length";
|
|
7
|
+
import type { PhiMediaKindValue } from "./media";
|
|
7
8
|
import type { PhiCmsWidgetConfigBase } from "../components/widgets/config/parser-primitives";
|
|
8
9
|
/**
|
|
9
10
|
* A Collection View's parsed config, as the item renderer it hands its items to receives it.
|
|
@@ -41,6 +42,35 @@ export type PhiCmsCollectionViewWidgetConfig = PhiCmsWidgetConfigBase & {
|
|
|
41
42
|
actions?: {
|
|
42
43
|
toolbar?: PhiCmsCollectionToolbarActionPresentation[];
|
|
43
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* Drag reordering of the items, written back through the bound Provider's action `actionKey`
|
|
47
|
+
* (`"reorder"` by default) with every item key in the new order (`itemKeys`). The Widget stores no
|
|
48
|
+
* order: the Provider's is the order, applied at once on a drop and taken back if refused. Offered
|
|
49
|
+
* in `grid` and `stack` only, and only while the whole collection is shown -- no search text, no
|
|
50
|
+
* filter set apart from the Widget's own initial query, everything on one page.
|
|
51
|
+
*/
|
|
52
|
+
reorder?: {
|
|
53
|
+
enabled: boolean;
|
|
54
|
+
actionKey?: string;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Read by the Media renderer (`PHI_MEDIA_LIBRARY_ITEM_RENDERER_KEY`) and by no other, whichever
|
|
58
|
+
* Provider it draws: where an upload from its upload panel goes and where its "Choose from Media
|
|
59
|
+
* library" picker opens, and what both offer.
|
|
60
|
+
*/
|
|
61
|
+
media?: {
|
|
62
|
+
/**
|
|
63
|
+
* A Folder of the Site Space by its path of names ("Shop Images / {category} / {product}"): an
|
|
64
|
+
* upload goes into it, the missing Folders created, and the picker opens on the deepest of it that
|
|
65
|
+
* is there. `{key}` is the binding param `key` (`source.params` with what `bindingParamsChange`
|
|
66
|
+
* laid over them): a text or a number, trimmed, a `/` in it a `-`, and a name whose placeholder has
|
|
67
|
+
* no value left out whole (`resolvePhiMediaFolderPathTemplate`). Absent: for the Media library's
|
|
68
|
+
* own Collection the Folder its listing has open, for any other the root of the Site Space.
|
|
69
|
+
*/
|
|
70
|
+
folderPath?: string;
|
|
71
|
+
/** The one kind the upload takes and the picker lists. Absent: the upload takes every kind, the picker lists images. */
|
|
72
|
+
mediaType?: PhiMediaKindValue;
|
|
73
|
+
};
|
|
44
74
|
pagination?: {
|
|
45
75
|
enabled: boolean;
|
|
46
76
|
pageSize?: number;
|
|
@@ -8,6 +8,7 @@ import type { PhiRuntimeConditionExpression } from "./runtime-condition";
|
|
|
8
8
|
import type { PhiSignalRoute, PhiSignalValue } from "./signals";
|
|
9
9
|
import type { PhiCssLength } from "./length";
|
|
10
10
|
import type { PhiControlSize } from "./control";
|
|
11
|
+
import type { PhiMediaKindValue } from "./media";
|
|
11
12
|
import type { PhiCollectionProviderQuery } from "./collection-provider";
|
|
12
13
|
import type { PhiProviderResourceSource } from "./runtime-data-provider";
|
|
13
14
|
import type { PhiFormId } from "./form-id";
|
|
@@ -384,6 +385,19 @@ export type PhiCollectionViewWidgetPlacement = PhiWidgetPlacementBase & {
|
|
|
384
385
|
actions?: {
|
|
385
386
|
toolbar?: PhiCmsCollectionToolbarActionPresentation[];
|
|
386
387
|
};
|
|
388
|
+
/** Drag reordering through the bound Provider's action (`PhiCmsCollectionViewWidgetConfig`). */
|
|
389
|
+
reorder?: {
|
|
390
|
+
enabled: boolean;
|
|
391
|
+
actionKey?: string;
|
|
392
|
+
};
|
|
393
|
+
/**
|
|
394
|
+
* The Media renderer's upload Folder (`{param}` from the binding params) and the kind it takes and its
|
|
395
|
+
* picker lists (`PhiCmsCollectionViewWidgetConfig`).
|
|
396
|
+
*/
|
|
397
|
+
media?: {
|
|
398
|
+
folderPath?: string;
|
|
399
|
+
mediaType?: PhiMediaKindValue;
|
|
400
|
+
};
|
|
387
401
|
pagination?: {
|
|
388
402
|
enabled: boolean;
|
|
389
403
|
pageSize?: number;
|
package/types/media.d.ts
CHANGED
|
@@ -137,6 +137,22 @@ export type PhiMediaAssetTile = {
|
|
|
137
137
|
font: PhiFontMetrics | null;
|
|
138
138
|
folder?: Pick<PhiMediaAssetFolder, "id" | "name"> | null;
|
|
139
139
|
};
|
|
140
|
+
/**
|
|
141
|
+
* An item of a Collection the Media library's renderer draws (`PHI_MEDIA_LIBRARY_ITEM_RENDERER_KEY`), of
|
|
142
|
+
* whichever Provider: what a Media tile reads of an Asset (`PhiMediaAssetTileControlAsset` is this without
|
|
143
|
+
* `folderId`), keyed by the Asset id (`id`, so the resource's `itemIdentityPath` is `"id"`). `kind` is the
|
|
144
|
+
* Media kind of `contentType` (`resolvePhiMediaKindFromContentType`); `deliveryPolicy` and
|
|
145
|
+
* `lifecycleStatus` say whether a visitor is served it, which the tile shows. `folderId` is read where an
|
|
146
|
+
* item has one, for the lock of its Folder; a Collection of references to Assets leaves it out. The
|
|
147
|
+
* renderer reads every item strictly (`readPhiMediaCollectionItems`): an item without one of the
|
|
148
|
+
* required fields is a failure naming the field, never a tile with a filler. `deliveryUrl` is empty for a
|
|
149
|
+
* reference whose Asset the library no longer answers; the tile shows the kind's icon.
|
|
150
|
+
*
|
|
151
|
+
* A whole `PhiMediaAssetTile` -- the Media library's own Collection -- is one of these.
|
|
152
|
+
*/
|
|
153
|
+
export type PhiMediaCollectionItem = Pick<PhiMediaAssetTile, "id" | "kind" | "originalName" | "title" | "altText" | "contentType" | "deliveryUrl" | "thumbnailUrl" | "previewUrl" | "deliveryPolicy" | "lifecycleStatus" | "width" | "height" | "blurDataUrl"> & {
|
|
154
|
+
folderId?: number | null;
|
|
155
|
+
};
|
|
140
156
|
export type PhiMediaPickerState = {
|
|
141
157
|
query: string;
|
|
142
158
|
folderId: number | null;
|