@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.
Files changed (182) hide show
  1. package/README.md +1 -1
  2. package/components/controls/phi-border-control.js +1 -1
  3. package/components/controls/phi-bound-radius-control.js +9 -9
  4. package/components/controls/phi-brand-control.js +1 -1
  5. package/components/controls/phi-drawer-control-adapter.js +4 -4
  6. package/components/controls/phi-dropdown-control.js +2 -2
  7. package/components/controls/phi-form-control.js +1 -1
  8. package/components/controls/phi-image-control.js +1 -1
  9. package/components/controls/phi-mask-picker-control.js +6 -6
  10. package/components/controls/phi-select-control.js +1 -1
  11. package/components/controls/phi-theme-scope-control.js +1 -1
  12. package/components/controls/use-phi-color-control-presets.js +2 -2
  13. package/components/forms/compound-form-controls.js +2 -2
  14. package/components/forms/extended-form-field-controls.js +1 -1
  15. package/components/forms/shared-form-provider-registry.js +2 -2
  16. package/components/layouts/clients/phi-flex-layout-client.js +4 -4
  17. package/components/layouts/clients/phi-grid-layout-client.js +3 -3
  18. package/components/layouts/clients/phi-sequence-slot-editor.js +1 -1
  19. package/components/layouts/layout-definitions.d.ts +4 -4
  20. package/components/layouts/phi-page-region-layout.js +1 -1
  21. package/components/layouts/phi-structure-region-layout.js +3 -3
  22. package/components/media/phi-asset-focal-rect-widget.js +4 -4
  23. package/components/media/phi-asset-inspector-section.js +1 -1
  24. package/components/media/phi-media-kind-icon.js +2 -2
  25. package/components/media/phi-media-restricted-icon.js +1 -1
  26. package/components/overlays/phi-overlay-container-client.js +1 -1
  27. package/components/regions/presets/phi-base-page-column.js +6 -2
  28. package/components/root/phi-config-provider.js +1 -1
  29. package/components/root/phi-root-background.js +1 -1
  30. package/components/root/phi-root-theme-resolver.js +1 -1
  31. package/components/shell/phi-module-icons.js +1 -1
  32. package/components/widgets/built-in/builder-workspace-preview.js +8 -8
  33. package/components/widgets/client/bullet-list-entries-editor.js +2 -2
  34. package/components/widgets/client/external-document-editor.js +1 -1
  35. package/components/widgets/client/html-editor.js +3 -3
  36. package/components/widgets/config/background.d.ts +1 -1
  37. package/components/widgets/config/background.js +1 -1
  38. package/components/widgets/inspector-field-row.js +1 -1
  39. package/components/widgets/label-sets/inspector.js +2 -0
  40. package/components/widgets/label-types/inspector.d.ts +1 -0
  41. package/components/widgets/label-types/inspector.js +1 -0
  42. package/components/widgets/shared/card-body-client.js +1 -1
  43. package/components/widgets/shared/result-body-client.js +1 -1
  44. package/constants/media-library-provider-keys.d.ts +8 -1
  45. package/constants/media-library-provider-keys.js +8 -1
  46. package/constants/record-field-kinds.d.ts +6 -0
  47. package/constants/record-field-kinds.js +7 -0
  48. package/constants/runtime-module-ownership.js +1 -1
  49. package/helpers/border-widget-style.d.ts +2 -2
  50. package/helpers/border-widget-style.js +2 -2
  51. package/helpers/cms-dialog.d.ts +4 -4
  52. package/helpers/cms-layout-defaults.d.ts +2 -2
  53. package/helpers/cms-page-catalog.d.ts +5 -0
  54. package/helpers/cms-preset-page-tree.d.ts +4 -0
  55. package/helpers/cms-preset-page-tree.js +2 -0
  56. package/helpers/layout-style.d.ts +2 -2
  57. package/helpers/page-layout-check.d.ts +4 -1
  58. package/helpers/page-layout-check.js +26 -0
  59. package/helpers/record-fields.d.ts +9 -0
  60. package/helpers/record-fields.js +84 -0
  61. package/helpers/surface-presets.d.ts +6 -6
  62. package/helpers/surface-style.d.ts +1 -1
  63. package/helpers.d.ts +0 -1
  64. package/helpers.js +0 -2
  65. package/module-page-check.d.ts +12 -0
  66. package/module-page-check.js +12 -0
  67. package/module-records.d.ts +4 -2
  68. package/module-records.js +3 -1
  69. package/next/antd-form-context-loader.mjs +31 -0
  70. package/next/config.d.mts +2 -0
  71. package/next/config.mjs +36 -3
  72. package/package.json +10 -1
  73. package/plugins/runtime-modules/asset/data-providers.d.ts +0 -65
  74. package/plugins/runtime-modules/asset/data-providers.js +0 -40
  75. package/plugins/runtime-modules/asset/definition.d.ts +0 -60
  76. package/plugins/runtime-modules/asset/ids.d.ts +0 -1
  77. package/plugins/runtime-modules/asset/ids.js +1 -2
  78. package/plugins/runtime-modules/asset/presets.d.ts +1 -0
  79. package/plugins/runtime-modules/asset/server.js +0 -5
  80. package/plugins/runtime-modules/blog/presets.d.ts +1 -0
  81. package/plugins/runtime-modules/builder/clients/inspector-config-field.d.ts +4 -1
  82. package/plugins/runtime-modules/builder/clients/inspector-config-field.js +13 -4
  83. package/plugins/runtime-modules/builder/clients/inspector-link-target-field.js +1 -1
  84. package/plugins/runtime-modules/builder/clients/inspector-section-widget.js +14 -1
  85. package/plugins/runtime-modules/builder/clients/inspector-signal-section.js +2 -2
  86. package/plugins/runtime-modules/builder/clients/layout-inspector.js +1 -1
  87. package/plugins/runtime-modules/builder/clients/layout-scaffold-buttons.js +4 -4
  88. package/plugins/runtime-modules/builder/clients/layout-scaffold-overlays.js +1 -1
  89. package/plugins/runtime-modules/builder/clients/region-inspector.js +1 -1
  90. package/plugins/runtime-modules/builder/clients/region-visibility-fields.js +1 -1
  91. package/plugins/runtime-modules/builder/clients/shells-workspace.js +1 -1
  92. package/plugins/runtime-modules/builder/clients/structure-canvas.js +2 -2
  93. package/plugins/runtime-modules/builder/clients/widget-effects-editor.js +1 -1
  94. package/plugins/runtime-modules/builder/clients/widget-inspector.d.ts +4 -1
  95. package/plugins/runtime-modules/builder/clients/widget-inspector.js +3 -2
  96. package/plugins/runtime-modules/builder/page-presets.server.d.ts +6 -0
  97. package/plugins/runtime-modules/builder/page-presets.server.js +8 -0
  98. package/plugins/runtime-modules/builder/pages-workspace.js +12 -1
  99. package/plugins/runtime-modules/builder/render-root-node-scaffold.js +5 -5
  100. package/plugins/runtime-modules/builder/structure-dnd.js +2 -2
  101. package/plugins/runtime-modules/builder/widgets/test-block/client.js +1 -1
  102. package/plugins/runtime-modules/content-entry-routes.d.ts +1 -0
  103. package/plugins/runtime-modules/contracts.d.ts +1 -1
  104. package/plugins/runtime-modules/contracts.js +41 -1
  105. package/plugins/runtime-modules/core/data-providers.d.ts +60 -0
  106. package/plugins/runtime-modules/core/data-providers.js +41 -0
  107. package/plugins/runtime-modules/core/definition.d.ts +55 -0
  108. package/plugins/runtime-modules/core/server.js +5 -0
  109. package/plugins/runtime-modules/core/widgets/button/config.d.ts +34 -0
  110. package/plugins/runtime-modules/core/widgets/button/config.js +16 -0
  111. package/plugins/runtime-modules/core/widgets/button/plugin.js +37 -6
  112. package/plugins/runtime-modules/core/widgets/card/config.d.ts +13 -2
  113. package/plugins/runtime-modules/core/widgets/description/config.d.ts +13 -2
  114. package/plugins/runtime-modules/core/widgets/description/editor.js +13 -13
  115. package/plugins/runtime-modules/core/widgets/entry-list/config.d.ts +11 -0
  116. package/plugins/runtime-modules/core/widgets/gallery/client.d.ts +4 -1
  117. package/plugins/runtime-modules/core/widgets/gallery/client.js +29 -21
  118. package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +16 -0
  119. package/plugins/runtime-modules/core/widgets/gallery/config.js +16 -0
  120. package/plugins/runtime-modules/core/widgets/gallery/server.d.ts +1 -1
  121. package/plugins/runtime-modules/core/widgets/gallery/server.js +11 -0
  122. package/plugins/runtime-modules/core/widgets/image/config.d.ts +35 -0
  123. package/plugins/runtime-modules/core/widgets/image/config.js +8 -0
  124. package/plugins/runtime-modules/core/widgets/image/plugin.js +19 -1
  125. package/plugins/runtime-modules/core/widgets/image/server.d.ts +3 -1
  126. package/plugins/runtime-modules/core/widgets/image/server.js +2 -2
  127. package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +13 -0
  128. package/plugins/runtime-modules/core/widgets/markdown/config.js +8 -0
  129. package/plugins/runtime-modules/core/widgets/markdown/editor.js +7 -7
  130. package/plugins/runtime-modules/core/widgets/markdown/plugin.js +20 -7
  131. package/plugins/runtime-modules/core/widgets/record/authoring.js +1 -1
  132. package/plugins/runtime-modules/core/widgets/result/config.d.ts +11 -0
  133. package/plugins/runtime-modules/core/widgets/simple-text/config.d.ts +13 -0
  134. package/plugins/runtime-modules/core/widgets/simple-text/config.js +9 -0
  135. package/plugins/runtime-modules/core/widgets/simple-text/editor.js +1 -1
  136. package/plugins/runtime-modules/core/widgets/simple-text/plugin.js +14 -1
  137. package/plugins/runtime-modules/core/widgets/spacer/client.js +1 -1
  138. package/plugins/runtime-modules/core/widgets/table/config.d.ts +37 -0
  139. package/plugins/runtime-modules/descriptor-compiler.js +8 -0
  140. package/plugins/runtime-modules/editor/presets.d.ts +1 -0
  141. package/plugins/runtime-modules/groups/definition.d.ts +1 -1
  142. package/plugins/runtime-modules/localization/presets.d.ts +1 -0
  143. package/plugins/runtime-modules/news/presets.d.ts +1 -0
  144. package/plugins/runtime-modules/resolver.js +2 -0
  145. package/plugins/runtime-modules/revisions/presets.d.ts +1 -0
  146. package/plugins/runtime-modules/theme/presets.d.ts +1 -0
  147. package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +25 -2
  148. package/server-helpers/cms-page-record.d.ts +26 -0
  149. package/server-helpers/cms-page-record.js +42 -0
  150. package/server-helpers/cms-request.js +48 -4
  151. package/server-helpers/record-fields.d.ts +62 -0
  152. package/server-helpers/record-fields.js +87 -0
  153. package/server-helpers/record-samples.d.ts +21 -0
  154. package/server-helpers/record-samples.js +41 -0
  155. package/styles/builder-scaffold.css +19 -19
  156. package/styles/controls.css +109 -109
  157. package/styles/gradients.css +23 -23
  158. package/styles/layout-affordances.css +15 -15
  159. package/styles/layout-authoring-scaffold.css +20 -20
  160. package/styles/layout.css +9 -9
  161. package/styles/root.css +4 -4
  162. package/styles/shell.css +48 -17
  163. package/theme/antd-css-var-contract.d.ts +86 -80
  164. package/theme/antd-css-var-contract.js +92 -81
  165. package/theme/phi-control-shape.d.ts +1 -1
  166. package/theme/phi-theme-gradients.d.ts +2 -2
  167. package/theme/phi-theme-gradients.js +14 -14
  168. package/theme/phi-theme-palette.d.ts +1 -1
  169. package/theme/phi-theme-palette.js +2 -2
  170. package/theme/phi-theme-tokens.d.ts +8 -5
  171. package/theme/phi-theme-tokens.js +59 -28
  172. package/theme/phi-theme.d.ts +14 -2
  173. package/theme/phi-theme.js +14 -1
  174. package/theme/phi-tokens.d.ts +5 -0
  175. package/theme/phi-tokens.js +9 -0
  176. package/types/cms-module-descriptors.d.ts +6 -0
  177. package/types/cms-plugins.d.ts +19 -1
  178. package/types/core-widget-placements.d.ts +10 -0
  179. package/types/record-provider.d.ts +92 -0
  180. package/types/widget-runtime.d.ts +5 -0
  181. /package/plugins/runtime-modules/{asset/services/folder-images.server.d.ts → core/services/media-folder-images.server.d.ts} +0 -0
  182. /package/plugins/runtime-modules/{asset/services/folder-images.server.js → core/services/media-folder-images.server.js} +0 -0
@@ -47,6 +47,7 @@ export function parsePhiCmsMarkdownWidgetConfig(config) {
47
47
  sourceMode: readMarkdownSourceMode(config.sourceMode) ?? (sourceUrl ? "url" : "inline"),
48
48
  widgetId: typeof config.widgetId === "number" || typeof config.widgetId === "string" ? config.widgetId : undefined,
49
49
  markdown: readString(config.markdown),
50
+ recordField: readString(config.recordField),
50
51
  sourceUrl,
51
52
  sourceLocale: readString(config.sourceLocale),
52
53
  revalidateSeconds: readNumber(config.revalidateSeconds),
@@ -117,6 +118,13 @@ export const PHI_MARKDOWN_WIDGET_DEFINITION = {
117
118
  ],
118
119
  },
119
120
  { key: "sourceUrl", type: "url", label: "Source URL", visibleWhen: { field: "sourceMode", equals: "url" } },
121
+ {
122
+ key: "recordField",
123
+ type: "record-field",
124
+ label: "Record field",
125
+ description: "Shows a field of the record this page is about instead of the text. The text stands in where the page has no record.",
126
+ kinds: ["markdown", "text"],
127
+ },
120
128
  {
121
129
  key: "sourceLocale",
122
130
  type: "string",
@@ -76,7 +76,7 @@ export function PhiMarkdownWidgetEditor({ blockId, config, onChange, onSourceLoc
76
76
  * leaves of a control's height. Stated, the clear button finds the first line by it, as it does in
77
77
  * every field that states one; left to Ant Design it hung at its own offset, half a line above.
78
78
  */
79
- paddingBlock: "calc((var(--ant-control-height) - 1lh) / 2)",
79
+ paddingBlock: "calc((var(--phi-control-height) - 1lh) / 2)",
80
80
  }, style: {
81
81
  /*
82
82
  * As wide as the slot: the Widget fills its inline axis (`fill-inline`), so the frame decides the
@@ -86,14 +86,14 @@ export function PhiMarkdownWidgetEditor({ blockId, config, onChange, onSourceLoc
86
86
  width: "100%",
87
87
  height: MARKDOWN_EDITOR_HEIGHT,
88
88
  minWidth: 0,
89
- padding: "var(--ant-padding-sm)",
90
- border: "1px solid var(--ant-color-border-secondary)",
89
+ padding: "var(--phi-padding-sm)",
90
+ border: "1px solid var(--phi-color-border-secondary)",
91
91
  /*
92
- * The Control shape, and not `--ant-border-radius`.
92
+ * The Control shape, and not `--phi-border-radius`.
93
93
  *
94
94
  * The field is `borderless`, so this style is the box: it draws the border, the ground and the
95
95
  * corner the Control would have drawn itself. The corner is the trap. On a Control element
96
- * `--ant-border-radius` does not mean the surface radius -- Ant Design ships a component token in
96
+ * `--phi-border-radius` does not mean the surface radius -- Ant Design ships a component token in
97
97
  * CSS variable mode as a LOCAL redefinition of the same variable on that element, so what is
98
98
  * read here is the Control shape, and under `pill` that is the full radius. Inline, where no
99
99
  * rule in `styles/control-shape.css` can reach it: a Markdown editor several rows tall came out
@@ -103,9 +103,9 @@ export function PhiMarkdownWidgetEditor({ blockId, config, onChange, onSourceLoc
103
103
  * held at every height (THEME.md, "Control shape").
104
104
  */
105
105
  borderRadius: "var(--phi-control-radius-grown-md)",
106
- background: "var(--ant-color-bg-container)",
106
+ background: "var(--phi-color-bg-container)",
107
107
  resize: "none",
108
- fontFamily: "var(--ant-font-family-code, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, monospace)",
108
+ fontFamily: "var(--phi-font-family-code, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, monospace)",
109
109
  lineHeight: 1.6,
110
110
  } }));
111
111
  }
@@ -4,6 +4,7 @@ import { resolveMarkdownRenderData } from "../../../../../components/widgets/sha
4
4
  import { PhiCmsFlags } from "../../../../../constants/phi-cms";
5
5
  import { hasPhiFlag } from "../../../../../helpers/flags";
6
6
  import { readPhiMarkdownSearchText, translatePhiSearchWidgetTexts } from "../../../../../server-helpers/search-text";
7
+ import { resolvePhiWidgetRecordField } from "../../../../../server-helpers/record-fields";
7
8
  import { PhiMarkdownWidget } from "./server";
8
9
  import { PHI_MARKDOWN_WIDGET_DEFINITION, PHI_MARKDOWN_WIDGET_PLUGIN_TYPE, } from "./config";
9
10
  export const PHI_MARKDOWN_WIDGET_PLUGIN = {
@@ -27,13 +28,25 @@ export const PHI_MARKDOWN_WIDGET_PLUGIN = {
27
28
  });
28
29
  return [...eyebrow, ...readPhiMarkdownSearchText(data.blocks)];
29
30
  },
30
- render: ({ widget, config, runtime }) => (_jsx(PhiMarkdownWidget, { config: {
31
- ...config,
32
- widgetId: widget.id,
33
- resolvedContent: widget.resolvedContent ?? null,
34
- preferSource: hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate),
35
- translate: !hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate),
36
- }, runtime: runtime }, `widget-${widget.id}`)),
31
+ render: async ({ widget, config, runtime, registry }) => {
32
+ /*
33
+ * A field of the page record takes the text's place: inline, in the page's language already, and
34
+ * nothing where the record does not have it.
35
+ */
36
+ const recordField = await resolvePhiWidgetRecordField({ registry, runtime, key: config.recordField, kinds: ["markdown", "text"] });
37
+ if (recordField.bound) {
38
+ return recordField.field?.value.trim()
39
+ ? (_jsx(PhiMarkdownWidget, { config: { ...config, widgetId: widget.id, sourceMode: "inline", markdown: recordField.field.value, resolvedContent: null, translate: false }, runtime: runtime }, `widget-${widget.id}`))
40
+ : null;
41
+ }
42
+ return (_jsx(PhiMarkdownWidget, { config: {
43
+ ...config,
44
+ widgetId: widget.id,
45
+ resolvedContent: widget.resolvedContent ?? null,
46
+ preferSource: hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate),
47
+ translate: !hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate),
48
+ }, runtime: runtime }, `widget-${widget.id}`));
49
+ },
37
50
  renderPreview: ({ widget, config, runtime }) => (_jsx(PhiWidgetInertPreview, { children: _jsx(PhiMarkdownWidget, { config: {
38
51
  ...config,
39
52
  widgetId: widget.id,
@@ -16,5 +16,5 @@ export const PHI_RECORD_WIDGET_BUILDER_PLUGIN = createPhiCmsBuilderWidgetPlugin(
16
16
  key: field.key,
17
17
  label: field.label,
18
18
  full: field.full,
19
- value: _jsx("span", { style: { color: "var(--ant-color-text-tertiary)" }, children: field.fieldKey }),
19
+ value: _jsx("span", { style: { color: "var(--phi-color-text-tertiary)" }, children: field.fieldKey }),
20
20
  })) })));
@@ -110,6 +110,17 @@ export declare const PHI_RESULT_WIDGET_DEFINITION: {
110
110
  editorPlacement?: "inspector" | "geometry" | "toolbar";
111
111
  visibleWhen?: import("../../../../../types").PhiCmsConfigFieldVisibilityRule | readonly import("../../../../../types").PhiCmsConfigFieldVisibilityRule[];
112
112
  heading?: string;
113
+ } & {
114
+ type: "record-field";
115
+ kinds: readonly import("../../../../../constants/record-field-kinds").PhiRecordFieldKind[];
116
+ }) | ({
117
+ key: string;
118
+ label: string;
119
+ description?: string;
120
+ required?: boolean;
121
+ editorPlacement?: "inspector" | "geometry" | "toolbar";
122
+ visibleWhen?: import("../../../../../types").PhiCmsConfigFieldVisibilityRule | readonly import("../../../../../types").PhiCmsConfigFieldVisibilityRule[];
123
+ heading?: string;
113
124
  } & {
114
125
  type: "dimension";
115
126
  widthKey?: string;
@@ -23,6 +23,8 @@ export type PhiCmsSimpleTextWidgetConfig = PhiCmsWidgetConfigBase & {
23
23
  disabled?: boolean;
24
24
  /** `"preset"` while the words are a Preset's and translated globally (`helpers/text-source.ts`). */
25
25
  textSource?: PhiTextSource;
26
+ /** A text, number or date field of the page record to show instead of the Widget's own text. */
27
+ recordField?: string;
26
28
  };
27
29
  declare function parsePhiCmsSimpleTextWidgetConfig(config: Record<string, unknown>): PhiCmsSimpleTextWidgetConfig;
28
30
  export type PhiSimpleTextWidgetRenderableConfig = PhiCmsSimpleTextWidgetConfig & {
@@ -117,6 +119,17 @@ export declare const PHI_SIMPLE_TEXT_WIDGET_DEFINITION: {
117
119
  editorPlacement?: "inspector" | "geometry" | "toolbar";
118
120
  visibleWhen?: import("../../../../../types").PhiCmsConfigFieldVisibilityRule | readonly import("../../../../../types").PhiCmsConfigFieldVisibilityRule[];
119
121
  heading?: string;
122
+ } & {
123
+ type: "record-field";
124
+ kinds: readonly import("../../../../../constants/record-field-kinds").PhiRecordFieldKind[];
125
+ }) | ({
126
+ key: string;
127
+ label: string;
128
+ description?: string;
129
+ required?: boolean;
130
+ editorPlacement?: "inspector" | "geometry" | "toolbar";
131
+ visibleWhen?: import("../../../../../types").PhiCmsConfigFieldVisibilityRule | readonly import("../../../../../types").PhiCmsConfigFieldVisibilityRule[];
132
+ heading?: string;
120
133
  } & {
121
134
  type: "dimension";
122
135
  widthKey?: string;
@@ -1,3 +1,4 @@
1
+ import { PHI_RECORD_TEXT_FIELD_KINDS } from "../../../../../helpers/record-fields";
1
2
  import { resolvePhiCmsWidgetPluginKey } from "../../../../../constants/cms-widget-types";
2
3
  import { readPhiTextSource } from "../../../../../helpers/text-source";
3
4
  import { PHI_SIMPLE_TEXT_MARKS } from "../../../../../types/core-widget-placements";
@@ -32,6 +33,7 @@ function parsePhiCmsSimpleTextWidgetConfig(config) {
32
33
  letterSpacing: readPhiLetterSpacingStep(config.letterSpacing),
33
34
  disabled: readBoolean(config.disabled),
34
35
  textSource: readPhiTextSource(config.textSource),
36
+ recordField: readString(config.recordField),
35
37
  };
36
38
  }
37
39
  export const PHI_SIMPLE_TEXT_WIDGET_DEFINITION = {
@@ -52,6 +54,13 @@ export const PHI_SIMPLE_TEXT_WIDGET_DEFINITION = {
52
54
  fields: [
53
55
  ...PHI_RENDERABLE_BLOCK_GEOMETRY_FIELDS,
54
56
  { key: "text", type: "string", label: "Text", required: true },
57
+ {
58
+ key: "recordField",
59
+ type: "record-field",
60
+ label: "Record field",
61
+ description: "Shows a field of the record this page is about instead of the text. The text stands in where the page has no record.",
62
+ kinds: PHI_RECORD_TEXT_FIELD_KINDS,
63
+ },
55
64
  { key: "href", type: "url", label: "Href" },
56
65
  { key: "icon", type: "icon", label: "Icon", editorPlacement: "toolbar" },
57
66
  { key: "color", type: "color", label: "Color", mode: "single", editorPlacement: "toolbar" },
@@ -122,7 +122,7 @@ export function PhiSimpleTextWidgetEditor({ text, config, onChangeText, }) {
122
122
  * form and wrong here -- the Widget stands on whatever its Region is painted with. Code text is
123
123
  * the exception, because there the fill is part of how the text reads.
124
124
  */
125
- backgroundColor: hasPhiSimpleTextMark(config, "code") ? "var(--ant-color-fill-secondary, rgba(0, 0, 0, 0.04))" : "transparent",
125
+ backgroundColor: hasPhiSimpleTextMark(config, "code") ? "var(--phi-color-fill-secondary, rgba(0, 0, 0, 0.04))" : "transparent",
126
126
  }, fitContent: true, style: {
127
127
  minWidth: 0,
128
128
  flex: "0 0 auto",
@@ -2,6 +2,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { PhiCmsFlags } from "../../../../../constants/phi-cms";
3
3
  import { hasPhiFlag } from "../../../../../helpers/flags";
4
4
  import { translatePhiSearchWidgetTexts } from "../../../../../server-helpers/search-text";
5
+ import { formatPhiRecordFieldText, PHI_RECORD_TEXT_FIELD_KINDS } from "../../../../../helpers/record-fields";
6
+ import { resolvePhiWidgetRecordField } from "../../../../../server-helpers/record-fields";
5
7
  import { PhiSimpleTextWidget } from "./server";
6
8
  import { PHI_SIMPLE_TEXT_WIDGET_DEFINITION, PHI_SIMPLE_TEXT_WIDGET_PLUGIN_TYPE, resolvePhiSimpleTextWidgetText, } from "./config";
7
9
  export const PHI_SIMPLE_TEXT_WIDGET_PLUGIN = {
@@ -16,10 +18,21 @@ export const PHI_SIMPLE_TEXT_WIDGET_PLUGIN = {
16
18
  textSource: config.textSource,
17
19
  });
18
20
  },
19
- render: ({ widget, config, runtime }) => {
21
+ render: async ({ widget, config, runtime, registry }) => {
20
22
  const noTranslate = hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate);
21
23
  // A record's text is already translated; only the Widget's own still has to be.
22
24
  const hasResolvedText = Boolean(widget.resolvedContent?.textFields.text);
25
+ /*
26
+ * A field of the page record takes the text's place, in the page's language already. A record
27
+ * without the field leaves nothing to show; a Page about no record shows the Widget's own text.
28
+ */
29
+ const recordField = await resolvePhiWidgetRecordField({ registry, runtime, key: config.recordField, kinds: PHI_RECORD_TEXT_FIELD_KINDS });
30
+ if (recordField.bound) {
31
+ const text = recordField.field ? formatPhiRecordFieldText(recordField.field, runtime.locale.current) : "";
32
+ return text
33
+ ? _jsx(PhiSimpleTextWidget, { blockId: widget.id, translate: false, labels: { text }, config: config, runtime: runtime }, `widget-${widget.id}`)
34
+ : null;
35
+ }
23
36
  return (_jsx(PhiSimpleTextWidget, { blockId: widget.id, translate: !noTranslate && !hasResolvedText, textSource: config.textSource, labels: {
24
37
  text: resolvePhiSimpleTextWidgetText({
25
38
  ...config,
@@ -52,6 +52,6 @@ export function PhiSpacerWidget({ config, }) {
52
52
  background: isEditor ? "rgba(71, 85, 105, 0.035)" : "transparent",
53
53
  boxShadow: isEditor ? "inset 0 0 0 1px rgba(71, 85, 105, 0.18)" : "none",
54
54
  border: isEditor ? "1px dashed rgba(71, 85, 105, 0.45)" : "0",
55
- borderRadius: isEditor ? "var(--ant-border-radius-lg)" : 0,
55
+ borderRadius: isEditor ? "var(--phi-border-radius-lg)" : 0,
56
56
  }, children: isEditor ? (_jsx("div", { "aria-hidden": "true", className: "phi-builder-spacer", children: _jsx(SpacerGlyph, { orientation: orientation }) })) : null }) }));
57
57
  }
@@ -135,6 +135,17 @@ export declare const PHI_TABLE_WIDGET_DEFINITION: {
135
135
  editorPlacement?: "inspector" | "geometry" | "toolbar";
136
136
  visibleWhen?: import("../../../../../types").PhiCmsConfigFieldVisibilityRule | readonly import("../../../../../types").PhiCmsConfigFieldVisibilityRule[];
137
137
  heading?: string;
138
+ } & {
139
+ type: "record-field";
140
+ kinds: readonly import("../../../../../constants/record-field-kinds").PhiRecordFieldKind[];
141
+ }) | ({
142
+ key: string;
143
+ label: string;
144
+ description?: string;
145
+ required?: boolean;
146
+ editorPlacement?: "inspector" | "geometry" | "toolbar";
147
+ visibleWhen?: import("../../../../../types").PhiCmsConfigFieldVisibilityRule | readonly import("../../../../../types").PhiCmsConfigFieldVisibilityRule[];
148
+ heading?: string;
138
149
  } & {
139
150
  type: "dimension";
140
151
  widthKey?: string;
@@ -438,6 +449,19 @@ export declare const PHI_TABLE_WIDGET_DEFINITION: {
438
449
  editorPlacement?: "inspector" | "geometry" | "toolbar";
439
450
  heading?: string;
440
451
  type: "video-provider";
452
+ } | {
453
+ visibleWhen: {
454
+ field: string;
455
+ notEquals: string;
456
+ };
457
+ key: string;
458
+ label: string;
459
+ description?: string;
460
+ required?: boolean;
461
+ editorPlacement?: "inspector" | "geometry" | "toolbar";
462
+ heading?: string;
463
+ type: "record-field";
464
+ kinds: readonly import("../../../../../constants/record-field-kinds").PhiRecordFieldKind[];
441
465
  } | {
442
466
  visibleWhen: {
443
467
  field: string;
@@ -804,6 +828,19 @@ export declare const PHI_TABLE_WIDGET_DEFINITION: {
804
828
  editorPlacement?: "inspector" | "geometry" | "toolbar";
805
829
  heading?: string;
806
830
  type: "video-provider";
831
+ } | {
832
+ visibleWhen: {
833
+ field: string;
834
+ equals: boolean;
835
+ };
836
+ key: string;
837
+ label: string;
838
+ description?: string;
839
+ required?: boolean;
840
+ editorPlacement?: "inspector" | "geometry" | "toolbar";
841
+ heading?: string;
842
+ type: "record-field";
843
+ kinds: readonly import("../../../../../constants/record-field-kinds").PhiRecordFieldKind[];
807
844
  } | {
808
845
  visibleWhen: {
809
846
  field: string;
@@ -114,6 +114,14 @@ export function compilePhiCmsRoutePattern(descriptor) {
114
114
  if (dynamicSegments.length > 1) {
115
115
  throw new Error(`${descriptor.ownerModuleId}/${descriptor.presetKey}: a route may contain at most one dynamic segment.`);
116
116
  }
117
+ // A page record is filled in from the address, so every route parameter it names has to be in the path.
118
+ if (descriptor.pageRecord) {
119
+ const routeParams = new Set(dynamicSegments.map((segment) => segment.slice(1)));
120
+ const named = Object.values(descriptor.pageRecord.params);
121
+ if (named.length === 0 || named.some((param) => !routeParams.has(param))) {
122
+ throw new Error(`${descriptor.ownerModuleId}/${descriptor.presetKey}: a page record's params must each name a parameter of the route path.`);
123
+ }
124
+ }
117
125
  for (const segment of segments) {
118
126
  if (segment.includes("*") ||
119
127
  segment.includes("?") ||
@@ -43,5 +43,6 @@ export declare const PHI_EDITOR_RUNTIME_MODULE_ROUTES: (PhiCmsRoutePresetDescrip
43
43
  activeModuleIds: ReadonlySet<import("../contracts").PhiRuntimeModuleId>;
44
44
  params: Readonly<Record<string, string>>;
45
45
  }) => import("../../../types").PhiResolvedCmsPageTree | Promise<import("../../../types").PhiResolvedCmsPageTree>;
46
+ pageRecord?: import("../../../types/record-provider").PhiCmsPageRecordDescriptor;
46
47
  navigation?: readonly import("../../../types").PhiCmsNavigationInjectionDescriptor[];
47
48
  })[];
@@ -250,7 +250,7 @@ export declare const PHI_GROUPS_RUNTIME_MODULE_DEFINITION: {
250
250
  iconFamily: string;
251
251
  mediaSpaces: {
252
252
  group: {
253
- kinds: ("image" | "video" | "audio" | "pdf" | "markdown" | "document" | "archive")[];
253
+ kinds: ("image" | "markdown" | "video" | "audio" | "pdf" | "document" | "archive")[];
254
254
  };
255
255
  };
256
256
  threadKinds: ("group" | "crossGroup")[];
@@ -42,5 +42,6 @@ export declare const PHI_LOCALIZATION_RUNTIME_MODULE_ROUTES: (PhiCmsRoutePresetD
42
42
  activeModuleIds: ReadonlySet<import("../contracts").PhiRuntimeModuleId>;
43
43
  params: Readonly<Record<string, string>>;
44
44
  }) => import("../../../types").PhiResolvedCmsPageTree | Promise<import("../../../types").PhiResolvedCmsPageTree>;
45
+ pageRecord?: import("../../../types/record-provider").PhiCmsPageRecordDescriptor;
45
46
  navigation?: readonly import("../../../types").PhiCmsNavigationInjectionDescriptor[];
46
47
  })[];
@@ -49,5 +49,6 @@ export declare const PHI_NEWS_RUNTIME_MODULE_ROUTES: ({
49
49
  activeModuleIds: ReadonlySet<import("../contracts").PhiRuntimeModuleId>;
50
50
  params: Readonly<Record<string, string>>;
51
51
  }) => import("../../../types").PhiResolvedCmsPageTree | Promise<import("../../../types").PhiResolvedCmsPageTree>;
52
+ pageRecord?: import("../../../types/record-provider").PhiCmsPageRecordDescriptor;
52
53
  navigation?: readonly import("../../../types").PhiCmsNavigationInjectionDescriptor[];
53
54
  })[];
@@ -618,6 +618,8 @@ export async function resolvePhiRuntimeRenderRegistry({ catalog, moduleSet, tree
618
618
  * binding names a Provider, not the Module whose Widget it sits in.
619
619
  */
620
620
  recordProviderLoadersByKey: new Map([...moduleSet.moduleDefinitionsById.keys()].flatMap((moduleId) => (catalog.get(moduleId)?.recordProviders ?? []).map((provider) => [provider.key, provider.load]))),
621
+ recordFieldsLoadersByKey: new Map([...moduleSet.moduleDefinitionsById.keys()].flatMap((moduleId) => (catalog.get(moduleId)?.recordProviders ?? []).flatMap((provider) => provider.loadFields ? [[provider.key, provider.loadFields]] : []))),
622
+ recordSamplesLoadersByKey: new Map([...moduleSet.moduleDefinitionsById.keys()].flatMap((moduleId) => (catalog.get(moduleId)?.recordProviders ?? []).flatMap((provider) => provider.loadSamples ? [[provider.key, provider.loadSamples]] : []))),
621
623
  dataProviderDescriptorsByKey,
622
624
  formDefinitionsById: moduleSet.formDefinitionsById,
623
625
  };
@@ -49,5 +49,6 @@ export declare const PHI_REVISIONS_RUNTIME_MODULE_ROUTES: {
49
49
  activeModuleIds: ReadonlySet<import("../contracts").PhiRuntimeModuleId>;
50
50
  params: Readonly<Record<string, string>>;
51
51
  }) => import("../../../types").PhiResolvedCmsPageTree | Promise<import("../../../types").PhiResolvedCmsPageTree>;
52
+ pageRecord?: import("../../../types/record-provider").PhiCmsPageRecordDescriptor;
52
53
  navigation?: readonly import("../../../types").PhiCmsNavigationInjectionDescriptor[];
53
54
  }[];
@@ -80,5 +80,6 @@ export declare const PHI_THEME_RUNTIME_MODULE_ROUTES: {
80
80
  activeModuleIds: ReadonlySet<import("../contracts").PhiRuntimeModuleId>;
81
81
  params: Readonly<Record<string, string>>;
82
82
  }) => import("../../../types").PhiResolvedCmsPageTree | Promise<import("../../../types").PhiResolvedCmsPageTree>;
83
+ pageRecord?: import("../../../types/record-provider").PhiCmsPageRecordDescriptor;
83
84
  navigation?: readonly import("../../../types").PhiCmsNavigationInjectionDescriptor[];
84
85
  }[];
@@ -23,6 +23,8 @@ import { resolvePhiAntdAliasTokens } from "../../../../../theme/phi-antd-token-r
23
23
  import { buildPhiThemeStructuralTokens } from "../../../../../theme/phi-theme";
24
24
  import { PHI_CONTROL_HEIGHTS, PHI_LAYOUT, PHI_PADDING, PHI_RADII, } from "../../../../../theme/phi-tokens";
25
25
  import { PHI_CONTAINER_BREAKPOINT_REGION } from "../../../../../theme/phi-container-breakpoints";
26
+ import { PHI_SPACE } from "../../../../../theme/antd-css-var-contract";
27
+ import { PHI_THEME_PAGE_PADDING_BANDS, PHI_THEME_PAGE_PADDING_SIDES } from "../../../../../theme/phi-theme-tokens";
26
28
  import { PHI_COLOR_PICKER_NEUTRAL_PRESETS, PHI_COLOR_PICKER_PRESETS } from "../../../../../components/widgets/config/color-picker-presets";
27
29
  import { PHI_SPACING_TOKEN_KEYS } from "../../../../../components/widgets/config/spacing-options";
28
30
  import { PhiColorFieldControl } from "../../../../../components/controls/phi-color-field-control";
@@ -42,6 +44,7 @@ import { PhiButtonControl } from "../../../../../components/controls/phi-button-
42
44
  import { PhiCheckboxControl } from "../../../../../components/controls/phi-checkbox-control";
43
45
  import { PhiLabeledControl } from "../../../../../components/controls/phi-labeled-control";
44
46
  import { PhiNumberControl } from "../../../../../components/controls/phi-number-control";
47
+ import { PhiPaddingControl } from "../../../../../components/controls/phi-padding-control";
45
48
  import { PhiColorControl } from "../../../../../components/controls/phi-color-control";
46
49
  import { PhiLinkTargetControl } from "../../../../../components/widgets/client/shared/phi-link-target-control";
47
50
  import { usePhiPageReferenceOptions } from "../../../../../components/widgets/client/shared/use-page-reference-options";
@@ -85,6 +88,7 @@ const BRAND_THEME_STYLE_SECTION_KEYS = [
85
88
  "fontSize",
86
89
  "wireframe",
87
90
  "pageWidth",
91
+ "pagePadding",
88
92
  ];
89
93
  /*
90
94
  * The shadow under each kind of Button (theme/phi-button-shadow.ts). "Theme" is no step at all -- the
@@ -1302,7 +1306,13 @@ export function PhiBuilderBrandStyleControlsWidgetClient({ runtime, config, }) {
1302
1306
  /** One row per size step: a label and the preset picker; Border Radius and Control Height share it. */
1303
1307
  const renderPresetSizeRows = (items, options) => (_jsx(PhiFlexControl, { vertical: true, gap: clientToken.paddingXS, children: items.map((item) => (_jsxs(PhiFlexControl, { align: "center", gap: clientToken.paddingSM, wrap: "nowrap", children: [_jsx(PhiTypographyControl, { style: { flex: `0 0 ${fieldLabelWidth}px` }, children: item.label }), _jsx(PhiPresetSizeControl, { value: item.value, fallbackKey: item.fallbackPreset, options: options, onChange: (value) => updateToken({ [item.key]: value }) })] }, item.key))) }));
1304
1308
  const wireframe = readEffectiveTokenBoolean(styleTokenInput, "wireframe", true);
1305
- const pageMax = readEffectiveTokenNumber(styleTokenInput, "phiPageMax", PHI_LAYOUT.pageMax);
1309
+ const pageMax = readEffectiveTokenNumber(styleTokenInput, "pageMax", PHI_LAYOUT.pageMax);
1310
+ const [pagePaddingBand, setPagePaddingBand] = useState("Phone");
1311
+ const pagePaddingDefault = PHI_SPACE[PHI_LAYOUT.pagePadding[pagePaddingBand.toLowerCase()]];
1312
+ const pagePadding = Object.fromEntries(PHI_THEME_PAGE_PADDING_SIDES.map((side) => [
1313
+ `padding${side}`,
1314
+ readEffectiveTokenString(styleTokenInput, `pagePadding${side}${pagePaddingBand}`, pagePaddingDefault),
1315
+ ]));
1306
1316
  const baseFontSize = readEffectiveTokenNumber(styleTokenInput, "fontSize", 12);
1307
1317
  function updateToken(tokenPatch) {
1308
1318
  publishDraft(mergeThemeToken(state.draft, tokenPatch));
@@ -1420,7 +1430,20 @@ export function PhiBuilderBrandStyleControlsWidgetClient({ runtime, config, }) {
1420
1430
  */
1421
1431
  key: "pageWidth",
1422
1432
  label: _jsx(PhiTypographyControl, { strong: true, children: "Page Width" }),
1423
- children: (_jsxs(PhiFlexControl, { vertical: true, gap: clientToken.paddingXS, children: [_jsxs(PhiFlexControl, { align: "center", gap: clientToken.paddingSM, wrap: "nowrap", children: [_jsx(PhiTypographyControl, { style: { flex: `0 0 ${fieldLabelWidth}px` }, children: "Maximum" }), _jsx(PhiNumberControl, { prefix: "px", value: pageMax, step: 1, min: PHI_CONTAINER_BREAKPOINT_REGION, onChange: (next) => updateToken({ phiPageMax: next == null ? undefined : next }) })] }), _jsxs(PhiTypographyControl, { type: "secondary", children: ["How wide a Page gets on a wide screen. At least ", PHI_CONTAINER_BREAKPOINT_REGION, "px, the width from which a Region counts as wide."] })] })),
1433
+ children: (_jsxs(PhiFlexControl, { vertical: true, gap: clientToken.paddingXS, children: [_jsxs(PhiFlexControl, { align: "center", gap: clientToken.paddingSM, wrap: "nowrap", children: [_jsx(PhiTypographyControl, { style: { flex: `0 0 ${fieldLabelWidth}px` }, children: "Maximum" }), _jsx(PhiNumberControl, { prefix: "px", value: pageMax, step: 1, min: PHI_CONTAINER_BREAKPOINT_REGION, onChange: (next) => updateToken({ pageMax: next == null ? undefined : next }) })] }), _jsxs(PhiTypographyControl, { type: "secondary", children: ["How wide a Page gets on a wide screen. At least ", PHI_CONTAINER_BREAKPOINT_REGION, "px, the width from which a Region counts as wide."] })] })),
1434
+ },
1435
+ {
1436
+ /*
1437
+ * How far a Page's content stands in (`PHI_PAGE.padding`), per side and per screen: a phone
1438
+ * below 768, a tablet below 1200, a desktop from there. Only the default of the Page column
1439
+ * the presets and packages build; a Layout that states its own padding keeps it.
1440
+ */
1441
+ key: "pagePadding",
1442
+ label: _jsx(PhiTypographyControl, { strong: true, children: "Page Padding" }),
1443
+ children: (_jsxs(PhiFlexControl, { vertical: true, gap: clientToken.paddingXS, children: [_jsx(PhiSegmentedControl, { value: pagePaddingBand, options: PHI_THEME_PAGE_PADDING_BANDS.map((band) => ({ value: band, label: band })), onChange: setPagePaddingBand }), _jsx(PhiPaddingControl, { value: pagePadding, showGap: false, onChange: (next) => updateToken(Object.fromEntries(PHI_THEME_PAGE_PADDING_SIDES.map((side) => {
1444
+ const value = next?.[`padding${side}`] ?? next?.padding;
1445
+ return [`pagePadding${side}${pagePaddingBand}`, value == null ? undefined : value];
1446
+ }))) }), _jsx(PhiTypographyControl, { type: "secondary", children: "The default of a Page that does not set its own: a phone below 768px, a tablet below 1200px." })] })),
1424
1447
  },
1425
1448
  ] }) })] }));
1426
1449
  }
@@ -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 { PhiRuntimeDataProviderBinding } from "../types/runtime-data-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: PhiRuntimeDataProviderBinding;
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,42 @@
1
+ import "server-only";
2
+ import { readPhiPageRecordField, resolvePhiRecordFields } from "./record-fields";
3
+ import { resolvePhiRecordSource } from "./record-source";
4
+ /** What the record Providers of the active Modules offer, as a render's registry holds it. */
5
+ function buildRecordRegistry(runtimeModuleCatalog, activeModuleIds) {
6
+ const entries = [...activeModuleIds].flatMap((moduleId) => {
7
+ const entry = runtimeModuleCatalog.get(moduleId);
8
+ return entry ? [entry] : [];
9
+ });
10
+ return {
11
+ recordProviderLoadersByKey: new Map(entries.flatMap((entry) => (entry.recordProviders ?? []).map((provider) => [provider.key, provider.load]))),
12
+ recordFieldsLoadersByKey: new Map(entries.flatMap((entry) => (entry.recordProviders ?? []).flatMap((provider) => provider.loadFields ? [[provider.key, provider.loadFields]] : []))),
13
+ dataProviderDescriptorsByKey: new Map(entries.flatMap((entry) => (entry.definition.dataProviders ?? []).map((provider) => [provider.key, provider]))),
14
+ };
15
+ }
16
+ export async function resolvePhiCmsPageRecord({ binding, runtime, runtimeModuleCatalog, activeModuleIds }) {
17
+ const declaration = binding.descriptor.pageRecord;
18
+ if (!declaration) {
19
+ return null;
20
+ }
21
+ const route = `${binding.descriptor.ownerModuleId}/${binding.descriptor.presetKey}`;
22
+ const registry = buildRecordRegistry(runtimeModuleCatalog, activeModuleIds);
23
+ const descriptor = registry.dataProviderDescriptorsByKey.get(declaration.providerKey);
24
+ if (descriptor?.kind !== "record" || !descriptor.record) {
25
+ throw new Error(`${route}: its page record names "${declaration.providerKey}", which is no active record Provider with declared fields.`);
26
+ }
27
+ // A Public page is rendered once for everybody, so it cannot be about what only one account may read.
28
+ if (descriptor.record.audience === "viewer" && binding.descriptor.area === "public") {
29
+ throw new Error(`${route}: a Public route cannot be about a record of audience "viewer".`);
30
+ }
31
+ const record = {
32
+ providerKey: declaration.providerKey,
33
+ params: Object.fromEntries(Object.entries(declaration.params).map(([name, routeParam]) => [name, binding.params[routeParam] ?? ""])),
34
+ };
35
+ const source = await resolvePhiRecordSource({ registry, runtime, binding: record });
36
+ if (source.status === "missing") {
37
+ return { status: "missing" };
38
+ }
39
+ const fields = await resolvePhiRecordFields({ registry, runtime, binding: record });
40
+ const text = (key) => readPhiPageRecordField(fields, key, ["text"])?.value.trim() || null;
41
+ return { status: "ok", binding: record, title: text(declaration.titleField), description: text(declaration.descriptionField) };
42
+ }
@@ -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
- function buildPhiRuntimePage(pagePayload) {
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
- const resolvedContent = effectivePage;
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 {