@phis/ui 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/components/controls/phi-border-control.js +1 -1
- package/components/controls/phi-bound-radius-control.js +9 -9
- package/components/controls/phi-brand-control.js +1 -1
- package/components/controls/phi-drawer-control-adapter.js +4 -4
- package/components/controls/phi-dropdown-control.js +2 -2
- package/components/controls/phi-form-control.js +1 -1
- package/components/controls/phi-image-control.js +1 -1
- package/components/controls/phi-mask-picker-control.js +6 -6
- package/components/controls/phi-select-control.js +1 -1
- package/components/controls/phi-theme-scope-control.js +1 -1
- package/components/controls/use-phi-color-control-presets.js +2 -2
- package/components/forms/compound-form-controls.js +2 -2
- package/components/forms/extended-form-field-controls.js +1 -1
- package/components/forms/shared-form-provider-registry.js +2 -2
- package/components/layouts/clients/phi-flex-layout-client.js +4 -4
- package/components/layouts/clients/phi-grid-layout-client.js +3 -3
- package/components/layouts/clients/phi-sequence-slot-editor.js +1 -1
- package/components/layouts/layout-definitions.d.ts +4 -4
- package/components/layouts/phi-page-region-layout.js +1 -1
- package/components/layouts/phi-structure-region-layout.js +3 -3
- package/components/media/phi-asset-focal-rect-widget.js +4 -4
- package/components/media/phi-asset-inspector-section.js +1 -1
- package/components/media/phi-media-kind-icon.js +2 -2
- package/components/media/phi-media-restricted-icon.js +1 -1
- package/components/overlays/phi-overlay-container-client.js +1 -1
- package/components/regions/presets/phi-base-page-column.js +6 -2
- package/components/root/phi-config-provider.js +1 -1
- package/components/root/phi-root-background.js +1 -1
- package/components/root/phi-root-theme-resolver.js +1 -1
- package/components/shell/phi-module-icons.js +1 -1
- package/components/widgets/built-in/builder-workspace-preview.js +8 -8
- package/components/widgets/client/bullet-list-entries-editor.js +2 -2
- package/components/widgets/client/external-document-editor.js +1 -1
- package/components/widgets/client/html-editor.js +3 -3
- package/components/widgets/config/background.d.ts +1 -1
- package/components/widgets/config/background.js +1 -1
- package/components/widgets/inspector-field-row.js +1 -1
- package/components/widgets/label-sets/inspector.js +2 -0
- package/components/widgets/label-types/inspector.d.ts +1 -0
- package/components/widgets/label-types/inspector.js +1 -0
- package/components/widgets/shared/card-body-client.js +1 -1
- package/components/widgets/shared/result-body-client.js +1 -1
- package/constants/media-library-provider-keys.d.ts +8 -1
- package/constants/media-library-provider-keys.js +8 -1
- package/constants/record-field-kinds.d.ts +6 -0
- package/constants/record-field-kinds.js +7 -0
- package/constants/runtime-module-ownership.js +1 -1
- package/helpers/border-widget-style.d.ts +2 -2
- package/helpers/border-widget-style.js +2 -2
- package/helpers/cms-dialog.d.ts +4 -4
- package/helpers/cms-layout-defaults.d.ts +2 -2
- package/helpers/cms-page-catalog.d.ts +5 -0
- package/helpers/cms-preset-page-tree.d.ts +4 -0
- package/helpers/cms-preset-page-tree.js +2 -0
- package/helpers/layout-style.d.ts +2 -2
- package/helpers/page-layout-check.d.ts +4 -1
- package/helpers/page-layout-check.js +26 -0
- package/helpers/record-fields.d.ts +9 -0
- package/helpers/record-fields.js +84 -0
- package/helpers/surface-presets.d.ts +6 -6
- package/helpers/surface-style.d.ts +1 -1
- package/helpers.d.ts +0 -1
- package/helpers.js +0 -2
- package/module-page-check.d.ts +12 -0
- package/module-page-check.js +12 -0
- package/module-records.d.ts +4 -2
- package/module-records.js +3 -1
- package/next/antd-form-context-loader.mjs +31 -0
- package/next/config.d.mts +2 -0
- package/next/config.mjs +36 -3
- package/package.json +10 -1
- package/plugins/runtime-modules/asset/data-providers.d.ts +0 -65
- package/plugins/runtime-modules/asset/data-providers.js +0 -40
- package/plugins/runtime-modules/asset/definition.d.ts +0 -60
- package/plugins/runtime-modules/asset/ids.d.ts +0 -1
- package/plugins/runtime-modules/asset/ids.js +1 -2
- package/plugins/runtime-modules/asset/presets.d.ts +1 -0
- package/plugins/runtime-modules/asset/server.js +0 -5
- package/plugins/runtime-modules/blog/presets.d.ts +1 -0
- package/plugins/runtime-modules/builder/clients/inspector-config-field.d.ts +4 -1
- package/plugins/runtime-modules/builder/clients/inspector-config-field.js +13 -4
- package/plugins/runtime-modules/builder/clients/inspector-link-target-field.js +1 -1
- package/plugins/runtime-modules/builder/clients/inspector-section-widget.js +14 -1
- package/plugins/runtime-modules/builder/clients/inspector-signal-section.js +2 -2
- package/plugins/runtime-modules/builder/clients/layout-inspector.js +1 -1
- package/plugins/runtime-modules/builder/clients/layout-scaffold-buttons.js +4 -4
- package/plugins/runtime-modules/builder/clients/layout-scaffold-overlays.js +1 -1
- package/plugins/runtime-modules/builder/clients/region-inspector.js +1 -1
- package/plugins/runtime-modules/builder/clients/region-visibility-fields.js +1 -1
- package/plugins/runtime-modules/builder/clients/shells-workspace.js +1 -1
- package/plugins/runtime-modules/builder/clients/structure-canvas.js +2 -2
- package/plugins/runtime-modules/builder/clients/widget-effects-editor.js +1 -1
- package/plugins/runtime-modules/builder/clients/widget-inspector.d.ts +4 -1
- package/plugins/runtime-modules/builder/clients/widget-inspector.js +3 -2
- package/plugins/runtime-modules/builder/page-presets.server.d.ts +6 -0
- package/plugins/runtime-modules/builder/page-presets.server.js +8 -0
- package/plugins/runtime-modules/builder/pages-workspace.js +12 -1
- package/plugins/runtime-modules/builder/render-root-node-scaffold.js +5 -5
- package/plugins/runtime-modules/builder/structure-dnd.js +2 -2
- package/plugins/runtime-modules/builder/widgets/test-block/client.js +1 -1
- package/plugins/runtime-modules/content-entry-routes.d.ts +1 -0
- package/plugins/runtime-modules/contracts.d.ts +1 -1
- package/plugins/runtime-modules/contracts.js +41 -1
- package/plugins/runtime-modules/core/data-providers.d.ts +60 -0
- package/plugins/runtime-modules/core/data-providers.js +41 -0
- package/plugins/runtime-modules/core/definition.d.ts +55 -0
- package/plugins/runtime-modules/core/server.js +5 -0
- package/plugins/runtime-modules/core/widgets/button/config.d.ts +34 -0
- package/plugins/runtime-modules/core/widgets/button/config.js +16 -0
- package/plugins/runtime-modules/core/widgets/button/plugin.js +37 -6
- package/plugins/runtime-modules/core/widgets/card/config.d.ts +13 -2
- package/plugins/runtime-modules/core/widgets/description/config.d.ts +13 -2
- package/plugins/runtime-modules/core/widgets/description/editor.js +13 -13
- package/plugins/runtime-modules/core/widgets/entry-list/config.d.ts +11 -0
- package/plugins/runtime-modules/core/widgets/gallery/client.d.ts +4 -1
- package/plugins/runtime-modules/core/widgets/gallery/client.js +29 -21
- package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +16 -0
- package/plugins/runtime-modules/core/widgets/gallery/config.js +16 -0
- package/plugins/runtime-modules/core/widgets/gallery/server.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/gallery/server.js +11 -0
- package/plugins/runtime-modules/core/widgets/image/config.d.ts +35 -0
- package/plugins/runtime-modules/core/widgets/image/config.js +8 -0
- package/plugins/runtime-modules/core/widgets/image/plugin.js +19 -1
- package/plugins/runtime-modules/core/widgets/image/server.d.ts +3 -1
- package/plugins/runtime-modules/core/widgets/image/server.js +2 -2
- package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +13 -0
- package/plugins/runtime-modules/core/widgets/markdown/config.js +8 -0
- package/plugins/runtime-modules/core/widgets/markdown/editor.js +7 -7
- package/plugins/runtime-modules/core/widgets/markdown/plugin.js +20 -7
- package/plugins/runtime-modules/core/widgets/record/authoring.js +1 -1
- package/plugins/runtime-modules/core/widgets/result/config.d.ts +11 -0
- package/plugins/runtime-modules/core/widgets/simple-text/config.d.ts +13 -0
- package/plugins/runtime-modules/core/widgets/simple-text/config.js +9 -0
- package/plugins/runtime-modules/core/widgets/simple-text/editor.js +1 -1
- package/plugins/runtime-modules/core/widgets/simple-text/plugin.js +14 -1
- package/plugins/runtime-modules/core/widgets/spacer/client.js +1 -1
- package/plugins/runtime-modules/core/widgets/table/config.d.ts +37 -0
- package/plugins/runtime-modules/descriptor-compiler.js +8 -0
- package/plugins/runtime-modules/editor/presets.d.ts +1 -0
- package/plugins/runtime-modules/groups/definition.d.ts +1 -1
- package/plugins/runtime-modules/localization/presets.d.ts +1 -0
- package/plugins/runtime-modules/news/presets.d.ts +1 -0
- package/plugins/runtime-modules/resolver.js +2 -0
- package/plugins/runtime-modules/revisions/presets.d.ts +1 -0
- package/plugins/runtime-modules/theme/presets.d.ts +1 -0
- package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +25 -2
- package/server-helpers/cms-page-record.d.ts +26 -0
- package/server-helpers/cms-page-record.js +42 -0
- package/server-helpers/cms-request.js +48 -4
- package/server-helpers/record-fields.d.ts +62 -0
- package/server-helpers/record-fields.js +87 -0
- package/server-helpers/record-samples.d.ts +21 -0
- package/server-helpers/record-samples.js +41 -0
- package/styles/builder-scaffold.css +19 -19
- package/styles/controls.css +109 -109
- package/styles/gradients.css +23 -23
- package/styles/layout-affordances.css +15 -15
- package/styles/layout-authoring-scaffold.css +20 -20
- package/styles/layout.css +9 -9
- package/styles/root.css +4 -4
- package/styles/shell.css +48 -17
- package/theme/antd-css-var-contract.d.ts +86 -80
- package/theme/antd-css-var-contract.js +92 -81
- package/theme/phi-control-shape.d.ts +1 -1
- package/theme/phi-theme-gradients.d.ts +2 -2
- package/theme/phi-theme-gradients.js +14 -14
- package/theme/phi-theme-palette.d.ts +1 -1
- package/theme/phi-theme-palette.js +2 -2
- package/theme/phi-theme-tokens.d.ts +8 -5
- package/theme/phi-theme-tokens.js +59 -28
- package/theme/phi-theme.d.ts +14 -2
- package/theme/phi-theme.js +14 -1
- package/theme/phi-tokens.d.ts +5 -0
- package/theme/phi-tokens.js +9 -0
- package/types/cms-module-descriptors.d.ts +6 -0
- package/types/cms-plugins.d.ts +19 -1
- package/types/core-widget-placements.d.ts +10 -0
- package/types/record-provider.d.ts +92 -0
- package/types/widget-runtime.d.ts +5 -0
- /package/plugins/runtime-modules/{asset/services/folder-images.server.d.ts → core/services/media-folder-images.server.d.ts} +0 -0
- /package/plugins/runtime-modules/{asset/services/folder-images.server.js → core/services/media-folder-images.server.js} +0 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import type { PhiBlockRuntime } from "../types";
|
|
3
|
+
import type { PhiCmsRuntimeRenderRegistry } from "../types/cms-plugins";
|
|
4
|
+
import type { PhiRecordField, PhiRecordFieldKind } from "../types/record-provider";
|
|
5
|
+
import type { PhiRuntimeDataProviderBinding } from "../types/runtime-data-provider";
|
|
6
|
+
type PhiRecordFieldsRegistry = Pick<PhiCmsRuntimeRenderRegistry, "recordProviderLoadersByKey" | "recordFieldsLoadersByKey" | "dataProviderDescriptorsByKey">;
|
|
7
|
+
/**
|
|
8
|
+
* The declared fields of one record (MODULES.md, "The fields of a record, and the record a Page is about").
|
|
9
|
+
*
|
|
10
|
+
* `none` is a Page that is about no record, or a binding to a Provider that declares no fields: a Widget
|
|
11
|
+
* bound to a field there has nothing to show and is not at fault. `missing` and `unavailable` are the
|
|
12
|
+
* record's own two failures, as `resolvePhiRecordSource` tells them apart.
|
|
13
|
+
*/
|
|
14
|
+
export type PhiPageRecordFieldsResult = {
|
|
15
|
+
status: "ok";
|
|
16
|
+
fields: ReadonlyMap<string, PhiRecordField>;
|
|
17
|
+
} | {
|
|
18
|
+
status: "none";
|
|
19
|
+
} | {
|
|
20
|
+
status: "missing";
|
|
21
|
+
} | {
|
|
22
|
+
status: "unavailable";
|
|
23
|
+
reason: string;
|
|
24
|
+
};
|
|
25
|
+
/** The declared fields of the record a binding names, read once per request for the same record. */
|
|
26
|
+
export declare function resolvePhiRecordFields({ registry, runtime, binding }: {
|
|
27
|
+
registry: PhiRecordFieldsRegistry;
|
|
28
|
+
runtime: PhiBlockRuntime;
|
|
29
|
+
binding: PhiRuntimeDataProviderBinding | null | undefined;
|
|
30
|
+
}): Promise<PhiPageRecordFieldsResult>;
|
|
31
|
+
/** The declared fields of the record this Page is about (`runtime.page.record`). */
|
|
32
|
+
export declare function resolvePhiPageRecordFields({ registry, runtime }: {
|
|
33
|
+
registry: PhiRecordFieldsRegistry;
|
|
34
|
+
runtime: PhiBlockRuntime;
|
|
35
|
+
}): Promise<PhiPageRecordFieldsResult>;
|
|
36
|
+
/** One field of a result, if the record has it and it is of one of the kinds asked for. */
|
|
37
|
+
export declare function readPhiPageRecordField<K extends PhiRecordFieldKind>(result: PhiPageRecordFieldsResult, key: string | null | undefined, kinds: readonly K[]): Extract<PhiRecordField, {
|
|
38
|
+
kind: K;
|
|
39
|
+
}> | null;
|
|
40
|
+
/**
|
|
41
|
+
* What a Widget that names a field of the page record is to draw.
|
|
42
|
+
*
|
|
43
|
+
* `bound: false` is a Widget that names none, or a Page that is about no record -- a template open in the
|
|
44
|
+
* Builder, a Widget copied to an ordinary Page: it draws its own content, which stands in for the field.
|
|
45
|
+
* `bound: true` with no field is a record that does not have it, and the Widget draws nothing of its own
|
|
46
|
+
* in its place.
|
|
47
|
+
*/
|
|
48
|
+
export type PhiWidgetRecordField<K extends PhiRecordFieldKind> = {
|
|
49
|
+
bound: false;
|
|
50
|
+
} | {
|
|
51
|
+
bound: true;
|
|
52
|
+
field: Extract<PhiRecordField, {
|
|
53
|
+
kind: K;
|
|
54
|
+
}> | null;
|
|
55
|
+
};
|
|
56
|
+
export declare function resolvePhiWidgetRecordField<K extends PhiRecordFieldKind>({ registry, runtime, key, kinds }: {
|
|
57
|
+
registry: PhiRecordFieldsRegistry | undefined;
|
|
58
|
+
runtime: PhiBlockRuntime;
|
|
59
|
+
key: string | null | undefined;
|
|
60
|
+
kinds: readonly K[];
|
|
61
|
+
}): Promise<PhiWidgetRecordField<K>>;
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { logRuntimeEvent } from "../net/log";
|
|
3
|
+
import { readPhiRecordFieldValue } from "../helpers/record-fields";
|
|
4
|
+
import { phiRuntime } from "./phi-runtime";
|
|
5
|
+
import { resolvePhiRecordSource } from "./record-source";
|
|
6
|
+
import { definePhiRequestMemoWith } from "./request-memo";
|
|
7
|
+
const resolveFields = definePhiRequestMemoWith(async (key, using) => {
|
|
8
|
+
const providerKey = key.providerKey;
|
|
9
|
+
const descriptor = using.registry.dataProviderDescriptorsByKey.get(providerKey);
|
|
10
|
+
const declared = descriptor?.kind === "record" ? descriptor.record?.fields : undefined;
|
|
11
|
+
const loadFields = using.registry.recordFieldsLoadersByKey.get(providerKey);
|
|
12
|
+
if (!declared || !loadFields) {
|
|
13
|
+
return { status: "none" };
|
|
14
|
+
}
|
|
15
|
+
const source = await resolvePhiRecordSource({
|
|
16
|
+
registry: using.registry,
|
|
17
|
+
runtime: using.runtime,
|
|
18
|
+
binding: { providerKey, params: key.params },
|
|
19
|
+
});
|
|
20
|
+
if (source.status !== "ok") {
|
|
21
|
+
return source;
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const read = await loadFields();
|
|
25
|
+
const values = await read(source.record, {
|
|
26
|
+
apiBaseUrl: using.apiBaseUrl,
|
|
27
|
+
internalToken: using.internalToken,
|
|
28
|
+
siteKey: key.siteKey,
|
|
29
|
+
locale: key.locale,
|
|
30
|
+
runtime: using.runtime,
|
|
31
|
+
});
|
|
32
|
+
const fields = new Map();
|
|
33
|
+
for (const field of declared) {
|
|
34
|
+
const raw = values[field.key];
|
|
35
|
+
if (raw === undefined || raw === null)
|
|
36
|
+
continue;
|
|
37
|
+
const value = readPhiRecordFieldValue(field.kind, raw);
|
|
38
|
+
if (value === undefined) {
|
|
39
|
+
logRuntimeEvent("warn", "cms.record.field_invalid", {
|
|
40
|
+
message: `Record provider "${key.providerKey}" answered field "${field.key}" with a value that is no ${field.kind}.`,
|
|
41
|
+
siteKey: key.siteKey,
|
|
42
|
+
area: using.runtime.area,
|
|
43
|
+
meta: { providerKey: key.providerKey, field: field.key, kind: field.kind },
|
|
44
|
+
});
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
fields.set(field.key, { kind: field.kind, value });
|
|
48
|
+
}
|
|
49
|
+
return { status: "ok", fields };
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
logRuntimeEvent("error", "cms.record.fields_failed", {
|
|
53
|
+
message: `Failed to read the fields of record provider "${key.providerKey}" for this render.`,
|
|
54
|
+
siteKey: key.siteKey,
|
|
55
|
+
area: using.runtime.area,
|
|
56
|
+
error,
|
|
57
|
+
meta: { providerKey: key.providerKey },
|
|
58
|
+
});
|
|
59
|
+
return { status: "unavailable", reason: error instanceof Error ? error.message : String(error) };
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
/** The declared fields of the record a binding names, read once per request for the same record. */
|
|
63
|
+
export function resolvePhiRecordFields({ registry, runtime, binding }) {
|
|
64
|
+
if (!binding) {
|
|
65
|
+
return Promise.resolve({ status: "none" });
|
|
66
|
+
}
|
|
67
|
+
const rt = phiRuntime(runtime);
|
|
68
|
+
return resolveFields({ providerKey: binding.providerKey, params: binding.params ?? {}, siteKey: rt.siteKey, locale: runtime.locale.current }, { registry, runtime, apiBaseUrl: rt.apiBaseUrl, internalToken: rt.internalToken });
|
|
69
|
+
}
|
|
70
|
+
/** The declared fields of the record this Page is about (`runtime.page.record`). */
|
|
71
|
+
export function resolvePhiPageRecordFields({ registry, runtime }) {
|
|
72
|
+
return resolvePhiRecordFields({ registry, runtime, binding: runtime.page?.record });
|
|
73
|
+
}
|
|
74
|
+
/** One field of a result, if the record has it and it is of one of the kinds asked for. */
|
|
75
|
+
export function readPhiPageRecordField(result, key, kinds) {
|
|
76
|
+
if (result.status !== "ok" || !key)
|
|
77
|
+
return null;
|
|
78
|
+
const field = result.fields.get(key);
|
|
79
|
+
return field && kinds.includes(field.kind) ? field : null;
|
|
80
|
+
}
|
|
81
|
+
export async function resolvePhiWidgetRecordField({ registry, runtime, key, kinds }) {
|
|
82
|
+
if (!key || !registry) {
|
|
83
|
+
return { bound: false };
|
|
84
|
+
}
|
|
85
|
+
const result = await resolvePhiPageRecordFields({ registry, runtime });
|
|
86
|
+
return result.status === "none" ? { bound: false } : { bound: true, field: readPhiPageRecordField(result, key, kinds) };
|
|
87
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import type { PhiBlockRuntime } from "../types";
|
|
3
|
+
import type { PhiCmsRuntimeRenderRegistry } from "../types/cms-plugins";
|
|
4
|
+
import type { PhiCmsPageRecordDescriptor } from "../types/record-provider";
|
|
5
|
+
import type { PhiRuntimeDataProviderBinding } from "../types/runtime-data-provider";
|
|
6
|
+
type PhiRecordSamplesRegistry = Pick<PhiCmsRuntimeRenderRegistry, "recordSamplesLoadersByKey">;
|
|
7
|
+
/**
|
|
8
|
+
* The record the Builder's Preview shows a template with (MODULES.md, "The fields of a record, and the
|
|
9
|
+
* record a Page is about"): the first sample the route's record Provider offers, as the binding a Page
|
|
10
|
+
* about a record carries.
|
|
11
|
+
*
|
|
12
|
+
* A sample's `params` are the Provider's own parameters (`{ slug: "chair" }`), not the route's, so they
|
|
13
|
+
* become the binding as they are. `null` is a Provider that offers no samples or none now, or one whose
|
|
14
|
+
* reader fails: the template then previews with its Widgets' own content, as it does in the Editor.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolvePhiPageRecordSampleBinding({ registry, runtime, pageRecord }: {
|
|
17
|
+
registry: PhiRecordSamplesRegistry;
|
|
18
|
+
runtime: PhiBlockRuntime;
|
|
19
|
+
pageRecord: PhiCmsPageRecordDescriptor;
|
|
20
|
+
}): Promise<PhiRuntimeDataProviderBinding | null>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { logRuntimeEvent } from "../net/log";
|
|
3
|
+
import { phiRuntime } from "./phi-runtime";
|
|
4
|
+
/**
|
|
5
|
+
* The record the Builder's Preview shows a template with (MODULES.md, "The fields of a record, and the
|
|
6
|
+
* record a Page is about"): the first sample the route's record Provider offers, as the binding a Page
|
|
7
|
+
* about a record carries.
|
|
8
|
+
*
|
|
9
|
+
* A sample's `params` are the Provider's own parameters (`{ slug: "chair" }`), not the route's, so they
|
|
10
|
+
* become the binding as they are. `null` is a Provider that offers no samples or none now, or one whose
|
|
11
|
+
* reader fails: the template then previews with its Widgets' own content, as it does in the Editor.
|
|
12
|
+
*/
|
|
13
|
+
export async function resolvePhiPageRecordSampleBinding({ registry, runtime, pageRecord }) {
|
|
14
|
+
const loadSamples = registry.recordSamplesLoadersByKey.get(pageRecord.providerKey);
|
|
15
|
+
if (!loadSamples) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const rt = phiRuntime(runtime);
|
|
19
|
+
try {
|
|
20
|
+
const read = await loadSamples();
|
|
21
|
+
const samples = await read({
|
|
22
|
+
apiBaseUrl: rt.apiBaseUrl,
|
|
23
|
+
internalToken: rt.internalToken,
|
|
24
|
+
siteKey: rt.siteKey,
|
|
25
|
+
locale: runtime.locale.current,
|
|
26
|
+
runtime,
|
|
27
|
+
});
|
|
28
|
+
const sample = samples[0];
|
|
29
|
+
return sample ? { providerKey: pageRecord.providerKey, params: sample.params } : null;
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
logRuntimeEvent("warn", "cms.record.samples_failed", {
|
|
33
|
+
message: `Failed to read the samples of record provider "${pageRecord.providerKey}" for the Preview.`,
|
|
34
|
+
siteKey: rt.siteKey,
|
|
35
|
+
area: runtime.area,
|
|
36
|
+
error,
|
|
37
|
+
meta: { providerKey: pageRecord.providerKey },
|
|
38
|
+
});
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -82,46 +82,46 @@
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
:where(.phi-builder-structure-region__slot[data-phi-builder-region-mode="editor"][data-phi-region-slot]) {
|
|
85
|
-
border: 1px dashed var(--
|
|
85
|
+
border: 1px dashed var(--phi-color-border-secondary);
|
|
86
86
|
/* Half-transparent: an unauthored Region has no ground, and the Theme Root Background stays visible. */
|
|
87
|
-
background: color-mix(in srgb, var(--
|
|
88
|
-
box-shadow: inset 0 0 0 1px var(--
|
|
87
|
+
background: color-mix(in srgb, var(--phi-color-bg-container) 50%, transparent);
|
|
88
|
+
box-shadow: inset 0 0 0 1px var(--phi-color-border-secondary);
|
|
89
89
|
padding: 0;
|
|
90
90
|
gap: 0;
|
|
91
91
|
cursor: pointer;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
:where(.phi-builder-structure-region__slot[data-phi-builder-region-mode="editor"]:not([data-phi-region-slot])) {
|
|
95
|
-
padding: var(--
|
|
96
|
-
gap: var(--
|
|
95
|
+
padding: var(--phi-padding-xs);
|
|
96
|
+
gap: var(--phi-padding-xs);
|
|
97
97
|
cursor: pointer;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
:where(.phi-builder-structure-region__slot[data-phi-builder-region-mode="editor"][data-phi-region-slot][data-phi-builder-region-selected="true"]) {
|
|
101
|
-
border-color: var(--
|
|
102
|
-
box-shadow: inset 0 0 0 1px var(--
|
|
101
|
+
border-color: var(--phi-color-primary);
|
|
102
|
+
box-shadow: inset 0 0 0 1px var(--phi-color-primary);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
:where(.phi-builder-structure-region__slot[data-phi-builder-region-mode="editor"][data-phi-region-slot][data-phi-builder-region-picking="true"]) {
|
|
106
|
-
border-color: var(--
|
|
107
|
-
background: var(--
|
|
108
|
-
box-shadow: inset 0 0 0 1px var(--
|
|
106
|
+
border-color: var(--phi-color-primary);
|
|
107
|
+
background: var(--phi-color-fill-quaternary);
|
|
108
|
+
box-shadow: inset 0 0 0 1px var(--phi-color-primary);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
:where(.phi-builder-structure-region__slot[data-phi-builder-region-mode="editor"][data-phi-region-slot][data-phi-structure-drop-state="accepted"]) {
|
|
112
|
-
border-color: var(--
|
|
113
|
-
background: var(--
|
|
114
|
-
box-shadow: inset 0 0 0 2px var(--
|
|
112
|
+
border-color: var(--phi-color-success) !important;
|
|
113
|
+
background: var(--phi-color-success-bg) !important;
|
|
114
|
+
box-shadow: inset 0 0 0 2px var(--phi-color-success) !important;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
:where(.phi-builder-structure-region__slot[data-phi-builder-region-mode="editor"][data-phi-region-slot][data-phi-structure-drop-state="rejected"]) {
|
|
118
|
-
border-color: var(--
|
|
119
|
-
background: var(--
|
|
120
|
-
box-shadow: inset 0 0 0 2px var(--
|
|
118
|
+
border-color: var(--phi-color-error) !important;
|
|
119
|
+
background: var(--phi-color-error-bg) !important;
|
|
120
|
+
box-shadow: inset 0 0 0 2px var(--phi-color-error) !important;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
:where(.phi-builder-structure-region__slot[data-phi-builder-region-mode="preview"][data-phi-region-slot]) {
|
|
124
|
-
border: 1px dashed var(--
|
|
124
|
+
border: 1px dashed var(--phi-color-border-secondary);
|
|
125
125
|
/* Preview mirrors the live Shell, where an unauthored Region is transparent. */
|
|
126
126
|
background: transparent;
|
|
127
127
|
box-shadow: none;
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
:where(.phi-builder-workspace-region-scaffold) {
|
|
143
|
-
--phi-builder-region-padding: var(--
|
|
143
|
+
--phi-builder-region-padding: var(--phi-padding-xs);
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
:where(.phi-builder-structure-region--full-height) {
|
|
@@ -280,7 +280,7 @@
|
|
|
280
280
|
gap: 8px;
|
|
281
281
|
min-width: 0;
|
|
282
282
|
min-height: 0;
|
|
283
|
-
padding: var(--
|
|
283
|
+
padding: var(--phi-padding-sm);
|
|
284
284
|
box-sizing: border-box;
|
|
285
285
|
pointer-events: none;
|
|
286
286
|
}
|