@phis/ui 0.4.23 → 0.5.0

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 (102) hide show
  1. package/components/controls/phi-background-control.js +1 -1
  2. package/components/controls/phi-breadcrumb-control.d.ts +2 -0
  3. package/components/media/media-asset-typed-fields.d.ts +10 -0
  4. package/components/media/media-asset-typed-fields.js +19 -0
  5. package/components/media/media-settings-labels.d.ts +33 -0
  6. package/components/media/media-settings-labels.js +62 -0
  7. package/components/media/media-upload-flow.d.ts +19 -0
  8. package/components/media/media-upload-flow.js +38 -0
  9. package/components/media/phi-asset-focal-rect-widget.js +2 -2
  10. package/components/media/phi-image-inspector-widget.js +1 -1
  11. package/components/media/phi-image-preview-data.js +5 -4
  12. package/components/media/phi-site-font-assets.js +2 -5
  13. package/components/media/use-authoring-asset-details.js +0 -1
  14. package/components/regions/presets/navigation-redirect.d.ts +2 -2
  15. package/components/regions/presets/navigation-redirect.js +3 -3
  16. package/components/regions/presets/phi-area-shell-preset-nodes.js +2 -1
  17. package/components/widgets/helpers/internal-reference-resolver.server.d.ts +1 -1
  18. package/components/widgets/helpers/internal-reference-resolver.server.js +4 -0
  19. package/components/widgets/label-sets/builder-modules.js +6 -0
  20. package/components/widgets/label-types/builder-modules.d.ts +4 -0
  21. package/components/widgets/label-types/builder-modules.js +3 -0
  22. package/constants/runtime-module-ownership.js +4 -0
  23. package/gateway/internal-references.d.ts +5 -0
  24. package/gateway/internal-references.js +12 -12
  25. package/gateway/site-media-settings.d.ts +2 -0
  26. package/gateway/site-media-settings.js +6 -1
  27. package/gateway/site-media-storage-reader.d.ts +19 -0
  28. package/gateway/site-media-storage-reader.js +24 -0
  29. package/helpers/cms-navigation-catalog.d.ts +2 -0
  30. package/helpers/cms-navigation-catalog.js +1 -0
  31. package/helpers/cms-page-catalog.d.ts +12 -0
  32. package/helpers/cms-page-catalog.js +5 -0
  33. package/helpers/phi-seo.d.ts +16 -2
  34. package/helpers/phi-seo.js +54 -11
  35. package/helpers/public-route-claims.d.ts +4 -0
  36. package/helpers/public-route-claims.js +1 -1
  37. package/next/seo-routes.d.ts +1 -1
  38. package/next/seo-routes.js +23 -5
  39. package/package.json +1 -1
  40. package/plugins/runtime-modules/area-definitions.d.ts +75 -6
  41. package/plugins/runtime-modules/area-definitions.js +20 -0
  42. package/plugins/runtime-modules/asset/client-data-providers.js +12 -0
  43. package/plugins/runtime-modules/asset/controller/runtime.js +1 -1
  44. package/plugins/runtime-modules/asset/data-providers.d.ts +27 -2
  45. package/plugins/runtime-modules/asset/data-providers.js +56 -0
  46. package/plugins/runtime-modules/asset/definition.d.ts +38 -2
  47. package/plugins/runtime-modules/asset/definition.js +2 -1
  48. package/plugins/runtime-modules/asset/ids.d.ts +4 -0
  49. package/plugins/runtime-modules/asset/ids.js +4 -0
  50. package/plugins/runtime-modules/asset/server.js +2 -1
  51. package/plugins/runtime-modules/asset/services/options.d.ts +7 -0
  52. package/plugins/runtime-modules/asset/services/options.js +38 -0
  53. package/plugins/runtime-modules/asset/services/storage-spaces-table.d.ts +3 -0
  54. package/plugins/runtime-modules/asset/services/storage-spaces-table.js +89 -0
  55. package/plugins/runtime-modules/asset/settings-forms.d.ts +17 -0
  56. package/plugins/runtime-modules/asset/settings-forms.js +117 -1
  57. package/plugins/runtime-modules/asset/trees/phi-default-admin-media-settings-page-tree.js +94 -1
  58. package/plugins/runtime-modules/builder/area-shell-presets.server.d.ts +8 -0
  59. package/plugins/runtime-modules/builder/area-shell-presets.server.js +13 -0
  60. package/plugins/runtime-modules/builder/controller/page-controller-helpers.js +1 -1
  61. package/plugins/runtime-modules/builder/controller/page-controller.d.ts +1 -1
  62. package/plugins/runtime-modules/builder/controller/page-controller.js +30 -3
  63. package/plugins/runtime-modules/builder/controller/server-definition.d.ts +7 -1
  64. package/plugins/runtime-modules/builder/controller/server-definition.js +8 -3
  65. package/plugins/runtime-modules/builder/data-providers.js +1 -0
  66. package/plugins/runtime-modules/builder/developer-workspace-types.d.ts +2 -0
  67. package/plugins/runtime-modules/builder/navigation-path-context.js +7 -3
  68. package/plugins/runtime-modules/builder/options-providers.js +2 -2
  69. package/plugins/runtime-modules/builder/page-address-rule.d.ts +39 -0
  70. package/plugins/runtime-modules/builder/page-address-rule.js +62 -0
  71. package/plugins/runtime-modules/builder/page-meta-form.js +10 -0
  72. package/plugins/runtime-modules/builder/public-route-collisions.js +7 -2
  73. package/plugins/runtime-modules/builder/services/page-source-tree.js +2 -1
  74. package/plugins/runtime-modules/builder/services/runtime-modules-table.js +49 -1
  75. package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +14 -2
  76. package/plugins/runtime-modules/core/widgets/breadcrumb/client.d.ts +14 -2
  77. package/plugins/runtime-modules/core/widgets/breadcrumb/client.js +35 -4
  78. package/plugins/runtime-modules/core/widgets/breadcrumb/server.d.ts +3 -1
  79. package/plugins/runtime-modules/core/widgets/breadcrumb/server.js +37 -2
  80. package/plugins/runtime-modules/core/widgets/card/editor.js +1 -1
  81. package/plugins/runtime-modules/core/widgets/image/client.js +1 -1
  82. package/plugins/runtime-modules/core/widgets/image/editor.js +1 -1
  83. package/plugins/runtime-modules/core/widgets/page-title/authoring.js +3 -1
  84. package/plugins/runtime-modules/core/widgets/page-title/client.d.ts +3 -1
  85. package/plugins/runtime-modules/core/widgets/page-title/client.js +5 -1
  86. package/plugins/runtime-modules/core/widgets/page-title/config.d.ts +25 -3
  87. package/plugins/runtime-modules/core/widgets/page-title/config.js +24 -3
  88. package/plugins/runtime-modules/core/widgets/page-title/plugin.js +1 -1
  89. package/plugins/runtime-modules/core/widgets/page-title/server.d.ts +3 -1
  90. package/plugins/runtime-modules/core/widgets/page-title/server.js +4 -3
  91. package/plugins/runtime-modules/core/widgets/table/client.js +1 -1
  92. package/plugins/runtime-modules/core/widgets/table/config.js +9 -0
  93. package/plugins/runtime-modules/descriptor-compiler.js +33 -8
  94. package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +1 -1
  95. package/server-helpers/cms-review-params.d.ts +25 -0
  96. package/server-helpers/cms-review-params.js +54 -0
  97. package/server-helpers/cms-review.d.ts +1 -25
  98. package/server-helpers/cms-review.js +2 -54
  99. package/types/cms-module-descriptors.d.ts +33 -3
  100. package/types/media.d.ts +6 -2
  101. package/types/table-widget.d.ts +11 -0
  102. package/types.d.ts +1 -1
@@ -1,6 +1,41 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
3
3
  import { PhiRuntimeModuleRenderClientHost } from "../../../../../components/runtime/runtime-module-render-client-manifest";
4
- export function PhiBreadcrumbWidget(props) {
5
- return (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.Breadcrumb, componentProps: { ...props } }));
4
+ import { fetchSiteNavigationFolderTarget } from "../../../../../gateway/site-nav";
5
+ import { readPhiServerApiCredentials } from "../../../../../helpers/phis-server-credentials";
6
+ /** The folders a Page path lies in, outermost first: `/docs/guides/a` gives `/docs` and `/docs/guides`. */
7
+ export function listPhiBreadcrumbFolderPaths(pagePath) {
8
+ const segments = pagePath.split("/").filter(Boolean);
9
+ return segments.slice(0, -1).map((_segment, index) => `/${segments.slice(0, index + 1).join("/")}`);
10
+ }
11
+ /**
12
+ * Which folders of the Page's path lead somewhere, so the client links exactly those.
13
+ *
14
+ * A folder segment is a link when its folder address resolves to a Page (REFERENCES.md, "Folder
15
+ * addresses"); one that resolves to nothing would be a link into a 404. Asked once per folder of the
16
+ * path, which is the depth of the path and not the size of the Site, and only when the trail shows the
17
+ * path at all. A failed lookup leaves that segment unlinked rather than failing the trail.
18
+ */
19
+ async function resolveLinkedFolderPaths(props) {
20
+ const { config, runtime } = props;
21
+ const pagePath = runtime?.page?.path;
22
+ if (!pagePath || !runtime?.site?.key || config?.showPath === false || config?.pathLabel?.trim()) {
23
+ return [];
24
+ }
25
+ const folders = listPhiBreadcrumbFolderPaths(pagePath);
26
+ if (folders.length === 0)
27
+ return [];
28
+ const { apiBaseUrl, internalToken } = readPhiServerApiCredentials();
29
+ const answers = await Promise.all(folders.map((path) => fetchSiteNavigationFolderTarget({
30
+ apiBaseUrl,
31
+ internalToken,
32
+ siteKey: runtime.site.key,
33
+ area: String(runtime.area),
34
+ path,
35
+ }).catch(() => null)));
36
+ return folders.filter((_path, index) => answers[index] != null);
37
+ }
38
+ export async function PhiBreadcrumbWidget(props) {
39
+ const linkedFolderPaths = await resolveLinkedFolderPaths(props);
40
+ return (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.Breadcrumb, componentProps: { ...props, pagePath: props.runtime?.page?.path ?? null, linkedFolderPaths } }));
6
41
  }
@@ -124,7 +124,7 @@ export function PhiCardWidgetEditor({ config, onChange }) {
124
124
  deliveryRevision: asset?.deliveryRevision,
125
125
  originalUrl: assetId == null ? null : buildPhiMediaAssetContentDeliveryUrl(assetId),
126
126
  sourceUrl: config.sourceKind === "url" ? config.sourceUrl : undefined,
127
- focalRect: asset?.meta?.focalRect,
127
+ focalRect: asset?.focalRect,
128
128
  sourceWidth: asset?.width,
129
129
  sourceHeight: asset?.height,
130
130
  });
@@ -41,7 +41,7 @@ export function PhiImageWidget({ labels, config, resolvedAsset, focalRect, autho
41
41
  deliveryRevision: resolvedAsset?.deliveryRevision,
42
42
  originalUrl: resolvedAsset?.deliveryUrl,
43
43
  sourceUrl: configSourceUrl,
44
- focalRect: focalRect ?? resolvedAsset?.meta?.focalRect,
44
+ focalRect: focalRect ?? resolvedAsset?.focalRect,
45
45
  fit: config?.fit,
46
46
  objectPosition: config?.objectPosition,
47
47
  sourceWidth: resolvedAsset?.width,
@@ -55,7 +55,7 @@ export function PhiImageWidgetEditor({ config, onChange }) {
55
55
  onChange,
56
56
  ]);
57
57
  const overlaySize = formatImageEditorOverlaySize(config, resolvedAssetDetails, config?.imageSize?.width ?? resolvedAssetDetails?.width, config?.imageSize?.height ?? resolvedAssetDetails?.height);
58
- return (_jsxs("div", { style: { position: "relative", display: "inline-block", maxWidth: "100%" }, children: [_jsx(PhiImageWidget, { labels: PHI_IMAGE_WIDGET_DEFAULT_LABELS, config: config ?? undefined, resolvedAsset: resolvedAssetDetails, focalRect: resolvedAssetDetails?.meta?.focalRect ?? null }), assetId != null ? (_jsxs(PhiTypographyControl, { style: {
58
+ return (_jsxs("div", { style: { position: "relative", display: "inline-block", maxWidth: "100%" }, children: [_jsx(PhiImageWidget, { labels: PHI_IMAGE_WIDGET_DEFAULT_LABELS, config: config ?? undefined, resolvedAsset: resolvedAssetDetails, focalRect: resolvedAssetDetails?.focalRect ?? null }), assetId != null ? (_jsxs(PhiTypographyControl, { style: {
59
59
  position: "absolute",
60
60
  top: "0.375rem",
61
61
  right: "0.375rem",
@@ -5,5 +5,7 @@ import { PHI_PAGE_TITLE_WIDGET_DEFAULT_LABELS } from "../../../../../components/
5
5
  import { PhiTypographyControl } from "../../../../../components/controls/phi-typography-control";
6
6
  export const PHI_PAGE_TITLE_WIDGET_BUILDER_PLUGIN = {
7
7
  ...PHI_PAGE_TITLE_WIDGET_DEFINITION,
8
- renderEditor: () => (_jsx(PhiTypographyControl, { presentation: "title", level: 5, style: { margin: 0, whiteSpace: "nowrap" }, children: PHI_PAGE_TITLE_WIDGET_DEFAULT_LABELS.editorPlaceholder })),
8
+ renderEditor: ({ config }) => (config.display === "heading"
9
+ ? (_jsx(PhiTypographyControl, { presentation: "title", level: 1, style: { margin: 0, textAlign: "center" }, children: PHI_PAGE_TITLE_WIDGET_DEFAULT_LABELS.editorPlaceholder }))
10
+ : (_jsx(PhiTypographyControl, { presentation: "title", level: 5, style: { margin: 0, whiteSpace: "nowrap" }, children: PHI_PAGE_TITLE_WIDGET_DEFAULT_LABELS.editorPlaceholder }))),
9
11
  };
@@ -1,5 +1,7 @@
1
+ import type { PhiPageTitleWidgetDisplay } from "./config";
1
2
  export type PhiPageTitleWidgetClientProps = {
2
3
  initialTitle: string;
3
4
  area?: string | null;
5
+ display: PhiPageTitleWidgetDisplay;
4
6
  };
5
- export declare function PhiPageTitleWidgetClient({ initialTitle, area, }: PhiPageTitleWidgetClientProps): import("react").JSX.Element;
7
+ export declare function PhiPageTitleWidgetClient({ initialTitle, area, display, }: PhiPageTitleWidgetClientProps): import("react").JSX.Element;
@@ -4,7 +4,8 @@ import { useState } from "react";
4
4
  import { usePhiSignalListener } from "../../../../../components/runtime/runtime-signal-bus";
5
5
  import { resolvePhiPageTitleSignalValue } from "../../../../../components/widgets/signals/page-title-signals";
6
6
  import { createPhiCoreRuntimeControllerAddress } from "../../../../../components/runtime/core-runtime-controller-address";
7
- export function PhiPageTitleWidgetClient({ initialTitle, area, }) {
7
+ import { PhiTypographyControl } from "../../../../../components/controls/phi-typography-control";
8
+ export function PhiPageTitleWidgetClient({ initialTitle, area, display, }) {
8
9
  const [state, setState] = useState(() => ({
9
10
  source: initialTitle,
10
11
  value: initialTitle,
@@ -39,6 +40,9 @@ export function PhiPageTitleWidgetClient({ initialTitle, area, }) {
39
40
  channels: ["pageMeta", "pageTitle"],
40
41
  receiver: "broadcast",
41
42
  });
43
+ if (display === "heading") {
44
+ return (_jsx(PhiTypographyControl, { presentation: "title", level: 1, style: { margin: 0, textAlign: "center" }, children: title }));
45
+ }
42
46
  return (_jsx("div", { style: {
43
47
  fontSize: "1.25rem",
44
48
  fontWeight: 600,
@@ -1,5 +1,16 @@
1
- export type PhiPageTitleWidgetConfig = Record<string, never>;
2
- declare function parsePhiPageTitleWidgetConfig(): PhiPageTitleWidgetConfig;
1
+ /**
2
+ * How the title stands.
3
+ *
4
+ * `heading` is the Page's own heading: its one `h1`, on the type scale, wrapping, centred. `label` is the
5
+ * title as a caption in a bar -- the Shell's header -- where a heading would give the page a second `h1`
6
+ * and the bar a line break.
7
+ */
8
+ export declare const PHI_PAGE_TITLE_WIDGET_DISPLAYS: readonly ["heading", "label"];
9
+ export type PhiPageTitleWidgetDisplay = (typeof PHI_PAGE_TITLE_WIDGET_DISPLAYS)[number];
10
+ export type PhiPageTitleWidgetConfig = {
11
+ display: PhiPageTitleWidgetDisplay;
12
+ };
13
+ declare function parsePhiPageTitleWidgetConfig(config: Record<string, unknown>): PhiPageTitleWidgetConfig;
3
14
  export declare const PHI_PAGE_TITLE_WIDGET_DEFINITION: {
4
15
  kind: "widget";
5
16
  pluginKey: string;
@@ -9,7 +20,18 @@ export declare const PHI_PAGE_TITLE_WIDGET_DEFINITION: {
9
20
  category: "content";
10
21
  description: string;
11
22
  iconFamily: string;
12
- fields: never[];
23
+ fields: {
24
+ key: string;
25
+ type: "choice";
26
+ label: string;
27
+ options: {
28
+ value: string;
29
+ label: string;
30
+ }[];
31
+ }[];
32
+ defaultConfig: {
33
+ display: "heading";
34
+ };
13
35
  parseConfig: typeof parsePhiPageTitleWidgetConfig;
14
36
  };
15
37
  export {};
@@ -1,6 +1,16 @@
1
1
  import { resolvePhiCmsWidgetPluginKey } from "../../../../../constants/cms-widget-types";
2
- function parsePhiPageTitleWidgetConfig() {
3
- return {};
2
+ import { createPhiConfigReader } from "../../../../../components/widgets/config/strict-config-reader";
3
+ /**
4
+ * How the title stands.
5
+ *
6
+ * `heading` is the Page's own heading: its one `h1`, on the type scale, wrapping, centred. `label` is the
7
+ * title as a caption in a bar -- the Shell's header -- where a heading would give the page a second `h1`
8
+ * and the bar a line break.
9
+ */
10
+ export const PHI_PAGE_TITLE_WIDGET_DISPLAYS = ["heading", "label"];
11
+ function parsePhiPageTitleWidgetConfig(config) {
12
+ const reader = createPhiConfigReader(config);
13
+ return { display: reader.oneOf("display", PHI_PAGE_TITLE_WIDGET_DISPLAYS) ?? "heading" };
4
14
  }
5
15
  export const PHI_PAGE_TITLE_WIDGET_DEFINITION = {
6
16
  kind: "widget",
@@ -11,6 +21,17 @@ export const PHI_PAGE_TITLE_WIDGET_DEFINITION = {
11
21
  category: "content",
12
22
  description: "Displays the current localized CMS page title from runtime metadata.",
13
23
  iconFamily: "basic",
14
- fields: [],
24
+ fields: [
25
+ {
26
+ key: "display",
27
+ type: "choice",
28
+ label: "Shows as",
29
+ options: [
30
+ { value: "heading", label: "Page heading" },
31
+ { value: "label", label: "Caption" },
32
+ ],
33
+ },
34
+ ],
35
+ defaultConfig: { display: "heading" },
15
36
  parseConfig: parsePhiPageTitleWidgetConfig,
16
37
  };
@@ -4,5 +4,5 @@ import { PHI_PAGE_TITLE_WIDGET_DEFINITION } from "./config";
4
4
  import { PhiPageTitleWidgetServer } from "./server";
5
5
  export const PHI_PAGE_TITLE_WIDGET_PLUGIN = {
6
6
  ...PHI_PAGE_TITLE_WIDGET_DEFINITION,
7
- ...definePhiPassiveWidgetRenderers(({ runtime }) => _jsx(PhiPageTitleWidgetServer, { runtime: runtime })),
7
+ ...definePhiPassiveWidgetRenderers(({ runtime, config }) => _jsx(PhiPageTitleWidgetServer, { runtime: runtime, config: config })),
8
8
  };
@@ -1,4 +1,6 @@
1
1
  import type { PhiServerBlockBaseProps } from "../../../../../types";
2
2
  import type { PhiPageTitleWidgetConfig } from "./config";
3
3
  import type { PhiPageTitleWidgetLabels } from "../../../../../components/widgets/label-types/page-title";
4
- export declare function PhiPageTitleWidgetServer({ runtime, }: Pick<PhiServerBlockBaseProps<PhiPageTitleWidgetLabels, PhiPageTitleWidgetConfig>, "runtime">): Promise<import("react").JSX.Element>;
4
+ export declare function PhiPageTitleWidgetServer({ runtime, config, }: Pick<PhiServerBlockBaseProps<PhiPageTitleWidgetLabels, PhiPageTitleWidgetConfig>, "runtime"> & {
5
+ config: PhiPageTitleWidgetConfig;
6
+ }): Promise<import("react").JSX.Element>;
@@ -3,14 +3,15 @@ import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
3
3
  import { PhiRuntimeModuleRenderClientHost } from "../../../../../components/runtime/runtime-module-render-client-manifest";
4
4
  import { getPhiPageTitleWidgetLabels } from "../../../../../components/widgets/label-sets/page-title";
5
5
  import { buildPhiWidgetLabelTranslatorOptions } from "../../../../../components/widgets/label-sets/runtime-options";
6
- function PhiPageTitleWidget({ labels, runtime, }) {
6
+ function PhiPageTitleWidget({ labels, runtime, config, }) {
7
7
  const title = runtime.page?.title?.trim() || labels.emptyTitle;
8
8
  return (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.PageTitle, componentProps: {
9
9
  initialTitle: title,
10
10
  area: runtime.area ?? null,
11
+ display: config.display,
11
12
  } }));
12
13
  }
13
- export async function PhiPageTitleWidgetServer({ runtime, }) {
14
+ export async function PhiPageTitleWidgetServer({ runtime, config, }) {
14
15
  const labels = await getPhiPageTitleWidgetLabels(buildPhiWidgetLabelTranslatorOptions(runtime));
15
- return _jsx(PhiPageTitleWidget, { labels: labels, runtime: runtime, config: {} });
16
+ return _jsx(PhiPageTitleWidget, { labels: labels, runtime: runtime, config: config });
16
17
  }
@@ -601,7 +601,7 @@ export function PhiTableWidgetClient({ config: inputConfig, renderMode, external
601
601
  required: field.required,
602
602
  disabled: loading,
603
603
  constraints: field.constraints,
604
- options: field.options,
604
+ options: column.editor?.options ?? field.options,
605
605
  prefix: column.editor?.prefix,
606
606
  }
607
607
  : undefined;
@@ -242,6 +242,15 @@ function readColumn(reader) {
242
242
  control: editorReader.oneOf("control", PHI_TABLE_COLUMN_EDITOR_CONTROLS),
243
243
  disabledWhen: readCondition(editorReader, "disabledWhen"),
244
244
  ...(editorReader.string("prefix") ? { prefix: editorReader.string("prefix") } : {}),
245
+ // The Site's own choices for a select cell, set by the placement (`editor.options`).
246
+ ...(editorReader.has("options")
247
+ ? {
248
+ options: editorReader.list("options", (option) => ({
249
+ value: requireString(option, "value"),
250
+ label: requireString(option, "label"),
251
+ })) ?? [],
252
+ }
253
+ : {}),
245
254
  });
246
255
  return {
247
256
  key: requireString(reader, "key"),
@@ -424,14 +424,18 @@ export function compilePhiCmsDescriptorCatalog({ catalog, areaDefinitions, }) {
424
424
  if (item.routePresetKey && item.overlayPresetKey) {
425
425
  throw new Error(`${label}/${item.itemKey}: an item goes to a route or opens an Overlay, never both.`);
426
426
  }
427
- // Only a Module's injected entry may lead out; an Area's own items carry no `target`.
428
- const externalTarget = "target" in item ? item.target : undefined;
429
- if (externalTarget !== undefined) {
427
+ // An external address is a Module's injected entry only; another Area's root either may name.
428
+ const target = item.target;
429
+ if (target !== undefined) {
430
430
  if (item.routePresetKey || item.overlayPresetKey || item.overlayNodeKey) {
431
- throw new Error(`${label}/${item.itemKey}: an item leads to an external address, a route or an Overlay, ` +
432
- "never more than one.");
431
+ throw new Error(`${label}/${item.itemKey}: an item leads to a target, a route or an Overlay, never more than one.`);
432
+ }
433
+ if (target.kind === "area") {
434
+ assertNavigationAreaTarget(target, area, `${label}/${item.itemKey}`);
435
+ }
436
+ else {
437
+ assertNavigationExternalTarget(target, `${label}/${item.itemKey}`);
433
438
  }
434
- assertNavigationExternalTarget(externalTarget, `${label}/${item.itemKey}`);
435
439
  }
436
440
  if (item.overlayPresetKey && !item.overlayNodeKey) {
437
441
  throw new Error(`${label}/${item.itemKey}: an Overlay reference needs both a preset key and a node key.`);
@@ -786,6 +790,18 @@ function assertNavigationExternalTarget(target, label) {
786
790
  throw new Error(`${label}: an external navigation target's newTab must be a boolean.`);
787
791
  }
788
792
  }
793
+ /**
794
+ * Another Area's root: an Area this Site has, and not the surface's own -- a link to one's own root is
795
+ * a route of the Area's base Module, and is named as one.
796
+ */
797
+ function assertNavigationAreaTarget(target, ownArea, label) {
798
+ if (!isPhiCmsAreaKey(target.area)) {
799
+ throw new Error(`${label}: an Area navigation target names an unknown Area "${String(target.area)}".`);
800
+ }
801
+ if (target.area === ownArea) {
802
+ throw new Error(`${label}: an Area navigation target must lead to another Area than "${ownArea}".`);
803
+ }
804
+ }
789
805
  /**
790
806
  * What an item points at, if anything currently answers there.
791
807
  *
@@ -801,6 +817,10 @@ function assertNavigationExternalTarget(target, label) {
801
817
  * turned down in the sidebar, linking `/`.
802
818
  */
803
819
  function resolveNavigationTarget(routeTable, ownerModuleId, routePresetKey, overlay, external) {
820
+ if (external?.kind === "area") {
821
+ // The Area segment, which every renderer reads as that Area's root; the root forwards from there.
822
+ return { kind: "area", area: external.area, path: `/${external.area}` };
823
+ }
804
824
  if (external) {
805
825
  // The shape a Site's stored external link resolves to, so every surface renders both alike. The
806
826
  // entry stays the Module's: `ownerModuleId` on the item, not the target, says whose it is.
@@ -838,7 +858,12 @@ function resolveNavigationTarget(routeTable, ownerModuleId, routePresetKey, over
838
858
  function buildResolvedNavigationNode(catalog, routeTable, navKey, ownerModuleId, descriptor, injection) {
839
859
  const target = resolveNavigationTarget(routeTable, ownerModuleId, descriptor.routePresetKey, descriptor.overlayPresetKey && descriptor.overlayNodeKey
840
860
  ? { presetKey: descriptor.overlayPresetKey, nodeKey: descriptor.overlayNodeKey }
841
- : null, "target" in descriptor ? descriptor.target : undefined);
861
+ : null, descriptor.target);
862
+ /*
863
+ * An Area entry that states no policy of its own is shown to whoever the target Area lets in: an entry
864
+ * leading to a door that turns the viewer away is a link nobody should have been offered.
865
+ */
866
+ const accessPolicy = descriptor.accessPolicy ?? (descriptor.target?.kind === "area" ? catalog.areaDefinitions.get(descriptor.target.area)?.accessPolicy : undefined);
842
867
  const intrinsicChildren = (descriptor.children ?? []).map((child) => buildResolvedNavigationNode(catalog, routeTable, navKey, ownerModuleId, child, null));
843
868
  const sourceLocale = catalog.sourceLocaleByModuleId.get(ownerModuleId);
844
869
  if (!sourceLocale) {
@@ -858,7 +883,7 @@ function buildResolvedNavigationNode(catalog, routeTable, navKey, ownerModuleId,
858
883
  kind: target || descriptor.signalRoutes?.emits?.length ? "link" : "container",
859
884
  label: { ...descriptor.label, sourceLocale },
860
885
  ...(descriptor.icon ? { icon: descriptor.icon } : {}),
861
- ...(descriptor.accessPolicy ? { accessPolicy: descriptor.accessPolicy } : {}),
886
+ ...(accessPolicy ? { accessPolicy } : {}),
862
887
  ...(descriptor.signalRoutes?.emits?.length
863
888
  ? { emits: descriptor.signalRoutes.emits }
864
889
  : {}),
@@ -1397,7 +1397,7 @@ export function PhiBuilderBrandStyleControlsWidgetClient({ runtime, config, }) {
1397
1397
  label: _jsx(PhiTypographyControl, { strong: true, children: "Font Family" }),
1398
1398
  children: (_jsxs(PhiFlexControl, { vertical: true, gap: clientToken.paddingXS, children: [fontSlots.map((item) => (_jsxs(PhiFlexControl, { align: "center", gap: clientToken.paddingSM, wrap: "nowrap", children: [_jsx(PhiTypographyControl, { style: { flex: `0 0 ${fieldLabelWidth}px` }, children: item.label }), _jsx(PhiSelectControl, { ariaLabel: `${item.label} font`, value: item.authored ?? undefined, placeholder: item.inherited || "Not installed", options: fontOptions, allowClear: true, size: "medium", style: { minWidth: 0, flex: "1 1 auto" }, onChange: (value) => publishDraft(
1399
1399
  // A cleared select reports nothing, which hands the slot back to the Set.
1400
- mergeThemeFontSlot(state.draft, item.key, value ?? null)) })] }, item.key))), _jsx(PhiDividerControl, { style: { marginBlock: clientToken.paddingXXS } }), _jsxs(PhiFlexControl, { align: "center", gap: clientToken.paddingSM, wrap: "nowrap", children: [_jsx(PhiTypographyControl, { style: { flex: `0 0 ${fieldLabelWidth}px` }, children: "Headings" }), _jsx(PhiSegmentedControl, { value: readPhiThemeHeadingFont(state.draft.typography), options: PHI_THEME_HEADING_FONT_OPTIONS, size: "small", onChange: (heading) => publishDraft(mergeThemeHeadingFont(state.draft, heading)) })] })] })),
1400
+ mergeThemeFontSlot(state.draft, item.key, value ?? null)) })] }, item.key))), siteFontAssets.options.length > 0 ? (_jsx(PhiTypographyControl, { type: "secondary", style: { fontSize: clientToken.fontSizeSM }, children: "Typefaces from the media library are delivered as subsets, which modifies the font file. Check that the font's licence permits subsetting before using it." })) : null, _jsx(PhiDividerControl, { style: { marginBlock: clientToken.paddingXXS } }), _jsxs(PhiFlexControl, { align: "center", gap: clientToken.paddingSM, wrap: "nowrap", children: [_jsx(PhiTypographyControl, { style: { flex: `0 0 ${fieldLabelWidth}px` }, children: "Headings" }), _jsx(PhiSegmentedControl, { value: readPhiThemeHeadingFont(state.draft.typography), options: PHI_THEME_HEADING_FONT_OPTIONS, size: "small", onChange: (heading) => publishDraft(mergeThemeHeadingFont(state.draft, heading)) })] })] })),
1401
1401
  },
1402
1402
  {
1403
1403
  key: "fontSize",
@@ -0,0 +1,25 @@
1
+ import { type PhiCmsReviewKind } from "../helpers/cms-scope-search-params";
2
+ export type { PhiCmsReviewKind };
3
+ export type PhiCmsReviewParams = {
4
+ kind: PhiCmsReviewKind;
5
+ revisionId: number;
6
+ area?: string | null;
7
+ page?: string | null;
8
+ navKey?: string | null;
9
+ themeKey?: string | null;
10
+ };
11
+ export declare function resolvePhiCmsReviewParams(searchParams?: Record<string, string | undefined>): PhiCmsReviewParams | null;
12
+ export declare function getPhiCmsReviewRevision(review: PhiCmsReviewParams | null | undefined, kind: PhiCmsReviewKind): number | null;
13
+ /**
14
+ * Whether this request reads the Area or the Page as a revision Core had to authorize.
15
+ *
16
+ * `revision` and a review of kind `area` or `page` are passed on to Core's Area and Page reads, and
17
+ * Core answers them only to a viewer it allows to preview (`requireSiteCmsPreviewApiContext`); a
18
+ * refusal comes back as 401/403 before anything renders. That is what lets the Area access guard step
19
+ * aside for such a request: somebody else has already decided. A review of kind `navigation` or
20
+ * `theme` changes neither read -- the Area and the Page come back live, unauthorized -- so it is no
21
+ * reason to step aside. Deciding on "any valid review" did exactly that, and
22
+ * `?reviewKind=navigation&reviewRevision=1` showed an anonymous visitor a staff Area's shell.
23
+ */
24
+ export declare function hasPhiCmsAuthorizedPreviewRead(searchParams?: Record<string, string | undefined>): boolean;
25
+ export declare function resolvePhiCmsRevisionFromSearchParams(searchParams?: Record<string, string | undefined>): number | null;
@@ -0,0 +1,54 @@
1
+ import { isPhiCmsReviewKind } from "../helpers/cms-scope-search-params";
2
+ function normalizeReviewKind(value) {
3
+ const normalized = value?.trim().toLowerCase();
4
+ return isPhiCmsReviewKind(normalized) ? normalized : null;
5
+ }
6
+ function normalizeOptionalString(value) {
7
+ const normalized = value?.trim();
8
+ return normalized ? normalized : null;
9
+ }
10
+ export function resolvePhiCmsReviewParams(searchParams) {
11
+ const kind = normalizeReviewKind(searchParams?.reviewKind);
12
+ const rawRevision = searchParams?.reviewRevision?.trim();
13
+ const revisionId = rawRevision ? Number(rawRevision) : null;
14
+ if (!kind || !Number.isInteger(revisionId) || revisionId <= 0) {
15
+ return null;
16
+ }
17
+ return {
18
+ kind,
19
+ revisionId: revisionId,
20
+ area: normalizeOptionalString(searchParams?.reviewArea),
21
+ page: normalizeOptionalString(searchParams?.reviewPage),
22
+ navKey: normalizeOptionalString(searchParams?.reviewNavKey),
23
+ themeKey: normalizeOptionalString(searchParams?.reviewThemeKey),
24
+ };
25
+ }
26
+ export function getPhiCmsReviewRevision(review, kind) {
27
+ return review?.kind === kind ? review.revisionId : null;
28
+ }
29
+ /**
30
+ * Whether this request reads the Area or the Page as a revision Core had to authorize.
31
+ *
32
+ * `revision` and a review of kind `area` or `page` are passed on to Core's Area and Page reads, and
33
+ * Core answers them only to a viewer it allows to preview (`requireSiteCmsPreviewApiContext`); a
34
+ * refusal comes back as 401/403 before anything renders. That is what lets the Area access guard step
35
+ * aside for such a request: somebody else has already decided. A review of kind `navigation` or
36
+ * `theme` changes neither read -- the Area and the Page come back live, unauthorized -- so it is no
37
+ * reason to step aside. Deciding on "any valid review" did exactly that, and
38
+ * `?reviewKind=navigation&reviewRevision=1` showed an anonymous visitor a staff Area's shell.
39
+ */
40
+ export function hasPhiCmsAuthorizedPreviewRead(searchParams) {
41
+ if (resolvePhiCmsRevisionFromSearchParams(searchParams) != null) {
42
+ return true;
43
+ }
44
+ const review = resolvePhiCmsReviewParams(searchParams);
45
+ return review?.kind === "area" || review?.kind === "page";
46
+ }
47
+ export function resolvePhiCmsRevisionFromSearchParams(searchParams) {
48
+ const rawValue = searchParams?.revision;
49
+ if (!rawValue?.trim()) {
50
+ return null;
51
+ }
52
+ const parsed = Number(rawValue);
53
+ return Number.isInteger(parsed) && parsed > 0 ? parsed : null;
54
+ }
@@ -1,30 +1,6 @@
1
1
  import "server-only";
2
2
  import type { PhiSiteRequestContext } from "../types/site-request-context";
3
- import { type PhiCmsReviewKind } from "../helpers/cms-scope-search-params";
4
- export type { PhiCmsReviewKind };
5
- export type PhiCmsReviewParams = {
6
- kind: PhiCmsReviewKind;
7
- revisionId: number;
8
- area?: string | null;
9
- page?: string | null;
10
- navKey?: string | null;
11
- themeKey?: string | null;
12
- };
13
- export declare function resolvePhiCmsReviewParams(searchParams?: Record<string, string | undefined>): PhiCmsReviewParams | null;
14
- export declare function getPhiCmsReviewRevision(review: PhiCmsReviewParams | null | undefined, kind: PhiCmsReviewKind): number | null;
15
- /**
16
- * Whether this request reads the Area or the Page as a revision Core had to authorize.
17
- *
18
- * `revision` and a review of kind `area` or `page` are passed on to Core's Area and Page reads, and
19
- * Core answers them only to a viewer it allows to preview (`requireSiteCmsPreviewApiContext`); a
20
- * refusal comes back as 401/403 before anything renders. That is what lets the Area access guard step
21
- * aside for such a request: somebody else has already decided. A review of kind `navigation` or
22
- * `theme` changes neither read -- the Area and the Page come back live, unauthorized -- so it is no
23
- * reason to step aside. Deciding on "any valid review" did exactly that, and
24
- * `?reviewKind=navigation&reviewRevision=1` showed an anonymous visitor a staff Area's shell.
25
- */
26
- export declare function hasPhiCmsAuthorizedPreviewRead(searchParams?: Record<string, string | undefined>): boolean;
27
- export declare function resolvePhiCmsRevisionFromSearchParams(searchParams?: Record<string, string | undefined>): number | null;
3
+ export { getPhiCmsReviewRevision, hasPhiCmsAuthorizedPreviewRead, resolvePhiCmsReviewParams, resolvePhiCmsRevisionFromSearchParams, type PhiCmsReviewKind, type PhiCmsReviewParams, } from "./cms-review-params";
28
4
  export declare function resolvePhiCmsThemeReviewRequestContext({ requestContext, searchParams, cookieHeader, }: {
29
5
  requestContext: PhiSiteRequestContext;
30
6
  searchParams?: Record<string, string | undefined>;
@@ -1,60 +1,8 @@
1
1
  import "server-only";
2
2
  import { getSiteThemeRevision } from "../gateway/site-theme";
3
3
  import { readPhiServerApiCredentials } from "../helpers/phis-server-credentials";
4
- import { isPhiCmsReviewKind } from "../helpers/cms-scope-search-params";
5
- function normalizeReviewKind(value) {
6
- const normalized = value?.trim().toLowerCase();
7
- return isPhiCmsReviewKind(normalized) ? normalized : null;
8
- }
9
- function normalizeOptionalString(value) {
10
- const normalized = value?.trim();
11
- return normalized ? normalized : null;
12
- }
13
- export function resolvePhiCmsReviewParams(searchParams) {
14
- const kind = normalizeReviewKind(searchParams?.reviewKind);
15
- const rawRevision = searchParams?.reviewRevision?.trim();
16
- const revisionId = rawRevision ? Number(rawRevision) : null;
17
- if (!kind || !Number.isInteger(revisionId) || revisionId <= 0) {
18
- return null;
19
- }
20
- return {
21
- kind,
22
- revisionId: revisionId,
23
- area: normalizeOptionalString(searchParams?.reviewArea),
24
- page: normalizeOptionalString(searchParams?.reviewPage),
25
- navKey: normalizeOptionalString(searchParams?.reviewNavKey),
26
- themeKey: normalizeOptionalString(searchParams?.reviewThemeKey),
27
- };
28
- }
29
- export function getPhiCmsReviewRevision(review, kind) {
30
- return review?.kind === kind ? review.revisionId : null;
31
- }
32
- /**
33
- * Whether this request reads the Area or the Page as a revision Core had to authorize.
34
- *
35
- * `revision` and a review of kind `area` or `page` are passed on to Core's Area and Page reads, and
36
- * Core answers them only to a viewer it allows to preview (`requireSiteCmsPreviewApiContext`); a
37
- * refusal comes back as 401/403 before anything renders. That is what lets the Area access guard step
38
- * aside for such a request: somebody else has already decided. A review of kind `navigation` or
39
- * `theme` changes neither read -- the Area and the Page come back live, unauthorized -- so it is no
40
- * reason to step aside. Deciding on "any valid review" did exactly that, and
41
- * `?reviewKind=navigation&reviewRevision=1` showed an anonymous visitor a staff Area's shell.
42
- */
43
- export function hasPhiCmsAuthorizedPreviewRead(searchParams) {
44
- if (resolvePhiCmsRevisionFromSearchParams(searchParams) != null) {
45
- return true;
46
- }
47
- const review = resolvePhiCmsReviewParams(searchParams);
48
- return review?.kind === "area" || review?.kind === "page";
49
- }
50
- export function resolvePhiCmsRevisionFromSearchParams(searchParams) {
51
- const rawValue = searchParams?.revision;
52
- if (!rawValue?.trim()) {
53
- return null;
54
- }
55
- const parsed = Number(rawValue);
56
- return Number.isInteger(parsed) && parsed > 0 ? parsed : null;
57
- }
4
+ import { getPhiCmsReviewRevision, resolvePhiCmsReviewParams } from "./cms-review-params";
5
+ export { getPhiCmsReviewRevision, hasPhiCmsAuthorizedPreviewRead, resolvePhiCmsReviewParams, resolvePhiCmsRevisionFromSearchParams, } from "./cms-review-params";
58
6
  export async function resolvePhiCmsThemeReviewRequestContext({ requestContext, searchParams, cookieHeader, }) {
59
7
  const review = resolvePhiCmsReviewParams(searchParams);
60
8
  const themeRevision = getPhiCmsReviewRevision(review, "theme");
@@ -147,6 +147,11 @@ export type PhiCmsNavigationBaseItemDescriptor = {
147
147
  */
148
148
  overlayPresetKey?: string;
149
149
  overlayNodeKey?: string;
150
+ /**
151
+ * Another Area, entered at its root. Mutually exclusive with `routePresetKey` and the Overlay keys; see
152
+ * `PhiCmsNavigationAreaTarget`.
153
+ */
154
+ target?: PhiCmsNavigationAreaTarget;
150
155
  accessPolicy?: PhiViewerAccessPolicy;
151
156
  /**
152
157
  * What this entry sends when it is chosen, instead of going somewhere.
@@ -214,6 +219,21 @@ export type PhiCmsNavigationExternalTarget = {
214
219
  href: string;
215
220
  newTab?: boolean;
216
221
  };
222
+ /**
223
+ * Another Area, entered at its root: the Admin's way into the Builder and back.
224
+ *
225
+ * The root and not a Page in it, because the root is the one address every Area answers whatever
226
+ * Modules it has switched on -- its base Module owns it -- and it forwards to wherever this viewer lands
227
+ * there. A Module Page in another Area is a different question: whether its Module answers there is that
228
+ * Area's fact, which this request never read, so such a reference does not resolve (`REFERENCES.md`).
229
+ *
230
+ * An entry without an `accessPolicy` of its own is shown to whoever the target Area lets in, so it never
231
+ * leads somebody to a door that turns them away. The target must be another Area than the surface's own.
232
+ */
233
+ export type PhiCmsNavigationAreaTarget = {
234
+ kind: "area";
235
+ area: PhiCmsAreaKey;
236
+ };
217
237
  export type PhiCmsNavigationInjectionItemDescriptor = {
218
238
  itemKey: string;
219
239
  label: PhiCmsNavigationLabel;
@@ -226,10 +246,11 @@ export type PhiCmsNavigationInjectionItemDescriptor = {
226
246
  overlayPresetKey?: string;
227
247
  overlayNodeKey?: string;
228
248
  /**
229
- * An address outside the Site. Mutually exclusive with `routePresetKey` and the Overlay keys; resolved
230
- * like a Site's stored external link, so every navigation surface renders it the same way.
249
+ * An address outside the Site, or another Area's root. Mutually exclusive with `routePresetKey` and the
250
+ * Overlay keys. An external address resolves like a Site's stored external link, so every navigation
251
+ * surface renders it the same way; an Area target is `PhiCmsNavigationAreaTarget`.
231
252
  */
232
- target?: PhiCmsNavigationExternalTarget;
253
+ target?: PhiCmsNavigationExternalTarget | PhiCmsNavigationAreaTarget;
233
254
  accessPolicy?: PhiViewerAccessPolicy;
234
255
  /** What this entry sends when it is chosen; see the base item descriptor. */
235
256
  signalRoutes?: {
@@ -290,6 +311,15 @@ export type PhiCmsResolvedNavigationTarget = (PhiCmsPresetIdentity & {
290
311
  path: string;
291
312
  external?: boolean;
292
313
  newTab?: boolean;
314
+ }
315
+ /**
316
+ * Another Area's root. `path` is the Area segment (`/builder`, `/public` for Public), which every
317
+ * renderer already reads as "that Area" rather than as a path in its own (`resolvePhiNavHref`).
318
+ */
319
+ | {
320
+ kind: "area";
321
+ area: PhiCmsAreaKey;
322
+ path: string;
293
323
  };
294
324
  export type PhiCmsResolvedNavigationItem = {
295
325
  id: PhiCmsInstanceId;
package/types/media.d.ts CHANGED
@@ -34,6 +34,7 @@ export type PhiMediaAssetFolder = {
34
34
  };
35
35
  export type { PhiFontMetrics, PhiMediaSpaceKind } from "@phis/contracts/media";
36
36
  import type { PhiFontMetrics } from "@phis/contracts/media";
37
+ import type { MediaFocalRect } from "../components/media/focal-rect";
37
38
  import type { PhiMediaSpaceKind } from "@phis/contracts/media";
38
39
  /**
39
40
  * The Space kinds a Module may declare a need for.
@@ -94,7 +95,9 @@ export type PhiMediaAsset = {
94
95
  blurDataUrl: string | null;
95
96
  thumbnailUrl?: string | null;
96
97
  previewUrl?: string | null;
97
- meta: Record<string, unknown> | null;
98
+ /** The entries of the stored `meta` a client acts on. `meta` itself is the server's. */
99
+ focalRect: MediaFocalRect | null;
100
+ font: PhiFontMetrics | null;
98
101
  title: string | null;
99
102
  altText: string | null;
100
103
  lifecycleStatus: number;
@@ -130,7 +133,8 @@ export type PhiMediaAssetTile = {
130
133
  deliveryRevision: number;
131
134
  presentationFlags: number;
132
135
  blurDataUrl?: string | null;
133
- meta?: Record<string, unknown> | null;
136
+ focalRect: MediaFocalRect | null;
137
+ font: PhiFontMetrics | null;
134
138
  folder?: Pick<PhiMediaAssetFolder, "id" | "name"> | null;
135
139
  };
136
140
  export type PhiMediaPickerState = {