@phis/ui 0.5.4 → 0.5.5

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 (94) hide show
  1. package/components/cms/phi-cms-layout-renderer.js +17 -7
  2. package/components/layouts/clients/phi-flex-layout-client.js +17 -2
  3. package/components/layouts/clients/phi-layout-anchored-overlay.d.ts +2 -0
  4. package/components/layouts/clients/phi-layout-anchored-overlay.js +2 -0
  5. package/components/regions/presets/content-entry-editor-page-tree.js +2 -0
  6. package/components/regions/presets/content-entry-public-page-trees.js +2 -0
  7. package/components/widgets/builder/stack-tabs.d.ts +2 -1
  8. package/components/widgets/builder/stack-tabs.js +18 -2
  9. package/components/widgets/config/choice-shared.d.ts +0 -48
  10. package/components/widgets/config/choice-shared.js +0 -1
  11. package/components/widgets/config/stack-tabs.js +4 -3
  12. package/helpers/config-text-fields.d.ts +49 -0
  13. package/helpers/config-text-fields.js +122 -0
  14. package/helpers/preset-text-source-check.d.ts +22 -0
  15. package/helpers/preset-text-source-check.js +45 -0
  16. package/helpers/text-source.d.ts +14 -5
  17. package/helpers/text-source.js +16 -3
  18. package/module-page-check.d.ts +1 -0
  19. package/module-page-check.js +1 -0
  20. package/package.json +1 -1
  21. package/plugins/runtime/phi-slot-child-frame-view.js +1 -1
  22. package/plugins/runtime/slot-size-policy.d.ts +8 -2
  23. package/plugins/runtime/slot-size-policy.js +51 -16
  24. package/plugins/runtime-modules/accounting/trees/phi-default-accounting-page-tree.js +2 -0
  25. package/plugins/runtime-modules/builder/clients/widget-inspector.js +2 -2
  26. package/plugins/runtime-modules/builder/trees/phi-builder-inspector-area-overlay-tree.server.js +3 -0
  27. package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +11 -0
  28. package/plugins/runtime-modules/core/widgets/button/config.d.ts +0 -1
  29. package/plugins/runtime-modules/core/widgets/button/config.js +0 -1
  30. package/plugins/runtime-modules/core/widgets/button/plugin.js +6 -25
  31. package/plugins/runtime-modules/core/widgets/card/config.d.ts +17 -1
  32. package/plugins/runtime-modules/core/widgets/card/config.js +16 -1
  33. package/plugins/runtime-modules/core/widgets/card/plugin.js +8 -10
  34. package/plugins/runtime-modules/core/widgets/card/server.d.ts +1 -2
  35. package/plugins/runtime-modules/core/widgets/card/server.js +16 -28
  36. package/plugins/runtime-modules/core/widgets/cascader/authoring.d.ts +1 -0
  37. package/plugins/runtime-modules/core/widgets/checkbox-group/config.d.ts +7 -1
  38. package/plugins/runtime-modules/core/widgets/checkbox-group/config.js +1 -1
  39. package/plugins/runtime-modules/core/widgets/description/config.d.ts +1 -0
  40. package/plugins/runtime-modules/core/widgets/entry-list/config.d.ts +1 -1
  41. package/plugins/runtime-modules/core/widgets/entry-list/config.js +0 -1
  42. package/plugins/runtime-modules/core/widgets/entry-list/plugin.js +1 -3
  43. package/plugins/runtime-modules/core/widgets/entry-list/server.d.ts +1 -3
  44. package/plugins/runtime-modules/core/widgets/entry-list/server.js +3 -3
  45. package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +1 -0
  46. package/plugins/runtime-modules/core/widgets/image/server.js +5 -9
  47. package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +1 -0
  48. package/plugins/runtime-modules/core/widgets/markdown-toc/server.js +3 -5
  49. package/plugins/runtime-modules/core/widgets/quick-links/plugin.js +2 -4
  50. package/plugins/runtime-modules/core/widgets/quick-links/server.d.ts +2 -5
  51. package/plugins/runtime-modules/core/widgets/quick-links/server.js +2 -6
  52. package/plugins/runtime-modules/core/widgets/result/config.d.ts +1 -1
  53. package/plugins/runtime-modules/core/widgets/result/config.js +0 -1
  54. package/plugins/runtime-modules/core/widgets/result/plugin.js +2 -4
  55. package/plugins/runtime-modules/core/widgets/result/server.d.ts +2 -3
  56. package/plugins/runtime-modules/core/widgets/result/server.js +11 -33
  57. package/plugins/runtime-modules/core/widgets/simple-text/config.d.ts +1 -0
  58. package/plugins/runtime-modules/core/widgets/slider/config.d.ts +11 -0
  59. package/plugins/runtime-modules/core/widgets/slider/config.js +1 -1
  60. package/plugins/runtime-modules/core/widgets/slot-upload/config.d.ts +0 -1
  61. package/plugins/runtime-modules/core/widgets/slot-upload/config.js +0 -2
  62. package/plugins/runtime-modules/core/widgets/slot-upload/plugin.js +2 -4
  63. package/plugins/runtime-modules/core/widgets/slot-upload/server.d.ts +3 -4
  64. package/plugins/runtime-modules/core/widgets/slot-upload/server.js +5 -13
  65. package/plugins/runtime-modules/core/widgets/spacer/config.d.ts +1 -1
  66. package/plugins/runtime-modules/core/widgets/spacer/config.js +1 -1
  67. package/plugins/runtime-modules/core/widgets/steps/config.d.ts +7 -2
  68. package/plugins/runtime-modules/core/widgets/steps/config.js +1 -2
  69. package/plugins/runtime-modules/core/widgets/steps/plugin.js +6 -30
  70. package/plugins/runtime-modules/core/widgets/table/config.d.ts +3 -0
  71. package/plugins/runtime-modules/core/widgets/table/config.js +1 -1
  72. package/plugins/runtime-modules/core/widgets/timeline/config.d.ts +8 -1
  73. package/plugins/runtime-modules/core/widgets/timeline/config.js +1 -2
  74. package/plugins/runtime-modules/core/widgets/timeline/plugin.js +6 -37
  75. package/plugins/runtime-modules/groups/trees/phi-default-admin-groups-page-tree.js +2 -0
  76. package/plugins/runtime-modules/groups/trees/phi-default-app-groups-page-tree.js +2 -0
  77. package/plugins/runtime-modules/localization/trees/phi-default-editor-translations-page-tree.js +3 -0
  78. package/plugins/runtime-modules/page-preset-overlays.d.ts +18 -0
  79. package/plugins/runtime-modules/page-preset-overlays.js +70 -0
  80. package/plugins/runtime-modules/public/trees/phi-default-pub-welcome-page-tree.js +1 -0
  81. package/plugins/runtime-modules/revisions/trees/phi-default-builder-revisions-page-tree.js +3 -0
  82. package/plugins/runtime-modules/search/widgets/search-box/server.js +3 -5
  83. package/plugins/runtime-modules/search/widgets/search-results/server.js +3 -5
  84. package/plugins/runtime-modules/theme/trees/phi-default-builder-theme-page-tree.js +4 -0
  85. package/plugins/runtime-modules/threads/trees/phi-default-threads-page-tree.js +2 -0
  86. package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +2 -0
  87. package/server-helpers/cms-request.js +34 -12
  88. package/server-helpers/cms-widget-texts.d.ts +14 -0
  89. package/server-helpers/cms-widget-texts.js +117 -0
  90. package/server-helpers/search-index.js +12 -3
  91. package/styles/root.css +6 -2
  92. package/types/cms-plugins.d.ts +30 -5
  93. package/types/core-widget-placements.d.ts +5 -0
  94. package/types/slot-size-policy.d.ts +19 -2
@@ -1,45 +1,14 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { PhiCmsFlags } from "../../../../../constants/phi-cms";
3
- import { hasPhiFlag } from "../../../../../helpers/flags";
4
2
  import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
5
3
  import { PhiRuntimeModuleRenderClientHost } from "../../../../../components/runtime/runtime-module-render-client-manifest";
6
- import { trBulkForLocale } from "../../../../../server-helpers/translate";
7
4
  import { PHI_TIMELINE_WIDGET_DEFINITION } from "./config";
8
- const PHI_TIMELINE_TRANSLATED_FIELDS = ["time", "title", "content"];
9
- /**
10
- * The entries' own words in the reader's language. The time is among them: an author writes "Yesterday"
11
- * or "Spring 2026" as often as a date, and a date that needs no translation comes back as it went.
5
+ /*
6
+ * The entries' own words arrive translated (server-helpers/cms-widget-texts.ts), the time among them: an
7
+ * author writes "Yesterday" or "Spring 2026" as often as a date. A Provider's entries are its own to
8
+ * translate, as an options Provider's are.
12
9
  */
13
- async function translatePhiTimelineConfig(config, runtime, translate) {
14
- /* A Provider's entries are its own to translate, as an options Provider's are. */
15
- if (!translate || config.entriesProvider || config.entries.length === 0)
16
- return config;
17
- const texts = config.entries.flatMap((entry) => PHI_TIMELINE_TRANSLATED_FIELDS.map((field) => entry[field] ?? ""));
18
- const translated = await trBulkForLocale(runtime.locale.current, texts);
19
- const width = PHI_TIMELINE_TRANSLATED_FIELDS.length;
20
- return {
21
- ...config,
22
- entries: config.entries.map((entry, index) => {
23
- const next = { ...entry };
24
- PHI_TIMELINE_TRANSLATED_FIELDS.forEach((field, offset) => {
25
- const source = entry[field];
26
- if (source)
27
- next[field] = translated[index * width + offset]?.trim() || source;
28
- });
29
- return next;
30
- }),
31
- };
32
- }
33
10
  export const PHI_TIMELINE_WIDGET_PLUGIN = {
34
11
  ...PHI_TIMELINE_WIDGET_DEFINITION,
35
- render: async ({ widget, config, runtime }) => (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.Timeline, componentProps: {
36
- blockId: widget.id,
37
- config: await translatePhiTimelineConfig(config, runtime, !hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate)),
38
- locale: runtime.locale.current,
39
- } })),
40
- renderPreview: async ({ widget, config, runtime }) => (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.Timeline, componentProps: {
41
- blockId: widget.id,
42
- config: await translatePhiTimelineConfig(config, runtime, !hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate)),
43
- locale: runtime.locale.current,
44
- } })),
12
+ render: ({ widget, config, runtime }) => (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.Timeline, componentProps: { blockId: widget.id, config, locale: runtime.locale.current } })),
13
+ renderPreview: ({ widget, config, runtime }) => (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.Timeline, componentProps: { blockId: widget.id, config, locale: runtime.locale.current } })),
45
14
  };
@@ -1,3 +1,4 @@
1
+ import { PHI_TEXT_SOURCE_PRESET } from "../../../../helpers/text-source";
1
2
  import { PHI_CMS_DEFAULT_SLOT_INDEX } from "../../../../constants/cms-layout-types";
2
3
  import { PhiCmsPageType } from "../../../../constants/phi-cms";
3
4
  import { PHI_GROUPS_RUNTIME_DATA_PROVIDER_KEYS } from "../ids";
@@ -85,6 +86,7 @@ export async function buildPhiDefaultAdminGroupsPageTree({ page, runtime, }) {
85
86
  label: text.submit,
86
87
  config: {
87
88
  key: `admin-groups-${workflow}-commands`,
89
+ textSource: PHI_TEXT_SOURCE_PRESET,
88
90
  buttons: [
89
91
  { key: "cancel", emits: [{ capabilityId: "close", value: null }], label: labels.actions.cancel, icon: "close" },
90
92
  { key: "save", emits: [{ capabilityId: "submit", value: null }], label: text.submit, variant: "primary", icon: "save" },
@@ -1,3 +1,4 @@
1
+ import { PHI_TEXT_SOURCE_PRESET } from "../../../../helpers/text-source";
1
2
  import { PHI_CMS_DEFAULT_SLOT_INDEX } from "../../../../constants/cms-layout-types";
2
3
  import { PhiCmsPageType } from "../../../../constants/phi-cms";
3
4
  import { PHI_GROUPS_RUNTIME_DATA_PROVIDER_KEYS } from "../ids";
@@ -257,6 +258,7 @@ export async function buildPhiDefaultAppGroupsPageTree({ page, runtime, }) {
257
258
  label: labels.membership.submit,
258
259
  config: {
259
260
  key: "app-groups-membership-commands",
261
+ textSource: PHI_TEXT_SOURCE_PRESET,
260
262
  compact: false,
261
263
  wrap: true,
262
264
  showLabels: true,
@@ -1,3 +1,4 @@
1
+ import { PHI_TEXT_SOURCE_PRESET } from "../../../../helpers/text-source";
1
2
  import { PHI_CMS_DEFAULT_SLOT_INDEX, PHI_CMS_SEQUENTIAL_LAYOUT_SLOTS, } from "../../../../constants/cms-layout-types";
2
3
  import { PhiCmsPageType } from "../../../../constants/phi-cms";
3
4
  import { createPhiCmsPresetNodes } from "../../../../helpers/cms-preset-nodes";
@@ -122,6 +123,7 @@ export async function buildPhiDefaultEditorTranslationsPageTree({ page, runtime,
122
123
  label: "editor source locale",
123
124
  config: {
124
125
  text: sourceLocaleText,
126
+ textSource: PHI_TEXT_SOURCE_PRESET,
125
127
  placeholder: widgetLabels.sourceLocaleLabel,
126
128
  readOnly: true,
127
129
  allowClear: false,
@@ -301,6 +303,7 @@ export async function buildPhiDefaultEditorTranslationsPageTree({ page, runtime,
301
303
  label: "editor translation commands",
302
304
  config: {
303
305
  key: "editor-translation-commands",
306
+ textSource: PHI_TEXT_SOURCE_PRESET,
304
307
  ...PHI_DIALOG_COMMANDS_CONFIG,
305
308
  buttons: [
306
309
  { key: "cancel", emits: [{ capabilityId: "command", value: "cancel" }], label: widgetLabels.actions.cancel, icon: "close" },
@@ -0,0 +1,18 @@
1
+ import type { PhiResolvedCmsPageTree } from "../../types/cms";
2
+ /**
3
+ * Lays the Overlays of a Page preset over a stored Page that answers for it (OVERLAYS.md, "Page
4
+ * preset Overlays").
5
+ *
6
+ * A stored Page holds no copy of an Overlay its preset declares, so the preset's are taken from
7
+ * `presetTree`, the same preset instantiated beside the stored tree: each Overlay, every Layout reachable
8
+ * from its Header, Body and Footer roots, and every Widget under those Layouts, in the preset's order. A
9
+ * stored Overlay with the id of a preset Overlay wins and its preset subtree is left out. Regions, the
10
+ * Page row, Controller settings and every stored node stay as stored; with nothing to take the stored
11
+ * tree itself is returned.
12
+ *
13
+ * The Area precedent is `composePhiCmsActiveAreaOverlayPresets` (descriptor-compiler.ts).
14
+ */
15
+ export declare function composePhiCmsPagePresetOverlays({ tree, presetTree, }: {
16
+ tree: PhiResolvedCmsPageTree;
17
+ presetTree: PhiResolvedCmsPageTree;
18
+ }): PhiResolvedCmsPageTree;
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Lays the Overlays of a Page preset over a stored Page that answers for it (OVERLAYS.md, "Page
3
+ * preset Overlays").
4
+ *
5
+ * A stored Page holds no copy of an Overlay its preset declares, so the preset's are taken from
6
+ * `presetTree`, the same preset instantiated beside the stored tree: each Overlay, every Layout reachable
7
+ * from its Header, Body and Footer roots, and every Widget under those Layouts, in the preset's order. A
8
+ * stored Overlay with the id of a preset Overlay wins and its preset subtree is left out. Regions, the
9
+ * Page row, Controller settings and every stored node stay as stored; with nothing to take the stored
10
+ * tree itself is returned.
11
+ *
12
+ * The Area precedent is `composePhiCmsActiveAreaOverlayPresets` (descriptor-compiler.ts).
13
+ */
14
+ export function composePhiCmsPagePresetOverlays({ tree, presetTree, }) {
15
+ const storedOverlayIds = new Set(tree.overlays.map((node) => node.id));
16
+ const presetOverlays = presetTree.overlays.filter((overlay) => !storedOverlayIds.has(overlay.id));
17
+ if (presetOverlays.length === 0)
18
+ return tree;
19
+ const childLayoutsByParent = new Map();
20
+ for (const layout of presetTree.layoutNodes) {
21
+ if (layout.parentLayoutNodeId === null)
22
+ continue;
23
+ const siblings = childLayoutsByParent.get(layout.parentLayoutNodeId);
24
+ if (siblings)
25
+ siblings.push(layout);
26
+ else
27
+ childLayoutsByParent.set(layout.parentLayoutNodeId, [layout]);
28
+ }
29
+ const layoutsById = new Map(presetTree.layoutNodes.map((layout) => [layout.id, layout]));
30
+ const takenLayoutIds = new Set();
31
+ const visit = (rootId) => {
32
+ if (rootId === null)
33
+ return;
34
+ const stack = [rootId];
35
+ while (stack.length > 0) {
36
+ const id = stack.pop();
37
+ if (takenLayoutIds.has(id))
38
+ continue;
39
+ const layout = layoutsById.get(id);
40
+ if (!layout)
41
+ continue;
42
+ takenLayoutIds.add(id);
43
+ for (const child of childLayoutsByParent.get(id) ?? [])
44
+ stack.push(child.id);
45
+ }
46
+ };
47
+ for (const overlay of presetOverlays) {
48
+ visit(overlay.headerLayoutNodeId);
49
+ visit(overlay.bodyLayoutNodeId);
50
+ visit(overlay.footerLayoutNodeId);
51
+ }
52
+ const layouts = presetTree.layoutNodes.filter((layout) => takenLayoutIds.has(layout.id));
53
+ const widgets = presetTree.contentWidgets.filter((widget) => takenLayoutIds.has(widget.parentLayoutNodeId));
54
+ const occupiedIds = new Set([
55
+ ...tree.layoutNodes.map((node) => node.id),
56
+ ...tree.contentWidgets.map((node) => node.id),
57
+ ]);
58
+ for (const node of [...presetOverlays, ...layouts, ...widgets]) {
59
+ if (occupiedIds.has(node.id)) {
60
+ throw new Error(`Page preset Overlay composition contains duplicate instance id "${node.id}".`);
61
+ }
62
+ occupiedIds.add(node.id);
63
+ }
64
+ return {
65
+ ...tree,
66
+ overlays: [...tree.overlays, ...presetOverlays],
67
+ layoutNodes: [...tree.layoutNodes, ...layouts],
68
+ contentWidgets: [...tree.contentWidgets, ...widgets],
69
+ };
70
+ }
@@ -160,6 +160,7 @@ export async function buildPhiDefaultPubWelcomePageTree({ page, runtime, }) {
160
160
  label: "pub welcome read more button",
161
161
  config: {
162
162
  key: "read-more",
163
+ textSource: PHI_TEXT_SOURCE_PRESET,
163
164
  label: "Read more...",
164
165
  variant: "primary",
165
166
  /*
@@ -1,3 +1,4 @@
1
+ import { PHI_TEXT_SOURCE_PRESET } from "../../../../helpers/text-source";
1
2
  import { PHI_CMS_DEFAULT_SLOT_INDEX, PHI_CMS_SEQUENTIAL_LAYOUT_SLOTS, PHI_CMS_THREE_COLUMN_LAYOUT_SLOT_INDEX, } from "../../../../constants/cms-layout-types";
2
3
  import { PhiCmsFlags, PhiCmsRegionType, PhiCmsStatus } from "../../../../constants/phi-cms";
3
4
  import { createPhiCmsPresetNodes } from "../../../../helpers/cms-preset-nodes";
@@ -227,6 +228,7 @@ export async function buildPhiDefaultBuilderRevisionsPageTree({ page, runtime, }
227
228
  label: "dev revisions area shell delete",
228
229
  config: {
229
230
  key: "revisions-area-shell-delete",
231
+ textSource: PHI_TEXT_SOURCE_PRESET,
230
232
  controlSize: "small",
231
233
  compact: true,
232
234
  showLabels: true,
@@ -350,6 +352,7 @@ export async function buildPhiDefaultBuilderRevisionsPageTree({ page, runtime, }
350
352
  label: "Builder delete area commands",
351
353
  config: {
352
354
  key: "delete-area-commands",
355
+ textSource: PHI_TEXT_SOURCE_PRESET,
353
356
  ...PHI_DIALOG_COMMANDS_CONFIG,
354
357
  buttons: [
355
358
  {
@@ -6,7 +6,6 @@ import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
6
6
  import { resolvePhiLinkHref } from "../../../../../helpers/link-target";
7
7
  import { resolvePhiLinkTargetReferences } from "../../../../../server-helpers/cms-link-targets";
8
8
  import { phiRuntime } from "../../../../../server-helpers/phi-runtime";
9
- import { trBulkForLocale } from "../../../../../server-helpers/translate";
10
9
  import { resolvePhiSearchPageLinkTarget } from "../../page-references";
11
10
  /**
12
11
  * The search box, resolved on the server: where the form goes, what the box says, what it already holds.
@@ -30,10 +29,9 @@ export async function PhiSearchBoxWidget({ config, runtime }) {
30
29
  if (!href) {
31
30
  return null;
32
31
  }
33
- const [labels, [placeholder]] = await Promise.all([
34
- getPhiSearchWidgetLabels({ apiBaseUrl: rt.apiBaseUrl, internalToken: rt.internalToken, locale }),
35
- config?.placeholder ? trBulkForLocale(locale, [config.placeholder]) : [""],
36
- ]);
32
+ // The placeholder arrives translated (server-helpers/cms-widget-texts.ts).
33
+ const placeholder = config?.placeholder ?? "";
34
+ const labels = await getPhiSearchWidgetLabels({ apiBaseUrl: rt.apiBaseUrl, internalToken: rt.internalToken, locale });
37
35
  return (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.SearchBox, componentProps: {
38
36
  labels,
39
37
  config: {
@@ -8,7 +8,6 @@ import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
8
8
  import { resolvePhiNavHref } from "../../../../../helpers/locale";
9
9
  import { fetchPhiSiteSearch } from "../../../../../gateway/site-search";
10
10
  import { phiRuntime } from "../../../../../server-helpers/phi-runtime";
11
- import { trBulkForLocale } from "../../../../../server-helpers/translate";
12
11
  import { readPhiRuntimeTreeRenderMode } from "../../../render-mode";
13
12
  /** The Areas a reader standing in `area` may search (SEARCH.md): App and Public from the App, else Public. */
14
13
  function resolvePhiSearchedAreas(area) {
@@ -33,10 +32,9 @@ export async function PhiSearchResultsWidget({ config, runtime, widgetId }) {
33
32
  const rt = phiRuntime(runtime);
34
33
  const locale = runtime.locale.current;
35
34
  const renderMode = readPhiRuntimeTreeRenderMode(config ?? {});
36
- const [labels, [title]] = await Promise.all([
37
- getPhiSearchResultsWidgetLabels({ apiBaseUrl: rt.apiBaseUrl, internalToken: rt.internalToken, locale }),
38
- config?.title ? trBulkForLocale(locale, [config.title]) : [""],
39
- ]);
35
+ // The heading arrives translated (server-helpers/cms-widget-texts.ts).
36
+ const title = config?.title ?? "";
37
+ const labels = await getPhiSearchResultsWidgetLabels({ apiBaseUrl: rt.apiBaseUrl, internalToken: rt.internalToken, locale });
40
38
  const raw = runtime.request?.searchParams?.[PHI_SEARCH_QUERY_PARAM];
41
39
  const query = readPhiSearchQuery(raw);
42
40
  const base = { title: title || undefined, minLength: PHI_SEARCH_MIN_QUERY_LENGTH };
@@ -1,3 +1,4 @@
1
+ import { PHI_TEXT_SOURCE_PRESET } from "../../../../helpers/text-source";
1
2
  import { PHI_CMS_DEFAULT_SLOT_INDEX, PHI_CMS_SEQUENTIAL_LAYOUT_SLOTS, PHI_CMS_THREE_COLUMN_LAYOUT_SLOT_INDEX, } from "../../../../constants/cms-layout-types";
2
3
  import { PhiCmsFlags, PhiCmsRegionType, PhiCmsStatus } from "../../../../constants/phi-cms";
3
4
  import { createPhiCmsPresetNodes } from "../../../../helpers/cms-preset-nodes";
@@ -357,6 +358,7 @@ export async function buildPhiDefaultBuilderThemePageTree({ page, runtime, regis
357
358
  draft: runtime.site.themeRevision?.workingDraftRevisionId != null,
358
359
  }),
359
360
  key: "brand-theme-preset",
361
+ textSource: PHI_TEXT_SOURCE_PRESET,
360
362
  signalRoutes: {
361
363
  emits: [
362
364
  {
@@ -428,6 +430,7 @@ export async function buildPhiDefaultBuilderThemePageTree({ page, runtime, regis
428
430
  checkedLabel: labels.themeSwitch.dark,
429
431
  uncheckedLabel: labels.themeSwitch.light,
430
432
  key: "brandPreviewThemeMode",
433
+ textSource: PHI_TEXT_SOURCE_PRESET,
431
434
  signalRoutes: {
432
435
  emits: [
433
436
  {
@@ -453,6 +456,7 @@ export async function buildPhiDefaultBuilderThemePageTree({ page, runtime, regis
453
456
  config: {
454
457
  value: "0",
455
458
  valueMode: "stack-slot-index",
459
+ textSource: PHI_TEXT_SOURCE_PRESET,
456
460
  key: PHI_THEME_STACK_SIGNAL_KEY,
457
461
  signalRoutes: {
458
462
  emits: [
@@ -1,3 +1,4 @@
1
+ import { PHI_TEXT_SOURCE_PRESET } from "../../../../helpers/text-source";
1
2
  import { PHI_CMS_DEFAULT_SLOT_INDEX } from "../../../../constants/cms-layout-types";
2
3
  import { PhiCmsFlags, PhiCmsPageType } from "../../../../constants/phi-cms";
3
4
  import { createPhiCmsPresetNodes } from "../../../../helpers/cms-preset-nodes";
@@ -643,6 +644,7 @@ export async function buildPhiDefaultThreadsPageTree({ page, runtime, area, }) {
643
644
  label: labels.openConversationLabel,
644
645
  config: {
645
646
  key: "app-threads-new-commands",
647
+ textSource: PHI_TEXT_SOURCE_PRESET,
646
648
  ...PHI_DIALOG_COMMANDS_CONFIG,
647
649
  buttons: [
648
650
  { key: "cancel", emits: [{ capabilityId: "command", value: "cancel" }], label: labels.cancelLabel, icon: "close" },
@@ -1,3 +1,4 @@
1
+ import { PHI_TEXT_SOURCE_PRESET } from "../../../../helpers/text-source";
1
2
  import { PHI_CMS_DEFAULT_SLOT_INDEX, } from "../../../../constants/cms-layout-types";
2
3
  import { PhiCmsPageType } from "../../../../constants/phi-cms";
3
4
  import { createPhiCmsPresetNodes } from "../../../../helpers/cms-preset-nodes";
@@ -543,6 +544,7 @@ export async function buildPhiDefaultAdminUsersPageTree({ page, runtime, }) {
543
544
  label: `admin users ${mode} commands`,
544
545
  config: {
545
546
  key: `admin-users-${mode}-commands`,
547
+ textSource: PHI_TEXT_SOURCE_PRESET,
546
548
  ...PHI_DIALOG_COMMANDS_CONFIG,
547
549
  buttons: [
548
550
  { key: "cancel", emits: [{ capabilityId: "command", value: "cancel" }], label: widgetLabels.confirm.cancel, icon: "close" },
@@ -5,6 +5,7 @@ import { resolvePhiCmsAreaKey, resolvePhiCmsAreaMask, } from "../constants/cms-a
5
5
  import { canPhiViewerAccess } from "../types/access";
6
6
  import { compilePhiCmsActiveRouteTable, instantiatePhiCmsRoutePreset, normalizePhiCmsRoutePath, resolvePhiCmsAreaShellPresetBinding, resolvePhiCmsDescriptorCatalog, resolvePhiCmsRoutePreset, } from "../plugins/runtime-modules/descriptor-compiler";
7
7
  import { resolvePhiRuntimeModuleIdsForArea } from "../plugins/runtime-modules/settings";
8
+ import { composePhiCmsPagePresetOverlays } from "../plugins/runtime-modules/page-preset-overlays";
8
9
  import { resolvePhiCmsRoutePage } from "../plugins/runtime-modules/route-page-resolution";
9
10
  import { PhiCmsFlags } from "../constants/phi-cms";
10
11
  import { hasPhiFlag } from "../helpers/flags";
@@ -239,20 +240,43 @@ export async function resolvePhiCmsRequest({ siteKey, locale, area, path, cookie
239
240
  const routeBinding = areaOwnedStoragePath && areaAllowed
240
241
  ? resolvePhiCmsRoutePreset(routeTable, areaOwnedStoragePath)
241
242
  : null;
242
- const loadedPage = await resolvePhiCmsRoutePage({
243
+ const presetOrigin = { instantiated: false };
244
+ const instantiateRoutePreset = (binding) => instantiatePhiRoutePresetPage({
245
+ binding,
246
+ requestedPath: path,
247
+ areaMask,
248
+ siteId,
249
+ runtime: runtimeWithAuthProvider,
250
+ runtimeModuleCatalog,
251
+ activeModuleKeys,
252
+ });
253
+ const routePage = await resolvePhiCmsRoutePage({
243
254
  binding: routeBinding,
244
255
  requestedPath: path,
245
256
  loadPage: loadResolvedCmsPage,
246
- instantiatePreset: (binding) => instantiatePhiRoutePresetPage({
247
- binding,
248
- requestedPath: path,
249
- areaMask,
250
- siteId,
251
- runtime: runtimeWithAuthProvider,
252
- runtimeModuleCatalog,
253
- activeModuleKeys,
254
- }),
257
+ instantiatePreset: (binding) => {
258
+ presetOrigin.instantiated = true;
259
+ return instantiateRoutePreset(binding);
260
+ },
255
261
  });
262
+ const routePresetAnswered = routePage?.sourcePreset?.presetKey === routeBinding?.descriptor.presetKey
263
+ && routePage?.sourcePreset?.ownerModuleId === routeBinding?.descriptor.ownerModuleId;
264
+ /*
265
+ * A stored Page that answers for the route's preset holds no copy of the Overlays the preset declares;
266
+ * they are laid over it here, from the preset instantiated beside it (OVERLAYS.md, "Page preset
267
+ * Overlays"). The instantiated preset already has them, an exact Site Page of a dynamic route is its own
268
+ * Page, and a lookup renders nothing.
269
+ */
270
+ const presetOverlayPage = purpose !== "lookup" && routePage && routeBinding && routePresetAnswered
271
+ && !presetOrigin.instantiated
272
+ ? await instantiateRoutePreset(routeBinding)
273
+ : null;
274
+ const loadedPage = routePage && presetOverlayPage
275
+ ? {
276
+ ...routePage,
277
+ page: composePhiCmsPagePresetOverlays({ tree: routePage.page, presetTree: presetOverlayPage.page }),
278
+ }
279
+ : routePage;
256
280
  /*
257
281
  * The record the Page is about, where its route names one: read once, here, for the Module's own tree
258
282
  * and for a stored override of it alike -- the override holds no address, only Widgets bound to the
@@ -260,8 +284,6 @@ export async function resolvePhiCmsRequest({ siteKey, locale, area, path, cookie
260
284
  * names no record is no Page: a 404 while rendering, nothing for a lookup.
261
285
  */
262
286
  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
287
  const pageRecord = loadedPage && routeBinding && routeIsParametrised && routePresetAnswered
266
288
  ? await resolvePhiCmsPageRecord({
267
289
  binding: routeBinding,
@@ -0,0 +1,14 @@
1
+ import "server-only";
2
+ import type { PhiBlockRuntime } from "../types";
3
+ import type { PhiResolvedCmsRenderableTree } from "../types/cms";
4
+ import type { PhiCmsRuntimeRenderRegistry, PhiCmsWidgetPluginDefinition } from "../types/cms-plugins";
5
+ export type PhiWidgetTextDefinition = Partial<Pick<PhiCmsWidgetPluginDefinition<unknown>, "fields" | "translatesOwnText" | "configTexts">>;
6
+ export type PhiWidgetTextSubject = {
7
+ id: string;
8
+ flags: number;
9
+ config: Record<string, unknown>;
10
+ definition: PhiWidgetTextDefinition | null | undefined;
11
+ };
12
+ /** Each subject's config with its words translated, keyed by id; a subject with none is not in the map. */
13
+ export declare function translatePhiWidgetConfigTexts(subjects: readonly PhiWidgetTextSubject[], runtime: PhiBlockRuntime): Promise<Map<string, Record<string, unknown>>>;
14
+ export declare function translatePhiCmsTreeWidgetTexts<TTree extends PhiResolvedCmsRenderableTree>(tree: TTree, registry: Pick<PhiCmsRuntimeRenderRegistry, "runtimeWidgetPluginsByType" | "previewWidgetPluginsByType">, runtime: PhiBlockRuntime): Promise<TTree>;
@@ -0,0 +1,117 @@
1
+ import "server-only";
2
+ import { PHI_TR_CTX_WEB_UI_LABEL, PHI_TR_CTX_WEB_UI_MESSAGE } from "../gateway/tr";
3
+ import { PhiCmsFlags } from "../constants/phi-cms";
4
+ import { collectPhiConfigTexts, collectPhiDeclaredConfigTexts, writePhiConfigTexts, } from "../helpers/config-text-fields";
5
+ import { hasPhiFlag } from "../helpers/flags";
6
+ import { maskPhiTextPlaceholders, resolvePhiTextPlaceholders } from "../helpers/text-placeholders";
7
+ import { PHI_TEXT_SOURCE_PRESET, readPhiTextSource } from "../helpers/text-source";
8
+ import { trBulkForLocale, trGlobalBulkForLocale } from "./translate";
9
+ /**
10
+ * The words in Widget configs in the reader's language, translated in one pass for a page.
11
+ *
12
+ * Translating is the rule, not something each Widget remembers: which fields are text is answered by
13
+ * their names (`helpers/config-text-fields.ts`), a text no field edits is declared by the Widget
14
+ * (`configTexts`), and every Widget is handed its config with those already in the reader's language. A
15
+ * Widget that `translatesOwnText` is left out -- a Markdown body is parsed into units before it is
16
+ * translated, and its author may want it left as written, which is why only such content Widgets carry
17
+ * the `NoTranslate` switch. A node a Preset flagged `NoTranslate` holds words it read from a Label Set in
18
+ * the reader's language already: nothing of it is sent, its placeholders are only filled in.
19
+ *
20
+ * Every text is masked before it is sent and filled after (`helpers/text-placeholders.ts`): `{site.name}`
21
+ * never reaches a translator, and a list entry's values stand as `%1` onwards, so "Up to %1 users" is
22
+ * translated once for every Site.
23
+ *
24
+ * The store is whose words they are (`helpers/text-source.ts`): a Preset's go to the platform's store,
25
+ * an author's to the Site's. One request per store and register, whatever the number of Widgets. The
26
+ * search index reads a Page's words through the same pass (`server-helpers/search-index.ts`).
27
+ */
28
+ const CTX_BY_REGISTER = {
29
+ label: PHI_TR_CTX_WEB_UI_LABEL,
30
+ message: PHI_TR_CTX_WEB_UI_MESSAGE,
31
+ };
32
+ function collectSubjectTexts(subject) {
33
+ const { definition } = subject;
34
+ if (!definition || definition.translatesOwnText)
35
+ return [];
36
+ const located = [
37
+ ...collectPhiConfigTexts(definition.fields ?? [], subject.config),
38
+ ...collectPhiDeclaredConfigTexts(definition.configTexts ?? [], subject.config),
39
+ ];
40
+ const seen = new Set();
41
+ return located.filter((location) => {
42
+ const key = location.path.join("\u0000");
43
+ if (seen.has(key))
44
+ return false;
45
+ seen.add(key);
46
+ return true;
47
+ });
48
+ }
49
+ /** Each subject's config with its words translated, keyed by id; a subject with none is not in the map. */
50
+ export async function translatePhiWidgetConfigTexts(subjects, runtime) {
51
+ const pending = subjects
52
+ .map((subject) => ({
53
+ subject,
54
+ batch: readPhiTextSource(subject.config.textSource) === PHI_TEXT_SOURCE_PRESET ? "global" : "site",
55
+ // Filled in all the same: a value or `{year}` is not a word, and a node left as written still shows it.
56
+ translate: !hasPhiFlag(subject.flags, PhiCmsFlags.NoTranslate),
57
+ locations: collectSubjectTexts(subject).map((location) => ({
58
+ location,
59
+ masked: maskPhiTextPlaceholders(location.text, location.values?.length ?? 0),
60
+ })),
61
+ }))
62
+ .filter((entry) => entry.locations.length > 0);
63
+ const configs = new Map();
64
+ if (pending.length === 0)
65
+ return configs;
66
+ const batches = new Map();
67
+ const positions = pending.map((entry) => entry.locations.map(({ location, masked }) => {
68
+ if (!entry.translate)
69
+ return null;
70
+ const key = `${entry.batch}:${location.register}`;
71
+ let texts = batches.get(key);
72
+ if (!texts) {
73
+ texts = [];
74
+ batches.set(key, texts);
75
+ }
76
+ texts.push(masked.text);
77
+ return { key, index: texts.length - 1 };
78
+ }));
79
+ const locale = runtime.locale.current;
80
+ const answers = new Map(await Promise.all([...batches].map(async ([key, texts]) => {
81
+ const [store, register] = key.split(":");
82
+ const ctx = CTX_BY_REGISTER[register];
83
+ const translated = store === "global"
84
+ ? await trGlobalBulkForLocale(locale, texts, ctx)
85
+ : await trBulkForLocale(locale, texts, ctx);
86
+ return [key, translated];
87
+ })));
88
+ pending.forEach((entry, entryIndex) => {
89
+ configs.set(entry.subject.id, writePhiConfigTexts(entry.subject.config, entry.locations.map(({ location, masked }, index) => {
90
+ const position = positions[entryIndex][index];
91
+ const translated = (position && answers.get(position.key)?.[position.index]?.trim()) || masked.text;
92
+ return {
93
+ path: location.path,
94
+ text: resolvePhiTextPlaceholders(translated, masked.names, runtime, location.values ?? []),
95
+ };
96
+ })));
97
+ });
98
+ return configs;
99
+ }
100
+ export async function translatePhiCmsTreeWidgetTexts(tree, registry, runtime) {
101
+ const configs = await translatePhiWidgetConfigTexts(tree.contentWidgets.map((widget) => ({
102
+ id: widget.id,
103
+ flags: widget.flags,
104
+ config: widget.config,
105
+ definition: registry.runtimeWidgetPluginsByType.get(widget.widgetType)
106
+ ?? registry.previewWidgetPluginsByType.get(widget.widgetType),
107
+ })), runtime);
108
+ if (configs.size === 0)
109
+ return tree;
110
+ return {
111
+ ...tree,
112
+ contentWidgets: tree.contentWidgets.map((widget) => {
113
+ const config = configs.get(widget.id);
114
+ return config ? { ...widget, config } : widget;
115
+ }),
116
+ };
117
+ }
@@ -1,4 +1,5 @@
1
1
  import "server-only";
2
+ import { translatePhiWidgetConfigTexts } from "./cms-widget-texts";
2
3
  import { createHash } from "node:crypto";
3
4
  import { PHI_SHARED_PACKAGE_NAME } from "../constants/package";
4
5
  import { createPhiRuntimeModuleId } from "../constants/module-identity";
@@ -315,12 +316,20 @@ async function readDocument({ bridge, area, locale, context, path, loadPlugin, a
315
316
  });
316
317
  const lines = await runWithPhiRequestRuntime(resolved.runtime, async () => {
317
318
  const collected = [];
318
- for (const widget of visible.contentWidgets) {
319
- const plugin = await loadPlugin(widget.widgetType);
319
+ const plugins = await Promise.all(visible.contentWidgets.map((widget) => loadPlugin(widget.widgetType)));
320
+ // The words as the render shows them: translated by the same pass (`server-helpers/cms-widget-texts.ts`).
321
+ const translatedConfigs = await translatePhiWidgetConfigTexts(visible.contentWidgets.map((widget, index) => ({
322
+ id: widget.id,
323
+ flags: widget.flags,
324
+ config: widget.config,
325
+ definition: plugins[index]?.searchText ? plugins[index] : null,
326
+ })), resolved.runtime);
327
+ for (const [index, widget] of visible.contentWidgets.entries()) {
328
+ const plugin = plugins[index];
320
329
  if (!plugin?.searchText)
321
330
  continue;
322
331
  try {
323
- const config = plugin.parseConfig(widget.config);
332
+ const config = plugin.parseConfig(translatedConfigs.get(widget.id) ?? widget.config);
324
333
  collected.push(...await plugin.searchText({ widget, config, runtime: resolved.runtime }));
325
334
  }
326
335
  catch (error) {
package/styles/root.css CHANGED
@@ -73,15 +73,19 @@ samp {
73
73
  }
74
74
 
75
75
  :where(.phi-tab-bar.ant-tabs) {
76
- height: 100%;
77
76
  line-height: 1;
78
77
  }
79
78
 
80
79
  :where(.phi-tab-bar.ant-tabs > .ant-tabs-nav) {
81
- height: 100%;
82
80
  margin: 0;
83
81
  }
84
82
 
83
+ /* Left and right placement fill the block axis (the Tab bar's `slotSizePolicy`); top and bottom are as high as their content. */
84
+ :where(.phi-tab-bar.ant-tabs-left, .phi-tab-bar.ant-tabs-right),
85
+ :where(.phi-tab-bar.ant-tabs-left > .ant-tabs-nav, .phi-tab-bar.ant-tabs-right > .ant-tabs-nav) {
86
+ height: 100%;
87
+ }
88
+
85
89
  :where(.phi-tab-bar.ant-tabs > .ant-tabs-content-holder) {
86
90
  flex: 0 0 0;
87
91
  min-width: 0;