@phis/ui 0.5.2 → 0.5.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/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-cascader-control.d.ts +9 -1
- package/components/controls/phi-cascader-control.js +25 -3
- 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-money-control.d.ts +39 -0
- package/components/controls/phi-money-control.js +34 -0
- package/components/controls/phi-number-control.d.ts +6 -1
- package/components/controls/phi-number-control.js +3 -3
- package/components/controls/phi-options-provider.d.ts +7 -0
- package/components/controls/phi-options-provider.js +11 -0
- 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.d.ts +1 -0
- package/components/forms/extended-form-field-controls.js +24 -2
- package/components/forms/form-descriptor-runtime-client.js +13 -0
- package/components/forms/form-provider-contract.d.ts +43 -0
- package/components/forms/form-provider-contract.js +40 -0
- package/components/forms/money-field.d.ts +27 -0
- package/components/forms/money-field.js +78 -0
- package/components/forms/shared-form-provider-registry.js +6 -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-picker-binding.js +6 -1
- package/components/media/phi-media-restricted-icon.js +1 -1
- package/components/media/phi-site-font-assets.js +6 -1
- package/components/motion/phi-sequence-run.d.ts +14 -1
- package/components/motion/phi-sequence-run.js +22 -3
- package/components/motion/phi-sequence-viewport.js +3 -1
- package/components/overlays/phi-overlay-container-client.js +1 -1
- package/components/regions/presets/content-entry-editor-page-tree.js +3 -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/tables/client/phi-table-binding.js +16 -3
- package/components/trees/client/phi-tree-binding.js +6 -2
- 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/client/shared/phi-collection-view-binding.js +10 -2
- package/components/widgets/client/shared/phi-rendered-value.d.ts +9 -1
- package/components/widgets/client/shared/phi-rendered-value.js +20 -1
- package/components/widgets/config/background.d.ts +1 -1
- package/components/widgets/config/background.js +1 -1
- package/components/widgets/config/choice-shared.d.ts +2 -2
- package/components/widgets/inspector-field-row.js +1 -1
- package/components/widgets/label-sets/gallery.js +6 -0
- package/components/widgets/label-sets/inspector.js +2 -0
- package/components/widgets/label-sets/interval.d.ts +4 -0
- package/components/widgets/label-sets/interval.js +31 -0
- package/components/widgets/label-sets/record.js +6 -1
- package/components/widgets/label-sets/slot-upload.d.ts +4 -0
- package/components/widgets/label-sets/slot-upload.js +36 -0
- package/components/widgets/label-sets/table.js +6 -1
- package/components/widgets/label-types/gallery.d.ts +7 -0
- package/components/widgets/label-types/gallery.js +6 -0
- package/components/widgets/label-types/inspector.d.ts +1 -0
- package/components/widgets/label-types/inspector.js +1 -0
- package/components/widgets/label-types/interval.d.ts +16 -0
- package/components/widgets/label-types/interval.js +21 -0
- package/components/widgets/label-types/record.d.ts +3 -0
- package/components/widgets/label-types/record.js +2 -0
- package/components/widgets/label-types/slot-upload.d.ts +24 -0
- package/components/widgets/label-types/slot-upload.js +16 -0
- package/components/widgets/label-types/table.d.ts +3 -0
- package/components/widgets/label-types/table.js +2 -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 +2 -1
- package/controls.d.ts +7 -0
- package/controls.js +4 -0
- package/helpers/border-widget-style.d.ts +2 -2
- package/helpers/border-widget-style.js +2 -2
- package/helpers/cms-dialog.d.ts +43 -7
- package/helpers/cms-dialog.js +46 -4
- package/helpers/cms-layout-defaults.d.ts +2 -2
- package/helpers/cms-page-catalog.d.ts +13 -0
- package/helpers/cms-page-catalog.js +18 -2
- package/helpers/cms-preset-nodes.d.ts +13 -3
- package/helpers/cms-preset-nodes.js +3 -2
- 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/money-amount.d.ts +48 -0
- package/helpers/money-amount.js +131 -0
- package/helpers/page-layout-check.d.ts +4 -1
- package/helpers/page-layout-check.js +41 -2
- package/helpers/record-fields.d.ts +22 -0
- package/helpers/record-fields.js +109 -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 +7 -2
- package/module-records.js +5 -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 +11 -2
- package/plugins/runtime-modules/accounting/module.d.ts +1 -1
- package/plugins/runtime-modules/app/module.d.ts +1 -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/asset/services/collection.js +1 -0
- package/plugins/runtime-modules/asset/trees/phi-default-builder-media-page-tree.js +2 -2
- package/plugins/runtime-modules/auth/trees/phi-default-admin-auth-settings-page-tree.js +3 -0
- 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/offered-page-catalog.js +3 -3
- package/plugins/runtime-modules/builder/options-providers.js +7 -0
- 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/trees/phi-default-builder-area-preset-tree.js +6 -3
- 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.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 +98 -0
- package/plugins/runtime-modules/core/form-providers.d.ts +43 -0
- package/plugins/runtime-modules/core/server.js +5 -0
- package/plugins/runtime-modules/core/widgets/breadcrumb/client.d.ts +6 -3
- package/plugins/runtime-modules/core/widgets/breadcrumb/client.js +6 -5
- package/plugins/runtime-modules/core/widgets/breadcrumb/plugin.js +1 -1
- package/plugins/runtime-modules/core/widgets/breadcrumb/server.d.ts +9 -1
- package/plugins/runtime-modules/core/widgets/breadcrumb/server.js +29 -3
- 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/cascader/authoring.d.ts +3 -3
- package/plugins/runtime-modules/core/widgets/cascader/client.js +1 -1
- package/plugins/runtime-modules/core/widgets/cascader/config.d.ts +8 -2
- package/plugins/runtime-modules/core/widgets/cascader/config.js +22 -0
- package/plugins/runtime-modules/core/widgets/checkbox-group/config.d.ts +1 -1
- 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/authoring.js +12 -3
- package/plugins/runtime-modules/core/widgets/gallery/client.d.ts +4 -1
- package/plugins/runtime-modules/core/widgets/gallery/client.js +38 -21
- package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +18 -0
- package/plugins/runtime-modules/core/widgets/gallery/config.js +24 -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/multi-select/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/record/authoring.js +1 -1
- package/plugins/runtime-modules/core/widgets/record/client.js +8 -2
- package/plugins/runtime-modules/core/widgets/record/config.js +4 -0
- package/plugins/runtime-modules/core/widgets/result/config.d.ts +11 -0
- package/plugins/runtime-modules/core/widgets/segmented/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/select-box/config.d.ts +1 -1
- 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/slot-upload/authoring.js +2 -1
- package/plugins/runtime-modules/core/widgets/slot-upload/client.d.ts +3 -1
- package/plugins/runtime-modules/core/widgets/slot-upload/client.js +45 -24
- package/plugins/runtime-modules/core/widgets/slot-upload/config.d.ts +12 -4
- package/plugins/runtime-modules/core/widgets/slot-upload/config.js +18 -1
- package/plugins/runtime-modules/core/widgets/slot-upload/plugin.js +4 -2
- package/plugins/runtime-modules/core/widgets/slot-upload/server.d.ts +9 -3
- package/plugins/runtime-modules/core/widgets/slot-upload/server.js +17 -3
- package/plugins/runtime-modules/core/widgets/spacer/client.js +1 -1
- package/plugins/runtime-modules/core/widgets/steps/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/table/client.js +4 -4
- package/plugins/runtime-modules/core/widgets/table/config.d.ts +37 -0
- package/plugins/runtime-modules/core/widgets/table/config.js +3 -0
- package/plugins/runtime-modules/descriptor-compiler.d.ts +11 -1
- package/plugins/runtime-modules/descriptor-compiler.js +57 -8
- package/plugins/runtime-modules/editor/presets.d.ts +1 -0
- package/plugins/runtime-modules/groups/definition.d.ts +1 -1
- package/plugins/runtime-modules/groups/forms.d.ts +18 -0
- package/plugins/runtime-modules/groups/forms.js +2 -2
- package/plugins/runtime-modules/groups/trees/phi-default-admin-groups-page-tree.js +6 -4
- package/plugins/runtime-modules/localization/presets.d.ts +1 -0
- package/plugins/runtime-modules/news/presets.d.ts +1 -0
- package/plugins/runtime-modules/public/module.d.ts +1 -1
- package/plugins/runtime-modules/resolver.js +7 -0
- package/plugins/runtime-modules/revisions/presets.d.ts +1 -0
- package/plugins/runtime-modules/revisions/trees/phi-default-builder-revisions-page-tree.js +2 -2
- package/plugins/runtime-modules/theme/presets.d.ts +1 -0
- package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +25 -2
- package/plugins/runtime-modules/threads/trees/phi-default-threads-page-tree.js +4 -2
- package/plugins/runtime-modules/user-management/controller/client.js +6 -1
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +3 -3
- package/runtime-render-client.d.ts +1 -1
- package/runtime-render-client.js +2 -1
- package/server-helpers/cms-page-record.d.ts +26 -0
- package/server-helpers/cms-page-record.js +52 -0
- package/server-helpers/cms-request.js +48 -4
- package/server-helpers/record-fields.d.ts +62 -0
- package/server-helpers/record-fields.js +86 -0
- package/server-helpers/record-samples.d.ts +21 -0
- package/server-helpers/record-samples.js +49 -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 +9 -0
- package/types/cms-plugins.d.ts +27 -1
- package/types/collection-provider.d.ts +7 -0
- package/types/core-widget-placements.d.ts +42 -0
- package/types/record-provider.d.ts +109 -1
- package/types/table-widget.d.ts +33 -1
- package/types/table-widget.js +1 -0
- package/types/tree-widget.d.ts +7 -0
- package/types/widget-runtime.d.ts +5 -0
- package/types.d.ts +1 -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
|
@@ -9,7 +9,7 @@ import { createPhiSignalAddress, createPhiSignalSubcontrolAddress, PHI_SIGNAL_VA
|
|
|
9
9
|
import { createPhiUserManagementControllerAddress, PHI_USER_MANAGEMENT_CONTROLLER_INSTANCE_KEY, PHI_USER_MANAGEMENT_CONTROLLER_TYPE, } from "../controller/address";
|
|
10
10
|
import { PHI_USER_MANAGEMENT_FORM_IDS } from "../forms";
|
|
11
11
|
import { PHI_USER_MANAGEMENT_PAGE_LAYOUT_IDS, PHI_USER_MANAGEMENT_PAGE_OVERLAY_IDS, PHI_USER_MANAGEMENT_PAGE_WIDGET_IDS, } from "../addresses";
|
|
12
|
-
import { PHI_DIALOG_BODY_CONFIG, PHI_DIALOG_COMMANDS_CONFIG } from "../../../../helpers/cms-dialog";
|
|
12
|
+
import { PHI_DIALOG_BODY_CONFIG, PHI_DIALOG_COMMANDS_CONFIG, PHI_DIALOG_WIDTH_SINGLE_COLUMN, } from "../../../../helpers/cms-dialog";
|
|
13
13
|
import { buildPhiWidgetLabelTranslatorOptions } from "../../../../components/widgets/label-sets/runtime-options";
|
|
14
14
|
const SYNTHETIC_ADMIN_USERS_REGION_IDS = {
|
|
15
15
|
regionContent: -431,
|
|
@@ -200,8 +200,8 @@ export async function buildPhiDefaultAdminUsersPageTree({ page, runtime, }) {
|
|
|
200
200
|
},
|
|
201
201
|
}],
|
|
202
202
|
overlays: [
|
|
203
|
-
overlay(PHI_USER_MANAGEMENT_PAGE_OVERLAY_IDS.overlayCreate, PHI_USER_MANAGEMENT_PAGE_LAYOUT_IDS.layoutCreate, widgetLabels.editor.addTitle,
|
|
204
|
-
overlay(PHI_USER_MANAGEMENT_PAGE_OVERLAY_IDS.overlayEdit, PHI_USER_MANAGEMENT_PAGE_LAYOUT_IDS.layoutEdit, widgetLabels.editor.editTitle,
|
|
203
|
+
overlay(PHI_USER_MANAGEMENT_PAGE_OVERLAY_IDS.overlayCreate, PHI_USER_MANAGEMENT_PAGE_LAYOUT_IDS.layoutCreate, widgetLabels.editor.addTitle, PHI_DIALOG_WIDTH_SINGLE_COLUMN, "admin-users-create-modal", "create"),
|
|
204
|
+
overlay(PHI_USER_MANAGEMENT_PAGE_OVERLAY_IDS.overlayEdit, PHI_USER_MANAGEMENT_PAGE_LAYOUT_IDS.layoutEdit, widgetLabels.editor.editTitle, PHI_DIALOG_WIDTH_SINGLE_COLUMN, "admin-users-edit-modal", "edit"),
|
|
205
205
|
overlay(PHI_USER_MANAGEMENT_PAGE_OVERLAY_IDS.overlayHistory, PHI_USER_MANAGEMENT_PAGE_LAYOUT_IDS.layoutHistory, widgetLabels.history.title, { compact: "calc(100vw - 32px)", medium: "90vw", wide: 980 }, "admin-users-history-modal"),
|
|
206
206
|
],
|
|
207
207
|
regions: [scaffold.region],
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { PhiRuntimeModuleRenderClientHost, PhiRuntimeModuleRenderClientManifestProvider, createPhiRuntimeModuleRenderClientManifest, definePhiRuntimeModuleRenderClient, extendPhiRuntimeModuleRenderClientManifest, } from "./components/runtime/runtime-module-render-client-manifest";
|
|
2
2
|
export type { PhiRuntimeModuleRenderClient, PhiRuntimeModuleRenderClientManifest, PhiRuntimeModuleRenderClientProps, } from "./components/runtime/runtime-module-render-client-manifest";
|
|
3
|
-
export { usePhiIntlLocale } from "./components/root/phi-intl-locale";
|
|
3
|
+
export { usePhiIntlLocale, usePhiIntlTimeZone } from "./components/root/phi-intl-locale";
|
package/runtime-render-client.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { PhiRuntimeModuleRenderClientHost, PhiRuntimeModuleRenderClientManifestProvider, createPhiRuntimeModuleRenderClientManifest, definePhiRuntimeModuleRenderClient, extendPhiRuntimeModuleRenderClientManifest, } from "./components/runtime/runtime-module-render-client-manifest";
|
|
2
|
-
|
|
2
|
+
// The page's language and the Site's time zone, which a Module's own binding sends with a Provider request.
|
|
3
|
+
export { usePhiIntlLocale, usePhiIntlTimeZone } from "./components/root/phi-intl-locale";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import type { PhiBlockRuntime } from "../types";
|
|
3
|
+
import type { PhiCmsRoutePresetBinding } from "../types/cms-module-descriptors";
|
|
4
|
+
import type { PhiRuntimeModuleCatalog, PhiRuntimeModuleId } from "../types/cms-plugins";
|
|
5
|
+
import type { PhiPageRecordBinding } from "../types/record-provider";
|
|
6
|
+
/**
|
|
7
|
+
* The record a route's Page is about, read before anything is drawn (MODULES.md, "The fields of a record,
|
|
8
|
+
* and the record a Page is about").
|
|
9
|
+
*
|
|
10
|
+
* `missing` is an address that names no record: the caller answers 404. An unavailable Provider is not
|
|
11
|
+
* that -- the Page is drawn, its Widgets say what they could not read, and the title stays the route's.
|
|
12
|
+
*/
|
|
13
|
+
export type PhiCmsPageRecord = {
|
|
14
|
+
status: "missing";
|
|
15
|
+
} | {
|
|
16
|
+
status: "ok";
|
|
17
|
+
binding: PhiPageRecordBinding;
|
|
18
|
+
title: string | null;
|
|
19
|
+
description: string | null;
|
|
20
|
+
};
|
|
21
|
+
export declare function resolvePhiCmsPageRecord({ binding, runtime, runtimeModuleCatalog, activeModuleIds }: {
|
|
22
|
+
binding: PhiCmsRoutePresetBinding;
|
|
23
|
+
runtime: PhiBlockRuntime;
|
|
24
|
+
runtimeModuleCatalog: PhiRuntimeModuleCatalog;
|
|
25
|
+
activeModuleIds: ReadonlySet<PhiRuntimeModuleId>;
|
|
26
|
+
}): Promise<PhiCmsPageRecord | null>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { buildPhiRecordDeclarationsByKey } from "../helpers/record-fields";
|
|
3
|
+
import { readPhiPageRecordField, resolvePhiRecordFields } from "./record-fields";
|
|
4
|
+
import { resolvePhiRecordSource } from "./record-source";
|
|
5
|
+
/** What the record Providers of the active Modules offer, as a render's registry holds it. */
|
|
6
|
+
function buildRecordRegistry(runtimeModuleCatalog, activeModuleIds) {
|
|
7
|
+
const entries = [...activeModuleIds].flatMap((moduleId) => {
|
|
8
|
+
const entry = runtimeModuleCatalog.get(moduleId);
|
|
9
|
+
return entry ? [entry] : [];
|
|
10
|
+
});
|
|
11
|
+
return {
|
|
12
|
+
recordProviderLoadersByKey: new Map(entries.flatMap((entry) => (entry.recordProviders ?? []).map((provider) => [provider.key, provider.load]))),
|
|
13
|
+
recordFieldsLoadersByKey: new Map(entries.flatMap((entry) => (entry.recordProviders ?? []).flatMap((provider) => provider.loadFields ? [[provider.key, provider.loadFields]] : []))),
|
|
14
|
+
recordDeclarationsByKey: buildPhiRecordDeclarationsByKey(entries),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export async function resolvePhiCmsPageRecord({ binding, runtime, runtimeModuleCatalog, activeModuleIds }) {
|
|
18
|
+
const declaration = binding.descriptor.pageRecord;
|
|
19
|
+
if (!declaration) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const route = `${binding.descriptor.ownerModuleId}/${binding.descriptor.presetKey}`;
|
|
23
|
+
const registry = buildRecordRegistry(runtimeModuleCatalog, activeModuleIds);
|
|
24
|
+
const declared = registry.recordDeclarationsByKey.get(declaration.providerKey);
|
|
25
|
+
if (!declared) {
|
|
26
|
+
throw new Error(`${route}: its page record names "${declaration.providerKey}", which is no active record Provider with declared fields.`);
|
|
27
|
+
}
|
|
28
|
+
// A Public page is rendered once for everybody, so it cannot be about what only one account may read.
|
|
29
|
+
if (declared.audience === "viewer" && binding.descriptor.area === "public") {
|
|
30
|
+
throw new Error(`${route}: a Public route cannot be about a record of audience "viewer".`);
|
|
31
|
+
}
|
|
32
|
+
const record = {
|
|
33
|
+
providerKey: declaration.providerKey,
|
|
34
|
+
params: Object.fromEntries(Object.entries(declaration.params).map(([name, routeParam]) => [name, binding.params[routeParam] ?? ""])),
|
|
35
|
+
};
|
|
36
|
+
const source = await resolvePhiRecordSource({ registry, runtime, binding: record });
|
|
37
|
+
if (source.status === "missing") {
|
|
38
|
+
return { status: "missing" };
|
|
39
|
+
}
|
|
40
|
+
const fields = await resolvePhiRecordFields({ registry, runtime, binding: record });
|
|
41
|
+
const text = (key) => readPhiPageRecordField(fields, key, ["text"])?.value.trim() || null;
|
|
42
|
+
/*
|
|
43
|
+
* The Page's binding is the read's own, plus the two names the route gave. They are added after the
|
|
44
|
+
* reads and the reads were keyed by `record`, so the names are no part of what is asked or memoised.
|
|
45
|
+
*/
|
|
46
|
+
const pageBinding = {
|
|
47
|
+
...record,
|
|
48
|
+
...(declaration.titleField ? { titleField: declaration.titleField } : {}),
|
|
49
|
+
...(declaration.descriptionField ? { descriptionField: declaration.descriptionField } : {}),
|
|
50
|
+
};
|
|
51
|
+
return { status: "ok", binding: pageBinding, title: text(declaration.titleField), description: text(declaration.descriptionField) };
|
|
52
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "server-only";
|
|
2
2
|
import { cache } from "react";
|
|
3
|
+
import { notFound } from "next/navigation";
|
|
3
4
|
import { resolvePhiCmsAreaKey, resolvePhiCmsAreaMask, } from "../constants/cms-areas";
|
|
4
5
|
import { canPhiViewerAccess } from "../types/access";
|
|
5
6
|
import { compilePhiCmsActiveRouteTable, instantiatePhiCmsRoutePreset, normalizePhiCmsRoutePath, resolvePhiCmsAreaShellPresetBinding, resolvePhiCmsDescriptorCatalog, resolvePhiCmsRoutePreset, } from "../plugins/runtime-modules/descriptor-compiler";
|
|
@@ -14,6 +15,7 @@ import { logRuntimeEvent } from "../net/log";
|
|
|
14
15
|
import { getPhiCmsPage, getPhiExactSiteArea } from "./cms";
|
|
15
16
|
import { buildPhiLocalCmsAreaPayload } from "./cms-area";
|
|
16
17
|
import { applyPhiPresetTreePublishedContent } from "./cms-bound-content";
|
|
18
|
+
import { resolvePhiCmsPageRecord } from "./cms-page-record";
|
|
17
19
|
import { resolvePhiAreaPageReferencePath, resolvePhiAreaRootRouteDecision } from "./area-root-route";
|
|
18
20
|
import { fetchSiteNavigationFolderTarget } from "../gateway/site-nav";
|
|
19
21
|
import { applyPhiAreaRootRouteDecision, buildPhiFolderAddressRedirectPage } from "../helpers/cms-area-root-route";
|
|
@@ -134,7 +136,25 @@ function mapResolvedPageToRequestedContext(pagePayload, areaMask, path) {
|
|
|
134
136
|
},
|
|
135
137
|
};
|
|
136
138
|
}
|
|
137
|
-
|
|
139
|
+
/** The record's own title and description on the Page; `msgId: 0`, because they are no Site message. */
|
|
140
|
+
function applyPhiPageRecordMeta(pagePayload, record) {
|
|
141
|
+
if (!record.title && !record.description) {
|
|
142
|
+
return pagePayload;
|
|
143
|
+
}
|
|
144
|
+
const field = (value) => ({ msgId: 0, source: value, value });
|
|
145
|
+
const pageMeta = pagePayload.page.pageMeta;
|
|
146
|
+
return {
|
|
147
|
+
...pagePayload,
|
|
148
|
+
page: {
|
|
149
|
+
...pagePayload.page,
|
|
150
|
+
pageMeta: {
|
|
151
|
+
title: record.title ? field(record.title) : pageMeta?.title ?? null,
|
|
152
|
+
description: record.description ? field(record.description) : pageMeta?.description ?? null,
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function buildPhiRuntimePage(pagePayload, record) {
|
|
138
158
|
const pageMeta = pagePayload.page.pageMeta;
|
|
139
159
|
return {
|
|
140
160
|
path: pagePayload.page.page.path,
|
|
@@ -144,6 +164,7 @@ function buildPhiRuntimePage(pagePayload) {
|
|
|
144
164
|
title: pageMeta?.title?.value ?? null,
|
|
145
165
|
description: pageMeta?.description?.value ?? null,
|
|
146
166
|
noindex: hasPhiFlag(pagePayload.page.page.flags, PhiCmsFlags.NoIndex),
|
|
167
|
+
...(record ? { record } : {}),
|
|
147
168
|
};
|
|
148
169
|
}
|
|
149
170
|
export async function resolvePhiCmsRequest({ siteKey, locale, area, path, cookieHeader, apiBaseUrl, internalToken, requestContext, searchParams, loadResolvedCmsPage, loadExactCmsArea, runtimeModuleCatalog, purpose = "render", }) {
|
|
@@ -232,6 +253,29 @@ export async function resolvePhiCmsRequest({ siteKey, locale, area, path, cookie
|
|
|
232
253
|
activeModuleKeys,
|
|
233
254
|
}),
|
|
234
255
|
});
|
|
256
|
+
/*
|
|
257
|
+
* The record the Page is about, where its route names one: read once, here, for the Module's own tree
|
|
258
|
+
* and for a stored override of it alike -- the override holds no address, only Widgets bound to the
|
|
259
|
+
* record's fields. A Page stored at this exact address is its own and about no record. An address that
|
|
260
|
+
* names no record is no Page: a 404 while rendering, nothing for a lookup.
|
|
261
|
+
*/
|
|
262
|
+
const routeIsParametrised = routeBinding ? Object.keys(routeBinding.params).length > 0 : false;
|
|
263
|
+
const routePresetAnswered = loadedPage?.sourcePreset?.presetKey === routeBinding?.descriptor.presetKey
|
|
264
|
+
&& loadedPage?.sourcePreset?.ownerModuleId === routeBinding?.descriptor.ownerModuleId;
|
|
265
|
+
const pageRecord = loadedPage && routeBinding && routeIsParametrised && routePresetAnswered
|
|
266
|
+
? await resolvePhiCmsPageRecord({
|
|
267
|
+
binding: routeBinding,
|
|
268
|
+
runtime: runtimeWithAuthProvider,
|
|
269
|
+
runtimeModuleCatalog,
|
|
270
|
+
activeModuleIds: activeModuleKeys,
|
|
271
|
+
})
|
|
272
|
+
: null;
|
|
273
|
+
if (pageRecord?.status === "missing") {
|
|
274
|
+
if (purpose === "lookup") {
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
notFound();
|
|
278
|
+
}
|
|
235
279
|
/*
|
|
236
280
|
* The Area root, as the Builder configured it.
|
|
237
281
|
*
|
|
@@ -294,13 +338,13 @@ export async function resolvePhiCmsRequest({ siteKey, locale, area, path, cookie
|
|
|
294
338
|
const effectivePage = resolvedPage
|
|
295
339
|
? mapResolvedPageToRequestedContext(resolvedPage, areaMask, path)
|
|
296
340
|
: null;
|
|
297
|
-
|
|
298
|
-
if (!resolvedContent) {
|
|
341
|
+
if (!effectivePage) {
|
|
299
342
|
return null;
|
|
300
343
|
}
|
|
344
|
+
const resolvedContent = pageRecord ? applyPhiPageRecordMeta(effectivePage, pageRecord) : effectivePage;
|
|
301
345
|
const resolvedRuntime = {
|
|
302
346
|
...runtimeWithAuthProvider,
|
|
303
|
-
page: buildPhiRuntimePage(resolvedContent),
|
|
347
|
+
page: buildPhiRuntimePage(resolvedContent, pageRecord?.binding),
|
|
304
348
|
};
|
|
305
349
|
if (purpose === "lookup") {
|
|
306
350
|
return {
|
|
@@ -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" | "recordDeclarationsByKey">;
|
|
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,86 @@
|
|
|
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 declared = using.registry.recordDeclarationsByKey.get(providerKey)?.fields;
|
|
10
|
+
const loadFields = using.registry.recordFieldsLoadersByKey.get(providerKey);
|
|
11
|
+
if (!declared || !loadFields) {
|
|
12
|
+
return { status: "none" };
|
|
13
|
+
}
|
|
14
|
+
const source = await resolvePhiRecordSource({
|
|
15
|
+
registry: using.registry,
|
|
16
|
+
runtime: using.runtime,
|
|
17
|
+
binding: { providerKey, params: key.params },
|
|
18
|
+
});
|
|
19
|
+
if (source.status !== "ok") {
|
|
20
|
+
return source;
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
const read = await loadFields();
|
|
24
|
+
const values = await read(source.record, {
|
|
25
|
+
apiBaseUrl: using.apiBaseUrl,
|
|
26
|
+
internalToken: using.internalToken,
|
|
27
|
+
siteKey: key.siteKey,
|
|
28
|
+
locale: key.locale,
|
|
29
|
+
runtime: using.runtime,
|
|
30
|
+
});
|
|
31
|
+
const fields = new Map();
|
|
32
|
+
for (const field of declared) {
|
|
33
|
+
const raw = values[field.key];
|
|
34
|
+
if (raw === undefined || raw === null)
|
|
35
|
+
continue;
|
|
36
|
+
const value = readPhiRecordFieldValue(field.kind, raw);
|
|
37
|
+
if (value === undefined) {
|
|
38
|
+
logRuntimeEvent("warn", "cms.record.field_invalid", {
|
|
39
|
+
message: `Record provider "${key.providerKey}" answered field "${field.key}" with a value that is no ${field.kind}.`,
|
|
40
|
+
siteKey: key.siteKey,
|
|
41
|
+
area: using.runtime.area,
|
|
42
|
+
meta: { providerKey: key.providerKey, field: field.key, kind: field.kind },
|
|
43
|
+
});
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
fields.set(field.key, { kind: field.kind, value });
|
|
47
|
+
}
|
|
48
|
+
return { status: "ok", fields };
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
logRuntimeEvent("error", "cms.record.fields_failed", {
|
|
52
|
+
message: `Failed to read the fields of record provider "${key.providerKey}" for this render.`,
|
|
53
|
+
siteKey: key.siteKey,
|
|
54
|
+
area: using.runtime.area,
|
|
55
|
+
error,
|
|
56
|
+
meta: { providerKey: key.providerKey },
|
|
57
|
+
});
|
|
58
|
+
return { status: "unavailable", reason: error instanceof Error ? error.message : String(error) };
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
/** The declared fields of the record a binding names, read once per request for the same record. */
|
|
62
|
+
export function resolvePhiRecordFields({ registry, runtime, binding }) {
|
|
63
|
+
if (!binding) {
|
|
64
|
+
return Promise.resolve({ status: "none" });
|
|
65
|
+
}
|
|
66
|
+
const rt = phiRuntime(runtime);
|
|
67
|
+
return resolveFields({ providerKey: binding.providerKey, params: binding.params ?? {}, siteKey: rt.siteKey, locale: runtime.locale.current }, { registry, runtime, apiBaseUrl: rt.apiBaseUrl, internalToken: rt.internalToken });
|
|
68
|
+
}
|
|
69
|
+
/** The declared fields of the record this Page is about (`runtime.page.record`). */
|
|
70
|
+
export function resolvePhiPageRecordFields({ registry, runtime }) {
|
|
71
|
+
return resolvePhiRecordFields({ registry, runtime, binding: runtime.page?.record });
|
|
72
|
+
}
|
|
73
|
+
/** One field of a result, if the record has it and it is of one of the kinds asked for. */
|
|
74
|
+
export function readPhiPageRecordField(result, key, kinds) {
|
|
75
|
+
if (result.status !== "ok" || !key)
|
|
76
|
+
return null;
|
|
77
|
+
const field = result.fields.get(key);
|
|
78
|
+
return field && kinds.includes(field.kind) ? field : null;
|
|
79
|
+
}
|
|
80
|
+
export async function resolvePhiWidgetRecordField({ registry, runtime, key, kinds }) {
|
|
81
|
+
if (!key || !registry) {
|
|
82
|
+
return { bound: false };
|
|
83
|
+
}
|
|
84
|
+
const result = await resolvePhiPageRecordFields({ registry, runtime });
|
|
85
|
+
return result.status === "none" ? { bound: false } : { bound: true, field: readPhiPageRecordField(result, key, kinds) };
|
|
86
|
+
}
|
|
@@ -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, PhiPageRecordBinding } from "../types/record-provider";
|
|
5
|
+
type PhiRecordSamplesRegistry = Pick<PhiCmsRuntimeRenderRegistry, "recordSamplesLoadersByKey">;
|
|
6
|
+
/**
|
|
7
|
+
* The record the Builder's Preview shows a template with (MODULES.md, "The fields of a record, and the
|
|
8
|
+
* record a Page is about"): the first sample the route's record Provider offers, as the binding a Page
|
|
9
|
+
* about a record carries -- with the route's `titleField` and `descriptionField`, so the Preview takes the
|
|
10
|
+
* same fields the live Page does.
|
|
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<PhiPageRecordBinding | null>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
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 -- with the route's `titleField` and `descriptionField`, so the Preview takes the
|
|
8
|
+
* same fields the live Page does.
|
|
9
|
+
*
|
|
10
|
+
* A sample's `params` are the Provider's own parameters (`{ slug: "chair" }`), not the route's, so they
|
|
11
|
+
* become the binding as they are. `null` is a Provider that offers no samples or none now, or one whose
|
|
12
|
+
* reader fails: the template then previews with its Widgets' own content, as it does in the Editor.
|
|
13
|
+
*/
|
|
14
|
+
export async function resolvePhiPageRecordSampleBinding({ registry, runtime, pageRecord }) {
|
|
15
|
+
const loadSamples = registry.recordSamplesLoadersByKey.get(pageRecord.providerKey);
|
|
16
|
+
if (!loadSamples) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const rt = phiRuntime(runtime);
|
|
20
|
+
try {
|
|
21
|
+
const read = await loadSamples();
|
|
22
|
+
const samples = await read({
|
|
23
|
+
apiBaseUrl: rt.apiBaseUrl,
|
|
24
|
+
internalToken: rt.internalToken,
|
|
25
|
+
siteKey: rt.siteKey,
|
|
26
|
+
locale: runtime.locale.current,
|
|
27
|
+
runtime,
|
|
28
|
+
});
|
|
29
|
+
const sample = samples[0];
|
|
30
|
+
return sample
|
|
31
|
+
? {
|
|
32
|
+
providerKey: pageRecord.providerKey,
|
|
33
|
+
params: sample.params,
|
|
34
|
+
...(pageRecord.titleField ? { titleField: pageRecord.titleField } : {}),
|
|
35
|
+
...(pageRecord.descriptionField ? { descriptionField: pageRecord.descriptionField } : {}),
|
|
36
|
+
}
|
|
37
|
+
: null;
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
logRuntimeEvent("warn", "cms.record.samples_failed", {
|
|
41
|
+
message: `Failed to read the samples of record provider "${pageRecord.providerKey}" for the Preview.`,
|
|
42
|
+
siteKey: rt.siteKey,
|
|
43
|
+
area: runtime.area,
|
|
44
|
+
error,
|
|
45
|
+
meta: { providerKey: pageRecord.providerKey },
|
|
46
|
+
});
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -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
|
}
|